Corregir footer duplicado - Issue #110

PROBLEMA:
- Footer se renderizaba duplicado con página 404 entre las duplicaciones
- main.js cargaba 'modal-contact.html' con ruta relativa incorrecta
- fetch('modal-contact.html') resolvía a URL base en vez de directorio del tema
- WordPress devolvía página 404 completa que se insertaba en #modalContainer

SOLUCIÓN:
1. Agregar wp_localize_script en enqueue-scripts.php para pasar themeUrl a JS
2. Corregir main.js para usar apusTheme.themeUrl + '/modal-contact.html'
3. Agregar fallback a '/wp-content/themes/apus-theme/modal-contact.html'

ARCHIVOS:
- wp-content/themes/apus-theme/inc/enqueue-scripts.php:204-212
- wp-content/themes/apus-theme/assets/js/main.js:59-62

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2025-11-06 22:37:21 -06:00
parent 0779cd144c
commit bda6fa9ee8
2 changed files with 16 additions and 1 deletions

View File

@@ -56,7 +56,12 @@ function loadContactModal() {
const modalContainer = document.getElementById('modalContainer');
if (!modalContainer) return;
fetch('modal-contact.html')
// Use theme URL from localized script
const modalUrl = (typeof apusTheme !== 'undefined' && apusTheme.themeUrl)
? apusTheme.themeUrl + '/modal-contact.html'
: '/wp-content/themes/apus-theme/modal-contact.html';
fetch(modalUrl)
.then(response => response.text())
.then(html => {
modalContainer.innerHTML = html;

View File

@@ -200,6 +200,16 @@ function apus_enqueue_custom_assets() {
'strategy' => 'defer',
)
);
// Localize script to pass theme URL to JavaScript
wp_localize_script(
'apus-main-js',
'apusTheme',
array(
'themeUrl' => get_template_directory_uri(),
'ajaxUrl' => admin_url('admin-ajax.php'),
)
);
}
add_action('wp_enqueue_scripts', 'apus_enqueue_custom_assets', 11);