WordPress.org

Make WordPress Core

Ticket #51123: deprecate_commonl10n.1.patch

File deprecate_commonl10n.1.patch, 11.8 KB (added by omarreiss, 11 months ago)
  • src/js/_enqueues/admin/common.js

    diff --git src/js/_enqueues/admin/common.js src/js/_enqueues/admin/common.js
    index 58f68d1..f52dd89 100644
     
    1919                __ = wp.i18n.__;
    2020
    2121/**
     22 * Throws an error for a deprecated property.
     23 *
     24 * @param {string} getter      The getter that was called.
     25 * @param {string} version     The version of WordPress that deprecated the function.
     26 * @param {string} replacement Optional. The getter that should have been called. Default null.
     27 */
     28function deprecatedProperty( getter, version, replacement ) {
     29        if ( typeof replacement !== 'undefined' ) {
     30                console.error( getter + ' is deprecated since version ' + version + '! Use ' + replacement + ' instead.' );
     31        } else {
     32                console.error( getter + ' is deprecated since version ' + version + ' with no alternative available.' );
     33        }
     34}
     35
     36/**
     37 * Deprecate all properties on an object.
     38 *
     39 * @param {string} name the name of the object i.e. commonL10n.
     40 * @param {object} l10nObject the object to deprecate the properties on.
     41 *
     42 * @return {object} The object with all its properties deprecated.
     43 */
     44function deprecateL10nObject( name, l10nObject ) {
     45        deprecatedObject = {};
     46
     47        Object.keys( l10nObject ).forEach( function( key ) {
     48                var prop = l10nObject[ key ];
     49                var propName = name + '.' + key;
     50
     51                if ( typeof prop === 'object' ) {
     52                        Object.defineProperty( deprecatedObject, key, { get: function() {
     53                                deprecatedProperty( propName, '5.5', prop.alternative );
     54                                return prop.func();
     55                        } } );
     56                } else {
     57                        Object.defineProperty( deprecatedObject, key, { get: function() {
     58                                deprecatedProperty( propName, '5.5', 'wp.i18n' );
     59                                return prop;
     60                        } } );
     61                }
     62        } );
     63
     64        return deprecatedObject;
     65}
     66
     67window.wp.deprecateL10nObject = deprecateL10nObject;
     68
     69/**
     70 * Removed in 5.5.0, needed for back-compatibility.
     71 *
     72 * @since 2.6.0
     73 * @deprecated 5.5.0
     74 */
     75window.commonL10n = window.commonL10n || {
     76        warnDelete: '',
     77        dismiss: '',
     78        collapseMenu: '',
     79        expandMenu: '',
     80};
     81
     82window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n );
     83
     84/**
     85 * Removed in 5.5.0, needed for back-compatibility.
     86 *
     87 * @since 3.3.0
     88 * @deprecated 5.5.0
     89 */
     90window.wpPointerL10n = window.wpPointerL10n || {
     91        dismiss: '',
     92};
     93
     94window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n );
     95
     96/**
     97 * Removed in 5.5.0, needed for back-compatibility.
     98 *
     99 * @deprecated 5.5.0
     100 */
     101window.userProfileL10n = window.userProfileL10n || {
     102        warn: '',
     103        warnWeak: '',
     104        show: '',
     105        hide: '',
     106        cancel: '',
     107        ariaShow: '',
     108        ariaHide: '',
     109};
     110
     111window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n );
     112
     113/**
     114 * Removed in 5.5.0, needed for back-compatibility.
     115 *
     116 * @since 4.9.6
     117 * @deprecated 5.5.0
     118 */
     119window.privacyToolsL10n = window.privacyToolsL10n || {
     120        noDataFound: '',
     121        foundAndRemoved: '',
     122        noneRemoved: '',
     123        someNotRemoved: '',
     124        removalError: '',
     125        emailSent: '',
     126        noExportFile: '',
     127        exportError: '',
     128};
     129
     130window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n );
     131
     132/**
     133 * Removed in 5.5.0, needed for back-compatibility.
     134 *
     135 * @since 3.6.0
     136 * @deprecated 5.5.0
     137 */
     138window.authcheckL10n = {
     139        beforeunload: '',
     140};
     141
     142window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n );
     143
     144/**
     145 * Removed in 5.5.0, needed for back-compatibility.
     146 *
     147 * @since 2.8.0
     148 * @deprecated 5.5.0
     149 */
     150window.tagsl10n = {
     151        noPerm: '',
     152        broken: '',
     153};
     154
     155window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n );
     156
     157/**
     158 * Removed in 5.5.0, needed for back-compatibility.
     159 *
     160 * @since 2.5.0
     161 * @deprecated 5.5.0
     162 */
     163window.adminCommentsL10n = window.adminCommentsL10n || {
     164        hotkeys_highlight_first: {
     165                alternative: "window.adminCommentsSettings.hotkeys_highlight_first",
     166                func: function() { return window.adminCommentsSettings.hotkeys_highlight_first; },
     167        },
     168        hotkeys_highlight_last: {
     169                alternative: "window.adminCommentsSettings.hotkeys_highlight_last",
     170                func: function() { return window.adminCommentsSettings.hotkeys_highlight_last; },
     171        },
     172        replyApprove: '',
     173        reply: '',
     174        warnQuickEdit: '',
     175        warnCommentChanges: '',
     176        docTitleComments: '',
     177        docTitleCommentsCount: '',
     178};
     179
     180window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n );
     181
     182/**
     183 * Removed in 5.5.0, needed for back-compatibility.
     184 *
     185 * @since 2.5.0
     186 * @deprecated 5.5.0
     187 */
     188window.tagsl10n = window.tagsl10n || {
     189        tagDelimiter: '',
     190        removeTerm: '',
     191        termSelected: '',
     192        termAdded: '',
     193        termRemoved: '',
     194};
     195
     196window.tagsL10n = deprecateL10nObject( 'tagsl10n', window.tagsl10n );
     197
     198/**
     199 * Removed in 5.5.0, needed for back-compatibility.
     200 *
     201 * @since 3.5.0
     202 * @deprecated 5.5.0
     203 */
     204window.wpColorPickerL10n = window.wpColorPickerL10n || {
     205        clear: '',
     206        clearAriaLabel: '',
     207        defaultString: '',
     208        defaultAriaLabel: '',
     209        pick: '',
     210        defaultLabel: '',
     211};
     212
     213window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n );
     214
     215/**
     216 * Removed in 5.5.0, needed for back-compatibility.
     217 *
     218 * @since 2.7.0
     219 * @deprecated 5.5.0
     220 */
     221window.attachMediaBoxL10n = window.attachMediaBoxL10n || {
     222        error: '',
     223};
     224
     225window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n );
     226
     227/**
     228 * Removed in 5.5.0, needed for back-compatibility.
     229 *
     230 * @deprecated 5.5.0
     231 */
     232window.postL10n = window.postL10n || {
     233        ok: '',
     234        cancel: '',
     235        publishOn: '',
     236        publishOnFuture: '',
     237        publishOnPast: '',
     238        dateFormat: '',
     239        showcomm: '',
     240        endcomm: '',
     241        publish: '',
     242        schedule: '',
     243        update: '',
     244        savePending: '',
     245        saveDraft: '',
     246        private: '',
     247        public: '',
     248        publicSticky: '',
     249        password: '',
     250        privatelyPublished: '',
     251        published: '',
     252        saveAlert: '',
     253        savingText: '',
     254        permalinkSaved: '',
     255};
     256
     257window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n );
     258
     259/**
     260 * Removed in 5.5.0, needed for back-compatibility.
     261 *
     262 * @since 2.7.0
     263 * @deprecated 5.5.0
     264 */
     265window.inlineEditL10n = window.inlineEditL10n || {
     266        error: '',
     267        ntdeltitle: '',
     268        notitle: '',
     269        comma: '',
     270        saved: '',
     271};
     272
     273window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n );
     274
     275/**
     276 * Removed in 5.5.0, needed for back-compatibility.
     277 *
     278 * @deprecated 5.5.0
     279 */
     280window.plugininstallL10n = window.plugininstallL10n || {
     281        plugin_information: '',
     282        plugin_modal_label: '',
     283        ays: '',
     284};
     285
     286window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n );
     287
     288/**
     289 * Removed in 5.5.0, needed for back-compatibility.
     290 *
     291 * @deprecated 5.5.0
     292 */
     293window.navMenuL10n = window.navMenuL10n || {
     294        noResultsFound: '',
     295        warnDeleteMenu: '',
     296        saveAlert: '',
     297        untitled: '',
     298};
     299
     300window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n );
     301
     302/**
     303 * Removed in 5.5.0, needed for back-compatibility.
     304 *
     305 * @since 2.5.0
     306 * @deprecated 5.5.0
     307 */
     308window.commentL10n = window.commentL10n || {
     309        submittedOn: '',
     310        dateFormat: '',
     311};
     312
     313window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n );
     314
     315/**
     316 * Removed in 5.5.0, needed for back-compatibility.
     317 *
     318 * @deprecated 5.5.0
     319 */
     320window.setPostThumbnailL10n = window.setPostThumbnailL10n || {
     321        setThumbnail: '',
     322        saving: '',
     323        error: '',
     324        done: '',
     325};
     326
     327window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n );
     328
     329
     330/**
    22331 * Removed in 3.3.0, needed for back-compatibility.
    23332 *
    24333 * @since 2.7.0
  • src/js/_enqueues/wp/theme-plugin-editor.js

    diff --git src/js/_enqueues/wp/theme-plugin-editor.js src/js/_enqueues/wp/theme-plugin-editor.js
    index 9516b0f..986717b 100644
    wp.themePluginEditor = (function( $ ) { 
    10001000
    10011001        return component;
    10021002})( jQuery );
     1003
     1004wp.themePluginEditor.l10n = wp.themePluginEditor.l10n || {
     1005        saveAlert: '',
     1006        saveError: '',
     1007        lintError: {
     1008                alternative: 'wp.i18n',
     1009                func: function() {
     1010                        return {
     1011                                singular: '',
     1012                                plural: '',
     1013                        };
     1014                },
     1015        }
     1016};
     1017
     1018wp.themePluginEditor.l10n = window.wp.deprecateL10nObject( 'wp.themePluginEditor.l10n', wp.themePluginEditor.l10n );
  • src/js/_enqueues/wp/updates.js

    diff --git src/js/_enqueues/wp/updates.js src/js/_enqueues/wp/updates.js
    index 48a256b..8848bb0 100644
     
    4343        wp.updates = {};
    4444
    4545        /**
     46         * Removed in 5.5.0, needed for back-compatibility.
     47         *
     48         * @since 4.2.0
     49         * @deprecated 5.5
     50         *
     51         * @type {object}
     52         */
     53        wp.updates.l10n = {
     54                searchResults: '',
     55                searchResultsLabel: '',
     56                noPlugins: '',
     57                noItemsSelected: '',
     58                updating: '',
     59                pluginUpdated: '',
     60                themeUpdated: '',
     61                update: '',
     62                updateNow: '',
     63                pluginUpdateNowLabel: '',
     64                updateFailedShort: '',
     65                updateFailed: '',
     66                pluginUpdatingLabel: '',
     67                pluginUpdatedLabel: '',
     68                pluginUpdateFailedLabel: '',
     69                updatingMsg: '',
     70                updatedMsg: '',
     71                updateCancel: '',
     72                beforeunload: '',
     73                installNow: '',
     74                pluginInstallNowLabel: '',
     75                installing: '',
     76                pluginInstalled: '',
     77                themeInstalled: '',
     78                installFailedShort: '',
     79                installFailed: '',
     80                pluginInstallingLabel: '',
     81                themeInstallingLabel: '',
     82                pluginInstalledLabel: '',
     83                themeInstalledLabel: '',
     84                pluginInstallFailedLabel: '',
     85                themeInstallFailedLabel: '',
     86                installingMsg: '',
     87                installedMsg: '',
     88                importerInstalledMsg: '',
     89                aysDelete: '',
     90                aysDeleteUninstall: '',
     91                aysBulkDelete: '',
     92                aysBulkDeleteThemes: '',
     93                deleting: '',
     94                deleteFailed: '',
     95                pluginDeleted: '',
     96                themeDeleted: '',
     97                livePreview: '',
     98                activatePlugin: '',
     99                activateTheme: '',
     100                activatePluginLabel: '',
     101                activateThemeLabel: '',
     102                activateImporter: '',
     103                activateImporterLabel: '',
     104                unknownError: '',
     105                connectionError: '',
     106                nonceError: '',
     107                pluginsFound: '',
     108                noPluginsFound: '',
     109                autoUpdatesEnable: '',
     110                autoUpdatesEnabling: '',
     111                autoUpdatesEnabled: '',
     112                autoUpdatesDisable: '',
     113                autoUpdatesDisabling: '',
     114                autoUpdatesDisabled: '',
     115                autoUpdatesError: '',
     116        };
     117
     118        wp.updates.l10n = window.wp.deprecateL10nObject( 'wp.updates.l10n', wp.updates.l10n );
     119
     120        /**
    46121         * User nonce for ajax calls.
    47122         *
    48123         * @since 4.2.0
  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index 6f59ec8..e0b8080 100644
    function wp_default_scripts( $scripts ) { 
    10131013        $scripts->add( 'htmlhint', '/wp-includes/js/codemirror/htmlhint.js', array(), '0.9.14-xwp' );
    10141014        $scripts->add( 'htmlhint-kses', '/wp-includes/js/codemirror/htmlhint-kses.js', array( 'htmlhint' ) );
    10151015        $scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror', 'underscore' ) );
    1016         $scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'wp-util', 'wp-sanitize', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) );
     1016        $scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'common', 'wp-util', 'wp-sanitize', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) );
    10171017        $scripts->set_translations( 'wp-theme-plugin-editor' );
    10181018
    10191019        $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 );
    function wp_default_scripts( $scripts ) { 
    12611261                $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
    12621262                $scripts->set_translations( 'privacy-tools' );
    12631263
    1264                 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
     1264                $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'common', 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
    12651265                $scripts->set_translations( 'updates' );
    12661266                did_action( 'init' ) && $scripts->localize(
    12671267                        'updates',