PHPackages                             josantonius/wp-register - 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. josantonius/wp-register

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

josantonius/wp-register
=======================

Register, minify and unify CSS and JavaScript resources.

1.0.5(8y ago)764MITPHPPHP ^5.6 || ^7.0

Since Mar 27Pushed 3y ago2 watchersCompare

[ Source](https://github.com/josantonius/wp-register)[ Packagist](https://packagist.org/packages/josantonius/wp-register)[ GitHub Sponsors](https://github.com/Josantonius)[ RSS](/packages/josantonius-wp-register/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (7)Used By (0)

PHP WordPress Register
======================

[](#php-wordpress-register)

[![Latest Stable Version](https://camo.githubusercontent.com/acfaff82e3a5a4bc785620fbaf355f43ab4b5e065f2c58a22c38d82f54bbdcc4/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f77702d72656769737465722f762f737461626c65)](https://packagist.org/packages/josantonius/wp-register)[![License](https://camo.githubusercontent.com/7cec893abc275fe2b5ceeabb2c911d96e3e21523a4a4f5e184b8ac10f31a84a8/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f77702d72656769737465722f6c6963656e7365)](LICENSE)

[Versión en español](README-ES.md)

Register, minify and unify CSS and JavaScript resources in WordPress.

---

- [Requirements](#requirements)
- [Installation](#installation)
- [Available Methods](#available-methods)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Tests](#tests)
- [Sponsor](#Sponsor)
- [License](#license)

---

Requirements
------------

[](#requirements)

This library is supported by **PHP versions 5.6** or higher and is compatible with **HHVM versions 3.0** or higher.

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

[](#installation)

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

To install **WP\_Register library**, simply:

```
composer require josantonius/wp-register

```

The previous command will only install the necessary files, if you prefer to **download the entire source code** you can use:

```
composer require josantonius/wp-register --prefer-source

```

You can also **clone the complete repository** with Git:

```
git clone https://github.com/josantonius/wp-register.git

```

Or **install it manually**:

[Download WP\_Register.php](https://raw.githubusercontent.com/josantonius/wp-register/master/src/class-wp-register.php):

```
wget https://raw.githubusercontent.com/josantonius/wp-register/master/src/class-wp-register.php

```

Available Methods
-----------------

[](#available-methods)

Available methods in this library:

### - Add scripts or styles

[](#--add-scripts-or-styles)

```
WP_Register::add($type, $data);
```

AttributeDescriptionTypeRequiredDefault$type'script' or 'style'stringYesAttributekeyDescriptionTypeRequiredDefault$dataSettingsarrayYesnameUnique IDstringYesurlUrl to filestringYesplace'admin' or 'front'stringNo'front'depsDependencesarrayNo\[\]versionVersionstringNofalsefooter**Only for scripts** - Attach in footerbooleanNotrueparams**Only for scripts** - Params available in JSarrayYes\[\]media**Only for styles** - MediastringNo''**@return** (boolean)

### - Sets whether to merge the content of files into a single file

[](#--sets-whether-to-merge-the-content-of-files-into-a-single-file)

```
WP_Register::unify($id, $params, $minify);
```

AttributeDescriptionTypeRequiredDefault$idAction hook namestringYes$paramsPath urlsmixedYes$minifyMinimize file contentbooleanNofalse**@return** (boolean true)

### - Check if a particular style or script has been added to be enqueued

[](#--check-if-a-particular-style-or-script-has-been-added-to-be-enqueued)

```
WP_Register::is_added($type, $name);
```

AttributeDescriptionTypeRequiredDefault$type'script' or 'style'stringYes$nameScript or style IDstringYes**@return** (boolean)

### - Remove before script or style have been registered

[](#--remove-before-script-or-style-have-been-registered)

```
WP_Register::remove($type, $name);
```

AttributeDescriptionTypeRequiredDefault$type'script' or 'style'stringYes$nameScript or style IDstringYes**@return** (boolean true)

Quick Start
-----------

[](#quick-start)

To use this library with **Composer**:

```
require __DIR__ . '/vendor/autoload.php';

use Josantonius\WP_Register;
```

Or If you installed it **manually**, use it:

```
require_once __DIR__ . '/class-wp-register.php';

use Josantonius\WP_Register\WP_Register;
```

Usage
-----

[](#usage)

Example of use for this library:

### - Add script

[](#--add-script)

```
WP_Register::add('script', [

    'name'  => 'HTML_script',
    'url'   => 'http://josantonius.com/js/html5.js'
]);
```

```
WP_Register::add('script', [

    'name'    => 'NavigationScript',
    'url'     => 'http://josantonius.com/js/navigation.js',
    'place'   => 'admin',
    'deps'    => ['jquery'],
    'version' => '1.1.3',
    'footer'  => true,
    'params'  => ['date' => date('now')],
]);
```

Additionally, a nonce is created for each script using its name. In this example, it will be accessible from JavaScript using `NavigationScript.nonce`.

`wp_verify_nonce($nonce, 'NavigationScript');`

In the case of scripts created from plugins, the path of the plugin directory is saved as a parameter. In this example, it will be accessible from JavaScript using `NavigationScript.pluginUrl`.

### - Add style

[](#--add-style)

```
WP_Register::add('style', [

    'name'  => 'EditorStyle',
    'url'   => 'http://josantonius.com/js/editor-style.css'
]);
```

```
WP_Register::add('style', [

    'name'    => 'DefaultStyle',
    'url'     => 'http://josantonius.com/js/style.css',
    'place'   => 'admin',
    'deps'    => [],
    'version' => '1.1.3',
    'media'   => 'all'
])
```

### - Unify

[](#--unify)

```
WP_Register::unify('UniqueID', 'http://josantonius.com/min/');
```

### - Unify and minify

[](#--unify-and-minify)

```
WP_Register::unify('UniqueID', 'http://josantonius.com/min/', true);
```

### - Unify specifying different url paths for styles and scripts

[](#--unify-specifying-different-url-paths-for-styles-and-scripts)

```
WP_Register::unify('UniqueID', [

    'styles'  => 'http://josantonius.com/min/css/',
    'scripts' => 'http://josantonius.com/min/js/'
]);
```

### - Unify and minify specifying different url paths for styles and scripts

[](#--unify-and-minify-specifying-different-url-paths-for-styles-and-scripts)

```
WP_Register::unify('UniqueID', [

    'styles'  => 'http://josantonius.com/min/css/',
    'scripts' => 'http://josantonius.com/min/js/'

], true);
```

### - Check if a particular style or script has been added to be registered

[](#--check-if-a-particular-style-or-script-has-been-added-to-be-registered)

```
WP_Register::is_added('script', 'HTML_script');

WP_Register::is_added('script', 'NavigationScript');

WP_Register::is_added('style', 'EditorStyle');

WP_Register::is_added('style', 'DefaultStyle');
```

### - Remove before script or style have been enqueued

[](#--remove-before-script-or-style-have-been-enqueued)

```
WP_Register::remove('script', 'HTML_script');

WP_Register::remove('script', 'NavigationScript');

WP_Register::remove('style', 'EditorStyle');

WP_Register::remove('style', 'DefaultStyle');
```

Tests
-----

[](#tests)

To run [tests](tests) you just need [composer](http://getcomposer.org/download/) and to execute the following:

```
git clone https://github.com/josantonius/wp-register.git

cd WP_Register

bash bin/install-wp-tests.sh wordpress_test root '' localhost latest

composer install

```

Run unit tests with [PHPUnit](https://phpunit.de/):

```
composer phpunit

```

Run [WordPress](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/) code standard tests with [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):

```
composer phpcs

```

Run [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style:

```
composer phpmd

```

Run all previous tests:

```
composer tests

```

Sponsor
-------

[](#sponsor)

If this project helps you to reduce your development time, [you can sponsor me](https://github.com/josantonius#sponsor) to support my open source work 😊

License
-------

[](#license)

This repository is licensed under the [MIT License](LICENSE).

Copyright © 2017-2022, [Josantonius](https://github.com/josantonius#contact)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~57 days

Total

6

Last Release

3045d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b221283501ec8a9cbaefaf27821a91ae8ddd33bddf1fccc6c6815b7ad216ff1?d=identicon)[Josantonius](/maintainers/Josantonius)

---

Top Contributors

[![josantonius](https://avatars.githubusercontent.com/u/18104336?v=4)](https://github.com/josantonius "josantonius (81 commits)")

---

Tags

cssenqueueminifyminify-cssminify-javascriptphpregisterscriptstyleunifyunify-cssunify-javascriptwordpressphpwordpresscssstyleJShhvmassetsscriptregisterenqueueminify CSSminify JSunify CSSunify JS

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/josantonius-wp-register/health.svg)

```
[![Health](https://phpackages.com/badges/josantonius-wp-register/health.svg)](https://phpackages.com/packages/josantonius-wp-register)
```

###  Alternatives

[sensiolabs/minify-bundle

Assets Minifier (CSS, JS) for Symfony &amp; Minify integration in Asset Mapper

5694.9k1](/packages/sensiolabs-minify-bundle)[fisharebest/laravel-assets

Asset management for Laravel

208.1k](/packages/fisharebest-laravel-assets)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
