From 93f55e8952cbc9bb58a9240a803b350be65d2389 Mon Sep 17 00:00:00 2001 From: FrankZamora Date: Thu, 6 Nov 2025 22:46:03 -0600 Subject: [PATCH] Quitar strategy defer para que wp_localize_script funcione - Issue #110 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PROBLEMA: - wp_localize_script no genera variable apusTheme en HTML - WordPress no puede inyectar scripts inline cuando se usa strategy => 'defer' - Resultado: JavaScript no tiene acceso a apusTheme.themeUrl - fetch() usa ruta incorrecta y carga página 404 en modalContainer SOLUCIÓN: - Quitar strategy => 'defer' de wp_enqueue_script - Usar solo 'true' (in_footer => true) como 5to parámetro - Incrementar versión a 1.0.2 para cache busting - Ahora wp_localize_script SÍ inyecta apusTheme correctamente REFERENCIA: - https://developer.wordpress.org/reference/functions/wp_localize_script/ - wp_localize_script requiere que script NO use defer/async ARCHIVO: - wp-content/themes/apus-theme/inc/enqueue-scripts.php:193-199 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- wp-content/themes/apus-theme/inc/enqueue-scripts.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/wp-content/themes/apus-theme/inc/enqueue-scripts.php b/wp-content/themes/apus-theme/inc/enqueue-scripts.php index 6565d27b..e46bc664 100644 --- a/wp-content/themes/apus-theme/inc/enqueue-scripts.php +++ b/wp-content/themes/apus-theme/inc/enqueue-scripts.php @@ -194,11 +194,8 @@ function apus_enqueue_custom_assets() { 'apus-main-js', get_template_directory_uri() . '/assets/js/main.js', array('apus-bootstrap-js'), - '1.0.1', // Cache bust: fix modal URL - array( - 'in_footer' => true, - 'strategy' => 'defer', - ) + '1.0.2', // Cache bust: remove defer for wp_localize_script compatibility + true // Load in footer (defer removed for wp_localize_script to work) ); // Localize script to pass theme URL to JavaScript