Make WordPress Core

Ticket #51498: 51498.2.patch

File 51498.2.patch, 14.2 KB (added by ocean90, 16 months 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

     
    55/* global pagenow, ajaxurl, postboxes, wpActiveEditor:true, ajaxWidgets */
    66/* global ajaxPopulateWidgets, quickPressLoad,  */
    77window.wp = window.wp || {};
     8window.communityEventsData = window.communityEventsData || {};
    89
    910/**
    1011 * Initializes the dashboard widget functionality.
     
    265266jQuery( function( $ ) {
    266267        'use strict';
    267268
    268         var communityEventsData = window.communityEventsData || {},
     269        var communityEventsData = window.communityEventsData,
     270                sprintf = wp.i18n.sprintf,
     271                __ = wp.i18n.__,
    269272                dateI18n = wp.date.dateI18n,
    270273                format = wp.date.format,
    271274                sprintf = wp.i18n.sprintf,
     
    466469                renderEventsTemplate: function( templateParams, initiatedBy ) {
    467470                        var template,
    468471                                elementVisibility,
    469                                 l10nPlaceholder  = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc.
    470472                                $toggleButton    = $( '.community-events-toggle-location' ),
    471473                                $locationMessage = $( '#community-events-location-message' ),
    472474                                $results         = $( '.community-events-results' );
     
    505507                                 * If the API determined the location by geolocating an IP, it will
    506508                                 * provide events, but not a specific location.
    507509                                 */
    508                                 $locationMessage.text( communityEventsData.l10n.attend_event_near_generic );
     510                                $locationMessage.text( __( 'Attend an upcoming event near you.' ) );
    509511
    510512                                if ( templateParams.events.length ) {
    511513                                        template = wp.template( 'community-events-event-list' );
     
    532534                                }
    533535
    534536                                if ( 'user' === initiatedBy ) {
    535                                         wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location.description ), 'assertive' );
     537                                        wp.a11y.speak(
     538                                                sprintf(
     539                                                        /* translators: %s: The name of a city. */
     540                                                        __( 'City updated. Listing events near %s.' ),
     541                                                        templateParams.location.description
     542                                                ),
     543                                                'assertive'
     544                                        );
    536545                                }
    537546
    538547                                elementVisibility['#community-events-location-message'] = true;
     
    542551                        } else if ( templateParams.unknownCity ) {
    543552                                template = wp.template( 'community-events-could-not-locate' );
    544553                                $( '.community-events-could-not-locate' ).html( template( templateParams ) );
    545                                 wp.a11y.speak( communityEventsData.l10n.could_not_locate_city.replace( l10nPlaceholder, templateParams.unknownCity ) );
     554                                wp.a11y.speak(
     555                                        sprintf(
     556                                                /*
     557                                                 * These specific examples were chosen to highlight the fact that a
     558                                                 * state is not needed, even for cities whose name is not unique.
     559                                                 * It would be too cumbersome to include that in the instructions
     560                                                 * to the user, so it's left as an implication.
     561                                                 */
     562                                                /*
     563                                                 * translators: %s is the name of the city we couldn't locate.
     564                                                 * Replace the examples with cities related to your locale. Test that
     565                                                 * they match the expected location and have upcoming events before
     566                                                 * including them. If no cities related to your locale have events,
     567                                                 * then use cities related to your locale that would be recognizable
     568                                                 * to most users. Use only the city name itself, without any region
     569                                                 * or country. Use the endonym (native locale name) instead of the
     570                                                 * English name if possible.
     571                                                 */
     572                                                __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
     573                                                templateParams.unknownCity
     574                                        )
     575                                );
    546576
    547577                                elementVisibility['.community-events-errors']           = true;
    548578                                elementVisibility['.community-events-could-not-locate'] = true;
     
    554584                                 * Showing error messages for an event that user isn't aware of
    555585                                 * could be confusing or unnecessarily distracting.
    556586                                 */
    557                                 wp.a11y.speak( communityEventsData.l10n.error_occurred_please_try_again );
     587                                wp.a11y.speak( __( 'An error occurred. Please try again.' ) );
    558588
    559589                                elementVisibility['.community-events-errors']         = true;
    560590                                elementVisibility['.community-events-error-occurred'] = true;
    561591                        } else {
    562                                 $locationMessage.text( communityEventsData.l10n.enter_closest_city );
     592                                $locationMessage.text( __( 'Enter your closest city to find nearby events.' ) );
    563593
    564594                                elementVisibility['#community-events-location-message'] = true;
    565595                                elementVisibility['.community-events-toggle-location']  = true;
     
    791821                });
    792822        }
    793823});
     824
     825/**
     826 * Removed in 5.6.0, needed for back-compatibility.
     827 *
     828 * @since 4.8.0
     829 * @deprecated 5.6.0
     830 *
     831 * @type {object}
     832*/
     833window.communityEventsData.l10n = window.communityEventsData.l10n || {
     834        enter_closest_city: '',
     835        error_occurred_please_try_again: '',
     836        attend_event_near_generic: '',
     837        could_not_locate_city: '',
     838        city_updated: ''
     839};
     840
     841window.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

     
    17571757                        'nonce'       => wp_create_nonce( 'community_events' ),
    17581758                        'cache'       => $events_client->get_cached_events(),
    17591759                        'time_format' => get_option( 'time_format' ),
    1760 
    1761                         'l10n'        => array(
    1762                                 'enter_closest_city'              => __( 'Enter your closest city to find nearby events.' ),
    1763                                 'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),
    1764                                 'attend_event_near_generic'       => __( 'Attend an upcoming event near you.' ),
    1765 
    1766                                 /*
    1767                                  * These specific examples were chosen to highlight the fact that a
    1768                                  * state is not needed, even for cities whose name is not unique.
    1769                                  * It would be too cumbersome to include that in the instructions
    1770                                  * to the user, so it's left as an implication.
    1771                                  */
    1772                                 /*
    1773                                  * translators: %s is the name of the city we couldn't locate.
    1774                                  * Replace the examples with cities related to your locale. Test that
    1775                                  * they match the expected location and have upcoming events before
    1776                                  * including them. If no cities related to your locale have events,
    1777                                  * then use cities related to your locale that would be recognizable
    1778                                  * to most users. Use only the city name itself, without any region
    1779                                  * or country. Use the endonym (native locale name) instead of the
    1780                                  * English name if possible.
    1781                                  */
    1782                                 'could_not_locate_city'           => __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
    1783 
    1784                                 // This one is only used with wp.a11y.speak(), so it can/should be more brief.
    1785                                 /* translators: %s: The name of a city. */
    1786                                 'city_updated'                    => __( 'City updated. Listing events near %s.' ),
    1787                         ),
    17881760                )
    17891761        );
    17901762}