PHPackages                             wpsmith/mupluginmanager - 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. wpsmith/mupluginmanager

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

wpsmith/mupluginmanager
=======================

Manages the auto-installation of a mu-plugin for a plugin.

0.0.1(5y ago)114GPL-2.0+PHPPHP &gt;=7.0.0

Since Jun 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/wpsmith/MuPluginManager)[ Packagist](https://packagist.org/packages/wpsmith/mupluginmanager)[ Docs](https://github.com/wpsmith/MuPluginManager)[ RSS](/packages/wpsmith-mupluginmanager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

MuPluginManager
===============

[](#mupluginmanager)

[![Code Climate](https://camo.githubusercontent.com/a39351b1b218c2e40c6518aad3fc25e256cbc26ab0df93c0109a4554941397b5/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7770736d6974682f4d75506c7567696e4d616e616765722f6261646765732f6770612e737667)](https://codeclimate.com/github/wpsmith/MuPluginManager)

A class to use in your WordPress plugin to install a MU Plugin auto-magically.

Description
-----------

[](#description)

This class takes a file and installs the file in the `/mu-plugins/` folder. If the file already exists, it will compare the versions of the file

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

[](#installation)

This isn't a WordPress plugin on its own, so the usual instructions don't apply. Instead you can install manually or using `composer`.

### Manually install class

[](#manually-install-class)

Copy [`MuPluginManager/src`](src) folder into your plugin for basic usage. Be sure to require the various files accordingly.

or:

### Install class via Composer

[](#install-class-via-composer)

1. Tell Composer to install this class as a dependency: `composer require wpsmith/mupluginmanager`
2. Recommended: Install the Mozart package: `composer require coenjacobs/mozart --dev` and [configure it](https://github.com/coenjacobs/mozart#configuration).
3. The class then renamed to use your own prefix to prevent collisions with other plugins bundling this class.

Implementation &amp; Usage
--------------------------

[](#implementation--usage)

Consider this basic plugin structure with the mu-plugin in its own folder for namespacing purposes:

```
|-- example.php
|-- includes
    |-- mu-plugin
        |-- example-mu.php
```

So then you can implement it like this:

```
use WPS\WP\MuPlugins\MuPluginManager;

/**
 * Gets the MU plugin manager.
 */
function get_muplugin_manager() {
    // Path to the actual MU plugin located within this plugin.
    $src = plugin_dir_path( __FILE__ ) . 'includes/mu-plugin/my-mu-plugin.php';
    $dest_filename = 'my-mu-plugin.php';

    new MuPluginManager( $src, $dest_filename, '0.0.1', 'my-mu-plugin-settings' );
}

// Register (de)activation hooks.
register_activation_hook( __FILE__, function() {
    MuPluginManager::on_activation( get_muplugin_manager() );
} );
register_deactivation_hook( __FILE__, function() {
    try {
        MuPluginManager::on_deactivation( get_muplugin_manager() );
    } catch ( \Exception $e ) {
        MuPluginManager::write_log( 'MU Plugin threw an error' );
        MuPluginManager::write_log( $e->getMessage() );
    }
} );
```

Now, for whatever reason, you want to check for the MU plugin on more than just activation or deactivation, the class can run automagically on plugins admin page.

```
use WPS\WP\MuPlugins\MuPluginManager;

/**
 * Gets the MU plugin manager.
 *
 * @return MuPluginManager MU plugin manager.
 */
function get_muplugin_manager() {
    static $mgr;

    if ( null !== $mgr ) {
        return $mgr;
    }

    // Path to the actual MU plugin located within this plugin.
    $src = plugin_dir_path( __FILE__ ) . 'mu-plugin/example-mu.php';
    $dest_filename = 'my-mu-plugin.php';

    $mgr = new MuPluginManager( $src, $dest_filename, '0.0.1', 'my-mu-plugin-settings' );

    return $mgr;
}

add_action( 'plugin_loaded', array( get_muplugin_manager(), 'add_hooks' ) );
```

Change Log
----------

[](#change-log)

See the [change log](CHANGELOG.md).

License
-------

[](#license)

[GPL 2.0 or later](LICENSE).

Contributions
-------------

[](#contributions)

Contributions are welcome - fork, fix and send pull requests against the `master` branch please.

Credits
-------

[](#credits)

Built by [Travis Smith](https://twitter.com/wp_smith)
Copyright 2013-2020 [Travis Smith](https://wpsmith.net)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

2170d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/46adebc3eebe7494dba592e75ac8f8572222050648b0283515b4a5896648d846?d=identicon)[wpsmith](/maintainers/wpsmith)

---

Top Contributors

[![wpsmithtwc](https://avatars.githubusercontent.com/u/15801496?v=4)](https://github.com/wpsmithtwc "wpsmithtwc (3 commits)")[![wpsmith](https://avatars.githubusercontent.com/u/817366?v=4)](https://github.com/wpsmith "wpsmith (2 commits)")

---

Tags

phpwordpresswordpress-php-librarywordpresspluginsmu-plugins

### Embed Badge

![Health badge](/badges/wpsmith-mupluginmanager/health.svg)

```
[![Health](https://phpackages.com/badges/wpsmith-mupluginmanager/health.svg)](https://phpackages.com/packages/wpsmith-mupluginmanager)
```

###  Alternatives

[tgmpa/tgm-plugin-activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins).

1.8k222.5k13](/packages/tgmpa-tgm-plugin-activation)[aristath/kirki

Extending the WordPress customizer

1.3k73.0k4](/packages/aristath-kirki)[balbuf/composer-wp

Manage WordPress core, plugins, and themes with composer.

173.6k](/packages/balbuf-composer-wp)

PHPackages © 2026

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