|
19 | 19 | * @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. |
20 | 20 | */ |
21 | 21 | function perflab_query_plugin_info( string $plugin_slug ) { |
22 | | - $transient_key = 'perflab_plugins_info-v2'; |
| 22 | + $transient_key = 'perflab_plugins_info'; |
23 | 23 | $plugins = get_transient( $transient_key ); |
24 | 24 |
|
25 | 25 | if ( is_array( $plugins ) ) { |
26 | 26 | // If the specific plugin_slug is not in the cache, return an error. |
27 | 27 | 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 | + ); |
29 | 32 | } |
30 | 33 | return $plugins[ $plugin_slug ]; // Return cached plugin info if found. |
31 | 34 | } |
@@ -83,7 +86,10 @@ function perflab_query_plugin_info( string $plugin_slug ) { |
83 | 86 | set_transient( $transient_key, $plugins, HOUR_IN_SECONDS ); |
84 | 87 |
|
85 | 88 | 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 | + ); |
87 | 93 | } |
88 | 94 |
|
89 | 95 | /** |
@@ -359,8 +365,11 @@ function perflab_install_and_activate_plugin( string $plugin_slug, array &$proce |
359 | 365 | } |
360 | 366 |
|
361 | 367 | $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 | + ); |
364 | 373 | } |
365 | 374 |
|
366 | 375 | $plugin_file_names = array_keys( $plugins ); |
|
0 commit comments