| @@ -2,8 +2,18 @@ | ||
| 2 | 2 | defined('ABSPATH') || exit; |
| 3 | 3 | |
| 4 | 4 | use FluentCart\App\Vite; |
| 5 | 5 | |
| 6 | +// The is_page() guard below exists for the shortcode path, where this view | |
| 7 | +// renders INSIDE a real page whose wp_head() already ran. A route that takes | |
| 8 | +// over the request and renders a whole document is the opposite case: it needs | |
| 9 | +// wp_head()/wp_footer() precisely BECAUSE nothing else will print them — and | |
| 10 | +// on a site with a static front page, a route hanging off home_url() makes | |
| 11 | +// is_page() true for reasons that have nothing to do with this view. Passing | |
| 12 | +// true explicitly says "I am the whole document", and forces the call. | |
| 13 | +$force_wp_head = isset($wp_head) && $wp_head === true; | |
| 14 | +$force_wp_footer = isset($wp_footer) && $wp_footer === true; | |
| 15 | + | |
| 6 | 16 | $wp_head = !((isset($wp_head) && $wp_head === false)); |
| 7 | 17 | $wp_footer = !((isset($wp_footer) && $wp_footer == false)); |
| 8 | 18 | ?> |
| 9 | 19 | <!DOCTYPE html> |
| @@ -15,9 +25,9 @@ | ||
| 15 | 25 | <?php endif; ?> |
| 16 | 26 | <?php |
| 17 | 27 | |
| 18 | 28 | |
| 19 | -if (!is_page() && \FluentCart\App\App::request()->get('action') !== 'elementor' && $wp_head) { | |
| 29 | +if (($force_wp_head || !is_page()) && \FluentCart\App\App::request()->get('action') !== 'elementor' && $wp_head) { | |
| 20 | 30 | remove_action('wp_head', 'print_emoji_detection_script', 7); |
| 21 | 31 | remove_action('wp_print_styles', 'print_emoji_styles'); |
| 22 | 32 | wp_head(); |
| 23 | 33 | } |
| @@ -25,9 +35,9 @@ | ||
| 25 | 35 | if (isset($styles) && is_array($styles) && !empty($enqueue_prefix)) { |
| 26 | 36 | Vite::printAllStyles($styles, $enqueue_prefix.'_styles'); |
| 27 | 37 | } |
| 28 | 38 | ?> |
| 29 | -<body> | |
| 39 | +<body class="<?php echo esc_attr(implode(' ', \FluentCart\App\Services\Theme\FrontendTheme::bodyClasses([]))); ?>"> | |
| 30 | 40 | |
| 31 | 41 | <div style="width: 100%; box-sizing: border-box"> |
| 32 | 42 | <?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 33 | 43 | </div> |
| @@ -38,9 +48,9 @@ | ||
| 38 | 48 | if (function_exists('wp_enqueue_block_template_skip_link')) { |
| 39 | 49 | wp_enqueue_block_template_skip_link(); |
| 40 | 50 | } |
| 41 | 51 | |
| 42 | -if (!is_page() && \FluentCart\App\App::request()->get('action') !== 'elementor' && $wp_footer) { | |
| 52 | +if (($force_wp_footer || !is_page()) && \FluentCart\App\App::request()->get('action') !== 'elementor' && $wp_footer) { | |
| 43 | 53 | wp_footer(); |
| 44 | 54 | } |
| 45 | 55 | |
| 46 | 56 | if (isset($scripts) && is_array($scripts) && !empty($enqueue_prefix)) { |