Automattic\WooCommerce\Internal\Admin

WCAdminAssets::get_script_asset_filename()public staticWC 1.0

Gets a script asset registry filename. The asset registry lists dependencies for the given script.

Method of the class: WCAdminAssets{}

No Hooks.

Return

String. complete asset filename.

Usage

$result = WCAdminAssets::get_script_asset_filename( $script_path_name, $file );
$script_path_name(string) (required)
Path to where the script asset registry is contained.
$file(string) (required)
File name (without extension).

WCAdminAssets::get_script_asset_filename() code WC 8.7.0

public static function get_script_asset_filename( $script_path_name, $file ) {
	$minification_supported = Features::exists( 'minified-js' );
	$script_min_filename    = $file . '.min.asset.php';
	$script_nonmin_filename = $file . '.asset.php';
	$script_asset_path      = WC_ADMIN_ABSPATH . WC_ADMIN_DIST_JS_FOLDER . $script_path_name . '/';

	// Check minification is supported first, to avoid multiple is_readable checks when minification is
	// not supported.
	if ( $minification_supported && is_readable( $script_asset_path . $script_min_filename ) ) {
		return $script_min_filename;
	} elseif ( is_readable( $script_asset_path . $script_nonmin_filename ) ) {
		return $script_nonmin_filename;
	} else {
		// could not find an asset file, throw an error.
		throw new \Exception( 'Could not find asset registry for ' . $script_path_name );
	}
}