72 lines
2.9 KiB
Markdown
72 lines
2.9 KiB
Markdown
# Conventions
|
|
|
|
> Generated by /paul:map-codebase — 2026-04-26
|
|
|
|
## PHP Conventions
|
|
|
|
### Current state (in existing code)
|
|
- **Style**: Procedural, no OOP
|
|
- **Naming**: snake_case with descriptive prefixes (`wcs_`, `bbloomer_`, `Divichild_`) — inconsistent across files
|
|
- **PHP version**: Basic PHP 5.x compatible constructs (no type hints, no match expressions)
|
|
- **Comments**: Minimal; PHPDoc used in divi-children-engine but not in functions.php
|
|
|
|
### Convention to follow when adding new code
|
|
- **Function prefix**: Use `szkolenia_` or `body_relax_` for all new functions
|
|
- **Security**: Always sanitize input (`sanitize_text_field()`), verify nonces for AJAX (`wp_verify_nonce()`), escape output (`esc_html()`, `wp_kses_post()`)
|
|
- **Hooks**: Register all hooks inside functions, not at file root level
|
|
- **Translations**: Wrap all user-facing strings in `__()` / `_e()` — text domain: `body-relax`
|
|
|
|
## CSS Conventions
|
|
|
|
### Current state
|
|
- Plain CSS (no preprocessor in production, SCSS compilation configured in VS Code)
|
|
- No BEM; simple semantic class names (`.icon_tags`, `.icon_profile`)
|
|
- ID-based selectors in admin CSS (anti-pattern)
|
|
- Hard-coded hex colors
|
|
- Breakpoints: 981px, 768px, 767px, 480px
|
|
|
|
### Convention to follow
|
|
- Namespace custom classes with `br-` prefix (e.g., `.br-availability-message`)
|
|
- Keep front-end CSS in `style.css`, admin CSS in `divi-children-engine/css/`
|
|
- Use SCSS variables for colors if using the Live Sass compiler
|
|
|
|
## JavaScript Conventions
|
|
|
|
### Current state
|
|
- Inline jQuery in PHP strings (no separate .js files in theme)
|
|
- Uses deprecated `.toggle()` (removed in jQuery 3.9+)
|
|
- References global `ajaxurl`
|
|
|
|
### Convention to follow
|
|
- Put new JS in separate files under `wp-content/themes/body-relax/js/`
|
|
- Enqueue via `wp_enqueue_script()` with jQuery dependency
|
|
- Use `wp_localize_script()` to pass ajaxurl and nonces
|
|
- Use `const`/`let`, avoid deprecated jQuery methods
|
|
|
|
## File Placement
|
|
|
|
| What to add | Where |
|
|
|------------|-------|
|
|
| WooCommerce filters/hooks | `wp-content/themes/body-relax/functions.php` |
|
|
| Admin UI / metaboxes | `wp-content/themes/body-relax/divi-children-engine/includes/` |
|
|
| Standalone cron scripts | Root of repo (like `cron-products.php`) |
|
|
| New plugin | `wp-content/plugins/` with own directory |
|
|
| Custom styles | `wp-content/themes/body-relax/style.css` |
|
|
|
|
## Git Conventions
|
|
|
|
### Current state
|
|
- Commit messages are all "Save" (no meaningful history)
|
|
- No `.gitignore` file
|
|
|
|
### Convention to follow
|
|
- Use conventional commits: `feat:`, `fix:`, `chore:`, `style:`
|
|
- Example: `feat: add availability countdown for last 3 spots`
|
|
|
|
## Deployment Notes
|
|
|
|
- FTP auto-upload is ON — every file save syncs to production immediately
|
|
- Do not edit Divi parent theme files (overwritten on update)
|
|
- Do not edit plugin files directly (overwritten on update) — use hooks/filters in theme instead
|
|
- The bbPress plugin is currently an exception (100+ modified files) — this is a known risk
|