Opened 9 years ago
Closed 9 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 | Owned by: | swissspidy |
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | minor | Version: | 3.8 |
Component: | Options, Meta APIs | Keywords: | has-patch commit |
Focuses: | administration | Cc: |
Description
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'.
<?php if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '1' != get_option( 'blog_public' ) ) {
Ref: https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/dashboard.php#L296
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 — it is up to search engines to honor your request.' ); ?></p> <?php /** * 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; ?>
Ref: https://github.com/WordPress/WordPress/blob/master/wp-admin/options-reading.php#L113
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.
<?php function noindex() { // If the blog is not public, tell robots to go away. if ( '0' == get_option('blog_public') ) wp_no_robots(); }
Ref: https://github.com/WordPress/WordPress/blob/master/wp-includes/general-template.php#L2608
Attachments (1)
Change History (8)
This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.
9 years ago
#3
@
9 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Version changed from trunk to 3.8
#4
@
9 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.
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 inwp-admin/includes/dashboard.php
(instead of checking against'1'
) should really be enough to fix this.