-
Notifications
You must be signed in to change notification settings - Fork 102
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
Install and activate Optimization Detective when the Embed Optimizer feature is activated from the Performance screen #1644
Conversation
…feature is activated
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this 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.
plugins/performance-lab/load.php
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
// 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'] | ||
); | ||
} |
There was a problem hiding this comment.
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
.
This reverts commit b012d8d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @westonruter!
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