Git Product home page Git Product logo

wp-plugin-loader's Introduction

WP Plugin Loader

Code-enabled WordPress plugin loading package.

Installation

You can install the package via Composer:

composer require alleyinteractive/wp-plugin-loader

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 for more information on caching.

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

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

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, call enable_caching() or set_cache_prefix( $prefix ) to specify a custom cache prefix.

use Alley\WP\WP_Plugin_Loader;

( new WP_Plugin_Loader( [ ... ] ) )->enable_caching();

( new WP_Plugin_Loader( [ ... ] ) )->set_cache_prefix( 'my-prefix' );

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

Testing

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

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

This project is actively maintained by Alley Interactive. Like what you see? Come work with us.

License

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

wp-plugin-loader's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar srtfisher avatar

Watchers

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

wp-plugin-loader's Issues

Tests

Description

I would like to see unit tests included here.

Use Case

I should be able to use this package with unit tests.

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.