# wp-graphql/trunk/src/Data/Loader/EnqueuedScriptLoader.php

WPGraphQL, version trunk. 35 lines.

- Page: https://pluginprobe.com/plugins/wp-graphql/trunk/code/src/Data/Loader/EnqueuedScriptLoader.php
- Raw: https://pluginprobe.com/plugins/wp-graphql/trunk/raw/src/Data/Loader/EnqueuedScriptLoader.php
- Modified: 2023-11-02T19:07:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-graphql/trunk/code/src/Data/Loader/EnqueuedScriptLoader.php#L10-L20`.

```php
<?php
namespace WPGraphQL\Data\Loader;

/**
 * Class EnqueuedScriptLoader
 *
 * @package WPGraphQL\Data\Loader
 */
class EnqueuedScriptLoader extends AbstractDataLoader {

	/**
	 * {@inheritDoc}
	 *
	 * @param string[] $keys Array of script handles to load
	 *
	 * @return array<string,mixed>
	 */
	public function loadKeys( array $keys ) {
		/** @var \WP_Scripts $wp_scripts */
		global $wp_scripts;

		$loaded = [];
		foreach ( $keys as $key ) {
			if ( isset( $wp_scripts->registered[ $key ] ) ) {
				$script         = $wp_scripts->registered[ $key ];
				$script->type   = 'EnqueuedScript';
				$loaded[ $key ] = $script;
			} else {
				$loaded[ $key ] = null;
			}
		}
		return $loaded;
	}
}

```
