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

Install and activate Optimization Detective when the Embed Optimizer feature is activated from the Performance screen #1644

Merged
merged 3 commits into from
Nov 11, 2024

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Nov 11, 2024

Fixes #1615

Most of the optimizations provided by Embed Optimizer require the Optimization Detective plugin. So this PR will automatically install and activate Optimization Detective when the Embed Optimizer feature is activated from the Performance screen.

Screen recording:

Screen.recording.2024-11-11.09.03.26.webm

Build for testing: performance-lab.zip

@westonruter westonruter added [Type] Enhancement A suggestion for improvement of an existing feature [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only labels Nov 11, 2024
@westonruter westonruter added this to the performance-lab n.e.x.t milestone Nov 11, 2024
@westonruter westonruter marked this pull request as ready for review November 11, 2024 17:16
Copy link

github-actions bot commented Nov 11, 2024

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: westonruter <[email protected]>
Co-authored-by: felixarntz <[email protected]>

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

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@westonruter While functionally this is a good call, I think we should not introduce a "half-baked" API for something like plugin suggestions which would need more thought.

@@ -83,14 +83,15 @@ function perflab_render_generator(): void {
*
* @since 3.0.0
*
* @return array<string, array{'constant': string, 'experimental'?: bool}> Associative array of $plugin_slug => $plugin_data pairs.
* @return array<string, array{'constant': string, 'experimental'?: bool, 'suggest'?: string[]}> Associative array of $plugin_slug => $plugin_data pairs.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we want to establish this as something we may want to do more, given that this is not a thing that WordPress Core supports.

Therefore instead of introducing a "schema" change here, I think we should for now hard-code this in perflab_install_and_activate_plugin(). Feels more hacky, but is more future-proof as it doesn't change any portion of the API. Given that this PR simply takes the "suggested" feature as if it was "required", that part would need more thought if we truly wanted to establish a way to suggest a feature.

Comment on lines 327 to 334
// Add recommended plugins (soft dependencies) to the list of plugins installed and activated.
$standalone_plugin_data = perflab_get_standalone_plugin_data();
if ( isset( $standalone_plugin_data[ $plugin_slug ]['suggest'] ) ) {
$plugin_data['requires_plugins'] = array_merge(
$plugin_data['requires_plugins'],
$standalone_plugin_data[ $plugin_slug ]['suggest']
);
}
Copy link
Member

Choose a reason for hiding this comment

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

See my other comment: For those reasons, I think we should simply hard-code here: If embed-optimizer, add optimization-detective to requires_plugins.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Thanks @westonruter!

@felixarntz felixarntz merged commit 5fbd82e into trunk Nov 11, 2024
14 checks passed
@felixarntz felixarntz deleted the add/od-install-upon-embed-optimizer-activate branch November 11, 2024 18:36
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] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimization Detective should be automatically installed and activated when activating Embed Optimizer
2 participants