Skip to content

Add a way to set file type in get_asset_info function #13

Description

@fabiankaegy

if ( file_exists( $this->dist_path . 'js/' . $slug . '.asset.php' ) ) {
$asset = require $this->dist_path . 'js/' . $slug . '.asset.php';
} elseif ( file_exists( $this->dist_path . 'css/' . $slug . '.asset.php' ) ) {
$asset = require $this->dist_path . 'css/' . $slug . '.asset.php';
} elseif ( file_exists( $this->dist_path . 'blocks/' . $slug . '.asset.php' ) ) {
$asset = require $this->dist_path . 'blocks/' . $slug . '.asset.php';
} else {
$asset = [
'version' => $this->fallback_version,
'dependencies' => [],
];
}

If a JS and CSS use the same handle, it might load incorrect asset PHP data.
because it always check js first.

maybe:

get_asset_info( $file_dir, $slug, $attribute = null )

Or include the dir in the slug:

get_asset_info( 'css/file' )
get_asset_info( 'js/file' )

This issue was originally reported by @turtlepod in https://github.com/10up/ui-kit-monorepo/issues/205

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions