Skip to content

Commit

Permalink
Use wp_robots() instead of noindex() in WP 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jan 21, 2021
1 parent d9add69 commit d167936
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion includes/amp-post-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
* @internal
*/
function amp_post_template_init_hooks() {
add_action( 'amp_post_template_head', 'noindex' );
if ( version_compare( strtok( get_bloginfo( 'version' ), '-' ), '5.7', '>=' ) ) {
add_action( 'amp_post_template_head', 'wp_robots' );
} else {
add_action( 'amp_post_template_head', 'noindex' );
}
add_action( 'amp_post_template_head', 'amp_post_template_add_title' );
add_action( 'amp_post_template_head', 'amp_post_template_add_canonical' );
add_action( 'amp_post_template_head', 'amp_post_template_add_fonts' );
Expand Down
6 changes: 5 additions & 1 deletion tests/php/test-amp-post-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public function setUp() {
/** @covers ::amp_post_template_init_hooks() */
public function test_amp_post_template_init_hooks() {
amp_post_template_init_hooks();
$this->assertSame( 10, has_action( 'amp_post_template_head', 'noindex' ) );
if ( version_compare( strtok( get_bloginfo( 'version' ), '-' ), '5.7', '>=' ) ) {
$this->assertSame( 10, has_action( 'amp_post_template_head', 'wp_robots' ) );
} else {
$this->assertSame( 10, has_action( 'amp_post_template_head', 'noindex' ) );
}
$this->assertSame( 10, has_action( 'amp_post_template_head', 'amp_post_template_add_title' ) );
$this->assertSame( 10, has_action( 'amp_post_template_head', 'amp_post_template_add_canonical' ) );
$this->assertSame( 10, has_action( 'amp_post_template_head', 'amp_post_template_add_fonts' ) );
Expand Down

0 comments on commit d167936

Please sign in to comment.