Make WordPress Core

Changeset 56526

Timestamp:
09/06/2023 09:21:17 PM (11 months 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.

Location:
trunk/src/wp-content/themes
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyeleven/inc/theme-options.php

    r55420 r56526  
    674674 */
    675675function twentyeleven_customize_preview_js() {
    676     wp_enqueue_script( 'twentyeleven-customizer', get_template_directory_uri() . '/inc/theme-customizer.js', array( 'customize-preview' ), '20150401', true );
     676    wp_enqueue_script( 'twentyeleven-customizer', get_template_directory_uri() . '/inc/theme-customizer.js', array( 'customize-preview' ), '20150401', );
    677677}
    678678add_action( 'customize_preview_init', 'twentyeleven_customize_preview_js' );
  • trunk/src/wp-content/themes/twentyfifteen/functions.php

    r56315 r56526  
    445445
    446446    // Skip-link fix is no longer enqueued by default.
    447     wp_register_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', true );
     447    wp_register_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', );
    448448
    449449    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
     
    455455    }
    456456
    457     wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20221101', true );
     457    wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20221101', );
    458458    wp_localize_script(
    459459        'twentyfifteen-script',
  • trunk/src/wp-content/themes/twentyfifteen/inc/customizer.php

    r55981 r56526  
    360360 */
    361361function twentyfifteen_customize_control_js() {
    362     wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20141216', true );
     362    wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20141216', );
    363363    wp_localize_script( 'color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes() );
    364364}
     
    371371 */
    372372function twentyfifteen_customize_preview_js() {
    373     wp_enqueue_script( 'twentyfifteen-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20141216', true );
     373    wp_enqueue_script( 'twentyfifteen-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20141216', );
    374374}
    375375add_action( 'customize_preview_init', 'twentyfifteen_customize_preview_js' );
  • trunk/src/wp-content/themes/twentyfourteen/functions.php

    r56315 r56526  
    368368
    369369    if ( is_front_page() && 'slider' === get_theme_mod( 'featured_content_layout' ) ) {
    370         wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20150120', true );
     370        wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20150120', );
    371371        wp_localize_script(
    372372            'twentyfourteen-slider',
     
    379379    }
    380380
    381     wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', true );
     381    wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', );
    382382}
    383383add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
  • trunk/src/wp-content/themes/twentyfourteen/inc/customizer.php

    r48067 r56526  
    143143 */
    144144function twentyfourteen_customize_preview_js() {
    145     wp_enqueue_script( 'twentyfourteen_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20141015', true );
     145    wp_enqueue_script( 'twentyfourteen_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20141015', );
    146146}
    147147add_action( 'customize_preview_init', 'twentyfourteen_customize_preview_js' );
  • trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php

    r55476 r56526  
    435435     */
    436436    public static function enqueue_scripts() {
    437         wp_enqueue_script( 'featured-content-suggest', get_template_directory_uri() . '/js/featured-content-admin.js', array( 'jquery', 'suggest' ), '20211130', true );
     437        wp_enqueue_script( 'featured-content-suggest', get_template_directory_uri() . '/js/featured-content-admin.js', array( 'jquery', 'suggest' ), '20211130', );
    438438    }
    439439
  • trunk/src/wp-content/themes/twentynineteen/functions.php

    r56315 r56526  
    260260
    261261    if ( has_nav_menu( 'menu-1' ) ) {
    262         wp_enqueue_script( 'twentynineteen-priority-menu', get_theme_file_uri( '/js/priority-menu.js' ), array(), '20200129', true );
    263         wp_enqueue_script( 'twentynineteen-touch-navigation', get_theme_file_uri( '/js/touch-keyboard-navigation.js' ), array(), '20230621', true );
     262        wp_enqueue_script( 'twentynineteen-priority-menu', get_theme_file_uri( '/js/priority-menu.js' ), array(), '20200129', );
     263        wp_enqueue_script( 'twentynineteen-touch-navigation', get_theme_file_uri( '/js/touch-keyboard-navigation.js' ), array(), '20230621', );
    264264    }
    265265
  • trunk/src/wp-content/themes/twentynineteen/inc/customizer.php

    r48102 r56526  
    126126 */
    127127function twentynineteen_customize_preview_js() {
    128     wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20181214', true );
     128    wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20181214', );
    129129}
    130130add_action( 'customize_preview_init', 'twentynineteen_customize_preview_js' );
     
    134134 */
    135135function twentynineteen_panels_js() {
    136     wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '20181214', true );
     136    wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '20181214', );
    137137}
    138138add_action( 'customize_controls_enqueue_scripts', 'twentynineteen_panels_js' );
  • trunk/src/wp-content/themes/twentyseventeen/functions.php

    r56315 r56526  
    478478
    479479    // Skip-link fix is no longer enqueued by default.
    480     wp_register_script( 'twentyseventeen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '20161114', true );
    481 
    482     wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '20211130', true );
     480    wp_register_script( 'twentyseventeen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '20161114', );
     481
     482    wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '20211130', );
    483483
    484484    $twentyseventeen_l10n = array(
     
    487487
    488488    if ( has_nav_menu( 'top' ) ) {
    489         wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array( 'jquery' ), '20210122', true );
     489        wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array( 'jquery' ), '20210122', );
    490490        $twentyseventeen_l10n['expand']   = __( 'Expand child menu', 'twentyseventeen' );
    491491        $twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' );
     
    500500    wp_localize_script( 'twentyseventeen-global', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
    501501
    502     wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.3', true );
     502    wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.3', );
    503503
    504504    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  • trunk/src/wp-content/themes/twentyseventeen/inc/customizer.php

    r56012 r56526  
    246246 */
    247247function twentyseventeen_customize_preview_js() {
    248     wp_enqueue_script( 'twentyseventeen-customize-preview', get_theme_file_uri( '/assets/js/customize-preview.js' ), array( 'customize-preview' ), '20161002', true );
     248    wp_enqueue_script( 'twentyseventeen-customize-preview', get_theme_file_uri( '/assets/js/customize-preview.js' ), array( 'customize-preview' ), '20161002', );
    249249}
    250250add_action( 'customize_preview_init', 'twentyseventeen_customize_preview_js' );
     
    254254 */
    255255function twentyseventeen_panels_js() {
    256     wp_enqueue_script( 'twentyseventeen-customize-controls', get_theme_file_uri( '/assets/js/customize-controls.js' ), array(), '20161020', true );
     256    wp_enqueue_script( 'twentyseventeen-customize-controls', get_theme_file_uri( '/assets/js/customize-controls.js' ), array(), '20161020', );
    257257}
    258258add_action( 'customize_controls_enqueue_scripts', 'twentyseventeen_panels_js' );
  • trunk/src/wp-content/themes/twentysixteen/functions.php

    r56315 r56526  
    414414
    415415    // Skip-link fix is no longer enqueued by default.
    416     wp_register_script( 'twentysixteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', true );
     416    wp_register_script( 'twentysixteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', );
    417417
    418418    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
     
    424424    }
    425425
    426     wp_enqueue_script( 'twentysixteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230629', true );
     426    wp_enqueue_script( 'twentysixteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230629', );
    427427
    428428    wp_localize_script(
  • trunk/src/wp-content/themes/twentysixteen/inc/customizer.php

    r48782 r56526  
    487487 */
    488488function twentysixteen_customize_control_js() {
    489     wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20170530', true );
     489    wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20170530', );
    490490    wp_localize_script( 'color-scheme-control', 'colorScheme', twentysixteen_get_color_schemes() );
    491491}
     
    498498 */
    499499function twentysixteen_customize_preview_js() {
    500     wp_enqueue_script( 'twentysixteen-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20170530', true );
     500    wp_enqueue_script( 'twentysixteen-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20170530', );
    501501}
    502502add_action( 'customize_preview_init', 'twentysixteen_customize_preview_js' );
  • trunk/src/wp-content/themes/twentythirteen/functions.php

    r56315 r56526  
    322322
    323323    // Loads JavaScript file with functionality specific to Twenty Thirteen.
    324     wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', true );
     324    wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', );
    325325
    326326    // Add Source Sans Pro and Bitter fonts, used in the main stylesheet.
     
    844844 */
    845845function twentythirteen_customize_preview_js() {
    846     wp_enqueue_script( 'twentythirteen-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20200516', true );
     846    wp_enqueue_script( 'twentythirteen-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20200516', );
    847847}
    848848add_action( 'customize_preview_init', 'twentythirteen_customize_preview_js' );
  • trunk/src/wp-content/themes/twentytwelve/functions.php

    r56315 r56526  
    189189
    190190    // Adds JavaScript for handling the navigation menu hide-and-show behavior.
    191     wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), '20141205', true );
     191    wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), '20141205', );
    192192
    193193    $font_url = twentytwelve_get_font_url();
     
    693693 */
    694694function twentytwelve_customize_preview_js() {
    695     wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20200516', true );
     695    wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20200516', );
    696696}
    697697add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' );
  • 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' ), );
    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, );
    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() );
  • trunk/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php

    r56300 r56526  
    7070            array(),
    7171            '1.0.0',
    72             true
     72           
    7373        );
    7474
     
    7878            array( 'twentytwentyone-dark-mode-support-toggle' ),
    7979            '1.0.0',
    80             true
     80           
    8181        );
    8282    }
     
    116116            array( 'customize-base', 'customize-controls', 'underscore', 'jquery', 'twentytwentyone-customize-helpers' ),
    117117            '1.0.0',
    118             true
     118           
    119119        );
    120120    }
  • trunk/src/wp-content/themes/twentytwentyone/functions.php

    r56170 r56526  
    422422        array(),
    423423        wp_get_theme()->get( 'Version' ),
    424         true
     424       
    425425    );
    426426
     
    431431        array(),
    432432        wp_get_theme()->get( 'Version' ),
    433         true
     433       
    434434    );
    435435    wp_add_inline_script(
     
    450450            array( 'twenty-twenty-one-ie11-polyfills' ),
    451451            wp_get_theme()->get( 'Version' ),
    452             true
     452           
    453453        );
    454454    }
     
    460460        array( 'twenty-twenty-one-ie11-polyfills' ),
    461461        wp_get_theme()->get( 'Version' ),
    462         true
     462       
    463463    );
    464464}
     
    474474function twentytwentyone_block_editor_script() {
    475475
    476     wp_enqueue_script( 'twentytwentyone-editor', get_theme_file_uri( '/assets/js/editor.js' ), array( 'wp-blocks', 'wp-dom' ), wp_get_theme()->get( 'Version' ), true );
     476    wp_enqueue_script( 'twentytwentyone-editor', get_theme_file_uri( '/assets/js/editor.js' ), array( 'wp-blocks', 'wp-dom' ), wp_get_theme()->get( 'Version' ), );
    477477}
    478478
     
    566566        array(),
    567567        wp_get_theme()->get( 'Version' ),
    568         true
     568       
    569569    );
    570570
     
    574574        array( 'customize-preview', 'customize-selective-refresh', 'jquery', 'twentytwentyone-customize-helpers' ),
    575575        wp_get_theme()->get( 'Version' ),
    576         true
     576       
    577577    );
    578578}
     
    593593        array(),
    594594        wp_get_theme()->get( 'Version' ),
    595         true
     595       
    596596    );
    597597}
Note: See TracChangeset for help on using the changeset viewer.