# FYPlugins Core Framework ## Overview FYPlugins Core is a powerful WordPress plugin framework that provides a standardized foundation for developing WordPress plugins. It offers a comprehensive set of tools, classes, and utilities to streamline plugin development while maintaining consistency across all FYPlugins products. ## Features ### Core Framework - **Plugin Management**: Centralized registration and management of FYPlugins - **Options Management**: Robust options handling with automatic prefixing and validation - **Transient Management**: Enhanced WordPress transient API with bulk operations - **Form Builder**: Advanced form generation with field validation and styling - **Admin Interface**: Consistent admin pages with tabbed navigation - **Debug Tools**: Comprehensive debugging interface with data export capabilities ### Admin Interface - **Tabbed Navigation**: Clean, intuitive admin interface with tab management - **Debug Dashboard**: Real-time system information and plugin diagnostics - **Data Management**: Bulk delete operations for options and transients - **Export Functionality**: JSON export of debug information - **Responsive Design**: Mobile-friendly admin interface ### Developer Tools - **Form Fields**: Pre-built field types (text, select, checkbox, color, etc.) - **Validation**: Built-in form validation with error handling - **Styling**: Consistent CSS framework for all FYPlugins - **AJAX Handlers**: Secure AJAX operations with nonce verification - **Hooks & Filters**: Extensive hook system for customization ## Directory Structure ``` core/ ├── ajax.php # AJAX request handlers ├── compat.php # WordPress compatibility layer ├── core-loader.php # Framework initialization ├── helpers.php # Utility functions ├── includes.php # File inclusion manager ├── assets/ # Frontend assets │ ├── css/admin.css # Admin styling │ ├── js/admin.js # Admin JavaScript │ └── img/ # Images and icons ├── class/ # Core classes │ ├── AdminPage.php # Admin page management │ ├── Core.php # Main framework class │ ├── Form.php # Form builder │ ├── FormField.php # Individual form fields │ ├── FormGroup.php # Form field grouping │ ├── Options.php # Options management │ ├── Plugin.php # Plugin registration │ ├── Stylesheet.php # CSS management │ └── Transient.php # Transient operations ├── templates/ # Admin templates │ ├── content.php # Main content wrapper │ ├── debugTab.php # Debug information display │ ├── footer.php # Admin footer │ ├── header.php # Admin header │ └── welcomeTab.php # Welcome page └── trait/ # Reusable traits ├── DataManager.php # Data manipulation ├── FormsManager.php # Form handling ├── PluginsManager.php # Plugin management └── SetGetHas.php # Property management ``` ## Classes Overview ### Core Classes #### `FYPlugins\Core\Core` Main framework controller that handles: - Plugin registration and management - Admin page rendering - Debug information collection - Asset enqueuing #### `FYPlugins\Core\Options` Manages WordPress options with features: - Automatic prefixing (`fyplugins_`) - Bulk operations (get all, delete all) - Data validation and sanitization #### `FYPlugins\Core\Transient` Enhanced transient management: - Prefixed transient keys - Bulk deletion capabilities - Database optimization #### `FYPlugins\Core\Form` Advanced form builder supporting: - Multiple field types - Validation rules - Error handling - Custom styling #### `FYPlugins\Core\AdminPage` Admin page management: - Tabbed interfaces - Menu integration - Capability checking - Template rendering ### Form Fields The framework includes comprehensive form field support: - Text inputs (text, email, url, password) - Select dropdowns - Checkboxes and radio buttons - Color picker - Textarea - Number inputs - Custom field types ## Usage Examples ### Basic Plugin Registration ```php // Register a new plugin with FYPlugins Core $plugin = new \FYPlugins\Core\Plugin([ 'name' => 'My Plugin', 'version' => '1.0.0', 'slug' => 'my-plugin', 'description' => 'Plugin description' ]); fyplugins_core()->registerPlugin($plugin); ``` ### Options Management ```php // Set an option fyplugins_core_options()->set('my_setting', 'value'); // Get an option $value = fyplugins_core_options()->get('my_setting', 'default'); // Get all FYPlugins options $all_options = fyplugins_core_options()->getAll(); ``` ### Transient Operations ```php // Set a transient fyplugins_core_transient()->set('cache_key', $data, 3600); // Get a transient $data = fyplugins_core_transient()->get('cache_key'); // Delete all FYPlugins transients fyplugins_core_transient()->deleteAll(); ``` ### Form Creation ```php $form = new \FYPlugins\Core\Form([ 'id' => 'my-form', 'action' => admin_url('admin-post.php'), 'method' => 'POST' ]); $form->addField([ 'type' => 'text', 'name' => 'title', 'label' => 'Title', 'required' => true ]); echo $form->render(); ``` ## Debug Features The debug interface provides: ### System Information - WordPress version and configuration - Server environment details - Active theme information - Multisite status ### FYPlugins Data - Registered plugins list - Options overview with hierarchical display - Active transients monitoring - Framework version information ### Data Management - Bulk delete FYPlugins options - Bulk delete FYPlugins transients - JSON export of all debug data - Collapsible array/object display ### Interactive Features - Expandable/collapsible data structures - Real-time data updates - Secure AJAX operations - Download debug reports ## Security Features - **Nonce Verification**: All AJAX requests include nonce validation - **Capability Checks**: User permission verification for admin operations - **Data Sanitization**: Automatic input sanitization and validation - **SQL Injection Prevention**: Prepared statements for database operations - **XSS Protection**: Output escaping for all displayed content ## Requirements - WordPress 5.0 or higher - PHP 7.4 or higher - MySQL 5.6 or higher - JavaScript enabled (for admin features) ## Installation 1. Upload the core framework to your plugin directory 2. Include the core loader in your plugin main file: ```php require_once plugin_dir_path(__FILE__) . 'includes/core/core-loader.php'; ``` 3. Initialize your plugin with the framework ## Development Guidelines ### Coding Standards - Follow WordPress coding standards - Use proper documentation blocks - Implement proper error handling - Validate and sanitize all inputs ### Best Practices - Use the provided traits for common functionality - Leverage the form builder for consistent UI - Utilize the options and transient managers - Follow the established directory structure ## Changelog ### Version 2.x - Enhanced debug interface with collapsible arrays - JSON export functionality - Improved form builder - Better error handling - Mobile-responsive admin interface ### Version 1.x - Initial framework release - Basic plugin management - Options and transient handling - Admin page framework ## Support For documentation, examples, and support: - Visit the FYPlugins website - Check the inline code documentation - Review the example implementations ## License This framework is part of the FYPlugins ecosystem and follows the same licensing terms as the parent plugin.