Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wp_robots() to prevent indexing the error template on WP≥5.7 #414

Merged
merged 1 commit into from
Feb 1, 2021

Conversation

westonruter
Copy link
Collaborator

This prevents a wp_no_robots() deprecation warning from being raised in WP 5.7-alpha which was introduced in WordPress/wordpress-develop#702.

@westonruter westonruter added this to the 0.7 milestone Feb 1, 2021
Copy link
Collaborator

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -17,7 +17,12 @@
add_action( 'wp_ajax_nopriv_wp_service_worker', 'wp_ajax_wp_service_worker' );
add_action( 'parse_query', 'wp_unauthenticate_error_template_requests' );

add_action( 'wp_head', 'wp_add_error_template_no_robots' );
add_action( 'error_head', 'wp_add_error_template_no_robots' );
if ( version_compare( strtok( get_bloginfo( 'version' ), '-' ), '5.7', '>=' ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we could check for whether the wp_robots function exists to avoid the need for specific version lookup - but I guess the downside of that would be that someone else theoretically could declare a function of that name before. Just a thought, nothing blocking.

@westonruter westonruter merged commit e748079 into develop Feb 1, 2021
@westonruter westonruter deleted the fix/wp-robots-5.7 branch February 1, 2021 21:45
@pooja-muchandikar
Copy link

QA Passed ✅

With WP 5.7 and PWA 0.6 version indexing was not part of error template
Screenshot 2022-04-19 at 2 59 36 PM


With WP 5.9.3 and PWA v0.7.0-alpha-52d5096-20220419T054300Z noindex is getting appended on error template
Screenshot 2022-04-19 at 3 01 28 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants