🧑💻 Development#
Tài liệu này dành cho developer muốn hiểu, mở rộng hoặc maintain plugin Sport Plugin.
📁 Kiến trúc tổng thể#
Plugin được thiết kế theo hướng modular + tách biệt logic rõ ràng:admin/ → Xử lý giao diện & logic trong WP Admin
assets/ → Tài nguyên frontend (CSS, JS, fonts, images)
build/ → Bundle UI (iframe + template build sẵn)
customizers/ → Cấu hình từng module shortcode
classes/ → Core class xử lý (OOP)
includes/ → Hệ thống lõi (hooks, API, data)
layouts/ → Render UI (view layer)
⚙️ Luồng hoạt động (Core Flow)#
2.
Load cấu hình từ customizers/
4.
Render thông qua layouts/
5.
Assets được load từ build/ hoặc assets/
MVC (Model: includes, View: layouts, Controller: shortcode/customizer)
🧩 Customizer System (Quan trọng nhất)#
customizers/
├── 6in1/
├── fixture/
├── player_board/
├── rank/
├── rate/
├── result/
Vai trò:#
Định nghĩa config cho từng shortcode/module
Cho phép thay đổi hiển thị mà không sửa core
🧠 Data Layer#
includes/
├── match-data.php
├── customizer-data.php
Nhiệm vụ:#
Cache / xử lý business logic
🎨 Render Layer (UI)#
layouts/
├── shortcode/
├── settings/
Nguyên tắc:#
Tách biệt hoàn toàn với data
📦 Build System#
build/
├── *_iframe/
├── css/
├── assets/
Vai trò:#
Chứa UI đã build sẵn (iframe-based)
Tối ưu performance (load nhanh)
🔌 Hooks & Integration#
Plugin sử dụng WordPress hooks:Có thể mở rộng bằng cách:
⚙️ Admin System#
admin/
├── functions-admin.php
├── assets/
Chức năng:#
Load script riêng cho admin
🌐 API & Data Sync#
Nhiệm vụ:#
🌍 Internationalization (i18n)#
languages/
├── .po / .mo / .json
Sử dụng:#
🔐 Security#
🧪 Debug & Dev#
🚀 Best Practices#
Không viết logic trong view
Dùng WordPress API thay vì code thuần
📌 Extend plugin#
Thêm module mới:#
2.
Thêm xử lý data (nếu cần):
Thêm shortcode:#
Thêm assets:#
Plugin dùng iframe + build → giảm tải server
Nên cache data nếu scale lớn
🧭 Định hướng phát triển#
Gutenberg Block thay shortcode
Cache nâng cao (Redis / Transient API)
👉 Đây là plugin có kiến trúc tốt, phù hợp cho hệ thống dữ liệu realtime và có khả năng scale cao.Ngày cập nhật 2026-03-26 14:37:31