Skip to content

Commit 6d58651

Browse files
committed
Site Health: Add a test and the related notice for the Search Engine Visibility setting.
This changeset adds a new Site Health test to make site owners more aware when search engines are discouraged from indexing their sites. It also increases the visibility of the related Dashboard widget notice. Changes: - Adds a new Site Health test under the "Privacy" category to check whether search engines are discouraged - Displays "recommended" status when search engines are discouraged, with clear messaging to review settings - Provides a direct link to the Reading Settings page to change this option - Use a red/alert color to the dashicon used on the Dashboard widget notice Props jeffr0, newyorkerlaura, joedolson, codente, abcd95, andrewhoyer, SirLouen, johnbillion, mymothersdaughter, audrasjb, Emlebrun, gaeldenysiak, beryldlg, Spaceshipone, coralietixeront, peterwilsoncc. Fixes #63375. git-svn-id: https://develop.svn.wordpress.org/trunk@60529 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2566fd5 commit 6d58651

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/wp-admin/css/dashboard.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@
442442

443443
#dashboard_right_now .search-engines-info:before {
444444
content: "\f348";
445+
color: #d63638;
445446
}
446447

447448
/* Dashboard WordPress events */

src/wp-admin/includes/class-wp-site-health.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,6 +2687,49 @@ public function get_test_autoloaded_options() {
26872687
return $result;
26882688
}
26892689

2690+
/**
2691+
* Tests whether search engine indexing is enabled.
2692+
*
2693+
* Surfaces as “good” if `blog_public === 1`, or “recommended” if `blog_public === 0`.
2694+
*
2695+
* @since 6.9
2696+
*
2697+
* @return array The test results.
2698+
*/
2699+
public function get_test_search_engine_visibility() {
2700+
$result = array(
2701+
'label' => __( 'Search engine indexing is enabled.', 'default' ),
2702+
'status' => 'good',
2703+
'badge' => array(
2704+
'label' => __( 'Privacy', 'default' ),
2705+
'color' => 'blue',
2706+
),
2707+
'description' => sprintf(
2708+
'<p>%s</p>',
2709+
__( 'Search engines can crawl and index your site. No action needed.', 'default' )
2710+
),
2711+
'actions' => sprintf(
2712+
'<p><a href="%1$s">%2$s</a></p>',
2713+
esc_url( admin_url( 'options-reading.php#blog_public' ) ),
2714+
__( 'Review your visibility settings', 'default' )
2715+
),
2716+
'test' => 'search_engine_visibility',
2717+
);
2718+
2719+
// If indexing is discouraged, flip to “recommended”:
2720+
if ( ! get_option( 'blog_public' ) ) {
2721+
$result['status'] = 'recommended';
2722+
$result['label'] = __( 'Search engines are discouraged from indexing this site.', 'default' );
2723+
$result['badge']['color'] = 'blue';
2724+
$result['description'] = sprintf(
2725+
'<p>%s</p>',
2726+
__( 'Your site is hidden from search engines. Consider enabling indexing if this is a public site.', 'default' )
2727+
);
2728+
}
2729+
2730+
return $result;
2731+
}
2732+
26902733
/**
26912734
* Returns a set of tests that belong to the site status page.
26922735
*
@@ -2775,6 +2818,10 @@ public static function get_tests() {
27752818
'label' => __( 'Autoloaded options' ),
27762819
'test' => 'autoloaded_options',
27772820
),
2821+
'search_engine_visibility' => array(
2822+
'label' => __( 'Search Engine Visibility' ),
2823+
'test' => 'search_engine_visibility',
2824+
),
27782825
),
27792826
'async' => array(
27802827
'dotorg_communication' => array(

0 commit comments

Comments
 (0)