Make WordPress Core

Changeset 60529


Ignore:
Timestamp:
07/31/2025 11:07:03 PM (13 months ago)
Author:
audrasjb
Message:

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.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/dashboard.css

    r58895 r60529  
    443443#dashboard_right_now .search-engines-info:before {
    444444        content: "\f348";
     445        color: #d63638;
    445446}
    446447
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r60319 r60529  
    26852685                 */
    26862686                $result['actions'] = apply_filters( 'site_status_autoloaded_options_action_to_perform', $result['actions'] );
     2687                return $result;
     2688        }
     2689
     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
    26872730                return $result;
    26882731        }
     
    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(
Note: See TracChangeset for help on using the changeset viewer.