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

Classic Theme Helper: Load relevant theme compat functionality from package #41598

Merged

Conversation

coder-karen
Copy link
Contributor

@coder-karen coder-karen commented Feb 6, 2025

Fixes https://github.com/Automattic/vulcan/issues/389

Proposed changes:

  • This PR requires the theme-tools compat files and functions that have been moved to the Classic Theme Helper package, from that package.
  • It also renames the filter copied over from modules/theme-tools.php to classic_theme_helper_theme_compat_files. This is to prevent loading issues that were obvious on Simple sites without the name change due to a file that hooks into the existing filter for those sites. Renaming the filter in the package prevents conflicts and continues to allow extensibility.
  • The PR to hook into the new filter for Simple sites is here - 172653-ghe-Automattic/wpcom - but the order in which either PR is merged makes no difference.

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

https://github.com/Automattic/vulcan/issues/389

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

No.

Testing instructions:

Test on self-hosted (testing locally or with the beta tester plugin), or WoA (using the beta tester plugin). The changes in this PR have no bearing for Simple sites but we can test that they are not affected - so test using the commands in the generated comment below on a sandboxed Simple site. On WoA and Simple the below implies both branches are checked out - if only one on WoA this just means we'll be loading only via that branch parent, but all functionality would still work).

Some random tests to confirm functionality is now loading via the Classic Theme Helper package:

  • Self-hosted / WoA: With TwentyFourteen active, open the Customizer > Featured Content. If you did not previously have a tag name set, the default 'featured' tag name will appear. To fully confirm it's coming from the package, you'd need to comment out the twentyfourteen_customizer_default function including the 'function_exists' check in modules/theme-tools/compat/twentyfourteen.php (If you load only via the Jetpack Mu WPcom plugin when testing WoA, commenting out the module file paths will prevent functionality. )
  • With Twenty Fifteen, Sixteen or Nineteen, ensure the responsive videos post type support works by adding a post, uploading a video (using the VideoPress block - you may need to ensure VideoPress is enabled at /wp-admin/admin.php?page=jetpack#performance), and then opening up page source on the the post front-end. You should see reference to jetpack-responsive-videos-css or responsive-videos.css (or responsive-videos.js on WoA). On Simple, the best option is to look for the jetpack-video-wrapper class in the div wrapping the video - for Simple we just want to confirm it is still working.

To confirm that we're still also reading the module file functions that are not duplicated in the Classic Theme Helper package:

  • Self-hosted only: With Twenty Fifteen, open a front-end page on your test site. View the page source, and look for the href for the twentyfifteen-jetpack-css script. It should be the modules file path.
    For Twenty Fourteen, Sixteen, Nineteen, Twenty, Twenty One, it's the same - twentyfourteen-jetpack-css etc.
  • WoA: As above, but you're looking for twentyfifteen-jetpack etc.

Copy link
Contributor

github-actions bot commented Feb 6, 2025

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/load-relevant-theme-compat-classic-theme-helper branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/load-relevant-theme-compat-classic-theme-helper
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/load-relevant-theme-compat-classic-theme-helper
    

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

Copy link
Contributor

github-actions bot commented Feb 6, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Jetpack plugin:

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

  • WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for none scheduled (scheduled code freeze on undefined).

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


Mu Wpcom plugin:

  • Next scheduled release: WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2).

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


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2).

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


Classic Theme helper plugin plugin:

  • Next scheduled release: none scheduled.

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 Feb 6, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/classic-theme-helper/src/class-main.php 0/30 (0.00%) 0.00% 1 ❤️‍🩹

Full summary · PHP report · JS report

… to prevent loading conflicts with the Jetpack module filter which will remain.
@coder-karen coder-karen changed the title Load relevant theme compat functionality from Classic Theme Helper pa… Classic Theme Helper: Load relevant theme compat functionality from package Feb 7, 2025
@coder-karen coder-karen marked this pull request as ready for review February 7, 2025 12:20
@coder-karen coder-karen requested a review from a team February 7, 2025 12:26
@coder-karen coder-karen added [Status] Needs Team Review Obsolete. Use Needs Review instead. and removed [Status] In Progress labels Feb 7, 2025
Copy link

jp-launch-control bot commented Feb 17, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/classic-theme-helper/src/class-main.php 0/30 (0.00%) 0.00% 1 ❤️‍🩹

Full summary · PHP report · JS report

@darssen darssen self-requested a review February 17, 2025 14:19
Copy link
Contributor

@darssen darssen left a comment

Choose a reason for hiding this comment

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

Thanks for the work here @coder-karen!

Changes make sense. I have added a comment regarding deprecating one public method instead of directly removing it. Let me know your thoughts.

The testing went well mainly, but for WoA I was not able to get the twentyfifteen-jetpack script file to ensure reading the module file functions that are not duplicated in the Classic Theme Helper package. Is there something I am missing?

@@ -78,15 +76,15 @@ public static function jetpack_load_theme_tools() {
/**
* Load theme compat file if it exists.
*/
public static function jetpack_load_theme_compat() {
public static function classic_theme_helper_load_theme_compat() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Although this is the Classic Theme Helper Package and its use might be minimal outside from the monorepo, should we deprecate first since it is a public method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the Classic Theme Helper package, we hadn't started hooking into that function yet, so it was never in use. I also searched internally and also via WPdirectory for the original function name, and it looks like no plugins or themes (or us) make use of the function whether it's via the modules file or package.
I'm reading mixed messaging about best practices in this case though.

The other option is to change the name back to what it was so as not to delay loading the features from the package, given there are also other unchanged function names in the same file.

Given that it wasn't in use, and the functionality it would have allowed was very minimal (and still duplicated in the modules file), I can't see why it would have been used externally. I'd veer toward renaming given all of that, but given the extra context where do you stand?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for all the details. After considering them I agree we should be fine by renaming 👍

@coder-karen
Copy link
Contributor Author

Thanks for testing!

The testing went well mainly, but for WoA I was not able to get the twentyfifteen-jetpack script file to ensure reading the module file functions that are not duplicated in the Classic Theme Helper package. Is there something I am missing?

I'm not too sure. What is your WoA test site setup? In my case, I have a WoA site, with the Beta tester plugin installed, and the branch checked out both via Jetpack and Jetpack Mu WPcom. I have installed and activated Twenty Fifteen, and with no ther changes I visit the homepage and open the page source, searching for twentyfifteen-jetpack. It's technically just a data-handle, no script source associated with it. This handle only exists via the module file, so if you see it, that confirms the module file is loading.

@darssen
Copy link
Contributor

darssen commented Feb 18, 2025

Thanks for testing!

The testing went well mainly, but for WoA I was not able to get the twentyfifteen-jetpack script file to ensure reading the module file functions that are not duplicated in the Classic Theme Helper package. Is there something I am missing?

I'm not too sure. What is your WoA test site setup? In my case, I have a WoA site, with the Beta tester plugin installed, and the branch checked out both via Jetpack and Jetpack Mu WPcom. I have installed and activated Twenty Fifteen, and with no ther changes I visit the homepage and open the page source, searching for twentyfifteen-jetpack. It's technically just a data-handle, no script source associated with it. This handle only exists via the module file, so if you see it, that confirms the module file is loading.

Yes, I am able to see the same data-handle. Approving :)

@coder-karen coder-karen merged commit ef7ae96 into trunk Feb 18, 2025
64 checks passed
@coder-karen coder-karen deleted the update/load-relevant-theme-compat-classic-theme-helper branch February 18, 2025 12:19
@github-actions github-actions bot removed the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Feb 18, 2025
@zinigor zinigor added this to the jetpack/14.4 milestone Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants