Giter VIP home page Giter VIP logo

must-use-loader's Introduction

Must Use Loader

Latest Stable Version Maintainability License

This small plugin scan and include all plugins in subdirectories from the Must Use plugin folder.

Description

The WordPress Must Use Plugins are acceptable to include without doings in the back end. But WordPress does not load plugins in subdirectories. They must be at the root of the Must Use plugin directory, on default /wp-content/mu-plugins/. This small plugin scan includes all plugins in subdirectories from the Must Use plugin folder.

The plugin has a simple cache, and you flush this cache if you go to the network plugin page; view is enough.

Screenshots

List of Must Use Plugins, include the automatically loads in subdirectories

Installation

Manual

  1. Download the php file
  2. Copy to your Must Use plugin folder, default /wp-content/mu-plugins/
  3. Alternative define your Must Use folder in the wp-config.php and copy the plugin in this folder
  4. Check in the network plugin page, if it works

Alternative via Composer

The plugin is available as Composer package and can be installed via Composer.

composer require bueltge/must-use-loader

Or to create as a project in your environment.

composer create-project bueltge/must-use-loader --no-dev

The package is on packagist and the package name is bueltge/must-use-loader.

Alternative via Git

  1. Go to your Must Use folder cd path
  2. git init .
  3. git remote add origin https://github.com/bueltge/must-use-loader.git
  4. git fetch origin
  5. git checkout master
  6. Check in the network plugin page, if it works

Customization

Custom Must Use Plugin directory

Define it in the wp-config.php of your install, as the following source.

// Custom mu plugin directory
define( 'WPMU_PLUGIN_DIR', dirname( __FILE__ ) . '/wpmu-plugins' );
define( 'WPMU_PLUGIN_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wpmu-plugins' );

Exclude plugins from loader

On default, exclude the plugin all plugin files, there start with an underline _. But you can remove plugins detected by the "Must Use Loader" from the loading process by using the must_use_loader.mu_plugins filter. Example:

function prefix_unset_autoloading( $mu_plugins ) {

    unset( $mu_plugins['plugin-folder/plugin-file.php'] );
    return $mu_plugins;
}
add_filter( 'must_use_loader.mu_plugins', 'prefix_unset_autoloading' );

Other Notes

Bugs, technical hints or contribute

Please give me feedback, contribute and file technical bugs on this GitHub Repo, use Issues.

License

Good news, this plugin is free for everyone! Since it's released under the MIT, you can use it free of charge on your personal or commercial blog. But if you enjoy this plugin, you can thank me and leave a small donation for the time I've spent writing and supporting this plugin. And I don't want to know how many hours of my life this plugin has already eaten ;)

Contact & Feedback

The plugin is designed and developed by me (Frank Bültge, Twitter)

Please let me know if you like the plugin or you hate it or whatever ... Please fork it, add an issue for ideas and bugs.

Disclaimer

I'm German, and my English might be gruesome here and there. So please be patient with me and let me know of typos or grammatical farts. Thanks

must-use-loader's People

Contributors

bueltge avatar cfoellmann avatar dannyvanholten avatar dependabot-preview[bot] avatar joranschipper avatar nicolasmn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

must-use-loader's Issues

Only showing 4 plugins, no more

This works fine for 4 plugins. I add a new plugin and its not showing. I tried another plugin and its not showing. then another! Seems the only 4 plugins I initially added are showing. Is there some sort of caching, or something else I need to do?
Thanks

[Bug]: Loaded Plugins not shown in Site Health > Info > MU Plugins

Description of the bug

The primary plugins screen shows all the loaded MU plugins, however I would expect the Site Health > Info > Must Use Plugins section does not show the plugins loaded by the MU Loader.

Reproduction instructions

  1. Go to Tools > Site Health
  2. Navigate to the "Info" tab
  3. Expand the 'Must Use plugins' section
  4. Plugins listed here do not include those loaded by the MU Loader

Expected behavior

The Site Health > Info > Must Use Plugins section should show the same list as the Plugins > Must Use section, including those loaded by this loader.

Environment info

MU Loader v1.3.1
WP v6.3.1

Relevant log output

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature Request] Autoload via Composer

This plugin looks great and it has a lot of potential! Have you considered adding support for autoloading the plugin via Composer? Then we could skip the step to active the plugin via the WordPress dashboard.

Ability to exclude plugins from loader

Usecase:
I run (try to run) Mercator (https://github.com/humanmade/Mercator) for domain mapping. It is included in sunrise.php and the folder(s) sit in mu-plugins.
Now I don't want it to be loaded by the must-use-loader.

I wasn't sure if filters work so early but I tested and the code I added works. Not sure if there are any situations this can lead to issues.

Filter usage:

function prefix_unset_autoloading( $mu_plugins ) {

	unset($mu_plugins["mercator-gui/gui.php"]);
	unset($mu_plugins["mercator-sso/sso.php"]);

	return $mu_plugins;
}
add_filter( 'mustuse_loader_mu_plugins', 'prefix_unset_autoloading' );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.