Ticket #29022: 29022.8.diff
File 29022.8.diff, 8.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
3929 3929 $status['newVersion'] = $theme->get( 'Version' ); 3930 3930 } 3931 3931 3932 // Add available updates counts and UI strings to the response. 3933 $update_data = wp_get_update_data(); 3934 $status['updateData'] = $update_data; 3935 3932 3936 wp_send_json_success( $status ); 3933 3937 } elseif ( false === $result ) { 3934 3938 global $wp_filesystem; … … 4018 4022 wp_send_json_error( $status ); 4019 4023 } 4020 4024 4025 // Add available updates counts and UI strings to the response. 4026 $update_data = wp_get_update_data(); 4027 $status['updateData'] = $update_data; 4028 4021 4029 wp_send_json_success( $status ); 4022 4030 } 4023 4031 … … 4217 4225 /* translators: %s: Plugin version */ 4218 4226 $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); 4219 4227 } 4228 4229 // Add available updates counts and UI strings to the response. 4230 $update_data = wp_get_update_data(); 4231 $status['updateData'] = $update_data; 4232 4220 4233 wp_send_json_success( $status ); 4221 4234 } elseif ( false === $result ) { 4222 4235 global $wp_filesystem; … … 4309 4322 wp_send_json_error( $status ); 4310 4323 } 4311 4324 4325 // Add available updates counts and UI strings to the response. 4326 $update_data = wp_get_update_data(); 4327 $status['updateData'] = $update_data; 4328 4312 4329 wp_send_json_success( $status ); 4313 4330 } 4314 4331 -
src/wp-admin/menu.php
43 43 $cap = 'update_languages'; 44 44 } 45 45 /* translators: %s: number of pending updates */ 46 $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' ); 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' ); 47 52 unset( $cap ); 48 53 } 49 54 … … 217 222 if ( ! isset( $update_data ) ) { 218 223 $update_data = wp_get_update_data(); 219 224 } 220 $count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n( $update_data['counts']['plugins'] ) . '</span></span>'; 225 226 $updates_plugin_text = ''; 227 if ( isset( $update_data['titles']['plugins'] ) ) { 228 $updates_plugin_text = '<span class="updates-plugins-text screen-reader-text">' . $update_data['titles']['plugins'] . '</span>'; 229 } 230 231 $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>'; 221 232 } 222 233 223 234 /* translators: %s: number of pending plugin updates */ -
src/wp-includes/admin-bar.php
1001 1001 return; 1002 1002 } 1003 1003 1004 $title = '<span class="ab-icon"></span><span class="ab-label" >' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';1005 $title .= '<span class=" screen-reader-text">' . $update_data['title'] . '</span>';1004 $title = '<span class="ab-icon"></span><span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; 1005 $title .= '<span class="updates-total-text screen-reader-text">' . $update_data['title'] . '</span>'; 1006 1006 1007 1007 $wp_admin_bar->add_menu( 1008 1008 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. -
tests/phpunit/tests/ajax/DeletePlugin.php
143 143 // Get the response. 144 144 $response = json_decode( $this->_last_response, true ); 145 145 146 $update_data = wp_get_update_data(); 147 146 148 $expected = array( 147 149 'success' => true, 148 150 'data' => array( … … 150 152 'slug' => 'foo', 151 153 'plugin' => 'foo.php', 152 154 'pluginName' => '', 155 'updateData' => $update_data, 153 156 ), 154 157 ); 155 158