Ticket #17703: 17703-05.patch
File 17703-05.patch, 8.3 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/class-wp-upgrader-skins.php
diff --git src/wp-admin/includes/class-wp-upgrader-skins.php src/wp-admin/includes/class-wp-upgrader-skins.php index 71a1293..f3183c6 100644
class WP_Upgrader_Skin { 19 19 var $upgrader; 20 20 var $done_header = false; 21 21 var $result = false; 22 var $upgrade_type = false; 22 23 23 24 function __construct($args = array()) { 24 25 $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false ); … … class WP_Upgrader_Skin { 92 93 function before() {} 93 94 function after() {} 94 95 96 /** 97 * Output javascript that calls function to decrement the update counts 98 * 99 * @since 3.9.0 100 */ 101 function decrement_update_count() { 102 103 if ( ! in_array( $this->upgrade_type, array( 'plugin', 'theme' ) ) ) { 104 return; 105 } 106 107 echo '<script type="text/javascript"> 108 (function( wp ) { 109 if ( wp && wp.decrementUpdateCount ) { 110 wp.decrementUpdateCount( "' . esc_js( $this->upgrade_type ) . '" ); 111 } 112 })( window.wp ); 113 </script>'; 114 115 } 116 95 117 } 96 118 97 119 /** … … class Plugin_Upgrader_Skin extends WP_Upgrader_Skin { 105 127 var $plugin = ''; 106 128 var $plugin_active = false; 107 129 var $plugin_network_active = false; 130 var $upgrade_type = 'plugin'; 108 131 109 132 function __construct($args = array()) { 110 133 $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') ); … … class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { 252 275 wp_ob_end_flush_all(); 253 276 flush(); 254 277 } 278 279 /** 280 * Output javascript that sends message to parent window to decrement the update counts 281 * 282 * @since 3.9.0 283 */ 284 function decrement_update_count() { 285 286 if ( ! in_array( $this->upgrade_type, array( 'plugin', 'theme' ) ) ) { 287 return; 288 } 289 290 echo '<script type="text/javascript"> 291 if ( window.postMessage && JSON ) { 292 window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . esc_js( $this->upgrade_type ) . '" } ), window.location.protocol + "//" + window.location.hostname ); 293 } 294 </script>'; 295 } 255 296 } 256 297 257 298 class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin { 258 299 var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in. 300 var $upgrade_type = 'plugin'; 259 301 260 302 function __construct($args = array()) { 261 303 parent::__construct($args); … … class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin { 290 332 291 333 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin { 292 334 var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in. 335 var $upgrade_type = 'theme'; 293 336 294 337 function __construct($args = array()) { 295 338 parent::__construct($args); … … class Theme_Installer_Skin extends WP_Upgrader_Skin { 468 511 */ 469 512 class Theme_Upgrader_Skin extends WP_Upgrader_Skin { 470 513 var $theme = ''; 514 var $upgrade_type = 'theme'; 471 515 472 516 function __construct($args = array()) { 473 517 $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') ); -
src/wp-admin/includes/class-wp-upgrader.php
diff --git src/wp-admin/includes/class-wp-upgrader.php src/wp-admin/includes/class-wp-upgrader.php index 664595a..514f281 100644
class WP_Upgrader { 368 368 } else { 369 369 //Install Succeeded 370 370 $this->skin->feedback('process_success'); 371 $this->skin->decrement_update_count(); 371 372 } 372 373 373 374 $this->skin->after(); -
new file src/wp-admin/js/updates.js
diff --git src/wp-admin/js/updates.js src/wp-admin/js/updates.js new file mode 100644 index 0000000..20c5278
- + 1 window.wp = window.wp || {}; 2 3 (function( $, wp ) { 4 5 /** 6 * Decrement update counts throughout the various menus 7 * 8 * @param {string} updateType 9 */ 10 wp.decrementUpdateCount = function( upgradeType ) { 11 var count, pluginCount, $elem; 12 13 $elem = $( '#wp-admin-bar-updates .ab-label'); 14 count = $elem.text(); 15 count = parseInt( count, 10 ) - 1; 16 $elem.text( count ); 17 18 $elem = $('a[href="update-core.php"] .update-plugins'); 19 $elem.each( function( index, elem ) { 20 elem.className = elem.className.replace( /count-\d+/, 'count-' + count ); 21 } ); 22 $elem.find( '.update-count' ).text( count ); 23 24 if ( 'plugin' === upgradeType ) { 25 $elem = $( '#menu-plugins' ); 26 pluginCount = $elem.find( '.plugin-count' ).eq(0).text(); 27 pluginCount = parseInt( pluginCount, 10 ) - 1; 28 $elem.find( '.plugin-count' ).text( pluginCount ); 29 $elem.find( '.update-plugins' ).each( function( index, elem ) { 30 elem.className = elem.className.replace( /count-\d+/, 'count-' + pluginCount ); 31 } ); 32 } 33 }; 34 35 $( window ).on( 'message', function( e ) { 36 var event = e.originalEvent, 37 message, 38 loc = document.location, 39 expectedOrigin = loc.protocol + '//' + loc.hostname; 40 41 if ( event.origin !== expectedOrigin ) { 42 return; 43 } 44 45 message = $.parseJSON( event.data ); 46 47 if ( typeof message.action === 'undefined' || message.action !== 'decrementUpdateCount' ) { 48 return; 49 } 50 51 wp.decrementUpdateCount( message.upgradeType ); 52 53 } ); 54 55 })( jQuery, window.wp ); -
src/wp-admin/plugins.php
diff --git src/wp-admin/plugins.php src/wp-admin/plugins.php index 61efcf5..8b1e4a0 100644
if ( $action ) { 113 113 $title = __( 'Update Plugins' ); 114 114 $parent_file = 'plugins.php'; 115 115 116 wp_enqueue_script('updates'); 116 117 require_once(ABSPATH . 'wp-admin/admin-header.php'); 117 118 118 119 echo '<div class="wrap">'; -
src/wp-admin/update-core.php
diff --git src/wp-admin/update-core.php src/wp-admin/update-core.php index 5b84ec4..aa2d19b 100644
require_once( dirname( __FILE__ ) . '/admin.php' ); 11 11 12 12 wp_enqueue_style( 'plugin-install' ); 13 13 wp_enqueue_script( 'plugin-install' ); 14 wp_enqueue_script( 'updates' ); 14 15 add_thickbox(); 15 16 16 17 if ( is_multisite() && ! is_network_admin() ) { -
src/wp-admin/update.php
diff --git src/wp-admin/update.php src/wp-admin/update.php index e70d9c2..551da8e 100644
if ( isset($_GET['action']) ) { 37 37 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); 38 38 $nonce = 'bulk-update-plugins'; 39 39 40 wp_enqueue_script(' jquery');40 wp_enqueue_script('updates'); 41 41 iframe_header(); 42 42 43 43 $upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); … … if ( isset($_GET['action']) ) { 54 54 $title = __('Update Plugin'); 55 55 $parent_file = 'plugins.php'; 56 56 $submenu_file = 'plugins.php'; 57 58 wp_enqueue_script('updates'); 57 59 require_once(ABSPATH . 'wp-admin/admin-header.php'); 58 60 59 61 $nonce = 'upgrade-plugin_' . $plugin; … … if ( isset($_GET['action']) ) { 154 156 check_admin_referer('upgrade-theme_' . $theme); 155 157 156 158 wp_enqueue_script( 'customize-loader' ); 159 wp_enqueue_script( 'updates' ); 157 160 158 161 $title = __('Update Theme'); 159 162 $parent_file = 'themes.php'; … … if ( isset($_GET['action']) ) { 185 188 $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes)); 186 189 $nonce = 'bulk-update-themes'; 187 190 188 wp_enqueue_script(' jquery');191 wp_enqueue_script('updates'); 189 192 iframe_header(); 190 193 191 194 $upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); -
src/wp-includes/admin-bar.php
diff --git src/wp-includes/admin-bar.php src/wp-includes/admin-bar.php index 67e6a1a..3f68673 100644
function wp_admin_bar_updates_menu( $wp_admin_bar ) { 693 693 $wp_admin_bar->add_menu( array( 694 694 'id' => 'updates', 695 695 'title' => $title, 696 'href' => network_admin_url( 'update-core.php' ), 697 'meta' => array( 698 'title' => $update_data['title'], 699 ), 696 'href' => network_admin_url( 'update-core.php' ) 700 697 ) ); 701 698 } 702 699 -
src/wp-includes/script-loader.php
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php index 6414760..649f95b 100644
function wp_default_scripts( &$scripts ) { 477 477 'ays' => __('Are you sure you want to install this plugin?') 478 478 ) ); 479 479 480 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery' ) ); 481 480 482 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); 481 483 482 484 $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 );