Skip to content

Commit 03607c4

Browse files
committed
Remove plugin version number from download link
This is done so that it automatically downloads the latest version
1 parent 291e1b2 commit 03607c4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,9 @@ function perflab_install_and_activate_plugin( string $plugin_slug, array &$proce
372372
// Replace new Plugin_Installer_Skin with new Quiet_Upgrader_Skin when output needs to be suppressed.
373373
$skin = new WP_Ajax_Upgrader_Skin( array( 'api' => $plugin_data ) );
374374
$upgrader = new Plugin_Upgrader( $skin );
375-
$result = $upgrader->install( $plugin_data['download_link'] );
375+
// Remove the version number from the link to download the latest plugin version.
376+
$download_link = (string) preg_replace( '#(\/plugin\/[^\/]+)\.\d+\.\d+\.\d+\.zip#', '$1.zip', $plugin_data['download_link'] );
377+
$result = $upgrader->install( $download_link );
376378

377379
if ( is_wp_error( $result ) ) {
378380
return $result;

0 commit comments

Comments
 (0)