Changeset 49992
- Timestamp:
- 01/21/2021 01:35:16 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-activate.php
r48672 r49992 115 115 } 116 116 add_action( 'wp_head', 'wpmu_activate_stylesheet' ); 117 add_action( 'wp_head', 'wp_sensitive_page_meta' ); 117 add_action( 'wp_head', 'wp_strict_cross_origin_referrer' ); 118 add_filter( 'wp_robots', 'wp_robots_sensitive_page' ); 118 119 119 120 get_header( 'wp-activate' ); -
trunk/src/wp-includes/class-wp-customize-manager.php
r49731 r49992 1901 1901 header( 'X-Robots: noindex, nofollow, noarchive' ); 1902 1902 } 1903 add_ action( 'wp_head', 'wp_no_robots' );1903 add_filter( 'wp_robots', 'wp_robots_no_robots' ); 1904 1904 add_filter( 'wp_headers', array( $this, 'filter_iframe_security_headers' ) ); 1905 1905 -
trunk/src/wp-includes/default-filters.php
r49904 r49992 231 231 // Email filters. 232 232 add_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); 233 234 // Robots filters. 235 add_filter( 'wp_robots', 'wp_robots_noindex' ); 233 236 234 237 // Mark site as no longer fresh. … … 292 295 add_action( 'wp_head', 'locale_stylesheet' ); 293 296 add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); 294 add_action( 'wp_head', ' noindex', 1 );297 add_action( 'wp_head', 'wp_robots', 1 ); 295 298 add_action( 'wp_head', 'print_emoji_detection_script', 7 ); 296 299 add_action( 'wp_head', 'wp_print_styles', 8 ); … … 312 315 313 316 if ( isset( $_GET['replytocom'] ) ) { 314 add_ action( 'wp_head', 'wp_no_robots' );317 add_filter( 'wp_robots', 'wp_robots_no_robots' ); 315 318 } 316 319 317 320 // Login actions. 321 add_action( 'login_head', 'wp_robots', 1 ); 318 322 add_filter( 'login_head', 'wp_resource_hints', 8 ); 319 323 add_action( 'login_head', 'wp_print_head_scripts', 9 ); … … 586 590 add_action( 'embed_head', 'wp_print_head_scripts', 20 ); 587 591 add_action( 'embed_head', 'wp_print_styles', 20 ); 588 add_action( 'embed_head', 'wp_ no_robots' );592 add_action( 'embed_head', 'wp_robots' ); 589 593 add_action( 'embed_head', 'rel_canonical' ); 590 594 add_action( 'embed_head', 'locale_stylesheet', 30 ); … … 597 601 add_action( 'embed_footer', 'wp_print_footer_scripts', 20 ); 598 602 603 add_filter( 'wp_robots', 'wp_embed_no_robots' ); 599 604 add_filter( 'excerpt_more', 'wp_embed_excerpt_more', 20 ); 600 605 add_filter( 'the_excerpt_embed', 'wptexturize' ); -
trunk/src/wp-includes/deprecated.php
r49597 r49992 4136 4136 return is_string( $value ) ? addslashes( $value ) : $value; 4137 4137 } 4138 4139 /** 4140 * Displays a noindex meta tag if required by the blog configuration. 4141 * 4142 * If a blog is marked as not being public then the noindex meta tag will be 4143 * output to tell web robots not to index the page content. Add this to the 4144 * {@see 'wp_head'} action. 4145 * 4146 * Typical usage is as a {@see 'wp_head'} callback: 4147 * 4148 * add_action( 'wp_head', 'noindex' ); 4149 * 4150 * @see wp_no_robots() 4151 * 4152 * @since 2.1.0 4153 * @deprecated 5.7.0 Use wp_robots_noindex() instead on 'wp_robots' filter. 4154 */ 4155 function noindex() { 4156 _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_noindex()' ); 4157 4158 // If the blog is not public, tell robots to go away. 4159 if ( '0' == get_option( 'blog_public' ) ) { 4160 wp_no_robots(); 4161 } 4162 } 4163 4164 /** 4165 * Display a noindex meta tag. 4166 * 4167 * Outputs a noindex meta tag that tells web robots not to index the page content. 4168 * Typical usage is as a {@see 'wp_head'} callback. add_action( 'wp_head', 'wp_no_robots' ); 4169 * 4170 * @since 3.3.0 4171 * @since 5.3.0 Echo "noindex,nofollow" if search engine visibility is discouraged. 4172 * @deprecated 5.7.0 Use wp_robots_no_robots() instead on 'wp_robots' filter. 4173 */ 4174 function wp_no_robots() { 4175 _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_no_robots()' ); 4176 4177 if ( get_option( 'blog_public' ) ) { 4178 echo "<meta name='robots' content='noindex,follow' />\n"; 4179 return; 4180 } 4181 4182 echo "<meta name='robots' content='noindex,nofollow' />\n"; 4183 } 4184 4185 /** 4186 * Display a noindex,noarchive meta tag and referrer origin-when-cross-origin meta tag. 4187 * 4188 * Outputs a noindex,noarchive meta tag that tells web robots not to index or cache the page content. 4189 * Outputs a referrer origin-when-cross-origin meta tag that tells the browser not to send the full 4190 * url as a referrer to other sites when cross-origin assets are loaded. 4191 * 4192 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_sensitive_page_meta' ); 4193 * 4194 * @since 5.0.1 4195 * @deprecated 5.7.0 Use wp_robots_sensitive_page() instead on 'wp_robots' filter 4196 * and wp_strict_cross_origin_referrer() on 'wp_head' action. 4197 */ 4198 function wp_sensitive_page_meta() { 4199 _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_sensitive_page()' ); 4200 4201 ?> 4202 <meta name='robots' content='noindex,noarchive' /> 4203 <?php 4204 wp_strict_cross_origin_referrer(); 4205 } -
trunk/src/wp-includes/embed.php
r49936 r49992 1244 1244 return $result; 1245 1245 } 1246 1247 /** 1248 * Adds noindex to the robots meta tag for embeds. 1249 * 1250 * Typical usage is as a {@see 'wp_robots'} callback: 1251 * 1252 * add_filter( 'wp_robots', 'wp_embed_no_robots' ); 1253 * 1254 * @since 5.7.0 1255 * 1256 * @param array $robots Associative array of robots directives. 1257 * @return array Filtered robots directives. 1258 */ 1259 function wp_embed_no_robots( array $robots ) { 1260 if ( ! is_embed() ) { 1261 return $robots; 1262 } 1263 1264 return wp_robots_no_robots( $robots ); 1265 } -
trunk/src/wp-includes/functions.php
r49941 r49992 1641 1641 * @since 2.1.0 1642 1642 * @since 5.3.0 Remove the "Disallow: /" output if search engine visiblity is 1643 * discouraged in favor of robots meta HTML tag in wp_no_robots(). 1643 * discouraged in favor of robots meta HTML tag via wp_robots_no_robots() 1644 * filter callback. 1644 1645 */ 1645 1646 function do_robots() { … … 3492 3493 <meta name="viewport" content="width=device-width"> 3493 3494 <?php 3494 if ( function_exists( 'wp_no_robots' ) ) { 3495 wp_no_robots(); 3495 if ( function_exists( 'wp_robots' ) && function_exists( 'wp_robots_no_robots' ) && function_exists( 'add_filter' ) ) { 3496 add_filter( 'wp_robots', 'wp_robots_no_robots' ); 3497 wp_robots(); 3496 3498 } 3497 3499 ?> -
trunk/src/wp-includes/general-template.php
r49977 r49992 3192 3192 3193 3193 /** 3194 * Displays a noindex meta tag if required by the blog configuration. 3195 * 3196 * If a blog is marked as not being public then the noindex meta tag will be 3197 * output to tell web robots not to index the page content. Add this to the 3198 * {@see 'wp_head'} action. 3199 * 3200 * Typical usage is as a {@see 'wp_head'} callback: 3201 * 3202 * add_action( 'wp_head', 'noindex' ); 3203 * 3204 * @see wp_no_robots() 3205 * 3206 * @since 2.1.0 3207 */ 3208 function noindex() { 3209 // If the blog is not public, tell robots to go away. 3210 if ( '0' == get_option( 'blog_public' ) ) { 3211 wp_no_robots(); 3212 } 3213 } 3214 3215 /** 3216 * Display a noindex meta tag. 3217 * 3218 * Outputs a noindex meta tag that tells web robots not to index the page content. 3219 * Typical usage is as a {@see 'wp_head'} callback. add_action( 'wp_head', 'wp_no_robots' ); 3220 * 3221 * @since 3.3.0 3222 * @since 5.3.0 Echo "noindex,nofollow" if search engine visibility is discouraged. 3223 */ 3224 function wp_no_robots() { 3225 if ( get_option( 'blog_public' ) ) { 3226 echo "<meta name='robots' content='noindex,follow' />\n"; 3227 return; 3228 } 3229 3230 echo "<meta name='robots' content='noindex,nofollow' />\n"; 3231 } 3232 3233 /** 3234 * Display a noindex,noarchive meta tag and referrer origin-when-cross-origin meta tag. 3235 * 3236 * Outputs a noindex,noarchive meta tag that tells web robots not to index or cache the page content. 3194 * Displays a referrer strict-origin-when-cross-origin meta tag. 3195 * 3237 3196 * Outputs a referrer origin-when-cross-origin meta tag that tells the browser not to send the full 3238 3197 * url as a referrer to other sites when cross-origin assets are loaded. 3239 3198 * 3240 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_s ensitive_page_meta' );3241 * 3242 * @since 5. 0.13243 */ 3244 function wp_s ensitive_page_meta() {3199 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_strict_cross_origin_referrer' ); 3200 * 3201 * @since 5.7.0 3202 */ 3203 function wp_strict_cross_origin_referrer() { 3245 3204 ?> 3246 <meta name='robots' content='noindex,noarchive' />3247 3205 <meta name='referrer' content='strict-origin-when-cross-origin' /> 3248 3206 <?php -
trunk/src/wp-login.php
r49945 r49992 43 43 44 44 // Don't index any of these forms. 45 add_action( 'login_head', 'wp_sensitive_page_meta' ); 45 add_filter( 'wp_robots', 'wp_robots_sensitive_page' ); 46 add_action( 'login_head', 'wp_strict_cross_origin_referrer' ); 46 47 47 48 add_action( 'login_head', 'wp_login_viewport_meta' ); -
trunk/src/wp-settings.php
r49904 r49992 182 182 require ABSPATH . WPINC . '/link-template.php'; 183 183 require ABSPATH . WPINC . '/author-template.php'; 184 require ABSPATH . WPINC . '/robots-template.php'; 184 185 require ABSPATH . WPINC . '/post.php'; 185 186 require ABSPATH . WPINC . '/class-walker-page.php'; -
trunk/src/wp-signup.php
r49078 r49992 4 4 require __DIR__ . '/wp-load.php'; 5 5 6 add_ action( 'wp_head', 'wp_no_robots' );6 add_filter( 'wp_robots', 'wp_robots_no_robots' ); 7 7 8 8 require __DIR__ . '/wp-blog-header.php'; -
trunk/tests/phpunit/tests/customize/manager.php
r49603 r49992 894 894 $this->assertSame( $did_action_customize_preview_init + 1, did_action( 'customize_preview_init' ) ); 895 895 896 $this->assertSame( 10, has_ action( 'wp_head', 'wp_no_robots' ) );896 $this->assertSame( 10, has_filter( 'wp_robots', 'wp_robots_no_robots' ) ); 897 897 $this->assertSame( 10, has_action( 'wp_head', array( $wp_customize, 'remove_frameless_preview_messenger_channel' ) ) ); 898 898 $this->assertSame( 10, has_filter( 'wp_headers', array( $wp_customize, 'filter_iframe_security_headers' ) ) ); -
trunk/tests/phpunit/tests/general/template.php
r49847 r49992 473 473 474 474 $this->assertSame( $expected, $result ); 475 }476 477 /**478 * @ticket 43590479 */480 function test_wp_no_robots() {481 // Simulate private site (search engines discouraged).482 update_option( 'blog_public', '0' );483 $actual_private = get_echo( 'wp_no_robots' );484 $this->assertSame( "<meta name='robots' content='noindex,nofollow' />\n", $actual_private );485 486 // Simulate public site.487 update_option( 'blog_public', '1' );488 $actual_public = get_echo( 'wp_no_robots' );489 $this->assertSame( "<meta name='robots' content='noindex,follow' />\n", $actual_public );490 475 } 491 476
Note: See TracChangeset
for help on using the changeset viewer.