Make WordPress Core

Ticket #51498: 51498.patch

File 51498.patch, 14.1 KB (added by ocean90, 5 years ago)
  • src/js/_enqueues/admin/common.js

     
    5555 * Deprecate all properties on an object.
    5656 *
    5757 * @since 5.5.1
     58 * @since 5.6.0 Added the `version` parameter.
    5859 *
    5960 * @param {string} name       The name of the object, i.e. commonL10n.
    6061 * @param {object} l10nObject The object to deprecate the properties on.
     62 * @param {string} version    The version of WordPress that deprecated the property.
    6163 *
    6264 * @return {object} The object with all its properties deprecated.
    6365 */
    64 function deprecateL10nObject( name, l10nObject ) {
     66function deprecateL10nObject( name, l10nObject, version ) {
    6567        var deprecatedObject = {};
    6668
    6769        Object.keys( l10nObject ).forEach( function( key ) {
     
    7072
    7173                if ( 'object' === typeof prop ) {
    7274                        Object.defineProperty( deprecatedObject, key, { get: function() {
    73                                 deprecatedProperty( propName, '5.5.0', prop.alternative );
     75                                deprecatedProperty( propName, version, prop.alternative );
    7476                                return prop.func();
    7577                        } } );
    7678                } else {
    7779                        Object.defineProperty( deprecatedObject, key, { get: function() {
    78                                 deprecatedProperty( propName, '5.5.0', 'wp.i18n' );
     80                                deprecatedProperty( propName, version, 'wp.i18n' );
    7981                                return prop;
    8082                        } } );
    8183                }
     
    99101        expandMenu: ''
    100102};
    101103
    102 window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n );
     104window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n, '5.5.0' );
    103105
    104106/**
    105107 * Removed in 5.5.0, needed for back-compatibility.
     
    111113        dismiss: ''
    112114};
    113115
    114 window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n );
     116window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n, '5.5.0' );
    115117
    116118/**
    117119 * Removed in 5.5.0, needed for back-compatibility.
     
    129131        ariaHide: ''
    130132};
    131133
    132 window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n );
     134window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n, '5.5.0' );
    133135
    134136/**
    135137 * Removed in 5.5.0, needed for back-compatibility.
     
    148150        exportError: ''
    149151};
    150152
    151 window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n );
     153window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n, '5.5.0' );
    152154
    153155/**
    154156 * Removed in 5.5.0, needed for back-compatibility.
     
    160162        beforeunload: ''
    161163};
    162164
    163 window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n );
     165window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n, '5.5.0' );
    164166
    165167/**
    166168 * Removed in 5.5.0, needed for back-compatibility.
     
    173175        broken: ''
    174176};
    175177
    176 window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n );
     178window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n, '5.5.0' );
    177179
    178180/**
    179181 * Removed in 5.5.0, needed for back-compatibility.
     
    198200        docTitleCommentsCount: ''
    199201};
    200202
    201 window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n );
     203window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n, '5.5.0' );
    202204
    203205/**
    204206 * Removed in 5.5.0, needed for back-compatibility.
     
    214216        termRemoved: ''
    215217};
    216218
    217 window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n );
     219window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n, '5.5.0' );
    218220
    219221/**
    220222 * Removed in 5.5.0, needed for back-compatibility.
     
    231233        defaultLabel: ''
    232234};
    233235
    234 window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n );
     236window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n, '5.5.0' );
    235237
    236238/**
    237239 * Removed in 5.5.0, needed for back-compatibility.
     
    243245        error: ''
    244246};
    245247
    246 window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n );
     248window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n, '5.5.0' );
    247249
    248250/**
    249251 * Removed in 5.5.0, needed for back-compatibility.
     
    276278        permalinkSaved: ''
    277279};
    278280
    279 window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n );
     281window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n, '5.5.0' );
    280282
    281283/**
    282284 * Removed in 5.5.0, needed for back-compatibility.
     
    292294        saved: ''
    293295};
    294296
    295 window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n );
     297window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n, '5.5.0' );
    296298
    297299/**
    298300 * Removed in 5.5.0, needed for back-compatibility.
     
    306308        ays: ''
    307309};
    308310
    309 window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n );
     311window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n, '5.5.0' );
    310312
    311313/**
    312314 * Removed in 5.5.0, needed for back-compatibility.
     
    321323        untitled: ''
    322324};
    323325
    324 window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n );
     326window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n, '5.5.0' );
    325327
    326328/**
    327329 * Removed in 5.5.0, needed for back-compatibility.
     
    334336        dateFormat: ''
    335337};
    336338
    337 window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n );
     339window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n, '5.5.0' );
    338340
    339341/**
    340342 * Removed in 5.5.0, needed for back-compatibility.
     
    349351        done: ''
    350352};
    351353
    352 window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n );
     354window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' );
    353355
    354356/**
    355357 * Removed in 3.3.0, needed for back-compatibility.
  • src/js/_enqueues/admin/widgets.js

     
    760760        widgetAdded: ''
    761761};
    762762
    763 wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n );
     763wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n, '5.5.0' );
  • src/js/_enqueues/wp/dashboard.js

     
    266266        'use strict';
    267267
    268268        var communityEventsData = window.communityEventsData || {},
     269                sprintf = wp.i18n.sprintf,
     270                __ = wp.i18n.__,
    269271                app;
    270272
    271273        /**
     
    460462                renderEventsTemplate: function( templateParams, initiatedBy ) {
    461463                        var template,
    462464                                elementVisibility,
    463                                 l10nPlaceholder  = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc.
    464465                                $toggleButton    = $( '.community-events-toggle-location' ),
    465466                                $locationMessage = $( '#community-events-location-message' ),
    466467                                $results         = $( '.community-events-results' );
     
    494495                                 * If the API determined the location by geolocating an IP, it will
    495496                                 * provide events, but not a specific location.
    496497                                 */
    497                                 $locationMessage.text( communityEventsData.l10n.attend_event_near_generic );
     498                                $locationMessage.text( __( 'Attend an upcoming event near you.' ) );
    498499
    499500                                if ( templateParams.events.length ) {
    500501                                        template = wp.template( 'community-events-event-list' );
     
    521522                                }
    522523
    523524                                if ( 'user' === initiatedBy ) {
    524                                         wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location.description ), 'assertive' );
     525                                        wp.a11y.speak(
     526                                                sprintf(
     527                                                        /* translators: %s: The name of a city. */
     528                                                        __( 'City updated. Listing events near %s.' ),
     529                                                        templateParams.location.description
     530                                                ),
     531                                                'assertive'
     532                                        );
    525533                                }
    526534
    527535                                elementVisibility['#community-events-location-message'] = true;
     
    531539                        } else if ( templateParams.unknownCity ) {
    532540                                template = wp.template( 'community-events-could-not-locate' );
    533541                                $( '.community-events-could-not-locate' ).html( template( templateParams ) );
    534                                 wp.a11y.speak( communityEventsData.l10n.could_not_locate_city.replace( l10nPlaceholder, templateParams.unknownCity ) );
     542                                wp.a11y.speak(
     543                                        sprintf(
     544                                                /*
     545                                                * These specific examples were chosen to highlight the fact that a
     546                                                * state is not needed, even for cities whose name is not unique.
     547                                                * It would be too cumbersome to include that in the instructions
     548                                                * to the user, so it's left as an implication.
     549                                                */
     550                                                /*
     551                                                * translators: %s is the name of the city we couldn't locate.
     552                                                * Replace the examples with cities related to your locale. Test that
     553                                                * they match the expected location and have upcoming events before
     554                                                * including them. If no cities related to your locale have events,
     555                                                * then use cities related to your locale that would be recognizable
     556                                                * to most users. Use only the city name itself, without any region
     557                                                * or country. Use the endonym (native locale name) instead of the
     558                                                * English name if possible.
     559                                                */
     560                                                __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
     561                                                templateParams.unknownCity
     562                                        )
     563                                );
    535564
    536565                                elementVisibility['.community-events-errors']           = true;
    537566                                elementVisibility['.community-events-could-not-locate'] = true;
     
    543572                                 * Showing error messages for an event that user isn't aware of
    544573                                 * could be confusing or unnecessarily distracting.
    545574                                 */
    546                                 wp.a11y.speak( communityEventsData.l10n.error_occurred_please_try_again );
     575                                wp.a11y.speak( __( 'An error occurred. Please try again.' ) );
    547576
    548577                                elementVisibility['.community-events-errors']         = true;
    549578                                elementVisibility['.community-events-error-occurred'] = true;
    550579                        } else {
    551                                 $locationMessage.text( communityEventsData.l10n.enter_closest_city );
     580                                $locationMessage.text( __( 'Enter your closest city to find nearby events.' ) );
    552581
    553582                                elementVisibility['#community-events-location-message'] = true;
    554583                                elementVisibility['.community-events-toggle-location']  = true;
     
    591620                });
    592621        }
    593622});
     623
     624/**
     625 * Removed in 5.6.0, needed for back-compatibility.
     626 *
     627 * @since 4.9.0
     628 * @deprecated 5.6.0
     629 *
     630 * @type {object}
     631*/
     632window.communityEventsData = window.communityEventsData || {};
     633window.communityEventsData.l10n = window.communityEventsData.l10n || {
     634        enter_closest_city: '',
     635        error_occurred_please_try_again: '',
     636        attend_event_near_generic: '',
     637        could_not_locate_city: '',
     638        city_updated: ''
     639};
     640
     641window.communityEventsData.l10n = window.wp.deprecateL10nObject( 'communityEventsData.l10n', window.communityEventsData.l10n, '5.6.0' );
  • src/js/_enqueues/wp/theme-plugin-editor.js

     
    10231023        }
    10241024};
    10251025
    1026 wp.themePluginEditor.l10n = window.wp.deprecateL10nObject( 'wp.themePluginEditor.l10n', wp.themePluginEditor.l10n );
     1026wp.themePluginEditor.l10n = window.wp.deprecateL10nObject( 'wp.themePluginEditor.l10n', wp.themePluginEditor.l10n, '5.5.0' );
  • src/js/_enqueues/wp/updates.js

     
    115115                autoUpdatesError: ''
    116116        };
    117117
    118         wp.updates.l10n = window.wp.deprecateL10nObject( 'wp.updates.l10n', wp.updates.l10n );
     118        wp.updates.l10n = window.wp.deprecateL10nObject( 'wp.updates.l10n', wp.updates.l10n, '5.5.0' );
    119119
    120120        /**
    121121         * User nonce for ajax calls.
  • src/wp-includes/script-loader.php

     
    13091309                $scripts->set_translations( 'wp-color-picker' );
    13101310
    13111311                $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 );
     1312                $scripts->set_translations( 'dashboard' );
    13121313
    13131314                $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
    13141315
     
    17551756                array(
    17561757                        'nonce' => wp_create_nonce( 'community_events' ),
    17571758                        'cache' => $events_client->get_cached_events(),
    1758 
    1759                         'l10n'  => array(
    1760                                 'enter_closest_city'              => __( 'Enter your closest city to find nearby events.' ),
    1761                                 'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),
    1762                                 'attend_event_near_generic'       => __( 'Attend an upcoming event near you.' ),
    1763 
    1764                                 /*
    1765                                  * These specific examples were chosen to highlight the fact that a
    1766                                  * state is not needed, even for cities whose name is not unique.
    1767                                  * It would be too cumbersome to include that in the instructions
    1768                                  * to the user, so it's left as an implication.
    1769                                  */
    1770                                 /*
    1771                                  * translators: %s is the name of the city we couldn't locate.
    1772                                  * Replace the examples with cities related to your locale. Test that
    1773                                  * they match the expected location and have upcoming events before
    1774                                  * including them. If no cities related to your locale have events,
    1775                                  * then use cities related to your locale that would be recognizable
    1776                                  * to most users. Use only the city name itself, without any region
    1777                                  * or country. Use the endonym (native locale name) instead of the
    1778                                  * English name if possible.
    1779                                  */
    1780                                 'could_not_locate_city'           => __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
    1781 
    1782                                 // This one is only used with wp.a11y.speak(), so it can/should be more brief.
    1783                                 /* translators: %s: The name of a city. */
    1784                                 'city_updated'                    => __( 'City updated. Listing events near %s.' ),
    1785                         ),
    17861759                )
    17871760        );
    17881761}