| @@ -1,77 +1,79 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace UltimateStoreKit\Modules\GlossyCarousel; | |
| 4 | - | |
| 5 | -use UltimateStoreKit\Base\Ultimate_Store_Kit_Module_Base; | |
| 6 | - | |
| 7 | -if (!defined('ABSPATH')) { | |
| 8 | - exit; | |
| 9 | -} // Exit if accessed directly | |
| 10 | - | |
| 11 | -class Module extends Ultimate_Store_Kit_Module_Base { | |
| 12 | - | |
| 13 | - public static function is_active() { | |
| 14 | - return class_exists('woocommerce'); | |
| 15 | - } | |
| 16 | - | |
| 17 | - public function get_name() { | |
| 18 | - return 'usk-glossy-carousel'; | |
| 19 | - } | |
| 20 | - | |
| 21 | - public function get_widgets() { | |
| 22 | - return ['Glossy_Carousel']; | |
| 23 | - } | |
| 24 | - | |
| 25 | - public function add_product_post_class($classes) { | |
| 26 | - $classes[] = 'product'; | |
| 27 | - | |
| 28 | - return $classes; | |
| 29 | - } | |
| 30 | - | |
| 31 | - public function add_products_post_class_filter() { | |
| 32 | - add_filter('post_class', [$this, 'add_product_post_class']); | |
| 33 | - } | |
| 34 | - | |
| 35 | - public function remove_products_post_class_filter() { | |
| 36 | - remove_filter('post_class', [$this, 'add_product_post_class']); | |
| 37 | - } | |
| 38 | - | |
| 39 | - public function register_wc_hooks() { | |
| 40 | - wc()->frontend_includes(); | |
| 41 | - } | |
| 42 | - | |
| 43 | - public function __construct() { | |
| 44 | - | |
| 45 | - parent::__construct(); | |
| 46 | - | |
| 47 | - if (!empty($_REQUEST['action']) && 'elementor' === $_REQUEST['action'] && is_admin()) { | |
| 48 | - add_action('init', [$this, 'register_wc_hooks'], 5); | |
| 49 | - } | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * Modal data | |
| 53 | - */ | |
| 54 | - add_action('wp_ajax_nopriv_ultimate_store_kit_wc_product_quick_view_content', [$this, 'ultimate_store_kit_wc_product_quick_view_content']); | |
| 55 | - add_action('wp_ajax_ultimate_store_kit_wc_product_quick_view_content', [$this, 'ultimate_store_kit_wc_product_quick_view_content']); | |
| 56 | - | |
| 57 | - add_action('ultimate_store_kit_quick_view_product_title', 'woocommerce_template_single_title'); | |
| 58 | - add_action('ultimate_store_kit_quick_view_product_single_rating', 'woocommerce_template_single_rating'); | |
| 59 | - add_action('ultimate_store_kit_quick_view_product_single_price', 'woocommerce_template_single_price'); | |
| 60 | - add_action('ultimate_store_kit_quick_view_product_single_excerpt', 'woocommerce_template_single_excerpt'); | |
| 61 | - add_action('ultimate_store_kit_quick_view_product_single_add_to_cart', 'woocommerce_template_single_add_to_cart'); | |
| 62 | - add_action('ultimate_store_kit_quick_view_product_single_meta', 'woocommerce_template_single_meta'); | |
| 63 | - add_action('ultimate_store_kit_quick_view_product_sale_flash', 'woocommerce_show_product_sale_flash'); | |
| 64 | - add_action('ultimate_store_kit_quick_glossy_carousel_view_product_images', [$this, 'ultimate_store_kit_quick_view_product_images']); | |
| 65 | - } | |
| 66 | - | |
| 67 | - public function ultimate_store_kit_wc_product_quick_view_content() { | |
| 68 | - | |
| 69 | - $product_id = isset($_POST['product_id']) ? sanitize_text_field($_POST['product_id']) : ''; | |
| 70 | - | |
| 71 | - ultimate_store_kit_wc_product_quick_view_content($product_id); | |
| 72 | - } | |
| 73 | - | |
| 74 | - public function ultimate_store_kit_quick_view_product_images() { | |
| 75 | - ultimate_store_kit_quick_view_product_images(); | |
| 76 | - } | |
| 77 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace UltimateStoreKit\Modules\GlossyCarousel; | |
| 4 | + | |
| 5 | +use UltimateStoreKit\Base\Ultimate_Store_Kit_Module_Base; | |
| 6 | + | |
| 7 | +if (!defined('ABSPATH')) { | |
| 8 | + exit; | |
| 9 | +} // Exit if accessed directly | |
| 10 | + | |
| 11 | +class Module extends Ultimate_Store_Kit_Module_Base { | |
| 12 | + | |
| 13 | + public static function is_active() { | |
| 14 | + return class_exists('woocommerce'); | |
| 15 | + } | |
| 16 | + | |
| 17 | + public function get_name() { | |
| 18 | + return 'usk-glossy-carousel'; | |
| 19 | + } | |
| 20 | + | |
| 21 | + public function get_widgets() { | |
| 22 | + return ['Glossy_Carousel']; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public function add_product_post_class($classes) { | |
| 26 | + $classes[] = 'product'; | |
| 27 | + | |
| 28 | + return $classes; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public function add_products_post_class_filter() { | |
| 32 | + add_filter('post_class', [$this, 'add_product_post_class']); | |
| 33 | + } | |
| 34 | + | |
| 35 | + public function remove_products_post_class_filter() { | |
| 36 | + remove_filter('post_class', [$this, 'add_product_post_class']); | |
| 37 | + } | |
| 38 | + | |
| 39 | + public function register_wc_hooks() { | |
| 40 | + wc()->frontend_includes(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + public function __construct() { | |
| 44 | + | |
| 45 | + parent::__construct(); | |
| 46 | + | |
| 47 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only check on which editor screen is loading; nothing is written. | |
| 48 | + if (!empty($_REQUEST['action']) && 'elementor' === $_REQUEST['action'] && is_admin()) { | |
| 49 | + add_action('init', [$this, 'register_wc_hooks'], 5); | |
| 50 | + } | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Modal data | |
| 54 | + */ | |
| 55 | + add_action('wp_ajax_nopriv_ultimate_store_kit_wc_product_quick_view_content', [$this, 'ultimate_store_kit_wc_product_quick_view_content']); | |
| 56 | + add_action('wp_ajax_ultimate_store_kit_wc_product_quick_view_content', [$this, 'ultimate_store_kit_wc_product_quick_view_content']); | |
| 57 | + | |
| 58 | + add_action('ultimate_store_kit_quick_view_product_title', 'woocommerce_template_single_title'); | |
| 59 | + add_action('ultimate_store_kit_quick_view_product_single_rating', 'woocommerce_template_single_rating'); | |
| 60 | + add_action('ultimate_store_kit_quick_view_product_single_price', 'woocommerce_template_single_price'); | |
| 61 | + add_action('ultimate_store_kit_quick_view_product_single_excerpt', 'woocommerce_template_single_excerpt'); | |
| 62 | + add_action('ultimate_store_kit_quick_view_product_single_add_to_cart', 'woocommerce_template_single_add_to_cart'); | |
| 63 | + add_action('ultimate_store_kit_quick_view_product_single_meta', 'woocommerce_template_single_meta'); | |
| 64 | + add_action('ultimate_store_kit_quick_view_product_sale_flash', 'woocommerce_show_product_sale_flash'); | |
| 65 | + add_action('ultimate_store_kit_quick_glossy_carousel_view_product_images', [$this, 'ultimate_store_kit_quick_view_product_images']); | |
| 66 | + } | |
| 67 | + | |
| 68 | + public function ultimate_store_kit_wc_product_quick_view_content() { | |
| 69 | + | |
| 70 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only public endpoint; ultimate_store_kit_wc_product_quick_view_content() rejects any product the visitor could not already view. | |
| 71 | + $product_id = isset($_POST['product_id']) ? absint(wp_unslash($_POST['product_id'])) : 0; | |
| 72 | + | |
| 73 | + ultimate_store_kit_wc_product_quick_view_content($product_id); | |
| 74 | + } | |
| 75 | + | |
| 76 | + public function ultimate_store_kit_quick_view_product_images() { | |
| 77 | + ultimate_store_kit_quick_view_product_images(); | |
| 78 | + } | |
| 79 | +} | |