Making WordPress.org

Changeset 2263


Ignore:
Timestamp:
01/10/2016 12:18:50 AM (9 years ago)
Author:
ocean90
Message:

Translate: Use the wp_default_scripts action for replacing the default editor script.

Prevents missing localized data like $gp_editor_options.

See #1352.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-js-warnings/wporg-gp-js-warnings.php

    r2123 r2263  
    1414 * - Translate the warning strings
    1515 * - Match warning error strings between GlotPress & this plugin?
    16  *
    17  * @author dd32
    1816 */
    1917class WPorg_GP_JS_Translation_Warnings {
    2018
    2119    function __construct() {
    22         add_action( 'wp_print_scripts', array( $this, 'replace_editor_with_our_own' ), 100 );
     20        add_action( 'wp_default_scripts', array( $this, 'replace_editor_with_our_own' ), 11 );
    2321    }
    2422
     
    2725     *
    2826     * This allows us to be output whenever `gp-editor` is.
     27     *
     28     * @param WP_Scripts $scripts WP_Scripts object.
    2929     */
    30     function replace_editor_with_our_own() {
    31         $query = wp_scripts()->query( 'gp-editor', 'registered' );
     30    function replace_editor_with_our_own( $scripts ) {
     31        $query = $scripts->query( 'gp-editor', 'registered' );
    3232        if ( ! $query ) {
    3333            return;
    3434        }
    3535
    36         wp_register_script( 'wporg-gp-editor', $query->src, $query->deps, $query->ver );
     36        $scripts->add( 'wporg-gp-editor', $query->src, $query->deps, $query->ver );
    3737        if ( isset( $query->extra['l10n'] ) ) {
    38             wp_localize_script( 'wporg-gp-editor', $query->extra['l10n'][0], $query->extra['l10n'][1] );
     38            $scripts->localize( 'wporg-gp-editor', $query->extra['l10n'][0], $query->extra['l10n'][1] );
    3939        }
    4040
    41         wp_deregister_script( 'gp-editor' );
    42         wp_register_script( 'gp-editor', plugins_url( '/wporg-gp-js-warnings.js', __FILE__ ), array( 'wporg-gp-editor', 'jquery' ), '2015-11-14' );
     41        $scripts->remove( 'gp-editor' );
     42        $scripts->add( 'gp-editor', plugins_url( '/wporg-gp-js-warnings.js', __FILE__ ), array( 'wporg-gp-editor', 'jquery' ), '2015-11-14' );
    4343    }
    4444
Note: See TracChangeset for help on using the changeset viewer.