Shiny Updates: Handle the case where the plugin is installed into a different directory than it previously existed in.

A good example of this is when the plugin being updated is currently installed as 'Plugin-Name' but the canonical directory is 'plugin-name', but it can also occur when the plugin is installed in 'super-cool-plugin' and it's canonical name is 'average-plugin'.

Merges [32570] to the 4.2 branch.
Fixes #32465

Built from https://develop.svn.wordpress.org/branches/4.2@33301


git-svn-id: http://core.svn.wordpress.org/branches/4.2@33273 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2015-07-17 03:55:28 +00:00
parent 19aa985476
commit 8e96288144

View File

@ -2892,6 +2892,7 @@ function wp_ajax_update_plugin() {
'oldVersion' => '', 'oldVersion' => '',
'newVersion' => '', 'newVersion' => '',
); );
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
if ( $plugin_data['Version'] ) { if ( $plugin_data['Version'] ) {
$status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); $status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
@ -2926,7 +2927,8 @@ function wp_ajax_update_plugin() {
wp_send_json_error( $status ); wp_send_json_error( $status );
} }
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); $plugin_data = get_plugins( '/' . $result[ $plugin ]['destination_name'] );
$plugin_data = reset( $plugin_data );
if ( $plugin_data['Version'] ) { if ( $plugin_data['Version'] ) {
$status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );