Skip to content

Commit

Permalink
Merge pull request #1644 from WordPress/add/od-install-upon-embed-opt…
Browse files Browse the repository at this point in the history
…imizer-activate

Install and activate Optimization Detective when the Embed Optimizer feature is activated from the Performance screen
  • Loading branch information
felixarntz authored Nov 11, 2024
2 parents a58f236 + 70f90b6 commit 5fbd82e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/performance-lab/includes/admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function perflab_query_plugin_info( string $plugin_slug ) {
$plugins = array();
$standalone_plugins = array_merge(
array_flip( perflab_get_standalone_plugins() ),
array( 'optimization-detective' => array() ) // TODO: Programmatically discover the plugin dependencies and add them here.
array( 'optimization-detective' => array() ) // TODO: Programmatically discover the plugin dependencies and add them here. See <https://github.com/WordPress/performance/issues/1616>.
);
foreach ( $response->plugins as $plugin_data ) {
if ( ! isset( $standalone_plugins[ $plugin_data['slug'] ] ) ) {
Expand Down Expand Up @@ -324,6 +324,11 @@ function perflab_install_and_activate_plugin( string $plugin_slug, array &$proce
return $plugin_data;
}

// Add recommended plugins (soft dependencies) to the list of plugins installed and activated.
if ( 'embed-optimizer' === $plugin_slug ) {
$plugin_data['requires_plugins'][] = 'optimization-detective';
}

// Install and activate plugin dependencies first.
foreach ( $plugin_data['requires_plugins'] as $requires_plugin_slug ) {
$result = perflab_install_and_activate_plugin( $requires_plugin_slug );
Expand Down

0 comments on commit 5fbd82e

Please sign in to comment.