PHPackages                             felixarntz/leavesandlove-wp-plugin-util - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. felixarntz/leavesandlove-wp-plugin-util

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

felixarntz/leavesandlove-wp-plugin-util
=======================================

This is a library to initialize WordPress plugins in a proper fashion, making usual processes a lot easier to handle and adding a few useful features, for example plugin dependency management or automatic multisite-compatibility.

2.0.3(9y ago)01.1k4GPL-3.0PHP

Since Apr 11Pushed 9y ago1 watchersCompare

[ Source](https://github.com/felixarntz/leavesandlove-wp-plugin-util)[ Packagist](https://packagist.org/packages/felixarntz/leavesandlove-wp-plugin-util)[ RSS](/packages/felixarntz-leavesandlove-wp-plugin-util/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (20)Used By (4)

[![Latest Stable Version](https://camo.githubusercontent.com/5f1d838cdbe7846aa306b74611b432ec4c3fee4eb5cd9dfe4ea9b5d55943c20d/68747470733a2f2f706f7365722e707567782e6f72672f66656c697861726e747a2f6c6561766573616e646c6f76652d77702d706c7567696e2d7574696c2f76657273696f6e)](https://packagist.org/packages/felixarntz/leavesandlove-wp-plugin-util)[![License](https://camo.githubusercontent.com/912794a6dbbbc0c46cb837331df9c0d42d103e2be6051503aa2cd73d4b21c9ff/68747470733a2f2f706f7365722e707567782e6f72672f66656c697861726e747a2f6c6561766573616e646c6f76652d77702d706c7567696e2d7574696c2f6c6963656e7365)](https://packagist.org/packages/felixarntz/leavesandlove-wp-plugin-util)

LaL WP Plugin Util
==================

[](#lal-wp-plugin-util)

This is a library to initialize WordPress plugins in a proper fashion, making usual processes a lot easier to handle and adding a few useful features, for example plugin dependency management or automatic multisite-compatibility. I originally developed this library to use it in my own plugins, but version 2.0.0 marks its initial public release.

Features
--------

[](#features)

- use WordPress plugin initialization best practices
- provide minimum required PHP and WordPress version
- provide other plugins (including minimum versions) as dependencies (optional)
- fail gracefully if any of the required dependencies are not met and show a helpful admin notice
- show plugin installation / activation / update links for plugin dependencies that are not met
- easily handle plugin installation, uninstallation, activation and deactivation by simply providing one method for each (optional) - it is automatically multisite-compatible
- allow the plugin to be used as a regular plugin, a must-use plugin or (if you provide an `is_library` argument with value `true`) even bundled as a library inside another plugin, must-use plugin or theme
- automatically handle textdomain loading, whether you use local .po files or wordpress.org language packs
- show a (permanently dismissible) status message in the admin when the plugin is activated (optional)
- easily add custom links to the plugin's row in the plugins list table (optional)
- have useful utility functions of your plugin already available, like getting absolute paths and URLs, the current plugin version or PHP notice generators (in case someone messes with your plugin)

This library uses WordPress best practices to initialize plugins and enhances the default behavior only where necessary - it does not reinvent the wheel or bloat the admin with dozens of internal settings.

Requirements
------------

[](#requirements)

Your plugin itself must:

- require at least PHP 5.3 and WordPress 3.5 (don't worry, the plugin loader will fail gracefully if a user with a lower version tries to run the plugin)
- use namespaces and composer (and preferably use autoloading)
- have a main initialization class called `App` which resides in your plugin's root namespace
- store local translation files (if needed) in an immediate plugin subdirectory `/languages/`

Getting Started
---------------

[](#getting-started)

To use the library, first add it to your project by adding it to your composer.json (`composer require felixarntz/leavesandlove-wp-plugin-util:2.0.1`). The library uses autoloading to load its classes. It is recommended that you also use autoloading with your plugin's own files.

Your plugin must have a main initialization class which is called `App` and resides in your plugin's root namespace (do not put this class in the actual plugin main file!). This main class must extend the `LaL_WP_Plugin` class bundled in this library. For more information on how to extend this class, please check out [it's PHPDoc block](https://github.com/felixarntz/leavesandlove-wp-plugin-util/blob/master/leavesandlove-wp-plugin.php#L13). See a little bit further below for a basic example of what that class could look like.

Then you initialize the main class from your plugin's main file. The following code snippet gives you an example:

```
