WP_Comment::__get
Magic getter.
If $name matches a post field, the comment post will be loaded and the post's value returned.
Метод класса: WP_Comment{}
Хуков нет.
Возвращает
mixed.
Использование
$WP_Comment = new WP_Comment(); $WP_Comment->__get( $name );
- $name(строка) (обязательный)
- Property name.
Список изменений
| С версии 4.4.0 | Введена. |
| С версии 7.1.0 | Returns null instead of the global post's field when the comment is not attached to a post, and no longer raises a warning when the comment's post cannot be found. |
Код WP_Comment::__get() WP Comment:: get WP 7.1
public function __get( $name ) {
if ( in_array( $name, $this->post_fields, true ) && 0 !== (int) $this->comment_post_ID ) {
$post = get_post( (int) $this->comment_post_ID );
if ( ! $post ) {
return null;
}
return $post->$name;
}
return null;
}