Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#34860 closed defect (bug) (fixed)

Search Engine Discouraged shown on dashboard when upgrading from an earlier version than 2.1

Reported by: bswatson's profile bswatson Owned by: swissspidy's profile swissspidy
Milestone: 4.5 Priority: normal
Severity: minor Version: 3.8
Component: Options, Meta APIs Keywords: has-patch commit
Focuses: administration Cc:


When upgrading a site to a version newer than 3.7 when the original version of WordPress was before 2.1, it's possible for the "Search Engines Discouraged" text to be shown on the dashboard, even if the setting isn't configured.

In the dashboard code, the conditional to check for this option checks specifically if get_option( 'blog_public' ) is set to '1'.

if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '1' != get_option( 'blog_public' ) ) {


The option settings, split logic on has_action( 'blog_privacy_selector' ). If the selector exists, it shows a radio button that set the option as '1' if search engines are allowed to index and '0' if they are not. If the option is not selected, search engines are not allowed.

The previous behavior was a checkbox that would set the option to 0 only if search engines were discouraged, and deselecting the checkbox would enable search engines.

<?php if ( has_action( 'blog_privacy_selector' ) ) : ?>
        <input id="blog-public" type="radio" name="blog_public" value="1" <?php checked('1', get_option('blog_public')); ?> />
        <label for="blog-public"><?php _e( 'Allow search engines to index this site' );?></label><br/>
        <input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked('0', get_option('blog_public')); ?> />
        <label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
        <p class="description"><?php _e( 'Note: Neither of these options blocks access to your site &mdash; it is up to search engines to honor your request.' ); ?></p>
         * Enable the legacy 'Site Visibility' privacy options.
         * By default the privacy options form displays a single checkbox to 'discourage' search
         * engines from indexing the site. Hooking to this action serves a dual purpose:
         * 1. Disable the single checkbox in favor of a multiple-choice list of radio buttons.
         * 2. Open the door to adding additional radio button choices to the list.
         * Hooking to this action also converts the 'Search Engine Visibility' heading to the more
         * open-ended 'Site Visibility' heading.
         * @since 2.1.0
        do_action( 'blog_privacy_selector' );
<?php else : ?>
        <label for="blog_public"><input name="blog_public" type="checkbox" id="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
        <?php _e( 'Discourage search engines from indexing this site' ); ?></label>
        <p class="description"><?php _e( 'It is up to search engines to honor this request.' ); ?></p>
<?php endif; ?>


On upgrade, the default value allowed search engines to be index, but now displays that they should not.

This only appears to be display issue on the dashboard, as output of the no-index meta checks against 0 instead of 1.

function noindex() {
        // If the blog is not public, tell robots to go away.
        if ( '0' == get_option('blog_public') )


Attachments (1)

34860.diff (690 bytes) - added by swissspidy 7 years ago.

Download all attachments as: .zip

Change History (8)

#1 @bswatson
7 years ago

  • Severity changed from normal to minor

This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.

7 years ago

#3 @swissspidy
7 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from trunk to 3.8

The default value of that option indeed changed over the years. The bug mentioned here was introduced in [26700] for 3.8.

It seems like a '0' === get_option( 'blog_public' ) check in wp-admin/includes/dashboard.php (instead of checking against '1') should really be enough to fix this.

7 years ago

#4 @swissspidy
7 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Future Release to 4.5

34860.diff uses the same check against '0' as in noindex(), preventing from incorrectly showing "Search Engines Discouraged" text when the blog_public option is not set.

#5 @ocean90
7 years ago

  • Keywords commit added

#6 @swissspidy
7 years ago

  • Owner set to swissspidy
  • Status changed from new to assigned

#7 @swissspidy
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 35873:

Dashboard: Do not show "Search Engines Discouraged" text when the blog_public option is not set.

Search engines are only discouraged from indexing the site when the option is explicitly set to 0.

Fixes #34860.

Note: See TracTickets for help on using tickets.