Ticket #13071: 13071.3.diff
File 13071.3.diff, 13.4 KB (added by , 4 years ago) |
---|
-
src/wp-admin/includes/class-wp-ms-themes-list-table.php
150 150 $total_this_page = $totals[ $status ]; 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 156 157 if ( $orderby ) { -
src/wp-admin/includes/class-wp-plugins-list-table.php
253 253 254 254 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 255 255 'plugins' => $js_plugins, 256 'totals' => wp_get_update_data(), 256 257 ) ); 257 258 258 259 if ( ! $orderby ) { -
src/wp-admin/js/updates.js
21 21 * @param {Array} settings.plugins.inactive Base names of inactive plugins. 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 ) { 30 32 var $document = $( document ); … … 257 259 }; 258 260 259 261 /** 260 * Decrements the update counts throughout the various menus.262 * Refreshes update counts everywhere on the screen. 261 263 * 262 * This includes the toolbar, the "Updates" menu item and the menu items 263 * for plugins and themes. 264 * 265 * @since 3.9.0 266 * 267 * @param {string} type The type of item that was updated or deleted. 268 * Can be 'plugin', 'theme'. 264 * @since 4.7.0 269 265 */ 270 wp.updates.decrementCount = function( type ) { 271 var $adminBarUpdates = $( '#wp-admin-bar-updates' ), 272 $dashboardNavMenuUpdateCount = $( 'a[href="update-core.php"] .update-plugins' ), 273 count = $adminBarUpdates.find( '.ab-label' ).text(), 274 $menuItem, $itemCount, itemCount; 266 wp.updates.refreshCount = function() { 267 var $adminBarUpdates = $( '#wp-admin-bar-updates' ), 268 $dashboardNavMenuUpdateCount = $( 'a[href="update-core.php"] .update-plugins' ), 269 $pluginsNavMenuUpdateCount = $( 'a[href="plugins.php"] .update-plugins' ), 270 $appearanceNavMenuUpdateCount = $( 'a[href="themes.php"] .update-plugins' ), 271 itemCount; 275 272 276 count = parseInt( count, 10 ) - 1;277 278 if ( count < 0 || isNaN( count ) ) {279 return;280 }281 282 273 $adminBarUpdates.find( '.ab-item' ).removeAttr( 'title' ); 283 $adminBarUpdates.find( '.ab-label' ).text( count);274 $adminBarUpdates.find( '.ab-label' ).text( settings.totals.counts.total ); 284 275 285 276 // Remove the update count from the toolbar if it's zero. 286 if ( ! count) {277 if ( 0 === settings.totals.counts.total ) { 287 278 $adminBarUpdates.find( '.ab-label' ).parents( 'li' ).remove(); 288 279 } 289 280 290 281 // Update the "Updates" menu item. 291 282 $dashboardNavMenuUpdateCount.each( function( index, element ) { 292 element.className = element.className.replace( /count-\d+/, 'count-' + count);283 element.className = element.className.replace( /count-\d+/, 'count-' + settings.totals.counts.total ); 293 284 } ); 285 if ( settings.totals.counts.total > 0 ) { 286 $dashboardNavMenuUpdateCount.find( '.update-count' ).text( settings.totals.counts.total ); 287 } else { 288 $dashboardNavMenuUpdateCount.remove(); 289 } 294 290 295 $dashboardNavMenuUpdateCount.removeAttr( 'title' ); 296 $dashboardNavMenuUpdateCount.find( '.update-count' ).text( count ); 297 298 if ( 'plugin' === type ) { 299 $menuItem = $( '#menu-plugins' ); 300 $itemCount = $menuItem.find( '.plugin-count' ); 301 } else if ( 'theme' === type ) { 302 $menuItem = $( '#menu-appearance' ); 303 $itemCount = $menuItem.find( '.theme-count' ); 291 // Update the "Plugins" menu item. 292 $pluginsNavMenuUpdateCount.each( function( index, element ) { 293 element.className = element.className.replace( /count-\d+/, 'count-' + settings.totals.counts.plugins ); 294 } ); 295 if ( settings.totals.counts.total > 0 ) { 296 $pluginsNavMenuUpdateCount.find( '.plugin-count' ).text( settings.totals.counts.plugins ); 297 } else { 298 $pluginsNavMenuUpdateCount.remove(); 304 299 } 305 300 306 // Decrement the counter of the other menu items. 307 if ( $itemCount ) { 308 itemCount = $itemCount.eq( 0 ).text(); 309 itemCount = parseInt( itemCount, 10 ) - 1; 301 // Update the "Appearance" menu item. 302 $appearanceNavMenuUpdateCount.each( function( index, element ) { 303 element.className = element.className.replace( /count-\d+/, 'count-' + settings.totals.counts.themes ); 304 } ); 305 if ( settings.totals.counts.total > 0 ) { 306 $appearanceNavMenuUpdateCount.find( '.theme-count' ).text( settings.totals.counts.themes ); 307 } else { 308 $appearanceNavMenuUpdateCount.remove(); 310 309 } 311 310 312 if ( itemCount < 0 || isNaN( itemCount ) ) { 313 return; 311 // Update list table filter navigation. 312 if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { 313 itemCount = settings.totals.counts.plugins; 314 } else if ( 'themes' === pagenow || 'themes-network' === pagenow ) { 315 itemCount = settings.totals.counts.themes; 314 316 } 315 317 316 318 if ( itemCount > 0 ) { 317 319 $( '.subsubsub .upgrade .count' ).text( '(' + itemCount + ')' ); 318 319 $itemCount.text( itemCount );320 $menuItem.find( '.update-plugins' ).each( function( index, element ) {321 element.className = element.className.replace( /count-\d+/, 'count-' + itemCount );322 } );323 320 } else { 324 321 $( '.subsubsub .upgrade' ).remove(); 325 $menuItem.find( '.update-plugins' ).remove();326 322 } 327 323 }; 328 324 329 325 /** 326 * Decrements the update counts throughout the various menus. 327 * 328 * This includes the toolbar, the "Updates" menu item and the menu items 329 * for plugins and themes. 330 * 331 * @since 3.9.0 332 * 333 * @param {string} type The type of item that was updated or deleted. 334 * Can be 'plugin', 'theme'. 335 */ 336 wp.updates.decrementCount = function( type ) { 337 settings.totals.counts.total = Math.max( --settings.totals.counts.total, 0 ); 338 339 if ( 'plugin' === type ) { 340 settings.totals.counts.plugins = Math.max( --settings.totals.counts.plugins, 0 ); 341 } else if ( 'theme' === type ) { 342 settings.totals.counts.themes = Math.max( --settings.totals.counts.themes, 0 ); 343 } 344 345 wp.updates.refreshCount( type ); 346 }; 347 348 /** 330 349 * Sends an Ajax request to the server to update a plugin. 331 350 * 332 351 * @since 4.2.0 … … 1217 1236 $themeRows.css( { backgroundColor: '#faafaa' } ).fadeOut( 350, function() { 1218 1237 var $views = $( '.subsubsub' ), 1219 1238 $themeRow = $( this ), 1220 totals = settings.t otals,1239 totals = settings.themes, 1221 1240 deletedRow = wp.template( 'item-deleted-row' ); 1222 1241 1223 1242 if ( ! $themeRow.hasClass( 'plugin-update-tr' ) ) { … … 1655 1674 $pluginSearch = $( '.plugins-php .wp-filter-search' ), 1656 1675 $pluginInstallSearch = $( '.plugin-install-php .wp-filter-search' ); 1657 1676 1677 settings = _.extend( settings, window._wpUpdatesItemCounts || {} ); 1678 1679 if ( settings.totals ) { 1680 wp.updates.refreshCount(); 1681 } 1682 1658 1683 /* 1659 1684 * Whether a user needs to submit filesystem credentials. 1660 1685 * … … 2378 2403 */ 2379 2404 $( window ).on( 'beforeunload', wp.updates.beforeunload ); 2380 2405 } ); 2381 })( jQuery, window.wp, _.extend( window._wpUpdatesSettings, window._wpUpdatesItemCounts || {} ));2406 })( jQuery, window.wp, window._wpUpdatesSettings ); -
src/wp-admin/menu.php
38 38 $cap = 'update_plugins'; 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 } 44 44 -
src/wp-admin/network/menu.php
14 14 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' ); 20 20 } -
src/wp-admin/themes.php
486 486 wp_print_admin_notice_templates(); 487 487 wp_print_update_row_templates(); 488 488 489 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 490 'totals' => wp_get_update_data(), 491 ) ); 492 489 493 require( ABSPATH . 'wp-admin/admin-footer.php' ); -
src/wp-admin/update-core.php
618 618 */ 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 623 628 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) { … … 642 647 if ( isset( $_POST['upgrade'] ) ) 643 648 do_core_upgrade($reinstall); 644 649 650 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 651 'totals' => wp_get_update_data(), 652 ) ); 653 645 654 include(ABSPATH . 'wp-admin/admin-footer.php'); 646 655 647 656 } elseif ( 'do-plugin-upgrade' == $action ) { … … 670 679 echo '<h1>' . __( 'Update Plugins' ) . '</h1>'; 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 675 689 } elseif ( 'do-theme-upgrade' == $action ) { … … 700 714 <iframe src="<?php echo $url ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe> 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 705 724 } elseif ( 'do-translation-upgrade' == $action ) { … … 720 739 $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) ); 721 740 $result = $upgrader->bulk_upgrade(); 722 741 742 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 743 'totals' => wp_get_update_data(), 744 ) ); 745 723 746 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); 724 747 725 748 } else { -
src/wp-includes/script-loader.php
606 606 'ays' => __('Are you sure you want to install this plugin?') 607 607 ) ); 608 608 609 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ) );609 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 ); 610 610 did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array( 611 611 'ajax_nonce' => wp_create_nonce( 'updates' ), 612 612 'l10n' => array(