WordPress.org

Make WordPress Core

Ticket #46957: 46957.3.diff

File 46957.3.diff, 10.6 KB (added by palmiak, 15 months ago)
  • wp-admin/includes/ajax-actions.php

    diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php
    index 0f1f0f4..0dee29d 100644
    a b function wp_ajax_wp_privacy_erase_personal_data() { 
    48694869function wp_ajax_health_check_dotorg_communication() {
    48704870        check_ajax_referer( 'health-check-site-status' );
    48714871
    4872         if ( ! current_user_can( 'install_plugins' ) ) {
     4872        if ( ! current_user_can( 'view_health_statuses' ) ) {
    48734873                wp_send_json_error();
    48744874        }
    48754875
    function wp_ajax_health_check_dotorg_communication() { 
    48894889function wp_ajax_health_check_is_in_debug_mode() {
    48904890        wp_verify_nonce( 'health-check-site-status' );
    48914891
    4892         if ( ! current_user_can( 'install_plugins' ) ) {
     4892        if ( ! current_user_can( 'view_health_statuses' ) ) {
    48934893                wp_send_json_error();
    48944894        }
    48954895
    function wp_ajax_health_check_is_in_debug_mode() { 
    49094909function wp_ajax_health_check_background_updates() {
    49104910        check_ajax_referer( 'health-check-site-status' );
    49114911
    4912         if ( ! current_user_can( 'install_plugins' ) ) {
     4912        if ( ! current_user_can( 'view_health_statuses' ) ) {
    49134913                wp_send_json_error();
    49144914        }
    49154915
    function wp_ajax_health_check_background_updates() { 
    49304930function wp_ajax_health_check_loopback_requests() {
    49314931        check_ajax_referer( 'health-check-site-status' );
    49324932
    4933         if ( ! current_user_can( 'install_plugins' ) ) {
     4933        if ( ! current_user_can( 'view_health_statuses' ) ) {
    49344934                wp_send_json_error();
    49354935        }
    49364936
    function wp_ajax_health_check_loopback_requests() { 
    49504950function wp_ajax_health_check_site_status_result() {
    49514951        check_ajax_referer( 'health-check-site-status-result' );
    49524952
    4953         if ( ! current_user_can( 'install_plugins' ) ) {
     4953        if ( ! current_user_can( 'view_health_statuses' ) ) {
    49544954                wp_send_json_error();
    49554955        }
    49564956
    function wp_ajax_health_check_site_status_result() { 
    49674967function wp_ajax_health_check_get_sizes() {
    49684968        check_ajax_referer( 'health-check-site-status-result' );
    49694969
    4970         if ( ! current_user_can( 'install_plugins' ) || is_multisite() ) {
     4970        if ( ! current_user_can( 'view_health_statuses' ) || is_multisite() ) {
    49714971                wp_send_json_error();
    49724972        }
    49734973
  • wp-admin/menu.php

    diff --git a/wp-admin/menu.php b/wp-admin/menu.php
    index d126339..f7cc775 100644
    a b $menu[75] = array( __( 'Tools' ), 'edit_posts', 'tools.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_health_statuses', 'site-health.php' );
    267267if ( is_multisite() && ! is_main_site() ) {
    268268        $submenu['tools.php'][25] = array( __( 'Delete Site' ), 'delete_site', 'ms-delete-site.php' );
    269269}
  • wp-admin/site-health-info.php

    diff --git a/wp-admin/site-health-info.php b/wp-admin/site-health-info.php
    index 42f2be0..8e095b2 100644
    a b require_once( dirname( __FILE__ ) . '/admin.php' ); 
    1111
    1212$title = __( 'Site Health Info' );
    1313
    14 if ( ! current_user_can( 'install_plugins' ) ) {
     14if ( ! current_user_can( 'view_health_statuses' ) ) {
    1515        wp_die( __( 'Sorry, you are not allowed to access the debug data.' ), '', 403 );
    1616}
    1717
  • wp-admin/site-health.php

    diff --git a/wp-admin/site-health.php b/wp-admin/site-health.php
    index 2c59626..4bcd927 100644
    a b require_once( dirname( __FILE__ ) . '/admin.php' ); 
    1616
    1717$title = __( 'Site Health Status' );
    1818
    19 if ( ! current_user_can( 'install_plugins' ) ) {
     19if ( ! current_user_can( 'view_health_statuses' ) ) {
    2020        wp_die( __( 'Sorry, you are not allowed to access site health information.' ), '', 403 );
    2121}
    2222
  • wp-includes/capabilities.php

    diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php
    index 640ca6f..6b4550d 100644
    a b function wp_maybe_grant_resume_extensions_caps( $allcaps ) { 
    979979        return $allcaps;
    980980}
    981981
     982/**
     983 * Filters the user capabilities to grant the 'view_health_statuses' 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_health_statuses'] = true;
     994        }
     995
     996        return $allcaps;
     997}
     998
    982999return;
    9831000
    9841001// Dummy gettext calls to get strings in the catalog.
  • wp-includes/default-filters.php

    diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php
    index ecdc87c..eb1c222 100644
    a b add_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3 ); 
    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 );