-
Notifications
You must be signed in to change notification settings - Fork 293
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
Update to always return AMP mode secondary. #3577
Conversation
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent |
@tofumatt As suggested I tested with the latest release of the AMP plugin and version 1.5.5. |
Looks like this is a new PR—we originally had the PR discussion in #3504, just curious why this new one was opened? It's usually best to keep changes in one PR so we can keep track of the discussion 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the existing check in place, but other than that looks good.
includes/Context.php
Outdated
if ( $exposes_support_mode ) { | ||
// If recent version, we can properly detect the mode. | ||
if ( $amp_plugin_version_2_or_higher ) { | ||
$mode = AMP_Options_Manager::get_option( 'theme_support' ); | ||
} else { | ||
$mode = AMP_Theme_Support::get_support_mode(); | ||
} | ||
|
||
if ( AMP_Theme_Support::STANDARD_MODE_SLUG === $mode ) { | ||
return self::AMP_MODE_PRIMARY; | ||
} | ||
|
||
if ( in_array( $mode, array( AMP_Theme_Support::TRANSITIONAL_MODE_SLUG, AMP_Theme_Support::READER_MODE_SLUG ), true ) ) { | ||
return self::AMP_MODE_SECONDARY; | ||
} | ||
} elseif ( function_exists( 'amp_is_canonical' ) ) { | ||
// On older versions, if it is not primary AMP, it is definitely secondary AMP (transitional or reader mode). | ||
if ( amp_is_canonical() ) { | ||
return self::AMP_MODE_PRIMARY; | ||
} | ||
|
||
if ( $exposes_support_mode || function_exists( 'amp_is_canonical' ) ) { | ||
return self::AMP_MODE_SECONDARY; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the original check in here, but add STANDARD_MODE_SLUG
in, eg:
if ( $exposes_support_mode ) {
// If recent version, we can properly detect the mode.
if ( $amp_plugin_version_2_or_higher ) {
$mode = AMP_Options_Manager::get_option( 'theme_support' );
} else {
$mode = AMP_Theme_Support::get_support_mode();
}
if (
in_array( $mode, array(
AMP_Theme_Support::STANDARD_MODE_SLUG,
AMP_Theme_Support::TRANSITIONAL_MODE_SLUG,
AMP_Theme_Support::READER_MODE_SLUG
), true )
) {
return self::AMP_MODE_SECONDARY;
}
} elseif ( function_exists( 'amp_is_canonical' ) ) {
return self::AMP_MODE_SECONDARY;
}
I know it seems a lot more verbose, but if new modes are added to the AMP plugin we should need to explicitly support them I'd think, which is what our old code is doing. Otherwise if ( in_array( $mode, array( AMP_Theme_Support::TRANSITIONAL_MODE_SLUG, AMP_Theme_Support::READER_MODE_SLUG ), true ) ) {
would be skipped and we'd always return self::AMP_MODE_SECONDARY
, but we don't.
So let's keep those checks in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tofumatt,
A couple of days ago Evan told us "develop has been cut into main so please ensure any remaining PRs for 1.35.0 (or follow-ups from QA) are created from and updated to target main.". I took this to mean that I needed to create a new branch from main for this ticket, transfer the changes to it and create a new PR. I guess this was the wrong approach. What should I have done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaemnnosttv Ah ok, thanks for clarifying 👍
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but as I made some changes passing over to @aaemnnosttv for another look before merging into the release.
@googlebot I consent. |
Summary
Update to always return AMP mode secondary.
Addresses issue #2998
Relevant technical choices
Checklist