[wp-trac] [WordPress Trac] #34860: Search Engine Discouraged shown on dashboard when upgrading from an earlier version than 2.1

WordPress Trac noreply at wordpress.org
Sun Dec 6 16:14:58 UTC 2015


#34860: Search Engine Discouraged shown on dashboard when upgrading from an earlier
version than 2.1
--------------------------------+-----------------------------
 Reporter:  bswatson            |      Owner:
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:  trunk
 Severity:  normal              |   Keywords:
  Focuses:  administration      |
--------------------------------+-----------------------------
 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
 <?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
 <?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
 <?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

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34860>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list