Skip to content

Commit 9ef06c0

Browse files
authored
Refactor
1 parent e30dce2 commit 9ef06c0

20 files changed

+1927
-2426
lines changed

.github/copilot-instructions.md

Lines changed: 48 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2,111 +2,65 @@
22
applyTo: '**'
33
---
44

5-
# WordPress Plugin Development Standards
5+
# EngineScript Site Exporter — Development Standards
66

7-
## 🎯 Core Principles
8-
9-
**Work Environment:** Remote GitHub Codespaces only. Never suggest local Terminal commands.
10-
11-
**WordPress First:** Use WordPress APIs, hooks, and standards exclusively. Avoid non-WP frameworks.
12-
13-
**Security Critical:** Sanitize all input, escape all output, use WordPress security functions.
14-
15-
**Thorough Analysis:** Read complete files (minimum 1500 lines) for accurate code review.
16-
17-
## 📋 Essential Requirements
18-
19-
### WordPress Compatibility
7+
## Project Context
208

9+
- **Plugin:** EngineScript Site Exporter (WordPress site export/backup plugin)
2110
- **WordPress:** 6.5+ minimum
22-
- **PHP:** 7.4+ minimum
23-
- **WooCommerce:** 5.0+ (when applicable)
24-
- Follow [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/) for PHP, JS, CSS, HTML, and accessibility
25-
26-
### Code Quality Standards
27-
28-
1. **Security First:** Always sanitize input (`sanitize_*()`) and escape output (`esc_*()`)
29-
2. **WordPress APIs:** Use WP functions instead of raw PHP/SQL
30-
3. **Hook System:** Proper use of `add_action()` and `add_filter()`
31-
4. **Internationalization:** Use `__()`, `_e()`, `esc_html__()` for all strings
32-
5. **Performance:** Avoid N+1 queries, use WP caching, optimize database calls
33-
34-
## 🔒 Security Requirements (Critical)
35-
36-
**Input Handling:**
37-
- Use `sanitize_text_field()`, `sanitize_email()`, `wp_kses()` for user input
38-
- Validate with `is_email()`, `absint()`, `wp_verify_nonce()` for security
39-
- Use prepared statements for database queries (`$wpdb->prepare()`)
40-
41-
**Output Security:**
42-
- Escape all output: `esc_html()`, `esc_attr()`, `esc_url()`, `esc_js()`
43-
- Use `wp_nonce_field()` and `wp_verify_nonce()` for forms
44-
- Check permissions with `current_user_can()` before sensitive operations
45-
46-
**Vulnerability Prevention:**
47-
- Prevent SQL injection, XSS, CSRF, Local File Inclusion (LFI), and path traversal
48-
- Follow principle of least privilege
11+
- **PHP:** 7.4+ minimum (use typed parameters, return types, short arrays `[]`, null coalescing `??=`)
12+
- **License:** GPL-3.0-or-later
13+
- **Text Domain:** `enginescript-site-exporter`
14+
- **Function Prefix:** `sse_`
15+
- **Constant Prefix:** `SSE_`
16+
- **Work Environment:** Remote GitHub Codespaces only
17+
18+
Follow [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/) for PHP, JS, CSS, HTML, and accessibility.
19+
20+
## Security (Critical)
21+
22+
All input must be sanitized; all output must be escaped. No exceptions.
23+
24+
- **Input:** `sanitize_text_field()`, `sanitize_file_name()`, `absint()`, `wp_kses()`, `wp_verify_nonce()`
25+
- **Output:** `esc_html()`, `esc_attr()`, `esc_url()`, `esc_js()`
26+
- **Forms:** `wp_nonce_field()` + `wp_verify_nonce()` for CSRF protection
27+
- **Permissions:** `current_user_can( 'manage_options' )` before any sensitive operation
28+
- **Database:** Use `$wpdb->prepare()` for any raw SQL (prefer WordPress APIs over raw queries)
29+
- **File operations:** Validate paths with `realpath()`, prevent directory traversal (`..`), use WordPress Filesystem API
30+
- **Prevent:** SQL injection, XSS, CSRF, LFI, path traversal, SSRF
4931
- Auto-identify and fix security issues when found
5032

51-
## 📝 Documentation & Versioning
52-
53-
**Changelog Management:**
54-
- Always update CHANGELOG.md and readme.txt when making code changes
55-
- **Sync both changelogs:** CHANGELOG.md and readme.txt changelog section
56-
- Use "Unreleased" section for ongoing changes
57-
58-
**Version Release Process (only when instructed):**
59-
- Follow semantic versioning (MAJOR.MINOR.PATCH)
60-
- Update version in: plugin header, README.md, readme.txt, CHANGELOG.md, GEMINI.md, and `.pot` language files, constants section, package.json, and composer.json
61-
- Move "Unreleased" changes to new version section in both changelogs
62-
- **Never auto-update versions** - wait for explicit instruction
33+
## Code Quality
6334

64-
**Code Documentation:**
65-
- Use PHPDoc with `@param`, `@return`, `@since` tags
66-
- Write clear function/class descriptions
67-
- Document security considerations and hooks used
35+
- Use WordPress APIs instead of raw PHP equivalents (e.g., `wp_mkdir_p()` not `mkdir()`)
36+
- Use `add_action()` / `add_filter()` for all hook registrations
37+
- Use `WP_Error` for error handling — log errors without exposing sensitive data
38+
- Enqueue assets with `wp_enqueue_style()` / `wp_enqueue_script()` — no inline CSS or JS
39+
- Internationalize all user-facing strings: `__()`, `_e()`, `esc_html__()`, `esc_attr__()`
40+
- PHPDoc all functions with `@param`, `@return`, `@since` tags
41+
- Remove dead code; keep functions focused and well-named
6842

69-
**Internationalization (i18n):**
70-
- Update `.pot` language files when adding or modifying translatable strings
71-
- Always use the correct text domain when dealing with translation functions
72-
- Mark all user-facing strings with `__()`, `_e()`, `esc_html__()`, `esc_attr__()`, etc.
43+
## Documentation & Versioning
7344

74-
## ⚡ Performance & Quality
45+
**Changelogs:**
46+
- Always update both CHANGELOG.md and readme.txt when making code changes
47+
- Keep both changelogs in sync — use "Unreleased" section for ongoing changes
7548

76-
**Performance Optimization:**
77-
- Use WordPress caching (`wp_cache_*()`, transients)
78-
- Optimize database queries, avoid N+1 problems
79-
- Proper asset enqueueing with `wp_enqueue_*()` functions
80-
- Focus on correctness first, then optimize
81-
82-
**Code Architecture:**
83-
- Group by feature, not by type
84-
- Use descriptive function/variable names
85-
- Remove unused code automatically
86-
- Follow feature-sliced design when applicable
49+
**Version Releases (only when explicitly instructed):**
50+
- Follow semantic versioning (MAJOR.MINOR.PATCH)
51+
- Update version in: plugin header, `ES_SITE_EXPORTER_VERSION` constant, README.md, readme.txt, CHANGELOG.md, GEMINI.md, `.pot` file header, and composer.json
52+
- Move "Unreleased" entries to the new version section
53+
- Never auto-update versions
8754

88-
**Error Handling:**
89-
- Use `WP_Error` for WordPress-specific errors
90-
- Log errors without exposing sensitive data
91-
- Handle edge cases gracefully
92-
- Validate all function parameters
55+
**Internationalization:**
56+
- Update `.pot` file when adding or modifying translatable strings
57+
- Always use text domain `enginescript-site-exporter`
9358

94-
## 🚀 Workflow & Automation
59+
## Workflow
9560

96-
**Task Execution:**
97-
- Make changes directly to existing files (don't create duplicates)
98-
- Proceed automatically unless action is destructive
61+
- Edit files in place — don't create duplicates
62+
- Proceed automatically unless the action is destructive (data loss, deletion)
9963
- Auto-identify and fix bugs when possible
100-
- Only ask confirmation for data loss/deletion scenarios
101-
102-
**File Management:**
103-
- Edit files in place (e.g., modify `admin.php` directly)
10464
- Create new files only when truly necessary
105-
- Avoid file duplication and unnecessary rewrites
106-
- Maintain clean project structure
107-
108-
**Communication:**
109-
- Provide concise, actionable responses
110-
- Use clear formatting for readability
111-
- Never create change summaries as separate .md files
112-
- Focus on specific changes made, not verbose explanations
65+
- Never create change-summary markdown files
66+
- Keep responses concise and actionable

0 commit comments

Comments
 (0)