diff --git a/wp-content/themes/apus-theme/assets/js/main.js b/wp-content/themes/apus-theme/assets/js/main.js index 2792a7f3..d9fe1619 100644 --- a/wp-content/themes/apus-theme/assets/js/main.js +++ b/wp-content/themes/apus-theme/assets/js/main.js @@ -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; diff --git a/wp-content/themes/apus-theme/inc/enqueue-scripts.php b/wp-content/themes/apus-theme/inc/enqueue-scripts.php index 9d42fc2c..05a36d7d 100644 --- a/wp-content/themes/apus-theme/inc/enqueue-scripts.php +++ b/wp-content/themes/apus-theme/inc/enqueue-scripts.php @@ -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);