| 1 |
<?php |
| 2 |
/** |
| 3 |
* Woo Builder wrapper for Single Product. |
| 4 |
* |
| 5 |
* @package King_Addons |
| 6 |
*/ |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
$template_id = apply_filters('king_addons/woo_builder/current_template_id', 0, 'single_product'); |
| 13 |
|
| 14 |
if (!$template_id) { |
| 15 |
wc_get_template('single-product.php'); |
| 16 |
return; |
| 17 |
} |
| 18 |
|
| 19 |
wp_enqueue_style(KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-builder-style'); |
| 20 |
wp_enqueue_script(KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-builder-script'); |
| 21 |
|
| 22 |
get_header('shop'); |
| 23 |
|
| 24 |
do_action('woocommerce_before_main_content'); |
| 25 |
|
| 26 |
global $post; |
| 27 |
if ($post instanceof WP_Post) { |
| 28 |
setup_postdata($post); |
| 29 |
} |
| 30 |
if ($post instanceof WP_Post && function_exists('wc_setup_product_data')) { |
| 31 |
wc_setup_product_data($post); |
| 32 |
} |
| 33 |
|
| 34 |
do_action('king_addons/woo_builder/before_render', 'single_product', $template_id); |
| 35 |
echo '<div class="king-addons-woo-builder king-addons-woo-builder--single-product" data-ka-context="single_product">'; |
| 36 |
echo \Elementor\Plugin::$instance->frontend->get_builder_content_for_display($template_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 37 |
echo '</div>'; |
| 38 |
do_action('king_addons/woo_builder/after_render', 'single_product', $template_id); |
| 39 |
|
| 40 |
if ($post instanceof WP_Post) { |
| 41 |
wp_reset_postdata(); |
| 42 |
} |
| 43 |
if (function_exists('wc_reset_product_data')) { |
| 44 |
wc_reset_product_data(); |
| 45 |
} |
| 46 |
|
| 47 |
do_action('woocommerce_after_main_content'); |
| 48 |
|
| 49 |
get_footer('shop'); |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|