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

Custom CSS: add deprecation warning for Start Fresh option #37193

Merged
merged 13 commits into from
Jun 26, 2024

Conversation

monsieur-z
Copy link
Contributor

@monsieur-z monsieur-z commented May 2, 2024

Proposed changes:

The Custom CSS feature will soon be deprecated from Jetpack.

In this PR, we're adding warnings for sites with the Start Fresh option enabled. Since this option prevents the site from loading the theme CSS, removing it will likely break the site design.

Site admins must take action, so these warnings must be visible. We've added them in 4 different places:

  • The Customizer
  • At the top of the Jetpack Dashboard and Settings pages
  • In the Custom CSS section of the Settings page
  • At the top of the frontend of the site, for admins only

Simple and atomic sites are not concerned by this.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

pfwV0U-4M-p2

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

Prerequisites

  • Spin up a test site with this branch
  • Install a classic theme (i.e. non block-based) such as Twenty Eleven
  • Connect Jetpack
  • Search for the Custom CSS section in the settings page: /wp-admin/admin.php?page=jetpack#/settings?term=css
  • Enable the CSS customization panel enhancement
Screenshot 2024-05-02 at 4 05 00 PM
  • Go to the Additional CSS section of the Customizer: /wp-admin/customize.php?autofocus%5Bsection%5D=custom_css
  • Enable the Start Fresh option
Screenshot 2024-05-02 at 4 07 49 PM

Notices

  • Refresh the page
  • Notice the warning at the top of the Customizer sidebar
Screenshot 2024-05-02 at 4 09 04 PM
  • Go back to the Custom CSS section in the settings section: /wp-admin/admin.php?page=jetpack#/settings?term=css
  • Verify it now displays a warning
Screenshot 2024-05-02 at 4 10 10 PM
  • Check that a similar warning is shown at the top of the page (in the Settings and Dashboard pages)
Screenshot 2024-05-02 at 4 10 46 PM
  • Visit the frontend of the site: check that you see a notice when you're authenticated as an admin only
Screenshot 2024-05-14 at 10 46 57 AM
  • In the Customizer, disable the Start Fresh option
  • Check the warnings are not displayed anymore
  • Optionally, test that the notices do not appear on simple and atomic sites, since the option will still be available in these instances

@github-actions github-actions bot added [Feature] Custom CSS [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress Admin Page React-powered dashboard under the Jetpack menu labels May 2, 2024
Copy link
Contributor

github-actions bot commented May 2, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for July 2, 2024 (scheduled code freeze on July 1, 2024).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

github-actions bot commented May 2, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the update/custom-css-start-fresh-warning branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/custom-css-start-fresh-warning
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@@ -30,6 +30,7 @@ public static function add_hooks() {
add_action( 'load-revision.php', array( __CLASS__, 'load_revision_php' ) );

add_action( 'wp_enqueue_scripts', array( __CLASS__, 'wp_enqueue_scripts' ) );
add_action( 'admin_footer', array( __CLASS__, 'update_initial_state' ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if that's the most appropriate hook to use. Let me know if there's a more suited one.

*/
public static function update_initial_state() {
$start_fresh = null;
// $wp_customize is not available here. Let's get the value of the `replace` option from the last
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since $wp_customize is unavailable here, I had to go with a more imperative approach to fetch the value of the Start Fresh option. Let me know if there's a better alternative.

'react-plugin',
"
try {
var options = window.Initial_State?.getModules?.['custom-css']?.options || {};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems the most straightforward way to make the value of the Start Fresh option available to client pages (the Customizer case is handled separately).

@monsieur-z monsieur-z marked this pull request as ready for review May 2, 2024 20:46
@monsieur-z monsieur-z requested a review from a team May 2, 2024 20:46
@monsieur-z monsieur-z self-assigned this May 2, 2024
i: <i />,
b: <b />,
a1: <CustomizerLink siteAdminUrl={ siteAdminUrl } />,
a2: <a href="https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/" />,
Copy link
Contributor

Choose a reason for hiding this comment

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

As it's an external link, should this open in a new tab instead, with rel="noopener noreferrer" and target="_blank"?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could rely on ExternalLink here, to handle both the display and the markup at once?

'contentWidth' => $content_help,
'revisions' => _x( 'See full history', 'Toolbar button to see full CSS revision history', 'jetpack' ),
'css_help_title' => _x( 'Help', 'Toolbar button to get help with custom CSS', 'jetpack' ),
'startFreshCustomizerWarning' => __( "The Start Fresh option in the Additional CSS panel is enabled, which means the theme's original CSS is not applied. This option will no longer be supported.", 'jetpack' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

With this, along with StartFreshDeprecationWarning, I wonder if we may need design/marketing input on the wording itself here? The part I am stumbling on in particular is 'This option will no longer be supported.' - I wonder if we need to allude to a sense of urgency even if not giving a date.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I came here to suggest the same thing. I think we need a date for it to be really useful. I would recommend giving a date matching the July or August monthly release (first Tuesday of the month) to give folks time to make the changes.

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Building on @coder-karen 's comment about wording and timing, I think it may be worth asking folks on Jetpack Design for their input on wording and the best combination of messages to ensure folks understand:

  • How and when the Custom CSS feature is going away
  • What that means for them
  • If they have to take action (i.e. if they use the start fresh), what they should do.

It may be worth p2'ing this on their p2 to get their full input on it maybe, so they can work on the different possible flows?

@@ -724,6 +731,8 @@ public static function customize_register( $wp_customize ) {
}
}

$deprecated_suffix = ' (' . __( 'deprecated', 'jetpack' ) . ')';
Copy link
Member

Choose a reason for hiding this comment

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

I think it may be best to edit the strings directly to add "(deprecated)". It will make easier for translators to provide meaningful, since not all languages would use this "term (deprecated)" format in the first place (RTL languages come to mind).

Yes, that will mean the strings will become untranslated for a bit, but I think it would still be a better experience in the end.

/**
* Update the initial state to include the `replace` option (Start Fresh) in the module data.
*/
public static function update_initial_state() {
Copy link
Member

Choose a reason for hiding this comment

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

Since this is only meant to be useful in the Jetpack dashboard, I think we should limit it to that page. We don't want to run a posts query on dashboard pages where it won't be used.

Hooking into admin_enqueue_scripts instead of admin_footer should give you more control there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

admin_enqueue_scripts won't work: the call to wp_add_inline_script in the callback will fail. But I could check the current page and bail out early if it's not the Jetpack dashboard.

'contentWidth' => $content_help,
'revisions' => _x( 'See full history', 'Toolbar button to see full CSS revision history', 'jetpack' ),
'css_help_title' => _x( 'Help', 'Toolbar button to get help with custom CSS', 'jetpack' ),
'startFreshCustomizerWarning' => __( "The Start Fresh option in the Additional CSS panel is enabled, which means the theme's original CSS is not applied. This option will no longer be supported.", 'jetpack' ),
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I came here to suggest the same thing. I think we need a date for it to be really useful. I would recommend giving a date matching the July or August monthly release (first Tuesday of the month) to give folks time to make the changes.

@monsieur-z
Copy link
Contributor Author

I've updated the link the notices, and added a notice in the frontend. I've updated the instructions accordingly.

Copy link
Contributor

@coder-karen coder-karen left a comment

Choose a reason for hiding this comment

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

On self hosted this looks good :)

As for an Atomic test site though (WoA dev site using rsync, and regular AT site using the beta tester plugin), I noticed that the dashboard notices weren't showing up. After digging a bit further, that appears to be because this.props.startFreshEnabled returns false when it should be true.

If this is replicable I think personally we'd want notices to display on the dashboard for Atomic sites as well, if it's possible.

@fgiannar fgiannar added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Team Review labels May 20, 2024
@monsieur-z
Copy link
Contributor Author

Thanks @coder-karen!

As for an Atomic test site though (WoA dev site using rsync, and regular AT site using the beta tester plugin), I noticed that the dashboard notices weren't showing up.

Interesting. I haven't been able to reproduce the issue on a regular AT site. Did you hit the Publish button in the Customizer after checking the option?
Screenshot 2024-05-23 at 2 06 19 PM

As for WoA sites, they shouldn't be impacted by this PR since they load their own plugin instead of the Jetpack module.

@monsieur-z monsieur-z force-pushed the update/custom-css-start-fresh-warning branch from 82fca2d to 39e9f61 Compare May 23, 2024 18:08
@monsieur-z
Copy link
Contributor Author

Instructions updated. PR's ready for review.

@monsieur-z monsieur-z force-pushed the update/custom-css-start-fresh-warning branch from 7c6ff0f to 7651571 Compare June 25, 2024 12:52
Copy link
Contributor

@sergeymitr sergeymitr left a comment

Choose a reason for hiding this comment

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

Works well, looks great 👍

@monsieur-z monsieur-z merged commit cca4617 into trunk Jun 26, 2024
56 checks passed
@monsieur-z monsieur-z deleted the update/custom-css-start-fresh-warning branch June 26, 2024 12:59
@github-actions github-actions bot added this to the jetpack/13.6 milestone Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu [Feature] Custom CSS [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants