Uses
Uses | Description |
---|---|
wp-includes/compat.php: hash_equals() | Timing attack safe string comparison |
Checks if the user can access password-protected content.
This method determines whether we need to override the regular password check in core with a filter.
(WP_Post) (Required) Post to check against.
(WP_REST_Request) (Required) Request data to check.
(bool) True if the user can access password-protected content, otherwise false.
File: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
public function can_access_password_content( $post, $request ) { if ( empty( $post->post_password ) ) { // No filter required. return false; } // Edit context always gets access to password-protected posts. if ( 'edit' === $request['context'] ) { return true; } // No password, no auth. if ( empty( $request['password'] ) ) { return false; } // Double-check the request password. return hash_equals( $post->post_password, $request['password'] ); }
Version | Description |
---|---|
4.7.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/can_access_password_content