Automattic\WooCommerce\Internal\Admin
WCAdminAssets::get_script_asset_filename
Gets a script asset registry filename. The asset registry lists dependencies for the given script.
Method of the class: WCAdminAssets{}
No Hooks.
Returns
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() WCAdminAssets::get script asset filename code WC 10.8.1
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 );
}
}