[ Index ]

PHP Cross Reference of WordPress

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: 3529 lines (130 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 8 files
 wp-includes/class.wp-styles.php
 wp-includes/assets/script-loader-packages.php
 wp-includes/functions.wp-scripts.php
 wp-includes/class-wp-dependency.php
 wp-includes/version.php
 wp-includes/class.wp-scripts.php
 wp-includes/class.wp-dependencies.php
 wp-includes/functions.wp-styles.php

Defines 48 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_enqueue_global_styles()
  wp_global_styles_render_svg_filters()
  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_block_style()
  _wp_theme_json_webfonts_handler()

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.
since: 5.0.0

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.
since: 5.0.0

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: array      $tests   Features to detect.
since: 5.0.0

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

param: WP_Scripts $scripts WP_Scripts object.
since: 6.0.0

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.
since: 5.0.0

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

param: WP_Scripts $scripts WP_Scripts object.
since: 5.0.0

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.

since: 5.0.0

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

param: WP_Scripts $scripts WP_Scripts object.
since: 5.0.0

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.
since: 5.0.0

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.
since: 2.6.0

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
since: 2.6.0

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

return: array Reordered array, if needed.
param: array $js_array JavaScript scripts array
since: 2.3.1

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.

since: 2.5.0

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

since: 4.6.0

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

since: 4.8.0

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'.
since: 2.6.0

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
since: 2.8.0

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

return: array
since: 2.8.0

_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
since: 2.8.0

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

since: 3.3.0

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

since: 2.8.0

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.

since: 2.8.0

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

return: array
since: 2.8.0

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

return: array|void
since: 3.3.0

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

since: 3.3.0

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

since: 2.8.0

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.

since: 5.0.0

wp_enqueue_global_styles()   X-Ref
Enqueues the global styles defined via theme.json.

since: 5.8.0

wp_global_styles_render_svg_filters()   X-Ref
Renders the SVG filters supplied by theme.json.

Note that this doesn't render the per-block user-defined
filters which are handled by wp_render_duotone_support,
but it should be rendered before the filtered content
in the body to satisfy Safari's rendering quirks.

since: 5.9.1

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.
since: 5.6.0

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.
since: 5.8.0

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).

since: 5.0.0

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

since: 5.3.0

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.

since: 5.5.0

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

since: 5.8.0

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.
since: 5.7.0

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.
since: 5.7.0

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.
since: 5.7.0

wp_get_inline_script_tag( $javascript, $attributes = array()   X-Ref
Wraps inline JavaScript in `<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 $javascript Inline JavaScript code.
param: array  $attributes Optional. Key-value pairs representing `<script>` tag attributes.
since: 5.7.0

wp_print_inline_script_tag( $javascript, $attributes = array()   X-Ref
Prints inline JavaScript wrapped in `<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 $javascript Inline JavaScript code.
param: array  $attributes Optional. Key-value pairs representing `<script>` tag attributes.
since: 5.7.0

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 );

since: 5.8.0

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

wp_enqueue_global_styles_css_custom_properties()   X-Ref
Function that enqueues the CSS Custom Properties coming from theme.json.

since: 5.9.0

wp_enqueue_block_support_styles( $style )   X-Ref
This function takes care of adding inline styles
in the proper place, depending on the theme in use.

param: string $style String containing the CSS styles to be added.
since: 5.9.1

wp_enqueue_block_style( $block_name, $args )   X-Ref
No description

_wp_theme_json_webfonts_handler()   X-Ref
Runs the theme.json webfonts handler.

Using `WP_Theme_JSON_Resolver`, it gets the fonts defined
in the `theme.json` for the current selection and style
variations, validates the font-face properties, generates
the '@font-face' style declarations, and then enqueues the
styles for both the editor and front-end.

Design Notes:
This is not a public API, but rather an internal handler.
A future public Webfonts API will replace this stopgap code.

This code design is intentional.
a. It hides the inner-workings.
b. It does not expose API ins or outs for consumption.
c. It only works with a theme's `theme.json`.

Why?
a. To avoid backwards-compatibility issues when
the Webfonts API is introduced in Core.
b. To make `fontFace` declarations in `theme.json` work.

since: 6.0.0



Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1