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

Update to always return AMP mode secondary. #3577

Merged
merged 2 commits into from
Jun 16, 2021

Conversation

Hazlitte
Copy link
Contributor

@Hazlitte Hazlitte commented Jun 15, 2021

Summary

Update to always return AMP mode secondary.

Addresses issue #2998

Relevant technical choices

Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 4.7 and PHP 5.6.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

@google-cla
Copy link

google-cla bot commented Jun 15, 2021

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 @googlebot I consent. in this pull request.

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 cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Jun 15, 2021
@Hazlitte Hazlitte changed the base branch from develop to main June 15, 2021 10:50
@Hazlitte Hazlitte closed this Jun 15, 2021
@Hazlitte Hazlitte reopened this Jun 15, 2021
@Hazlitte
Copy link
Contributor Author

@googlebot I consent

@google-cla google-cla bot added cla: yes and removed cla: no labels Jun 15, 2021
@Hazlitte Hazlitte marked this pull request as ready for review June 15, 2021 10:56
@Hazlitte
Copy link
Contributor Author

@tofumatt As suggested I tested with the latest release of the AMP plugin and version 1.5.5.

@tofumatt tofumatt changed the title Update to. always return AMP mode secondary. Update to always return AMP mode secondary. Jun 16, 2021
@tofumatt
Copy link
Collaborator

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 🙂

Copy link
Collaborator

@tofumatt tofumatt left a 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.

Comment on lines 351 to 357
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;
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Hazlitte that comment was only regarding issues for the release (1.35.0). #2998 was not tagged with the release, so no change was needed here.

Copy link
Contributor Author

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 👍

@google-cla
Copy link

google-cla bot commented Jun 16, 2021

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 @googlebot I consent. in this pull request.

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 cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Jun 16, 2021
Copy link
Collaborator

@tofumatt tofumatt left a 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.

@tofumatt
Copy link
Collaborator

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Jun 16, 2021
@tofumatt tofumatt changed the base branch from main to develop June 16, 2021 17:30
@tofumatt tofumatt merged commit a29c3b5 into develop Jun 16, 2021
@tofumatt tofumatt deleted the bug/2998-amp-mode-secondary branch June 16, 2021 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants