adzadzadz/wp-plugin-framework

Modern MVC framework for WordPress plugin development - Build professional plugins with clean architecture

v2.4.0 2025-08-27 12:32 UTC

This package is auto-updated.

Last update: 2025-09-09 14:50:55 UTC


README

Operation CWAL (Can't Wait Any Longer) - Start building WordPress plugins RIGHT NOW with modern MVC architecture.

๐Ÿš€ Why This Framework?

You're a developer. You love MVC. You hate WordPress's procedural chaos.

This framework is for developers who:

  • โœ… Can't Wait Any Longer to start building professional WordPress plugins
  • โœ… Love working with MVC architecture instead of procedural spaghetti code
  • โœ… Want to start writing plugins immediately without setup hassle
  • โœ… Demand modern PHP practices in WordPress development
  • โœ… Need professional structure for scalable plugin development

โšก Operation CWAL - Instant Plugin Development

# Install via Composer (FASTEST)
composer create-project adzadzadz/wp-plugin-framework my-awesome-plugin

# Start coding IMMEDIATELY
cd my-awesome-plugin

That's it. You're ready to build.

๐ŸŽฏ Built for MVC Lovers

Clean Controller Structure

<?php
namespace App\Controllers;

use AdzWP\Core\Controller;

class MyAwesomeController extends Controller
{
    public $actions = [
        'init' => 'initialize',
        'admin_menu' => 'setupAdminMenu'
    ];

    public function initialize()
    {
        // Your plugin logic here - NO HOOKS MESS!
    }
}

Elegant Database Models

<?php
namespace App\Models;

use AdzWP\Db\Model;

class Post extends Model
{
    protected $table = 'posts';
    protected $fillable = ['title', 'content', 'status'];
    
    // ORM-style relationships and queries
    public function comments()
    {
        return $this->hasMany(Comment::class);
    }
}

Fluent Query Builder

$posts = $this->queryBuilder()
    ->select(['id', 'title', 'content'])
    ->from('posts')
    ->where('status', 'published')
    ->orderBy('created_at', 'DESC')
    ->limit(10)
    ->get();

๐Ÿ—๏ธ Framework Architecture

src/
โ”œโ”€โ”€ AdzMain.php          # Global \Adz framework access
โ”œโ”€โ”€ Core/                # Core framework components
โ”‚   โ”œโ”€โ”€ Controller.php   # MVC Controller base class
โ”‚   โ”œโ”€โ”€ Model.php        # MVC Model base class
โ”‚   โ”œโ”€โ”€ Service.php      # Service layer base class
โ”‚   โ”œโ”€โ”€ Config.php       # Configuration management
โ”‚   โ””โ”€โ”€ View.php         # Template rendering
โ”œโ”€โ”€ Db/                  # Database layer
โ”‚   โ”œโ”€โ”€ Model.php        # ORM-style database models
โ”‚   โ”œโ”€โ”€ QueryBuilder.php # Fluent query interface
โ”‚   โ””โ”€โ”€ Connection.php   # Database connection
โ””โ”€โ”€ Helpers/             # Utility classes
    โ”œโ”€โ”€ ArrayHelper.php  # Array manipulation utilities
    โ””โ”€โ”€ RESTHelper.php   # REST API utilities

๐ŸŽช Features That Make You Productive

๐Ÿ”ฅ Instant Setup

  • Zero configuration - Works out of the box
  • PSR-4 autoloading - Modern PHP standards
  • Composer ready - Professional dependency management

๐Ÿ—๏ธ Professional Architecture

  • MVC pattern - Separate concerns like a pro
  • Service layer - Reusable business logic with dependency injection
  • Auto-hook registration - Methods automatically become WordPress hooks
  • Automatic admin pages - adminPage{Name}() methods create admin pages automatically
  • Context-aware methods - admin{Name}() and frontend{Name}() run only where needed
  • ORM-style models - Database interactions made easy
  • Dependency injection - Clean, testable code
  • Event system - WordPress hooks without the mess

๐Ÿงช Testing Ready

  • 61 unit tests included - Quality guaranteed
  • PHPUnit integration - Professional testing workflow
  • WordPress mocks - Test without WordPress overhead

๐Ÿ“ฆ Developer Experience

  • IDE friendly - Full autocompletion and navigation
  • Modern namespaces - AdzWP\Core\*, AdzWP\Db\*
  • Global framework access - Simple \Adz::config() calls

๐Ÿš€ Quick Start Example

1. Create Your Plugin Structure

// my-plugin.php
<?php
/**
 * Plugin Name: My Awesome Plugin
 * Description: Built with ADZ Framework - Operation CWAL!
 */

require_once 'vendor/autoload.php';

// Initialize framework
$framework = \Adz::config();
$framework->set('plugin.path', __DIR__);

// Load your controllers
new App\Controllers\MyAwesomeController();

2. Build Your Controller (Auto-Hook Registration)

// src/Controllers/MyAwesomeController.php
<?php
namespace App\Controllers;

use AdzWP\Core\Controller;

class MyAwesomeController extends Controller
{
    // Methods starting with 'action' are automatically registered as WordPress actions
    public function actionWpInit()
    {
        if ($this->isAdmin()) {
            $this->setupAdminInterface();
        }
    }

    public function actionWpAjaxMyAction()
    {
        $data = ['message' => 'Hello from ADZ Framework!'];
        wp_send_json_success($data);
    }

    // Methods starting with 'filter' are automatically registered as WordPress filters
    public function filterTheTitle($title, $post_id)
    {
        return $title . ' (Enhanced)';
    }

    /**
     * Use priority parameter for custom priority (recommended)
     */
    public function actionAdminMenu($priority = 20)
    {
        // This runs with priority 20
        // WordPress receives 0 arguments (priority param excluded)
        add_menu_page('My Plugin', 'My Plugin', 'manage_options', 'my-plugin', [$this, 'renderPage']);
    }

    /**
     * Automatic admin page creation - creates menu and handles display
     * @page_title My Plugin Settings
     * @menu_title Settings
     * @icon_url dashicons-admin-settings
     */
    public function adminPageSettings()
    {
        echo '<div class="wrap">';
        echo '<h1>My Plugin Settings</h1>';
        echo '<p>This admin page was created automatically!</p>';
        echo '</div>';
    }

    /**
     * Admin-only method - runs only in WordPress admin
     */
    public function adminInitializeSettings()
    {
        register_setting('my_plugin_settings', 'my_plugin_option');
    }

    /**
     * Frontend-only method - runs only on site frontend
     */
    public function frontendEnqueueScripts()
    {
        wp_enqueue_script('my-plugin-frontend', 'script.js');
    }
}

3. Create Your Services

// src/Services/UserService.php
<?php
namespace App\Services;

use AdzWP\Core\Service;

class UserService extends Service
{
    public function getDisplayName(int $userId): string
    {
        $user = get_userdata($userId);
        return $user ? ($user->display_name ?: $user->user_login) : 'Unknown User';
    }

    public function updateUserMeta(int $userId, string $key, $value): bool
    {
        if (!get_userdata($userId)) {
            return false;
        }
        
        return update_user_meta($userId, $key, $value) !== false;
    }
}

4. Use Services in Controllers

class MyController extends Controller
{
    public function actionWpInit()
    {
        // Initialize services
        new \App\Services\UserService();
    }

    public function actionUserRegister($userId)
    {
        // Access service via magic property
        $displayName = $this->userService->getDisplayName($userId);
        
        // Update user meta via service
        $this->userService->updateUserMeta($userId, 'welcome_sent', true);
    }
}

5. Create Your Models

// src/Models/CustomPost.php
<?php
namespace App\Models;

use AdzWP\Db\Model;

class CustomPost extends Model
{
    protected $table = 'custom_posts';
    protected $fillable = ['title', 'content', 'meta'];

    public function save(): bool
    {
        // Your save logic here
        return true;
    }
}

๐Ÿ“Š Why Developers Choose ADZ Framework

Traditional WordPress ADZ Framework
๐Ÿคฎ Procedural spaghetti ๐ŸŽฏ Clean MVC architecture
๐ŸŒ Manual hook management โšก Automatic hook registration
๐Ÿ˜ต Global function chaos ๐Ÿ—๏ธ Organized namespaces
๐Ÿ”ง Manual setup hell ๐Ÿš€ Instant productivity
๐Ÿ› Hard to test ๐Ÿงช Test-driven development

๐ŸŽฏ Operation CWAL Targets

  • โœ… Plugin MVP in under 30 minutes
  • โœ… Professional plugin architecture from day 1
  • โœ… Zero WordPress procedural code
  • โœ… Testable, maintainable, scalable
  • โœ… Modern PHP development experience

๐Ÿ“š Documentation & Support

๐Ÿ”ง Requirements

  • PHP 7.4+ (Modern PHP features)
  • WordPress 5.0+ (Latest WordPress APIs)
  • Composer (Dependency management)

๐Ÿ“ˆ Framework Stats

  • โœ… 61 Unit Tests - Quality guaranteed
  • โœ… 85 Assertions - Thoroughly tested
  • โœ… 100% Pass Rate - Production ready
  • โœ… PSR-4 Compliant - Modern standards
  • โœ… Zero Dependencies - Lightweight core

๐ŸŽช Get Started NOW

# Operation CWAL - Deploy immediately!
composer create-project adzadzadz/wp-plugin-framework my-plugin
cd my-plugin
# Start building your WordPress plugin empire! ๐Ÿš€

Built for developers who Can't Wait Any Longer to create amazing WordPress plugins with professional MVC architecture.

ADZ Framework - Because WordPress development should be enjoyable, not painful.