can_view_chatbot()) { return; } $has_chatbot_shortcode = false; $has_search_shortcode = false; $post = get_post(); if ($post) { $has_chatbot_shortcode = has_shortcode($post->post_content, 'shoponix_chatbot'); $has_search_shortcode = has_shortcode($post->post_content, 'shoponix_ai_search'); } if (!is_product() && !is_shop() && !is_front_page() && !$has_chatbot_shortcode && !$has_search_shortcode) { if (get_option('shoponix_enabled') !== 'yes') return; } wp_enqueue_style('shoponix-chat-widget', SHOPONIX_PLUGIN_URL . 'assets/css/chat-widget.css', [], SHOPONIX_VERSION); wp_enqueue_script('shoponix-core', SHOPONIX_PLUGIN_URL . 'assets/js/modules/core.js', ['jquery'], SHOPONIX_VERSION, true); wp_enqueue_script('shoponix-ui', SHOPONIX_PLUGIN_URL . 'assets/js/modules/ui.js', ['shoponix-core'], SHOPONIX_VERSION, true); wp_enqueue_script('shoponix-api', SHOPONIX_PLUGIN_URL . 'assets/js/modules/api.js', ['shoponix-core'], SHOPONIX_VERSION, true); wp_enqueue_script('shoponix-ecommerce', SHOPONIX_PLUGIN_URL . 'assets/js/modules/ecommerce.js', ['shoponix-core'], SHOPONIX_VERSION, true); wp_enqueue_script('shoponix-features', SHOPONIX_PLUGIN_URL . 'assets/js/modules/features.js', ['shoponix-core'], SHOPONIX_VERSION, true); wp_enqueue_script('shoponix-chat-init', SHOPONIX_PLUGIN_URL . 'assets/js/modules/init.js', ['shoponix-ui', 'shoponix-api', 'shoponix-ecommerce', 'shoponix-features'], SHOPONIX_VERSION, true); wp_localize_script('shoponix-core', 'shoponix_chat', [ 'ajax_url' => admin_url('admin-ajax.php'), 'rest_url' => esc_url_raw(rest_url()), 'nonce' => wp_create_nonce('shoponix_chat_nonce'), 'rest_nonce' => wp_create_nonce('wp_rest'), 'primary_color' => get_option('shoponix_primary_color', '#7c3aed'), 'live_support_url' => esc_url(get_option('shoponix_live_support_url', '')), 'live_support_phone' => esc_attr(get_option('shoponix_live_support_phone', '')), 'special_coupon' => esc_attr(get_option('shoponix_special_coupon', '')), 'special_coupon_msg' => esc_attr(get_option('shoponix_special_coupon_msg', '')), 'proactive_trigger' => is_product() ? get_option('shoponix_proactive_trigger', 'no') : 'no', 'proactive_delay' => intval(get_option('shoponix_proactive_delay', '30')), 'cart_contents_count' => (function_exists('WC') && WC()->cart) ? WC()->cart->get_cart_contents_count() : 0, 'cart_total' => (function_exists('WC') && WC()->cart) ? WC()->cart->get_cart_total() : 0, 'is_cart' => function_exists('is_cart') && is_cart(), 'is_checkout' => function_exists('is_checkout') && is_checkout(), 'current_product_id' => is_product() ? get_the_ID() : 0, 'current_product_name' => is_product() ? get_the_title() : '', 'locale' => get_locale(), 'ab_test_enabled' => get_option('shoponix_ab_test_enabled', 'no') ]); } public function shortcode() { if (!$this->can_view_chatbot()) { return ''; } ob_start(); include SHOPONIX_PLUGIN_DIR . 'templates/chat-window.php'; return ob_get_clean(); } public function search_shortcode() { if (!$this->can_view_chatbot()) { return ''; } ob_start(); ?>
can_view_chatbot()) { return; } echo $this->shortcode(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } }