WP_REST_Posts_Controller::check_password_required()
Overrides the result of the post password check for REST requested posts.
Allow users to read the content of password protected posts if they have previously passed a permission check or if they have the edit_post for the post being checked.
Метод класса: WP_REST_Posts_Controller{}
Хуков нет.
Возвращает
true|false
. Result of password check taking in to account REST API considerations.
Использование
$WP_REST_Posts_Controller = new WP_REST_Posts_Controller(); $WP_REST_Posts_Controller->check_password_required( $required, $post );
- $required(true|false) (обязательный)
- Whether the post requires a password check.
- $post(WP_Post) (обязательный)
- The post been password checked.
Список изменений
С версии 5.7.1 | Введена. |
Код WP_REST_Posts_Controller::check_password_required() WP REST Posts Controller::check password required WP 6.6.2
public function check_password_required( $required, $post ) { if ( ! $required ) { return $required; } $post = get_post( $post ); if ( ! $post ) { return $required; } if ( ! empty( $this->password_check_passed[ $post->ID ] ) ) { // Password previously checked and approved. return false; } return ! current_user_can( 'edit_post', $post->ID ); }