PHPackages                             hametuha/wp-enqueue-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hametuha/wp-enqueue-manager

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hametuha/wp-enqueue-manager
===========================

A WordPress library to bulk register assets.

1.2.1(1y ago)112.0k↓100%2[2 issues](https://github.com/hametuha/wp-enqueue-manager/issues)1GPL-3.0-or-laterPHPPHP &gt;=7.2

Since Dec 20Pushed 1y agoCompare

[ Source](https://github.com/hametuha/wp-enqueue-manager)[ Packagist](https://packagist.org/packages/hametuha/wp-enqueue-manager)[ RSS](/packages/hametuha-wp-enqueue-manager/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (6)Versions (12)Used By (1)

wp-enqueue-manager
==================

[](#wp-enqueue-manager)

Bulk register WordPress assets with specified folder structure. Good shortcut for your theme development.

[![Travis CI master branch](https://camo.githubusercontent.com/7ee448da15a31950a18effca39d25e7dcb05490f061f2cab5edf686e04825716/68747470733a2f2f7472617669732d63692e6f72672f68616d65747568612f77702d656e71756575652d6d616e616765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hametuha/wp-enqueue-manager)

Installation
------------

[](#installation)

Use composer.

```
composer require hametuha/wp-enqueue-manager

```

Usage
-----

[](#usage)

Write dependnecies in your assets(js and css) header as comment. format is like `wpdeps=dependencies`. CSV ready.

This notation will be used for the `deps` argument of `wp_register_script`[(doc)](https://developer.wordpress.org/reference/functions/wp_register_script/) and `wp_register_style`[(doc)](https://developer.wordpress.org/reference/functions/wp_register_style/).

Operations should be done in `init` hook or before. Write codes in your `functions.php`.

### Javascript

[](#javascript)

Header file should be like below:

```
/*!
 * wpdeps=jquery,thicbox
 */
jQuery(document).ready(function($){
  // Do something.
});
```

**NOTICE:** If you use autoprefixer or minify tools, be careful about cleaning up comments.

Then, register them all from your theme or plugin.

```
// Register all js in folder.
// e.g. /assets/js/sample.js will be regsitered as 'my-sample'.
Hametuha\WpEnqueueManager::register_js( __DIR__ . '/assets/, 'my-', '1.0.0' );
```

### Stylesheet

[](#stylesheet)

Same as javascript, regsier

```
/*!
 * wpdeps=bootstrap
 */
body{
   background-color: red;
}
```

And, run `register_styles`.

```
// Register all css in folder.
// e.g. /assets/css/sample.css will be regsitered as 'my-sample'.
Hametuha\WpEnqueueManager::register_styles( __DIR__ . '/assets/, 'my-', '1.0.0' );
```

### Versionning

[](#versionning)

If you are a theme or plugin author, it's proper to pass the version of your theme/plugin. Lazy authors may just pass `null` or skip the argument. Then the file modified time will be used as version string.

Localization
------------

[](#localization)

For Javascript localization, you can bulk register localization vars.

```
Hametuha\WpEnqueueManager::register_js_var_files( __DIR__ . '/l10n );

```

File name equals js handle name. Camelized handle name should be var name. PHP files should return var array.

For example, if you put `my-sample.php` below in `l10n` directory.

```
