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,142 +1,72 @@
# Architecture — krolewskie-miody.pl
# Architektura
## Repository Structure
**Data analizy:** 2026-05-19
Only `wp-content/` and WordPress root files are tracked in Git.
`wp-includes/` and `wp-admin/` core directories are present but represent standard WordPress core.
## Przegląd Wzorca
```
krolewskie-miody.pl/
├── wp-config.php # DB config + constants
├── .htaccess # Rewrites, max_input_vars=10000
├── index.php # WP entry point
├── wp-blog-header.php # WP bootstrap
├── wp-content/
│ ├── themes/
│ │ ├── betheme/ # Active theme (parent, no child)
│ │ ├── twentytwentyfive/
│ │ ├── twentytwentyfour/
│ │ └── twentytwentythree/
│ └── plugins/ # 76 plugins
├── .paul/ # PAUL project management
├── .serena/ # Serena AI tooling
├── .vscode/ # VS Code + FTP config
└── CLAUDE.md # AI assistant instructions
```
**Ogólnie:** monolityczna aplikacja WordPress/WooCommerce z dużą liczbą pluginów i vendorowym motywem.
## Theme Architecture: BeTheme (betheme/)
**Kluczowe cechy:**
- Request lifecycle kontroluje WordPress core przez `index.php`, `wp-blog-header.php`, `wp-load.php` i `wp-settings.php`.
- Logika sprzedażowa przechodzi przez WooCommerce w `wp-content/plugins/woocommerce/`.
- Customizacja rozpoznana w kodzie to plugin `wp-content/plugins/ws-inpost-map/`.
- Motyw `wp-content/themes/betheme/` dostarcza dużą część warstwy prezentacji i shortcodeów.
```
betheme/
├── functions.php # Theme bootstrap (defines MFN_THEME_VERSION)
├── style.css # Theme header metadata only
├── woocommerce.php # WooCommerce template root
├── header.php / header-shop.php # Header templates
├── footer.php # Footer template (19KB)
├── style.php / style-colors.php # Dynamic PHP-generated CSS
├── functions/ # Core theme PHP logic
│ ├── theme-functions.php # 119KB — main hooks & functions
│ ├── theme-head.php # 79KB — HEAD/frontend logic
│ ├── theme-woocommerce.php # 72KB — WooCommerce customization (1,752 lines)
│ ├── theme-shortcodes.php # 405KB / 13,793 lines — visual builder shortcodes
│ ├── theme-hooks.php # Hook definitions
│ ├── theme-menu.php # Menu handling (350 lines)
│ ├── admin/ # Admin-side classes
│ ├── builder/ # Visual builder (class-mfn-builder*.php)
│ ├── modules/ # Dynamic data module
│ ├── plugins/
│ │ ├── visual-composer.php # 81KB VC integration
│ │ └── elementor/ # Elementor support
│ ├── post-types/ # Custom post type classes
│ └── widgets/ # Theme widgets
├── woocommerce/ # 27 WooCommerce template overrides
│ ├── archive-product.php
│ ├── content-product.php
│ ├── content-single-product.php
│ ├── cart/ (5 files)
│ ├── checkout/form-checkout.php
│ ├── single-product/ (6+ files)
│ ├── loop/ (4 files)
│ ├── myaccount/downloads.php
│ └── notices/ (2 files)
├── muffin-options/
│ └── theme-options.php # 337KB master options panel
├── visual-builder/ # Muffin's visual page builder
├── css/ # Pre-compiled stylesheets
├── js/ # Pre-compiled JavaScript
├── includes/ # Template partials
├── templates/ # Page templates
├── languages/ # Translations
└── wpml/wpml-config.xml # WPML multilingual config
```
## Warstwy
## Class Architecture (BeTheme)
**WordPress Core:**
- Cel: bootstrap aplikacji, ładowanie konfiguracji, pluginów, motywów i hooków.
- Lokalizacje: `index.php`, `wp-load.php`, `wp-settings.php`, `wp-config.php`.
- Uwaga: w repozytorium nie ma pełnego `wp-admin/` ani `wp-includes/`, więc snapshot jest niepełnym drzewem WordPress.
BeTheme uses a class-per-feature pattern with `mfn_` prefix on all functions:
**WooCommerce:**
- Cel: koszyk, checkout, zamówienia, płatności, wysyłki i model danych sklepu.
- Lokalizacje: `wp-content/plugins/woocommerce/`, pluginy `woo-*`, `woocommerce-*`.
- Używane przez: customowy plugin `wp-content/plugins/ws-inpost-map/` oraz liczne integracje płatności/dostaw.
**Admin classes** (`functions/admin/`):
- `class-mfn-api.php`, `class-mfn-dashboard.php`, `class-mfn-helper.php`
- `class-mfn-update.php`, `class-mfn-plugins.php`, `class-mfn-setup.php`
**Motyw:**
- Cel: frontend, szablony, shortcode'y i builder.
- Lokalizacje: `wp-content/themes/betheme/`, `wp-content/themes/twentytwenty*/`.
- Ryzyko: brak widocznego child theme; customizacje w `wp-content/themes/betheme/` utrudnią aktualizacje.
**Builder classes** (`functions/builder/`):
- `class-mfn-builder.php` — main builder
- `class-mfn-builder-fields.php` — 2.4MB field definitions
- `class-mfn-builder-admin.php` — 154KB
- `class-mfn-builder-front.php` — 136KB
- `class-mfn-builder-woo-helper.php` — WooCommerce builder integration
**Custom Plugin: `ws-inpost-map`:**
- Cel: dodać wybór Paczkomatu InPost na checkout i zapisać wybrany punkt do zamówienia.
- Entry point: `wp-content/plugins/ws-inpost-map/ws-inpost-map.php`.
- Manager: `wp-content/plugins/ws-inpost-map/App/WsInpostMap.php`.
- Hooki checkoutu: `wp-content/plugins/ws-inpost-map/App/WsInpostActions.php`.
- Metoda wysyłki: `wp-content/plugins/ws-inpost-map/App/WsInpostShippingMethod.php`.
- Panel ustawień: `wp-content/plugins/ws-inpost-map/App/WSInpostSettings.php`.
- Assety: `wp-content/plugins/ws-inpost-map/App/Assets.php`.
**Post type classes** (`functions/post-types/`):
- `class-mfn-post-type-page.php`, `class-mfn-post-type-product.php`
- `class-mfn-post-type-template.php` — 84KB
- 10+ additional post type classes
## Przepływ Danych
**Elementor widget classes** (`functions/plugins/elementor/`):
- `class-mfn-elementor.php` + 80+ widget classes
**Checkout z Paczkomatem:**
1. WordPress ładuje plugin przez `wp-content/plugins/ws-inpost-map/ws-inpost-map.php`.
2. `WSIM_InpostMapPlugin` uruchamia `WsInpostMapOnCheckout\App\WsInpostMap`.
3. `WsInpostMap` tworzy `WsInpostActions`, `Assets` i `WSInpostSettings`.
4. `WsInpostActions` rejestruje hooki WooCommerce, jeśli istnieje klasa `woocommerce` i opcja `active-button` jest włączona.
5. Frontend checkoutu ładuje mapę i pole `billing__paczkomat_id`.
6. `saveCustomFieldOrderMeta` zapisuje wartość jako order meta `paczkomat_id`.
7. `displayPaczkomatFieldInOrder` pokazuje zapisany Paczkomat w adminie zamówienia.
## WordPress Request Flow
**Metoda dostawy:**
1. `woocommerce_shipping_init` ładuje `App/WsInpostShippingMethod.php`.
2. `woocommerce_shipping_methods` rejestruje `wsim_inpost_shipping_method`.
3. `WSIM_InpostShippingMethod` pobiera ustawienia instancji WooCommerce i dodaje rate przez `calculate_shipping`.
```
HTTP Request
→ index.php (defines WP_USE_THEMES = true)
→ wp-blog-header.php
→ wp-load.php → wp-config.php (DB + constants)
→ wp-settings.php (load plugins + theme)
→ betheme/functions.php (theme init: MFN_THEME_VERSION = 27.6.4)
→ Loads theme-options.php, theme-functions.php, theme-head.php
→ WordPress template hierarchy selects template file
→ WooCommerce hooks modify product/cart/checkout rendering
```
## Entry Points
## WooCommerce Integration Points
- `index.php` - web entry point WordPress.
- `wp-login.php`, `xmlrpc.php`, `wp-cron.php` - standardowe entry pointy WordPress.
- `wp-content/plugins/ws-inpost-map/ws-inpost-map.php` - entry point customowego pluginu.
- `wp-content/themes/betheme/functions.php` - bootstrap motywu.
1. **Theme support declared** in `theme-woocommerce.php`:
- `wc-product-gallery-zoom`, `wc-product-gallery-lightbox`, `wc-product-gallery-slider`
- Custom image sizes for thumbnails and single product
## Cross-Cutting Concerns
2. **Hooks removed** (theme replaces defaults):
- `woocommerce_before_main_content` wrappers, breadcrumb, sidebar, sale flash, product thumbnail
- Hooki WordPress/WooCommerce są głównym mechanizmem integracji.
- Dane sklepu żyją w bazie WordPress/WooCommerce, a customowe dane InPost są w order meta `paczkomat_id`.
- Tłumaczenia przez text domain `ws-inpost-map` i katalog `wp-content/plugins/ws-inpost-map/languages/`.
- Assety frontendowe pluginu InPost są ładowane globalnie przez `wp_enqueue_scripts`, a nie tylko na checkout.
3. **Hooks added** (theme enhancements):
- Quantity buttons, wishlist button, excerpt in loop, cart fragment AJAX
4. **Template overrides** (`betheme/woocommerce/`):
- 27 files override WooCommerce default templates
## Custom Code Locations
| Location | Purpose |
|----------|---------|
| `betheme/functions/theme-woocommerce.php` | WooCommerce hooks & filters |
| `betheme/functions/theme-functions.php` | Theme hooks, helpers, shortcodes |
| `betheme/woocommerce/` | WooCommerce template overrides |
| `code-snippets` plugin | DB-stored PHP snippets (admin-managed) |
| `head-footer-code` plugin | Header/footer injection |
| `wp-headers-and-footers` plugin | Global header/footer scripts |
## Database
- **Engine:** MariaDB at `mariadb114.miody.nazwa.pl`
- **Database:** `miody_miodynew`
- **Table prefix:** `wp_` (default — not hardened)
- **Custom tables:** None confirmed outside standard WordPress/WooCommerce tables
- **Schema doc:** `.paul/codebase/db_schema.md`
---
*Aktualizuj po zmianie aktywnego motywu, checkoutu, płatności, dostaw albo custom pluginów.*