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. [Utility &amp; Helpers](/categories/utility)
4. /
5. studiometa/wp-toolkit

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

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

WordPress utilities for Studio Meta.

2.3.1(10mo ago)912.1k↑222.2%1[2 issues](https://github.com/studiometa/wp-toolkit/issues)[4 PRs](https://github.com/studiometa/wp-toolkit/pulls)1MITPHPPHP ^8.1CI passing

Since Nov 17Pushed 10mo 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 3w ago

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

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

47

—

FairBetter than 93% of packages

Maintenance50

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 88.1% 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

308d 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)")[![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)")[![lusimeon](https://avatars.githubusercontent.com/u/5418329?v=4)](https://github.com/lusimeon "lusimeon (3 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

[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M514](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19564.8M1.6k](/packages/drupal-core)

PHPackages © 2026

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