PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / widgets / loop / thumbnail / config.php
shop-press / Elementor / widgets / loop / thumbnail Last commit date
image 1 year ago config.php 1 year ago
config.php
269 lines
1 <?php
2 namespace ShopPress\Elementor\Widgets\LoopBuilder;
3
4 use Elementor\Controls_Manager;
5
6 use ShopPress\Elementor\ShopPressWidgets;
7
8 defined( 'ABSPATH' ) || exit;
9
10 class Thumbnail extends ShopPressWidgets {
11
12 public function get_name() {
13 return 'sp-item-thumbnail';
14 }
15
16 public function get_title() {
17 return __( 'Product Thumbnail', 'shop-press' );
18 }
19
20 public function get_icon() {
21 return 'sp-widget sp-eicon-product-thumbnail';
22 }
23
24 public function get_style_depends() {
25 if ( is_rtl() ) {
26 return array( 'sp-loop-thumbnail', 'sp-products-loop', 'sp-products-loop-rtl' );
27 } else {
28 return array( 'sp-loop-thumbnail', 'sp-products-loop' );
29 }
30 }
31
32 public function get_categories() {
33 return array( 'sp_woo_loop' );
34 }
35
36 public function setup_styling_options() {
37
38 $this->register_group_styler(
39 'wrapper',
40 __( 'Wrapper', 'shop-press' ),
41 array(
42 'wrapper' => array(
43 'label' => esc_html__( 'Wrapper', 'shop-press' ),
44 'type' => 'styler',
45 'selector' => '.sp-product-thumbnail',
46 'wrapper' => '{{WRAPPER}}',
47 ),
48 )
49 );
50
51 $this->register_group_styler(
52 'image',
53 __( 'Image', 'shop-press' ),
54 array(
55 'Wrapper' => array(
56 'label' => esc_html__( 'Wrapper', 'shop-press' ),
57 'type' => 'styler',
58 'selector' => '.sp-product-thumbnail a',
59 'wrapper' => '{{WRAPPER}}',
60 ),
61 'item' => array(
62 'label' => esc_html__( 'Image', 'shop-press' ),
63 'type' => 'styler',
64 'selector' => '.sp-product-thumbnail a img',
65 'wrapper' => '{{WRAPPER}}',
66 ),
67 )
68 );
69 }
70
71 protected function register_controls() {
72 $this->start_controls_section(
73 'section_content',
74 array(
75 'label' => __( 'General', 'shop-press' ),
76 )
77 );
78
79 $_image_sizes = self::get_all_image_sizes();
80 $image_sizes = array();
81 foreach ( $_image_sizes as $key => $image_size ) {
82
83 $image_sizes[ $key ] = $image_size['title'] ?? '';
84 }
85 $image_sizes['full'] = __( 'Full', 'shop-press' );
86 $this->add_control(
87 'thumb_size',
88 array(
89 'label' => esc_html__( 'Thumbnail Size', 'shop-press' ),
90 'type' => Controls_Manager::SELECT,
91 'options' => $image_sizes,
92 'default' => 'woocommerce_thumbnail',
93 )
94 );
95 $this->add_control(
96 'thumbnail_type',
97 array(
98 'label' => esc_html__( 'Thumbnail Type', 'shop-press' ),
99 'type' => Controls_Manager::CHOOSE,
100 'options' => array(
101 'single' => array(
102 'title' => esc_html__( 'Single', 'shop-press' ),
103 'icon' => 'eicon-image',
104 ),
105 'change_image_on_hover' => array(
106 'title' => esc_html__( 'Change image on hover', 'shop-press' ),
107 'icon' => 'eicon-image-rollover',
108 ),
109 'slider' => array(
110 'title' => esc_html__( 'Slider', 'shop-press' ),
111 'icon' => 'eicon-photo-library',
112 ),
113 ),
114 'default' => 'single',
115 'toggle' => true,
116 )
117 );
118
119 $this->add_control(
120 'show_arrows',
121 array(
122 'label' => esc_html__( 'Arrows', 'shop-press' ),
123 'type' => Controls_Manager::SWITCHER,
124 'label_on' => esc_html__( 'Show', 'shop-press' ),
125 'label_off' => esc_html__( 'Hide', 'shop-press' ),
126 'return_value' => 'true',
127 'default' => 'true',
128 'condition' => array(
129 'thumbnail_type' => 'slider',
130 ),
131 )
132 );
133
134 $this->add_control(
135 'show_nav',
136 array(
137 'label' => esc_html__( 'Navigation', 'shop-press' ),
138 'type' => Controls_Manager::SWITCHER,
139 'label_on' => esc_html__( 'Show', 'shop-press' ),
140 'label_off' => esc_html__( 'Hide', 'shop-press' ),
141 'return_value' => 'true',
142 'default' => 'false',
143 'condition' => array(
144 'thumbnail_type' => 'slider',
145 ),
146 )
147 );
148
149 $this->add_control(
150 'nav_type',
151 array(
152 'label' => esc_html__( 'Navigation Type', 'shop-press' ),
153 'type' => Controls_Manager::CHOOSE,
154 'options' => array(
155 'bullets_nav' => array(
156 'title' => esc_html__( 'Bullets', 'shop-press' ),
157 'icon' => 'eicon-navigation-horizontal',
158 ),
159 'images_nav' => array(
160 'title' => esc_html__( 'Images', 'shop-press' ),
161 'icon' => 'eicon-photo-library',
162 ),
163 ),
164 'default' => 'bullets_nav',
165 'toggle' => true,
166 'condition' => array(
167 'thumbnail_type' => 'slider',
168 'show_nav' => 'true',
169 ),
170 )
171 );
172
173 $this->end_controls_section();
174 $this->setup_styling_options();
175
176 do_action( 'shoppress/elementor/widget/register_controls_init', $this );
177 }
178
179 protected function render() {
180 $settings = $this->get_settings_for_display();
181
182 do_action( 'shoppress/widget/before_render', $settings );
183
184 $args = array(
185 'thumb_size' => $settings['thumb_size'],
186 // 'change_image' => $settings['change_image'],
187 'thumbnail_type' => $settings['thumbnail_type'],
188 'show_arrows' => $settings['show_arrows'],
189 'show_nav' => $settings['show_nav'],
190 'nav_type' => $settings['nav_type'],
191 );
192
193 if ( $this->editor_preview() ) {
194 sp_load_builder_template( 'loop/loop-thumbnail', $args );
195 }
196 }
197
198 protected function content_template() {
199 ?>
200 <#
201 var classes = '';
202 if ( 'change_image_on_hover' === settings.thumbnail_type ) {
203 classes += ' has-gallery';
204 } else {
205 classes += ' sp-slider-style';
206 }
207 #>
208
209 <div class="sp-product-thumbnail {{ classes }}">
210 <a href="#">
211 <# if ( 'slider' === settings.thumbnail_type ) { #>
212 <# if ( 'true' === settings.show_arrows ) { #>
213 <button class="slick-prev slick-arrow" aria-label="Previous" type="button" style="">Previous</button>
214 <button class="slick-next slick-arrow" aria-label="Next" type="button" style="">Next</button>
215 <# } #>
216 <div>
217 <img src="<?php echo esc_url( SHOPPRESS_URL . '/Elementor/widgets/loop/thumbnail/image/' ); ?>t-shirt-with-logo.jpg" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail tns-item" aria-hidden="true" tabindex="-1">
218 </div>
219 <# if ( 'true' === settings.show_nav && 'bullets_nav' === settings.nav_type ) { #>
220 <ul class="slick-dots" style="" role="tablist">
221 <li class="slick-active" role="presentation">
222 <button type="button" role="tab" id="slick-slide-control20" aria-controls="slick-slide20" aria-label="1 of 4" tabindex="0" aria-selected="true">1</button>
223 </li>
224 <li role="presentation">
225 <button type="button" role="tab" id="slick-slide-control21" aria-controls="slick-slide21" aria-label="2 of 4" tabindex="-1">2</button>
226 </li>
227 </ul>
228 <# } #>
229 <# } else { #>
230 <img src="<?php echo esc_url( SHOPPRESS_URL . '/Elementor/widgets/loop/thumbnail/image/' ); ?>t-shirt-with-logo.jpg" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail">
231 <# if ( 'change_image_on_hover' === settings.thumbnail_type ) { #>
232 <div class="sp-product-th-gallery">
233 <img src="<?php echo esc_url( SHOPPRESS_URL . '/Elementor/widgets/loop/thumbnail/image/' ); ?>t-shirt-with-logo.jpg" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail">
234 </div>
235 <# } #>
236 <# } #>
237 </a>
238 <# if ('true' === settings.show_nav && 'images_nav' === settings.nav_type ) { #>
239 <div
240 class="sp-nav-slider sp-slider-style"
241 >
242 <div class="slick-list">
243 <div
244 class="slick-track"
245 >
246 <div
247 class="sp-thumb-nav slick-current"
248 >
249 <img src="<?php echo esc_url( SHOPPRESS_URL . '/Elementor/widgets/loop/thumbnail/image/' ); ?>t-shirt-with-logo-1-100x100.jpg" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail">
250 </div>
251 <div
252 class="sp-thumb-nav"
253 >
254 <img src="<?php echo esc_url( SHOPPRESS_URL . '/Elementor/widgets/loop/thumbnail/image/' ); ?>hoodie-with-zipper-2-100x100.jpg" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail">
255 </div>
256 <div
257 class="sp-thumb-nav"
258 >
259 <img src="<?php echo esc_url( SHOPPRESS_URL . '/Elementor/widgets/loop/thumbnail/image/' ); ?>hoodie-with-pocket-2-100x100.jpg" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail">
260 </div>
261 </div>
262 </div>
263 </div>
264 <# } #>
265 </div>
266 <?php
267 }
268 }
269