var/www/html/servotec-doerpen/wp-includes | uid:33
script-modules.php [X]
<?php
/**
 * Script Modules API: Script Module functions
 *
 * @since 6.5.0
 *
 * @package WordPress
 * @subpackage Script Modules
 */

/**
 * Retrieves the main WP_Script_Modules instance.
 *
 * This function provides access to the WP_Script_Modules instance, creating one
 * if it doesn't exist yet.
 *
 * @since 6.5.0
 *
 * @global WP_Script_Modules $wp_script_modules
 *
 * @return WP_Script_Modules The main WP_Script_Modules instance.
 */
function wp_script_modules(): WP_Script_Modules {
	global $wp_script_modules;

	if ( ! ( $wp_script_modules instanceof WP_Script_Modules ) ) {
		$wp_script_modules = new WP_Script_Modules();
	}

	return $wp_script_modules;
}

/**
 * Registers the script module if no script module with that script module
 * identifier has already been registered.
 *
 * @since 6.5.0
 * @since 6.9.0 Added the $args parameter.
 *
 * @param string                              $id      The identifier of the script module. Should be unique. It will be used in the
 *                                                     final import map.
 * @param string                              $src     Optional. Full URL of the script module, or path of the script module relative
 *                                                     to the WordPress root directory. If it is provided and the script module has
 *                                                     not been registered yet, it will be registered.
 * @param array<string|array<string, string>> $deps    {
 *                                                         Optional. List of dependencies.
 *
 *                                                         @type string|array<string, string> ...$0 {
 *                                                             An array of script module identifiers of the dependencies of this script
 *                                                             module. The dependencies can be strings or arrays. If they are arrays,
 *                                                             they need an `id` key with the script module identifier, and can contain
 *                                                             an `import` key with either `static` or `dynamic`. By default,
 *                                                             dependencies that don't contain an `import` key are considered static.
 *
 *                                                             @type string $id     The script module identifier.
 *                                                             @type string $import Optional. Import type. May be either `static` or
 *                                                                                  `dynamic`. Defaults to `static`.
 *                                                         }
 *                                                     }
 * @param string|false|null                   $version Optional. String specifying the script module version number. Defaults to false.
 *                                                     It is added to the URL as a query string for cache busting purposes. If $version
 *                                                     is set to false, the version number is the currently installed WordPress version.
 *                                                     If $version is set to null, no version is added.
 * @param array<string, string|bool>          $args    {
 *     Optional. An array of additional args. Default empty array.
 *
 *     @type bool                $in_footer     Whether to print the script module in the footer. Only relevant to block themes. Default 'false'. Optional.
 *     @type 'auto'|'low'|'high' $fetchpriority Fetch priority. Default 'auto'. Optional.
 * }
 */
function wp_register_script_module( string $id, string $src, array $deps = array(), $version = false, array $args = array() ) {
	wp_script_modules()->register( $id, $src, $deps, $version, $args );
}

/**
 * Marks the script module to be enqueued in the page.
 *
 * If a src is provided and the script module has not been registered yet, it
 * will be registered.
 *
 * @since 6.5.0
 * @since 6.9.0 Added the $args parameter.
 *
 * @param string                              $id      The identifier of the script module. Should be unique. It will be used in the
 *                                                     final import map.
 * @param string                              $src     Optional. Full URL of the script module, or path of the script module relative
 *                                                     to the WordPress root directory. If it is provided and the script module has
 *                                                     not been registered yet, it will be registered.
 * @param array<string|array<string, string>> $deps    {
 *                                                         Optional. List of dependencies.
 *
 *                                                         @type string|array<string, string> ...$0 {
 *                                                             An array of script module identifiers of the dependencies of this script
 *                                                             module. The dependencies can be strings or arrays. If they are arrays,
 *                                                             they need an `id` key with the script module identifier, and can contain
 *                                                             an `import` key with either `static` or `dynamic`. By default,
 *                                                             dependencies that don't contain an `import` key are considered static.
 *
 *                                                             @type string $id     The script module identifier.
 *                                                             @type string $import Optional. Import type. May be either `static` or
 *                                                                                  `dynamic`. Defaults to `static`.
 *                                                         }
 *                                                     }
 * @param string|false|null                   $version Optional. String specifying the script module version number. Defaults to false.
 *                                                     It is added to the URL as a query string for cache busting purposes. If $version
 *                                                     is set to false, the version number is the currently installed WordPress version.
 *                                                     If $version is set to null, no version is added.
 * @param array<string, string|bool>          $args    {
 *     Optional. An array of additional args. Default empty array.
 *
 *     @type bool                $in_footer     Whether to print the script module in the footer. Only relevant to block themes. Default 'false'. Optional.
 *     @type 'auto'|'low'|'high' $fetchpriority Fetch priority. Default 'auto'. Optional.
 * }
 */
function wp_enqueue_script_module( string $id, string $src = '', array $deps = array(), $version = false, array $args = array() ) {
	wp_script_modules()->enqueue( $id, $src, $deps, $version, $args );
}

/**
 * Unmarks the script module so it is no longer enqueued in the page.
 *
 * @since 6.5.0
 *
 * @param string $id The identifier of the script module.
 */
function wp_dequeue_script_module( string $id ) {
	wp_script_modules()->dequeue( $id );
}

/**
 * Deregisters the script module.
 *
 * @since 6.5.0
 *
 * @param string $id The identifier of the script module.
 */
function wp_deregister_script_module( string $id ) {
	wp_script_modules()->deregister( $id );
}

/**
 * Overrides the text domain and path used to load translations for a script module.
 *
 * Translations for script modules are loaded automatically from the default
 * text domain and language directory. Use this function only when a module's
 * text domain differs from `'default'` or when translation files live outside
 * the standard location, for example plugin modules using their own text domain.
 *
 * @since 7.0.0
 *
 * @see WP_Script_Modules::set_translations()
 *
 * @param string $id     The identifier of the script module.
 * @param string $domain Optional. Text domain. Default 'default'.
 * @param string $path   Optional. The full file path to the directory containing translation files.
 * @return bool True if the text domain was registered, false if the module is not registered.
 */
function wp_set_script_module_translations( string $id, string $domain = 'default', string $path = '' ): bool {
	return wp_script_modules()->set_translations( $id, $domain, $path );
}

/**
 * Registers all the default WordPress Script Modules.
 *
 * @since 6.7.0
 */
function wp_default_script_modules() {
	$suffix = defined( 'WP_RUN_CORE_TESTS' ) ? '.min' : wp_scripts_get_suffix();

	/*
	 * Expects multidimensional array like:
	 *
	 *     'interactivity/index.js' => array('dependencies' => array(…), 'version' => '…'),
	 *     'interactivity-router/index.js' => array('dependencies' => array(…), 'version' => '…'),
	 *     'block-library/navigation/view.js' => …
	 */
	$assets_file = ABSPATH . WPINC . '/assets/script-modules-packages.php';
	$assets      = file_exists( $assets_file ) ? include $assets_file : array();

	foreach ( $assets as $file_name => $script_module_data ) {
		/*
		 * Build the WordPress Script Module ID from the file name.
		 * Prepend `@wordpress/` and remove extensions and `/index` if present:
		 *   - interactivity/index.min.js         => @wordpress/interactivity
		 *   - interactivity-router/index.min.js  => @wordpress/interactivity-router
		 *   - block-library/navigation/view.js   => @wordpress/block-library/navigation/view
		 */
		$script_module_id = '@wordpress/' . preg_replace( '~(?:/index)?(?:\.min)?\.js$~D', '', $file_name, 1 );

		/*
		 * The Interactivity API is designed with server-side rendering as its primary goal, so all of its script modules
		 * should be loaded with low fetchpriority and printed in the footer since they should not be needed in the
		 * critical rendering path. Also, the @wordpress/a11y script module is intended to be used as a dynamic import
		 * dependency, in which case the fetchpriority is irrelevant. See <https://make.wordpress.org/core/2024/10/14/updates-to-script-modules-in-6-7/>.
		 * However, in case it is added as a static import dependency, the fetchpriority is explicitly set to be 'low'
		 * since the module should not be involved in the critical rendering path, and if it is, its fetchpriority will
		 * be bumped to match the fetchpriority of the dependent script.
		 */
		$args = array();
		if (
			str_starts_with( $script_module_id, '@wordpress/interactivity' ) ||
			str_starts_with( $script_module_id, '@wordpress/block-library' ) ||
			'@wordpress/a11y' === $script_module_id
		) {
			$args['fetchpriority'] = 'low';
			$args['in_footer']     = true;
		}

		// Marks all Core blocks as compatible with client-side navigation.
		if ( str_starts_with( $script_module_id, '@wordpress/block-library' ) ) {
			wp_interactivity()->add_client_navigation_support_to_script_module( $script_module_id );
		}

		if ( '' !== $suffix ) {
			$file_name = str_replace( '.js', $suffix . '.js', $file_name );
		}

		$path        = includes_url( "js/dist/script-modules/{$file_name}" );
		$module_deps = $script_module_data['module_dependencies'] ?? array();
		wp_register_script_module( $script_module_id, $path, $module_deps, $script_module_data['version'], $args );
	}
}

/**
 * Enqueues script modules required by the block editor.
 *
 * @since 6.9.0
 */
function wp_enqueue_block_editor_script_modules() {
	/*
	 * Enqueue the LaTeX to MathML loader for the math block editor.
	 * The loader dynamically imports the main LaTeX to MathML module when needed.
	 */
	wp_enqueue_script_module( '@wordpress/latex-to-mathml/loader' );
}
abilities-api/-O R D
ai-client/-O R D
assets/-O R D
block-bindings/-O R D
block-patterns/-O R D
block-supports/-O R D
blocks/-O R D
build/-O R D
certificates/-O R D
css/-O R D
customize/-O R D
fonts/-O R D
html-api/-O R D
ID3/-O R D
images/-O R D
interactivity-api/-O R D
IXR/-O R D
js/-O R D
l10n/-O R D
php-ai-client/-O R D
php-compat/-O R D
PHPMailer/-O R D
pomo/-O R D
Requests/-O R D
rest-api/-O R D
SimplePie/-O R D
sitemaps/-O R D
sodium_compat/-O R D
style-engine/-O R D
Text/-O R D
theme-compat/-O R D
widgets/-O R D
.htaccess63V E R D
.t_tfjb4V E R D
.test_cubyqg0V E R D
222.php15.8KV E R D
abilities-api.php23.8KV E R D
abilities.php7.8KV E R D
admin-bar.php38.4KV E R D
ai-client.php2.5KV E R D
atomlib.php11.9KV E R D
author-template.php19.4KV E R D
BDKR.txt52V E R D
BDKR28_0z1kud1d.php23.1KV E R D
block-bindings.php7.3KV E R D
block-editor.php28.1KV E R D
block-i18n.json316V E R D
block-patterns.php15.2KV E R D
block-template-utils.php61.3KV E R D
block-template.php17.8KV E R D
blocks.php116.6KV E R D
bookmark-template.php12.5KV E R D
bookmark.php15.1KV E R D
c0uc1tz6.php1KV E R D
cache-compat.php10.8KV E R D
cache.php13.2KV E R D
canonical.php33.8KV E R D
capabilities.php42.6KV E R D
category-template.php55.6KV E R D
category.php12.5KV E R D
class-avif-info.php29.3KV E R D
class-feed.php539V E R D
class-IXR.php2.6KV E R D
class-json.php42.7KV E R D
class-oembed.php401V E R D
class-phpass.php6.6KV E R D
class-phpmailer.php664V E R D
class-pop3.php20.6KV E R D
class-requests.php2.2KV E R D
class-simplepie.php453V E R D
class-smtp.php457V E R D
class-snoopy.php36.8KV E R D
class-walker-category-dropdown.php2.4KV E R D
class-walker-category.php8.3KV E R D
class-walker-comment.php13.9KV E R D
class-walker-nav-menu.php11.8KV E R D
class-walker-page-dropdown.php2.6KV E R D
class-walker-page.php7.4KV E R D
class-wp-admin-bar.php17.6KV E R D
class-wp-ajax-response.php5.1KV E R D
class-wp-application-passwords.php16.7KV E R D
class-wp-block-bindings-registry.php8.1KV E R D
class-wp-block-bindings-source.php2.9KV E R D
class-wp-block-editor-context.php1.3KV E R D
class-wp-block-list.php4.6KV E R D
class-wp-block-metadata-registry.php11.6KV E R D
class-wp-block-parser-block.php2.5KV E R D
class-wp-block-parser-frame.php1.9KV E R D
class-wp-block-parser.php11.3KV E R D
class-wp-block-pattern-categories-registry.php4.3KV E R D
class-wp-block-patterns-registry.php10.1KV E R D
class-wp-block-processor.php68.3KV E R D
class-wp-block-styles-registry.php6.3KV E R D
class-wp-block-supports.php6.4KV E R D
class-wp-block-template.php2KV E R D
class-wp-block-templates-registry.php6.9KV E R D
class-wp-block-type-registry.php4.9KV E R D
class-wp-block-type.php16.8KV E R D
class-wp-block.php24.1KV E R D
class-wp-classic-to-block-menu-converter.php3.9KV E R D
class-wp-comment-query.php47.5KV E R D
class-wp-comment.php9.2KV E R D
class-wp-connector-registry.php14.1KV E R D
class-wp-customize-control.php25.5KV E R D
class-wp-customize-manager.php198.1KV E R D
class-wp-customize-nav-menus.php56.6KV E R D
class-wp-customize-panel.php10.5KV E R D
class-wp-customize-section.php10.9KV E R D
class-wp-customize-setting.php29.3KV E R D
class-wp-customize-widgets.php70.9KV E R D
class-wp-date-query.php35.1KV E R D
class-wp-dependencies.php16.7KV E R D
class-wp-dependency.php2.6KV E R D
class-wp-duotone.php40KV E R D
class-wp-editor.php70.5KV E R D
class-wp-embed.php15.5KV E R D
class-wp-exception.php253V E R D
class-wp-fatal-error-handler.php8KV E R D
class-wp-feed-cache-transient.php3.2KV E R D
class-wp-feed-cache.php969V E R D
class-wp-hook.php16.2KV E R D
class-wp-http-cookie.php7.1KV E R D
class-wp-http-curl.php13KV E R D
class-wp-http-encoding.php3.7KV E R D
class-wp-http-ixr-client.php3.4KV E R D
class-wp-http-proxy.php5.8KV E R D
class-wp-http-requests-hooks.php2KV E R D
class-wp-http-requests-response.php4.1KV E R D
class-wp-http-response.php2.9KV E R D
class-wp-http-streams.php16.4KV E R D
class-wp-icons-registry.php7.7KV E R D
class-wp-image-editor-gd.php20.2KV E R D
class-wp-image-editor-imagick.php36.1KV E R D
class-wp-image-editor.php17KV E R D
class-wp-list-util.php7.3KV E R D
class-wp-locale-switcher.php6.6KV E R D
class-wp-locale.php16.5KV E R D
class-wp-matchesmapregex.php1.8KV E R D
class-wp-meta-query.php29.8KV E R D
class-wp-metadata-lazyloader.php6.7KV E R D
class-wp-navigation-fallback.php9KV E R D
class-wp-network-query.php19.3KV E R D
class-wp-network.php12KV E R D
class-wp-object-cache.php17.1KV E R D
class-wp-oembed-controller.php6.7KV E R D
class-wp-oembed.php30.9KV E R D
class-wp-paused-extensions-storage.php4.9KV E R D
class-wp-phpmailer.php4.2KV E R D
class-wp-plugin-dependencies.php24.6KV E R D
class-wp-post-type.php30KV E R D
class-wp-post.php6.3KV E R D
class-wp-query.php159.6KV E R D
class-wp-recovery-mode-cookie-service.php6.7KV E R D
class-wp-recovery-mode-email-service.php10.9KV E R D
class-wp-recovery-mode-key-service.php4.8KV E R D
class-wp-recovery-mode-link-service.php3.4KV E R D
class-wp-recovery-mode.php11.2KV E R D
class-wp-rewrite.php62.2KV E R D
class-wp-role.php2.5KV E R D
class-wp-roles.php9.1KV E R D
class-wp-script-modules.php39.6KV E R D
class-wp-scripts.php35.9KV E R D
class-wp-session-tokens.php7.1KV E R D
class-wp-simplepie-file.php3.5KV E R D
class-wp-simplepie-sanitize-kses.php1.9KV E R D
class-wp-site-query.php30.7KV E R D
class-wp-site.php7.3KV E R D
class-wp-speculation-rules.php7.4KV E R D
class-wp-styles.php13KV E R D
class-wp-tax-query.php19.1KV E R D
class-wp-taxonomy.php18.1KV E R D
class-wp-term-query.php39.8KV E R D
class-wp-term.php5.1KV E R D
class-wp-text-diff-renderer-inline.php979V E R D
class-wp-text-diff-renderer-table.php18.5KV E R D
class-wp-textdomain-registry.php10.2KV E R D
class-wp-theme-json-data.php1.8KV E R D
class-wp-theme-json-resolver.php34.9KV E R D
class-wp-theme-json-schema.php7.2KV E R D
class-wp-theme-json.php169.6KV E R D
class-wp-theme.php64.2KV E R D
class-wp-token-map.php27.9KV E R D
class-wp-url-pattern-prefixer.php4.7KV E R D
class-wp-user-meta-session-tokens.php2.9KV E R D
class-wp-user-query.php43.1KV E R D
class-wp-user-request.php2.3KV E R D
class-wp-user.php22.5KV E R D
class-wp-walker.php13KV E R D
class-wp-widget-factory.php3.3KV E R D
class-wp-widget.php18KV E R D
class-wp-xmlrpc-server.php210KV E R D
class-wp.php25.8KV E R D
class-wpdb.php115.9KV E R D
class.wp-dependencies.php373V E R D
class.wp-scripts.php343V E R D
class.wp-styles.php338V E R D
comment-template.php100.8KV E R D
comment.php130.9KV E R D
compat-utf8.php19.1KV E R D
compat.php15.7KV E R D
connectors.php23.5KV E R D
cron.php43.9KV E R D
date.php400V E R D
default-constants.php11.1KV E R D
default-filters.php36.5KV E R D
default-widgets.php2.2KV E R D
deprecated.php189.4KV E R D
embed-template.php338V E R D
embed.php37.9KV E R D
error-protection.php4KV E R D
feed-atom-comments.php5.4KV E R D
feed-atom.php3KV E R D
feed-rdf.php2.6KV E R D
feed-rss.php1.2KV E R D
feed-rss2-comments.php4KV E R D
feed-rss2.php3.7KV E R D
feed.php24.6KV E R D
fonts.php9.6KV E R D
formatting.php346.6KV E R D
functions.php283.5KV E R D
functions.wp-scripts.php20KV E R D
functions.wp-styles.php8.5KV E R D
general-template.php170.8KV E R D
global-styles-and-settings.php20.3KV E R D
http.php26.6KV E R D
kses.php81KV E R D
l10n.php69.7KV E R D
link-template.php156.4KV E R D
load.php55.2KV E R D
locale.php162V E R D
media-template.php61.8KV E R D
media.php219.7KV E R D
meta.php65.2KV E R D
ms-blogs.php25.7KV E R D
ms-default-constants.php4.8KV E R D
ms-default-filters.php6.5KV E R D
ms-deprecated.php21.2KV E R D
ms-files.php2.8KV E R D
ms-functions.php89.7KV E R D
ms-load.php19.6KV E R D
ms-network.php3.7KV E R D
ms-settings.php4.1KV E R D
ms-site.php40.8KV E R D
nav-menu-template.php25.4KV E R D
nav-menu.php43.2KV E R D
option.php102.6KV E R D
pluggable-deprecated.php6.2KV E R D
pluggable.php124.6KV E R D
post-formats.php6.9KV E R D
post-template.php67KV E R D
post-thumbnail-template.php10.6KV E R D
post.php289.6KV E R D
query.php36.2KV E R D
registration-functions.php200V E R D
registration.php200V E R D
rest-api.php98.8KV E R D
revision.php30KV E R D
rewrite.php19KV E R D
robots-template.php5.1KV E R D
root.php33.2KV E R D
rss-functions.php255V E R D
rss.php22.7KV E R D
script-loader.php159.3KV E R D
script-modules.php11.7KV E R D
session.php258V E R D
shortcodes.php23.5KV E R D
sitemaps.php3.2KV E R D
speculative-loading.php8.4KV E R D
spl-autoload-compat.php441V E R D
style-engine.php7.4KV E R D
taxonomy.php173KV E R D
template-canvas.php544V E R D
template-loader.php4.2KV E R D
template.php36KV E R D
theme-i18n.json1.8KV E R D
theme-previews.php2.8KV E R D
theme-templates.php4KV E R D
theme.json8.8KV E R D
theme.php131.5KV E R D
update.php37.4KV E R D
user.php174.6KV E R D
utf8.php7.1KV E R D
vars.php6.5KV E R D
version.php1.1KV E R D
view-transitions.php602V E R D
widgets.php69.2KV E R D
wp-cron-compat.php3.7KV E R D
wp-db.php445V E R D
wp-diff.php799V E R D