Skip to content

Conversation

@ShyamGadde
Copy link
Contributor

Summary

Fixes #2136

@ShyamGadde ShyamGadde added the [Type] Bug An existing feature is broken label Aug 20, 2025
@ShyamGadde ShyamGadde added this to the performance-lab n.e.x.t milestone Aug 20, 2025
@ShyamGadde ShyamGadde added the [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only label Aug 20, 2025
@codecov
Copy link

codecov bot commented Aug 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.91%. Comparing base (15e51bc) to head (19e7bd7).
⚠️ Report is 17 commits behind head on trunk.

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk    #2143      +/-   ##
==========================================
+ Coverage   68.74%   68.91%   +0.16%     
==========================================
  Files          91       91              
  Lines        7996     8033      +37     
==========================================
+ Hits         5497     5536      +39     
+ Misses       2499     2497       -2     
Flag Coverage Δ
multisite 68.91% <100.00%> (+0.16%) ⬆️
single 35.59% <43.75%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ShyamGadde ShyamGadde requested a review from westonruter August 20, 2025 16:35
);

// Only show if the feature plugin is not already active and not installed.
if ( ! in_array( 'view-transitions', $installed_plugin_slugs, true ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Similar to SPECULATION_RULES_VERSION, we should also check for VIEW_TRANSITIONS_VERSION here.

The same applies to the No-cache BFCache plugin, but I noticed it doesn’t currently define a version: https://github.com/westonruter/nocache-bfcache/blob/main/nocache-bfcache.php.

@westonruter Do you think we should define a version there as well, similar to how other Performance Lab plugins handle it?

Copy link
Member

@westonruter westonruter Aug 21, 2025

Choose a reason for hiding this comment

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

It does define a version, actually: https://github.com/westonruter/nocache-bfcache/blob/1f7118afee2dbdc43fc1642a7eac4a8ab81911c5/nocache-bfcache.php#L37

This constant is being used currently by the PL plugin when constructing the meta generator tag.

'constant' => 'WestonRuter\NocacheBFCache\VERSION',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to SPECULATION_RULES_VERSION, we should also check for VIEW_TRANSITIONS_VERSION here.

I initially considered using constants (as seen in commit 4a0fb05) to check if the plugin is active. However, this approach only accounts for active plugins and does not handle the case where the plugin is installed but deactivated.

To address both scenarios (active plugins and installed-but-deactivated plugins), I opted to use the plugin slug in the subsequent commit. This ensures the pointer is not shown in either case.

If you still feel that the constant-based approach is preferable, I’m happy to revert to the earlier implementation. Let me know your thoughts!

cc @westonruter

Copy link
Member

Choose a reason for hiding this comment

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

@ShyamGadde I think what you've done makes sense. The admin pointer should be be shown if a feature plugin has been installed or activated, since either is a signal that the use is already aware of the feature and doesn't need the pointer to inform them of anything.

@ShyamGadde ShyamGadde marked this pull request as ready for review August 21, 2025 09:39
@ShyamGadde ShyamGadde requested a review from felixarntz as a code owner August 21, 2025 09:39
@github-actions
Copy link

github-actions bot commented Aug 21, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ShyamGadde <[email protected]>
Co-authored-by: westonruter <[email protected]>
Co-authored-by: mukeshpanchal27 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter
Copy link
Member

@ShyamGadde there's one more scenario that I think would make sense to include here: what if someone has Performance Lab installed and they already have View Transitions installed. What if they then uninstall View Transitions? Would this not then cause the View Transitions admin pointer to immediately get displayed? If so, then I think we should proactively add the View Transitions admin pointer to the list of dismissed pointers, similar to how we dismiss all pointers when landing on the Performance screen.

@westonruter
Copy link
Member

@ShyamGadde I did some refactoring to improve coverage and make it so that there was only one call to update_user_meta(). Please take a look.

$installed_plugins = get_plugins();
if (
defined( 'SPECULATION_RULES_VERSION' )
isset( $installed_plugins['speculation-rules/load.php']['Version'] )
Copy link
Member

Choose a reason for hiding this comment

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

This change allows for the code to be tested without having to define the constant by loading the plugin.

if ( ! in_array( $hook_suffix, array( 'index.php', 'plugins.php' ), true ) ) {

// And if we're on the Performance screen, automatically dismiss the pointers.
if ( isset( $_GET['page'] ) && PERFLAB_SCREEN === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
Copy link
Member

Choose a reason for hiding this comment

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

This turns out to not have been ideal. It should have used $hooks_suffix, to see if it is equal to 'settings_page_' . PERFLAB_SCREEN.

* Requires at least: 6.6
* Requires PHP: 7.2
* Version: 1.5.0
* Version: 1.6.0
Copy link
Member

Choose a reason for hiding this comment

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

This version bump was required in order to test the new admin pointer.

@westonruter
Copy link
Member

Build for testing: performance-lab.zip

// Pointer Options.
const options = {
content: <?php echo wp_json_encode( '<h3>' . esc_html( $args['heading'] ) . '</h3>' . wp_kses( $args['content'], $wp_kses_options ) ); ?>,
content: <?php echo wp_json_encode( '<h3>' . esc_html( $args['heading'] ) . '</h3>' . wp_kses( $args['content'], $wp_kses_options ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>,
Copy link
Member

Choose a reason for hiding this comment

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

@westonruter
Copy link
Member

Some last sanity checks…

When installing the plugin for the first time, I get this the initial pointer as expected:

Screenshot 2025-08-25 at 08 33 16

If I have already had the plugin installed and the initial pointer was dismissed, then upgrading to the new version shows the expected pointers:

Screenshot 2025-08-25 at 08 34 27

Upon updating Speculative Loading to the latest build, I then its specific pointer:

Screenshot 2025-08-25 at 08 36 47

@westonruter westonruter merged commit 1baf227 into WordPress:trunk Aug 25, 2025
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Type] Bug An existing feature is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin pointer for new plugin should be omitted if plugin is already active

3 participants