File tree 4 files changed +38
-19
lines changed
4 files changed +38
-19
lines changed Original file line number Diff line number Diff line change 11
11
"require" : {
12
12
"php" : " >=8.0" ,
13
13
"automattic/jetpack-constants" : " ^2.0" ,
14
- "x-wp/helper-functions" : " ^1.9 " ,
14
+ "x-wp/helper-functions" : " ^1.18 " ,
15
15
"x-wp/helper-traits" : " ^1.9"
16
16
},
17
17
"require-dev" : {
Original file line number Diff line number Diff line change @@ -359,7 +359,7 @@ public function find( string $ext ): array {
359
359
* @param class-string<T> $type The type of asset to get.
360
360
* @return array<string,T>
361
361
*/
362
- public function get ( string $ type ): array {
362
+ public function collect ( string $ type ): array {
363
363
$ found = array ();
364
364
365
365
foreach ( array_keys ( $ this ->manifest ) as $ src ) {
@@ -372,4 +372,21 @@ public function get( string $type ): array {
372
372
373
373
return $ found ;
374
374
}
375
+
376
+ /**
377
+ * Get an asset by field.
378
+ *
379
+ * @param string $id The ID of the asset to get.
380
+ * @param string $field The field to search by.
381
+ * @return Style|Script|Image|Font|null
382
+ */
383
+ public function get ( string $ id , string $ field = 'handle ' ): Style |Script |Image |Font |null {
384
+ foreach ( array_keys ( $ this ->manifest ) as $ src ) {
385
+ if ( $ id === $ this [ $ src ]->{"{$ field }" }() ) {
386
+ return $ this [ $ src ];
387
+ }
388
+ }
389
+
390
+ return null ;
391
+ }
375
392
}
Original file line number Diff line number Diff line change @@ -55,21 +55,21 @@ public function __construct(
55
55
}
56
56
57
57
/**
58
- * Get the bundle instance.
58
+ * Get the WP_Filesystem instance.
59
59
*
60
- * @return XWP_Asset_Bundle
60
+ * @return \WP_Filesystem_Direct|null
61
61
*/
62
- public function bundle (): XWP_Asset_Bundle {
63
- return $ this -> bundle ;
62
+ protected function wpfs (): ? \ WP_Filesystem_Direct {
63
+ return \xwp_wpfs () ?: null ;
64
64
}
65
65
66
66
/**
67
- * Get the WP_Filesystem instance.
67
+ * Get the bundle instance.
68
68
*
69
- * @return \WP_Filesystem_Base|null
69
+ * @return XWP_Asset_Bundle
70
70
*/
71
- protected function wpfs (): ? \ WP_Filesystem_Base {
72
- return \wp_load_filesystem () ?: null ;
71
+ public function bundle (): XWP_Asset_Bundle {
72
+ return $ this -> bundle ;
73
73
}
74
74
75
75
/**
You can’t perform that action at this time.
0 commit comments