close
Skip to content

Commit 2bec0e8

Browse files
authored
Merge pull request #1651 from WordPress/fix/plugin-not-found-disambiguation
Fix uses of 'Plugin not found' string
2 parents f9e464b + 762df74 commit 2bec0e8

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
* @return array{name: string, slug: string, short_description: string, requires: string|false, requires_php: string|false, requires_plugins: string[], download_link: string, version: string}|WP_Error Array of plugin data or WP_Error if failed.
2020
*/
2121
function perflab_query_plugin_info( string $plugin_slug ) {
22-
$transient_key = 'perflab_plugins_info-v2';
22+
$transient_key = 'perflab_plugins_info';
2323
$plugins = get_transient( $transient_key );
2424

2525
if ( is_array( $plugins ) ) {
2626
// If the specific plugin_slug is not in the cache, return an error.
2727
if ( ! isset( $plugins[ $plugin_slug ] ) ) {
28-
return new WP_Error( 'plugin_not_found', __( 'Plugin not found.', 'performance-lab' ) );
28+
return new WP_Error(
29+
'plugin_not_found',
30+
__( 'Plugin not found in cached API response.', 'performance-lab' )
31+
);
2932
}
3033
return $plugins[ $plugin_slug ]; // Return cached plugin info if found.
3134
}
@@ -83,7 +86,10 @@ function perflab_query_plugin_info( string $plugin_slug ) {
8386
set_transient( $transient_key, $plugins, HOUR_IN_SECONDS );
8487

8588
if ( ! isset( $plugins[ $plugin_slug ] ) ) {
86-
return new WP_Error( 'plugin_not_found', __( 'Plugin not found.', 'performance-lab' ) );
89+
return new WP_Error(
90+
'plugin_not_found',
91+
__( 'Plugin not found in API response.', 'performance-lab' )
92+
);
8793
}
8894

8995
/**
@@ -359,8 +365,11 @@ function perflab_install_and_activate_plugin( string $plugin_slug, array &$proce
359365
}
360366

361367
$plugins = get_plugins( '/' . $plugin_slug );
362-
if ( empty( $plugins ) ) {
363-
return new WP_Error( 'plugin_not_found', __( 'Plugin not found.', 'default' ) );
368+
if ( count( $plugins ) === 0 ) {
369+
return new WP_Error(
370+
'plugin_not_found',
371+
__( 'Plugin not found among installed plugins.', 'performance-lab' )
372+
);
364373
}
365374

366375
$plugin_file_names = array_keys( $plugins );

0 commit comments

Comments
 (0)