PHPackages                             studiometa/wp-toolkit - 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. studiometa/wp-toolkit

ActiveLibrary

studiometa/wp-toolkit
=====================

WordPress utilities for Studio Meta.

2.3.1(7mo ago)911.5k—0%1[2 issues](https://github.com/studiometa/wp-toolkit/issues)[4 PRs](https://github.com/studiometa/wp-toolkit/pulls)MITPHPPHP ^8.1CI passing

Since Nov 17Pushed 7mo ago9 watchersCompare

[ Source](https://github.com/studiometa/wp-toolkit)[ Packagist](https://packagist.org/packages/studiometa/wp-toolkit)[ RSS](/packages/studiometa-wp-toolkit/feed)WikiDiscussions develop Synced today

READMEChangelog (10)Dependencies (15)Versions (27)Used By (0)

WordPress toolkit
=================

[](#wordpress-toolkit)

[![Packagist Version](https://camo.githubusercontent.com/57417b29c7c8ad028672327414f9663ae913ad5015f859dce5d3664596ac401e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f73747564696f6d6574612f77702d746f6f6c6b69743f696e636c7564655f70726572656c6561736573266c6162656c3d7061636b6167697374267374796c653d666c61742d737175617265)](https://packagist.org/packages/studiometa/wp-toolkit)[![License MIT](https://camo.githubusercontent.com/e42b02ff7bb8aa1e66d741b74546490fbf4166f84f38830e816d179c034e4b56/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73747564696f6d6574612f77702d746f6f6c6b69743f7374796c653d666c61742d737175617265)](https://packagist.org/packages/studiometa/wp-toolkit)[![Codecov](https://camo.githubusercontent.com/67d4848285b1e42aa8599a110a0fef30786c5ccad4b9e664dfb52a836dc2dae4/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f73747564696f6d6574612f77702d746f6f6c6b69743f7374796c653d666c61742d737175617265)](https://codecov.io/gh/studiometa/wp-toolkit/)

> A PHP toolkit to boost your WordPress development! 🚀

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

[](#installation)

Install the package via Composer:

```
composer require studiometa/wp-toolkit
```

**Requirements**

- PHP &gt;=7.3

Usage
-----

[](#usage)

```
// Create Custom Post Type
use Studiometa\WPToolkit\Builders\PostTypeBuilder;

$cpt = new PostTypeBuilder( 'product' );
$cpt->set_labels( 'Product', 'Products' )
  ->set_has_archive( true )
  ->register();

// Create Custom Taxonomy
use Studiometa\WPToolkit\Builders\TaxonomyBuilder;

$tax = new TaxonomyBuilder( 'product-cat' );
$tax->set_post_types( 'product' )
  ->set_labels( 'Product Category', 'Product Categories' )
  ->register();

// Create a manager
use Studiometa\WPToolkit\Managers\ManagerInterface;

class CustomManager implements ManagerInterface {
  run() {
    add_action( 'init', array( $this, 'some_action' ) );
  }

  some_action() {
    // do something on init
  }
}

// Init all managers
use Studiometa\WPToolkit\Managers\ManagerFactory;
use Studiometa\WPToolkit\Managers\AssetsManager;
use Studiometa\WPToolkit\Managers\CleanupManager;

ManagerFactory::init(
  array(
    new AssetsManager(),
    new CleanupManager(),
    new CustomManager()
  )
);
```

AssetsManager
-------------

[](#assetsmanager)

The `AssetsManager` manager does the heavy lifting of registering and enqueuing assets for you. It works with a configuration file in YAML with the following format:

```
:
  css:
    :
  js:
    :
```

If used with our [Webpack configuration package](https://github.com/studiometa/webpack-config), you can also specify entrypoints and all their dependencies to be registered and enqueued.

```
all:
  entries:
    - css/app.scss
    - js/app.js
```

```
new AssetsManager(
  get_template_directory() . '/config/assets.yml',
  get_template_directory() . '/dist/assets-manifest.json',
);
```

### Parameters

[](#parameters)

- `$configuration_filepath` (`string`): path to the `config.yml` file, defaults to `config/assets.yml` in your theme.
- `$webpack_manifest_filepath` (`string`), path to the Webpack assets manifest file, defaults to `dist/assets-manifest.json` in your theme.

Helpers
-------

[](#helpers)

Functions to interact with WordPress behaviour.

### Plugin helper

[](#plugin-helper)

```
use Studiometa\WPToolkit\Helpers\PluginHelper;
// Check if a specified plugin is enable.
use Studiometa\WPToolkit\Helpers\PluginHelper;
PluginHelper::is_plugin_enabled( 'my-plugin/my-plugin.php' );
```

Transient Cleaner
-----------------

[](#transient-cleaner)

### Usage

[](#usage-1)

> **Important** Transients keys must be prefixed with transient cleaner prefix (`TransientCleaner::PREFIX`) to be tracked.

```
use Studiometa\WPToolkit\TransientCleaner;

// 1. Set a transient with transient cleaner prefix.
if ( $my_condition ) {
  set_transient(
    TransientCleaner::PREFIX . 'transient_key',
    'example'
  );
}

// 2. Initialize transient cleaner.
$transient_cleaner = TransientCleaner::get_instance(
  array(
    'post'   => array(
      'all'           => array(
        TransientCleaner::PREFIX . 'transient_key',
      ),
      'post_type_key' => array(
        TransientCleaner::PREFIX . 'transient_key',
        TransientCleaner::PREFIX . 'transient_key_1',
      )
    ),
    'term'   => array(
      'all'                    => array(),
      'your_taxonomy_type_key' => array(),
      'category'               => array(),
    ),
    'option' => array(
      'all'             => array(),
      'option_key'      => array(),
      'blogdescription' => array(),
    ),
  )
);

// Update config if needed.
$transient_cleaner->set_config(array());

// 3. Insert/Update post/term/option to see your transients deleted based on your config.
```

Contribute
----------

[](#contribute)

### Run tests

[](#run-tests)

#### PHPUnit

[](#phpunit)

```
# WP-tests must be installed before run PHPUnit (required a test MySQL database).
./bin/install-wp-tests.sh [dbname] [dbuser] [dbpasswd] [dbhost] [test_version]
composer run-script phpunit
```

Tests can be run in ddev which preconfigures the WordPress environment when starting:

```
ddev start
ddev exec phpunit
```

To test against different PHP version, you can edit the `.ddev/config.yaml` file and change the `php_version` property.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance60

Regular maintenance activity

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 72.3% 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 ~133 days

Recently: every ~127 days

Total

14

Last Release

214d ago

Major Versions

1.0.0 → 2.0.02024-03-08

PHP version history (3 changes)1.0.0-alpha1PHP ^7.3

1.0.0PHP ^7.3|^8.0

2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e88435dae9fed57464c2668f35d4c7dd7f874e55e9727972369538d639d6373?d=identicon)[titouanmathis](/maintainers/titouanmathis)

---

Top Contributors

[![titouanmathis](https://avatars.githubusercontent.com/u/250145?v=4)](https://github.com/titouanmathis "titouanmathis (133 commits)")[![lusimeon](https://avatars.githubusercontent.com/u/5418329?v=4)](https://github.com/lusimeon "lusimeon (36 commits)")[![perruche](https://avatars.githubusercontent.com/u/11503190?v=4)](https://github.com/perruche "perruche (8 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (4 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (3 commits)")

---

Tags

wordpresswordpress-development

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/studiometa-wp-toolkit/health.svg)

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

###  Alternatives

[contao/core-bundle

Contao Open Source CMS

1231.6M2.0k](/packages/contao-core-bundle)

PHPackages © 2026

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