Automattic\WooCommerce\Admin\Features\Settings

Init::get_script_urls()private staticWC 1.0

Retrieve the script URLs from the provided script handles. This will also filter out scripts from WordPress core since they only need to be loaded once.

Method of the class: Init{}

No Hooks.

Return

Array. Array of script URLs.

Usage

$result = Init::get_script_urls( $script_handles );
$script_handles(array) (required)
Array of script handles.

Init::get_script_urls() code WC 9.7.1

private static function get_script_urls( $script_handles ) {
	global $wp_scripts;
	$script_urls = array();
	foreach ( $script_handles as $script ) {
		$registered_script = $wp_scripts->registered[ $script ];
		if ( ! isset( $registered_script->src ) ) {
			continue;
		}

		// Skip scripts from WordPress core since they only need to be loaded once.
		if ( strpos( $registered_script->src, '/' . WPINC . '/js' ) === 0 || strpos( $registered_script->src, '/wp-admin/js' ) === 0 ) {
			continue;
		}

		if ( strpos( $registered_script->src, '/' ) === 0 ) {
			$script_urls[] = home_url( $registered_script->src );
		} else {
			$script_urls[] = $registered_script->src;
		}
	}
	return $script_urls;
}