WP_REST_Comments_Controller::check_read_permission()
Checks if the comment can be read.
Метод класса: WP_REST_Comments_Controller{}
Хуков нет.
Возвращает
true|false
. Whether the comment can be read.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->check_read_permission( $comment, $request );
- $comment(WP_Comment) (обязательный)
- Comment object.
- $request(WP_REST_Request) (обязательный)
- Request data to check.
Список изменений
С версии 4.7.0 | Введена. |
Код WP_REST_Comments_Controller::check_read_permission() WP REST Comments Controller::check read permission WP 6.2.2
protected function check_read_permission( $comment, $request ) { if ( ! empty( $comment->comment_post_ID ) ) { $post = get_post( $comment->comment_post_ID ); if ( $post ) { if ( $this->check_read_post_permission( $post, $request ) && 1 === (int) $comment->comment_approved ) { return true; } } } if ( 0 === get_current_user_id() ) { return false; } if ( empty( $comment->comment_post_ID ) && ! current_user_can( 'moderate_comments' ) ) { return false; } if ( ! empty( $comment->user_id ) && get_current_user_id() === (int) $comment->user_id ) { return true; } return current_user_can( 'edit_comment', $comment->comment_ID ); }