Changeset 38827
- Timestamp:
- 10/19/2016 10:26:31 AM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php
r38307 r38827 151 151 152 152 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 153 'totals' => $totals, 153 'themes' => $totals, 154 'totals' => wp_get_update_data(), 154 155 ) ); 155 156 -
trunk/src/wp-admin/includes/class-wp-plugins-list-table.php
r38672 r38827 254 254 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 255 255 'plugins' => $js_plugins, 256 'totals' => wp_get_update_data(), 256 257 ) ); 257 258 -
trunk/src/wp-admin/js/updates.js
r38813 r38827 22 22 * @param {Array} settings.plugins.upgrade Base names of plugins with updates available. 23 23 * @param {Array} settings.plugins.recently_activated Base names of recently activated plugins. 24 * @param {object=} settings.totals Plugin/theme status information or null. 25 * @param {number} settings.totals.all Amount of all plugins or themes. 26 * @param {number} settings.totals.upgrade Amount of plugins or themes with updates available. 27 * @param {number} settings.totals.disabled Amount of disabled themes. 24 * @param {object=} settings.themes Plugin/theme status information or null. 25 * @param {number} settings.themes.all Amount of all themes. 26 * @param {number} settings.themes.upgrade Amount of themes with updates available. 27 * @param {number} settings.themes.disabled Amount of disabled themes. 28 * @param {object=} settings.totals Combined information for available update counts. 29 * @param {number} settings.totals.count Holds the amount of available updates. 28 30 */ 29 31 (function( $, wp, settings ) { … … 262 264 263 265 /** 266 * Refreshes update counts everywhere on the screen. 267 * 268 * @since 4.7.0 269 */ 270 wp.updates.refreshCount = function() { 271 var $adminBarUpdates = $( '#wp-admin-bar-updates' ), 272 $dashboardNavMenuUpdateCount = $( 'a[href="update-core.php"] .update-plugins' ), 273 $pluginsNavMenuUpdateCount = $( 'a[href="plugins.php"] .update-plugins' ), 274 $appearanceNavMenuUpdateCount = $( 'a[href="themes.php"] .update-plugins' ), 275 itemCount; 276 277 $adminBarUpdates.find( '.ab-item' ).removeAttr( 'title' ); 278 $adminBarUpdates.find( '.ab-label' ).text( settings.totals.counts.total ); 279 280 // Remove the update count from the toolbar if it's zero. 281 if ( 0 === settings.totals.counts.total ) { 282 $adminBarUpdates.find( '.ab-label' ).parents( 'li' ).remove(); 283 } 284 285 // Update the "Updates" menu item. 286 $dashboardNavMenuUpdateCount.each( function( index, element ) { 287 element.className = element.className.replace( /count-\d+/, 'count-' + settings.totals.counts.total ); 288 } ); 289 if ( settings.totals.counts.total > 0 ) { 290 $dashboardNavMenuUpdateCount.find( '.update-count' ).text( settings.totals.counts.total ); 291 } else { 292 $dashboardNavMenuUpdateCount.remove(); 293 } 294 295 // Update the "Plugins" menu item. 296 $pluginsNavMenuUpdateCount.each( function( index, element ) { 297 element.className = element.className.replace( /count-\d+/, 'count-' + settings.totals.counts.plugins ); 298 } ); 299 if ( settings.totals.counts.total > 0 ) { 300 $pluginsNavMenuUpdateCount.find( '.plugin-count' ).text( settings.totals.counts.plugins ); 301 } else { 302 $pluginsNavMenuUpdateCount.remove(); 303 } 304 305 // Update the "Appearance" menu item. 306 $appearanceNavMenuUpdateCount.each( function( index, element ) { 307 element.className = element.className.replace( /count-\d+/, 'count-' + settings.totals.counts.themes ); 308 } ); 309 if ( settings.totals.counts.total > 0 ) { 310 $appearanceNavMenuUpdateCount.find( '.theme-count' ).text( settings.totals.counts.themes ); 311 } else { 312 $appearanceNavMenuUpdateCount.remove(); 313 } 314 315 // Update list table filter navigation. 316 if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { 317 itemCount = settings.totals.counts.plugins; 318 } else if ( 'themes' === pagenow || 'themes-network' === pagenow ) { 319 itemCount = settings.totals.counts.themes; 320 } 321 322 if ( itemCount > 0 ) { 323 $( '.subsubsub .upgrade .count' ).text( '(' + itemCount + ')' ); 324 } else { 325 $( '.subsubsub .upgrade' ).remove(); 326 } 327 }; 328 329 /** 264 330 * Decrements the update counts throughout the various menus. 265 331 * … … 273 339 */ 274 340 wp.updates.decrementCount = function( type ) { 275 var $adminBarUpdates = $( '#wp-admin-bar-updates' ), 276 $dashboardNavMenuUpdateCount = $( 'a[href="update-core.php"] .update-plugins' ), 277 count = $adminBarUpdates.find( '.ab-label' ).text(), 278 $menuItem, $itemCount, itemCount; 279 280 count = parseInt( count, 10 ) - 1; 281 282 if ( count < 0 || isNaN( count ) ) { 283 return; 284 } 285 286 $adminBarUpdates.find( '.ab-item' ).removeAttr( 'title' ); 287 $adminBarUpdates.find( '.ab-label' ).text( count ); 288 289 // Remove the update count from the toolbar if it's zero. 290 if ( ! count ) { 291 $adminBarUpdates.find( '.ab-label' ).parents( 'li' ).remove(); 292 } 293 294 // Update the "Updates" menu item. 295 $dashboardNavMenuUpdateCount.each( function( index, element ) { 296 element.className = element.className.replace( /count-\d+/, 'count-' + count ); 297 } ); 298 299 $dashboardNavMenuUpdateCount.removeAttr( 'title' ); 300 $dashboardNavMenuUpdateCount.find( '.update-count' ).text( count ); 341 settings.totals.counts.total = Math.max( --settings.totals.counts.total, 0 ); 301 342 302 343 if ( 'plugin' === type ) { 303 $menuItem = $( '#menu-plugins' ); 304 $itemCount = $menuItem.find( '.plugin-count' ); 344 settings.totals.counts.plugins = Math.max( --settings.totals.counts.plugins, 0 ); 305 345 } else if ( 'theme' === type ) { 306 $menuItem = $( '#menu-appearance' ); 307 $itemCount = $menuItem.find( '.theme-count' ); 308 } 309 310 // Decrement the counter of the other menu items. 311 if ( $itemCount ) { 312 itemCount = $itemCount.eq( 0 ).text(); 313 itemCount = parseInt( itemCount, 10 ) - 1; 314 } 315 316 if ( itemCount < 0 || isNaN( itemCount ) ) { 317 return; 318 } 319 320 if ( itemCount > 0 ) { 321 $( '.subsubsub .upgrade .count' ).text( '(' + itemCount + ')' ); 322 323 $itemCount.text( itemCount ); 324 $menuItem.find( '.update-plugins' ).each( function( index, element ) { 325 element.className = element.className.replace( /count-\d+/, 'count-' + itemCount ); 326 } ); 327 } else { 328 $( '.subsubsub .upgrade' ).remove(); 329 $menuItem.find( '.update-plugins' ).remove(); 330 } 346 settings.totals.counts.themes = Math.max( --settings.totals.counts.themes, 0 ); 347 } 348 349 wp.updates.refreshCount( type ); 331 350 }; 332 351 … … 1252 1271 var $views = $( '.subsubsub' ), 1253 1272 $themeRow = $( this ), 1254 totals = settings.t otals,1273 totals = settings.themes, 1255 1274 deletedRow = wp.template( 'item-deleted-row' ); 1256 1275 … … 1689 1708 $pluginSearch = $( '.plugins-php .wp-filter-search' ), 1690 1709 $pluginInstallSearch = $( '.plugin-install-php .wp-filter-search' ); 1710 1711 settings = _.extend( settings, window._wpUpdatesItemCounts || {} ); 1712 1713 if ( settings.totals ) { 1714 wp.updates.refreshCount(); 1715 } 1691 1716 1692 1717 /* … … 2413 2438 $( window ).on( 'beforeunload', wp.updates.beforeunload ); 2414 2439 } ); 2415 })( jQuery, window.wp, _.extend( window._wpUpdatesSettings, window._wpUpdatesItemCounts || {} ));2440 })( jQuery, window.wp, window._wpUpdatesSettings ); -
trunk/src/wp-admin/menu.php
r37431 r38827 39 39 else 40 40 $cap = 'update_themes'; 41 $submenu[ 'index.php' ][10] = array( sprintf( __('Updates %s'), "<span class='update-plugins count-{$update_data['counts']['total']}' title='{$update_data['title']}'><span class='update-count'>" . number_format_i18n($update_data['counts']['total']) . "</span></span>" ), $cap, 'update-core.php');41 $submenu[ 'index.php' ][10] = array( sprintf( __('Updates %s'), "<span class='update-plugins count-{$update_data['counts']['total']}'><span class='update-count'>" . number_format_i18n($update_data['counts']['total']) . "</span></span>" ), $cap, 'update-core.php'); 42 42 unset( $cap ); 43 43 } -
trunk/src/wp-admin/network/menu.php
r37365 r38827 15 15 $update_data = wp_get_update_data(); 16 16 if ( $update_data['counts']['total'] ) { 17 $submenu['index.php'][10] = array( sprintf( __( 'Updates %s' ), "<span class='update-plugins count-{$update_data['counts']['total']}' title='{$update_data['title']}'><span class='update-count'>" . number_format_i18n( $update_data['counts']['total'] ) . "</span></span>" ), 'update_core', 'update-core.php' );17 $submenu['index.php'][10] = array( sprintf( __( 'Updates %s' ), "<span class='update-plugins count-{$update_data['counts']['total']}'><span class='update-count'>" . number_format_i18n( $update_data['counts']['total'] ) . "</span></span>" ), 'update_core', 'update-core.php' ); 18 18 } else { 19 19 $submenu['index.php'][10] = array( __( 'Updates' ), 'update_core', 'update-core.php' ); -
trunk/src/wp-admin/themes.php
r38788 r38827 491 491 wp_print_update_row_templates(); 492 492 493 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 494 'totals' => wp_get_update_data(), 495 ) ); 496 493 497 require( ABSPATH . 'wp-admin/admin-footer.php' ); -
trunk/src/wp-admin/update-core.php
r38743 r38827 619 619 do_action( 'core_upgrade_preamble' ); 620 620 echo '</div>'; 621 622 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 623 'totals' => wp_get_update_data(), 624 ) ); 625 621 626 include(ABSPATH . 'wp-admin/admin-footer.php'); 622 627 … … 642 647 if ( isset( $_POST['upgrade'] ) ) 643 648 do_core_upgrade($reinstall); 649 650 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 651 'totals' => wp_get_update_data(), 652 ) ); 644 653 645 654 include(ABSPATH . 'wp-admin/admin-footer.php'); … … 671 680 echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="' . esc_attr__( 'Update progress' ) . '"></iframe>'; 672 681 echo '</div>'; 682 683 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 684 'totals' => wp_get_update_data(), 685 ) ); 686 673 687 include(ABSPATH . 'wp-admin/admin-footer.php'); 674 688 … … 701 715 </div> 702 716 <?php 717 718 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 719 'totals' => wp_get_update_data(), 720 ) ); 721 703 722 include(ABSPATH . 'wp-admin/admin-footer.php'); 704 723 … … 720 739 $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) ); 721 740 $result = $upgrader->bulk_upgrade(); 741 742 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 743 'totals' => wp_get_update_data(), 744 ) ); 722 745 723 746 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); -
trunk/src/wp-includes/script-loader.php
r38810 r38827 612 612 ) ); 613 613 614 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ) );614 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 ); 615 615 did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array( 616 616 'ajax_nonce' => wp_create_nonce( 'updates' ),
Note: See TracChangeset
for help on using the changeset viewer.