fix: Include fonts in production build and strengthen theme override

Problem 1: Fonts not loading (404 errors)
Root Cause: Build script only copied app.js and app.css, not fonts folder
Solution: Include fonts directory in production build

Problem 2: Theme header/footer still showing on some themes
Root Cause: Header/footer removal only worked in 'full' mode, not for shortcode pages
Solution:
- Use blank template (spa-full-page.php) for ANY page with WooNooW shortcodes
- Remove theme elements for shortcode pages even in 'disabled' mode
- Stronger detection for Shop page (archive) shortcode check

Changes:
- build-production.sh: Copy fonts folder if exists
- TemplateOverride.php:
  * use_spa_template() now checks for shortcodes in disabled mode
  * should_remove_theme_elements() removes for shortcode pages
  * Added Shop page archive check for shortcode detection

Result:
 Fonts now included in production build (~500KB added)
 Theme header/footer removed on ALL shortcode pages
 Works with any theme (Astra, Twenty Twenty-Three, etc.)
 Clean SPA experience regardless of SPA mode setting
 Package size: 2.1M (was 1.6M, +500KB for fonts)
This commit is contained in:
Dwindi Ramadhana
2025-12-30 19:34:39 +07:00
parent e0777c708b
commit 48a5a5593b
2 changed files with 45 additions and 8 deletions

View File

@@ -68,11 +68,15 @@ echo "Copying SPA build files..."
mkdir -p ${BUILD_DIR}/${PLUGIN_NAME}/customer-spa/dist
mkdir -p ${BUILD_DIR}/${PLUGIN_NAME}/admin-spa/dist
# Customer SPA - only app.js and app.css
# Customer SPA - app.js, app.css, and fonts
cp customer-spa/dist/app.js ${BUILD_DIR}/${PLUGIN_NAME}/customer-spa/dist/
cp customer-spa/dist/app.css ${BUILD_DIR}/${PLUGIN_NAME}/customer-spa/dist/
if [ -d "customer-spa/dist/fonts" ]; then
cp -r customer-spa/dist/fonts ${BUILD_DIR}/${PLUGIN_NAME}/customer-spa/dist/
echo "✓ Copied customer-spa fonts"
fi
# Admin SPA - only app.js and app.css (no dynamic imports for now)
# Admin SPA - app.js and app.css
cp admin-spa/dist/app.js ${BUILD_DIR}/${PLUGIN_NAME}/admin-spa/dist/
cp admin-spa/dist/app.css ${BUILD_DIR}/${PLUGIN_NAME}/admin-spa/dist/