Make WordPress Core


Ignore:
Timestamp:
04/17/2021 01:12:25 AM (5 years ago)
Author:
Clorith
Message:

Site Health: Support custom sub-menus and pages.

Allow developers to extend the Site Health screen with their own custom navigation tabs and pages.

This implements a new filter, site_health_navigation_tabs, which takes an associated array of tab identifiers/slugs, and tab labels, allowing developers to add their own subpage to the Site Health interface as new tabs.

To output a custom page, or add to an existing page, the site_health_tab_content action is triggered whenever the tab query argument is present and not empty. This action includes the current tab as its argument, which a developer would match against to only output content when relevant.

Props ramiy for initial patch.
Fixes #47225.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/site-health-info.php

    r48233 r50764  
    77 */
    88
    9 /** WordPress Administration Bootstrap */
    10 require_once __DIR__ . '/admin.php';
    11 
    12 $title = __( 'Site Health Info' );
    13 
    14 if ( ! current_user_can( 'view_site_health_checks' ) ) {
    15         wp_die( __( 'Sorry, you are not allowed to access the debug data.' ), '', 403 );
     9if ( ! defined( 'ABSPATH' ) ) {
     10        die();
    1611}
    17 
    18 wp_enqueue_style( 'site-health' );
    19 wp_enqueue_script( 'site-health' );
    2012
    2113if ( ! class_exists( 'WP_Debug_Data' ) ) {
     
    2719
    2820$health_check_site_status = WP_Site_Health::get_instance();
    29 
    30 require_once ABSPATH . 'wp-admin/admin-header.php';
    3121?>
    32 <div class="health-check-header">
    33         <div class="health-check-title-section">
    34                 <h1>
    35                         <?php _e( 'Site Health' ); ?>
    36                 </h1>
    37         </div>
    38 
    39         <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js">
    40                 <div class="site-health-progress">
    41                         <svg role="img" aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
    42                                 <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
    43                                 <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
    44                         </svg>
    45                 </div>
    46                 <div class="site-health-progress-label">
    47                         <?php _e( 'Results are still loading&hellip;' ); ?>
    48                 </div>
    49         </div>
    50 
    51         <nav class="health-check-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
    52                 <a href="<?php echo esc_url( admin_url( 'site-health.php' ) ); ?>" class="health-check-tab">
    53                         <?php
    54                         /* translators: Tab heading for Site Health Status page. */
    55                         _ex( 'Status', 'Site Health' );
    56                         ?>
    57                 </a>
    58 
    59                 <a href="<?php echo esc_url( admin_url( 'site-health.php?tab=debug' ) ); ?>" class="health-check-tab active" aria-current="true">
    60                         <?php
    61                         /* translators: Tab heading for Site Health Info page. */
    62                         _ex( 'Info', 'Site Health' );
    63                         ?>
    64                 </a>
    65         </nav>
    66 </div>
    67 
    68 <hr class="wp-header-end">
    6922
    7023<div class="notice notice-error hide-if-js">
     
    180133        </div>
    181134</div>
    182 
    183 <?php
    184 require_once ABSPATH . 'wp-admin/admin-footer.php';
Note: See TracChangeset for help on using the changeset viewer.