WP_Scripts
- Since
- 2.1.0
- Source
wp-includes/class-wp-scripts.php:18
Core class used to register scripts.
Compatibility
- WordPress
- since 2.1.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 5
Every hook that fires from inside WP_Scripts, in the order it appears in the class, grouped by the method that fires it.
WP_Scripts::init()
- do_action( wp_default_scripts )action line 166
WP_Scripts::do_item()
- apply_filters( script_loader_src )filter line 356
- apply_filters( script_loader_src )filter line 412
- apply_filters( script_loader_tag )filter line 441
WP_Scripts::all_deps()
- apply_filters( print_scripts_array )filter line 735
Properties · 14
$base_urlstringpublic- Base URL for scripts.
$content_urlstringpublic- URL of the content directory.
$default_versionstringpublic- Default version string for scripts.
$concatstringpublic- Holds a list of script handles which will be concatenated.
$concat_versionstringpublic- Holds a string which contains script handles and their version.
$do_concatboolpublic- Whether to perform concatenation.
$print_htmlstringpublic- Holds HTML markup of scripts and additional data if concatenation is enabled.
$print_codestringpublic- Holds inline code if concatenation is enabled.
$ext_handlesstringpublic- Holds a list of script handles which are not in the default directory if concatenation is enabled.
$ext_versionstringpublic- Holds a string which contains handles and versions of scripts which are not in the default directory if concatenation is enabled.
$default_dirsarraypublic- List of default directories.
$dependents_maparrayprivate- Holds a mapping of dependents (as handles) for a given script handle.
$delayed_strategiesstring[]private- Holds a reference to the delayed (non-blocking) script loading strategies.
Methods · 26
- __construct()Constructor.
- init()Initialize the class.
- print_scripts()Prints scripts.
- print_scripts_l10n()Prints extra scripts of a registered script.
- print_extra_script()Prints extra scripts of a registered script.
- are_all_dependents_in_footer()Checks whether all dependents of a given handle are in the footer.
- do_item()Processes a script dependency.
- add_inline_script()Adds extra code to a registered script.
- print_inline_script()Prints inline scripts registered for a specific handle.
- get_inline_script_data()Gets data for inline scripts registered for a specific handle.
- get_inline_script_tag()Gets tags for inline scripts registered for a specific handle.
- localize()Localizes a script, only if the script has already been added.
- set_group()Sets handle group.
- set_translations()Sets a translation textdomain.
- print_translations()Prints translations set for a specific handle.
- all_deps()Determines script dependencies.
- do_head_items()Processes items and dependencies for the head group.
- do_footer_items()Processes items and dependencies for the footer group.
- in_default_dir()Whether a handle's source is in a default directory.
- add_data()This overrides the add_data method from WP_Dependencies, to support normalizing of $args.
- get_dependents()Gets all dependents of a script.
- is_delayed_strategy()Checks if the strategy passed is a valid delayed (non-blocking) strategy.
- get_eligible_loading_strategy()Gets the best eligible loading strategy for a script.
- filter_eligible_strategies()Filter the list of eligible loading strategies for a script.
- has_inline_script()Gets data for inline scripts registered for a specific handle.
- reset()Resets class properties.
Source code
class WP_Scripts extends WP_Dependencies { /** * Base URL for scripts. * * Full URL with trailing slash. * * @since 2.6.0 * @var string */ public $base_url; /** * URL of the content directory. * * @since 2.8.0 * @var string */ public $content_url; /** * Default version string for scripts. * * @since 2.6.0 * @var string */ public $default_version; /** * Holds handles of scripts which are enqueued in footer. * * @since 2.8.0 * @var array */ public $in_footer = array(); /** * Holds a list of script handles which will be concatenated. * * @since 2.8.0 * @var string */ public $concat = ''; /** * Holds a string which contains script handles and their version. * * @since 2.8.0 * @deprecated 3.4.0 * @var string */ public $concat_version = ''; /** * Whether to perform concatenation. * * @since 2.8.0 * @var bool */ public $do_concat = false; /** * Holds HTML markup of scripts and additional data if concatenation * is enabled. * * @since 2.8.0 * @var string */ public $print_html = ''; /** * Holds inline code if concatenation is enabled. * * @since 2.8.0 * @var string */ public $print_code = ''; /** * Holds a list of script handles which are not in the default directory * if concatenation is enabled.Changelog
Introduced in 2.1.0. 3 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
6.9.7
Method
is_valid_fetchpriority() added.verified against source6.9.7
Method
get_highest_fetchpriority_with_dependents() added.verified against source6.9.7
Method
get_dependency_warning_message() added.verified against source2.1.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-includes/class-wp-scripts.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.