Skip to content

Commit bfebee6

Browse files
committed
docs: add php enqueue docs for version 3.2.0
1 parent 15990fc commit bfebee6

File tree

1 file changed

+106
-16
lines changed

1 file changed

+106
-16
lines changed

site/docs/apis/php-api.md

Lines changed: 106 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ An associative array of additional configuration.
149149

150150
Here are the supported keys:
151151

152-
- `js` (`boolean`) True if we are to include javascript files.
153-
- `css` (`boolean`) True if we are to include stylesheet files.
154-
- `js_dep` (`array`) Additional dependencies for the javascript assets.
155-
- `css_dep` (`array`) Additional dependencies for the stylesheet assets.
156-
- `in_footer` (`boolean`) Whether to print the assets in footer (for js only).
157-
- `media` (`string`) Media attribute for stylesheets (defaults `'all'`).
152+
- `js` (`boolean`) True if we are to include javascript files.
153+
- `css` (`boolean`) True if we are to include stylesheet files.
154+
- `js_dep` (`array`) Additional dependencies for the javascript assets.
155+
- `css_dep` (`array`) Additional dependencies for the stylesheet assets.
156+
- `in_footer` (`boolean`) Whether to print the assets in footer (for js only).
157+
- `media` (`string`) Media attribute for stylesheets (defaults `'all'`).
158158

159159
**defaults to**
160160

@@ -251,21 +251,13 @@ Let us consider the following `manifest.json` file generated by `@wpackio/script
251251
"wpackioEp": {
252252
"main": {
253253
"js": ["app/runtime.js", "app/vendor~main.js", "app/main.js"],
254-
"js.map": [
255-
"app/runtime.js.map",
256-
"app/vendor.js.map",
257-
"app/main.js.map"
258-
],
254+
"js.map": ["app/runtime.js.map", "app/vendor.js.map", "app/main.js.map"],
259255
"css": ["app/main.css"],
260256
"css.map": ["app/main.css.map"]
261257
},
262258
"mobile": {
263259
"js": ["app/runtime.js", "app/vendor~mobile.js", "app/mobile.js"],
264-
"js.map": [
265-
"app/runtime.js.map",
266-
"app/vendor.js.map",
267-
"app/mobile.js.map"
268-
]
260+
"js.map": ["app/runtime.js.map", "app/vendor.js.map", "app/mobile.js.map"]
269261
}
270262
}
271263
}
@@ -402,3 +394,101 @@ $enqueue->getManifest( $asset );
402394

403395
The relative path of the asset (with forward `/` as director separator) for which
404396
URL is to be calculated.
397+
398+
## Instance API: `getPrimaryJsHandle`
399+
400+
Get primary js handle from enqueued/registered assets. This is useful to localize/translate the script handle.
401+
402+
### Usage
403+
404+
```php
405+
$enqueue = new \WPackio\Enqueue( 'appName', 'dist', '1.0.0', 'plugin', PLUGIN_PATH );
406+
$assets = $enqueue->enqueue(); // or ->register
407+
$primary_js_handle = $enqueue->getPrimaryJsHandle( $assets );
408+
```
409+
410+
### Parameters
411+
412+
It accepts only one parameter.
413+
414+
```php
415+
$enqueue->getPrimaryJsHandle( $assets );
416+
```
417+
418+
#### `$assets` (`array`)
419+
420+
Assets array as returned from enqueue or register.
421+
422+
## Instance API: `getPrimaryCssHandle`
423+
424+
Get primary css handle from enqueued/registered assets. This is useful to localize/translate the script handle.
425+
426+
### Usage
427+
428+
```php
429+
$enqueue = new \WPackio\Enqueue( 'appName', 'dist', '1.0.0', 'plugin', PLUGIN_PATH );
430+
$assets = $enqueue->enqueue(); // or ->register
431+
$primary_css_handle = $enqueue->getPrimaryCssHandle( $assets );
432+
```
433+
434+
### Parameters
435+
436+
It accepts only one parameter.
437+
438+
```php
439+
$enqueue->getPrimaryCssHandle( $assets );
440+
```
441+
442+
#### `$assets` (`array`)
443+
444+
Assets array as returned from enqueue or register.
445+
446+
## Instance API: `getJsHandles`
447+
448+
Get all js handles from enqueued/registered assets. Would return an empty array
449+
if no handles were found or if invalid input.
450+
451+
### Usage
452+
453+
```php
454+
$enqueue = new \WPackio\Enqueue( 'appName', 'dist', '1.0.0', 'plugin', PLUGIN_PATH );
455+
$assets = $enqueue->enqueue(); // or ->register
456+
$js_handles = $enqueue->getJsHandles( $assets );
457+
```
458+
459+
### Parameters
460+
461+
It accepts only one parameter.
462+
463+
```php
464+
$enqueue->getJsHandles( $assets );
465+
```
466+
467+
#### `$assets` (`array`)
468+
469+
Assets array as returned from enqueue or register.
470+
471+
## Instance API: `getCssHandles`
472+
473+
Get all css handles from enqueued/registered assets. Would return an empty array
474+
if no handles were found or if invalid input.
475+
476+
### Usage
477+
478+
```php
479+
$enqueue = new \WPackio\Enqueue( 'appName', 'dist', '1.0.0', 'plugin', PLUGIN_PATH );
480+
$assets = $enqueue->enqueue(); // or ->register
481+
$css_handles = $enqueue->getCssHandles( $assets );
482+
```
483+
484+
### Parameters
485+
486+
It accepts only one parameter.
487+
488+
```php
489+
$enqueue->getCssHandles( $assets );
490+
```
491+
492+
#### `$assets` (`array`)
493+
494+
Assets array as returned from enqueue or register.

0 commit comments

Comments
 (0)