PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 1.1.4
ShopBuilder – WooCommerce Builder For Elementor v1.1.4
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
shopbuilder / app / Elementor / Widgets / Single / ProductImages.php

ProductImages.php in ShopBuilder – WooCommerce Builder For Elementor 1.1.4, at app/Elementor/Widgets/Single/ProductImages.php

145 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main ProductImages class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Elementor\Widgets\Single;
9
10 use RadiusTheme\SB\Helpers\Fns;
11 use RadiusTheme\SB\Abstracts\ElementorWidgetBase;
12 use RadiusTheme\SB\Elementor\Widgets\Controls\ProductImagesSettings;
13
14 // Do not allow directly accessing this file.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit( 'This script cannot be accessed directly.' );
17 }
18
19 /**
20 * Product Images class
21 */
22 class ProductImages extends ElementorWidgetBase {
23 /**
24 * Construct function
25 *
26 * @param array $data default array.
27 * @param mixed $args default arg.
28 */
29 public function __construct( $data = [], $args = null ) {
30 $this->rtsb_name = esc_html__( 'Product Images', 'shopbuilder' );
31 $this->rtsb_base = 'rtsb-product-image';
32 parent::__construct( $data, $args );
33 add_action( 'wp_footer', 'woocommerce_photoswipe' );
34 $this->the_hooks();
35 }
36
37 /**
38 * Widget Field
39 *
40 * @return array
41 */
42 public function widget_fields() {
43 $fields = ProductImagesSettings::widget_fields( $this );
44 return apply_filters( 'rtsb/elements/elementor/single/' . $this->rtsb_base, $fields, $this );
45 }
46 /**
47 * Widget Field.
48 *
49 * @return void
50 */
51 public function editor_scripts() {
52 ?>
53 <script>
54 /*
55 * Initialize all galleries on page.
56 */
57 jQuery( '.woocommerce-product-gallery' ).each( function() {
58 const that = this;
59 jQuery( this ).trigger( 'wc-product-gallery-before-init', [ this, wc_single_product_params ] );
60 setTimeout( function(){
61 jQuery(that).wc_product_gallery(wc_single_product_params);
62 }, 1000 );
63
64 jQuery( this ).trigger( 'wc-product-gallery-after-init', [ this, wc_single_product_params ] );
65 } );
66 <?php if ( function_exists( 'rtwpvg' ) ) { ?>
67 setTimeout( function(){
68 jQuery('.rtsb-product-images .rtwpvg-wrapper').rtWpVGallery();
69 }, 1000 );
70 <?php } ?>
71
72 jQuery(document).ready(function ($) {
73 setTimeout(function () {
74 const zoomIcon = $('.rtsb-product-images').attr('data-zoom-icon');
75 if (!zoomIcon) {
76 $('.rtsb-product-images')
77 .find('.woocommerce-product-gallery__trigger,.rtwpvg-trigger')
78 .remove();
79 }
80 $('.rtsb-product-images')
81 .find('.woocommerce-product-gallery__trigger,.rtwpvg-trigger')
82 .html(zoomIcon);
83 }, 50);
84 });
85 </script>
86 <?php
87 }
88
89 /**
90 * Widget Field.
91 *
92 * @param array $control Control.
93 *
94 * @return void
95 */
96 public function the_hooks( $control = null ) {
97 if ( ! $control ) {
98 return;
99 }
100 add_filter(
101 'woocommerce_product_thumbnails_columns',
102 function( $col ) {
103 $col = 0;
104 return $col;
105 }
106 );
107 if ( empty( $control['show_zoom'] ) ) {
108 add_filter( 'rtwpvg_trigger_icon', '__return_false' );
109 }
110 if ( empty( $control['show_thumbnails'] ) ) {
111 add_filter( 'rtwpvg_show_product_thumbnail_slider', '__return_false' );
112 remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
113 }
114 }
115 /**
116 * Render Function
117 *
118 * @return void
119 */
120 protected function render() {
121 global $product, $post;
122 $_product = $product;
123 $product = Fns::get_product();
124 $controllers = $this->get_settings_for_display();
125
126 $this->theme_support();
127
128 $controllers['lightbox_icon'] = Fns::icons_manager( $controllers['lightbox_icon'] );
129 $data = [
130 'template' => 'elementor/single-product/product-images',
131 'controllers' => $controllers,
132 ];
133 $this->the_hooks( $controllers );
134
135 Fns::load_template( $data['template'], $data );
136
137 if ( $this->is_edit_mode() ) {
138 $this->editor_scripts();
139 }
140 $this->theme_support( 'render_reset' );
141 $product = $_product; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
142 }
143
144 }
145