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/twentytwentyone/functions.php

    r56170 r56526  
    422422                array(),
    423423                wp_get_theme()->get( 'Version' ),
    424                 true
     424                array( 'in_footer' => true )
    425425        );
    426426
    … …  
    431431                array(),
    432432                wp_get_theme()->get( 'Version' ),
    433                 true
     433                array( 'in_footer' => true )
    434434        );
    435435        wp_add_inline_script(
    … …  
    450450                        array( 'twenty-twenty-one-ie11-polyfills' ),
    451451                        wp_get_theme()->get( 'Version' ),
    452                         true
     452                        array( 'in_footer' => true )
    453453                );
    454454        }
    … …  
    460460                array( 'twenty-twenty-one-ie11-polyfills' ),
    461461                wp_get_theme()->get( 'Version' ),
    462                 true
     462                array( 'in_footer' => true )
    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' ), array( 'in_footer' => true ) );
    477477}
    478478
    … …  
    566566                array(),
    567567                wp_get_theme()->get( 'Version' ),
    568                 true
     568                array( 'in_footer' => true )
    569569        );
    570570
    … …  
    574574                array( 'customize-preview', 'customize-selective-refresh', 'jquery', 'twentytwentyone-customize-helpers' ),
    575575                wp_get_theme()->get( 'Version' ),
    576                 true
     576                array( 'in_footer' => true )
    577577        );
    578578}
    … …  
    593593                array(),
    594594                wp_get_theme()->get( 'Version' ),
    595                 true
     595                array( 'in_footer' => true )
    596596        );
    597597}
Note: See TracChangeset for help on using the changeset viewer.