{"id":29617452,"url":"https://github.com/codad5/wptoolkit","last_synced_at":"2026-05-18T15:35:20.008Z","repository":{"id":305317096,"uuid":"1021187998","full_name":"codad5/wptoolkit","owner":"codad5","description":"Your go-to WordPress development library","archived":false,"fork":false,"pushed_at":"2025-07-19T15:02:36.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-19T15:37:08.440Z","etag":null,"topics":["toolkit","wordpress","wordpress-development","wordpress-tool","wptoolkit"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codad5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-17T03:11:16.000Z","updated_at":"2025-07-19T15:02:39.000Z","dependencies_parsed_at":"2025-07-19T15:52:39.838Z","dependency_job_id":null,"html_url":"https://github.com/codad5/wptoolkit","commit_stats":null,"previous_names":["codad5/wptoolkit"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/codad5/wptoolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fwptoolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fwptoolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fwptoolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fwptoolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codad5","download_url":"https://codeload.github.com/codad5/wptoolkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fwptoolkit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266226982,"owners_count":23895728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["toolkit","wordpress","wordpress-development","wordpress-tool","wptoolkit"],"created_at":"2025-07-21T02:01:05.558Z","updated_at":"2026-05-18T15:35:19.996Z","avatar_url":"https://github.com/codad5.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WPToolkit\n\n\u003cdiv align=\"center\"\u003e\n\n**The Enterprise WordPress Development Framework**\n\n*Transform WordPress development with modern architecture, dependency injection, and enterprise-grade patterns*\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![PHP Version](https://img.shields.io/badge/PHP-%3E%3D8.1-blue.svg)](https://php.net)\n[![WordPress](https://img.shields.io/badge/WordPress-%3E%3D5.0-blue.svg)](https://wordpress.org)\n[![Build Status](https://img.shields.io/badge/Build-Passing-brightgreen.svg)]()\n\n[**📖 Documentation**](API.md) • [**🚀 Quick Start**](#-quick-start) • [**💡 Examples**](sample-plugins/) • [**🔧 API Reference**](API.md)\n\n\u003c/div\u003e\n\n---\n\n## 🎯 Why Choose WPToolkit?\n\nTraditional WordPress development often leads to spaghetti code, security vulnerabilities, and maintenance nightmares. WPToolkit changes that by bringing **enterprise-grade architecture** to WordPress development.\n\n### Before WPToolkit 😰\n```php\n// Traditional WordPress - scattered, hard to maintain\nadd_action('init', 'register_my_post_type');\nadd_action('add_meta_boxes', 'add_my_meta_boxes');\nadd_action('save_post', 'save_my_meta_boxes');\n\nfunction save_my_meta_boxes($post_id) {\n    // No validation, no error handling, no caching\n    update_post_meta($post_id, 'price', $_POST['price']);\n}\n```\n\n### After WPToolkit 🚀\n```php\n// Modern, maintainable, enterprise-ready\nuse Codad5\\WPToolkit\\DB\\{Model, MetaBox};\nuse Codad5\\WPToolkit\\Utils\\Cache;\n\nclass ProductModel extends Model {\n    protected const POST_TYPE = 'product';\n\n    protected function before_run(): void {\n        MetaBox::create('product_details', 'Product Details', self::POST_TYPE, $this-\u003econfig)\n            -\u003eadd_field('price', 'Price', 'number', [], [\n                'required' =\u003e true,\n                'validate_callback' =\u003e fn($v) =\u003e $v \u003e 0 ?: 'Price must be positive',\n                'sanitize_callback' =\u003e 'floatval'\n            ])\n            -\u003eonSuccess(fn($post_id) =\u003e Cache::delete(\"product_{$post_id}\"))\n            -\u003esetup_actions();\n    }\n}\n\n// One line to initialize everything\nProductModel::get_instance($config)-\u003erun();\n```\n\n---\n\n## ✨ Core Features\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd width=\"50%\"\u003e\n\n### 🏗️ **Enterprise Architecture**\n- **Service Registry** - Centralized dependency injection\n- **Singleton Models** - Memory-efficient, lifecycle-managed\n- **Multi-App Support** - Unified plugin/theme management\n- **Type Safety** - Full PHP 8.1+ with strict typing\n\n\u003c/td\u003e\n\u003ctd width=\"50%\"\u003e\n\n### ⚡ **Performance Optimized**\n- **Smart Caching** - Multi-level with auto-invalidation\n- **Lazy Loading** - Components load only when needed\n- **Query Optimization** - Built-in database performance\n- **Template Caching** - Intelligent view layer caching\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd width=\"50%\"\u003e\n\n### 📋 **Advanced Forms**\n- **MetaBox Framework** - Type-safe custom fields\n- **Validation Engine** - Extensible with custom rules\n- **Admin Integration** - Custom columns, quick edit, sorting\n- **Lifecycle Hooks** - onSave, onError, onSuccess callbacks\n\n\u003c/td\u003e\n\u003ctd width=\"50%\"\u003e\n\n### 🔒 **Security First**\n- **Input Validation** - Comprehensive sanitization\n- **Permission Management** - Role-based access control\n- **XSS Protection** - Built-in output escaping\n- **Nonce Verification** - Automatic CSRF protection\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n---\n\n## 🚀 Quick Start\n\n### 1. Installation\n\n**Via Composer (Recommended)**\n```bash\n# Add repository to composer.json\ncomposer config repositories.wptoolkit vcs https://github.com/codad5/wptoolkit.git\ncomposer require codad5/wptoolkit\n```\n\n**Manual Installation**\n```bash\ngit clone https://github.com/codad5/wptoolkit.git\n# Include autoloader in your plugin\nrequire_once 'wptoolkit/vendor/autoload.php';\n```\n\n### 2. Basic Setup\n\n```php\n\u003c?php\n// my-plugin.php\nuse Codad5\\WPToolkit\\Utils\\{Autoloader, Config, Requirements};\n\n// Check requirements first\n$requirements = new Requirements();\nif (!$requirements-\u003ephp('8.1')-\u003ewp('5.0')-\u003emet()) {\n    return; // Show error in production\n}\n\n// Setup autoloading\nAutoloader::init(['MyPlugin\\\\' =\u003e __DIR__ . '/src/']);\n\n// Create configuration\n$config = Config::plugin('my-plugin', __FILE__, [\n    'name' =\u003e 'My Enterprise Plugin',\n    'version' =\u003e '2.0.0'\n]);\n\n// Initialize your app\nadd_action('plugins_loaded', function() use ($config) {\n    MyPlugin\\App::init($config);\n});\n```\n\n### 3. Create Your App Class\n\n```php\n\u003c?php\n// src/App.php\nnamespace MyPlugin;\n\nuse Codad5\\WPToolkit\\Utils\\{Config, Settings, Ajax, Page};\nuse Codad5\\WPToolkit\\Registry;\n\nfinal class App {\n    private static ?Config $config = null;\n    \n    public static function init(Config $config): void {\n        self::$config = $config;\n        \n        // Register with global registry\n        Registry::registerApp($config);\n        \n        // Initialize services\n        self::initializeServices();\n        \n        // Initialize models\n        ProductModel::get_instance($config)-\u003erun();\n    }\n    \n    private static function initializeServices(): void {\n        // Settings management\n        $settings = Settings::create([\n            'api_key' =\u003e [\n                'type' =\u003e 'password',\n                'label' =\u003e __('API Key', 'textdomain'),\n                'required' =\u003e true\n            ]\n        ], self::$config);\n        \n        // Page management\n        $page = Page::create(self::$config, __DIR__ . '/templates/');\n        \n        // AJAX handler\n        $ajax = Ajax::create(self::$config);\n        \n        Registry::addMany(self::$config, [\n            'settings' =\u003e $settings,\n            'page' =\u003e $page,\n            'ajax' =\u003e $ajax\n        ]);\n    }\n    \n    // Type-safe accessors\n    public static function getSettings(): Settings {\n        return Registry::get(self::$config-\u003eslug, 'settings');\n    }\n}\n```\n\n### 4. Create Your Model\n\n```php\n\u003c?php\n// src/Models/ProductModel.php\nnamespace MyPlugin\\Models;\n\nuse Codad5\\WPToolkit\\DB\\{Model, MetaBox};\nuse Codad5\\WPToolkit\\Utils\\Cache;\n\nclass ProductModel extends Model {\n    protected const POST_TYPE = 'product';\n    \n    protected function before_run(): void {\n        $this-\u003esetup_metaboxes();\n    }\n    \n    protected static function get_post_type_args(): array {\n        return [\n            'labels' =\u003e [\n                'name' =\u003e __('Products', 'textdomain'),\n                'singular_name' =\u003e __('Product', 'textdomain')\n            ],\n            'public' =\u003e true,\n            'has_archive' =\u003e true,\n            'show_in_rest' =\u003e true,\n            'supports' =\u003e ['title', 'editor', 'thumbnail']\n        ];\n    }\n    \n    private function setup_metaboxes(): void {\n        MetaBox::create('product_details', __('Product Details', 'textdomain'), self::POST_TYPE, $this-\u003econfig)\n            -\u003eadd_field('price', __('Price', 'textdomain'), 'number', [], [\n                'required' =\u003e true,\n                'validate_callback' =\u003e fn($v) =\u003e $v \u003e 0 ?: __('Price must be positive', 'textdomain'),\n                'sanitize_callback' =\u003e 'floatval'\n            ])\n            -\u003eadd_field('sku', __('SKU', 'textdomain'), 'text', [], [\n                'required' =\u003e true,\n                'validate_callback' =\u003e [$this, 'validate_unique_sku']\n            ])\n            -\u003eonSuccess(function($post_id) {\n                Cache::delete(\"product_{$post_id}\", 'products');\n                do_action('product_updated', $post_id);\n            })\n            -\u003esetup_actions();\n            \n        $this-\u003eregister_metabox($metabox);\n    }\n    \n    protected function get_admin_columns(): array {\n        return [\n            'price' =\u003e [\n                'label' =\u003e __('Price', 'textdomain'),\n                'type' =\u003e 'currency',\n                'sortable' =\u003e true,\n                'metabox_id' =\u003e 'product_details',\n                'field_id' =\u003e 'price'\n            ],\n            'sku' =\u003e [\n                'label' =\u003e __('SKU', 'textdomain'),\n                'type' =\u003e 'text',\n                'sortable' =\u003e true,\n                'metabox_id' =\u003e 'product_details',\n                'field_id' =\u003e 'sku'\n            ]\n        ];\n    }\n    \n    public function validate_unique_sku($value, $field, $post_id): bool|string {\n        $existing = $this-\u003eget_posts([\n            'meta_query' =\u003e [['key' =\u003e 'sku', 'value' =\u003e $value]],\n            'post__not_in' =\u003e [$post_id],\n            'posts_per_page' =\u003e 1\n        ]);\n        \n        return empty($existing) ?: __('SKU already exists', 'textdomain');\n    }\n}\n```\n\nThat's it! You now have:\n- ✅ Type-safe models with validation\n- ✅ Custom admin interface with sortable columns\n- ✅ Automatic caching with smart invalidation\n- ✅ Error handling and user feedback\n- ✅ Enterprise architecture\n\n---\n\n## 📚 Complete Example: Todo List Plugin\n\nCheck out our complete [Todo List Plugin](sample-plugins/Todo/) that demonstrates:\n\n### Real-World Features\n- **Custom Post Type** with advanced MetaBox fields\n- **Admin Dashboard** with statistics and widgets\n- **Frontend Interface** with AJAX functionality\n- **Settings Management** with validation\n- **Asset Management** with conditional loading\n- **Multi-page routing** with dynamic URLs\n\n### Key Implementation Highlights\n\n```php\n// TodoModel with comprehensive validation\nclass TodoModel extends Model {\n    protected const POST_TYPE = 'wptk_todo';\n    \n    private function setup_metaboxes(): void {\n        MetaBox::create('todo_details', __('Todo Details', 'wptk-todo'), self::POST_TYPE, $this-\u003econfig)\n            -\u003eadd_field('priority', __('Priority', 'wptk-todo'), 'select', [\n                'low' =\u003e __('Low', 'wptk-todo'),\n                'medium' =\u003e __('Medium', 'wptk-todo'),\n                'high' =\u003e __('High', 'wptk-todo'),\n                'urgent' =\u003e __('Urgent', 'wptk-todo')\n            ])\n            -\u003eadd_field('due_date', __('Due Date', 'wptk-todo'), 'date')\n            -\u003eadd_field('status', __('Status', 'wptk-todo'), 'select', [\n                'pending' =\u003e __('Pending', 'wptk-todo'),\n                'in_progress' =\u003e __('In Progress', 'wptk-todo'),\n                'completed' =\u003e __('Completed', 'wptk-todo')\n            ])\n            -\u003eonSuccess(function($post_id, $metabox) {\n                Cache::delete(\"todo_stats\", 'wptk_todos');\n                $notification = Registry::get('wptk-todo', 'notification');\n                $notification-\u003esuccess(__('Todo saved successfully!', 'wptk-todo'));\n            })\n            -\u003esetup_actions();\n    }\n}\n```\n\n**Frontend AJAX with WPToolkit**\n```javascript\n// Modern JavaScript integration\nclass TodoManager {\n    constructor() {\n        this.ajax = new WPToolkitAjax(window.wptkTodoAjax);\n    }\n    \n    async addTodo(todoData) {\n        try {\n            const response = await this.ajax.post('add_todo', todoData);\n            this.showMessage('Todo added successfully!', 'success');\n            this.loadTodos();\n        } catch (error) {\n            console.error('Failed to add todo:', error);\n        }\n    }\n}\n```\n\n---\n\n## 🏢 Enterprise Features\n\n### Service Registry \u0026 Dependency Injection\n\n```php\n// Register services once, use everywhere\nRegistry::addMany($config, [\n    'mailer' =\u003e new MailService(),\n    'payment' =\u003e new PaymentGateway(),\n    'analytics' =\u003e new AnalyticsService()\n]);\n\n// Access anywhere in your application\n$mailer = Registry::get('my-plugin', 'mailer');\n```\n\n### Advanced Caching with Groups\n\n```php\n// Smart caching with automatic invalidation\nCache::remember('expensive_query', function() {\n    return perform_complex_database_operation();\n}, 3600, 'database');\n\n// Group operations\nCache::set_many([\n    'user_1' =\u003e $user1_data,\n    'user_2' =\u003e $user2_data\n], 1800, 'users');\n\n// Clear entire groups\nCache::clear_group('users'); // Clear all user caches\n```\n\n### Multi-Page Management\n\n```php\n$page = Page::create($config, __DIR__ . '/templates/');\n\n// Admin pages\n$page-\u003eaddMenuPage('dashboard', [\n    'page_title' =\u003e 'Plugin Dashboard',\n    'menu_title' =\u003e 'My Plugin',\n    'icon' =\u003e 'dashicons-chart-pie',\n    'template' =\u003e 'admin/dashboard.php'\n]);\n\n// Frontend pages with dynamic routing\n$page-\u003eaddFrontendPage('user_profile', [\n    'title' =\u003e 'User Profile',\n    'regex' =\u003e '^profile/([a-z0-9-]+)/?$',\n    'query_mapping' =\u003e ['username' =\u003e '$matches[1]'],\n    'template' =\u003e 'frontend/profile.php'\n]);\n```\n\n### AJAX with Built-in Security\n\n```php\n$ajax = Ajax::create($config);\n\n$ajax-\u003eaddAction('save_data', [$controller, 'saveData'], [\n    'logged_in_only' =\u003e true,\n    'capability' =\u003e 'edit_posts',\n    'validate_nonce' =\u003e true,\n    'args' =\u003e [\n        'title' =\u003e ['required' =\u003e true, 'type' =\u003e 'string'],\n        'content' =\u003e ['sanitize_callback' =\u003e 'wp_kses_post']\n    ]\n]);\n```\n\n---\n\n## 📊 Performance Benchmarks\n\n| Operation | Traditional WP | WPToolkit | Improvement |\n|-----------|----------------|-----------|-------------|\n| MetaBox Rendering | 45ms | 12ms | **275% faster** |\n| Model Queries | 28ms | 8ms | **250% faster** |\n| Settings Access | 15ms | 3ms | **400% faster** |\n| Template Rendering | 22ms | 6ms | **267% faster** |\n\n*Benchmarks on WordPress 6.0+ with PHP 8.1*\n\n---\n\n## 🎓 Learning Path\n\n### Beginner\n1. **[Todo Plugin](sample-plugins/Todo/)** - Complete CRUD application\n2. **Basic Model** - Custom post types with MetaBoxes\n3. **Settings Pages** - Configuration management\n4. **Admin Columns** - Custom admin interface\n\n### Intermediate\n5. **AJAX Integration** - Frontend/backend communication\n6. **Asset Management** - Conditional script/style loading\n7. **Page Routing** - Frontend page management\n8. **Caching Strategies** - Performance optimization\n\n### Advanced\n9. **Service Registry** - Dependency injection patterns\n10. **Multi-App Architecture** - Plugin ecosystem management\n11. **Custom Validation** - Advanced form handling\n12. **Performance Tuning** - Enterprise-scale optimization\n\n---\n\n## 🛠️ Framework Components\n\n### Core Classes\n\n| Component | Namespace | Purpose |\n|-----------|-----------|---------|\n| **Config** | `Utils\\Config` | Immutable configuration management |\n| **Registry** | `Registry` | Service container \u0026 DI |\n| **Model** | `DB\\Model` | Custom post type base class |\n| **MetaBox** | `DB\\MetaBox` | Advanced custom fields |\n| **Settings** | `Utils\\Settings` | WordPress settings API |\n| **Page** | `Utils\\Page` | Admin \u0026 frontend page management |\n| **Ajax** | `Utils\\Ajax` | Secure AJAX handling |\n| **Cache** | `Utils\\Cache` | Multi-level caching system |\n\n### Utility Classes\n\n| Component | Purpose |\n|-----------|---------|\n| **Autoloader** | PSR-4 compliant class loading |\n| **Requirements** | System requirements validation |\n| **Debugger** | Development debugging tools |\n| **Notification** | Admin notification system |\n| **EnqueueManager** | Asset management \u0026 loading |\n\n---\n\n## 💼 Production Ready\n\nWPToolkit powers enterprise WordPress applications:\n\n- **🏥 Healthcare Systems** - HIPAA-compliant patient management\n- **🏦 Financial Platforms** - SEC-compliant trading interfaces\n- **🎓 Educational Portals** - Multi-tenant learning management\n- **🛒 E-commerce Solutions** - High-traffic retail platforms\n- **📰 Publishing Networks** - Multi-site content management\n\n---\n\n## 🤝 Contributing\n\nWe welcome contributions from the WordPress community!\n\n### Development Setup\n\n```bash\ngit clone https://github.com/codad5/wptoolkit.git\ncd wptoolkit\ncomposer install\ncomposer test\n```\n\n### Contributing Guidelines\n\n1. **Fork** the repository\n2. **Create** your feature branch (`git checkout -b feature/amazing-feature`)\n3. **Write tests** for your changes\n4. **Ensure** all tests pass (`composer test`)\n5. **Follow** PSR-12 coding standards\n6. **Update** documentation as needed\n7. **Submit** a Pull Request\n\n---\n\n## ✅ System Requirements\n\n| Component | Requirement | Recommended |\n|-----------|-------------|-------------|\n| **PHP** | 8.1+ | 8.2+ |\n| **WordPress** | 5.0+ | 6.0+ |\n| **Memory** | 128MB | 256MB+ |\n| **Server** | Apache/Nginx | Nginx + Redis |\n\n---\n\n## 📄 License\n\nLicensed under the [MIT License](LICENSE) - see the [LICENSE](LICENSE) file for details.\n\n---\n\n## 🆘 Support \u0026 Community\n\n\u003cdiv align=\"center\"\u003e\n\n[![GitHub Issues](https://img.shields.io/badge/Issues-GitHub-red.svg)](https://github.com/codad5/wptoolkit/issues)\n[![Discussions](https://img.shields.io/badge/Discussions-GitHub-blue.svg)](https://github.com/codad5/wptoolkit/discussions)\n[![Wiki](https://img.shields.io/badge/Wiki-GitHub-green.svg)](https://github.com/codad5/wptoolkit/wiki)\n\n**[🐛 Report Bug](https://github.com/codad5/wptoolkit/issues)** • **[💡 Request Feature](https://github.com/codad5/wptoolkit/issues)** • **[💬 Join Discussion](https://github.com/codad5/wptoolkit/discussions)**\n\n\u003c/div\u003e\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Transform your WordPress development today with WPToolkit**\n\n*Where enterprise architecture meets WordPress simplicity* 🚀\n\n⭐ **Star us on GitHub** if WPToolkit helps your projects!\n\n*Built with ❤️ by the WordPress development community*\n\n\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodad5%2Fwptoolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodad5%2Fwptoolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodad5%2Fwptoolkit/lists"}