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

Portfolio / Testimonials: on block themes remove settings and menu items when not in use #41714

Merged

Conversation

coder-karen
Copy link
Contributor

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

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

Proposed changes:

  • This PR ensures that for sites using block themes, testimonials and portfolios aren't shown as options to toggle on and off (in Jetpack > Settings > Writing, and Settings > Writing) unless either is already active, or either already have published posts. With the latter check, this relies on a transient, so is useful only as a temporary fallback for any accidental toggle switches.
  • Filters have also been added - classic_theme_helper_should_display_portfolios and classic_theme_helper_should_display_testimonials so that on a site by site basis the display of testimonial or portfolio settings can be overridden.
  • No changes will be made to Calypso page settings due to current projects related to those pages (see the linked issue for relevant links).

Code coverage note: Nothing in the Classic Theme Helper package has any existing tests. I'll add an internal issue to look at 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

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

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

No.

Testing instructions:

To test, on a self-hosted site testing locally or using the beta tester plugin, or an WoA site using the beta tester plugin and both branches (with just the Jetpack Mu Wpcom plugin using the branch, behavior should be as before). Also on Simple, using the commands in the generated comment below, for a sandboxed test site.

  • On trunk / latest Jetpack version, add any theme and enable both Testimonials and Portfolios (either at Jetpack > Settings > Writing - /wp-admin/admin.php?page=jetpack#writing for WoA and self-hosted only, or Settings > Writing - /wp-admin/options-writing.php)
  • Add a couple of Testimonials and Portfolio items - making sure there are no published versions of either (only drafts or trashed versions).
  • Disable both Testimonials and Portfolios and then switch to a block-based theme if not using one already (for example Twenty Twenty Five). You should still be able to toggle off and on both Portfolios and Testimonials.
  • Switch to this branch and refresh both the Jetpack > Settings > Writing page and the Settings > Writing page (just Settings > Writing for Simple sites).
  • You should not see a custom content type section at all.
  • Switch to a theme that supports one or both custom post types (Sketch - Portfolios, Dara - Testimonials, Lodestar - both). The toggles should be visible again (and the toggle for the option that the theme supports should be on, eg. portfolios for Sketch).
  • Now removed: Now make sure you convert a testimonial or portfolio item to be published , then turn both testimonial and portfolios of with the toggles on either settings page. On WoA / Simple you may need to switch to a theme such as Twenty Fifteen as you won't be able to toggle off / on a CPT if the theme supports it.
  • Now removed: Switching back to a block based theme, you should now see the custom post type (testimonials or portfolios) as a toggle-able option on either settings page. As a disclaimer though, the 'count' functionality that checks if there are published testimonials or portfolios relies on a transient if that post type is not active. As such it isn't 100% reliable but is meant as a safety net if someone on a block theme accidentally toggles off portfolios or testimonials with published items in either.
  • A more reliable test is to toggle on testimonials or portfolios when on a non block based theme, then switch to a block based theme. The toggle that was on should remain on.
  • Test different configurations - different themes (eg non block themes that don't support either CPT, an example could be Twenty Fifteen), published / non published posts if you can, to make sure the result is as expected. Note as well that if you switch from a theme that enables support for eg Portfolios and toggles that on by default, it is expected that that would toggle off when switching to another theme if there are no active items there - that's previous behaviour.
  • Menu items should display / not display when expected as well.
  • If you have access to run SQL commands on a test site, you can run 'DELETE FROM wp_options WHERE option_name LIKE ('_transient_jetpack-testimonial-count-cache');' and 'DELETE FROM wp_options WHERE option_name = '_transient_timeout_jetpack-testimonial-count-cache';' (and the same for portfolios) if you want to test behavior without the transients.

To test the filter:

  • On self-hosted or WoA, add a functionality plugin like Code Snippets.
  • Make sure on your test site that you have a block theme active, and that testimonials are not displaying (not toggled on).
  • Add the following filter:
add_filter( 'classic_theme_helper_should_display_testimonials', function( $should_display ) {
    return true;
});
  • Testimonials should now be an option on both settings pages. The same can be done for portfolios.

@coder-karen coder-karen added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. labels Feb 11, 2025
@coder-karen coder-karen self-assigned this Feb 11, 2025
Copy link
Contributor

github-actions bot commented Feb 11, 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 remove/portfolio-testimonial-settings-menu-block-themes 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 remove/portfolio-testimonial-settings-menu-block-themes
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin remove/portfolio-testimonial-settings-menu-block-themes
    

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

@github-actions github-actions bot added [Feature] Theme Tools [Package] Classic Theme Helper [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Admin Page React-powered dashboard under the Jetpack menu labels Feb 11, 2025
Copy link
Contributor

github-actions bot commented Feb 11, 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.

Copy link
Contributor

github-actions bot commented Feb 11, 2025

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/classic-theme-helper/src/custom-post-types/class-jetpack-portfolio.php 0/583 (0.00%) 0.00% 17 💔
projects/packages/classic-theme-helper/src/custom-post-types/class-jetpack-testimonial.php 0/412 (0.00%) 0.00% 11 💔
projects/packages/classic-theme-helper/src/custom-content-types.php 0/90 (0.00%) 0.00% 7 💔
projects/plugins/jetpack/_inc/client/writing/custom-content-types.jsx 0/30 (0.00%) 0.00% 2 ❤️‍🩹

Full summary · PHP report · JS report

Add label I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. to override the failing coverage check.

@coder-karen coder-karen marked this pull request as ready for review February 11, 2025 13:10
Copy link

jp-launch-control bot commented Feb 17, 2025

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/classic-theme-helper/src/custom-post-types/class-jetpack-portfolio.php 0/575 (0.00%) 0.00% 9 💔
projects/packages/classic-theme-helper/src/custom-post-types/class-jetpack-testimonial.php 0/410 (0.00%) 0.00% 9 💔
projects/packages/classic-theme-helper/src/custom-content-types.php 0/90 (0.00%) 0.00% 7 💔
projects/plugins/jetpack/_inc/client/writing/custom-content-types.jsx 0/30 (0.00%) 0.00% 2 ❤️‍🩹

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@fgiannar fgiannar self-requested a review February 17, 2025 12:54
Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

Testing on WoA:
The theme I had previously enabled was Lodestar. I could see both Testimonials and Portfolio after enabling the branch for both Jetpack and WPcom Features plugins.
I switched to Twenty Twenty-Four after trashing all my testimonials (no Portfolio projects) but now I only see the Testimonials under Custom content types:
Screenshot 2025-02-17 at 15 49 43

Testing on Simple
Similar behaviour. The theme I had previously enabled was Hola.
I trashed all my Testimonials and Portfolio projects.
I then switched to Twenty Twenty-Four but I can only see Testimonials available in Settings->Writing:
Screenshot 2025-02-17 at 15 45 18

Is this expected? I guess I should also see Portfolio, right?

@fgiannar fgiannar added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Feb 17, 2025
@coder-karen
Copy link
Contributor Author

Thanks for testing! It would seem the Testimonials were still displaying due to stored transients, assuming they'd been published before being trashed. However I did more testing and couldn't locate the transients when testing on a Jurassic Ninja site, so couldn't think of a different and reliable way to store a temporary value for the count, vs testing locally where I was able to modify the transients in the database.

I decided to pare things back to what was made in an original suggestion (P2 comment pfwV0U-ik-p2#comment-387), and only keep the feature enabled when switching to a block theme if it was already enabled, disregarding any previously published testimonials or portfolios.

@coder-karen coder-karen removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Feb 18, 2025
Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

Great work, Karen! Tested on Simple and WoA and all seems to work as described in the test instructions. Also thanks for baring with me and explaining the expected functionality in detail!

@fgiannar fgiannar added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Team Review labels Feb 18, 2025
@coder-karen coder-karen added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Feb 18, 2025
@coder-karen coder-karen merged commit ca38ed6 into trunk Feb 18, 2025
71 checks passed
@coder-karen coder-karen deleted the remove/portfolio-testimonial-settings-menu-block-themes branch February 18, 2025 10:31
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! 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
Labels
Admin Page React-powered dashboard under the Jetpack menu [Feature] Theme Tools I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Package] Classic Theme Helper [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants