Make WordPress Core


Ignore:
Timestamp:
07/01/2020 07:48:30 PM (6 years ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/common.js.

This removes the usage of wp_localize_script() for passing translations to the script and instead adds the translatable strings in the script directly through the use of wp.i18n and its utilities.

Props swissspidy, ocean90.
See #20491.
Fixes #50526.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r48266 r48267  
    609609
    610610    $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils' ), false, 1 );
    611     did_action( 'init' ) && $scripts->localize(
    612         'common',
    613         'commonL10n',
    614         array(
    615             'warnDelete'   => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
    616             'dismiss'      => __( 'Dismiss this notice.' ),
    617             'collapseMenu' => __( 'Collapse Main menu' ),
    618             'expandMenu'   => __( 'Expand Main menu' ),
    619         )
    620     );
     611    $scripts->set_translations( 'common' );
    621612
    622613    $scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 );
     
    810801    // Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv.
    811802    // It sets jQuery as a dependency, as the theme may have been implicitly loading it this way.
    812     $scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '4.1.4', 1 );
    813     $scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '4.2.2', 1 );
     803    $scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '3.2.0', 1 );
     804    $scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '3.3.2', 1 );
    814805    $scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2b', 1 );
    815806
Note: See TracChangeset for help on using the changeset viewer.