Changeset 34569 for trunk/src/wp-includes/class-wp-comment.php
- Timestamp:
- 09/26/2015 02:24:17 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-comment.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-comment.php
r34561 r34569 228 228 * @access public 229 229 * 230 * @param string $format Return value format. 'tree' for a hierarchical tree, 'flat' for a flattened array. 231 * Default 'tree'. 230 * @param array $args { 231 * Array of arguments used to pass to get_comments() and determine format. 232 * 233 * @type string $format Return value format. 'tree' for a hierarchical tree, 'flat' for a flattened array. 234 * Default 'tree'. 235 * @type string $status Comment status to limit results by. Accepts 'hold' (`comment_status=0`), 236 * 'approve' (`comment_status=1`), 'all', or a custom comment status. 237 * Default 'all'. 238 * @type string $hierarchical Whether to include comment descendants in the results. 239 * 'threaded' returns a tree, with each comment's children 240 * stored in a `children` property on the `WP_Comment` object. 241 * 'flat' returns a flat array of found comments plus their children. 242 * Pass `false` to leave out descendants. 243 * The parameter is ignored (forced to `false`) when `$fields` is 'ids' or 'counts'. 244 * Accepts 'threaded', 'flat', or false. Default: 'threaded'. 245 * @type string|array $orderby Comment status or array of statuses. To use 'meta_value' 246 * or 'meta_value_num', `$meta_key` must also be defined. 247 * To sort by a specific `$meta_query` clause, use that 248 * clause's array key. Accepts 'comment_agent', 249 * 'comment_approved', 'comment_author', 250 * 'comment_author_email', 'comment_author_IP', 251 * 'comment_author_url', 'comment_content', 'comment_date', 252 * 'comment_date_gmt', 'comment_ID', 'comment_karma', 253 * 'comment_parent', 'comment_post_ID', 'comment_type', 254 * 'user_id', 'comment__in', 'meta_value', 'meta_value_num', 255 * the value of $meta_key, and the array keys of 256 * `$meta_query`. Also accepts false, an empty array, or 257 * 'none' to disable `ORDER BY` clause. 258 * } 232 259 * @return array Array of `WP_Comment` objects. 233 260 */ 234 public function get_children( $format = 'tree' ) { 261 public function get_children( $args = array() ) { 262 $defaults = array( 263 'format' => 'tree', 264 'status' => 'all', 265 'hierarchical' => 'threaded', 266 'orderby' => '', 267 ); 268 269 $_args = wp_parse_args( $args, $defaults ); 270 $_args['parent'] = $this->comment_ID; 271 235 272 if ( is_null( $this->children ) ) { 236 $this->children = get_comments( array( 237 'parent' => $this->comment_ID, 238 'hierarchical' => 'threaded', 239 ) ); 240 } 241 242 if ( 'flat' === $format ) { 273 $this->children = get_comments( $_args ); 274 } 275 276 if ( 'flat' === $_args['format'] ) { 243 277 $children = array(); 244 278 foreach ( $this->children as $child ) { 245 $children = array_merge( $children, array( $child ), $child->get_children( 'flat' ) ); 279 $child_args = $_args; 280 $child_args['format'] = 'flat'; 281 // get_children() resets this value automatically. 282 unset( $child_args['parent'] ); 283 284 $children = array_merge( $children, array( $child ), $child->get_children( $child_args ) ); 246 285 } 247 286 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)