Ticket #33030: 33030-updates.diff
File 33030-updates.diff, 9.9 KB (added by , 6 years ago) |
---|
-
src/js/_enqueues/wp/updates.js
279 279 $appearanceNavMenuUpdateCount = $( 'a[href="themes.php"] .update-plugins' ), 280 280 itemCount; 281 281 282 $adminBarUpdates.find( '.ab-item' ). removeAttr( 'title');282 $adminBarUpdates.find( '.ab-item' ).attr( 'title', settings.totals.title ); 283 283 $adminBarUpdates.find( '.ab-label' ).text( settings.totals.counts.total ); 284 $adminBarUpdates.find( '.updates-total-text' ).text( settings.totals.title ); 284 285 285 286 // Remove the update count from the toolbar if it's zero. 286 287 if ( 0 === settings.totals.counts.total ) { … … 293 294 } ); 294 295 if ( settings.totals.counts.total > 0 ) { 295 296 $dashboardNavMenuUpdateCount.find( '.update-count' ).text( settings.totals.counts.total ); 297 $dashboardNavMenuUpdateCount.find( '.updates-total-text' ).text( settings.totals.title ); 296 298 } else { 297 299 $dashboardNavMenuUpdateCount.remove(); 298 300 } … … 303 305 } ); 304 306 if ( settings.totals.counts.total > 0 ) { 305 307 $pluginsNavMenuUpdateCount.find( '.plugin-count' ).text( settings.totals.counts.plugins ); 308 $pluginsNavMenuUpdateCount.find( '.updates-plugins-text' ).text( settings.totals.titles.plugins ); 306 309 } else { 307 310 $pluginsNavMenuUpdateCount.remove(); 308 311 } … … 340 343 * 341 344 * @since 3.9.0 342 345 * 343 * @param {string} type The type of item that was updated or deleted. 344 * Can be 'plugin', 'theme'. 346 * @param {string} type The type of item that was updated or deleted. 347 * Can be 'plugin', 'theme'. 348 * @param {object} updateData The available updates counts and UI strings. 345 349 */ 346 wp.updates.decrementCount = function( type ) {350 wp.updates.decrementCount = function( type, updateData ) { 347 351 settings.totals.counts.total = Math.max( --settings.totals.counts.total, 0 ); 352 settings.totals.title = updateData.title; 348 353 349 354 if ( 'plugin' === type ) { 350 355 settings.totals.counts.plugins = Math.max( --settings.totals.counts.plugins, 0 ); 356 settings.totals.titles.plugins = updateData.titles.plugins; 351 357 } else if ( 'theme' === type ) { 352 358 settings.totals.counts.themes = Math.max( --settings.totals.counts.themes, 0 ); 353 359 } 354 360 355 wp.updates.refreshCount( type);361 wp.updates.refreshCount(); 356 362 }; 357 363 358 364 /** … … 442 448 443 449 wp.a11y.speak( wp.updates.l10n.updatedMsg, 'polite' ); 444 450 445 wp.updates.decrementCount( 'plugin' );451 wp.updates.decrementCount( 'plugin', response.updateData ); 446 452 447 453 $document.trigger( 'wp-plugin-update-success', response ); 448 454 }; … … 802 808 // Remove plugin from update count. 803 809 if ( -1 !== _.indexOf( plugins.upgrade, response.plugin ) ) { 804 810 plugins.upgrade = _.without( plugins.upgrade, response.plugin ); 805 wp.updates.decrementCount( 'plugin' );811 wp.updates.decrementCount( 'plugin', response.updateData ); 806 812 } 807 813 808 814 // Remove from views. … … 1015 1021 wp.updates.addAdminNotice( _.extend( { selector: $notice }, updatedMessage ) ); 1016 1022 wp.a11y.speak( wp.updates.l10n.updatedMsg, 'polite' ); 1017 1023 1018 wp.updates.decrementCount( 'theme' );1024 wp.updates.decrementCount( 'theme', response.updateData ); 1019 1025 1020 1026 $document.trigger( 'wp-theme-update-success', response ); 1021 1027 … … 1292 1298 // Remove theme from update count. 1293 1299 if ( $themeRow.hasClass( 'update' ) ) { 1294 1300 totals.upgrade--; 1295 wp.updates.decrementCount( 'theme' );1301 wp.updates.decrementCount( 'theme', response.updateData ); 1296 1302 } 1297 1303 1298 1304 // Remove from views. … … 2436 2442 2437 2443 // Called from `wp-admin/includes/class-wp-upgrader-skins.php`. 2438 2444 case 'decrementUpdateCount': 2439 /** @property {string} message.upgradeType */ 2440 wp.updates.decrementCount( message.upgradeType ); 2445 wp.updates.decrementCount( message.upgradeType, message.upgradeData ); 2441 2446 break; 2442 2447 2443 2448 case 'install-plugin': -
src/wp-admin/includes/ajax-actions.php
3921 3921 $status['newVersion'] = $theme->get( 'Version' ); 3922 3922 } 3923 3923 3924 // Add available updates counts and UI strings to the response. 3925 $update_data = wp_get_update_data(); 3926 $status['updateData'] = $update_data; 3927 3924 3928 wp_send_json_success( $status ); 3925 3929 } elseif ( false === $result ) { 3926 3930 global $wp_filesystem; … … 4010 4014 wp_send_json_error( $status ); 4011 4015 } 4012 4016 4017 // Add available updates counts and UI strings to the response. 4018 $update_data = wp_get_update_data(); 4019 $status['updateData'] = $update_data; 4020 4013 4021 wp_send_json_success( $status ); 4014 4022 } 4015 4023 … … 4209 4217 /* translators: %s: Plugin version */ 4210 4218 $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); 4211 4219 } 4220 4221 // Add available updates counts and UI strings to the response. 4222 $update_data = wp_get_update_data(); 4223 $status['updateData'] = $update_data; 4224 4212 4225 wp_send_json_success( $status ); 4213 4226 } elseif ( false === $result ) { 4214 4227 global $wp_filesystem; … … 4301 4314 wp_send_json_error( $status ); 4302 4315 } 4303 4316 4317 // Add available updates counts and UI strings to the response. 4318 $update_data = wp_get_update_data(); 4319 $status['updateData'] = $update_data; 4320 4304 4321 wp_send_json_success( $status ); 4305 4322 } 4306 4323 -
src/wp-admin/includes/class-wp-upgrader-skin.php
182 182 return; 183 183 } 184 184 185 // At this point, the strings generated by `wp_get_update_data()` are 186 // incorrect until all updates have finished - the data is cached, 187 // and isn't regenerated until the end of the update process. 188 // See https://core.trac.wordpress.org/ticket/29022#comment:7 189 $update_data = wp_json_encode( wp_get_update_data() ); 190 185 191 if ( defined( 'IFRAME_REQUEST' ) ) { 186 192 echo '<script type="text/javascript"> 187 193 if ( window.postMessage && JSON ) { 188 window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );194 window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '", upgradeData: ' . $update_data . ' } ), window.location.protocol + "//" + window.location.hostname ); 189 195 } 190 196 </script>'; 191 197 } else { 192 198 echo '<script type="text/javascript"> 193 199 (function( wp ) { 194 if ( wp && wp.updates && wp.updates.decrementCount ) 195 wp.updates.decrementCount( "' . $type . '" );200 if ( wp && wp.updates && wp.updates.decrementCount ) { 201 wp.updates.decrementCount( "' . $type . '", ' . $update_data . ' ); 196 202 } 197 203 })( window.wp ); 198 204 </script>'; -
src/wp-admin/menu.php
42 42 } else { 43 43 $cap = 'update_languages'; 44 44 } 45 $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' ); 45 46 $updates_text = ''; 47 if ( isset( $update_data['title'] ) ) { 48 $updates_text = '<span class="updates-total-text screen-reader-text">' . $update_data['title'] . '</span>'; 49 } 50 51 $submenu['index.php'][10] = array( sprintf( __( 'Updates %s' ), "<span class='update-plugins count-{$update_data['counts']['total']}'><span class='update-count' aria-hidden='true'>" . number_format_i18n( $update_data['counts']['total'] ) . '</span>' . $updates_text . '</span>' ), $cap, 'update-core.php' ); 46 52 unset( $cap ); 47 53 } 48 54 … … 211 217 if ( ! isset( $update_data ) ) { 212 218 $update_data = wp_get_update_data(); 213 219 } 214 $count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n( $update_data['counts']['plugins'] ) . '</span></span>'; 220 221 $updates_plugin_text = ''; 222 if ( isset( $update_data['titles']['plugins'] ) ) { 223 $updates_plugin_text = '<span class="updates-plugins-text screen-reader-text">' . $update_data['titles']['plugins'] . '</span>'; 224 } 225 226 $count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count' aria-hidden='true'>" . number_format_i18n( $update_data['counts']['plugins'] ) . '</span>' . $updates_plugin_text . '</span>'; 215 227 } 216 228 217 229 $menu[65] = array( sprintf( __( 'Plugins %s' ), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'dashicons-admin-plugins' ); -
src/wp-includes/admin-bar.php
997 997 return; 998 998 } 999 999 1000 $title = '<span class="ab-icon"></span><span class="ab-label" >' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';1001 $title .= '<span class=" screen-reader-text">' . $update_data['title'] . '</span>';1000 $title = '<span class="ab-icon"></span><span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; 1001 $title .= '<span class="updates-total-text screen-reader-text">' . $update_data['title'] . '</span>'; 1002 1002 1003 1003 $wp_admin_bar->add_menu( 1004 1004 array( -
src/wp-includes/update.php
692 692 $update_data = array( 693 693 'counts' => $counts, 694 694 'title' => $update_title, 695 'titles' => $titles, 695 696 ); 696 697 /** 697 698 * Filters the returned array of update data for plugins, themes, and WordPress core.