Add your own addons to EA4V

When you want to quickly code a feature or ask someone to add a simple feature to your website, the code can easily become messy—spread across multiple places and storing data inconsistently.

EA4V allows you to use it as an optimized framework to add your own features in a structured way, making them much easier to manage.

 

You can copy this guide and give it to anyone who wants to build custom features for EA4V.

Download ea4v-custom-addons

Extending EA4V with Custom Addons

EA4V allows you to create and register your own addons using the ea4v/addons filter.

This package includes a starter plugin called ea4v-custom-addons. You can use it as a base for building your own addons or as a reference to understand how the system works.

How It Works

When EA4V starts, it loads a list of addons from:

app/config/addons.config.php

Before loading them, EA4V passes this list through the filter:

ea4v/addons

This filter allows external plugins to register their own addons.

Each addon only needs:
– a unique key
– a path to its init.php file

Example:

add_filter(‘ea4v/addons’, function (array $addons): array {
$addons[‘my_addon’] = ‘/absolute/path/to/my-addon/init.php’;
return $addons;
});

EA4V will automatically require this file and load the addon the same way it loads its built-in addons.

Starter Plugin: ea4v-custom-addons

The ea4v-custom-addons plugin is a minimal example showing how to create an addon.

Plugin structure:

ea4v-custom-addons/
├── ea4v-custom-addons.php
└── addons/
└── hello-world/
├── init.php
├── controllers/
│ └── settings-controller.php
└── templates/
└── backend-settings.php

Main Plugin File

The file ea4v-custom-addons.php is responsible for registering addons with EA4V.

add_filter(‘ea4v/addons’, function (array $addons): array {
$addons[‘hello_world’] = EA4V_CUSTOM_ADDONS_PATH . ‘addons/hello-world/init.php’;
return $addons;
});

When EA4V loads addons, it will load this init.php file.

init.php

This file is the entry point of the addon.

You can bootstrap anything your addon needs here, such as controllers, hooks, or services.

Example:

require_once __DIR__ . ‘/controllers/settings-controller.php’;
new Controllers\Settings_Controller();

Settings Controller

This controller connects your addon to the EA4V settings system.

It uses two filters.

ea4v/settings/register
Used to define the settings schema.

public function register_schema($schema)
{
$schema[‘hello_world’] = Schema::Object([
‘enable_greeting’ => Schema::Bool()->default(true),
‘greeting_name’ => Schema::String()->default(‘World’),
]);

return $schema;
}

ea4v/settings/tabs
Used to add a tab to the EA4V settings page.

public function register_tabs($tabs)
{
$tabs[] = [
‘key’ => ‘hello_world’,
‘label’ => ‘Hello World’,
‘template’ => plugin_dir_path(__DIR__) . ‘templates/backend-settings.php’,
];

return $tabs;
}

Admin Template

This template renders the settings UI in the admin panel.

Example:

<template v-if=”!subtab”>
<div class=”ts-group”>
<div class=”ts-group-head”><h3>Hello World</h3></div>

<div class=”x-row”>
<?php Switcher_Model::render([
‘v-model’ => ‘config.hello_world.enable_greeting’,
‘label’ => ‘Enable Greeting’,
]) ?>
</div>
</div>
</template>

Reading Settings in Your Addon

After the settings are saved, you can access them anywhere using:

\EA4V\get(‘settings.hello_world.enable_greeting’);
\EA4V\get(‘settings.hello_world.greeting_name’);

Adding Another Addon

To add another addon:

1. Create an addon folder

addons/your-addon/
init.php

2. Register it in the main plugin

$addons[‘your_addon’] = EA4V_CUSTOM_ADDONS_PATH . ‘addons/your-addon/init.php’;

Once registered, EA4V will automatically load the addon.

Table of contents

Table of Contents

Must-Read Articles

This is a post/feature of . Explore .