- Timestamp:
- 06/10/2019 07:41:12 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r45424 r45507 4870 4870 check_ajax_referer( 'health-check-site-status' ); 4871 4871 4872 if ( ! current_user_can( ' install_plugins' ) ) {4872 if ( ! current_user_can( 'view_site_health_checks' ) ) { 4873 4873 wp_send_json_error(); 4874 4874 } … … 4890 4890 wp_verify_nonce( 'health-check-site-status' ); 4891 4891 4892 if ( ! current_user_can( ' install_plugins' ) ) {4892 if ( ! current_user_can( 'view_site_health_checks' ) ) { 4893 4893 wp_send_json_error(); 4894 4894 } … … 4910 4910 check_ajax_referer( 'health-check-site-status' ); 4911 4911 4912 if ( ! current_user_can( ' install_plugins' ) ) {4912 if ( ! current_user_can( 'view_site_health_checks' ) ) { 4913 4913 wp_send_json_error(); 4914 4914 } … … 4931 4931 check_ajax_referer( 'health-check-site-status' ); 4932 4932 4933 if ( ! current_user_can( ' install_plugins' ) ) {4933 if ( ! current_user_can( 'view_site_health_checks' ) ) { 4934 4934 wp_send_json_error(); 4935 4935 } … … 4951 4951 check_ajax_referer( 'health-check-site-status-result' ); 4952 4952 4953 if ( ! current_user_can( ' install_plugins' ) ) {4953 if ( ! current_user_can( 'view_site_health_checks' ) ) { 4954 4954 wp_send_json_error(); 4955 4955 } … … 4968 4968 check_ajax_referer( 'health-check-site-status-result' ); 4969 4969 4970 if ( ! current_user_can( ' install_plugins' ) || is_multisite() ) {4970 if ( ! current_user_can( 'view_site_health_checks' ) || is_multisite() ) { 4971 4971 wp_send_json_error(); 4972 4972 } -
trunk/src/wp-admin/menu.php
r45448 r45507 264 264 $submenu['tools.php'][10] = array( __( 'Import' ), 'import', 'import.php' ); 265 265 $submenu['tools.php'][15] = array( __( 'Export' ), 'export', 'export.php' ); 266 $submenu['tools.php'][20] = array( __( 'Site Health' ), ' install_plugins', 'site-health.php' );266 $submenu['tools.php'][20] = array( __( 'Site Health' ), 'view_site_health_checks', 'site-health.php' ); 267 267 $submenu['tools.php'][25] = array( __( 'Export Personal Data' ), 'export_others_personal_data', 'export-personal-data.php' ); 268 268 $submenu['tools.php'][30] = array( __( 'Erase Personal Data' ), 'erase_others_personal_data', 'erase-personal-data.php' ); -
trunk/src/wp-admin/site-health-info.php
r45259 r45507 12 12 $title = __( 'Site Health Info' ); 13 13 14 if ( ! current_user_can( ' install_plugins' ) ) {14 if ( ! current_user_can( 'view_site_health_checks' ) ) { 15 15 wp_die( __( 'Sorry, you are not allowed to access the debug data.' ), '', 403 ); 16 16 } -
trunk/src/wp-admin/site-health.php
r45488 r45507 17 17 $title = __( 'Site Health Status' ); 18 18 19 if ( ! current_user_can( ' install_plugins' ) ) {19 if ( ! current_user_can( 'view_site_health_checks' ) ) { 20 20 wp_die( __( 'Sorry, you are not allowed to access site health information.' ), '', 403 ); 21 21 } -
trunk/src/wp-includes/capabilities.php
r45419 r45507 1026 1026 } 1027 1027 1028 /** 1029 * Filters the user capabilities to grant the 'view_site_health_checks' capabilities as necessary. 1030 * 1031 * @since 5.2.2 1032 * 1033 * @param bool[] $allcaps An array of all the user's capabilities. 1034 * @param string[] $caps Required primitive capabilities for the requested capability. 1035 * @param array $args { 1036 * Arguments that accompany the requested capability check. 1037 * 1038 * @type string $0 Requested capability. 1039 * @type int $1 Concerned user ID. 1040 * @type mixed ...$2 Optional second and further parameters, typically object ID. 1041 * } 1042 * @param WP_User $user The user object. 1043 * @return bool[] Filtered array of the user's capabilities. 1044 */ 1045 function wp_maybe_grant_site_health_caps( $allcaps, $caps, $args, $user ) { 1046 if ( ! empty( $allcaps['install_plugins'] ) && ( ! is_multisite() || is_super_admin( $user->ID ) ) ) { 1047 $allcaps['view_site_health_checks'] = true; 1048 } 1049 1050 return $allcaps; 1051 } 1052 1028 1053 return; 1029 1054 -
trunk/src/wp-includes/default-filters.php
r44973 r45507 581 581 add_filter( 'user_has_cap', 'wp_maybe_grant_install_languages_cap', 1 ); 582 582 add_filter( 'user_has_cap', 'wp_maybe_grant_resume_extensions_caps', 1 ); 583 add_filter( 'user_has_cap', 'wp_maybe_grant_site_health_caps', 1, 4 ); 583 584 584 585 unset( $filter, $action ); -
trunk/tests/phpunit/tests/user/capabilities.php
r44973 r45507 77 77 return array( 78 78 79 'unfiltered_html' => array( 'administrator', 'editor' ), 80 81 'activate_plugins' => array( 'administrator' ), 82 'create_users' => array( 'administrator' ), 83 'delete_plugins' => array( 'administrator' ), 84 'delete_themes' => array( 'administrator' ), 85 'delete_users' => array( 'administrator' ), 86 'edit_files' => array( 'administrator' ), 87 'edit_plugins' => array( 'administrator' ), 88 'edit_themes' => array( 'administrator' ), 89 'edit_users' => array( 'administrator' ), 90 'install_plugins' => array( 'administrator' ), 91 'install_themes' => array( 'administrator' ), 92 'update_core' => array( 'administrator' ), 93 'update_plugins' => array( 'administrator' ), 94 'update_themes' => array( 'administrator' ), 95 'edit_theme_options' => array( 'administrator' ), 96 'export' => array( 'administrator' ), 97 'import' => array( 'administrator' ), 98 'list_users' => array( 'administrator' ), 99 'manage_options' => array( 'administrator' ), 100 'promote_users' => array( 'administrator' ), 101 'remove_users' => array( 'administrator' ), 102 'switch_themes' => array( 'administrator' ), 103 'edit_dashboard' => array( 'administrator' ), 104 'resume_plugins' => array( 'administrator' ), 105 'resume_themes' => array( 'administrator' ), 106 107 'moderate_comments' => array( 'administrator', 'editor' ), 108 'manage_categories' => array( 'administrator', 'editor' ), 109 'edit_others_posts' => array( 'administrator', 'editor' ), 110 'edit_pages' => array( 'administrator', 'editor' ), 111 'edit_others_pages' => array( 'administrator', 'editor' ), 112 'edit_published_pages' => array( 'administrator', 'editor' ), 113 'publish_pages' => array( 'administrator', 'editor' ), 114 'delete_pages' => array( 'administrator', 'editor' ), 115 'delete_others_pages' => array( 'administrator', 'editor' ), 116 'delete_published_pages' => array( 'administrator', 'editor' ), 117 'delete_others_posts' => array( 'administrator', 'editor' ), 118 'delete_private_posts' => array( 'administrator', 'editor' ), 119 'edit_private_posts' => array( 'administrator', 'editor' ), 120 'read_private_posts' => array( 'administrator', 'editor' ), 121 'delete_private_pages' => array( 'administrator', 'editor' ), 122 'edit_private_pages' => array( 'administrator', 'editor' ), 123 'read_private_pages' => array( 'administrator', 'editor' ), 124 125 'edit_published_posts' => array( 'administrator', 'editor', 'author' ), 126 'upload_files' => array( 'administrator', 'editor', 'author' ), 127 'publish_posts' => array( 'administrator', 'editor', 'author' ), 128 'delete_published_posts' => array( 'administrator', 'editor', 'author' ), 129 130 'edit_posts' => array( 'administrator', 'editor', 'author', 'contributor' ), 131 'delete_posts' => array( 'administrator', 'editor', 'author', 'contributor' ), 132 133 'read' => array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ), 134 135 'level_10' => array( 'administrator' ), 136 'level_9' => array( 'administrator' ), 137 'level_8' => array( 'administrator' ), 138 'level_7' => array( 'administrator', 'editor' ), 139 'level_6' => array( 'administrator', 'editor' ), 140 'level_5' => array( 'administrator', 'editor' ), 141 'level_4' => array( 'administrator', 'editor' ), 142 'level_3' => array( 'administrator', 'editor' ), 143 'level_2' => array( 'administrator', 'editor', 'author' ), 144 'level_1' => array( 'administrator', 'editor', 'author', 'contributor' ), 145 'level_0' => array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ), 146 147 'administrator' => array( 'administrator' ), 148 'editor' => array( 'editor' ), 149 'author' => array( 'author' ), 150 'contributor' => array( 'contributor' ), 151 'subscriber' => array( 'subscriber' ), 79 'unfiltered_html' => array( 'administrator', 'editor' ), 80 81 'activate_plugins' => array( 'administrator' ), 82 'create_users' => array( 'administrator' ), 83 'delete_plugins' => array( 'administrator' ), 84 'delete_themes' => array( 'administrator' ), 85 'delete_users' => array( 'administrator' ), 86 'edit_files' => array( 'administrator' ), 87 'edit_plugins' => array( 'administrator' ), 88 'edit_themes' => array( 'administrator' ), 89 'edit_users' => array( 'administrator' ), 90 'install_plugins' => array( 'administrator' ), 91 'install_themes' => array( 'administrator' ), 92 'update_core' => array( 'administrator' ), 93 'update_plugins' => array( 'administrator' ), 94 'update_themes' => array( 'administrator' ), 95 'edit_theme_options' => array( 'administrator' ), 96 'export' => array( 'administrator' ), 97 'import' => array( 'administrator' ), 98 'list_users' => array( 'administrator' ), 99 'manage_options' => array( 'administrator' ), 100 'promote_users' => array( 'administrator' ), 101 'remove_users' => array( 'administrator' ), 102 'switch_themes' => array( 'administrator' ), 103 'edit_dashboard' => array( 'administrator' ), 104 'resume_plugins' => array( 'administrator' ), 105 'resume_themes' => array( 'administrator' ), 106 'view_site_health_checks' => array( 'administrator' ), 107 108 'moderate_comments' => array( 'administrator', 'editor' ), 109 'manage_categories' => array( 'administrator', 'editor' ), 110 'edit_others_posts' => array( 'administrator', 'editor' ), 111 'edit_pages' => array( 'administrator', 'editor' ), 112 'edit_others_pages' => array( 'administrator', 'editor' ), 113 'edit_published_pages' => array( 'administrator', 'editor' ), 114 'publish_pages' => array( 'administrator', 'editor' ), 115 'delete_pages' => array( 'administrator', 'editor' ), 116 'delete_others_pages' => array( 'administrator', 'editor' ), 117 'delete_published_pages' => array( 'administrator', 'editor' ), 118 'delete_others_posts' => array( 'administrator', 'editor' ), 119 'delete_private_posts' => array( 'administrator', 'editor' ), 120 'edit_private_posts' => array( 'administrator', 'editor' ), 121 'read_private_posts' => array( 'administrator', 'editor' ), 122 'delete_private_pages' => array( 'administrator', 'editor' ), 123 'edit_private_pages' => array( 'administrator', 'editor' ), 124 'read_private_pages' => array( 'administrator', 'editor' ), 125 126 'edit_published_posts' => array( 'administrator', 'editor', 'author' ), 127 'upload_files' => array( 'administrator', 'editor', 'author' ), 128 'publish_posts' => array( 'administrator', 'editor', 'author' ), 129 'delete_published_posts' => array( 'administrator', 'editor', 'author' ), 130 131 'edit_posts' => array( 'administrator', 'editor', 'author', 'contributor' ), 132 'delete_posts' => array( 'administrator', 'editor', 'author', 'contributor' ), 133 134 'read' => array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ), 135 136 'level_10' => array( 'administrator' ), 137 'level_9' => array( 'administrator' ), 138 'level_8' => array( 'administrator' ), 139 'level_7' => array( 'administrator', 'editor' ), 140 'level_6' => array( 'administrator', 'editor' ), 141 'level_5' => array( 'administrator', 'editor' ), 142 'level_4' => array( 'administrator', 'editor' ), 143 'level_3' => array( 'administrator', 'editor' ), 144 'level_2' => array( 'administrator', 'editor', 'author' ), 145 'level_1' => array( 'administrator', 'editor', 'author', 'contributor' ), 146 'level_0' => array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ), 147 148 'administrator' => array( 'administrator' ), 149 'editor' => array( 'editor' ), 150 'author' => array( 'author' ), 151 'contributor' => array( 'contributor' ), 152 'subscriber' => array( 'subscriber' ), 152 153 153 154 ); … … 158 159 return array( 159 160 160 'unfiltered_html' => array(), 161 162 'activate_plugins' => array(), 163 'create_users' => array(), 164 'delete_plugins' => array(), 165 'delete_themes' => array(), 166 'delete_users' => array(), 167 'edit_files' => array(), 168 'edit_plugins' => array(), 169 'edit_themes' => array(), 170 'edit_users' => array(), 171 'install_plugins' => array(), 172 'install_themes' => array(), 173 'update_core' => array(), 174 'update_plugins' => array(), 175 'update_themes' => array(), 176 177 'edit_theme_options' => array( 'administrator' ), 178 'export' => array( 'administrator' ), 179 'import' => array( 'administrator' ), 180 'list_users' => array( 'administrator' ), 181 'manage_options' => array( 'administrator' ), 182 'promote_users' => array( 'administrator' ), 183 'remove_users' => array( 'administrator' ), 184 'switch_themes' => array( 'administrator' ), 185 'edit_dashboard' => array( 'administrator' ), 186 'resume_plugins' => array( 'administrator' ), 187 'resume_themes' => array( 'administrator' ), 188 189 'moderate_comments' => array( 'administrator', 'editor' ), 190 'manage_categories' => array( 'administrator', 'editor' ), 191 'edit_others_posts' => array( 'administrator', 'editor' ), 192 'edit_pages' => array( 'administrator', 'editor' ), 193 'edit_others_pages' => array( 'administrator', 'editor' ), 194 'edit_published_pages' => array( 'administrator', 'editor' ), 195 'publish_pages' => array( 'administrator', 'editor' ), 196 'delete_pages' => array( 'administrator', 'editor' ), 197 'delete_others_pages' => array( 'administrator', 'editor' ), 198 'delete_published_pages' => array( 'administrator', 'editor' ), 199 'delete_others_posts' => array( 'administrator', 'editor' ), 200 'delete_private_posts' => array( 'administrator', 'editor' ), 201 'edit_private_posts' => array( 'administrator', 'editor' ), 202 'read_private_posts' => array( 'administrator', 'editor' ), 203 'delete_private_pages' => array( 'administrator', 'editor' ), 204 'edit_private_pages' => array( 'administrator', 'editor' ), 205 'read_private_pages' => array( 'administrator', 'editor' ), 206 207 'edit_published_posts' => array( 'administrator', 'editor', 'author' ), 208 'upload_files' => array( 'administrator', 'editor', 'author' ), 209 'publish_posts' => array( 'administrator', 'editor', 'author' ), 210 'delete_published_posts' => array( 'administrator', 'editor', 'author' ), 211 212 'edit_posts' => array( 'administrator', 'editor', 'author', 'contributor' ), 213 'delete_posts' => array( 'administrator', 'editor', 'author', 'contributor' ), 214 215 'read' => array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ), 216 217 'level_10' => array( 'administrator' ), 218 'level_9' => array( 'administrator' ), 219 'level_8' => array( 'administrator' ), 220 'level_7' => array( 'administrator', 'editor' ), 221 'level_6' => array( 'administrator', 'editor' ), 222 'level_5' => array( 'administrator', 'editor' ), 223 'level_4' => array( 'administrator', 'editor' ), 224 'level_3' => array( 'administrator', 'editor' ), 225 'level_2' => array( 'administrator', 'editor', 'author' ), 226 'level_1' => array( 'administrator', 'editor', 'author', 'contributor' ), 227 'level_0' => array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ), 228 229 'administrator' => array( 'administrator' ), 230 'editor' => array( 'editor' ), 231 'author' => array( 'author' ), 232 'contributor' => array( 'contributor' ), 233 'subscriber' => array( 'subscriber' ), 161 'unfiltered_html' => array(), 162 163 'activate_plugins' => array(), 164 'create_users' => array(), 165 'delete_plugins' => array(), 166 'delete_themes' => array(), 167 'delete_users' => array(), 168 'edit_files' => array(), 169 'edit_plugins' => array(), 170 'edit_themes' => array(), 171 'edit_users' => array(), 172 'install_plugins' => array(), 173 'install_themes' => array(), 174 'update_core' => array(), 175 'update_plugins' => array(), 176 'update_themes' => array(), 177 'view_site_health_checks' => array(), 178 179 'edit_theme_options' => array( 'administrator' ), 180 'export' => array( 'administrator' ), 181 'import' => array( 'administrator' ), 182 'list_users' => array( 'administrator' ), 183 'manage_options' => array( 'administrator' ), 184 'promote_users' => array( 'administrator' ), 185 'remove_users' => array( 'administrator' ), 186 'switch_themes' => array( 'administrator' ), 187 'edit_dashboard' => array( 'administrator' ), 188 'resume_plugins' => array( 'administrator' ), 189 'resume_themes' => array( 'administrator' ), 190 191 'moderate_comments' => array( 'administrator', 'editor' ), 192 'manage_categories' => array( 'administrator', 'editor' ), 193 'edit_others_posts' => array( 'administrator', 'editor' ), 194 'edit_pages' => array( 'administrator', 'editor' ), 195 'edit_others_pages' => array( 'administrator', 'editor' ), 196 'edit_published_pages' => array( 'administrator', 'editor' ), 197 'publish_pages' => array( 'administrator', 'editor' ), 198 'delete_pages' => array( 'administrator', 'editor' ), 199 'delete_others_pages' => array( 'administrator', 'editor' ), 200 'delete_published_pages' => array( 'administrator', 'editor' ), 201 'delete_others_posts' => array( 'administrator', 'editor' ), 202 'delete_private_posts' => array( 'administrator', 'editor' ), 203 'edit_private_posts' => array( 'administrator', 'editor' ), 204 'read_private_posts' => array( 'administrator', 'editor' ), 205 'delete_private_pages' => array( 'administrator', 'editor' ), 206 'edit_private_pages' => array( 'administrator', 'editor' ), 207 'read_private_pages' => array( 'administrator', 'editor' ), 208 209 'edit_published_posts' => array( 'administrator', 'editor', 'author' ), 210 'upload_files' => array( 'administrator', 'editor', 'author' ), 211 'publish_posts' => array( 'administrator', 'editor', 'author' ), 212 'delete_published_posts' => array( 'administrator', 'editor', 'author' ), 213 214 'edit_posts' => array( 'administrator', 'editor', 'author', 'contributor' ), 215 'delete_posts' => array( 'administrator', 'editor', 'author', 'contributor' ), 216 217 'read' => array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ), 218 219 'level_10' => array( 'administrator' ), 220 'level_9' => array( 'administrator' ), 221 'level_8' => array( 'administrator' ), 222 'level_7' => array( 'administrator', 'editor' ), 223 'level_6' => array( 'administrator', 'editor' ), 224 'level_5' => array( 'administrator', 'editor' ), 225 'level_4' => array( 'administrator', 'editor' ), 226 'level_3' => array( 'administrator', 'editor' ), 227 'level_2' => array( 'administrator', 'editor', 'author' ), 228 'level_1' => array( 'administrator', 'editor', 'author', 'contributor' ), 229 'level_0' => array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ), 230 231 'administrator' => array( 'administrator' ), 232 'editor' => array( 'editor' ), 233 'author' => array( 'author' ), 234 'contributor' => array( 'contributor' ), 235 'subscriber' => array( 'subscriber' ), 234 236 235 237 ); … … 398 400 $actual['subscriber'], 399 401 $actual['contributor'], 400 // the following twoare granted via `user_has_cap`:402 // The following are granted via `user_has_cap`: 401 403 $actual['resume_plugins'], 402 $actual['resume_themes'] 404 $actual['resume_themes'], 405 $actual['view_site_health_checks'] 403 406 ); 404 407 … … 1201 1204 $this->assertFalse( $contributor->has_cap( 'edit_post', $post ) ); 1202 1205 $this->assertFalse( $contributor->has_cap( 'delete_post', $post ) ); 1203 $this->assertEquals( $status === 'publish', $contributor->has_cap( 'read_post', $post ) );1206 $this->assertEquals( 'publish' === $status, $contributor->has_cap( 'read_post', $post ) ); 1204 1207 } 1205 1208
Note: See TracChangeset
for help on using the changeset viewer.