Skip to content

Commit b012d8d

Browse files
committed
Remove hard-coded reference to embed-optimizer
1 parent 7bee476 commit b012d8d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

plugins/performance-lab/includes/admin/plugins.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,12 @@ function perflab_install_and_activate_plugin( string $plugin_slug, array &$proce
325325
}
326326

327327
// Add recommended plugins (soft dependencies) to the list of plugins installed and activated.
328-
if ( 'embed-optimizer' === $plugin_slug ) {
329-
$plugin_data['requires_plugins'][] = 'optimization-detective';
328+
$standalone_plugin_data = perflab_get_standalone_plugin_data();
329+
if ( isset( $standalone_plugin_data[ $plugin_slug ]['suggest'] ) ) {
330+
$plugin_data['requires_plugins'] = array_merge(
331+
$plugin_data['requires_plugins'],
332+
$standalone_plugin_data[ $plugin_slug ]['suggest']
333+
);
330334
}
331335

332336
// Install and activate plugin dependencies first.

plugins/performance-lab/load.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,15 @@ function perflab_render_generator(): void {
8383
*
8484
* @since 3.0.0
8585
*
86-
* @return array<string, array{'constant': string, 'experimental'?: bool}> Associative array of $plugin_slug => $plugin_data pairs.
86+
* @return array<string, array{'constant': string, 'experimental'?: bool, 'suggest'?: string[]}> Associative array of $plugin_slug => $plugin_data pairs.
8787
*/
8888
function perflab_get_standalone_plugin_data(): array {
8989
/*
9090
* Alphabetically sorted list of plugin slugs and their data.
9191
* Supported keys per plugin are:
9292
* - 'constant' (string, required)
9393
* - 'experimental' (boolean, optional)
94+
* - 'suggest' (string[], optional)
9495
*/
9596
return array(
9697
'auto-sizes' => array(
@@ -103,6 +104,7 @@ function perflab_get_standalone_plugin_data(): array {
103104
'embed-optimizer' => array(
104105
'constant' => 'EMBED_OPTIMIZER_VERSION',
105106
'experimental' => true,
107+
'suggest' => array( 'optimization-detective' ),
106108
),
107109
'image-prioritizer' => array(
108110
'constant' => 'IMAGE_PRIORITIZER_VERSION',

0 commit comments

Comments
 (0)