WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Automattic\WooCommerce\Blocks\Assets

Api::register_script() public WC 2.5.0

Registers a script according to wp_register_script, additionally loading the translations for the file.

{} Это метод класса: Api{}

Возвращает

null. Null. Ничего.

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

$Api = new Api();
$Api->register_script( $handle, $relative_src, $dependencies, $has_i18n );
$handle(строка) (обязательный)
Name of the script. Should be unique.
$relative_src(строка) (обязательный)
Relative url for the script to the path from plugin root.
$dependencies(массив)
An array of registered script handles this script depends on.
По умолчанию: empty array
$has_i18n(true|false)
Whether to add a script translation call to this file.
По умолчанию: true

Список изменений

С версии 2.5.0 Введена.

Код Api::register_script() WC 5.2.0

<?php
public function register_script( $handle, $relative_src, $dependencies = [], $has_i18n = true ) {
	$src        = $this->get_asset_url( $relative_src );
	$asset_path = $this->package->get_path(
		str_replace( '.js', '.asset.php', $relative_src )
	);

	if ( file_exists( $asset_path ) ) {
		$asset        = require $asset_path;
		$dependencies = isset( $asset['dependencies'] ) ? array_merge( $asset['dependencies'], $dependencies ) : $dependencies;
		$version      = ! empty( $asset['version'] ) ? $asset['version'] : $this->get_file_version( $relative_src );
	} else {
		$version = $this->get_file_version( $relative_src );
	}

	if ( in_array( $handle, $dependencies, true ) ) {
		if ( $this->package->feature()->is_development_environment() ) {
			$dependencies = array_diff( $dependencies, [ $handle ] );
				add_action(
					'admin_notices',
					function() use ( $handle ) {
							echo '<div class="error"><p>';
							/* translators: %s file handle name. */
							printf( esc_html__( 'Script with handle %s had a dependency on itself which has been removed. This is an indicator that your JS code has a circular dependency that can cause bugs.', 'woocommerce' ), esc_html( $handle ) );
							echo '</p></div>';
					}
				);
		} else {
			throw new Exception( sprintf( 'Script with handle %s had a dependency on itself. This is an indicator that your JS code has a circular dependency that can cause bugs.', $handle ) );
		}
	}

	wp_register_script( $handle, $src, apply_filters( 'woocommerce_blocks_register_script_dependencies', $dependencies, $handle ), $version, true );

	if ( $has_i18n && function_exists( 'wp_set_script_translations' ) ) {
		wp_set_script_translations( $handle, 'woocommerce', $this->package->get_path( 'languages' ) );
	}
}