PHPackages                             wbf/pluginsframework - 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. wbf/pluginsframework

ActiveLibrary

wbf/pluginsframework
====================

An helper component for Wordpress plugin development

114PHP

Since Sep 28Pushed 8y ago3 watchersCompare

[ Source](https://github.com/wagaweb/wbf_pluginsframework)[ Packagist](https://packagist.org/packages/wbf/pluginsframework)[ RSS](/packages/wbf-pluginsframework/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Plugins Framework
=================

[](#plugins-framework)

Plugins Framework component is an set of tools and extensible classes to help WordPress plugins developers.

It supports a "convention over configuration" principle to keep the environment clean and maintainable.

Getting started
---------------

[](#getting-started)

You start the development of a new plugin either by extending BasePlugin or TemplatePlugin.

The latter makes available a set of methods to add theme-overridable templates to the plugin.

### Simple plugin

[](#simple-plugin)

You can check out [here](https://github.com/wagaweb/wbf-sample-plugin) a barebone plugin.

BasePlugin takes care of:

- Initializing useful vars like `plugin_dir`, `plugin_path`, `plugin_relative_dir`, ect...
- Setting up the localization domain
- Linking together a standard "convention over configuration" structure (see below)
- Storing actions and filters added by plugin

And provides a number of useful functions:

- A complete caching mechanism based on transients
- The ability to setup a custom update server
- and much more...

### Plugin directories structure

[](#plugin-directories-structure)

WBF Plugin Framework supports an arbitrary standardized structure to enhance plugins maintainability.

The most basic plugin structure is the shown below:

```
.
|-src/
|---includes/
|-----index.php
|-----wbf-plugin-check-functions.php
|---Plugin.php
|-index.php
|-waboot-sample.php

```

If you want to split the code for the frontend from the code for the dashboard, you can use a structure like this:

```
.
|-src/
|---includes/
|-----index.php
|-----wbf-plugin-check-functions.php
|---Admin.php
|---Frontend.php
|---Plugin.php
|-index.php
|-waboot-sample.php

```

The framework automatically recognizes the structure and links Plugin, Admin and Frontend class instances together.

The Loader instance within Plugin will receive a reference to both Frontend and Admin, and those instances will receive a reference to Plugin in their constructors.

A practical example can be found [here](https://github.com/wagaweb/wbf-sample-plugin/tree/standard-structure-base).

If you have a complex plugin with many classes and files, you can choose to further split the structure:

```
.
|-src/
|---includes/
|-----index.php
|-----wbf-plugin-check-functions.php
|---admin/
|-----Admin.php
|-----more-files...
|-----more-files...
|---frontend/
|-----Frontend.php
|-----more-files...
|-----more-files...
|---Plugin.php
|-index.php
|-waboot-sample.php

```

An example can be found [here](https://github.com/wagaweb/wbf-sample-plugin/tree/standard-structure-complex).

### Template plugin

[](#template-plugin)

Plugins that extends TemplatePlugin can inject their template into Wordpress "template\_include" mechanism.

**Register common templates**

You can add a common wordpress template (selectable through admin dashboard) with:

```
$this->add_template("Custom Page Template",$this->get_src_dir()."/templates/custom-page-template.php");
```

**Register hierarchy templates**

The hierarchy templates are loaded automatically. During 'init' the framework register any templates (not previously registered) under `/src/templates` as hierarchy template. Then during 'template\_include' it will serve any registered templates not overridden by the theme from the plugin directory.

You can manually register hierarchy template with:

```
$this->add_hierarchy_template("single-sample-post-type.php", $this->get_src_dir()."/custom_hierarchy_templates/single-sample-post-type.php");
```

An example con be found [here](https://github.com/wagaweb/wbf-sample-plugin/tree/template-plugin-standard).

### More features

[](#more-features)

**Using built-in cache mechanism**

BasePlugin has a built-in caching feature based on transients which allows to easily organize them in groups and nodes.

The two main methods are: `maybe_set_transient()` and `maybe_get_transient()`.

Any transient name added with set method will be prefixed with plugin name, for example, given "sample-plugin" as plugin name: `maybe_set_transient("posts")` will create a transient named: `sample-plugin[posts]`; "posts" will become a new "node type".

You can create node part by putting a colon between the node type name and the node part id. For example, let's say you have a gallery post type, and you want to cache the images in each gallery: you can achieve that with something similiar to:

```
//Somewhere in plugin:
$this->loader->add_action("save_post", $this, "cache_my_images")

//Somewhere else:
public function cache_my_images($post_id){
    //Checking... checking....
    $this->maybe_set_transient("gallery:{$post_id}");
}
```

Then you can selectively retrieve or delete the cache. For example:

```
//Delete the cache for the gallery with ID 12
$this->clear_transients("gallery",12)

//Delete the caches for all galleries
$this->clear_transients("gallery")

//Delete all transients
$this->clear_transients()
```

**Adding custom links for the plugin in Wordpress plugins list**

From constructor of the class that extends BasePlugin:

```
$this->add_action_links([
    [
        'name' => "New link"
        'link' => "/path/to/link"
    ],
    //more links
]);
```

**Setting up an update server**

From the constructor of the class that extends BasePlugin: \[...\]

```
$this->set_update_server("my/end/point");
```

Endpoint must be compatible with CustomUpdater WBF component.

For more info about CustomUpdater WBF component: [click here](https://github.com/wagaweb/wbf/tree/master/src/components/customupdater).

**Register a license**

From the constructor of the class that extends BasePlugin:

```
$license = new \My\License("my-license"); //a class which extends \WBF\components\license\License and implements \WBF\components\license\Licence_Interface
$this->register_license($license);
```

You can also link a license to the custom updater (the update will be blocked with invalid licenses)

```
$license = new \My\License("my-license");
$this->set_update_server("my/end/point",$license);
```

For more info about License WBF component: [click here](https://github.com/wagaweb/wbf/tree/master/src/components/license).

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ecab5a59cfdd434af4feb082bcb4c24e264ea99574713c876789c3ea8a088c65?d=identicon)[Waga Dev](/maintainers/Waga%20Dev)

---

Top Contributors

[![LostCore](https://avatars.githubusercontent.com/u/2674299?v=4)](https://github.com/LostCore "LostCore (37 commits)")

### Embed Badge

![Health badge](/badges/wbf-pluginsframework/health.svg)

```
[![Health](https://phpackages.com/badges/wbf-pluginsframework/health.svg)](https://phpackages.com/packages/wbf-pluginsframework)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
