Commit Graph

4 Commits

Author SHA1 Message Date
Boone Gorges
fc854a837f Introduce hierarchical query support to WP_Comment_Query.
Comments can be threaded. Now your query can be threaded too! Bonus: it's
not totally insane.

* The new `$hierarchical` parameter for `WP_Comment_Query` accepts three values:
  * `false` - Default value, and equivalent to current behavior. No descendants are fetched for matched comments.
  * `'flat'` - `WP_Comment_Query` will fetch the descendant tree for each comment matched by the query paramaters, and append them to the flat array of comments returned. Use this when you have a separate routine for constructing the tree - for example, when passing a list of comments to a `Walker` object.
  * `'threaded'` - `WP_Comment_Query` will fetch the descendant tree for each comment, and return it in a tree structure located in the `children` property of the `WP_Comment` objects.
* `WP_Comment` now has a few utility methods for fetching the descendant tree (`get_children()`), fetching a single direct descendant comment (`get_child()`), and adding anothing `WP_Comment` object as a direct descendant (`add_child()`). Note that `add_child()` only modifies the comment object - it does not touch the database.

Props boonebgorges, wonderboymusic.
See #8071.
Built from https://develop.svn.wordpress.org/trunk@34546


git-svn-id: http://core.svn.wordpress.org/trunk@34510 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 15:13:24 +00:00
Drew Jaynes
8df8fb6046 Docs: The Comment API is singular.
See #33701.

Built from https://develop.svn.wordpress.org/trunk@34409


git-svn-id: http://core.svn.wordpress.org/trunk@34373 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 13:43:25 +00:00
Drew Jaynes
54c2cabf66 Docs: Add complete file, class, property, and method documentation for the new WP_Comment class, introduced in [33891].
It's important for new functionality, especially something as significant as a new class to have complete documentation upon initial commit – not after the fact.

See #32619.

Built from https://develop.svn.wordpress.org/trunk@33893


git-svn-id: http://core.svn.wordpress.org/trunk@33862 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-03 19:58:24 +00:00
Scott Taylor
e73ee5ac98 Introduce WP_Comment class to model/strongly-type rows from the comments database table. Inclusion of this class is a pre-req for some more general comment cleanup and sanity.
* Takes inspiration from `WP_Post` and adds sanity to comment caching. 
* Clarifies when the current global value for `$comment` is returned. The current implementation in `get_comment()` introduces side effects and an occasion stale global value for `$comment` when comment caches are cleaned.
* Strongly-types `@param` docs
* This class is marked `final` for now

Props wonderboymusic, nacin.

See #32619.

Built from https://develop.svn.wordpress.org/trunk@33891


git-svn-id: http://core.svn.wordpress.org/trunk@33860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-03 18:17:24 +00:00