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:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user