Ticket #13071: 13071.diff
File 13071.diff, 9.1 KB (added by , 4 years ago) |
---|
-
src/wp-admin/includes/admin-filters.php
diff --git src/wp-admin/includes/admin-filters.php src/wp-admin/includes/admin-filters.php index 141e8aa..50adb8c 100644
add_action( 'admin_notices', 'maintenance_nag', 10 ); 111 111 112 112 add_filter( 'update_footer', 'core_update_footer' ); 113 113 114 add_action( 'admin_print_footer_scripts-plugins.php', 'wp_print_update_count_for_js' ); 115 add_action( 'admin_print_footer_scripts-themes.php', 'wp_print_update_count_for_js' ); 116 add_action( 'admin_print_footer_scripts-update-core.php', 'wp_print_update_count_for_js' ); 117 114 118 // Update Core hooks. 115 119 add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); 116 120 -
src/wp-admin/includes/update.php
diff --git src/wp-admin/includes/update.php src/wp-admin/includes/update.php index 74899e3..a7573cb 100644
function wp_print_update_row_templates() { 754 754 </script> 755 755 <?php 756 756 } 757 758 function wp_print_update_count_for_js() { 759 ?> 760 <script type='text/javascript'> 761 _wpUpdatesSettings.updateCounts = <?php echo json_encode( ( wp_get_update_data() )['counts'] ); ?>; 762 wp && wp.updates && wp.updates.refreshCount(); 763 </script> 764 <?php 765 } -
src/wp-admin/js/updates.js
diff --git src/wp-admin/js/updates.js src/wp-admin/js/updates.js index 239829f..4a2e5df 100644
256 256 } 257 257 }; 258 258 259 /** 260 * Decrements the update counts throughout the various menus. 261 * 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'. 269 */ 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; 275 276 count = parseInt( count, 10 ) - 1; 277 278 if ( count < 0 || isNaN( count ) ) { 279 return; 280 } 259 wp.updates.refreshCount = function( type ) { 260 var $adminBarUpdates = $( '#wp-admin-bar-updates' ), 261 $dashboardNavMenuUpdateCount = $( 'a[href="update-core.php"] .update-plugins' ), 262 $pluginsNavMenuUpdateCount = $( 'a[href="plugins.php"] .update-plugins' ), 263 $appearanceNavMenuUpdateCount = $( 'a[href="themes.php"] .update-plugins' ), 264 itemCount; 281 265 282 266 $adminBarUpdates.find( '.ab-item' ).removeAttr( 'title' ); 283 $adminBarUpdates.find( '.ab-label' ).text( count);267 $adminBarUpdates.find( '.ab-label' ).text( settings.updateCounts.total ); 284 268 285 269 // Remove the update count from the toolbar if it's zero. 286 if ( ! count) {270 if ( 0 === settings.updateCounts.total ) { 287 271 $adminBarUpdates.find( '.ab-label' ).parents( 'li' ).remove(); 288 272 } 289 273 290 274 // Update the "Updates" menu item. 291 275 $dashboardNavMenuUpdateCount.each( function( index, element ) { 292 element.className = element.className.replace( /count-\d+/, 'count-' + count);276 element.className = element.className.replace( /count-\d+/, 'count-' + settings.updateCounts.total ); 293 277 } ); 294 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' ); 278 if ( 0 < settings.updateCounts.total ) { 279 $dashboardNavMenuUpdateCount.find( '.update-count' ).text( settings.updateCounts.total ); 280 } else { 281 $dashboardNavMenuUpdateCount.remove(); 304 282 } 305 283 306 // Decrement the counter of the other menu items. 307 if ( $itemCount ) { 308 itemCount = $itemCount.eq( 0 ).text(); 309 itemCount = parseInt( itemCount, 10 ) - 1; 284 // Update the "Plugins" menu item. 285 $pluginsNavMenuUpdateCount.each( function( index, element ) { 286 element.className = element.className.replace( /count-\d+/, 'count-' + settings.updateCounts.plugins ); 287 } ); 288 if ( 0 < settings.updateCounts.total ) { 289 $pluginsNavMenuUpdateCount.find( '.plugin-count' ).text( settings.updateCounts.plugins ); 290 } else { 291 $pluginsNavMenuUpdateCount.remove(); 310 292 } 311 293 312 if ( itemCount < 0 || isNaN( itemCount ) ) { 313 return; 294 // Update the "Appearance" menu item. 295 $appearanceNavMenuUpdateCount.each( function( index, element ) { 296 element.className = element.className.replace( /count-\d+/, 'count-' + settings.updateCounts.themes ); 297 } ); 298 if ( 0 < settings.updateCounts.total ) { 299 $appearanceNavMenuUpdateCount.find( '.theme-count' ).text( settings.updateCounts.themes ); 300 } else { 301 $appearanceNavMenuUpdateCount.remove(); 314 302 } 315 303 316 if ( itemCount > 0 ) { 317 $( '.subsubsub .upgrade .count' ).text( '(' + itemCount + ')' ); 304 // Update list table filter navigation. 305 if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { 306 itemCount = settings.updateCounts.plugins; 307 } else if ( 'themes' === pagenow || 'themes-network' === pagenow ) { 308 itemCount = settings.updateCounts.themes; 309 } 318 310 319 $itemCount.text( itemCount ); 320 $menuItem.find( '.update-plugins' ).each( function( index, element ) { 321 element.className = element.className.replace( /count-\d+/, 'count-' + itemCount ); 322 } ); 311 if ( 0 < itemCount ) { 312 $( '.subsubsub .upgrade .count' ).text( '(' + settings.updateCounts.themes + ')' ); 323 313 } else { 324 314 $( '.subsubsub .upgrade' ).remove(); 325 $menuItem.find( '.update-plugins' ).remove();326 315 } 316 } 317 318 /** 319 * Decrements the update counts throughout the various menus. 320 * 321 * This includes the toolbar, the "Updates" menu item and the menu items 322 * for plugins and themes. 323 * 324 * @since 3.9.0 325 * 326 * @param {string} type The type of item that was updated or deleted. 327 * Can be 'plugin', 'theme'. 328 */ 329 wp.updates.decrementCount = function( type ) { 330 settings.updateCounts.total = Math.max( --settings.updateCounts.total, 0 ); 331 332 if ( 'plugin' === type ) { 333 settings.updateCounts.plugins = Math.max( --settings.updateCounts.plugins, 0 ); 334 } else if ( 'theme' === type ) { 335 settings.updateCounts.themes = Math.max( --settings.updateCounts.themes, 0 ); 336 } 337 338 wp.updates.refreshCount( type ); 327 339 }; 328 340 329 341 /** -
src/wp-admin/menu.php
diff --git src/wp-admin/menu.php src/wp-admin/menu.php index 6c0b38f..2fd146b 100644
if ( ! is_multisite() ) { 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
diff --git src/wp-admin/network/menu.php src/wp-admin/network/menu.php index 8b5f002..1cb22f2 100644
$submenu['index.php'][0] = array( __( 'Home' ), 'read', 'index.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-includes/script-loader.php
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php index a778d4e..4ab4b5f 100644
function wp_default_scripts( &$scripts ) { 606 606 'ays' => __('Are you sure you want to install this plugin?') 607 607 ) ); 608 608 609 $update_data = wp_get_update_data(); 609 610 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ) ); 610 611 did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array( 611 612 'ajax_nonce' => wp_create_nonce( 'updates' ), … … function wp_default_scripts( &$scripts ) { 687 688 'pluginsFound' => __( 'Number of plugins found: %d' ), 688 689 'noPluginsFound' => __( 'No plugins found. Try a different search.' ), 689 690 ), 691 'updateCounts' => $update_data['counts'] 690 692 ) ); 691 693 692 694 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );