WordPress.org

Make WordPress Core

Ticket #46957: 46957.2.diff

File 46957.2.diff, 2.9 KB (added by spacedmonkey, 19 months ago)
  • src/wp-admin/menu.php

     
    263263        $submenu['tools.php'][5]  = array( __( 'Available Tools' ), 'edit_posts', 'tools.php' );
    264264        $submenu['tools.php'][10] = array( __( 'Import' ), 'import', 'import.php' );
    265265        $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', 'site-health.php' );
    267267if ( is_multisite() && ! is_main_site() ) {
    268268        $submenu['tools.php'][25] = array( __( 'Delete Site' ), 'delete_site', 'ms-delete-site.php' );
    269269}
  • src/wp-admin/site-health-info.php

     
    1111
    1212$title = __( 'Site Health Info' );
    1313
    14 if ( ! current_user_can( 'install_plugins' ) ) {
     14if ( ! current_user_can( 'view_site_health' ) ) {
    1515        wp_die( __( 'Sorry, you are not allowed to access the debug data.' ), '', 403 );
    1616}
    1717
  • src/wp-admin/site-health.php

     
    1616
    1717$title = __( 'Site Health Status' );
    1818
    19 if ( ! current_user_can( 'install_plugins' ) ) {
     19if ( ! current_user_can( 'view_site_health' ) ) {
    2020        wp_die( __( 'Sorry, you are not allowed to access site health information.' ), '', 403 );
    2121}
    2222
  • src/wp-includes/capabilities.php

     
    979979        return $allcaps;
    980980}
    981981
     982/**
     983 * Filters the user capabilities to grant the 'view_site_health' capabilities as necessary.
     984 *
     985 * @since 5.2.0
     986 *
     987 * @param bool[] $allcaps An array of all the user's capabilities.
     988 * @return bool[] Filtered array of the user's capabilities.
     989 */
     990function wp_maybe_grant_site_health_caps( $allcaps ) {
     991
     992        if ( ! empty( $allcaps['install_plugins'] ) ) {
     993                $allcaps['view_site_health'] = true;
     994        }
     995
     996        return $allcaps;
     997}
     998
    982999return;
    9831000
    9841001// Dummy gettext calls to get strings in the catalog.
  • src/wp-includes/default-filters.php

     
    580580// Capabilities
    581581add_filter( 'user_has_cap', 'wp_maybe_grant_install_languages_cap', 1 );
    582582add_filter( 'user_has_cap', 'wp_maybe_grant_resume_extensions_caps', 1 );
     583add_filter( 'user_has_cap', 'wp_maybe_grant_site_health_caps', 1 );
    583584
    584585unset( $filter, $action );