PHPackages                             realtyna/wp-plugin-framework - 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. realtyna/wp-plugin-framework

ActiveLibrary[Framework](/categories/framework)

realtyna/wp-plugin-framework
============================

A framework for developing WordPress plugins with consistent design and structure.

1.0.7(1y ago)0661LGPL-3.0-or-laterPHPPHP &gt;=8.1CI failing

Since Aug 5Pushed 3mo ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (11)Used By (1)

Realtyna Base Plugin
====================

[](#realtyna-base-plugin)

[![WordPress Base Plugin Banner](https://camo.githubusercontent.com/ba7535ae94e9d869736e700c615412be8d2defcf7ea4e0ba6cda80b22402068b/68747470733a2f2f7265616c74796e612e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30352f6c6f676f2e706e67)](https://camo.githubusercontent.com/ba7535ae94e9d869736e700c615412be8d2defcf7ea4e0ba6cda80b22402068b/68747470733a2f2f7265616c74796e612e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30352f6c6f676f2e706e67)

Welcome to the Realtyna Base Plugin, a structured and scalable foundation for developing WordPress plugins. This framework is designed to simplify the process of plugin development by providing a set of tools and conventions, enabling developers to create robust and maintainable plugins.

Introduction
------------

[](#introduction)

Hi, I'm Chandler, and I'm here working for [Realtyna](https://realtyna.com/). I'm a Senior Backend/WordPress Developer. At Realtyna, we've developed numerous plugins, and this framework is the result of continuous improvement in our development process.

Previously, I created a WordPress framework called [Realtyna MVC Core](https://github.com/realtyna/Realtyna-MVC-Core), which you can find the documentation for [here](https://code.realtyna.com/mvc-core-docs). That structure served us well for almost a year. However, over time, I realized that we were relying heavily on third-party Composer packages that weren't essential. This prompted me to refactor the framework. The idea remains the same, but with what I believe is a much better execution this time.

I would love to hear your opinions and contributions to this project!

Features
--------

[](#features)

- **Modular Architecture**: Create plugins with a clear separation of concerns using components and subcomponents.
- **Settings Management**: Easily manage plugin settings with a centralized handler.
- **Database Migrations**: Utilize a migration system for database schema management.
- **Admin Page Management**: Simplify the creation and organization of admin pages with custom templates.
- **Custom Utilities**: Implement custom logging, helper functions, and more.
- **Abstract Classes**: Base classes for common WordPress functionalities like admin pages, custom post types, taxonomies, widgets, shortcodes, AJAX handlers, and REST API endpoints.

Documentation
-------------

[](#documentation)

Comprehensive documentation is available for developers of all levels:

- [Introduction](docs/Introduction.md)
- [Installation](docs/Installation.md)
- [Getting Started](docs/Getting_Started.md)
- [Core Concepts](docs/Core_Concepts.md)
- [Advanced Usage](docs/Advanced_Usage.md)
- [API Reference](docs/API_Reference.md)
- [Examples and Use Cases](docs/Examples_and_Use_Cases.md)
- [Release Script Guide](docs/release.md)
- [Troubleshooting and FAQ](docs/Troubleshooting_and_FAQ.md)
- [Contribution Guide](docs/Contribution_Guide.md)
- [Changelog](docs/Changelog.md)
- [License](docs/License.md)

Installation
------------

[](#installation)

### Creating the Base Plugin

[](#creating-the-base-plugin)

To create a new WordPress plugin using the Realtyna Base Plugin framework, you can use the following Composer command:

```
composer create-project realtyna/base-plugin {PluginName}
```

Replace `{PluginName}` with the desired name for your plugin. This command will generate the base structure for your new plugin and automatically update the namespace, constant name, plugin name, and configuration settings based on the project name you provide.

### Configuring Your Plugin

[](#configuring-your-plugin)

After running the `create-project` command, the script will automatically:

1. **Update Namespace**: The namespace in all class files will be updated to match your project name.
2. **Update Constant Name**: The constant name used throughout the project will reflect your plugin's name.
3. **Update Plugin Name**: The plugin name used in various parts of the code and configuration will be set to the name you provided.
4. **Configure `config.php`**: The `config.php` file will be updated to reflect your plugin’s name, slug, and text domain based on the project name.

#### Example Configuration

[](#example-configuration)

The `config.php` file located in the `./src/Config/config.php` directory will automatically be configured, but you can still customize additional settings if needed. Here’s an example:

```
return [
    'name' => 'Realtyna Base Plugin',
    'slug' => 'realtyna-base-plugin',
    'text-domain' => 'realtyna-base-plugin',
    'log' => [
        'active' => true,
        'level' => 'error',
        'path' => REALTYNA_BASE_PLUGIN_DIR . '/logs'
    ],
];
```

- **name**: The name of your plugin.
- **slug**: The slug used for your plugin (usually a lowercase, hyphen-separated version of the name).
- **text-domain**: The text domain used for translation purposes.
- **log**: Configuration for logging. Set `active` to `true` to enable logging, and specify the `level` of logging (e.g., `error`, `warning`, `info`).

### Overview of `Main.php`

[](#overview-of-mainphp)

The `Main.php` file is the heart of your plugin. It extends the `StartUp` class and handles the initialization of your plugin’s components, admin pages, logging, and database migrations.

#### Key Methods in `Main.php`:

[](#key-methods-in-mainphp)

- **components()**: Register your plugin’s components here. Each component is a separate class that encapsulates specific functionality, such as handling custom post types or AJAX requests.

    ```
    protected function components(): void
    {
        $this->addComponent(YourComponent::class);
    }
    ```
- **adminPages()**: Register admin pages for your plugin. Admin pages allow you to create custom interfaces in the WordPress dashboard.

    ```
    protected function adminPages(): void
    {
        $this->addAdminPage(YourAdminPage::class);
    }
    ```
- **boot()**: This method is used for bootstrapping your plugin, setting up the container, and initializing logging if configured.

    ```
    protected function boot(): void
    {
        // Set the container in the App class for global access.
        App::setContainer($this->container);
        if($this->config->get('log.active')){
            Log::init($this->config->get('log.path'), $this->config->get('log.level'));
        }
    }
    ```
- **migrations()**: Register database migrations here. Migrations handle changes to the database schema, such as creating or altering tables.

    ```
    protected function migrations(): void
    {
        $this->addMigration(CreateYourTableMigration::class);
    }
    ```

### Developing a Component

[](#developing-a-component)

Components are modular pieces of your plugin that handle specific tasks. For example, you might have a component for custom post types, another for handling AJAX requests, and another for registering REST API endpoints.

#### Example: Creating a Component

[](#example-creating-a-component)

Here is a basic example of how to create a component with all its features:

```
namespace MyCompany\MyPlugin\Components;

use Realtyna\MvcCore\Abstracts\ComponentAbstract;

class MyComponent extends ComponentAbstract
{
    public function register()
    {
        // Register your component actions and filters here
    }

    public function postTypes()
    {
        $this->addPostType(MyCustomPostType::class);
    }

    public function subComponents()
    {
        $this->addSubComponent(MySubComponent::class);
    }

    public function adminPages()
    {
        $this->addAdminPage(MyAdminPage::class);
    }

    public function ajaxHandlers()
    {
        $this->addAjaxHandler(MyAjaxHandler::class);
    }

    public function shortcodes()
    {
        $this->addShortcode(MyShortcode::class);
    }

    public function restApiEndpoints()
    {
        $this->addRestApiEndpoint(MyRestApiEndpoint::class);
    }

    public function widgets()
    {
        $this->addWidget(MyWidget::class);
    }

    public function customTaxonomies()
    {
        $this->addCustomTaxonomy(MyCustomTaxonomy::class);
    }
}
```

#### Key Methods in the Component:

[](#key-methods-in-the-component)

- **register()**: This method is where you register your component’s actions and filters with WordPress.
- **postTypes()**: Add custom post types handled by this component.
- **subComponents()**: If your component has subcomponents, register them here.
- **adminPages()**: Add any admin pages that belong to this component.
- **ajaxHandlers()**: Register AJAX handlers that will respond to AJAX requests.
- **shortcodes()**: Add any shortcodes provided by this component.
- **restApiEndpoints()**: Register any REST API endpoints.
- **widgets()**: Add custom widgets provided by this component.
- **customTaxonomies()**: Register any custom taxonomies.

By following this structure, you can build well-organized, maintainable, and scalable WordPress plugins using the Realtyna Base Plugin framework.

Contributing
------------

[](#contributing)

Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

Acknowledgements
----------------

[](#acknowledgements)

- Thanks to all the open-source projects that make development faster and easier.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance63

Regular maintenance activity

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.1% 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.

###  Release Activity

Cadence

Every ~24 days

Recently: every ~43 days

Total

8

Last Release

469d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f4416479e3d3dc9dba6e10985f03a2f11d07fac096e69924692265befa39663?d=identicon)[realtyna](/maintainers/realtyna)

---

Top Contributors

[![chandler-realtyna](https://avatars.githubusercontent.com/u/121955781?v=4)](https://github.com/chandler-realtyna "chandler-realtyna (41 commits)")[![realtyna](https://avatars.githubusercontent.com/u/121965832?v=4)](https://github.com/realtyna "realtyna (4 commits)")

---

Tags

pluginframeworkwordpress

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/realtyna-wp-plugin-framework/health.svg)

```
[![Health](https://phpackages.com/badges/realtyna-wp-plugin-framework/health.svg)](https://phpackages.com/packages/realtyna-wp-plugin-framework)
```

###  Alternatives

[redux-framework/redux-framework

Build better and beautiful sites in WordPress, faster.

1.8k6.2k](/packages/redux-framework-redux-framework)[metabolism/wordpress-bundle

Build enterprise solutions with WordPress

775.0k1](/packages/metabolism-wordpress-bundle)[alleyinteractive/pest-plugin-wordpress

WordPress Pest Integration

263.7k1](/packages/alleyinteractive-pest-plugin-wordpress)

PHPackages © 2026

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