Make WordPress Core


Ignore:
Timestamp:
09/06/2023 09:21:17 PM (3 years ago)
Author:
flixos90
Message:

Bundled Theme: Update default themes to use new script function signature.

In WordPress 6.3, the last parameter of wp_register_script() and wp_enqueue_script() was changed to an array rather than a boolean. While a boolean is still supported for backward compatibility, it makes sense to update the codebase to use the new signature.

The updates are fully backward compatible:

  • In places where true was provided, array( 'in_footer' => true ) will still be interpreted as a boolean true in WordPress versions prior to 6.3.
  • In places where false was provided, the parameter is omitted which will work correctly throughout all WordPress versions given that is and has been the default value anyway.

Props mrinal013, huzaifaalmesbah, niravsherasiya7707, joemcgill.
Fixes #59302.
See #58634.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentytwenty/functions.php

    r56106 r56526  
    214214        }
    215215
    216         wp_enqueue_script( 'twentytwenty-js', get_template_directory_uri() . '/assets/js/index.js', array(), $theme_version, false );
     216        wp_enqueue_script( 'twentytwenty-js', get_template_directory_uri() . '/assets/js/index.js', array(), $theme_version );
    217217        wp_script_add_data( 'twentytwenty-js', 'async', true );
    218218
     
    432432
    433433        // Enqueue the editor script.
    434         wp_enqueue_script( 'twentytwenty-block-editor-script', get_theme_file_uri( '/assets/js/editor-script-block.js' ), array( 'wp-blocks', 'wp-dom' ), wp_get_theme()->get( 'Version' ), true );
     434        wp_enqueue_script( 'twentytwenty-block-editor-script', get_theme_file_uri( '/assets/js/editor-script-block.js' ), array( 'wp-blocks', 'wp-dom' ), wp_get_theme()->get( 'Version' ), array( 'in_footer' => true ) );
    435435}
    436436
     
    626626
    627627        // Add main customizer js file.
    628         wp_enqueue_script( 'twentytwenty-customize', get_template_directory_uri() . '/assets/js/customize.js', array( 'jquery' ), $theme_version, false );
     628        wp_enqueue_script( 'twentytwenty-customize', get_template_directory_uri() . '/assets/js/customize.js', array( 'jquery' ), $theme_version );
    629629
    630630        // Add script for color calculations.
    631         wp_enqueue_script( 'twentytwenty-color-calculations', get_template_directory_uri() . '/assets/js/color-calculations.js', array( 'wp-color-picker' ), $theme_version, false );
     631        wp_enqueue_script( 'twentytwenty-color-calculations', get_template_directory_uri() . '/assets/js/color-calculations.js', array( 'wp-color-picker' ), $theme_version );
    632632
    633633        // Add script for controls.
    634         wp_enqueue_script( 'twentytwenty-customize-controls', get_template_directory_uri() . '/assets/js/customize-controls.js', array( 'twentytwenty-color-calculations', 'customize-controls', 'underscore', 'jquery' ), $theme_version, false );
     634        wp_enqueue_script( 'twentytwenty-customize-controls', get_template_directory_uri() . '/assets/js/customize-controls.js', array( 'twentytwenty-color-calculations', 'customize-controls', 'underscore', 'jquery' ), $theme_version );
    635635        wp_localize_script( 'twentytwenty-customize-controls', 'twentyTwentyBgColors', twentytwenty_get_customizer_color_vars() );
    636636}
     
    648648        $theme_version = wp_get_theme()->get( 'Version' );
    649649
    650         wp_enqueue_script( 'twentytwenty-customize-preview', get_theme_file_uri( '/assets/js/customize-preview.js' ), array( 'customize-preview', 'customize-selective-refresh', 'jquery' ), $theme_version, true );
     650        wp_enqueue_script( 'twentytwenty-customize-preview', get_theme_file_uri( '/assets/js/customize-preview.js' ), array( 'customize-preview', 'customize-selective-refresh', 'jquery' ), $theme_version, array( 'in_footer' => true ) );
    651651        wp_localize_script( 'twentytwenty-customize-preview', 'twentyTwentyBgColors', twentytwenty_get_customizer_color_vars() );
    652652        wp_localize_script( 'twentytwenty-customize-preview', 'twentyTwentyPreviewEls', twentytwenty_get_elements_array() );
Note: See TracChangeset for help on using the changeset viewer.