New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WordPress Must Use (MU) Plugins #76

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
7 participants
@bradydoll
Contributor

bradydoll commented May 10, 2013

Adds support for the WordPress must use plugins directory (mu-plugins). This directory is for WordPress plugins that are automatically loaded. This new installer type is called wordpress-muplugin.

See http://codex.wordpress.org/Must_Use_Plugins for more information about this directory.

Brady Doll
Add support for WordPress Must Use (MU) Plugins
Adds support for the WordPress must use plugins directory (mu-plugins).  This directory is for WordPress plugins that are automatically loaded.  This new installer type is called `wordpress-muplugin`.
@romulodl

This comment has been minimized.

Show comment
Hide comment
@romulodl

romulodl commented May 21, 2013

👍

@shama shama closed this in 3e2a526 May 23, 2013

@shama

This comment has been minimized.

Show comment
Hide comment
@shama

shama May 23, 2013

Contributor

Merged thanks!

Contributor

shama commented May 23, 2013

Merged thanks!

@sbuzonas

This comment has been minimized.

Show comment
Hide comment
@sbuzonas

sbuzonas May 31, 2013

Contributor

I'm not quite sure how this works? @bradydoll how is your installation configured to handle this? WordPress only loads files directly in mu-plugins so wp-content/mu-plugins/{$name}/ will install the plugin in a subdirectory that gets passed over.

Contributor

sbuzonas commented May 31, 2013

I'm not quite sure how this works? @bradydoll how is your installation configured to handle this? WordPress only loads files directly in mu-plugins so wp-content/mu-plugins/{$name}/ will install the plugin in a subdirectory that gets passed over.

@lavoiesl

This comment has been minimized.

Show comment
Hide comment
@lavoiesl

lavoiesl Aug 20, 2013

+1 for @slbmeh, this solution does not work.

The plugin file must be directly at wp-content/mu-plugins/{$name}.php, not a subdirectory.

lavoiesl commented Aug 20, 2013

+1 for @slbmeh, this solution does not work.

The plugin file must be directly at wp-content/mu-plugins/{$name}.php, not a subdirectory.

@shama

This comment has been minimized.

Show comment
Hide comment
@shama

shama Aug 20, 2013

Contributor

@bradydoll Any comment in response to the above two comments?

Contributor

shama commented Aug 20, 2013

@bradydoll Any comment in response to the above two comments?

@lavoiesl

This comment has been minimized.

Show comment
Hide comment

lavoiesl commented Aug 22, 2013

@lavoiesl

This comment has been minimized.

Show comment
Hide comment
@lavoiesl

lavoiesl Oct 11, 2013

Any update on this ?

lavoiesl commented Oct 11, 2013

Any update on this ?

@ddebernardy

This comment has been minimized.

Show comment
Hide comment
@ddebernardy

ddebernardy Feb 6, 2014

@lavoiesl re your solution, you'll actually be better off manually adding (and committing) a php file into your wp-content/mu-plugins folder.

ddebernardy commented Feb 6, 2014

@lavoiesl re your solution, you'll actually be better off manually adding (and committing) a php file into your wp-content/mu-plugins folder.

@lavoiesl

This comment has been minimized.

Show comment
Hide comment
@lavoiesl

lavoiesl Feb 6, 2014

@ddebernardy no, because that way, the file is tied to your project, you lose all the benefits of having composer manage the updates. I have been using this solution since and it’s wonderful.

lavoiesl commented Feb 6, 2014

@ddebernardy no, because that way, the file is tied to your project, you lose all the benefits of having composer manage the updates. I have been using this solution since and it’s wonderful.

@ddebernardy

This comment has been minimized.

Show comment
Hide comment
@ddebernardy

ddebernardy Feb 6, 2014

No no, you misunderstood me. I meant that you should just add a file named after the mu-plugin:

# wp-content/mu-plugins/example.php:
<?php
require __DIR__.'/example/example.php'

ddebernardy commented Feb 6, 2014

No no, you misunderstood me. I meant that you should just add a file named after the mu-plugin:

# wp-content/mu-plugins/example.php:
<?php
require __DIR__.'/example/example.php'
@lavoiesl

This comment has been minimized.

Show comment
Hide comment
@lavoiesl

lavoiesl Feb 6, 2014

I believe that kinda defeats the purpose. Anyway, whatever works for you.

lavoiesl commented Feb 6, 2014

I believe that kinda defeats the purpose. Anyway, whatever works for you.

@shama

This comment has been minimized.

Show comment
Hide comment
@shama

shama Feb 6, 2014

Contributor

@lavoiesl If you got time, I'd be happy to take a PR that fixes this. I am unfamiliar with wordpress MU plugins. Thanks!

Contributor

shama commented Feb 6, 2014

@lavoiesl If you got time, I'd be happy to take a PR that fixes this. I am unfamiliar with wordpress MU plugins. Thanks!

@ddebernardy

This comment has been minimized.

Show comment
Hide comment
@ddebernardy

ddebernardy Feb 6, 2014

Well, it's certainly better than nothing. Apart from that, yeah, it ideally ought to get added by configuring post-install and post-update commands as is done in Symfony:

"scripts": {
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ],
    "post-update-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ]
},

ddebernardy commented Feb 6, 2014

Well, it's certainly better than nothing. Apart from that, yeah, it ideally ought to get added by configuring post-install and post-update commands as is done in Symfony:

"scripts": {
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ],
    "post-update-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ]
},
@lavoiesl

This comment has been minimized.

Show comment
Hide comment
@lavoiesl

lavoiesl Feb 6, 2014

I cannot write a PR because Composer does not support install hooks.
At the end of the day, a file must be copied to wp-content/mu-plugins.

However, here is a rewritten mu-loader: https://github.com/wemakecustom/wp-mu-loader
It only requires you to copy or symlink a tiny file to wp-content/mu-plugins.

lavoiesl commented Feb 6, 2014

I cannot write a PR because Composer does not support install hooks.
At the end of the day, a file must be copied to wp-content/mu-plugins.

However, here is a rewritten mu-loader: https://github.com/wemakecustom/wp-mu-loader
It only requires you to copy or symlink a tiny file to wp-content/mu-plugins.

@ddebernardy

This comment has been minimized.

Show comment
Hide comment
@ddebernardy

ddebernardy Feb 7, 2014

@lavoiesl: Actually, my understanding is it does: https://getcomposer.org/doc/articles/scripts.md

I'll try to look into it during the WE or early next week if you don't. (There are a few example scripts in Symfony.)

@lavoiesl @shama The more I think about it, the more convinced I am that the wordpress-muplugin type is some kind of an aberration in its current form.

When you define a plugin's composer.json file, you seldom if ever use the wordpress-muplugin type, preferring the wordpress-plugin type instead.

What's actually needed, I think, is basically this:

  • The ability to override the wordpress-plugin type defined by the plugin, without needing to define a package repo. (Btw: is that already possible? I couldn't find how in the docs.)
  • Use a post-install/post-update script to toss in extra files (or add symb links) in the mu-plugins folder

Regarding that first point, I mean not needing to define a repository like so:

    {
        "type": "package",
        "package": {
            "name": "vendor/wp-plugin-name",
            "type": "wordpress-muplugin",
            "version": "dev-master",
            "source": {
                "url": "git@example.com:wp/plugins/name.git",
                "type": "git",
                "reference": "origin/master"
            },
            "extra": {
                "installer-name": "name"
            }
        }
    },

The path of least resistance at the moment is to override the install folder for individual plugins and add some kind of loader in the mu-plugins folder — both of which kind of suck.

ddebernardy commented Feb 7, 2014

@lavoiesl: Actually, my understanding is it does: https://getcomposer.org/doc/articles/scripts.md

I'll try to look into it during the WE or early next week if you don't. (There are a few example scripts in Symfony.)

@lavoiesl @shama The more I think about it, the more convinced I am that the wordpress-muplugin type is some kind of an aberration in its current form.

When you define a plugin's composer.json file, you seldom if ever use the wordpress-muplugin type, preferring the wordpress-plugin type instead.

What's actually needed, I think, is basically this:

  • The ability to override the wordpress-plugin type defined by the plugin, without needing to define a package repo. (Btw: is that already possible? I couldn't find how in the docs.)
  • Use a post-install/post-update script to toss in extra files (or add symb links) in the mu-plugins folder

Regarding that first point, I mean not needing to define a repository like so:

    {
        "type": "package",
        "package": {
            "name": "vendor/wp-plugin-name",
            "type": "wordpress-muplugin",
            "version": "dev-master",
            "source": {
                "url": "git@example.com:wp/plugins/name.git",
                "type": "git",
                "reference": "origin/master"
            },
            "extra": {
                "installer-name": "name"
            }
        }
    },

The path of least resistance at the moment is to override the install folder for individual plugins and add some kind of loader in the mu-plugins folder — both of which kind of suck.

@AlchemyUnited

This comment has been minimized.

Show comment
Hide comment
@AlchemyUnited

AlchemyUnited Feb 23, 2017

I realize this is an old thread but I just bumped into this. In any case, here's a needs-to-be-updated "plugin" I use with mu-plugins. You have to do some manual editing (which kinda sorta isn't what mu-plugins is for) but in the end you gain control AND a better folder structure, as WP wants everything to be in main mu-plugins folder.

https://github.com/WPezPlugins/wp-ezmu-plugins

I have made some changes to this but haven't bothered to update the repo. (Sorry.) If anyone is interest LMK and I'll move it up my priority list.

AlchemyUnited commented Feb 23, 2017

I realize this is an old thread but I just bumped into this. In any case, here's a needs-to-be-updated "plugin" I use with mu-plugins. You have to do some manual editing (which kinda sorta isn't what mu-plugins is for) but in the end you gain control AND a better folder structure, as WP wants everything to be in main mu-plugins folder.

https://github.com/WPezPlugins/wp-ezmu-plugins

I have made some changes to this but haven't bothered to update the repo. (Sorry.) If anyone is interest LMK and I'll move it up my priority list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment