16
16
* @since 2.8.0
17
17
*
18
18
* @param string $plugin_slug The string identifier for the plugin in questions slug.
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.
19
+ * @return array{name: string, slug: string, short_description: string, requires: string|false, requires_php: string|false, requires_plugins: 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
22
$ transient_key = 'perflab_plugins_info ' ;
@@ -40,7 +40,6 @@ function perflab_query_plugin_info( string $plugin_slug ) {
40
40
'requires ' ,
41
41
'requires_php ' ,
42
42
'requires_plugins ' ,
43
- 'download_link ' ,
44
43
'version ' , // Needed by install_plugin_install_status().
45
44
);
46
45
@@ -113,7 +112,7 @@ function perflab_query_plugin_info( string $plugin_slug ) {
113
112
/**
114
113
* Validated (mostly) plugin data.
115
114
*
116
- * @var array<string, array{name: string, slug: string, short_description: string, requires: string|false, requires_php: string|false, requires_plugins: string[], download_link: string, version: string}> $plugins
115
+ * @var array<string, array{name: string, slug: string, short_description: string, requires: string|false, requires_php: string|false, requires_plugins: string[], version: string}> $plugins
117
116
*/
118
117
return $ plugins [ $ plugin_slug ];
119
118
}
@@ -343,11 +342,27 @@ function perflab_install_and_activate_plugin( string $plugin_slug, array &$proce
343
342
}
344
343
$ processed_plugins [] = $ plugin_slug ;
345
344
346
- $ plugin_data = perflab_query_plugin_info ( $ plugin_slug );
345
+ // Get the freshest data (including the most recent download_link) as opposed what is cached by perflab_query_plugin_info().
346
+ $ plugin_data = plugins_api (
347
+ 'plugin_information ' ,
348
+ array (
349
+ 'slug ' => $ plugin_slug ,
350
+ 'fields ' => array (
351
+ 'download_link ' => true ,
352
+ 'requires_plugins ' => true ,
353
+ 'sections ' => false , // Omit the bulk of the response which we don't need.
354
+ ),
355
+ )
356
+ );
357
+
347
358
if ( $ plugin_data instanceof WP_Error ) {
348
359
return $ plugin_data ;
349
360
}
350
361
362
+ if ( is_object ( $ plugin_data ) ) {
363
+ $ plugin_data = (array ) $ plugin_data ;
364
+ }
365
+
351
366
// Add recommended plugins (soft dependencies) to the list of plugins installed and activated.
352
367
if ( 'embed-optimizer ' === $ plugin_slug ) {
353
368
$ plugin_data ['requires_plugins ' ][] = 'optimization-detective ' ;
0 commit comments