Conversation
Implements script dependencies through the use:
```
$enqueue->front([
'as' => 'ShirtCreatorInterface',
'src' => Helper::assetUrl('/js/app.js'),
'dep' => ['jquery'],
'filter' => [ 'page' => '*' ]
]);
```
|
This makes sense to me. Though, you should allow dep to be passed a string if there is only one of them, for sure 😄 |
Herbert/Framework/Enqueue.php
Outdated
There was a problem hiding this comment.
I'd either new line this and use curlies or, on L77 use array_get($attrs, 'dep', []) instead.
|
Most definitely a worthy improvement. Will take care of that. |
Improve dependency attributes fetching for enqueue.
Changes the way scripts are called now using wp_register_script first in order to localize scripts.
Ex:
```
$enqueue->front([
'as' => 'MyScript',
'src' => Helper::assetUrl('/js/app.js'),
'dep' => 'jquery',
'filter' => [ 'page' => '*' ],
'localize' => array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) )
]);
```
|
Not sure if I should have created a new branch but since the source code affects the same area... |
|
+1 |
|
@csrui I have just started learning herbert from nearly a month and I do feel like a looser, as I am unable to do things usually I can do in wordpress, in last one month, using even your code It gives me error Fatal error: Using $this when not in object context in E:\plugins\Analytica\app\Controllers\AnalyticaController.php on line 168 and if I will call front with Enqueue::fronT() , it gives me no error neither it enqueue the script. |
|
You need can't use $this directly in a class without having it in a method. Move your code up to the __construct-method, should work. |
|
Hi @tormjens I have already solved this issue by en-queuing my scripts in enqueue.php |
|
@onnimonni This feature is crucial. Since the commits look firm, I see no reason for further delaying a merge. |
|
@csrui Could you resolve the merge conflicts? Thanks! |
|
@csrui Ping. =) |
|
This project seems dead. |
Implements script dependencies through the use: