11# Project-specific instructions for Gemini AI
2- # This file provides context about the Simple WP Optimizer WordPress plugin
3- # to help Gemini understand the codebase and provide better analysis
4-
5- # Simple WP Optimizer - WordPress Plugin
62
73## Project Overview
4+
5+ ** Simple WP Optimizer - WordPress Plugin**
86This is a WordPress performance optimization plugin that removes unnecessary features and scripts to improve site performance. Designed for WordPress administrators who want to optimize their site's speed by disabling unused functionality and reducing resource overhead.
97
108## Plugin Details
9+
1110- ** Name:** Simple WP Optimizer
12- - ** Version:** 1.7 .0
11+ - ** Version:** 1.8 .0
1312- ** WordPress Compatibility:** 6.5+
1413- ** PHP Compatibility:** 7.4+
1514- ** License:** GPL-3.0-or-later
@@ -18,7 +17,9 @@ This is a WordPress performance optimization plugin that removes unnecessary fea
1817## Architecture & Design Patterns
1918
2019### Single-File Plugin Architecture
20+
2121The plugin follows a single-file architecture pattern for simplicity:
22+
2223``` php
2324// All functionality contained in simple-wp-optimizer.php
2425// Functions prefixed with 'es_optimizer_' for namespace consistency
@@ -28,7 +29,9 @@ function es_optimizer_function_name() {
2829```
2930
3031### Plugin Initialization
32+
3133The plugin uses proper WordPress initialization patterns with plugins_loaded hook:
34+
3235``` php
3336function es_optimizer_init() {
3437 // Hook admin menu creation
@@ -41,6 +44,7 @@ add_action( 'plugins_loaded', 'es_optimizer_init' );
4144```
4245
4346### File Structure
47+
4448- ` simple-wp-optimizer.php ` - Main plugin file (all functionality)
4549- ` languages/ ` - Translation files (.pot file included)
4650- ` CHANGELOG.md ` - Developer changelog
@@ -51,12 +55,14 @@ add_action( 'plugins_loaded', 'es_optimizer_init' );
5155## WordPress Coding Standards
5256
5357### Naming Conventions
58+
5459- ** Functions:** ` es_optimizer_snake_case ` (WordPress standard with plugin prefix)
5560- ** Variables:** ` $snake_case `
5661- ** Constants:** ` ES_WP_OPTIMIZER_UPPER_SNAKE_CASE `
5762- ** Text Domain:** Always use ` 'simple-wp-optimizer' `
5863
5964### Security Requirements
65+
6066- Always use ` esc_html() ` , ` esc_attr() ` , ` esc_url() ` for output
6167- Sanitize input with ` sanitize_text_field() ` , ` wp_unslash() ` , etc.
6268- Use ` current_user_can( 'manage_options' ) ` for capability checks
@@ -65,6 +71,7 @@ add_action( 'plugins_loaded', 'es_optimizer_init' );
6571- Use WordPress Options API for settings storage
6672
6773### WordPress Integration
74+
6875- ** Hooks:** Proper use of actions and filters with appropriate priorities
6976- ** Performance Features:** Integration with WordPress caching and optimization APIs
7077- ** Settings API:** WordPress Settings API for admin interface
@@ -76,6 +83,7 @@ add_action( 'plugins_loaded', 'es_optimizer_init' );
7683### Core Functionality
7784
7885#### Performance Optimization Features
86+
7987- ** XML-RPC Disabling:** Remove XML-RPC functionality for security and performance
8088- ** JSON REST API Control:** Disable REST API for non-logged users
8189- ** jQuery Migrate Removal:** Remove unnecessary jQuery Migrate script
@@ -86,36 +94,42 @@ add_action( 'plugins_loaded', 'es_optimizer_init' );
8694- ** DNS Prefetch Management:** User-configurable DNS prefetch for external domains
8795
8896#### Settings Management
97+
8998- ** Options Caching:** Static caching system to reduce database queries
9099- ** Conditional Admin Loading:** Admin assets only load on plugin settings page
91100- ** User-Friendly Interface:** Toggle-based settings for easy optimization control
92101- ** Input Validation:** Comprehensive validation for all user inputs
93102
94103#### Security Features
104+
95105- ** Domain Validation:** DNS prefetch domains validated to prevent injection
96106- ** Input Sanitization:** All user inputs properly sanitized and escaped
97107- ** Capability Checks:** Admin-only access with proper permission verification
98108- ** Nonce Protection:** CSRF protection on all form submissions
99109
100110### Performance Optimization Focus
111+
101112- ** Frontend Performance:** Reduces HTTP requests and removes unused resources
102113- ** Admin Performance:** Conditional loading of admin assets
103114- ** Database Optimization:** Option caching to minimize database queries
104115- ** Script Optimization:** Selective removal of unnecessary WordPress scripts
105116
106117### DNS Prefetch Security
118+
107119- ** Domain Validation:** All DNS prefetch domains validated to prevent injection
108120- ** Clean Domain Enforcement:** Only clean domains without paths/parameters allowed
109121- ** Input Sanitization:** URL validation prevents malicious domain injection
110122- ** Output Escaping:** All domain outputs properly escaped for security
111123
112124### WordPress Hook Management
125+
113126- ** Priority Handling:** High-priority hooks (PHP_INT_MAX) to ensure optimization execution
114127- ** Hook Timing:** Proper use of init, wp_head, and other WordPress lifecycle hooks
115128- ** Filter Override Protection:** Prevents other plugins from disabling optimizations
116129- ** Action Consolidation:** Organized hook management for better performance
117130
118131### Option Caching System
132+
119133- ** Static Caching:** ` es_optimizer_get_options() ` function with static cache
120134- ** Database Query Reduction:** Minimizes repeated option retrieval
121135- ** Memory Efficiency:** Efficient caching without memory overhead
@@ -124,18 +138,21 @@ add_action( 'plugins_loaded', 'es_optimizer_init' );
124138## Development Standards
125139
126140### Error Handling
141+
127142- ** WP_Error Usage:** Consistent error object returns throughout
128143- ** Comprehensive Logging:** Structured logging with severity levels
129144- ** Security Logging:** Detailed logs for security events
130145- ** User Feedback:** Clear error messages without information disclosure
131146
132147### Documentation
148+
133149- ** PHPDoc Compliance:** Complete documentation for all functions
134150- ** Security Comments:** Detailed security justifications
135151- ** Code Examples:** Clear usage examples in documentation
136152- ** Version Control:** Comprehensive changelog maintenance
137153
138154### Testing & Quality Assurance
155+
139156- ** PHPStan Level 5:** Static analysis compliance
140157- ** PHPCS WordPress Standards:** Full coding standards compliance
141158- ** PHPMD Compliance:** Code quality and complexity management
@@ -144,34 +161,39 @@ add_action( 'plugins_loaded', 'es_optimizer_init' );
144161## When Reviewing Code
145162
146163### Critical Issues to Flag
164+
1471651 . ** Performance Impact** (optimization conflicts, excessive resource usage)
1481662 . ** WordPress Compatibility** (plugin/theme conflicts, hook interference)
1491673 . ** Security Vulnerabilities** (input validation, output escaping)
1501684 . ** WordPress Standard Violations** (coding standards, API misuse)
1511695 . ** Option Management Issues** (database performance, caching problems)
152170
153171### Plugin-Specific Security Concerns
172+
1541731 . ** DNS Prefetch Validation:** Ensure domain inputs are properly validated
1551742 . ** Settings Security:** Verify admin-only access and nonce verification
1561753 . ** Hook Priority Conflicts:** Check for potential conflicts with other plugins
1571764 . ** Input Sanitization:** Validate all user-provided domains and settings
1581775 . ** Output Escaping:** Ensure all dynamic content is properly escaped
159178
160179### Performance Focus Areas
180+
1611811 . ** Frontend Optimization:** Script and style removal effectiveness
1621822 . ** Admin Performance:** Conditional asset loading efficiency
1631833 . ** Database Optimization:** Option caching and query reduction
1641844 . ** Hook Performance:** Efficient hook management and execution
1651855 . ** Memory Usage:** Optimization without excessive memory consumption
166186
167187### Positive Patterns to Recognize
188+
1681891 . ** WordPress API Compliance:** Proper use of WordPress hooks and functions
1691902 . ** Performance-First Design:** Optimizations that genuinely improve site speed
1701913 . ** User Experience:** Clear interface for managing optimizations
1711924 . ** Compatibility Focus:** Safe optimizations that don't break functionality
1721935 . ** Documentation Quality:** Clear documentation of optimization effects
173194
174195### Suggestions to Provide
196+
1751971 . ** WordPress-Specific Solutions:** Prefer WordPress APIs over generic PHP
1761982 . ** Performance Enhancements:** Additional optimization opportunities
1771993 . ** Compatibility Improvements:** Better plugin/theme compatibility
0 commit comments