Download the PHP package devuri/plugin-interface without Composer

On this page you can find all versions of the php package devuri/plugin-interface. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package plugin-interface

WordPress Plugin Interface

A simple PHP interface designed to provide a consistent structure for WordPress plugins. It defines a set of methods that any implementing class must adhere to, ensuring uniformity and ease of use across different plugins.

Installation

Simply include the PluginInterface.php file in your project, or install it via Composer:

Usage

Implementing the Plugin Interface

To create a plugin using the Plugin Interface, follow these steps:

  1. Implement the PluginInterface: Create a class that implements the PluginInterface. This class will define the behavior of your plugin.

  2. Define Class Properties: Define class properties to hold the plugin directory path and URL. These properties will be used as initialization parameters.

  3. Implement the init() Method: Implement the init() method to initialize your plugin. Use the class properties to set the plugin directory path and URL.

  4. Implement the hooks() Method: Implement the hooks() method to register any WordPress hooks (actions and filters) necessary for your plugin.

Using the Plugin Interface

To use a plugin that implements the Plugin Interface, follow these steps:

  1. Initialize the Plugin: Call the init() method of the plugin class, passing the plugin directory path and URL as parameters.

  2. Use the Plugin: Once initialized, you can use the plugin as needed. Any hooks registered by the plugin will be automatically executed by WordPress.

Example

Here's an example implementation of a plugin using the Plugin Interface:

Or you can also use the base abstract Implementation, which will include init() and the required properties $plugin_dir_path and $plugin_dir_url

Below is an example of how you can instantiate the plugin class, set the plugin path and url:

Explanation:

  1. Include Plugin Interface and Class: The PluginInterface is included to ensure the class adheres to the interface.

  2. Get Plugin Directory Path: The wp_plugin_dir_path() function is used to retrieve the directory path of the plugin file (__FILE__). This ensures that the plugin directory path is always accurate.

  3. Define Plugin URL: The plugin_dir_url() function is used to construct the URL of the plugin directory. This URL can be used to enqueue scripts, styles, or create links within the plugin.

  4. Initialize the Plugin: The init() method of the MyPlugin class is called, passing the plugin directory path and URL as parameters. This initializes an instance of the plugin is in the application.

  5. Call hooks() Method: Optionally, the hooks() method of the plugin class can be called to register any WordPress hooks necessary for the plugin's functionality.

Benefits:

using wp_plugin_dir_path() and plugin_dir_url() to set the plugin path and URL provides a robust approach to plugin development.

TraitInstalled

The TraitInstalled on AbstractPlugin provides utility methods to check if a WordPress plugin is installed and active. It helps manage plugin dependencies efficiently.

1. MyPlugin::is_installed($plugin_file)

Checks if a plugin is installed.

2. MyPlugin::is_active($plugin_file)

Checks if a plugin is active.

3. MyPlugin::get_installed_plugins()

Retrieves all installed plugins.

Example Usage

Check if a plugin is both installed and active:

Benefits of the Interface

License

This project is licensed under the MIT License - see the LICENSE file for details.


All versions of plugin-interface with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^7.4 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package devuri/plugin-interface contains the following files

Loading the files please wait ....