Docs: Document the usage of some globals in `wp-includes/script-loader.php`.

Follow-up to [44114], [44262], [49080], [50761], [51471].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@51942


git-svn-id: http://core.svn.wordpress.org/trunk@51531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-10-27 18:21:58 +00:00
parent 6a5a0062ff
commit 311cf99866
2 changed files with 24 additions and 7 deletions

View File

@ -39,11 +39,16 @@ require ABSPATH . WPINC . '/functions.wp-styles.php';
*
* @since 5.0.0
*
* @global string $tinymce_version
* @global bool $concatenate_scripts
* @global bool $compress_scripts
*
* @param WP_Scripts $scripts WP_Scripts object.
* @param bool $force_uncompressed Whether to forcibly prevent gzip compression. Default false.
*/
function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) {
global $tinymce_version, $concatenate_scripts, $compress_scripts;
$suffix = wp_scripts_get_suffix();
$dev_suffix = wp_scripts_get_suffix( 'dev' );
@ -72,6 +77,8 @@ function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) {
*
* @since 5.0.0
*
* @global WP_Locale $wp_locale WordPress date and time locale object.
*
* @param WP_Scripts $scripts WP_Scripts object.
*/
function wp_default_packages_vendor( $scripts ) {
@ -277,6 +284,8 @@ function wp_default_packages_scripts( $scripts ) {
*
* @since 5.0.0
*
* @global WP_Locale $wp_locale WordPress date and time locale object.
*
* @param WP_Scripts $scripts WP_Scripts object.
*/
function wp_default_packages_inline_scripts( $scripts ) {
@ -1379,9 +1388,13 @@ function wp_default_scripts( $scripts ) {
*
* @since 2.6.0
*
* @global array $editor_styles
*
* @param WP_Styles $styles
*/
function wp_default_styles( $styles ) {
global $editor_styles;
// Include an unmodified $wp_version.
require ABSPATH . WPINC . '/version.php';
@ -1534,7 +1547,6 @@ function wp_default_styles( $styles ) {
$wp_edit_blocks_dependencies[] = 'wp-editor-classic-layout-styles';
}
global $editor_styles;
if ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) {
// Include opinionated block styles if no $editor_styles are declared, so the editor never appears broken.
$wp_edit_blocks_dependencies[] = 'wp-block-library-theme';
@ -2032,16 +2044,17 @@ function _print_scripts() {
* @return array
*/
function wp_print_head_scripts() {
global $wp_scripts;
if ( ! did_action( 'wp_print_scripts' ) ) {
/** This action is documented in wp-includes/functions.wp-scripts.php */
do_action( 'wp_print_scripts' );
}
global $wp_scripts;
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
return array(); // No need to run if nothing is queued.
}
return print_head_scripts();
}
@ -2243,8 +2256,6 @@ function script_concat_settings() {
* the editor and the front-end.
*
* @since 5.0.0
*
* @global WP_Screen $current_screen WordPress current screen object.
*/
function wp_common_block_scripts_and_styles() {
if ( is_admin() && ! wp_should_load_block_editor_scripts_and_styles() ) {
@ -2333,6 +2344,8 @@ function wp_enqueue_global_styles() {
*
* @since 5.6.0
*
* @global WP_Screen $current_screen WordPress current screen object.
*
* @return bool Whether scripts and styles should be enqueued.
*/
function wp_should_load_block_editor_scripts_and_styles() {
@ -2436,8 +2449,12 @@ function wp_enqueue_registered_block_scripts_and_styles() {
* Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend.
*
* @since 5.3.0
*
* @global WP_Styles $wp_styles
*/
function enqueue_block_styles_assets() {
global $wp_styles;
$block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
foreach ( $block_styles as $block_name => $styles ) {
@ -2465,7 +2482,7 @@ function enqueue_block_styles_assets() {
// If the site loads separate styles per-block, check if the block has a stylesheet registered.
if ( wp_should_load_separate_core_block_assets() ) {
$block_stylesheet_handle = generate_block_asset_handle( $block_name, 'style' );
global $wp_styles;
if ( isset( $wp_styles->registered[ $block_stylesheet_handle ] ) ) {
$handle = $block_stylesheet_handle;
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-51941';
$wp_version = '5.9-alpha-51942';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.