Improve latest version detection in plugin updater. Props DD32. fixes #8129
git-svn-id: http://svn.automattic.com/wordpress/trunk@9793 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
961a173fd3
commit
f5d551efe0
|
@ -425,8 +425,23 @@ function install_plugin_information() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( 'install' == $type && file_exists( WP_PLUGIN_DIR . '/' . $api->slug ) ) //TODO: Make more.. searchable?
|
if ( 'install' == $type && is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
|
||||||
$type = 'latest_installed';
|
$installed_plugin = get_plugins('/' . $api->slug);
|
||||||
|
if ( ! empty($installed_plugin) ) {
|
||||||
|
$key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
|
||||||
|
if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '>') ){
|
||||||
|
$type = 'latest_installed';
|
||||||
|
} elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
|
||||||
|
$type = 'newer_installed';
|
||||||
|
$newer_version = $installed_plugin[ $key ]['Version'];
|
||||||
|
} else {
|
||||||
|
//If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
|
||||||
|
delete_option('update_plugins');
|
||||||
|
$update_file = $api->slug . '/' . $key; //This code branch only deals with a plugin which is in a folder the same name as its slug, Doesnt support plugins which have 'non-standard' names
|
||||||
|
$type = 'update_available';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch ( $type ) :
|
switch ( $type ) :
|
||||||
default:
|
default:
|
||||||
|
@ -440,6 +455,11 @@ function install_plugin_information() {
|
||||||
?><a href="<?php echo wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file) ?>" target="_parent"><?php _e('Install Update Now') ?></a><?php
|
?><a href="<?php echo wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file) ?>" target="_parent"><?php _e('Install Update Now') ?></a><?php
|
||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
|
case 'newer_installed':
|
||||||
|
if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) :
|
||||||
|
?><a><?php printf(__('Newer Version (%s) Installed'), $newer_version) ?></a><?php
|
||||||
|
endif;
|
||||||
|
break;
|
||||||
case 'latest_installed':
|
case 'latest_installed':
|
||||||
if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) :
|
if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) :
|
||||||
?><a><?php _e('Latest Version Installed') ?></a><?php
|
?><a><?php _e('Latest Version Installed') ?></a><?php
|
||||||
|
|
|
@ -272,6 +272,7 @@ function _maybe_update_themes( ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'load-plugins.php', 'wp_update_plugins' );
|
add_action( 'load-plugins.php', 'wp_update_plugins' );
|
||||||
|
add_action( 'load-update.php', 'wp_update_plugins' );
|
||||||
add_action( 'admin_init', '_maybe_update_plugins' );
|
add_action( 'admin_init', '_maybe_update_plugins' );
|
||||||
add_action( 'wp_update_plugins', 'wp_update_plugins' );
|
add_action( 'wp_update_plugins', 'wp_update_plugins' );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue