Changeset 34599 for trunk/src/wp-includes/class-wp-comment.php
- Timestamp:
- 09/26/2015 04:01:05 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-comment.php
r34595 r34599 158 158 */ 159 159 protected $children; 160 161 /** 162 * Post fields. 163 * 164 * @since 4.4.0 165 * @access protected 166 * @var array 167 */ 168 protected $post_fields = array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_content_filtered', 'post_parent', 'guid', 'menu_order', 'post_type', 'post_mime_type', 'comment_count' ); 160 169 161 170 /** … … 323 332 324 333 /** 325 * Whether a comment has post from which to retrieve magic properties 326 * 327 * @since 4.4.0 328 * @access public 329 * 330 * @param string $name 334 * Check whether a non-public property is set. 335 * 336 * If `$name` matches a post field, the comment post will be loaded and the post's value checked. 337 * 338 * @since 4.4.0 339 * @access public 340 * 341 * @param string $name Property name. 331 342 * @return bool 332 343 */ 333 344 public function __isset( $name ) { 334 if ( 335 0 === (int) $this->comment_post_ID 336 || property_exists( $this, $name ) 337 ) { 338 return; 339 } 340 341 $post = get_post( $this->comment_post_ID ); 342 if ( $post ) { 345 if ( in_array( $name, $this->post_fields ) && 0 !== (int) $this->comment_post_ID ) { 346 $post = get_post( $this->comment_post_ID ); 343 347 return property_exists( $post, $name ); 344 348 } … … 346 350 347 351 /** 348 * Magic getter for $post properties 352 * Magic getter. 353 * 354 * If `$name` matches a post field, the comment post will be loaded and the post's value returned. 349 355 * 350 356 * @since 4.4.0 … … 355 361 */ 356 362 public function __get( $name ) { 357 $post = get_post( $this->comment_post_ID );358 if ( $post ) {363 if ( in_array( $name, $this->post_fields ) ) { 364 $post = get_post( $this->comment_post_ID ); 359 365 return $post->$name; 360 366 }
Note: See TracChangeset
for help on using the changeset viewer.