Download the PHP package wp-plus/wp-oop-base without Composer
On this page you can find all versions of the php package wp-plus/wp-oop-base. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wp-plus/wp-oop-base
More information about wp-plus/wp-oop-base
Files in wp-plus/wp-oop-base
Package wp-oop-base
Short Description Opinionated OOP base for WordPress plugin and theme development.
License MIT
Informations about the package wp-oop-base
WP OOP Base
An opinionated object-oriented base library for WordPress plugin and theme development, providing a structured foundation for building maintainable WordPress extensions.
Overview
WP OOP Base offers a collection of abstract classes and interfaces that promote clean, object-oriented architecture in WordPress development. It provides standardized patterns for common WordPress functionality including plugins, hooks, shortcodes, custom post types, and taxonomies.
Features
- Plugin Architecture: Singleton-based plugin classes with extensible sub-plugin support
- Hook Management: Object-oriented wrapper for WordPress actions and filters
- Shortcode Framework: Structured approach to shortcode development with attribute validation
- Custom Post Types & Taxonomies: Abstract classes for registering custom content types
- Helper Utilities: Common WordPress development utilities
- Clean Architecture: Structured patterns for maintainable code organization
- PSR-4 Autoloading: Modern PHP autoloading standards
Requirements
- PHP 8.0 or higher
- WordPress 6.5 or higher (for development)
Installation
Via Composer
When installed via Composer, the library is automatically loaded through Composer's autoloader and doesn't need to be placed in the WordPress plugins directory. Simply include Composer's autoloader in your project and the classes will be available.
Note: this will work only if Composer's autoloader is included - either manually or using a tool like composer-autoload for WordPress.
Manual Installation
- Download the library
- Place it in your
wp-content/plugins/wp-oop-base/directory - Activate the plugin through the WordPress admin
Must-Use Plugin Installation
For must-use plugin functionality (automatically loaded, before regular plugins):
- Follow the manual installation steps above
- Move
wp-oop-base.phptowp-content/mu-plugins/ - Keep all other files in
wp-content/plugins/wp-oop-base/
The bootstrap file will automatically detect the correct paths whether it's running as a regular plugin or must-use plugin.
Quick Start
Creating a Plugin
Creating a Hook
Creating a Shortcode
Creating a Custom Post Type
Architecture
Core Components
Plugin System
AbstractPlugin: Base class for singleton plugin instancesAbstractExtensiblePlugin: Plugin class that can contain sub-pluginsPluginsContainerTrait: Manages collections of sub-plugins
Hook System
AbstractHook: Base class for WordPress actions and filtersAbstractActivationHook: Specialized hooks for plugin activationAbstractMultiHook: Container of multiple hooks with hook-like interface
Registration System
RegistrableInterface: Contract for registerable componentsAbstractRegistrable: Base implementation for registerable components
Content Types
AbstractCustomPostType: Framework for custom post typesAbstractCustomTaxonomy: Framework for custom taxonomies
Other
AbstractShortcode: Structured shortcode development with attribute validation
Design Patterns
Singleton Pattern
All plugin classes use the singleton pattern to ensure single instances:
Convenient Static Methods
The library provides convenient static methods for common operations:
Registration Pattern
Components implement a consistent registration/unregistration pattern:
Helper Classes
DateTime Helper
Utilities for WordPress-aware date/time formatting:
Post Helper
Utilities for post operations:
Database Access Trait
Convenient access to the WordPress database object:
Advanced Usage
Extensible Plugins
Create plugins that can contain other plugins:
Multi-Hooks
Register multiple related hooks together:
Best Practices
- Use Dependency Injection: Set dependencies via setters in plugin constructors
- Follow WordPress Coding Standards: Maintain consistency with WordPress conventions
- Implement Proper Error Handling: Use exceptions for configuration errors
- Validate Input: Always validate and sanitize user input in shortcodes and hooks
- Use Static Methods Judiciously: Static convenience methods create new instances each time they're called
Contributing
Contributions are welcome! Please ensure your code follows PSR-4 autoloading standards and includes appropriate documentation.
License
This project is licensed under the MIT License - see the LICENSE file for details.