Changeset 34546 for trunk/src/wp-includes/class-wp-comment.php
- Timestamp:
- 09/25/2015 03:12:09 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-comment.php
r34409 r34546 151 151 152 152 /** 153 * Comment children. 154 * 155 * @since 4.4.0 156 * @access protected 157 * @var array 158 */ 159 protected $children; 160 161 /** 153 162 * Retrieves a WP_Comment instance. 154 163 * … … 212 221 return get_object_vars( $this ); 213 222 } 223 224 /** 225 * Get the children of a comment. 226 * 227 * @since 4.4.0 228 * @access public 229 * 230 * @return array Array of `WP_Comment` objects. 231 */ 232 public function get_children() { 233 if ( is_null( $this->children ) ) { 234 $this->children = get_comments( array( 235 'parent' => $this->comment_ID, 236 'hierarchical' => 'threaded', 237 ) ); 238 } 239 240 return $this->children; 241 } 242 243 /** 244 * Add a child to the comment. 245 * 246 * Used by `WP_Comment_Query` when bulk-filling descendants. 247 * 248 * @since 4.4.0 249 * @access public 250 * 251 * @param WP_Comment $child Child comment. 252 */ 253 public function add_child( WP_Comment $child ) { 254 $this->comments[ $child->comment_ID ] = $child; 255 } 256 257 /** 258 * Get a child comment by ID. 259 * 260 * @since 4.4.0 261 * @access public 262 * 263 * @param int $child_id ID of the child. 264 * @return WP_Comment|bool Returns the comment object if found, otherwise false. 265 */ 266 public function get_child( $child_id ) { 267 if ( isset( $this->comments[ $child_id ] ) ) { 268 return $this->comments[ $child_id ]; 269 } 270 271 return false; 272 } 214 273 }
Note: See TracChangeset
for help on using the changeset viewer.