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