Skip to content

Commit

Permalink
docs: add php enqueue docs for version 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
swashata committed May 2, 2021
1 parent 15990fc commit bfebee6
Showing 1 changed file with 106 additions and 16 deletions.
122 changes: 106 additions & 16 deletions site/docs/apis/php-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ An associative array of additional configuration.

Here are the supported keys:

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

**defaults to**

Expand Down Expand Up @@ -251,21 +251,13 @@ Let us consider the following `manifest.json` file generated by `@wpackio/script
"wpackioEp": {
"main": {
"js": ["app/runtime.js", "app/vendor~main.js", "app/main.js"],
"js.map": [
"app/runtime.js.map",
"app/vendor.js.map",
"app/main.js.map"
],
"js.map": ["app/runtime.js.map", "app/vendor.js.map", "app/main.js.map"],
"css": ["app/main.css"],
"css.map": ["app/main.css.map"]
},
"mobile": {
"js": ["app/runtime.js", "app/vendor~mobile.js", "app/mobile.js"],
"js.map": [
"app/runtime.js.map",
"app/vendor.js.map",
"app/mobile.js.map"
]
"js.map": ["app/runtime.js.map", "app/vendor.js.map", "app/mobile.js.map"]
}
}
}
Expand Down Expand Up @@ -402,3 +394,101 @@ $enqueue->getManifest( $asset );

The relative path of the asset (with forward `/` as director separator) for which
URL is to be calculated.

## Instance API: `getPrimaryJsHandle`

Get primary js handle from enqueued/registered assets. This is useful to localize/translate the script handle.

### Usage

```php
$enqueue = new \WPackio\Enqueue( 'appName', 'dist', '1.0.0', 'plugin', PLUGIN_PATH );
$assets = $enqueue->enqueue(); // or ->register
$primary_js_handle = $enqueue->getPrimaryJsHandle( $assets );
```

### Parameters

It accepts only one parameter.

```php
$enqueue->getPrimaryJsHandle( $assets );
```

#### `$assets` (`array`)

Assets array as returned from enqueue or register.

## Instance API: `getPrimaryCssHandle`

Get primary css handle from enqueued/registered assets. This is useful to localize/translate the script handle.

### Usage

```php
$enqueue = new \WPackio\Enqueue( 'appName', 'dist', '1.0.0', 'plugin', PLUGIN_PATH );
$assets = $enqueue->enqueue(); // or ->register
$primary_css_handle = $enqueue->getPrimaryCssHandle( $assets );
```

### Parameters

It accepts only one parameter.

```php
$enqueue->getPrimaryCssHandle( $assets );
```

#### `$assets` (`array`)

Assets array as returned from enqueue or register.

## Instance API: `getJsHandles`

Get all js handles from enqueued/registered assets. Would return an empty array
if no handles were found or if invalid input.

### Usage

```php
$enqueue = new \WPackio\Enqueue( 'appName', 'dist', '1.0.0', 'plugin', PLUGIN_PATH );
$assets = $enqueue->enqueue(); // or ->register
$js_handles = $enqueue->getJsHandles( $assets );
```

### Parameters

It accepts only one parameter.

```php
$enqueue->getJsHandles( $assets );
```

#### `$assets` (`array`)

Assets array as returned from enqueue or register.

## Instance API: `getCssHandles`

Get all css handles from enqueued/registered assets. Would return an empty array
if no handles were found or if invalid input.

### Usage

```php
$enqueue = new \WPackio\Enqueue( 'appName', 'dist', '1.0.0', 'plugin', PLUGIN_PATH );
$assets = $enqueue->enqueue(); // or ->register
$css_handles = $enqueue->getCssHandles( $assets );
```

### Parameters

It accepts only one parameter.

```php
$enqueue->getCssHandles( $assets );
```

#### `$assets` (`array`)

Assets array as returned from enqueue or register.

0 comments on commit bfebee6

Please sign in to comment.