Better Wordpress threaded comments
Here is something slightly different, I’m trying to get into the habit of writing out my notes and detailed changes in INAP 3.0 for my own use, so I thought they may help others in the process. The following walk through details the process I took to create a method to thread comments for Wordpress. Most of the project specific code has been removed to keep the code from being cluttered.
The threading structure for the plugin needed to be able to handle an unlimited number of children in an order, and the ability to “flatten” the children after a certain user-specified depth (shown in the code examples as $max_depth). The threading structure needed to be rewritten because in short, the old version (seen here) worked by individually querying the database for each comment to look for children, utilized globals to pass information from one section to another, used a complex method of if/elses to determine what functions should do, and was very slow.

