This commit is contained in:
2026-05-19 20:05:59 +02:00
parent 82fb5ad653
commit e90c251d0b
28 changed files with 777 additions and 2158 deletions

View File

@@ -1,94 +1,49 @@
# Conventions — krolewskie-miody.pl
# Konwencje Kodu
## PHP Conventions (CLAUDE.md)
**Data analizy:** 2026-05-19
- **Standard:** PSR-12 formatting
- **Classes:** PascalCase — e.g. `MfnDynamicData`, `class-mfn-builder.php`
- **Methods/Functions:** snake_case — e.g. `mfn_woocommerce_product_reviews_tab_title()`
- **Database variables:** snake_case
- **Theme function prefix:** `mfn_` for all BeTheme functions
- **Max nesting depth:** 3 levels — extract deeper logic to named methods
- **Comments:** Only when explaining *why*, never *what*
- **Customizations:** Child theme or dedicated plugin only — never in WordPress core or parent theme directly
## Reguły Projektowe
## File Naming
Źródło: `CLAUDE.md`.
- Plugin/theme files: kebab-case — `class-mfn-builder.php`
- Class files: prefixed with `class-``class-mfn-dynamic-data.php`
- PHP powinien stosować PSR-12.
- Klasy: PascalCase.
- Metody: camelCase.
- Zmienne DB: snake_case.
- Unikać zagnieżdżeń powyżej 3 poziomów.
- Komentarze mają wyjaśniać "dlaczego", nie "co".
- Customizacje tylko w child theme albo dedykowanym pluginie, nigdy w core WordPress.
## WordPress Hook Usage
## Aktualne Wzorce W Kodzie
Hooks registered in `wp-content/themes/betheme/functions/`:
**WordPress/WooCommerce:**
- Integracja przez `add_action`, `add_filter`, `register_activation_hook`, `register_deactivation_hook`.
- Escaping i sanitizacja przez funkcje WordPress: `esc_html`, `esc_attr`, `sanitize_text_field`, `wp_verify_nonce`.
- Ustawienia przez WordPress Settings API w `wp-content/plugins/ws-inpost-map/App/WSInpostSettings.php`.
**Core hooks used:**
- `after_setup_theme` — theme init
- `init` — WP initialization
- `wp_enqueue_scripts` — script/style loading
- `pre_get_posts` — query modification
- `admin_menu` — admin customization
**Custom plugin `ws-inpost-map`:**
- Namespace: `WsInpostMapOnCheckout\App`.
- Autoloading PSR-4 w `wp-content/plugins/ws-inpost-map/composer.json`.
- Stałe pluginu: `WSIM_INPOST_MAP_PLUGIN_DIR_PATH`, `WSIM_INPOST_MAP_PLUGIN_DIR_URL`.
- Klasa shipping method `WSIM_InpostShippingMethod` nie jest namespacowana, bo WooCommerce ładuje ją jako nazwę klasy metody wysyłki.
**Custom theme hooks (mfn_):**
- `mfn_before_content` / `mfn_after_content`
- `mfn_before_shop_content` / `mfn_after_shop_content`
- `mfn_hook_bottom`
## Odchylenia I Miejsca Do Uważania
## WooCommerce Hook Pattern
- `wp-content/plugins/ws-inpost-map/App/WsInpostActions.php` używa mieszanki wcięć 2 spacje i stylu odbiegającego od PSR-12.
- `wp-content/plugins/ws-inpost-map/App/WSInpostSettings.php` jest duży względem reszty custom pluginu i łączy definicje pól, rendering admina, ustawienia oraz style dynamiczne.
- Brak widocznego child theme w `wp-content/themes/`; nie należy modyfikować `wp-content/themes/betheme/` bez wyraźnego powodu i planu aktualizacji.
- Kod vendorowy w `wp-content/plugins/` ma własne standardy; nie traktować go jako stylu dla nowych customizacji.
See `wp-content/themes/betheme/functions/theme-woocommerce.php`.
## Zalecany Kierunek Dla Nowych Zmian
**Remove defaults, then add custom:**
```php
// Remove WooCommerce defaults
remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action('woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
- Nowe customizacje sklepu dodawać w dedykowanym pluginie albo child theme.
- Dla zmian checkoutu najpierw sprawdzić kolizje z pluginami:
- `wp-content/plugins/flexible-checkout-fields/`
- `wp-content/plugins/woo-checkout-field-editor-pro/`
- `wp-content/plugins/woocommerce-checkout-manager/`
- `wp-content/plugins/ws-inpost-map/`
- Sanitizować dane wejściowe na granicy requestu i escape'ować przy renderowaniu HTML.
- Nie zapisywać sekretów w dokumentacji PAUL.
// Add theme equivalents
add_action('woocommerce_before_quantity_input_field', 'mfn_woocommerce_before_quantity_input_field');
add_action('woocommerce_after_add_to_cart_button', 'mfn_append_wishlist_button');
add_filter('loop_shop_columns', 'mfn_woo_loop_shop_columns', 20);
add_filter('woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
```
## CSS / JS Conventions
- **No build tooling** — no SASS, Webpack, or Gulp
- CSS and JS are pre-compiled and committed directly
- Main files: `betheme/css/be.css`, `betheme/js/scripts.js`
- Both minified and unminified versions maintained
- Custom CSS should go in child theme `style.css` (once child theme is created)
## Configuration Constants (wp-config.php)
Currently defined:
```php
define('RSSSL_KEY', '...'); // Really Simple SSL API key
define('WP_DEBUG', false); // Production mode
```
**Not yet defined (recommended):**
```php
define('DISALLOW_FILE_EDIT', true);
define('FORCE_SSL_ADMIN', true);
define('WP_MEMORY_LIMIT', '256M');
```
## Database Conventions
- Schema documented in `.paul/codebase/db_schema.md`
- Every schema change requires a new migration — never modify existing ones
- Use `$wpdb->prepare()` for all dynamic queries
- Table prefix: `wp_` (default)
## Version Control
- **Remote:** `https://git.project-pro.pl/Project-Pro/krolewskie-miody.pl.git`
- **Branch:** `main`
- **No `.gitignore`** — currently all files tracked (security risk; see concerns.md)
- Excluded from FTP deploy: `.git`, `.vscode`, `.paul`, `.serena`, `CLAUDE.md`
## Code Quality Tools
None configured. Recommended additions:
- `.phpcs.xml` — PHP CodeSniffer with WordPress/PSR-12 ruleset
- `phpstan.neon` — Static analysis
- `.eslintrc` — JavaScript linting
---
*Aktualizuj po ustaleniu automatycznego formatowania albo po wydzieleniu child theme/custom pluginu.*