PHPackages                             devuri/plugin-interface - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. devuri/plugin-interface

ActiveLibrary[Framework](/categories/framework)

devuri/plugin-interface
=======================

A simple PHP interface designed to provide a consistent structure for WordPress plugins.

0.2.2(1y ago)13.7k1MITPHPPHP ^7.3 || ^7.4 || ^8.0CI passing

Since Mar 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/devuri/plugin-interface)[ Packagist](https://packagist.org/packages/devuri/plugin-interface)[ RSS](/packages/devuri-plugin-interface/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (5)Used By (1)

WordPress 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
------------

[](#installation)

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

```
composer require devuri/plugin-interface
```

Usage
-----

[](#usage)

### Implementing the Plugin Interface

[](#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

[](#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
-------

[](#example)

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

```
