Skip to content

Commit

Permalink
Revert making the value '1' required for the AMP query var
Browse files Browse the repository at this point in the history
Co-authored-by: Weston Ruter <westonruter@google.com>
  • Loading branch information
pierlon and westonruter committed Sep 22, 2020
1 parent f806254 commit 83ec4a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions includes/amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1915,16 +1915,16 @@ function amp_generate_script_hash( $script ) {
* @return string AMP URL.
*/
function amp_get_url( $url ) {
return add_query_arg( amp_get_slug(), 1, $url );
return add_query_arg( amp_get_slug(), '1', $url );
}

/**
* Determine whether the current request has the AMP query parameter set with the required value '1'.
* Determine whether the current request has the AMP query parameter set.
*
* @since 2.1
*
* @return bool True if the AMP query parameter is set with the required value, false if not.
*/
function amp_has_query_var() {
return isset( $_GET[ amp_get_slug() ] ) && 1 === filter_var( $_GET[ amp_get_slug() ], FILTER_VALIDATE_INT ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return isset( $_GET[ amp_get_slug() ] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
2 changes: 1 addition & 1 deletion includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public static function ensure_proper_amp_location() {
global $wp;
$path_args = [];
wp_parse_str( $wp->matched_query, $path_args );
if ( isset( $path_args[ amp_get_slug() ] ) && '1' !== $path_args[ amp_get_slug() ] ) {
if ( isset( $path_args[ amp_get_slug() ] ) && '' !== $path_args[ amp_get_slug() ] ) {
if ( wp_safe_redirect( amp_get_permalink( get_queried_object_id() ), 301 ) ) {
// @codeCoverageIgnoreStart
exit;
Expand Down

0 comments on commit 83ec4a8

Please sign in to comment.