Ticket #29022: 29022.5.diff
File 29022.5.diff, 6.4 KB (added by , 10 years ago) |
---|
-
src/wp-admin/js/updates.js
1 /* global updatesL10n */ 1 2 window.wp = window.wp || {}; 2 3 3 4 (function( $, wp ) { … … 10 11 * @param {string} updateType 11 12 */ 12 13 wp.updates.decrementCount = function( upgradeType ) { 13 var count, pluginCount, $elem; 14 var pluginCount, $elem, screenReaderText = '', 15 updateTypes = { 16 plugins: { 17 type: 'plugin', 18 count: 'pluginCount', 19 singular: updatesL10n.plugin, 20 plural: updatesL10n.plugins 21 }, 22 themes: { 23 type: 'theme', 24 count: 'themeCount', 25 singular: updatesL10n.theme, 26 plural: updatesL10n.themes 27 }, 28 wordpress: { 29 type: 'wordpress', 30 count: 'wordpressCount', 31 singular: updatesL10n.wordpress, 32 plural: updatesL10n.wordpress 33 }, 34 translations: { 35 type: 'translation', 36 count: 'translationCount', 37 singular: updatesL10n.translation, 38 plural: updatesL10n.translations 39 } 40 }; 14 41 15 $elem = $( '#wp-admin-bar-updates .ab-label' ); 16 count = $elem.text(); 17 count = parseInt( count, 10 ) - 1; 18 if ( count < 0 ) { 42 updatesL10n.totalCount = parseInt( updatesL10n.totalCount, 10 ) - 1; 43 if ( updatesL10n.totalCount < 0 ) { 19 44 return; 20 45 } 21 $( '#wp-admin-bar-updates .ab-item' ).removeAttr( 'title' ); 22 $elem.text( count ); 46 $( '#wp-admin-bar-updates .ab-label' ).text( updatesL10n.totalCount ); 23 47 24 48 $elem = $( 'a[href="update-core.php"] .update-plugins' ); 25 49 $elem.each( function( index, elem ) { 26 elem.className = elem.className.replace( /count-\d+/, 'count-' + count );50 elem.className = elem.className.replace( /count-\d+/, 'count-' + updatesL10n.totalCount ); 27 51 } ); 28 $elem.removeAttr( 'title' ); 29 $elem.find( '.update-count' ).text( count ); 52 $elem.find( '.update-count' ).text( updatesL10n.totalCount ); 30 53 31 54 if ( 'plugin' === upgradeType ) { 32 55 $elem = $( '#menu-plugins' ); 33 pluginCount = $elem.find( '.plugin-count' ).eq(0).text(); 34 pluginCount = parseInt( pluginCount, 10 ) - 1; 35 if ( pluginCount < 0 ) { 36 return; 56 pluginCount = parseInt( updatesL10n.pluginCount, 10 ) - 1; 57 if ( pluginCount >= 0 ) { 58 $elem.find( '.plugin-count' ).text( pluginCount ); 59 $elem.find( '.update-plugins' ).each( function( index, elem ) { 60 elem.className = elem.className.replace( /count-\d+/, 'count-' + pluginCount ); 61 } ); 37 62 } 38 $elem.find( '.plugin-count' ).text( pluginCount );39 $elem.find( '.update-plugins' ).each( function( index, elem ) {40 elem.className = elem.className.replace( /count-\d+/, 'count-' + pluginCount );41 } );42 63 } 64 $.each( updateTypes, function( updateItemName, updateItem ) { 65 if ( updateItem.type == upgradeType ) { 66 updatesL10n[ updateItem.count ] = parseInt( updatesL10n[ updateItem.count ], 10 ); 67 // Decrement count if not already 0 68 updatesL10n[ updateItem.count ] = ( 0 === parseInt( updatesL10n[ updateItem.count ], 10 ) ? updatesL10n[ updateItem.count ] : updatesL10n[ updateItem.count ] - 1 ); 69 } 70 // If there are still updates available, add to the screen reader text 71 if ( 0 !== parseInt( updatesL10n[ updateItem.count ], 10 ) ) { 72 // Prefix a comma and space to the constructed screenReaderText if it already has a value 73 screenReaderText += '' === screenReaderText ? '' : ', '; 74 // Choose singular if count == 1 or plural if greater, replace %d with count in translation string 75 screenReaderText += ( 1 === parseInt( updatesL10n[ updateItem.count ], 10 ) ? updateItem.singular : updateItem.plural ).replace( '%d', updatesL10n[ updateItem.count ] ); 76 } 77 }); 78 79 $( '#wp-admin-bar-updates .ab-item' ).attr( 'title', screenReaderText ); 80 $( '#wp-admin-bar-updates .screen-reader-text' ).text( screenReaderText ); 81 43 82 }; 44 83 45 84 $( window ).on( 'message', function( e ) { -
src/wp-includes/script-loader.php
496 496 497 497 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery' ) ); 498 498 499 $update_data = wp_get_update_data(); 500 501 did_action( 'init' ) && $scripts->localize( 'updates', 'updatesL10n', array( 502 'plugin' => __( '%d Plugin Update' ), 503 'plugins' => __( '%d Plugin Updates' ), 504 'theme' => __( '%d Theme Update' ), 505 'themes' => __( '%d Theme Updates' ), 506 'translation' => __( '%d Translation Update' ), 507 'translations' => __( '%d Translations Updates' ), 508 'wordpress' => __( 'WordPress Update' ), 509 'pluginCount' => $update_data['counts']['plugins'], 510 'translationCount' => $update_data['counts']['translations'], 511 'themeCount' => $update_data['counts']['themes'], 512 'wordpressCount' => $update_data['counts']['wordpress'], 513 'totalCount' => $update_data['counts']['total'], 514 ) ) ; 515 499 516 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); 500 517 501 518 $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 ); … … 510 527 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 ); 511 528 512 529 $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); 513 530 514 531 $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 ); 515 532 $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 ); 516 533 did_action( 'init' ) && $scripts->localize( 'media', 'attachMediaBoxL10n', array( -
src/wp-includes/update.php
550 550 if ( $counts['themes'] ) 551 551 $titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] ); 552 552 if ( $counts['translations'] ) 553 $titles['translations'] = __( 'Translation Updates');553 $titles['translations'] = sprintf( _n( '%d Translation Update', '%d Translation Updates', $counts['translations'] ), $counts['translations'] ); 554 554 555 555 $update_title = $titles ? esc_attr( implode( ', ', $titles ) ) : ''; 556 556