[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> script-loader.php (summary)

WordPress scripts and styles default loader. Several constants are used to manage the loading, concatenating and compression of scripts and CSS: define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation, define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS, define('COMPRESS_SCRIPTS', false); disables compression of scripts, define('COMPRESS_CSS', false); disables compression of CSS, define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).

File Size: 3406 lines (130 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 8 files
 wp-includes/functions.wp-scripts.php
 wp-includes/class-wp-scripts.php
 wp-includes/functions.wp-styles.php
 wp-includes/class-wp-dependencies.php
 wp-includes/class-wp-dependency.php
 wp-includes/version.php
 wp-admin/includes/class-wp-community-events.php
 wp-includes/class-wp-styles.php

Defines 52 functions

  wp_register_tinymce_scripts()
  wp_default_packages_vendor()
  wp_get_script_polyfill()
  wp_register_development_scripts()
  wp_default_packages_scripts()
  wp_default_packages_inline_scripts()
  wp_tinymce_inline_scripts()
  wp_default_packages()
  wp_scripts_get_suffix()
  wp_default_scripts()
  wp_default_styles()
  wp_prototype_before_jquery()
  wp_just_in_time_script_localization()
  wp_localize_jquery_ui_datepicker()
  wp_localize_community_events()
  wp_style_loader_src()
  print_head_scripts()
  print_footer_scripts()
  _print_scripts()
  wp_print_head_scripts()
  _wp_footer_scripts()
  wp_print_footer_scripts()
  wp_enqueue_scripts()
  print_admin_styles()
  print_late_styles()
  _print_styles()
  script_concat_settings()
  wp_common_block_scripts_and_styles()
  wp_filter_out_block_nodes()
  wp_enqueue_global_styles()
  wp_enqueue_global_styles_custom_css()
  wp_should_load_block_editor_scripts_and_styles()
  wp_should_load_separate_core_block_assets()
  wp_enqueue_registered_block_scripts_and_styles()
  enqueue_block_styles_assets()
  enqueue_editor_block_styles_assets()
  wp_enqueue_editor_block_directory_assets()
  wp_enqueue_editor_format_library_assets()
  wp_sanitize_script_attributes()
  wp_get_script_tag()
  wp_print_script_tag()
  wp_get_inline_script_tag()
  wp_print_inline_script_tag()
  wp_maybe_inline_styles()
  _wp_normalize_relative_css_links()
  wp_enqueue_global_styles_css_custom_properties()
  wp_enqueue_block_support_styles()
  wp_enqueue_stored_styles()
  wp_enqueue_block_style()
  wp_enqueue_classic_theme_styles()
  wp_add_editor_classic_theme_styles()
  wp_remove_surrounding_empty_script_tags()

Functions
Functions that are not part of a class:

wp_register_tinymce_scripts( $scripts, $force_uncompressed = false )   X-Ref
Registers TinyMCE scripts.

param: WP_Scripts $scripts            WP_Scripts object.
param: bool       $force_uncompressed Whether to forcibly prevent gzip compression. Default false.

wp_default_packages_vendor( $scripts )   X-Ref
Registers all the WordPress vendor scripts that are in the standardized
`js/dist/vendor/` location.

For the order of `$scripts->add` see `wp_default_scripts`.

param: WP_Scripts $scripts WP_Scripts object.

wp_get_script_polyfill( $scripts, $tests )   X-Ref
Returns contents of an inline script used in appending polyfill scripts for
browsers which fail the provided tests. The provided array is a mapping from
a condition to verify feature support to its polyfill script handle.

return: string Conditional polyfill inline script.
param: WP_Scripts $scripts WP_Scripts object.
param: string[]   $tests   Features to detect.

wp_register_development_scripts( $scripts )   X-Ref
Registers development scripts that integrate with `@wordpress/scripts`.

param: WP_Scripts $scripts WP_Scripts object.

wp_default_packages_scripts( $scripts )   X-Ref
Registers all the WordPress packages scripts that are in the standardized
`js/dist/` location.

For the order of `$scripts->add` see `wp_default_scripts`.

param: WP_Scripts $scripts WP_Scripts object.

wp_default_packages_inline_scripts( $scripts )   X-Ref
Adds inline scripts required for the WordPress JavaScript packages.

param: WP_Scripts $scripts WP_Scripts object.

wp_tinymce_inline_scripts()   X-Ref
Adds inline scripts required for the TinyMCE in the block editor.

These TinyMCE init settings are used to extend and override the default settings
from `_WP_Editors::default_settings()` for the Classic block.


wp_default_packages( $scripts )   X-Ref
Registers all the WordPress packages scripts.

param: WP_Scripts $scripts WP_Scripts object.

wp_scripts_get_suffix( $type = '' )   X-Ref
Returns the suffix that can be used for the scripts.

There are two suffix types, the normal one and the dev suffix.

return: string The script suffix.
param: string $type The type of suffix to retrieve.

wp_default_scripts( $scripts )   X-Ref
Registers all WordPress scripts.

Localizes some of them.
args order: `$scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );`
when last arg === 1 queues the script for the footer

param: WP_Scripts $scripts WP_Scripts object.

wp_default_styles( $styles )   X-Ref
Assigns default styles to $styles object.

Nothing is returned, because the $styles parameter is passed by reference.
Meaning that whatever object is passed will be updated without having to
reassign the variable that was passed back to the same value. This saves
memory.

Adding default styles is not the only task, it also assigns the base_url
property, the default version, and text direction for the object.

param: WP_Styles $styles

wp_prototype_before_jquery( $js_array )   X-Ref
Reorders JavaScript scripts array to place prototype before jQuery.

return: string[] Reordered array, if needed.
param: string[] $js_array JavaScript scripts array

wp_just_in_time_script_localization()   X-Ref
Loads localized data on print rather than initialization.

These localizations require information that may not be loaded even by init.


wp_localize_jquery_ui_datepicker()   X-Ref
Localizes the jQuery UI datepicker.


wp_localize_community_events()   X-Ref
Localizes community events data that needs to be passed to dashboard.js.


wp_style_loader_src( $src, $handle )   X-Ref
Administration Screen CSS for changing the styles.

If installing the 'wp-admin/' directory will be replaced with './'.

The $_wp_admin_css_colors global manages the Administration Screens CSS
stylesheet that is loaded. The option that is set is 'admin_color' and is the
color and key for the array. The value for the color key is an object with
a 'url' parameter that has the URL path to the CSS file.

The query from $src parameter will be appended to the URL that is given from
the $_wp_admin_css_colors array value URL.

return: string|false URL path to CSS stylesheet for Administration Screens.
param: string $src    Source URL.
param: string $handle Either 'colors' or 'colors-rtl'.

print_head_scripts()   X-Ref
Prints the script queue in the HTML head on admin pages.

Postpones the scripts that were queued for the footer.
print_footer_scripts() is called in the footer to print these scripts.

return: array

print_footer_scripts()   X-Ref
Prints the scripts that were queued for the footer or too late for the HTML head.

return: array

_print_scripts()   X-Ref
Prints scripts (internal use only)


wp_print_head_scripts()   X-Ref
Prints the script queue in the HTML head on the front end.

Postpones the scripts that were queued for the footer.
wp_print_footer_scripts() is called in the footer to print these scripts.

return: array

_wp_footer_scripts()   X-Ref
Private, for use in *_footer_scripts hooks


wp_print_footer_scripts()   X-Ref
Hooks to print the scripts and styles in the footer.


wp_enqueue_scripts()   X-Ref
Wrapper for do_action( 'wp_enqueue_scripts' ).

Allows plugins to queue scripts for the front end using wp_enqueue_script().
Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.


print_admin_styles()   X-Ref
Prints the styles queue in the HTML head on admin pages.

return: array

print_late_styles()   X-Ref
Prints the styles that were queued too late for the HTML head.

return: array|void

_print_styles()   X-Ref
Prints styles (internal use only).


script_concat_settings()   X-Ref
Determines the concatenation and compression settings for scripts and styles.


wp_common_block_scripts_and_styles()   X-Ref
Handles the enqueueing of block scripts and styles that are common to both
the editor and the front-end.


wp_filter_out_block_nodes( $nodes )   X-Ref
Applies a filter to the list of style nodes that comes from WP_Theme_JSON::get_style_nodes().

This particular filter removes all of the blocks from the array.

We want WP_Theme_JSON to be ignorant of the implementation details of how the CSS is being used.
This filter allows us to modify the output of WP_Theme_JSON depending on whether or not we are
loading separate assets, without making the class aware of that detail.

return: array A filtered array of style nodes.
param: array $nodes The nodes to filter.

wp_enqueue_global_styles()   X-Ref
No description

wp_enqueue_global_styles_custom_css()   X-Ref
Enqueues the global styles custom css defined via theme.json.


wp_should_load_block_editor_scripts_and_styles()   X-Ref
Checks if the editor scripts and styles for all registered block types
should be enqueued on the current screen.

return: bool Whether scripts and styles should be enqueued.

wp_should_load_separate_core_block_assets()   X-Ref
Checks whether separate styles should be loaded for core blocks on-render.

When this function returns true, other functions ensure that core blocks
only load their assets on-render, and each block loads its own, individual
assets. Third-party blocks only load their assets when rendered.

When this function returns false, all core block assets are loaded regardless
of whether they are rendered in a page or not, because they are all part of
the `block-library/style.css` file. Assets for third-party blocks are always
enqueued regardless of whether they are rendered or not.

This only affects front end and not the block editor screens.

return: bool Whether separate assets will be loaded.

wp_enqueue_registered_block_scripts_and_styles()   X-Ref
Enqueues registered block scripts and styles, depending on current rendered
context (only enqueuing editor scripts while in context of the editor).


enqueue_block_styles_assets()   X-Ref
Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend.


enqueue_editor_block_styles_assets()   X-Ref
No description

wp_enqueue_editor_block_directory_assets()   X-Ref
Enqueues the assets required for the block directory within the block editor.


wp_enqueue_editor_format_library_assets()   X-Ref
Enqueues the assets required for the format library within the block editor.


wp_sanitize_script_attributes( $attributes )   X-Ref
Sanitizes an attributes array into an attributes string to be placed inside a `<script>` tag.

Automatically injects type attribute if needed.
Used by {@see wp_get_script_tag()} and {@see wp_get_inline_script_tag()}.

return: string String made of sanitized `<script>` tag attributes.
param: array $attributes Key-value pairs representing `<script>` tag attributes.

wp_get_script_tag( $attributes )   X-Ref
Formats `<script>` loader tags.

It is possible to inject attributes in the `<script>` tag via the {@see 'wp_script_attributes'} filter.
Automatically injects type attribute if needed.

return: string String containing `<script>` opening and closing tags.
param: array $attributes Key-value pairs representing `<script>` tag attributes.

wp_print_script_tag( $attributes )   X-Ref
Prints formatted `<script>` loader tag.

It is possible to inject attributes in the `<script>` tag via the  {@see 'wp_script_attributes'}  filter.
Automatically injects type attribute if needed.

param: array $attributes Key-value pairs representing `<script>` tag attributes.

wp_get_inline_script_tag( $data, $attributes = array()   X-Ref
Constructs an inline script tag.

It is possible to inject attributes in the `<script>` tag via the  {@see 'wp_script_attributes'}  filter.
Automatically injects type attribute if needed.

return: string String containing inline JavaScript code wrapped around `<script>` tag.
param: string $data       Data for script tag: JavaScript, importmap, speculationrules, etc.
param: array  $attributes Optional. Key-value pairs representing `<script>` tag attributes.

wp_print_inline_script_tag( $data, $attributes = array()   X-Ref
Prints an inline script tag.

It is possible to inject attributes in the `<script>` tag via the  {@see 'wp_script_attributes'}  filter.
Automatically injects type attribute if needed.

param: string $data       Data for script tag: JavaScript, importmap, speculationrules, etc.
param: array  $attributes Optional. Key-value pairs representing `<script>` tag attributes.

wp_maybe_inline_styles()   X-Ref
Allows small styles to be inlined.

This improves performance and sustainability, and is opt-in. Stylesheets can opt in
by adding `path` data using `wp_style_add_data`, and defining the file's absolute path:

wp_style_add_data( $style_handle, 'path', $file_path );


_wp_normalize_relative_css_links( $css, $stylesheet_url )   X-Ref
No description

wp_enqueue_global_styles_css_custom_properties()   X-Ref
No description

wp_enqueue_block_support_styles( $style, $priority = 10 )   X-Ref
Hooks inline styles in the proper place, depending on the active theme.

param: string $style    String containing the CSS styles to be added.
param: int    $priority To set the priority for the add_action.

wp_enqueue_stored_styles( $options = array()   X-Ref
No description

wp_enqueue_block_style( $block_name, $args )   X-Ref
Enqueues a stylesheet for a specific block.

If the theme has opted-in to separate-styles loading,
then the stylesheet will be enqueued on-render,
otherwise when the block inits.

param: string $block_name The block-name, including namespace.
param: array  $args       {

wp_enqueue_classic_theme_styles()   X-Ref
Loads classic theme styles on classic themes in the frontend.

This is needed for backwards compatibility for button blocks specifically.


wp_add_editor_classic_theme_styles( $editor_settings )   X-Ref
Loads classic theme styles on classic themes in the editor.

This is needed for backwards compatibility for button blocks specifically.

return: array A filtered array of editor settings.
param: array $editor_settings The array of editor settings.

wp_remove_surrounding_empty_script_tags( $contents )   X-Ref
Removes leading and trailing _empty_ script tags.

This is a helper meant to be used for literal script tag construction
within `wp_get_inline_script_tag()` or `wp_print_inline_script_tag()`.
It removes the literal values of "<script>" and "</script>" from
around an inline script after trimming whitespace. Typically this
is used in conjunction with output buffering, where `ob_get_clean()`
is passed as the `$contents` argument.

Example:

// Strips exact literal empty SCRIPT tags.
$js = '<script>sayHello();</script>;
'sayHello();' === wp_remove_surrounding_empty_script_tags( $js );

// Otherwise if anything is different it warns in the JS console.
$js = '<script type="text/javascript">console.log( "hi" );</script>';
'console.error( ... )' === wp_remove_surrounding_empty_script_tags( $js );

return: string Script body without surrounding script tag literals, or
param: string $contents Script body with manually created SCRIPT tag literals.



Generated : Fri Apr 26 08:20:02 2024 Cross-referenced by PHPXref