equal
deleted
inserted
replaced
160 |
160 |
161 /** |
161 /** |
162 * Retrieves a WP_Comment instance. |
162 * Retrieves a WP_Comment instance. |
163 * |
163 * |
164 * @since 4.4.0 |
164 * @since 4.4.0 |
165 * @static |
|
166 * |
165 * |
167 * @global wpdb $wpdb WordPress database abstraction object. |
166 * @global wpdb $wpdb WordPress database abstraction object. |
168 * |
167 * |
169 * @param int $id Comment ID. |
168 * @param int $id Comment ID. |
170 * @return WP_Comment|false Comment object, otherwise false. |
169 * @return WP_Comment|false Comment object, otherwise false. |
254 * } |
253 * } |
255 * @return array Array of `WP_Comment` objects. |
254 * @return array Array of `WP_Comment` objects. |
256 */ |
255 */ |
257 public function get_children( $args = array() ) { |
256 public function get_children( $args = array() ) { |
258 $defaults = array( |
257 $defaults = array( |
259 'format' => 'tree', |
258 'format' => 'tree', |
260 'status' => 'all', |
259 'status' => 'all', |
261 'hierarchical' => 'threaded', |
260 'hierarchical' => 'threaded', |
262 'orderby' => '', |
261 'orderby' => '', |
263 ); |
262 ); |
264 |
263 |
265 $_args = wp_parse_args( $args, $defaults ); |
264 $_args = wp_parse_args( $args, $defaults ); |
266 $_args['parent'] = $this->comment_ID; |
265 $_args['parent'] = $this->comment_ID; |
267 |
266 |
268 if ( is_null( $this->children ) ) { |
267 if ( is_null( $this->children ) ) { |
269 if ( $this->populated_children ) { |
268 if ( $this->populated_children ) { |
270 $this->children = array(); |
269 $this->children = array(); |
274 } |
273 } |
275 |
274 |
276 if ( 'flat' === $_args['format'] ) { |
275 if ( 'flat' === $_args['format'] ) { |
277 $children = array(); |
276 $children = array(); |
278 foreach ( $this->children as $child ) { |
277 foreach ( $this->children as $child ) { |
279 $child_args = $_args; |
278 $child_args = $_args; |
280 $child_args['format'] = 'flat'; |
279 $child_args['format'] = 'flat'; |
281 // get_children() resets this value automatically. |
280 // get_children() resets this value automatically. |
282 unset( $child_args['parent'] ); |
281 unset( $child_args['parent'] ); |
283 |
282 |
284 $children = array_merge( $children, array( $child ), $child->get_children( $child_args ) ); |
283 $children = array_merge( $children, array( $child ), $child->get_children( $child_args ) ); |