<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[50764] trunk/src: Site Health: Support custom sub-menus and pages.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/50764">50764</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/50764","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>Clorith</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-04-17 01:12:25 +0000 (Sat, 17 Apr 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/ticket/47225">#47225</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcjs_enqueuesadminsitehealthjs">trunk/src/js/_enqueues/admin/site-health.js</a></li>
<li><a href="#trunksrcwpadmincsssitehealthcss">trunk/src/wp-admin/css/site-health.css</a></li>
<li><a href="#trunksrcwpadminincludesclasswpsitehealthphp">trunk/src/wp-admin/includes/class-wp-site-health.php</a></li>
<li><a href="#trunksrcwpadminsitehealthinfophp">trunk/src/wp-admin/site-health-info.php</a></li>
<li><a href="#trunksrcwpadminsitehealthphp">trunk/src/wp-admin/site-health.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjs_enqueuesadminsitehealthjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/admin/site-health.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/admin/site-health.js 2021-04-16 17:24:47 UTC (rev 50763)
+++ trunk/src/js/_enqueues/admin/site-health.js 2021-04-17 01:12:25 UTC (rev 50764)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -443,4 +443,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> recalculateProgression();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Trigger a class toggle when the extended menu button is clicked.
+ $( '.health-check-offscreen-nav-wrapper' ).on( 'click', function() {
+ $( this ).toggleClass( 'visible' );
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span></span></pre></div>
<a id="trunksrcwpadmincsssitehealthcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/site-health.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/site-health.css 2021-04-16 17:24:47 UTC (rev 50763)
+++ trunk/src/wp-admin/css/site-health.css 2021-04-17 01:12:25 UTC (rev 50764)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,12 +118,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> .health-check-tabs-wrapper {
</span><span class="cx" style="display: block; padding: 0 10px"> /* IE 11 */
</span><span class="cx" style="display: block; padding: 0 10px"> display: -ms-inline-grid;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- -ms-grid-columns: 1fr 1fr;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ -ms-grid-columns: 1fr 1fr 1fr 1fr;
</ins><span class="cx" style="display: block; padding: 0 10px"> vertical-align: top;
</span><span class="cx" style="display: block; padding: 0 10px"> /* modern browsers */
</span><span class="cx" style="display: block; padding: 0 10px"> display: inline-grid;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ grid-template-columns: 1fr 1fr 1fr 1fr;
+}
+
+.health-check-tabs-wrapper.tab-count-1 {
+ grid-template-columns: 1fr;
+}
+.health-check-tabs-wrapper.tab-count-2 {
</ins><span class="cx" style="display: block; padding: 0 10px"> grid-template-columns: 1fr 1fr;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.health-check-tabs-wrapper.tab-count-3 {
+ grid-template-columns: 1fr 1fr 1fr;
+}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .health-check-tab {
</span><span class="cx" style="display: block; padding: 0 10px"> display: block; /* IE 11 */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -134,6 +144,43 @@
</span><span class="cx" style="display: block; padding: 0 10px"> transition: box-shadow 0.5s ease-in-out;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.health-check-offscreen-nav-wrapper {
+ position: relative;
+ background: transparent;
+ border: none;
+}
+.health-check-offscreen-nav-wrapper:focus .health-check-offscreen-nav {
+ left: initial;
+}
+
+.health-check-offscreen-nav {
+ display: none;
+ position: absolute;
+ padding-top: 10px;
+ right: 0;
+ top: 100%;
+ width: 13rem;
+}
+.health-check-offscreen-nav-wrapper.visible .health-check-offscreen-nav {
+ display: inline-block;
+}
+.health-check-offscreen-nav:before {
+ position: absolute;
+ content: "";
+ width: 0;
+ height: 0;
+ border-style: solid;
+ border-width: 0 10px 5px 10px;
+ border-color: transparent transparent #ffffff transparent;
+ right: 20px;
+ top: 5px;
+}
+
+.health-check-offscreen-nav .health-check-tab {
+ background: #fff;
+ box-shadow: 0 2px 5px 0 rgba( 0, 0, 0, 0.75 );
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .health-check-tab:nth-child(1) {
</span><span class="cx" style="display: block; padding: 0 10px"> -ms-grid-column: 1; /* IE 11 */
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -152,6 +199,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> box-shadow: inset 0 -3px #3582c4;
</span><span class="cx" style="display: block; padding: 0 10px"> font-weight: 600;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.health-check-offscreen-nav .health-check-tab.active {
+ box-shadow: inset 3px 0 #3582c4;
+ font-weight: 600;
+}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .health-check-body {
</span><span class="cx" style="display: block; padding: 0 10px"> max-width: 800px;
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpsitehealthphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-site-health.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-site-health.php 2021-04-16 17:24:47 UTC (rev 50763)
+++ trunk/src/wp-admin/includes/class-wp-site-health.php 2021-04-17 01:12:25 UTC (rev 50764)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,9 +50,24 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_site_health_scheduled_check', array( $this, 'wp_cron_scheduled_check' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ add_action( 'site_health_tab_content', array( $this, 'show_site_health_tab' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Output the content of a tab in the Site Health screen.
+ *
+ * @since 5.8.0
+ *
+ * @param string $tab Slug of the current tab being displayed.
+ */
+ public function show_site_health_tab( $tab ) {
+ if ( 'debug' === $tab ) {
+ require_once ABSPATH . '/wp-admin/site-health-info.php';
+ }
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Return an instance of the WP_Site_Health class, or create one if none exist yet.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.4.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -103,7 +118,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $health_check_js_variables['site_status']['issues'] = $issue_counts;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'site-health' === $screen->id && ! isset( $_GET['tab'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'site-health' === $screen->id && ( ! isset( $_GET['tab'] ) || empty( $_GET['tab'] ) ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $tests = WP_Site_Health::get_tests();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Don't run https test on development environments.
</span></span></pre></div>
<a id="trunksrcwpadminsitehealthinfophp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/site-health-info.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/site-health-info.php 2021-04-16 17:24:47 UTC (rev 50763)
+++ trunk/src/wp-admin/site-health-info.php 2021-04-17 01:12:25 UTC (rev 50764)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,18 +6,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @subpackage Administration
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/** WordPress Administration Bootstrap */
-require_once __DIR__ . '/admin.php';
-
-$title = __( 'Site Health Info' );
-
-if ( ! current_user_can( 'view_site_health_checks' ) ) {
- wp_die( __( 'Sorry, you are not allowed to access the debug data.' ), '', 403 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+if ( ! defined( 'ABSPATH' ) ) {
+ die();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-wp_enqueue_style( 'site-health' );
-wp_enqueue_script( 'site-health' );
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'WP_Debug_Data' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,47 +18,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $health_check_site_status = WP_Site_Health::get_instance();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-require_once ABSPATH . 'wp-admin/admin-header.php';
</del><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div class="health-check-header">
- <div class="health-check-title-section">
- <h1>
- <?php _e( 'Site Health' ); ?>
- </h1>
- </div>
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js">
- <div class="site-health-progress">
- <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">
- <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
- <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
- </svg>
- </div>
- <div class="site-health-progress-label">
- <?php _e( 'Results are still loading…' ); ?>
- </div>
- </div>
-
- <nav class="health-check-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
- <a href="<?php echo esc_url( admin_url( 'site-health.php' ) ); ?>" class="health-check-tab">
- <?php
- /* translators: Tab heading for Site Health Status page. */
- _ex( 'Status', 'Site Health' );
- ?>
- </a>
-
- <a href="<?php echo esc_url( admin_url( 'site-health.php?tab=debug' ) ); ?>" class="health-check-tab active" aria-current="true">
- <?php
- /* translators: Tab heading for Site Health Info page. */
- _ex( 'Info', 'Site Health' );
- ?>
- </a>
- </nav>
-</div>
-
-<hr class="wp-header-end">
-
</del><span class="cx" style="display: block; padding: 0 10px"> <div class="notice notice-error hide-if-js">
</span><span class="cx" style="display: block; padding: 0 10px"> <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -179,6 +132,3 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php } ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-<?php
-require_once ABSPATH . 'wp-admin/admin-footer.php';
</del></span></pre></div>
<a id="trunksrcwpadminsitehealthphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/site-health.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/site-health.php 2021-04-16 17:24:47 UTC (rev 50763)
+++ trunk/src/wp-admin/site-health.php 2021-04-17 01:12:25 UTC (rev 50764)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,18 +6,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @subpackage Administration
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( isset( $_GET['tab'] ) && 'debug' === $_GET['tab'] ) {
- require_once __DIR__ . '/site-health-info.php';
- return;
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> /** WordPress Administration Bootstrap */
</span><span class="cx" style="display: block; padding: 0 10px"> require_once __DIR__ . '/admin.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_reset_vars( array( 'action' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$title = __( 'Site Health Status' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$tabs = array(
+ /* translators: Tab heading for Site Health Status page. */
+ '' => _x( 'Status', 'Site Health' ),
+ /* translators: Tab heading for Site Health Info page. */
+ 'debug' => _x( 'Info', 'Site Health' ),
+);
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * An associated array of extra tabs for the Site Health navigation bar.
+ *
+ * Add a custom page to the Site Health screen, based on a tab slug and label.
+ * The label you provide will also be used as part of the site title.
+ *
+ * @since 5.8.0
+ *
+ * @param array $tabs An associated array of tab slugs and their label.
+ */
+$tabs = apply_filters( 'site_health_navigation_tabs', $tabs );
+
+$wrapper_classes = array(
+ 'health-check-tabs-wrapper',
+ 'hide-if-no-js',
+ 'tab-count-' . count( $tabs ),
+);
+
+$title = sprintf(
+ // translators: %s: The currently displayed tab.
+ __( 'Site Health %s' ),
+ ( isset( $_GET['tab'] ) ? esc_html( $tabs[ $_GET['tab'] ] ) : esc_html( $tabs[0] ) )
+);
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'view_site_health_checks' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( __( 'Sorry, you are not allowed to access site health information.' ), '', 403 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -86,25 +110,87 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <nav class="health-check-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
- <a href="<?php echo esc_url( admin_url( 'site-health.php' ) ); ?>" class="health-check-tab active" aria-current="true">
- <?php
- /* translators: Tab heading for Site Health Status page. */
- _ex( 'Status', 'Site Health' );
- ?>
- </a>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <nav class="<?php echo implode( ' ', $wrapper_classes ); ?>" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
+ <?php
+ $tabs_slice = $tabs;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <a href="<?php echo esc_url( admin_url( 'site-health.php?tab=debug' ) ); ?>" class="health-check-tab">
- <?php
- /* translators: Tab heading for Site Health Info page. */
- _ex( 'Info', 'Site Health' );
- ?>
- </a>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * If there are more than 4 tabs, only output the first 3 inline,
+ * the remaining links will be added to a sub-navigation.
+ */
+ if ( count( $tabs ) > 4 ) {
+ $tabs_slice = array_slice( $tabs, 0, 3 );
+ }
+
+ foreach ( $tabs_slice as $slug => $label ) {
+ printf(
+ '<a href="%s" class="health-check-tab %s">%s</a>',
+ esc_url(
+ add_query_arg(
+ array(
+ 'tab' => $slug,
+ ),
+ admin_url( 'site-health.php' )
+ )
+ ),
+ ( isset( $_GET['tab'] ) && $_GET['tab'] === $slug ? 'active' : '' ),
+ esc_html( $label )
+ );
+ }
+ ?>
+
+ <?php if ( count( $tabs ) > 4 ) : ?>
+ <button type="button" class="health-check-tab health-check-offscreen-nav-wrapper" aria-haspopup="true">
+ <span class="dashicons dashicons-ellipsis"></span>
+ <span class="screen-reader-text"><?php _e( 'Toggle extra menu items' ); ?></span>
+
+ <div class="health-check-offscreen-nav">
+ <?php
+ // Remove the first few entries from the array as being already output.
+ $tabs_slice = array_slice( $tabs, 3 );
+ foreach ( $tabs_slice as $slug => $label ) {
+ printf(
+ '<a href="%s" class="health-check-tab %s">%s</a>',
+ esc_url(
+ add_query_arg(
+ array(
+ 'tab' => $slug,
+ ),
+ admin_url( 'site-health.php' )
+ )
+ ),
+ ( isset( $_GET['tab'] ) && $_GET['tab'] === $slug ? 'active' : '' ),
+ esc_html( $label )
+ );
+ }
+ ?>
+ </div>
+ </button>
+ <?php endif; ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </nav>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <hr class="wp-header-end">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+if ( isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ) {
+ /**
+ * Output content of a custom Site Health tab.
+ *
+ * This action fires right after the Site Health header, and users are still subject to
+ * the capability checks for the Site Health page to view any custom tabs and their contents.
+ *
+ * @since 5.8.0
+ *
+ * @param string $tab The slug of the tab that was requested.
+ */
+ do_action( 'site_health_tab_content', $_GET['tab'] );
+
+ require_once ABSPATH . 'wp-admin/admin-footer.php';
+ return;
+} else {
+ ?>
+
</ins><span class="cx" style="display: block; padding: 0 10px"> <div class="notice notice-error hide-if-js">
</span><span class="cx" style="display: block; padding: 0 10px"> <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,5 +279,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php
+}
</ins><span class="cx" style="display: block; padding: 0 10px"> require_once ABSPATH . 'wp-admin/admin-footer.php';
</span></span></pre>
</div>
</div>
</body>
</html>