WP_REST_Post_Statuses_Controller::check_read_permission()
Checks whether a given post status should be visible.
Метод класса: WP_REST_Post_Statuses_Controller{}
Хуков нет.
Возвращает
true|false
. True if the post status is visible, otherwise false.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->check_read_permission( $status );
- $status(объект) (обязательный)
- Post status.
Список изменений
С версии 4.7.0 | Введена. |
Код WP_REST_Post_Statuses_Controller::check_read_permission() WP REST Post Statuses Controller::check read permission WP 6.7.1
protected function check_read_permission( $status ) { if ( true === $status->public ) { return true; } if ( false === $status->internal || 'trash' === $status->name ) { $types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); foreach ( $types as $type ) { if ( current_user_can( $type->cap->edit_posts ) ) { return true; } } } return false; }