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

Always allow switching to Reader mode, but default to mode defined by theme #2622

Merged
merged 3 commits into from
Jun 14, 2019

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Jun 13, 2019

This is a follow-up on #2550.

When using a core theme, a notice is displayed encouraging a user to switch to Standard or Transitional mode:

image

If using a non-core theme without any special theme support, it looks like:

image

However, when using a theme like Neve which has built-in paired AMP support, the Reader mode option is removed:

image

The user can still switch to Transitional mode (see #2312), but the Reader mode is gone.

Additionally, if a theme is active which is AMP-first (non-paired amp theme support declared), then they see no options at all:

image

This can be undesirable because while the theme itself has amp support, the plugins being used by the theme may very well not. For such sites, having the option to stay in Reader mode is important until AMP-compatible plugins can be activated. As it stands today, the lack of Reader mode availability could cause theme makers hesitate from adding AMP compatibility, since it limits the options available to their users. It could cause users to either switch to a different theme if they want AMP, or turn off AMP if they really want the theme.

So we should let Reader mode always be an available option. Nevertheless, upon activating the AMP plugin and the theme has amp support, then the default option should be Standard when paired flag is present and Transitional when paired flag is present. As explained in #2312, if paired is absent then the Transitional mode should still not be made available.

This is related to #1384: Default to transitional mode with auto-sanitization for new activations, and to native mode when compatible theme/plugins active.

Proposed Changes

No change for when a core theme is being used, continuing to default to Reader mode or when using a theme that lacks amp theme support.

However, when switching to a theme like Neve which has paired theme support, then for existing plugin activations (which had previously been on Reader) then the Reader mode remains active and a green notice is displayed encouraging them to switch:

image

For new AMP plugin activations, the default mode is Transitional, and again the Reader mode is still presented as an option (the notice is removed because the user switched):

image

Similarly, if the user has activated a theme that has amp theme support without the paired flag (i.e. an AMP-first theme), then upon switching to such a theme from an existing Reader mode install they would see defaulting to Reader with a notice:

image

And brand new AMP plugin activations would default to Standard for themes that have non-paried amp theme support, but with the ability to switch to Reader:

image

@westonruter westonruter added this to the v1.2 milestone Jun 13, 2019
@westonruter westonruter requested a review from amedina June 13, 2019 20:13
@googlebot googlebot added the cla: yes Signed the Google CLA label Jun 13, 2019
@westonruter
Copy link
Member Author

Best to suppress whitespace changes when reviewing: https://github.com/ampproject/amp-wp/pull/2622/files?w=1

@amedina

This comment has been minimized.

Copy link
Member

@amedina amedina left a comment

Choose a reason for hiding this comment

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

LGTM. Tested the branch varying the theme support options. The changes make the UX more intuitive and I think it captures important use cases for the plugin.

@westonruter westonruter force-pushed the update/reader-mode-availability branch from daed656 to 68f8c9a Compare June 14, 2019 00:41
@westonruter westonruter merged commit ba069d4 into develop Jun 14, 2019
@westonruter westonruter deleted the update/reader-mode-availability branch June 14, 2019 00:50
@kienstra
Copy link
Contributor

Hi @westonruter,
Hope your day's off to a great start.

What do you think about moving this to 'Ready for Merging,' without more functional testing? I could test this also, if that would help.

Thanks, Weston!

@westonruter
Copy link
Member Author

I did test various scenarios, including variables:

  • Upgrading from 1.0 to 1.2
  • Testing with DB that had theme_support option saved for native, paired, and disabled.
  • Activating a theme with theme support in 1.0 and ensuring the same mode is selected upon upgrade.
  • On fresh installs, activating the plugin should have default mode that corresponds to mode defined in the theme.

Having your set of eyes on testing to make sure it works as expected would be helpful.

*/
self::$support_added_via_option = ( $is_paired && self::STANDARD_MODE_SLUG === $theme_support_option ) ? self::STANDARD_MODE_SLUG : null;
if ( self::STANDARD_MODE_SLUG === self::$support_added_via_option ) {
// Make sure the user option can override what the theme has specified.
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea. Like you mentioned, the theme might have support, but plugins might not.

@kienstra
Copy link
Contributor

kienstra commented Jun 15, 2019

Upgrading from 1.0 to 1.2
theme_support option looks good

  1. 'Classic' mode to 'Reader' mode:

classic-mode

  1. 'Paired' mode to 'Transitional' mode:

paired-mode

  1. 'Native' mode to 'Standard' mode:

native-mode

Steps Taken

  1. Activate Twenty Nineteen
  2. Run wp option delete amp-options
  3. Use the 1.0.0-built tag
  4. In the AMP Options menu, observe that 'Classic' mode is selected
  5. Use the `1.2-RC1-built tag
  6. Verify that the right template options are present, like 'Reader' mode
  7. Repeat steps 2-6 for 'Paired' and 'Native' modes (though in step 4, change the template mode)

@kienstra
Copy link
Contributor

kienstra commented Jun 15, 2019

Theme with declared AMP support
Worked as expected

Activating a theme with theme support in 1.0 and ensuring the same mode is selected upon upgrade.

Steps Taken

  1. Activate Twenty Fifteen child theme that has add_theme_support( 'amp' )
  2. wp option delete amp-options
  3. git fetch --tags && git checkout 1.0.0-built
  4. Observe the AMP Settings page:

1 0-native

  1. git checkout 1.2-RC1-built
  2. In the AMP Options menu, observe that 'Standard' mode is selected, as expected:

1 2-native

  1. Repeat steps 2-5, but in the child theme change add_theme_support( 'amp' ) to add_theme_support( 'amp', array( 'paired' => true ) )

  2. As expected, on checking out 1.2-RC1-built, it's in 'Transitional' mode:

transitional-1 2

  1. 'Transitional' mode works as expected, with a non-AMP URL and an AMP URL

@kienstra
Copy link
Contributor

kienstra commented Jun 15, 2019

Testing on (simulated) fresh install
Also worked as expected

On fresh installs, activating the plugin should have default mode that corresponds to mode defined in the theme.

Steps Taken

  1. wp option delete amp-options # simulate a fresh install
  2. git checkout 1.2-RC1-built
  3. Activate a Twenty Fifteen child theme that has add_theme_support( 'amp' )
  4. As expected, 'Standard' mode is selected:

1 2-rc1-native

  1. wp option delete amp-options
  2. In the child theme, change add_theme_support( ‘amp’ ) to add_theme_support( ‘amp’, array( ‘paired’ => true ) )
  3. As expected, 'Transitional' is selected, but the user can change it:

theme-paired

@kienstra
Copy link
Contributor

Looks Good!

Hi @westonruter,
Sorry for the delay. All of the variables that you mentioned above also looked good in my testing.

See you soon!

@westonruter
Copy link
Member Author

Thank you for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Signed the Google CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants