PHPackages                             automattic/jetpack-config - 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. automattic/jetpack-config

ActiveJetpack-library[Utility &amp; Helpers](/categories/utility)

automattic/jetpack-config
=========================

Jetpack configuration package that initializes other packages and configures Jetpack's functionality. Can be used as a base for all variants of Jetpack package usage.

v3.1.1(11mo ago)33.6M—3.9%111GPL-2.0-or-laterPHPPHP &gt;=7.2CI failing

Since Jan 10Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Automattic/jetpack-config)[ Packagist](https://packagist.org/packages/automattic/jetpack-config)[ RSS](/packages/automattic-jetpack-config/feed)WikiDiscussions trunk Synced 1mo ago

READMEChangelog (1)Dependencies (14)Versions (63)Used By (11)

Jetpack Configuration
=====================

[](#jetpack-configuration)

Allows for enabling and initializing of Jetpack features provided by other packages.

Usage
=====

[](#usage)

Add this package as a dependency to your project:

```
composer require automattic/jetpack-config

```

Add every other package you're planning to configure:

```
composer require automattic/jetpack-sync
composer require automattic/jetpack-options
composer require automattic/jetpack-my-jetpack

```

In your code initialize the configuration package at or before plugins\_loaded priority 1:

```
use Automattic/Jetpack/Config;

// Configuring Jetpack as early as plugins_loaded priority 1
// to make sure every action handler gets properly set.
add_action( 'plugins_loaded', 'configure_jetpack', 1 );

function configure_jetpack() {
    $config = new Config();

    foreach (
        array(
            'sync',
            'tracking',
            'tos',
        )
        as $feature
    ) {
        $config->ensure( $feature );
    }
}

```

Adding your package to the config class
=======================================

[](#adding-your-package-to-the-config-class)

You can have your package initialized using the Config class by adding several things.

The configure method
--------------------

[](#the-configure-method)

It's better to have one static configure method in your package class. That method will be called early on the `plugins_loaded`hook. This way you can add your own `plugins_loaded` handlers with standard priority and they will get executed:

```
class Configurable_Package {

    public static function configure() {
        add_action( 'plugins_loaded', array( __CLASS__, 'on_plugins_loaded' );
    }

    public static function on_plugins_loaded() {
        self::do_interesting_stuff();
    }

}

```

The feature enabling method
---------------------------

[](#the-feature-enabling-method)

An enabling method should be added to the Config class and should only contain your configuration method call.

```

public function enable_configurable_package() {
    Configurable_Package::configure();

    return true;
}

```

Note that the method name should use the feature slug, in this case your feature slug is `configurable_package` for the sake of simplicity. When you're adding your feature it should be unique and recognizable, like `sync` or `tracking`.

The feature slug
----------------

[](#the-feature-slug)

To make sure the feature is supported by the Config class, you need to add its slug to the config class property:

```
    /**
     * The initial setting values.
     *
     * @var Array
     */
    protected $config = array(
        // ...
        'configurable_package' => false,
        // ...
    );

```

The ensure\_options call
------------------------

[](#the-ensure_options-call)

Each consumer will initialize your package from its own instance of the `Config` class, and each consumer can call `$config->ensure( 'your-feature', $options )` passing different options.

Your package will need to handle these options and decide what to do with them when different consumers pass diferent options.

You do that by creating a `ensure_options_{$package_slug}` method to the `Config` class. For example:

```

public function ensure_options_configurable_package() {
    $options = $this->get_feature_options( 'configurable_package' );
    Configurable_Package::handle_initialization_options( $options );
	return true;
}

```

This method will be called every time a different consumer "ensures" your feature and pass some options. It will run BEFORE the `enable_$feature` method is called, so your package must be prepare to receive and treat this options before it is initialized. By the time it is initialized, it should have received all the different options consumers have passed and decided what to do with them.

The ensure call
---------------

[](#the-ensure-call)

Finally you need to add a block that will check if your package is loaded and mark it to be initialized:

```
if ( $this->config['configurable_package'] ) {
    $this->ensure_class( 'Configurable_Package' ) && $this->ensure_feature( 'configurable_package' );
}

```

This code does three things: it checks whether the current setup has requested your package to be loaded. Next it checks if the class that you need for the package to run is present, and then it adds the hook handlers that initialize your class. After that you can use the config package's interface in a Jetpack package consumer application and load your package as shown in the first section of this README.

Config Package Dependencies
===========================

[](#config-package-dependencies)

The Config package does not have any composer package dependencies. The consumer plugins must require the packages that they need.

Before using a package class, the Config package will verify that the class exists using the `Config::ensure_class()` method. This allows the consumer plugins to use the Config package to enable and initialize Jetpack features while requiring only the packages that they need.

Using this package in your WordPress plugin
-------------------------------------------

[](#using-this-package-in-your-wordpress-plugin)

If you plan on using this package in your WordPress plugin, we would recommend that you use [Jetpack Autoloader](https://packagist.org/packages/automattic/jetpack-autoloader) as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.

Security
--------

[](#security)

Need to report a security vulnerability? Go to  or directly to our security bug bounty site .

License
-------

[](#license)

jetpack-config is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt)

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance73

Regular maintenance activity

Popularity46

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

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 ~39 days

Recently: every ~90 days

Total

51

Last Release

334d ago

Major Versions

v1.15.4 → v2.0.02023-11-20

v2.0.4 → v3.0.02024-11-14

PHP version history (2 changes)v2.0.0PHP &gt;=7.0

v3.0.0PHP &gt;=7.2

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/11609890f6e7a840715f4cfc9622d77ea64b7dfc024df5643fbf8471a18c00f3?d=identicon)[kraft](/maintainers/kraft)

![](https://www.gravatar.com/avatar/5326730499ec14e274f51b9bcc39db6aac0fb38b33849715aae0e2587a2b93df?d=identicon)[jeherve](/maintainers/jeherve)

![](https://www.gravatar.com/avatar/6e220e167e341c28b1aa10bf0bb0374999068329f8683d3187ee3cf6749b8837?d=identicon)[dereksmart](/maintainers/dereksmart)

---

Top Contributors

[![anomiex](https://avatars.githubusercontent.com/u/1030580?v=4)](https://github.com/anomiex "anomiex (78 commits)")[![tbradsha](https://avatars.githubusercontent.com/u/32492176?v=4)](https://github.com/tbradsha "tbradsha (20 commits)")[![jeherve](https://avatars.githubusercontent.com/u/426388?v=4)](https://github.com/jeherve "jeherve (19 commits)")[![zinigor](https://avatars.githubusercontent.com/u/374293?v=4)](https://github.com/zinigor "zinigor (17 commits)")[![samiff](https://avatars.githubusercontent.com/u/15803018?v=4)](https://github.com/samiff "samiff (14 commits)")[![kraftbj](https://avatars.githubusercontent.com/u/88897?v=4)](https://github.com/kraftbj "kraftbj (11 commits)")[![coder-karen](https://avatars.githubusercontent.com/u/16754605?v=4)](https://github.com/coder-karen "coder-karen (9 commits)")[![sdixon194](https://avatars.githubusercontent.com/u/33553323?v=4)](https://github.com/sdixon194 "sdixon194 (5 commits)")[![gmjuhasz](https://avatars.githubusercontent.com/u/36671565?v=4)](https://github.com/gmjuhasz "gmjuhasz (3 commits)")[![leogermani](https://avatars.githubusercontent.com/u/971483?v=4)](https://github.com/leogermani "leogermani (3 commits)")[![sergeymitr](https://avatars.githubusercontent.com/u/1341249?v=4)](https://github.com/sergeymitr "sergeymitr (3 commits)")[![bindlegirl](https://avatars.githubusercontent.com/u/1242807?v=4)](https://github.com/bindlegirl "bindlegirl (3 commits)")[![nunyvega](https://avatars.githubusercontent.com/u/16329583?v=4)](https://github.com/nunyvega "nunyvega (2 commits)")[![ice9js](https://avatars.githubusercontent.com/u/8056203?v=4)](https://github.com/ice9js "ice9js (2 commits)")[![zaerl](https://avatars.githubusercontent.com/u/167611?v=4)](https://github.com/zaerl "zaerl (2 commits)")[![manzoorwanijk](https://avatars.githubusercontent.com/u/18226415?v=4)](https://github.com/manzoorwanijk "manzoorwanijk (2 commits)")[![kangzj](https://avatars.githubusercontent.com/u/1425433?v=4)](https://github.com/kangzj "kangzj (2 commits)")[![miguelxpn](https://avatars.githubusercontent.com/u/12788275?v=4)](https://github.com/miguelxpn "miguelxpn (2 commits)")[![paulopmt1](https://avatars.githubusercontent.com/u/1044309?v=4)](https://github.com/paulopmt1 "paulopmt1 (1 commits)")[![jwebbdev](https://avatars.githubusercontent.com/u/1992658?v=4)](https://github.com/jwebbdev "jwebbdev (1 commits)")

---

Tags

jetpack

### Embed Badge

![Health badge](/badges/automattic-jetpack-config/health.svg)

```
[![Health](https://phpackages.com/badges/automattic-jetpack-config/health.svg)](https://phpackages.com/packages/automattic-jetpack-config)
```

###  Alternatives

[hellonico/acf-country

A country field for ACF.

12193.2k](/packages/hellonico-acf-country)[aimes/module-checkout-designs

Swap checkout layouts via system configuration, or conditions

3312.2k1](/packages/aimes-module-checkout-designs)

PHPackages © 2026

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