WPSEO_Admin_Asset_Manager::scripts_to_be_registered()protectedYoast 1.0

Returns the scripts that need to be registered.

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

Хуков нет.

Возвращает

Массив. The scripts that need to be registered.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->scripts_to_be_registered();

Код WPSEO_Admin_Asset_Manager::scripts_to_be_registered() Yoast 24.0

protected function scripts_to_be_registered() {
	$header_scripts          = [
		'admin-global',
		'block-editor',
		'classic-editor',
		'post-edit',
		'help-scout-beacon',
		'redirect-old-features-tab',
	];
	$additional_dependencies = [
		'analysis-worker'          => [ self::PREFIX . 'analysis-package' ],
		'api-client'               => [ 'wp-api' ],
		'crawl-settings'           => [ 'jquery' ],
		'dashboard-widget'         => [ self::PREFIX . 'api-client' ],
		'wincher-dashboard-widget' => [ self::PREFIX . 'api-client' ],
		'editor-modules'           => [ 'jquery' ],
		'elementor'                => [
			self::PREFIX . 'api-client',
			self::PREFIX . 'externals-components',
			self::PREFIX . 'externals-contexts',
			self::PREFIX . 'externals-redux',
		],
		'indexation'               => [
			'jquery-ui-core',
			'jquery-ui-progressbar',
		],
		'first-time-configuration' => [
			self::PREFIX . 'api-client',
			self::PREFIX . 'externals-components',
			self::PREFIX . 'externals-contexts',
			self::PREFIX . 'externals-redux',
		],
		'integrations-page'        => [
			self::PREFIX . 'api-client',
			self::PREFIX . 'externals-components',
			self::PREFIX . 'externals-contexts',
			self::PREFIX . 'externals-redux',
		],
		'post-edit'                => [
			self::PREFIX . 'api-client',
			self::PREFIX . 'block-editor',
			self::PREFIX . 'externals-components',
			self::PREFIX . 'externals-contexts',
			self::PREFIX . 'externals-redux',
		],
		'reindex-links'            => [
			'jquery-ui-core',
			'jquery-ui-progressbar',
		],
		'settings'                 => [
			'jquery-ui-core',
			'jquery-ui-progressbar',
			self::PREFIX . 'api-client',
			self::PREFIX . 'externals-components',
			self::PREFIX . 'externals-contexts',
			self::PREFIX . 'externals-redux',
		],
		'term-edit'                => [
			self::PREFIX . 'api-client',
			self::PREFIX . 'classic-editor',
			self::PREFIX . 'externals-components',
			self::PREFIX . 'externals-contexts',
			self::PREFIX . 'externals-redux',
		],
		'general-page'             => [
			self::PREFIX . 'api-client',
		],
	];

	$plugin_scripts   = $this->load_generated_asset_file(
		[
			'asset_file'      => __DIR__ . '/../src/generated/assets/plugin.php',
			'ext_length'      => 3,
			'additional_deps' => $additional_dependencies,
			'header_scripts'  => $header_scripts,
		]
	);
	$external_scripts = $this->load_generated_asset_file(
		[
			'asset_file'      => __DIR__ . '/../src/generated/assets/externals.php',
			'ext_length'      => 3,
			'suffix'          => '-package',
			'base_dir'        => 'externals/',
			'additional_deps' => $additional_dependencies,
			'header_scripts'  => $header_scripts,
		]
	);
	$language_scripts = $this->load_generated_asset_file(
		[
			'asset_file'      => __DIR__ . '/../src/generated/assets/languages.php',
			'ext_length'      => 3,
			'suffix'          => '-language',
			'base_dir'        => 'languages/',
			'additional_deps' => $additional_dependencies,
			'header_scripts'  => $header_scripts,
		]
	);
	$renamed_scripts  = $this->load_renamed_scripts();

	$scripts = array_merge(
		$plugin_scripts,
		$external_scripts,
		$language_scripts,
		$renamed_scripts
	);

	$scripts['installation-success'] = [
		'name'    => 'installation-success',
		'src'     => 'installation-success.js',
		'deps'    => [
			'wp-a11y',
			'wp-dom-ready',
			'wp-components',
			'wp-element',
			'wp-i18n',
			self::PREFIX . 'components-new-package',
			self::PREFIX . 'externals-components',
		],
		'version' => $scripts['installation-success']['version'],
	];

	$scripts['post-edit-classic'] = [
		'name'      => 'post-edit-classic',
		'src'       => $scripts['post-edit']['src'],
		'deps'      => array_map(
			static function ( $dep ) {
				if ( $dep === self::PREFIX . 'block-editor' ) {
					return self::PREFIX . 'classic-editor';
				}
				return $dep;
			},
			$scripts['post-edit']['deps']
		),
		'in_footer' => ! in_array( 'post-edit-classic', $header_scripts, true ),
		'version'   => $scripts['post-edit']['version'],
	];

	$scripts['workouts'] = [
		'name'    => 'workouts',
		'src'     => 'workouts.js',
		'deps'    => [
			'clipboard',
			'lodash',
			'wp-api-fetch',
			'wp-a11y',
			'wp-components',
			'wp-compose',
			'wp-data',
			'wp-dom-ready',
			'wp-element',
			'wp-i18n',
			self::PREFIX . 'externals-components',
			self::PREFIX . 'externals-contexts',
			self::PREFIX . 'externals-redux',
			self::PREFIX . 'analysis',
			self::PREFIX . 'react-select',
			self::PREFIX . 'components-new-package',
		],
		'version' => $scripts['workouts']['version'],
	];

	// Add the current language to every script that requires the analysis package.
	foreach ( $scripts as $name => $script ) {
		if ( substr( $name, -8 ) === 'language' ) {
			continue;
		}
		if ( in_array( self::PREFIX . 'analysis-package', $script['deps'], true ) ) {
			$scripts[ $name ]['deps'][] = self::PREFIX . YoastSEO()->helpers->language->get_researcher_language() . '-language';
		}
	}

	return $scripts;
}