Changeset 50078
- Timestamp:
- 01/29/2021 08:36:03 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/default-filters.php
r50065 r50078 234 234 // Robots filters. 235 235 add_filter( 'wp_robots', 'wp_robots_noindex' ); 236 add_filter( 'wp_robots', 'wp_robots_max_image_preview_large' ); 236 237 237 238 // Mark site as no longer fresh. -
trunk/src/wp-includes/robots-template.php
r49992 r50078 134 134 return $robots; 135 135 } 136 137 /** 138 * Adds 'max-image-preview:large' to the robots meta tag. 139 * 140 * This directive tells web robots that large image previews are allowed to be 141 * displayed, e.g. in search engines, unless the blog is marked as not being public. 142 * 143 * Typical usage is as a {@see 'wp_robots'} callback: 144 * 145 * add_filter( 'wp_robots', 'wp_robots_max_image_preview_large' ); 146 * 147 * @since 5.7.0 148 * 149 * @param array $robots Associative array of robots directives. 150 * @return array Filtered robots directives. 151 */ 152 function wp_robots_max_image_preview_large( array $robots ) { 153 if ( get_option( 'blog_public' ) ) { 154 $robots['max-image-preview'] = 'large'; 155 } 156 return $robots; 157 } -
trunk/tests/phpunit/tests/robots.php
r49992 r50078 162 162 } 163 163 164 /** 165 * @ticket 51511 166 */ 167 public function test_wp_robots_max_image_preview_large() { 168 add_filter( 'wp_robots', 'wp_robots_max_image_preview_large' ); 169 170 update_option( 'blog_public', '1' ); 171 $output = get_echo( 'wp_robots' ); 172 $this->assertContains( "'max-image-preview:large'", $output ); 173 174 update_option( 'blog_public', '0' ); 175 $output = get_echo( 'wp_robots' ); 176 $this->assertEmpty( $output ); 177 } 178 164 179 public function add_noindex_directive( array $robots ) { 165 180 $robots['noindex'] = true;
Note: See TracChangeset
for help on using the changeset viewer.