WP_REST_Terms_Controller::check_read_terms_permission_for_post()
Checks if the terms for a post can be read.
Метод класса: WP_REST_Terms_Controller{}
Хуков нет.
Возвращает
true|false
. Whether the terms for the post can be read.
Использование
$WP_REST_Terms_Controller = new WP_REST_Terms_Controller(); $WP_REST_Terms_Controller->check_read_terms_permission_for_post( $post, $request );
- $post(WP_Post) (обязательный)
- Post object.
- $request(WP_REST_Request) (обязательный)
- Full details about the request.
Список изменений
С версии 6.0.3 | Введена. |
Код WP_REST_Terms_Controller::check_read_terms_permission_for_post() WP REST Terms Controller::check read terms permission for post WP 6.7.1
public function check_read_terms_permission_for_post( $post, $request ) { // If the requested post isn't associated with this taxonomy, deny access. if ( ! is_object_in_taxonomy( $post->post_type, $this->taxonomy ) ) { return false; } // Grant access if the post is publicly viewable. if ( is_post_publicly_viewable( $post ) ) { return true; } // Otherwise grant access if the post is readable by the logged-in user. if ( current_user_can( 'read_post', $post->ID ) ) { return true; } // Otherwise, deny access. return false; }