PHPackages                             alleyinteractive/wp-plugin-loader - 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. alleyinteractive/wp-plugin-loader

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

alleyinteractive/wp-plugin-loader
=================================

Code-enabled WordPress plugin loading

v1.0.1(10mo ago)2414.5k—6.6%1[1 PRs](https://github.com/alleyinteractive/wp-plugin-loader/pulls)GPL-2.0-or-laterPHPPHP ^8.1CI passing

Since Jul 21Pushed 1mo ago18 watchersCompare

[ Source](https://github.com/alleyinteractive/wp-plugin-loader)[ Packagist](https://packagist.org/packages/alleyinteractive/wp-plugin-loader)[ Docs](https://github.com/alleyinteractive/wp-plugin-loader)[ RSS](/packages/alleyinteractive-wp-plugin-loader/feed)WikiDiscussions develop Synced 2w ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

WP Plugin Loader
================

[](#wp-plugin-loader)

Code-enabled WordPress plugin loading package.

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

[](#installation)

You can install the package via Composer:

```
composer require alleyinteractive/wp-plugin-loader
```

Usage
-----

[](#usage)

Load the package via Composer and use it like so:

```
use Alley\WP\WP_Plugin_Loader;

new WP_Plugin_Loader( [
	'plugin/plugin.php',
	'plugin-name-without-file',
] );
```

The plugin loader will load the specified plugins, be it files or folders under `plugins`/`client-mu-plugins`, and mark them as activated on the plugins screen. You can pass files or plugin folders that the package will attempt to determine the main plugin file from and load.

See [APCu Caching](#apcu-caching) for more information on caching.

### Fluent Loading

[](#fluent-loading)

The package supports a fluent API for loading plugins with the `create()` method:

```
use Alley\WP\WP_Plugin_Loader;

WP_Plugin_Loader::create()
	->add( 'plugin/plugin.php' )
	->add( [
		'plugin-name-without-file',
		'another-plugin',
	] )
	->load();
```

You can also use the `when()` method to conditionally load plugins:

```
use Alley\WP\WP_Plugin_Loader;

WP_Plugin_Loader::create()
	->add( 'plugin/plugin.php' )
	->when( fn () => 'production' !== wp_get_environment_type(), 'logger' )
	->load();
```

This pairs nicely with named arguments:

```
use Alley\WP\WP_Plugin_Loader;

WP_Plugin_Loader::create()
	->add( 'plugin/plugin.php' )
	->when(
		condition: fn () => 'production' !== wp_get_environment_type(),
		plugin: 'logger',
	)
	->load();
```

When using fluent loading you must call the `load()` method to load the plugins at the end of the chain.

### Plugin Directories

[](#plugin-directories)

Out of the box, the package will attempt to load your plugin from `wp-content/plugins`. When it is found, the package will attempt to load your plugin from `wp-content/client-mu-plugins`. For non-WordPress VIP sites, the plugin will also load plugins from `wp-content/mu-plugins`.

### Preventing Activations

[](#preventing-activations)

The package supports preventing activations of plugins via the plugins screen (useful to fully lock down the plugins enabled on site):

```
use Alley\WP\WP_Plugin_Loader;

( new WP_Plugin_Loader( [ ... ] )->prevent_activations();
```

Plugin activations will be prevented on the plugin screen as well as with a capability check.

### APCu Caching

[](#apcu-caching)

When a plugin is loaded by a directory name the package will attempt to determine the main plugin file from the directory. This can be a semi-expensive operation that can be cached with APCu. To enable caching, pass `$cache` to the constructor with a boolean or string prefix:

```
use Alley\WP\WP_Plugin_Loader;

new WP_Plugin_Loader( plugins: [ ... ], cache: true );

new WP_Plugin_Loader( plugins: [ ... ], cache: 'my-prefix' );
```

Note: caching will only be enabled if APCu is available.

Testing
-------

[](#testing)

Run `composer test` to run tests against PHPUnit and the PHP code in the plugin.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

This project is actively maintained by [Alley Interactive](https://github.com/alleyinteractive). Like what you see? [Come work with us](https://alley.com/careers/).

- [Sean Fisher](https://github.com/srtfisher)
- [All Contributors](../../contributors)

License
-------

[](#license)

The GNU General Public License (GPL) license. Please see [License File](LICENSE) for more information.

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance73

Regular maintenance activity

Popularity40

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 77.2% 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 ~88 days

Total

10

Last Release

321d ago

Major Versions

v0.2.0 → v1.0.02025-03-10

PHP version history (2 changes)v0.1.0PHP ^8.0

v0.2.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/338d27065b1074f2d66d049d742f22996dd137eef6f91bc8f75350ceee1e8ef2?d=identicon)[srtfisher](/maintainers/srtfisher)

---

Top Contributors

[![srtfisher](https://avatars.githubusercontent.com/u/346399?v=4)](https://github.com/srtfisher "srtfisher (44 commits)")[![dlh01](https://avatars.githubusercontent.com/u/697432?v=4)](https://github.com/dlh01 "dlh01 (4 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

wordpresswordpress-packagewordpress-php-libraryalleyinteractivewp-plugin-loader

### Embed Badge

![Health badge](/badges/alleyinteractive-wp-plugin-loader/health.svg)

```
[![Health](https://phpackages.com/badges/alleyinteractive-wp-plugin-loader/health.svg)](https://phpackages.com/packages/alleyinteractive-wp-plugin-loader)
```

###  Alternatives

[alleyinteractive/wp-block-converter

Convert HTML into Gutenberg Blocks with PHP

68460.5k2](/packages/alleyinteractive-wp-block-converter)[alleyinteractive/wp-alleyvate

Defaults for WordPress sites by Alley.

3545.2k](/packages/alleyinteractive-wp-alleyvate)[alleyinteractive/wp-curate

Plugin to curate homepages and other landing pages

11268.5k](/packages/alleyinteractive-wp-curate)[alleyinteractive/feed-consumer

Ingest external feeds and other data sources into WordPress

117.1k](/packages/alleyinteractive-feed-consumer)[alleyinteractive/wp-bulk-task

A library to assist with running performant bulk tasks against WordPress objects.

21462.8k5](/packages/alleyinteractive-wp-bulk-task)

PHPackages © 2026

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