PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.0
ShopBuilder – WooCommerce Builder For Elementor v2.0.0
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Modules/QuickView/QuickViewFrontEnd.php +34 -57 2.1.52.0.0 View file →
@@ -16,17 +16,14 @@
16 16
17 17 public function __construct() {
18 18 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue' ] );
19 19
20 - // Gallery Plugin Support rtwpvg_disable_enqueue_scripts
21 - add_filter( 'rtwpvg_disable_enqueue_scripts', '__return_false', 11 );
22 -
23 20 // Template.
24 21
25 - add_action( 'rtsb/modules/quick_view/frontend/display', [ $this, 'button_hook' ] );
26 - // Add do_action( 'rtsb/modules/quick_view/frontend/display' ); for display anywhere.
22 + add_action( 'rtsb/modules/quick_view/frontend/display', [ $this, 'button_hook' ] );
23 + // Add do_action( 'rtsb/modules/quick_view/frontend/display' ); for display anywhere.
27 24
28 - add_action( 'rtsb/modules/quick_view/print_button', [ $this, 'print_button' ] );
25 + add_action( 'rtsb/modules/quick_view/print_button', [ $this, 'print_button' ] );
29 26
30 27 // Load action for product template.
31 28 $this->quick_view_action_template();
32 29
@@ -38,8 +35,9 @@
38 35
39 36 add_action( 'wp_ajax_nopriv_rtsb_load_product_quick_view', [ $this, 'product_quick_view_ajax' ] );
40 37
41 38 $this->attach_button();
39 +
42 40 }
43 41
44 42
45 43 /**
@@ -61,12 +59,13 @@
61 59 add_action( 'rtsb/wcqv/product/summary', 'woocommerce_template_single_price', 15 );
62 60 add_action( 'rtsb/wcqv/product/summary', 'woocommerce_template_single_excerpt', 20 );
63 61 add_action( 'rtsb/wcqv/product/summary', 'woocommerce_template_single_add_to_cart', 25 );
64 62 add_action( 'rtsb/wcqv/product/summary', 'woocommerce_template_single_meta', 30 );
63 +
65 64 }
66 65
67 66 public function product_quick_view_ajax() {
68 - $product_id = isset( $_REQUEST['product_id'] ) ? absint( $_REQUEST['product_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
67 + $product_id = absint( $_REQUEST['product_id'] );
69 68
70 69 if ( empty( $product_id ) ) {
71 70 wp_send_json_error( esc_html__( 'Product Id not found', 'shopbuilder' ) );
72 71 }
@@ -72,9 +71,9 @@
72 71 }
73 72
74 73 global $sitepress;
75 74
76 - $lang = isset( $_REQUEST['lang'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['lang'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
75 + $lang = isset( $_REQUEST['lang'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['lang'] ) ) : '';
77 76 if ( defined( 'ICL_LANGUAGE_CODE' ) && $lang && isset( $sitepress ) ) {
78 77 $sitepress->switch_lang( $lang, true );
79 78 }
80 79
@@ -81,16 +80,16 @@
81 80 // Set the main wp query for the product.
82 81 wp( 'p=' . $product_id . '&post_type=product' );
83 82
84 83 // Remove product thumbnails gallery.
85 - if ( defined( 'RTWPVG_VERSION' ) ) {
86 - remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
87 - }
88 - if ( ! defined( 'RTWPVG_VERSION' ) ) {
89 - add_action( 'woocommerce_product_thumbnails', [ $this, 'woocommerce_product_thumbnails_before' ], 1 );
90 - add_action( 'woocommerce_product_thumbnails', [ $this, 'woocommerce_product_thumbnails_after' ], 25 );
91 - }
92 -
84 + remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
85 + // Change template for variable products.
86 + // if ( isset( $GLOBALS['yith_wccl'] ) ) {
87 + // $GLOBALS['yith_wccl']->obj = new YITH_WCCL_Frontend();
88 + // $GLOBALS['yith_wccl']->obj->override();
89 + // } elseif ( defined( 'YITH_WCCL_PREMIUM' ) && YITH_WCCL_PREMIUM && class_exists( 'YITH_WCCL_Frontend' ) ) {
90 + // $attributes = YITH_WCCL_Frontend()->create_attributes_json( $product_id, true );
91 + // }
93 92 ob_start();
94 93 Fns::load_template( 'quick-view/content' );
95 94 $html = ob_get_contents(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
96 95 ob_end_clean();
@@ -118,9 +117,9 @@
118 117 'hook' => 'woocommerce_after_shop_loop_item',
119 118 'priority' => 15,
120 119 ],
121 120 'custom' => [
122 - 'hook' => Fns::get_option( 'modules', 'quick_view', 'loop_custom_hook_name', '' ),
121 + 'hook' => Fns::get_option( 'modules', 'quick_view', 'loop_custom_hook_name', '' ),
123 122 'priority' => Fns::get_option( 'modules', 'quick_view', 'loop_custom_hook_priority', '' ),
124 123 ],
125 124 ]
126 125 );
@@ -148,38 +147,16 @@
148 147 * Print "Add to compare" button
149 148 *
150 149 * @return void
151 150 */
152 - public function woocommerce_product_thumbnails_before() {
153 - ?>
154 - <div class="rtsb-gallery-images-wrapper">
155 - <?php
156 - }
157 - /**
158 - * Print "Add to compare" button
159 - *
160 - * @return void
161 - */
162 - public function woocommerce_product_thumbnails_after() {
163 -
164 - ?>
165 - </div>
166 - <?php
167 - }
168 -
169 - /**
170 - * Print "Add to compare" button
171 - *
172 - * @return void
173 - */
174 151 public function button_hook() {
175 152 if ( ! apply_filters( 'rtsb/module/quick_view/show_button', true ) ) {
176 153 return;
177 154 }
178 - global $product;
179 - if ( $product instanceof WC_Product ) {
180 - do_action( 'rtsb/modules/quick_view/print_button', $product->get_id() );
181 - }
155 + global $product;
156 + if( $product instanceof WC_Product ) {
157 + do_action('rtsb/modules/quick_view/print_button', $product->get_id());
158 + }
182 159 }
183 160
184 161
185 162 /**
@@ -187,25 +164,25 @@
187 164 */
188 165 public function print_button( $product_id = 0 ) {
189 166 global $product;
190 167
191 - if ( ! $product instanceof WC_Product && $product_id ) {
192 - $product = wc_get_product( $product_id );
168 + // product object.
169 + $current_product = $product_id ? wc_get_product( $product_id ) : false;
170 + $current_product = $current_product ?: $product;
171 +
172 + if ( ! $current_product instanceof WC_Product ) {
173 + return '';
193 174 }
194 175
195 - // if ( ! $current_product instanceof WC_Product ) {
196 - // return '';
197 - // }
198 -
199 176 $classes = []; // button class.
200 - $button_text = Fns::get_option( 'modules', 'quick_view', 'button_text', esc_html__( 'Quick View', 'shopbuilder' ) );
177 + $button_text = Fns::get_option( 'modules', 'quick_view', 'button_text', esc_html__( 'Quick View', 'shopbuilder' ) );
201 178
202 - $icon_html = '<i class="rtsb-icon rtsb-icon-eye"></i>';
179 + $icon_html = '<i class="rtsb-icon rtsb-icon-eye"></i>';
203 180 // get product type.
204 - $product_type = $product->get_type();
181 + $product_type = $current_product->get_type();
205 182 $params = [
206 183 'classes' => $classes,
207 - 'product_id' => $product->get_id(),
184 + 'product_id' => $current_product->get_id(),
208 185 'product_type' => $product_type,
209 186 'button_text' => $button_text,
210 187 'left_text' => apply_filters( 'rtsb/module/quick_view/button_left_text', '' ),
211 188 'right_text' => apply_filters( 'rtsb/module/quick_view/button_right_text', '' ),
@@ -228,17 +205,17 @@
228 205 * @return string [HTML]
229 206 */
230 207 public function button_shortcode( $atts, $content = '' ) {
231 208 $this->enqueue();
232 - global $product;
209 + global $product;
233 210 if ( ! $product instanceof WC_Product ) {
234 211 return '';
235 212 }
236 213 ob_start();
237 214
238 - do_action( 'rtsb/modules/quick_view/print_button', $product->get_id() );
215 + do_action( 'rtsb/modules/quick_view/print_button', $product->get_id() );
239 216
240 - return ob_get_clean();
217 + return ob_get_clean();
241 218 }
242 219
243 220 public function enqueue() {
244 221 wp_enqueue_script( 'wc-add-to-cart-variation' );
@@ -296,9 +273,9 @@
296 273 * @return string Filtered HTML.
297 274 */
298 275 public function add_button_for_block( $item_html, $data, $product ) {
299 276 // Add the link "Add to wishlist" in the loop.
300 - $shop_btn_position = Fns::get_option( 'modules', 'quick_view', 'loop_btn_position', 'after_add_to_cart' );
277 + $shop_btn_position = Fns::get_option( 'modules', 'quick_view', 'loop_btn_position', 'after_add_to_cart' );
301 278 ob_start();
302 279 $this->print_button( $product->get_id() );
303 280 $button = ob_get_clean();
304 281 $parts = [];