Automattic\WooCommerce\Internal\Admin

WCAdminAssets::register_script()public staticWC 1.0

Loads a script

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

Хуков нет.

Возвращает

null. Ничего.

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

$result = WCAdminAssets::register_script( $script_path_name, $script_name, $need_translation );
$script_path_name(строка) (обязательный)
The script path name.
$script_name(строка) (обязательный)
Filename of the script to load.
$need_translation(true|false)
Whether the script need translations.
По умолчанию: false

Код WCAdminAssets::register_script() WC 7.1.0

public static function register_script( $script_path_name, $script_name, $need_translation = false ) {
	$script_assets_filename = self::get_script_asset_filename( $script_path_name, $script_name );
	$script_assets          = require WC_ADMIN_ABSPATH . WC_ADMIN_DIST_JS_FOLDER . $script_path_name . '/' . $script_assets_filename;

	wp_enqueue_script(
		'wc-admin-' . $script_name,
		self::get_url( $script_path_name . '/' . $script_name, 'js' ),
		array_merge( array( WC_ADMIN_APP ), $script_assets ['dependencies'] ),
		self::get_file_version( 'js' ),
		true
	);
	if ( $need_translation ) {
		wp_set_script_translations( 'wc-admin-' . $script_name, 'woocommerce' );
	}
}