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

Live Preview: Disable the Global Styles limit when live previewing Woo and Premium themes #84924

Merged
merged 4 commits into from
Dec 7, 2023

Conversation

miksansegundo
Copy link
Contributor

@miksansegundo miksansegundo commented Dec 6, 2023

Related to #79223 #83630 #84676
Closes #84899

Proposed Changes

  • Do not enqueue the assets that limit Global Styles when live previewing a Premium theme if the site doesn't have a premium plan or higher.
  • The effect of the change above ^ is showing only one notice asking users to upgrade because the Global Styles notice won't appear when users change styles.
  • Plus, because the Global Styles gateway doesn't replace the Styles Welcome Guide, that guide appears when users click on the styles icon ☯️ and helps them to learn more about the Global Styles feature.
    • We could also show that guide to users when live previewing any theme because it adds value. WDYT?

BTW. I reported a minor issue on the copy of the Styles Welcome Guide that has been fixed.

BEFORE AFTER
Screenshot 2566-12-06 at 20 27 59 Screenshot 2566-12-06 at 20 29 52

Testing Instructions

In your sandbox run install-plugin.sh etk fix/live-preview-unique-notice

Upgrade Notice for Premium themes

  • Prepare a simple site with the Personal plan or lower plan.
  • Sandbox that site
  • Access https://<your-site>/wp-admin/site-editor.php?wp_theme_preview=<premium-theme> to preview a premium theme (e.g., premium/outland).
  • Change global styles and expect to see only the upgrade notice "You are previewing..."
  • Repeat the test on atomic uploading the ETK plugin for this branch
Screen.Recording.2566-12-06.at.20.11.47.mov

Upgrade Notice for Woo themes

  • Prepare a simple site with the Premium plan or higher plan.
  • Sandbox that site
  • Access https:///wp-admin/site-editor.php?wp_theme_preview= to preview a premium theme (e.g., premium/tsubaki).
  • Change global styles and expect to see only the upgrade notice "You are previewing..."
  • Repeat the test on atomic uploading the ETK plugin for this branch
Screen.Recording.2566-12-06.at.20.13.25.mov

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • https://wpcalypso.wordpress.com/devdocs/docs/testing/index.md for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-ajp-p2)?

@miksansegundo miksansegundo requested review from a team December 6, 2023 13:52
@miksansegundo miksansegundo self-assigned this Dec 6, 2023
@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Dec 6, 2023
Copy link

github-actions bot commented Dec 6, 2023

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

array_filter(
$software_sets,
function ( $software_set ) {
return $software_set->product_slug === 'woo-on-plans';
Copy link
Member

Choose a reason for hiding this comment

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

Could you update to check woo-on-plans here as well? 🙇 : https://github.com/Automattic/wp-calypso/blob/fba40b1/apps/wpcom-block-editor/src/wpcom/features/live-preview/hooks/use-previewing-theme.ts#L13

I realized that would be safer now (but might be changed to support bundle themes).
#84483 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'm on it.

Copy link
Member

@okmttdhr okmttdhr left a comment

Choose a reason for hiding this comment

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

LGTM with nits comments 👍
Thanks for working on this PR.

Copy link
Contributor

@taipeicoder taipeicoder left a comment

Choose a reason for hiding this comment

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

Nice solution! Tested:

  • Upgrade Notice for Premium themes

    • Prepare a simple site with the Personal plan or lower plan.
    • Sandbox that site
    • Access https:///wp-admin/site-editor.php?wp_theme_preview= to preview a premium theme (e.g., premium/outland).
    • ✅ Change global styles and expect to see only the upgrade notice "You are previewing..."
    • ✅ Repeat the test on atomic uploading the ETK plugin for this branch
  • Upgrade Notice for Woo themes

    • Prepare a simple site with the Personal plan or lower plan.
    • Sandbox that site
    • Access https:///wp-admin/site-editor.php?wp_theme_preview= to preview a premium theme (e.g., premium/tsubaki).
    • ✅ Change global styles and expect to see only the upgrade notice "You are previewing..."
    • ✅ Repeat the test on atomic uploading the ETK plugin for this branch

@@ -62,6 +62,16 @@ function wpcom_should_limit_global_styles( $blog_id = 0 ) {
return false;
}

// Do not limit Global Styles when live previewing a Woo theme without a Business plan or higher.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it's simpler to just check for "Do not limit Global Styles when live previewing a premium theme, and the site has a premium plan or higher", since we only want to know about these conditions in particular:

  1. Is live previewing.
  2. Is premium theme.
  3. wpcom_site_has_feature( WPCOM_Features::GLOBAL_STYLES, $blog_id ) is true.

This way we don't need to check whether the premium theme is Premium or WooCommerce 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I have implemented that logic but struggled while testing it because wpcom_site_has_feature( WPCOM_Features::GLOBAL_STYLES, $blog_id ) always returns false when a sandboxed site has a premium plan or higher.

I've asked T-Rex about that in p1701937616146419-slack-C04DZ8M0GHW

@matticbot
Copy link
Contributor

matticbot commented Dec 7, 2023

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • editing-toolkit
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/live-preview-unique-notice on your sandbox.

@miksansegundo
Copy link
Contributor Author

I updated the code to make it simpler but won't work when testing on our sandbox. I vote for deploying and testing it on production. Thoughts?

@taipeicoder
Copy link
Contributor

I updated the code to make it simpler but won't work when testing on our sandbox. I vote for deploying and testing it on production. Thoughts?

Yes, let's deploy 🚢

@miksansegundo miksansegundo merged commit 2a2109a into trunk Dec 7, 2023
12 checks passed
@miksansegundo miksansegundo deleted the fix/live-preview-unique-notice branch December 7, 2023 11:58
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 7, 2023
@miksansegundo
Copy link
Contributor Author

It's working fine 😍
Please retest when you can 🙏

cpapazoglou pushed a commit that referenced this pull request Dec 11, 2023
…o and Premium themes (#84924)

* Disable Global Styles limit for live previewing woo and premium themes on Dotcom

* Simplify by not limiting Global Styles when live previewing a Premium theme with a Premium plan or higher

* Update apps/editing-toolkit/editing-toolkit-plugin/wpcom-global-styles/index.php

Co-authored-by: Griffith Chen <griffith.chen@automattic.com>

* Update naming and comments to be more clear

---------

Co-authored-by: Griffith Chen <griffith.chen@automattic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Live preview: Ensure showing only one notice simultaneously by hiding the Global Style notice
4 participants