Skip to content

Commit

Permalink
Reuse amp_has_query_var() in AMP_Theme_Support::finish_init()
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Oct 5, 2020
1 parent 123a64f commit 52a6fbf
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,20 +327,14 @@ public static function finish_init() {
add_filter( 'template_include', [ __CLASS__, 'serve_paired_browsing_experience' ], PHP_INT_MAX );
}

$has_query_var = (
isset( $_GET[ amp_get_slug() ] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
||
false !== get_query_var( amp_get_slug(), false )
);

if ( ! amp_is_request() ) {
/*
* Redirect to AMP-less URL if AMP is not available for this URL and yet the query var is present.
* Temporary redirect is used for admin users because implied transitional mode and template support can be
* enabled by user ay any time, so they will be able to make AMP available for this URL and see the change
* without wrestling with the redirect cache.
*/
if ( $has_query_var ) {
if ( amp_has_query_var() ) {
self::redirect_non_amp_url( current_user_can( 'manage_options' ) ? 302 : 301 );
}

Expand Down

0 comments on commit 52a6fbf

Please sign in to comment.