Uses
Uses | Description |
---|---|
wp-includes/http.php: wp_parse_url() | A wrapper for PHP’s parse_url() function that handles consistency in the return values across PHP versions. |
Retrieves a list of unique hosts of all enqueued scripts and styles.
(string[]) A list of unique hosts of enqueued scripts and styles.
File: wp-includes/general-template.php
function wp_dependencies_unique_hosts() { global $wp_scripts, $wp_styles; $unique_hosts = array(); foreach ( array( $wp_scripts, $wp_styles ) as $dependencies ) { if ( $dependencies instanceof WP_Dependencies && ! empty( $dependencies->queue ) ) { foreach ( $dependencies->queue as $handle ) { if ( ! isset( $dependencies->registered[ $handle ] ) ) { continue; } /* @var _WP_Dependency $dependency */ $dependency = $dependencies->registered[ $handle ]; $parsed = wp_parse_url( $dependency->src ); if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts, true ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) { $unique_hosts[] = $parsed['host']; } } } } return $unique_hosts; }
Version | Description |
---|---|
4.6.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_dependencies_unique_hosts