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.

Метод класса: Init{}

Хуков нет.

Возвращает

Массив. Array of script URLs.

Использование

$result = Init::get_script_urls( $script_handles );
$script_handles(массив) (обязательный)
Array of script handles.

Код Init::get_script_urls() 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;
}