{"id":22335002,"url":"https://github.com/wpsmith/mupluginmanager","last_synced_at":"2026-04-25T16:33:54.822Z","repository":{"id":57082377,"uuid":"262898470","full_name":"wpsmith/MuPluginManager","owner":"wpsmith","description":"A class to use in your WordPress plugin to install a MU Plugin auto-magically.","archived":false,"fork":false,"pushed_at":"2020-06-07T20:46:07.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T13:48:48.579Z","etag":null,"topics":["php","wordpress","wordpress-php-library"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/wpsmith/mupluginmanager","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wpsmith.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-11T00:04:25.000Z","updated_at":"2022-07-07T09:11:15.000Z","dependencies_parsed_at":"2022-08-24T14:58:20.531Z","dependency_job_id":null,"html_url":"https://github.com/wpsmith/MuPluginManager","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpsmith%2FMuPluginManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpsmith%2FMuPluginManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpsmith%2FMuPluginManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpsmith%2FMuPluginManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wpsmith","download_url":"https://codeload.github.com/wpsmith/MuPluginManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245614995,"owners_count":20644376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","wordpress","wordpress-php-library"],"created_at":"2024-12-04T05:11:13.790Z","updated_at":"2026-04-25T16:33:54.795Z","avatar_url":"https://github.com/wpsmith.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MuPluginManager\n\n[![Code Climate](https://codeclimate.com/github/wpsmith/MuPluginManager/badges/gpa.svg)](https://codeclimate.com/github/wpsmith/MuPluginManager)\n\nA class to use in your WordPress plugin to install a MU Plugin auto-magically.\n\n## Description\n\nThis 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\n\n## Installation\n\nThis isn't a WordPress plugin on its own, so the usual instructions don't apply. Instead you can install manually or using `composer`.\n\n### Manually install class\nCopy [`MuPluginManager/src`](src) folder into your plugin for basic usage. Be sure to require the various files accordingly.\n\nor:\n\n### Install class via Composer\n1. Tell Composer to install this class as a dependency: `composer require wpsmith/mupluginmanager`\n2. Recommended: Install the Mozart package: `composer require coenjacobs/mozart --dev` and [configure it](https://github.com/coenjacobs/mozart#configuration).\n3. The class then renamed to use your own prefix to prevent collisions with other plugins bundling this class.\n\n## Implementation \u0026 Usage\n\nConsider this basic plugin structure with the mu-plugin in its own folder for namespacing purposes:\n```bash\n|-- example.php\n|-- includes\n    |-- mu-plugin\n        |-- example-mu.php\n```\n\nSo then you can implement it like this:\n```php\nuse WPS\\WP\\MuPlugins\\MuPluginManager;\n\n/**\n * Gets the MU plugin manager.\n */\nfunction get_muplugin_manager() {\n    // Path to the actual MU plugin located within this plugin.\n    $src = plugin_dir_path( __FILE__ ) . 'includes/mu-plugin/my-mu-plugin.php';\n    $dest_filename = 'my-mu-plugin.php';\n    \n    new MuPluginManager( $src, $dest_filename, '0.0.1', 'my-mu-plugin-settings' );\n}\n\n// Register (de)activation hooks.\nregister_activation_hook( __FILE__, function() {\n    MuPluginManager::on_activation( get_muplugin_manager() );\n} );\nregister_deactivation_hook( __FILE__, function() {\n    try {\n        MuPluginManager::on_deactivation( get_muplugin_manager() );\n    } catch ( \\Exception $e ) {\n        MuPluginManager::write_log( 'MU Plugin threw an error' );\n        MuPluginManager::write_log( $e-\u003egetMessage() );\n    }\n} );\n```\n\nNow, 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.\n```php\nuse WPS\\WP\\MuPlugins\\MuPluginManager;\n\n/**\n * Gets the MU plugin manager.\n *\n * @return MuPluginManager MU plugin manager.\n */\nfunction get_muplugin_manager() {\n    static $mgr;\n    \n    if ( null !== $mgr ) {\n        return $mgr;\n    }\n\n    // Path to the actual MU plugin located within this plugin.\n    $src = plugin_dir_path( __FILE__ ) . 'mu-plugin/example-mu.php';\n    $dest_filename = 'my-mu-plugin.php';\n    \n    $mgr = new MuPluginManager( $src, $dest_filename, '0.0.1', 'my-mu-plugin-settings' );\n    \n    return $mgr;\n}\n\nadd_action( 'plugin_loaded', array( get_muplugin_manager(), 'add_hooks' ) );\n````\n## Change Log\n\nSee the [change log](CHANGELOG.md).\n\n## License\n\n[GPL 2.0 or later](LICENSE).\n\n## Contributions\n\nContributions are welcome - fork, fix and send pull requests against the `master` branch please.\n\n## Credits\n\nBuilt by [Travis Smith](https://twitter.com/wp_smith)  \nCopyright 2013-2020 [Travis Smith](https://wpsmith.net)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpsmith%2Fmupluginmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwpsmith%2Fmupluginmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpsmith%2Fmupluginmanager/lists"}