Skip to content

Commit b02993c

Browse files
committed
Override add() method in VendorAsset
1 parent 959408b commit b02993c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: src/Assets/VendorAsset.php

+18
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ public function __construct( string $slug, string $url, string $type = 'js' ) {
4343
$this->type = strtolower( $type );
4444
}
4545

46+
/**
47+
* Registers a vendor asset.
48+
*
49+
* @param string $slug The asset slug.
50+
* @param string $url The asset file path.
51+
* @param ?string $type The asset type.
52+
* @param ?string $version The asset version.
53+
*/
54+
public static function add( string $slug, string $url, ?string $type = null, ?string $version = null ) {
55+
$instance = new self( $slug, $url, $type ?? 'js' );
56+
57+
if ( null !== $version ) {
58+
$instance->set_version( $version );
59+
}
60+
61+
return Assets::init()->add( $instance );
62+
}
63+
4664
/**
4765
* Set the asset version.
4866
*

0 commit comments

Comments
 (0)