WordPress.org

Make WordPress Core

Ticket #51123: deprecate_commonl10n.patch

File deprecate_commonl10n.patch, 1.2 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..88924bf 100644
     
    1919                __ = wp.i18n.__;
    2020
    2121/**
     22 * @param {string} getter      The getter that was called.
     23 * @param {string} version     The version of WordPress that deprecated the function.
     24 * @param {string} replacement Optional. The getter that should have been called. Default null.
     25 */
     26function deprecatedGetter( getter, version, replacement ) {
     27        if ( typeof replacement !== 'undefined' ) {
     28                console.error( getter + ' is deprecated since version ' + version + '! Use ' + replacement + ' instead.' );
     29        } else {
     30                console.error( getter + ' is deprecated since version ' + version + ' with no alternative available.' );
     31        }
     32}
     33
     34/**
     35 * Removed in 5.5.0, needed for back-compatibility.
     36 *
     37 * @since 2.6.0
     38 * @deprecated 5.5.0
     39 */
     40window.commonL10n = {};
     41
     42[ 'warnDelete', 'dismiss', 'collapseMenu', 'expandMenu' ].forEach( function( getter ) {
     43        window.commonL10n.__defineGetter__( getter, function() {
     44                deprecatedGetter( getter, '5.5', 'wp.i18n' );
     45                return '';
     46        } );
     47} );
     48
     49/**
    2250 * Removed in 3.3.0, needed for back-compatibility.
    2351 *
    2452 * @since 2.7.0