PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / widgets / single-product / image / config.php
shop-press / Elementor / widgets / single-product / image Last commit date
images 3 years ago config.php 3 weeks ago
config.php
314 lines
1 <?php
2 namespace ShopPress\Elementor\Widgets;
3
4 use ShopPress\Elementor\ShopPressWidgets;
5 use Elementor\Controls_Manager;
6
7 defined( 'ABSPATH' ) || exit;
8
9 class Image extends ShopPressWidgets {
10
11 public function get_name() {
12 return 'sp-image';
13 }
14
15 public function get_title() {
16 return __( 'Product Images', 'shop-press' );
17 }
18
19 public function get_icon() {
20 return 'sp-widget sp-eicon-product-thumbnail';
21 }
22
23 public function get_categories() {
24 return array( 'sp_woo_single' );
25 }
26
27 public function get_style_depends() {
28 return array( 'sp-image' );
29 }
30
31 public function get_script_depends() {
32 return array( 'sp-image' );
33 }
34
35 public function setup_styling_options() {
36
37 $this->register_group_styler(
38 'wrapper',
39 __( 'Wrapper', 'shop-press' ),
40 array(
41 'wrapper' => array(
42 'label' => esc_html__( 'Wrapper', 'shop-press' ),
43 'type' => 'styler',
44 'selector' => '.sp-images',
45 'wrapper' => '{{WRAPPER}}',
46 ),
47 )
48 );
49
50 $product_gallery_status = sp_is_module_active( 'product_gallery' );
51
52 if ( ! $product_gallery_status ) {
53 $this->register_group_styler(
54 'image',
55 __( 'Image', 'shop-press' ),
56 array(
57 'container' => array(
58 'label' => esc_html__( 'Container', 'shop-press' ),
59 'type' => 'styler',
60 'selector' => '.woocommerce-product-gallery.woocommerce-product-gallery.images',
61 'wrapper' => '{{WRAPPER}} .sp-images',
62 ),
63 'image' => array(
64 'label' => esc_html__( 'Featured Image', 'shop-press' ),
65 'type' => 'styler',
66 'selector' => '.woocommerce-product-gallery__wrapper img, {{WRAPPER}} .sp-images .sp-product-gallery images img',
67 'wrapper' => '{{WRAPPER}} .sp-images',
68 ),
69 'zoom_container' => array(
70 'label' => esc_html__( 'Zoom Icon Container', 'shop-press' ),
71 'type' => 'styler',
72 'selector' => '.woocommerce-product-gallery__trigger, {{WRAPPER}} .sp-images .sp-product-gallery .sp-product-gallery-__trigger',
73 'wrapper' => '{{WRAPPER}} .sp-images .woocommerce-product-gallery',
74 ),
75 )
76 );
77
78 $this->register_group_styler(
79 'gallery_images',
80 __( 'Gallery Images', 'shop-press' ),
81 array(
82 'gallery_nav_wrap' => array(
83 'label' => esc_html__( 'Nav Wrapper', 'shop-press' ),
84 'type' => 'styler',
85 'selector' => '.flex-control-nav.flex-control-thumbs',
86 'wrapper' => '{{WRAPPER}} .sp-images .woocommerce-product-gallery.images',
87 ),
88 'gallery_images_wrap' => array(
89 'label' => esc_html__( 'Images Wrapper', 'shop-press' ),
90 'type' => 'styler',
91 'selector' => 'li',
92 'wrapper' => '{{WRAPPER}} .sp-images .woocommerce-product-gallery.images .flex-control-nav.flex-control-thumbs',
93 ),
94 'gallery_images' => array(
95 'label' => esc_html__( 'Images', 'shop-press' ),
96 'type' => 'styler',
97 'selector' => 'img',
98 'wrapper' => '{{WRAPPER}} .sp-images .woocommerce-product-gallery.images .flex-control-nav.flex-control-thumbs li',
99 ),
100 'gallery_images_active' => array(
101 'label' => esc_html__( 'Active Image', 'shop-press' ),
102 'type' => 'styler',
103 'selector' => 'img.flex-active',
104 'wrapper' => '{{WRAPPER}} .sp-images .woocommerce-product-gallery.images .flex-control-nav.flex-control-thumbs li',
105 ),
106 )
107 );
108 }
109
110 $slider_option = sp_get_module_settings( 'product_gallery', 'gallery_type' );
111
112 if ( $slider_option === 'slider' ) {
113 $this->register_group_styler(
114 'featured_image_slider',
115 __( 'Featured Image Slider', 'shop-press' ),
116 array(
117 'slider_wrapper' => array(
118 'label' => esc_html__( 'Wrapper', 'shop-press' ),
119 'type' => 'styler',
120 'selector' => '.sp-product-gallery-slider.sp-slider-style',
121 'wrapper' => '{{WRAPPER}} .sp-images',
122 ),
123 'slider_featured_image_wrapper' => array(
124 'label' => esc_html__( 'Featured Image Wrapper', 'shop-press' ),
125 'type' => 'styler',
126 'selector' => '.sp-product-gallery-image',
127 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery-slider.sp-slider-style',
128 ),
129 'slider_featured_image' => array(
130 'label' => esc_html__( 'Featured Image', 'shop-press' ),
131 'type' => 'styler',
132 'selector' => 'img',
133 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery-slider.sp-slider-style .sp-product-gallery-image',
134 ),
135 'slider_zoom_container' => array(
136 'label' => esc_html__( 'Zoom Icon Container', 'shop-press' ),
137 'type' => 'styler',
138 'selector' => '.sp-product-gallery__trigger',
139 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery-slider.sp-slider-style .sp-product-gallery-image',
140 ),
141 'slider_featured_image_prev' => array(
142 'label' => esc_html__( 'Prev Arrow', 'shop-press' ),
143 'type' => 'styler',
144 'selector' => '.slick-arrow.slick-prev',
145 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery-slider.sp-slider-style',
146 ),
147 'slider_featured_image_next' => array(
148 'label' => esc_html__( 'Next Arrow', 'shop-press' ),
149 'type' => 'styler',
150 'selector' => '.slick-arrow.slick-next',
151 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery-slider.sp-slider-style',
152 ),
153 'slider_featured_image_bullets_wrapper' => array(
154 'label' => esc_html__( 'Bullets Wrapper', 'shop-press' ),
155 'type' => 'styler',
156 'selector' => '.slick-dots',
157 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery-slider.sp-slider-style',
158 ),
159 'slider_featured_image_bullets' => array(
160 'label' => esc_html__( 'Bullets', 'shop-press' ),
161 'type' => 'styler',
162 'selector' => 'button',
163 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery-slider.sp-slider-style .slick-dots li',
164 ),
165 'slider_featured_image_bullets_active' => array(
166 'label' => esc_html__( 'Active Bullet', 'shop-press' ),
167 'type' => 'styler',
168 'selector' => 'button',
169 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery-slider.sp-slider-style .slick-dots li.slick-active',
170 ),
171 )
172 );
173
174 $this->register_group_styler(
175 'slider_gallery_nav',
176 __( 'Gallery Nav', 'shop-press' ),
177 array(
178 'slider_gallery_nav_wrapper' => array(
179 'label' => esc_html__( 'Gallery Nav Wrapper', 'shop-press' ),
180 'type' => 'styler',
181 'selector' => '.sp-product-gallery-nav-items',
182 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery',
183 ),
184 'slider_gallery_nav_items' => array(
185 'label' => esc_html__( 'Gallery Nav Items', 'shop-press' ),
186 'type' => 'styler',
187 'selector' => '.slick-slide',
188 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery .sp-product-gallery-nav-items .sp-product-gallery-nav-items-images',
189 ),
190 'slider_gallery_nav_current_item' => array(
191 'label' => esc_html__( 'Gallery Nav Current Item', 'shop-press' ),
192 'type' => 'styler',
193 'selector' => '.slick-slide.slick-current',
194 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery .sp-product-gallery-nav-items .sp-product-gallery-nav-items-images',
195 ),
196 'slider_gallery_nav_items_img' => array(
197 'label' => esc_html__( 'Gallery Nav Items Images', 'shop-press' ),
198 'type' => 'styler',
199 'selector' => 'img',
200 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery .sp-product-gallery-nav-items .sp-product-gallery-nav-items-images .slick-slide .sp-product-gallery-nav-item',
201 ),
202 'slider_gallery_nav_prev' => array(
203 'label' => esc_html__( 'Prev Arrow', 'shop-press' ),
204 'type' => 'styler',
205 'selector' => '.slick-arrow.slick-prev',
206 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery .sp-product-gallery-nav-items .sp-product-gallery-nav-items-images',
207 ),
208 'slider_gallery_nav_next' => array(
209 'label' => esc_html__( 'Next Arrow', 'shop-press' ),
210 'type' => 'styler',
211 'selector' => '.slick-arrow.slick-next',
212 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery .sp-product-gallery-nav-items .sp-product-gallery-nav-items-images',
213 ),
214 )
215 );
216 }
217
218 if ( $slider_option !== 'slider' ) {
219 $this->register_group_styler(
220 'column_gallery',
221 __( 'Product Gallery', 'shop-press' ),
222 array(
223 'columns_gallery_items' => array(
224 'label' => esc_html__( 'Gallery Items Wrapper', 'shop-press' ),
225 'type' => 'styler',
226 'selector' => '.sp-product-gallery-image',
227 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery .sp-product-gallery-images',
228 ),
229 'columns_gallery_items_image' => array(
230 'label' => esc_html__( 'Gallery Items Image', 'shop-press' ),
231 'type' => 'styler',
232 'selector' => 'img',
233 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery .sp-product-gallery-images .sp-product-gallery-image',
234 ),
235 'columns_gallery_zoom_container' => array(
236 'label' => esc_html__( 'Zoom Icon Container', 'shop-press' ),
237 'type' => 'styler',
238 'selector' => '.sp-product-gallery__trigger',
239 'wrapper' => '{{WRAPPER}} .sp-images .sp-product-gallery .sp-product-gallery-images .sp-product-gallery-image',
240 ),
241 )
242 );
243 }
244 }
245
246 protected function register_controls() {
247 $this->setup_styling_options();
248
249 do_action( 'shoppress/elementor/widget/register_controls_init', $this );
250 }
251
252 protected function render() {
253 do_action( 'shoppress/widget/before_render', $this->get_settings_for_display() );
254
255 if ( $this->editor_preview() ) {
256 sp_load_builder_template( 'single-product/product-image' );
257 }
258 }
259
260 protected function content_template() {
261
262 $image_url = SHOPPRESS_URL . '/Elementor/widgets/single-product/image/images/t-shirt-with-logo-1-600x600.jpg';
263
264 if ( has_action( 'shoppress_product_image_widget_dummy' ) ) {
265
266 do_action( 'shoppress_product_image_widget_dummy' );
267 return;
268 }
269 ?>
270 <style>
271 ol.flex-control-nav.flex-control-thumbs li {
272 display: inline-block;
273 }
274
275 ol.flex-control-nav.flex-control-thumbs {
276 padding: 0;
277 margin-top: 5px;
278 }
279
280 .woocommerce div.product .woocommerce-product-gallery.images {
281 float: none !important;
282 }
283 </style>
284
285 <div class="sp-images">
286 <div class="sp-product-gallery woocommerce-product-gallery woocommerce-product-gallery--with-images woocommerce-product-gallery--columns-4 images" data-columns="4" style="opacity: 1;">
287 <a href="#" class="woocommerce-product-gallery__trigger sp-product-gallery__trigger">
288 <?php // phpcs:ignore PluginCheck.CodeAnalysis.Offloading.OffloadedContent -- WordPress.org emoji for Elementor preview template. ?>
289 <img draggable="false" role="img" class="emoji" alt="🔍" src="https://s.w.org/images/core/emoji/14.0.0/svg/1f50d.svg">
290 </a>
291 <div class="flex-viewport" style="overflow: hidden; position: relative; height: 550px;">
292 <figure class="woocommerce-product-gallery__wrapper sp-product-gallery__wrapper" style="width: 1000%; transition-duration: 0s; transform: translate3d(0px, 0px, 0px);">
293 <div class="sp-product-gallery-image woocommerce-product-gallery__image flex-active-slide" style="position: relative; overflow: hidden; width: 550px; margin-right: 0px; float: left; display: block;">
294 <a href="<?php echo esc_url( $image_url ); ?>"><img width="600" height="600" src="<?php echo esc_url( $image_url ); ?>" class="wp-post-image">
295 </div>
296 <div data-thumb="<?php echo esc_url( $image_url ); ?>" class="sp-product-gallery-image woocommerce-product-gallery__image" style="width: 550px; margin-right: 0px; float: left; display: block;">
297 <a href="<?php echo esc_url( $image_url ); ?>"><img width="600" height="600" src="<?php echo esc_url( $image_url ); ?>"></a>
298 </div>
299 <div class="sp-product-gallery-image woocommerce-product-gallery__image" style="width: 550px; margin-right: 0px; float: left; display: block;">
300 <a href="<?php echo esc_url( $image_url ); ?>"><img width="600" height="600" src="<?php echo esc_url( $image_url ); ?>"></a>
301 </div>
302 </figure>
303 </div>
304 <ol class="flex-control-nav flex-control-thumbs">
305 <li><img onload="this.width = this.naturalWidth; this.height = this.naturalHeight" src="<?php echo esc_url( SHOPPRESS_URL . '/Elementor/widgets/single-product/image/images/' ); ?>t-shirt-with-logo-1-100x100.jpg" class="flex-active" draggable="false" width="100" height="100"></li>
306 <li><img onload="this.width = this.naturalWidth; this.height = this.naturalHeight" src="<?php echo esc_url( SHOPPRESS_URL . '/Elementor/widgets/single-product/image/images/' ); ?>hoodie-with-pocket-2-100x100.jpg" draggable="false" width="100" height="100"></li>
307 <li><img onload="this.width = this.naturalWidth; this.height = this.naturalHeight" src="<?php echo esc_url( SHOPPRESS_URL . '/Elementor/widgets/single-product/image/images/' ); ?>hoodie-with-zipper-2-100x100.jpg" draggable="false" width="100" height="100"></li>
308 </ol>
309 </div>
310 </div>
311 <?php
312 }
313 }
314