Download the PHP package realtyna/wp-plugin-framework without Composer
On this page you can find all versions of the php package realtyna/wp-plugin-framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package wp-plugin-framework
Realtyna Base Plugin
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
Hi, I'm Chandler, and I'm here working for Realtyna. 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, which you can find the documentation for here. 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
- 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
Comprehensive documentation is available for developers of all levels:
- Introduction
- Installation
- Getting Started
- Core Concepts
- Advanced Usage
- API Reference
- Examples and Use Cases
- Release Script Guide
- Troubleshooting and FAQ
- Contribution Guide
- Changelog
- License
Installation
Creating the Base Plugin
To create a new WordPress plugin using the Realtyna Base Plugin framework, you can use the following Composer command:
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
After running the create-project
command, the script will automatically:
- Update Namespace: The namespace in all class files will be updated to match your project name.
- Update Constant Name: The constant name used throughout the project will reflect your plugin's name.
- Update Plugin Name: The plugin name used in various parts of the code and configuration will be set to the name you provided.
- Configure
config.php
: Theconfig.php
file will be updated to reflect your plugin’s name, slug, and text domain based on the project name.
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:
- 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
totrue
to enable logging, and specify thelevel
of logging (e.g.,error
,warning
,info
).
Overview of Main.php
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
:
-
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.
-
adminPages(): Register admin pages for your plugin. Admin pages allow you to create custom interfaces in the WordPress dashboard.
-
boot(): This method is used for bootstrapping your plugin, setting up the container, and initializing logging if configured.
- migrations(): Register database migrations here. Migrations handle changes to the database schema, such as creating or altering tables.
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
Here is a basic example of how to create a component with all its features:
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
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgements
- Thanks to all the open-source projects that make development faster and easier.