diff --git a/wp-admin/about.php b/wp-admin/about.php index bcc3cd6e65..d496e1b044 100644 --- a/wp-admin/about.php +++ b/wp-admin/about.php @@ -36,6 +36,26 @@ include( ABSPATH . 'wp-admin/admin-header.php' );

+

+ Version %s addressed some security issues.' ), + '5.1.9' + ); + ?> + the release notes.' ), + sprintf( + /* translators: %s: WordPress version */ + esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ), + sanitize_title( '5.1.9' ) + ) + ); + ?> +

password_check_passed[ $post->ID ] ) ) { + // Password previously checked and approved. + return false; + } + + return ! current_user_can( 'edit_post', $post->ID ); + } + /** * Retrieves a collection of posts. * @@ -300,7 +340,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { // Allow access to all password protected posts if the context is edit. if ( 'edit' === $request['context'] ) { - add_filter( 'post_password_required', '__return_false' ); + add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 ); } $posts = array(); @@ -316,7 +356,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { // Reset filter. if ( 'edit' === $request['context'] ) { - remove_filter( 'post_password_required', '__return_false' ); + remove_filter( 'post_password_required', array( $this, 'check_password_required' ) ); } $page = (int) $query_args['paged']; @@ -414,7 +454,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { // Allow access to all password protected posts if the context is edit. if ( 'edit' === $request['context'] ) { - add_filter( 'post_password_required', '__return_false' ); + add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 ); } if ( $post ) { @@ -442,8 +482,14 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { return false; } - // Edit context always gets access to password-protected posts. - if ( 'edit' === $request['context'] ) { + /* + * Users always gets access to password protected content in the edit + * context if they have the `edit_post` meta capability. + */ + if ( + 'edit' === $request['context'] && + current_user_can( 'edit_post', $post->ID ) + ) { return true; } @@ -1519,8 +1565,9 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { $has_password_filter = false; if ( $this->can_access_password_content( $post, $request ) ) { + $this->password_check_passed[ $post->ID ] = true; // Allow access to the post, permissions already checked before. - add_filter( 'post_password_required', '__return_false' ); + add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 ); $has_password_filter = true; } @@ -1547,7 +1594,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { if ( $has_password_filter ) { // Reset filter. - remove_filter( 'post_password_required', '__return_false' ); + remove_filter( 'post_password_required', array( $this, 'check_password_required' ) ); } if ( in_array( 'author', $fields, true ) ) {