PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
← All changes | includes/utils/post-component.php +865 -716 1.2.41.3.17 View file →
@@ -1,6 +1,8 @@
1 1 <?php
2 +
2 3 namespace UiCoreElements\Utils;
4 +
3 5 use Elementor\Controls_Manager;
4 6 use Elementor\Icons_Manager;
5 7 use Elementor\Plugin;
6 8
@@ -22,9 +24,10 @@
22 24 *
23 25 * @since 1.0.4
24 26 */
25 27
26 -trait Post_Trait {
28 +trait Post_Trait
29 +{
27 30
28 31 use Button_Trait,
29 32 Meta_Trait;
30 33
@@ -30,9 +33,9 @@
30 33
31 34 // Control Register Content functions
32 35 function TRAIT_register_post_item_controls($section = true)
33 36 {
34 - if($section) {
37 + if ($section) {
35 38 $this->start_controls_section(
36 39 'section_item_content',
37 40 [
38 41 'label' => esc_html__('Item', 'uicore-elements'),
@@ -38,92 +41,129 @@
38 41 'label' => esc_html__('Item', 'uicore-elements'),
39 42 ]
40 43 );
41 44 }
42 - $this->add_control(
43 - 'box_style',
44 - [
45 - 'label' => __('Item Style', 'uicore-elements'),
46 - 'type' => Controls_Manager::SELECT,
47 - 'default' => 'classic',
48 - 'options' => [
49 - 'classic' => __('Classic', 'uicore-elements'),
50 - 'split' => __('Split', 'uicore-elements'),
51 - 'overlay' => __('Overlay', 'uicore-elements'),
52 - ],
53 - 'render_type' => 'template',
54 - 'prefix_class' => 'ui-e-apg-',
45 + $this->add_control(
46 + 'box_style',
47 + [
48 + 'label' => __('Item Style', 'uicore-elements'),
49 + 'type' => Controls_Manager::SELECT,
50 + 'default' => 'classic',
51 + 'options' => [
52 + 'classic' => __('Classic', 'uicore-elements'),
53 + 'split' => __('Split', 'uicore-elements'),
54 + 'overlay' => __('Overlay', 'uicore-elements'),
55 + ],
56 + 'render_type' => 'template',
57 + 'prefix_class' => 'ui-e-apg-',
58 + ]
59 + );
60 + $this->add_control(
61 + 'split_mobile',
62 + [
63 + 'label' => __('Use Classic Layout on Mobile' . UICORE_ELEMENTS_NEW_OPTION, 'uicore-elements'), // TODO: remove badge, at least 2, releases after 1.3.15
64 + 'type' => Controls_Manager::SWITCHER,
65 + 'default' => 'ui-e-apg-split-not-phone',
66 + 'return_value' => 'ui-e-apg-split-not-phone',
67 + 'prefix_class' => '',
68 + 'condition' => [
69 + 'box_style' => 'split',
70 + ],
71 + ]
72 + );
73 + $this->add_control(
74 + 'image',
75 + [
76 + 'label' => __('Image', 'uicore-elements'),
77 + 'type' => Controls_Manager::SWITCHER,
78 + 'separator' => 'before',
79 + 'default' => 'yes'
80 + ]
81 + );
82 + $this->add_control(
83 + 'image_size_select',
84 + [
85 + 'label' => __('Image Size', 'uicore-elements'),
86 + 'type' => Controls_Manager::SELECT,
87 + 'default' => 'uicore-medium',
88 + 'options' => Helper::get_images_sizes(),
89 + 'separator' => 'after',
90 + 'condition' => [
91 + 'image' => 'yes',
55 92 ]
56 - );
57 - $this->add_control(
58 - 'image',
59 - [
60 - 'label' => __('Image', 'uicore-elements'),
61 - 'type' => Controls_Manager::SWITCHER,
62 - 'separator' => 'before',
63 - 'default' => 'yes'
93 + ]
94 + );
95 + $this->add_control(
96 + 'title',
97 + [
98 + 'label' => __('Title', 'uicore-elements'),
99 + 'type' => Controls_Manager::SWITCHER,
100 + 'default' => 'yes'
101 + ]
102 + );
103 + $this->add_control(
104 + 'title_tag',
105 + [
106 + 'label' => __('HTML Tag', 'uicore-elements'),
107 + 'type' => Controls_Manager::SELECT,
108 + 'default' => 'h4',
109 + 'options' => Helper::get_title_tags(),
110 + 'separator' => 'after',
111 + 'condition' => [
112 + 'title' => 'yes',
64 113 ]
65 - );
66 - $this->add_control(
67 - 'image_size_select',
68 - [
69 - 'label' => __('Image Size', 'uicore-elements'),
70 - 'type' => Controls_Manager::SELECT,
71 - 'default' => 'uicore-medium',
72 - 'options' => Helper::get_images_sizes(),
73 - 'separator' => 'after',
74 - 'condition' => [
75 - 'image' => 'yes',
76 - ]
114 + ]
115 + );
116 + $this->add_control(
117 + 'excerpt',
118 + [
119 + 'label' => __('Excerpt', 'uicore-elements'),
120 + 'type' => Controls_Manager::SWITCHER,
121 + 'default' => 'yes'
122 + ]
123 + );
124 + $this->add_control(
125 + 'excerpt_trim',
126 + [
127 + 'label' => __('Excerpt Length (words)', 'uicore-elements'),
128 + 'type' => Controls_Manager::NUMBER,
129 + 'min' => 5,
130 + 'max' => 100,
131 + 'step' => 1,
132 + 'default' => 55,
133 + 'separator' => 'after',
134 + 'condition' => array(
135 + 'excerpt' => 'yes',
136 + ),
137 + ]
138 + );
139 + $this->add_control(
140 + 'show_button',
141 + [
142 + 'label' => __('Read More Button', 'uicore-elements'),
143 + 'type' => Controls_Manager::SWITCHER,
144 + 'default' => 'no'
145 + ]
146 + );
147 + $this->add_control(
148 + 'global_link',
149 + [
150 + 'label' => __('Global Wrapper Link', 'uicore-elements'),
151 + 'type' => Controls_Manager::SWITCHER,
152 + 'default' => 'no',
153 + 'condition' => [
154 + 'box_style' => 'overlay'
77 155 ]
78 - );
79 - $this->add_control(
80 - 'title',
81 - [
82 - 'label' => __('Title', 'uicore-elements'),
83 - 'type' => Controls_Manager::SWITCHER,
84 - 'default' => 'yes'
85 - ]
86 - );
87 - $this->add_control(
88 - 'excerpt',
89 - [
90 - 'label' => __('Excerpt', 'uicore-elements'),
91 - 'type' => Controls_Manager::SWITCHER,
92 - 'default' => 'yes'
93 - ]
94 - );
95 - $this->add_control(
96 - 'excerpt_trim',
97 - [
98 - 'label' => __('Excerpt Length (words)', 'uicore-elements'),
99 - 'type' => Controls_Manager::NUMBER,
100 - 'min' => 5,
101 - 'max' => 100,
102 - 'step' => 1,
103 - 'default' => 55,
104 - 'separator' => 'after',
105 - 'condition' => array(
106 - 'excerpt' => 'yes',
107 - ),
108 - ]
109 - );
110 - $this->add_control(
111 - 'show_button',
112 - [
113 - 'label' => __('Read More Button', 'uicore-elements'),
114 - 'type' => Controls_Manager::SWITCHER,
115 - 'default' => 'no'
116 - ]
117 - );
156 + ]
157 + );
118 158
119 - if($section) {
159 + if ($section) {
120 160 $this->end_controls_section();
121 161 }
122 162 }
123 163 function TRAIT_register_post_button_controls($section = true)
124 164 {
125 - if($section){
165 + if ($section) {
126 166 $this->start_controls_section(
127 167 'section_button_content',
128 168 [
129 169 'label' => esc_html__('Button', 'uicore-elements'),
@@ -133,23 +173,23 @@
133 173 ]
134 174 );
135 175 }
136 176
137 - $this->register_button_content_controls(
138 - [
139 - 'section_condition' => [
140 - 'show_button' => 'yes'
141 - ],
142 - 'button_default_text' => 'Read More'
143 - ]
144 - );
145 - $this->remove_control('button_type');
146 - $this->remove_control('link');
147 - $this->remove_control('button_css_id');
148 - $this->remove_control('size');
149 - $this->remove_control('align');
177 + $this->register_button_content_controls(
178 + [
179 + 'section_condition' => [
180 + 'show_button' => 'yes'
181 + ],
182 + 'button_default_text' => 'Read More'
183 + ]
184 + );
185 + $this->remove_control('button_type');
186 + $this->remove_control('link');
187 + $this->remove_control('button_css_id');
188 + $this->remove_control('size');
189 + $this->remove_control('align');
150 190
151 - if($section){
191 + if ($section) {
152 192 $this->end_controls_section();
153 193 }
154 194 }
155 195 /**
@@ -159,9 +199,9 @@
159 199 * @param bool $product_metas. If true, will only print options that relates with products.
160 200 */
161 201 function TRAIT_register_post_meta_controls($section = true, $product_metas = false)
162 202 {
163 - if($section){
203 + if ($section) {
164 204 $this->start_controls_section(
165 205 'section_extra_item_content',
166 206 [
167 207 'label' => esc_html__('Meta', 'uicore-elements'),
@@ -168,73 +208,73 @@
168 208 ]
169 209 );
170 210 }
171 211
172 - $this->add_control(
173 - 'top_meta',
174 - [
175 - 'label' => esc_html__('Top Meta', 'uicore-elements'),
176 - 'type' => \Elementor\Controls_Manager::REPEATER,
177 - 'fields' => $this->get_meta_content_controls($product_metas),
178 - 'default' => [
179 - [
180 - 'type' => $product_metas ? 'product sale' : 'category'
181 - ],
212 + $this->add_control(
213 + 'top_meta',
214 + [
215 + 'label' => esc_html__('Top Meta', 'uicore-elements'),
216 + 'type' => \Elementor\Controls_Manager::REPEATER,
217 + 'fields' => $this->get_meta_content_controls($product_metas),
218 + 'default' => [
219 + [
220 + 'type' => $product_metas ? 'product sale' : 'category'
182 221 ],
183 - 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
184 - 'prevent_empty' => false,
185 - 'separator' => 'before'
186 - ]
187 - );
188 - $this->add_control(
189 - 'before_title_meta',
190 - [
191 - 'label' => esc_html__('Before Title Meta', 'uicore-elements'),
192 - 'type' => \Elementor\Controls_Manager::REPEATER,
193 - 'fields' => $this->get_meta_content_controls($product_metas),
194 - 'default' => [
195 - [
196 - 'type' => $product_metas ? 'none' : 'author'
197 - ],
222 + ],
223 + 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
224 + 'prevent_empty' => false,
225 + 'separator' => 'before'
226 + ]
227 + );
228 + $this->add_control(
229 + 'before_title_meta',
230 + [
231 + 'label' => esc_html__('Before Title Meta', 'uicore-elements'),
232 + 'type' => \Elementor\Controls_Manager::REPEATER,
233 + 'fields' => $this->get_meta_content_controls($product_metas),
234 + 'default' => [
235 + [
236 + 'type' => $product_metas ? 'none' : 'author'
198 237 ],
199 - 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
200 - 'prevent_empty' => false,
201 - 'separator' => 'before',
202 - ]
203 - );
204 - $this->add_control(
205 - 'after_title_meta',
206 - [
207 - 'label' => esc_html__('After Title Meta', 'uicore-elements'),
208 - 'type' => \Elementor\Controls_Manager::REPEATER,
209 - 'fields' => $this->get_meta_content_controls($product_metas),
210 - 'default' => [
211 - [
212 - 'type' => $product_metas ? 'product price' : 'date'
213 - ],
238 + ],
239 + 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
240 + 'prevent_empty' => false,
241 + 'separator' => 'before',
242 + ]
243 + );
244 + $this->add_control(
245 + 'after_title_meta',
246 + [
247 + 'label' => esc_html__('After Title Meta', 'uicore-elements'),
248 + 'type' => \Elementor\Controls_Manager::REPEATER,
249 + 'fields' => $this->get_meta_content_controls($product_metas),
250 + 'default' => [
251 + [
252 + 'type' => $product_metas ? 'product price' : 'date'
214 253 ],
215 - 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
216 - 'prevent_empty' => false,
217 - 'separator' => 'before',
218 - ]
219 - );
220 - $this->add_control(
221 - 'bottom_meta',
222 - [
223 - 'label' => esc_html__('Bottom Meta', 'uicore-elements'),
224 - 'type' => \Elementor\Controls_Manager::REPEATER,
225 - 'fields' => $this->get_meta_content_controls($product_metas),
226 - 'default' => [
227 - [
228 - 'type' => $product_metas ? 'none' : 'none'
229 - ],
254 + ],
255 + 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
256 + 'prevent_empty' => false,
257 + 'separator' => 'before',
258 + ]
259 + );
260 + $this->add_control(
261 + 'bottom_meta',
262 + [
263 + 'label' => esc_html__('Bottom Meta', 'uicore-elements'),
264 + 'type' => \Elementor\Controls_Manager::REPEATER,
265 + 'fields' => $this->get_meta_content_controls($product_metas),
266 + 'default' => [
267 + [
268 + 'type' => $product_metas ? 'none' : 'none'
230 269 ],
231 - 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
232 - 'prevent_empty' => false,
233 - 'separator' => 'before',
234 - ]
235 - );
236 - if($section){
270 + ],
271 + 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
272 + 'prevent_empty' => false,
273 + 'separator' => 'before',
274 + ]
275 + );
276 + if ($section) {
237 277 $this->end_controls_section();
238 278 }
239 279 }
240 280 function TRAIT_register_post_query_controls($section = true)
@@ -240,13 +280,13 @@
240 280 function TRAIT_register_post_query_controls($section = true)
241 281 {
242 282
243 283 // In some contexts, such as theme-builder, our custom controls are not available
244 - if( ! class_exists('UiCoreElements\Controls\Post_Filter') ){
284 + if (! class_exists('UiCoreElements\Controls\Post_Filter')) {
245 285 require_once UICORE_ELEMENTS_INCLUDES . '/controls/class-post-filter-control.php';
246 286 }
247 287
248 - if($section){
288 + if ($section) {
249 289 $this->start_controls_section(
250 290 'section_post_grid_def',
251 291 [
252 292 'label' => esc_html__('Query', 'uicore-elements'),
@@ -253,87 +293,115 @@
253 293 ]
254 294 );
255 295 }
256 296
257 - $this->add_group_control(
258 - Post_Filter::get_type(),
259 - [
260 - 'name' => 'posts-filter',
261 - 'label' => esc_html__('Posts', 'uicore-elements'),
262 - 'description' => esc_html__('Current Query Settings > Reading', 'uicore-elements'),
263 - ]
264 - );
265 - $this->add_control(
266 - 'item_limit',
267 - [
268 - 'label' => esc_html__('Item Limit', 'uicore-elements'),
269 - 'type' => Controls_Manager::SLIDER,
270 - 'reder_type' => 'template',
271 - 'range' => [
272 - 'px' => [
273 - 'min' => -1,
274 - 'max' => 100,
275 - ],
297 + $this->add_group_control(
298 + Post_Filter::get_type(),
299 + [
300 + 'name' => 'posts-filter',
301 + 'label' => esc_html__('Posts', 'uicore-elements'),
302 + 'description' => esc_html__('Current Query Settings > Reading', 'uicore-elements'),
303 + ]
304 + );
305 + $this->add_control(
306 + 'item_order',
307 + [
308 + 'label' => esc_html__('Item Order', 'uicore-elements'),
309 + 'type' => Controls_Manager::SELECT,
310 + 'options' => [
311 + 'ASC' => esc_html__('Ascending', 'uicore-elements'),
312 + 'DESC' => esc_html__('Descending', 'uicore-elements'),
313 + ],
314 + 'default' => 'DESC',
315 + ]
316 + );
317 + $this->add_control(
318 + 'item_order_by',
319 + [
320 + 'label' => esc_html__('Item Order By', 'uicore-elements'),
321 + 'type' => Controls_Manager::SELECT,
322 + 'options' => [
323 + 'date' => esc_html__('Date', 'uicore-elements'),
324 + 'modified' => esc_html__('Modified Date', 'uicore-elements'),
325 + 'title' => esc_html__('Title', 'uicore-elements'),
326 + 'rand' => esc_html__('Random', 'uicore-elements'),
327 + 'comment_count' => esc_html__('Comments Count', 'uicore-elements'),
328 + 'menu_order' => esc_html__('Menu Order', 'uicore-elements'),
329 + ],
330 + 'default' => 'date',
331 + ]
332 + );
333 + $this->add_control(
334 + 'item_limit',
335 + [
336 + 'label' => esc_html__('Item Limit', 'uicore-elements'),
337 + 'type' => Controls_Manager::SLIDER,
338 + 'reder_type' => 'template',
339 + 'range' => [
340 + 'px' => [
341 + 'min' => -1,
342 + 'max' => 100,
276 343 ],
277 - 'default' => [
278 - 'size' => 3,
279 - ],
280 - 'condition' => array(
281 - 'posts-filter_post_type!' => 'current',
282 - ),
283 - ]
284 - );
344 + ],
345 + 'default' => [
346 + 'size' => 3,
347 + ],
348 + 'condition' => array(
349 + 'posts-filter_post_type!' => 'current',
350 + ),
351 + ]
352 + );
285 353
286 - $this->add_control(
287 - 'offset',
288 - [
289 - 'label' => esc_html__('Query Offset', 'uicore-elements'),
290 - 'type' => Controls_Manager::SLIDER,
291 - 'render_type' => 'template',
292 - 'range' => [
293 - 'px' => [
294 - 'min' => -1,
295 - 'max' => 10,
296 - ],
354 + $this->add_control(
355 + 'offset',
356 + [
357 + 'label' => esc_html__('Query Offset', 'uicore-elements'),
358 + 'type' => Controls_Manager::SLIDER,
359 + 'render_type' => 'template',
360 + 'range' => [
361 + 'px' => [
362 + 'min' => -1,
363 + 'max' => 10,
297 364 ],
298 - 'default' => [
299 - 'size' => 0,
300 - ],
301 - 'condition' => [
302 - 'pagination_type' => 'numbers',
303 - ]
365 + ],
366 + 'default' => [
367 + 'size' => 0,
368 + ],
369 + 'condition' => [
370 + 'pagination_type' => 'numbers',
304 371 ]
305 - );
372 + ]
373 + );
306 374
307 - $this->add_control(
308 - 'offset_alert',
309 - [
310 - 'type' => Controls_Manager::ALERT,
311 - 'alert_type' => 'info',
312 - 'content' => esc_html__('Offset is disabled with Load More pagination.', 'uicore-elements'),
313 - 'condition' => [
314 - 'pagination_type!' => 'numbers',
315 - ]
375 + $this->add_control(
376 + 'offset_alert',
377 + [
378 + 'type' => Controls_Manager::ALERT,
379 + 'alert_type' => 'info',
380 + 'content' => esc_html__('Offset is disabled with Load More pagination.', 'uicore-elements'),
381 + 'condition' => [
382 + 'pagination_type!' => 'numbers',
316 383 ]
317 - );
384 + ]
385 + );
318 386
319 - $this->add_control(
320 - 'sticky',
321 - [
322 - 'label' => esc_html__('Sticky Posts', 'uicore-elements'),
323 - 'type' => Controls_Manager::SWITCHER,
324 - 'label_on' => esc_html__('Show', 'uicore-elements'),
325 - 'label_off' => esc_html__('Hide', 'uicore-elements'),
326 - 'description' => esc_html__('Sticky posts works only on the front-end.', 'uicore-elements'),
327 - 'return_value' => 1,
328 - 'default' => 0,
329 - 'condition' => [
330 - 'pagination!' => 'yes',
331 - ],
332 - ]
333 - );
387 + $this->add_control(
388 + 'sticky',
389 + [
390 + 'label' => esc_html__('Sticky Posts', 'uicore-elements'),
391 + 'type' => Controls_Manager::SWITCHER,
392 + 'label_on' => esc_html__('Show', 'uicore-elements'),
393 + 'label_off' => esc_html__('Hide', 'uicore-elements'),
394 + 'description' => esc_html__('Sticky posts works only on the front-end.', 'uicore-elements'),
395 + 'return_value' => 1,
396 + 'default' => 0,
397 + 'condition' => [
398 + 'pagination!' => 'yes',
399 + ],
400 + ]
401 + );
334 402
335 - if($section){
403 + if ($section) {
336 404 $this->end_controls_section();
337 405 }
338 406 }
339 407
@@ -339,9 +407,9 @@
339 407
340 408 // Control Register Styles functions
341 409 function TRAIT_register_post_item_style_controls($section = true, $active_tab = false)
342 410 {
343 - if($section){
411 + if ($section) {
344 412 $this->start_controls_section(
345 413 'section_style_item',
346 414 [
347 415 'label' => __('Item Style', 'uicore-elements'),
@@ -349,132 +417,132 @@
349 417 ]
350 418 );
351 419 }
352 420
353 - $this->start_controls_tabs(
354 - 'item_border_shadow'
355 - );
421 + $this->start_controls_tabs(
422 + 'item_border_shadow'
423 + );
356 424
357 - $this->start_controls_tab(
358 - 'item_bs_normal_tab',
359 - [
360 - 'label' => esc_html__('Normal', 'uicore-elements'),
361 - ]
362 - );
363 - $this->add_group_control(
364 - Group_Control_Background::get_type(),
365 - [
366 - 'name' => 'content_bg',
367 - 'types' => [ 'classic', 'gradient' ],
368 - 'selector' => '{{WRAPPER}} .ui-e-item article',
369 - ]
370 - );
371 - $this->add_group_control(
372 - Group_Control_Border::get_type(),
373 - [
374 - 'name' => 'item_border',
375 - 'selector' => '{{WRAPPER}} .ui-e-item article',
376 - ]
377 - );
378 - $this->add_group_control(
379 - Group_Control_Box_Shadow::get_type(),
380 - [
381 - 'name' => 'item_shadow',
382 - 'selector' => '{{WRAPPER}} .ui-e-item article',
383 - ]
384 - );
385 - $this->end_controls_tab();
425 + $this->start_controls_tab(
426 + 'item_bs_normal_tab',
427 + [
428 + 'label' => esc_html__('Normal', 'uicore-elements'),
429 + ]
430 + );
431 + $this->add_group_control(
432 + Group_Control_Background::get_type(),
433 + [
434 + 'name' => 'content_bg',
435 + 'types' => ['classic', 'gradient'],
436 + 'selector' => '{{WRAPPER}} .ui-e-item article',
437 + ]
438 + );
439 + $this->add_group_control(
440 + Group_Control_Border::get_type(),
441 + [
442 + 'name' => 'item_border',
443 + 'selector' => '{{WRAPPER}} .ui-e-item article',
444 + ]
445 + );
446 + $this->add_group_control(
447 + Group_Control_Box_Shadow::get_type(),
448 + [
449 + 'name' => 'item_shadow',
450 + 'selector' => '{{WRAPPER}} .ui-e-item article',
451 + ]
452 + );
453 + $this->end_controls_tab();
386 454
387 - $this->start_controls_tab(
388 - 'item_bs_hover_tab',
389 - [
390 - 'label' => esc_html__('Hover', 'uicore-elements'),
391 - ]
392 - );
393 - $this->add_group_control(
394 - Group_Control_Background::get_type(),
395 - [
396 - 'name' => 'content_bg_hover',
397 - 'types' => [ 'classic', 'gradient' ],
398 - 'selector' => '{{WRAPPER}} .ui-e-item article',
399 - ]
400 - );
401 - $this->add_group_control(
402 - Group_Control_Border::get_type(),
403 - [
404 - 'name' => 'item_border_hover',
405 - 'selector' => '{{WRAPPER}} .ui-e-item:hover article',
406 - ]
407 - );
408 - $this->add_group_control(
409 - Group_Control_Box_Shadow::get_type(),
410 - [
411 - 'name' => 'item_shadow_hover',
412 - 'selector' => '{{WRAPPER}} .ui-e-item:hover article',
413 - ]
414 - );
415 - $this->end_controls_tab();
455 + $this->start_controls_tab(
456 + 'item_bs_hover_tab',
457 + [
458 + 'label' => esc_html__('Hover', 'uicore-elements'),
459 + ]
460 + );
461 + $this->add_group_control(
462 + Group_Control_Background::get_type(),
463 + [
464 + 'name' => 'content_bg_hover',
465 + 'types' => ['classic', 'gradient'],
466 + 'selector' => '{{WRAPPER}} .ui-e-item:hover article',
467 + ]
468 + );
469 + $this->add_group_control(
470 + Group_Control_Border::get_type(),
471 + [
472 + 'name' => 'item_border_hover',
473 + 'selector' => '{{WRAPPER}} .ui-e-item:hover article',
474 + ]
475 + );
476 + $this->add_group_control(
477 + Group_Control_Box_Shadow::get_type(),
478 + [
479 + 'name' => 'item_shadow_hover',
480 + 'selector' => '{{WRAPPER}} .ui-e-item:hover article',
481 + ]
482 + );
483 + $this->end_controls_tab();
416 484
417 - if($active_tab){
418 - $this->start_controls_tab(
419 - 'item_bs_active_tab',
420 - [
421 - 'label' => esc_html__('Active', 'uicore-elements'),
422 - ]
423 - );
424 - $this->add_group_control(
425 - Group_Control_Border::get_type(),
426 - [
427 - 'name' => 'item_border_active',
428 - 'selector' => '{{WRAPPER}} .ui-e-item.ui-e-active article',
429 - ]
430 - );
431 - $this->add_group_control(
432 - Group_Control_Box_Shadow::get_type(),
433 - [
434 - 'name' => 'item_shadow_active',
435 - 'selector' => '{{WRAPPER}} .ui-e-item.ui-e-active article',
436 - ]
437 - );
438 - $this->end_controls_tab();
439 - }
440 -
441 - $this->end_controls_tabs();
442 -
443 - $this->add_control(
444 - 'item_padding',
485 + if ($active_tab) {
486 + $this->start_controls_tab(
487 + 'item_bs_active_tab',
445 488 [
446 - 'label' => esc_html__('Padding', 'uicore-elements'),
447 - 'type' => Controls_Manager::DIMENSIONS,
448 - 'size_units' => ['px', 'em', 'rem', '%'],
449 - 'separator' => 'before',
450 - 'selectors' => [
451 - '{{WRAPPER}} .ui-e-item article' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
452 - ],
453 - 'condition' => array(
454 - 'box_style!' => 'overlay',
455 - ),
489 + 'label' => esc_html__('Active', 'uicore-elements'),
456 490 ]
457 -
458 491 );
459 - $this->add_control(
460 - 'item_radius',
492 + $this->add_group_control(
493 + Group_Control_Border::get_type(),
461 494 [
462 - 'label' => esc_html__('Border Radius', 'uicore-elements'),
463 - 'type' => Controls_Manager::DIMENSIONS,
464 - 'selectors' => [
465 - '{{WRAPPER}} ' => '--ui-e-border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;'
466 - ],
495 + 'name' => 'item_border_active',
496 + 'selector' => '{{WRAPPER}} .ui-e-item.ui-e-active article',
467 497 ]
468 498 );
499 + $this->add_group_control(
500 + Group_Control_Box_Shadow::get_type(),
501 + [
502 + 'name' => 'item_shadow_active',
503 + 'selector' => '{{WRAPPER}} .ui-e-item.ui-e-active article',
504 + ]
505 + );
506 + $this->end_controls_tab();
507 + }
469 508
470 - if($section){
509 + $this->end_controls_tabs();
510 +
511 + $this->add_control(
512 + 'item_padding',
513 + [
514 + 'label' => esc_html__('Padding', 'uicore-elements'),
515 + 'type' => Controls_Manager::DIMENSIONS,
516 + 'size_units' => ['px', 'em', 'rem', '%'],
517 + 'separator' => 'before',
518 + 'selectors' => [
519 + '{{WRAPPER}} .ui-e-item article' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
520 + ],
521 + 'condition' => array(
522 + 'box_style!' => 'overlay',
523 + ),
524 + ]
525 +
526 + );
527 + $this->add_control(
528 + 'item_radius',
529 + [
530 + 'label' => esc_html__('Border Radius', 'uicore-elements'),
531 + 'type' => Controls_Manager::DIMENSIONS,
532 + 'selectors' => [
533 + '{{WRAPPER}} ' => '--ui-e-border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;'
534 + ],
535 + ]
536 + );
537 +
538 + if ($section) {
471 539 $this->end_controls_section();
472 540 }
473 541 }
474 542 function TRAIT_register_post_content_style_controls($section = true)
475 543 {
476 - if($section){
544 + if ($section) {
477 545 $this->start_controls_section(
478 546 'section_style_content',
479 547 [
480 548 'label' => __('Content Style', 'uicore-elements'),
@@ -481,235 +549,302 @@
481 549 'tab' => Controls_Manager::TAB_STYLE,
482 550 ]
483 551 );
484 552 }
485 - $this->add_control(
486 - 'image_size',
487 - [
488 - 'label' => __('Image Height (%)', 'uicore-elements'),
489 - 'type' => Controls_Manager::NUMBER,
490 - 'min' => 1,
491 - 'max' => 500,
492 - 'step' => 1,
493 - 'default' => 57,
494 - 'selectors' => [
495 - '{{WRAPPER}} .ui-e-post-top' => '--ui-e-img-size: {{VALUE}}',
553 + $this->add_responsive_control(
554 + 'image_size',
555 + [
556 + 'label' => __('Image Height (%)', 'uicore-elements'),
557 + 'type' => Controls_Manager::NUMBER,
558 + 'min' => 1,
559 + 'max' => 500,
560 + 'step' => 1,
561 + 'default' => 57,
562 + 'selectors' => [
563 + '{{WRAPPER}} .ui-e-post-top' => '--ui-e-img-size: {{VALUE}}',
564 + ],
565 + 'condition' => [
566 + 'masonry!' => 'ui-e-maso',
567 + ],
568 + ]
569 + );
570 + $this->add_responsive_control(
571 + 'image_position',
572 + [
573 + 'label' => __('Image Position', 'uicore-elements'),
574 + 'type' => Controls_Manager::SELECT,
575 + 'default' => 'center center',
576 + 'tablet_default' => '',
577 + 'mobile_default' => '',
578 + 'options' => [
579 + '' => esc_html__('Default', 'uicore-elements'),
580 + 'left top' => esc_html__('Left Top', 'uicore-elements'),
581 + 'left center' => esc_html__('Left Center', 'uicore-elements'),
582 + 'left bottom' => esc_html__('Left Bottom', 'uicore-elements'),
583 + 'center top' => esc_html__('Center Top', 'uicore-elements'),
584 + 'center center' => esc_html__('Center Center', 'uicore-elements'),
585 + 'center bottom' => esc_html__('Center Bottom', 'uicore-elements'),
586 + 'right top' => esc_html__('Right Top', 'uicore-elements'),
587 + 'right center' => esc_html__('Right Center', 'uicore-elements'),
588 + 'right bottom' => esc_html__('Right Bottom', 'uicore-elements'),
589 + ],
590 + 'selectors' => [
591 + '{{WRAPPER}} .ui-e-post-img' => 'background-position: {{VALUE}}',
592 + ],
593 + ]
594 + );
595 + $this->add_responsive_control(
596 + 'image_fit',
597 + [
598 + 'label' => __('Image Fit', 'uicore-elements'),
599 + 'type' => Controls_Manager::SELECT,
600 + 'default' => 'cover',
601 + 'tablet_default' => '',
602 + 'mobile_default' => '',
603 + 'options' => [
604 + '' => esc_html__('Default', 'uicore-elements'),
605 + 'cover' => esc_html__('Cover', 'uicore-elements'),
606 + 'contain' => esc_html__('Contain', 'uicore-elements'),
607 + 'auto' => esc_html__('Auto', 'uicore-elements'),
608 + ],
609 + 'selectors' => [
610 + '{{WRAPPER}} .ui-e-post-img' => 'background-size: {{VALUE}}',
611 + ],
612 + ]
613 + );
614 + $this->add_control(
615 + 'image_radius',
616 + [
617 + 'label' => esc_html__('Border Radius', 'uicore-elements'),
618 + 'type' => Controls_Manager::DIMENSIONS,
619 + 'size_units' => ['px', 'em', '%'],
620 + 'selectors' => [
621 + '{{WRAPPER}} .ui-e-post-top' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}px {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
622 + ],
623 + 'condition' => array(
624 + 'box_style!' => 'overlay',
625 + ),
626 + ]
627 + );
628 + $this->add_group_control(
629 + Group_Control_Box_Shadow::get_type(),
630 + [
631 + 'name' => 'image_shadow',
632 + 'label' => esc_html__('Box Shadow', 'uicore-elements'),
633 + 'selector' => '{{WRAPPER}} .ui-e-post-top',
634 + 'condition' => array(
635 + 'box_style!' => 'overlay',
636 + ),
637 + ]
638 + );
639 + $this->add_responsive_control(
640 + 'content_alignment',
641 + [
642 + 'label' => esc_html__('Content Alignment', 'uicore-elements'),
643 + 'type' => Controls_Manager::CHOOSE,
644 + 'options' => [
645 + 'start' => [
646 + 'title' => esc_html__('Left', 'uicore-elements'),
647 + 'icon' => 'eicon-text-align-left',
496 648 ],
497 - 'condition' => [
498 - 'masonry!' => 'ui-e-maso',
649 + 'center' => [
650 + 'title' => esc_html__('Center', 'uicore-elements'),
651 + 'icon' => 'eicon-text-align-center',
499 652 ],
500 - ]
501 - );
502 - $this->add_control(
503 - 'image_radius',
504 - [
505 - 'label' => esc_html__('Border Radius', 'uicore-elements'),
506 - 'type' => Controls_Manager::DIMENSIONS,
507 - 'size_units' => ['px', 'em', '%'],
508 - 'selectors' => [
509 - '{{WRAPPER}} .ui-e-post-top' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}px {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
653 + 'end' => [
654 + 'title' => esc_html__('Right', 'uicore-elements'),
655 + 'icon' => 'eicon-text-align-right',
510 656 ],
511 - 'condition' => array(
512 - 'box_style!' => 'overlay',
513 - ),
514 - ]
515 - );
516 - $this->add_group_control(
517 - Group_Control_Box_Shadow::get_type(),
518 - [
519 - 'name' => 'image_shadow',
520 - 'label' => esc_html__('Box Shadow', 'uicore-elements'),
521 - 'selector' => '{{WRAPPER}} .ui-e-post-top',
522 - 'condition' => array(
523 - 'box_style!' => 'overlay',
524 - ),
525 - ]
526 - );
527 - $this->add_responsive_control(
528 - 'content_alignment',
529 - [
530 - 'label' => esc_html__('Content Alignment', 'uicore-elements'),
531 - 'type' => Controls_Manager::CHOOSE,
532 - 'options' => [
533 - 'left' => [
534 - 'title' => esc_html__('Left', 'uicore-elements'),
535 - 'icon' => 'eicon-text-align-left',
536 - ],
537 - 'center' => [
538 - 'title' => esc_html__('Center', 'uicore-elements'),
539 - 'icon' => 'eicon-text-align-center',
540 - ],
541 - 'stretch' => [
542 - 'title' => esc_html__('Justified', 'uicore-elements'),
543 - 'icon' => 'eicon-text-align-justify',
544 - ],
657 + 'stretch' => [
658 + 'title' => esc_html__('Justified', 'uicore-elements'),
659 + 'icon' => 'eicon-text-align-justify',
545 660 ],
546 - 'selectors' => [
547 - '{{WRAPPER}} .ui-e-post-content' => 'align-items: {{VALUE}}; text-align: {{VALUE}};',
661 + ],
662 + 'selectors_dictionary' => [
663 + 'left' => 'start',
664 + ],
665 + 'default' => is_rtl() ? 'end' : 'start',
666 + 'selectors' => [
667 + '{{WRAPPER}} .ui-e-post-content' => 'align-items: {{VALUE}}; text-align: {{VALUE}};',
668 + ],
669 + ]
670 + );
671 + $this->add_control(
672 + 'title_color',
673 + [
674 + 'label' => esc_html__('Title Color', 'uicore-elements'),
675 + 'type' => Controls_Manager::COLOR,
676 + 'default' => '',
677 + 'separator' => 'before',
678 + 'selectors' => [
679 + '{{WRAPPER}} .ui-e-post-title' => 'color: {{VALUE}};',
680 + ],
681 + ]
682 + );
683 + $this->add_control(
684 + 'title_hcolor',
685 + [
686 + 'label' => esc_html__('Title Hover Color', 'uicore-elements'),
687 + 'type' => Controls_Manager::COLOR,
688 + 'default' => '',
689 + 'selectors' => [
690 + '{{WRAPPER}} .ui-e-post-title:hover' => 'color: {{VALUE}};',
691 + ],
692 + ]
693 + );
694 + $this->add_group_control(
695 + Group_Control_Typography::get_type(),
696 + [
697 + 'name' => 'title_typography',
698 + 'label' => esc_html__('Title Typography', 'uicore-elements'),
699 + 'selector' => '{{WRAPPER}} .ui-e-post-title',
700 + ]
701 + );
702 + $this->add_responsive_control(
703 + 'title_gap',
704 + [
705 + 'label' => __('Title Top Space', 'uicore-elements'),
706 + 'type' => Controls_Manager::SLIDER,
707 + 'size_units' => ['em'],
708 + 'separator' => 'after',
709 + 'range' => [
710 + 'px' => [
711 + 'min' => 0,
712 + 'max' => 3,
713 + 'step' => 0.1,
548 714 ],
549 - ]
550 - );
551 - $this->add_control(
552 - 'title_color',
553 - [
554 - 'label' => esc_html__('Title Color', 'uicore-elements'),
555 - 'type' => Controls_Manager::COLOR,
556 - 'default' => '',
557 - 'separator' => 'before',
558 - 'selectors' => [
559 - '{{WRAPPER}} .ui-e-post-title' => 'color: {{VALUE}};',
715 + ],
716 + 'default' => [
717 + 'unit' => 'em',
718 + 'size' => 1.2,
719 + ],
720 + 'selectors' => [
721 + '{{WRAPPER}} .ui-e-post-title' => 'margin-top: {{SIZE}}em;',
722 + ],
723 + ]
724 + );
725 + $this->add_control(
726 + 'text_color',
727 + [
728 + 'label' => esc_html__('Excerpt Color', 'uicore-elements'),
729 + 'type' => Controls_Manager::COLOR,
730 + 'default' => '',
731 + 'selectors' => [
732 + '{{WRAPPER}} .ui-e-post-text' => 'color: {{VALUE}};',
733 + ],
734 + ]
735 + );
736 + $this->add_group_control(
737 + Group_Control_Typography::get_type(),
738 + [
739 + 'name' => 'text_typography',
740 + 'label' => esc_html__('Excerpt Typography', 'uicore-elements'),
741 + 'selector' => '{{WRAPPER}} .ui-e-post-text',
742 + ]
743 + );
744 + $this->add_responsive_control(
745 + 'text_gap',
746 + [
747 + 'label' => __('Excerpt Top Space', 'uicore-elements'),
748 + 'type' => Controls_Manager::SLIDER,
749 + 'size_units' => ['em'],
750 + 'separator' => 'after',
751 + 'range' => [
752 + 'px' => [
753 + 'min' => 0,
754 + 'max' => 3,
755 + 'step' => 0.1,
560 756 ],
561 - ]
562 - );
563 - $this->add_control(
564 - 'title_hcolor',
565 - [
566 - 'label' => esc_html__('Title Hover Color', 'uicore-elements'),
567 - 'type' => Controls_Manager::COLOR,
568 - 'default' => '',
569 - 'selectors' => [
570 - '{{WRAPPER}} .ui-e-post-title:hover' => 'color: {{VALUE}};',
757 + ],
758 + 'default' => [
759 + 'unit' => 'em',
760 + 'size' => 0.8,
761 + ],
762 + 'selectors' => [
763 + '{{WRAPPER}} .ui-e-post-text' => 'margin-top: {{SIZE}}em;',
764 + ],
765 + ]
766 + );
767 + $this->add_group_control(
768 + Group_Control_Background::get_type(),
769 + [
770 + 'name' => 'content_background',
771 + 'selector' => '{{WRAPPER}} .ui-e-post-content',
772 + ]
773 + );
774 + $this->add_group_control(
775 + Group_Control_Background::get_type(),
776 + [
777 + 'name' => 'content_background_hover',
778 + 'selector' => '{{WRAPPER}} .ui-e-item:hover .ui-e-post-content',
779 + 'fields_options' => [
780 + 'background' => [
781 + 'label' => esc_html__('Hover Background', 'uicore-elements'),
571 782 ],
783 + ],
784 + 'condition' => [
785 + 'box_style' => 'overlay',
572 786 ]
573 - );
574 - $this->add_group_control(
575 - Group_Control_Typography::get_type(),
576 - [
577 - 'name' => 'title_typography',
578 - 'label' => esc_html__('Title Typography', 'uicore-elements'),
579 - 'selector' => '{{WRAPPER}} .ui-e-post-title',
787 + ]
788 + );
789 + $this->add_responsive_control(
790 + 'content_padding',
791 + [
792 + 'label' => esc_html__('Content Padding', 'uicore-elements'),
793 + 'type' => Controls_Manager::DIMENSIONS,
794 + 'size_units' => ['px', 'em', '%'],
795 + 'selectors' => [
796 + '{{WRAPPER}} .ui-e-post-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
580 797 ]
581 - );
582 - $this->add_control(
583 - 'title_gap',
584 - [
585 - 'label' => __('Title Top Space', 'uicore-elements'),
586 - 'type' => Controls_Manager::SLIDER,
587 - 'size_units' => ['em'],
588 - 'separator' => 'after',
589 - 'range' => [
590 - 'px' => [
591 - 'min' => 0,
592 - 'max' => 3,
593 - 'step' => 0.1,
594 - ],
798 + ]
799 + );
800 + $this->add_control(
801 + 'content_radius',
802 + [
803 + 'label' => esc_html__('Content Border Radius', 'uicore-elements'),
804 + 'type' => Controls_Manager::DIMENSIONS,
805 + 'selectors' => [
806 + '{{WRAPPER}} .ui-e-post-content' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;'
807 + ],
808 + 'condition' => array(
809 + 'box_style!' => 'overlay',
810 + ),
811 + ]
812 + );
813 + $this->add_control(
814 + 'content_gap',
815 + [
816 + 'label' => __('Content Space', 'uicore-elements'),
817 + 'type' => Controls_Manager::SLIDER,
818 + 'size_units' => ['em'],
819 + 'separator' => 'after',
820 + 'range' => [
821 + 'px' => [
822 + 'min' => 0,
823 + 'max' => 3,
824 + 'step' => 0.1,
595 825 ],
596 - 'default' => [
597 - 'unit' => 'em',
598 - 'size' => 1.2,
599 - ],
600 - 'selectors' => [
601 - '{{WRAPPER}} .ui-e-post-title' => 'margin-top: {{SIZE}}em;',
602 - ],
603 - ]
604 - );
605 - $this->add_control(
606 - 'text_color',
607 - [
608 - 'label' => esc_html__('Excerpt Color', 'uicore-elements'),
609 - 'type' => Controls_Manager::COLOR,
610 - 'default' => '',
611 - 'selectors' => [
612 - '{{WRAPPER}} .ui-e-post-text' => 'color: {{VALUE}};',
613 - ],
614 - ]
615 - );
616 - $this->add_group_control(
617 - Group_Control_Typography::get_type(),
618 - [
619 - 'name' => 'text_typography',
620 - 'label' => esc_html__('Excerpt Typography', 'uicore-elements'),
621 - 'selector' => '{{WRAPPER}} .ui-e-post-text',
622 - ]
623 - );
624 - $this->add_control(
625 - 'text_gap',
626 - [
627 - 'label' => __('Excerpt Top Space', 'uicore-elements'),
628 - 'type' => Controls_Manager::SLIDER,
629 - 'size_units' => ['em'],
630 - 'separator' => 'after',
631 - 'range' => [
632 - 'px' => [
633 - 'min' => 0,
634 - 'max' => 3,
635 - 'step' => 0.1,
636 - ],
637 - ],
638 - 'default' => [
639 - 'unit' => 'em',
640 - 'size' => 0.8,
641 - ],
642 - 'selectors' => [
643 - '{{WRAPPER}} .ui-e-post-text' => 'margin-top: {{SIZE}}em;',
644 - ],
645 - ]
646 - );
647 - $this->add_group_control(
648 - Group_Control_Background::get_type(),
649 - [
650 - 'name' => 'content_background',
651 - 'selector' => '{{WRAPPER}} .ui-e-post-content',
652 - ]
653 - );
654 - $this->add_responsive_control(
655 - 'content_padding',
656 - [
657 - 'label' => esc_html__('Content Padding', 'uicore-elements'),
658 - 'type' => Controls_Manager::DIMENSIONS,
659 - 'size_units' => ['px', 'em', '%'],
660 - 'selectors' => [
661 - '{{WRAPPER}} .ui-e-post-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
662 - ]
663 - ]
664 - );
665 - $this->add_control(
666 - 'content_radius',
667 - [
668 - 'label' => esc_html__('Content Border Radius', 'uicore-elements'),
669 - 'type' => Controls_Manager::DIMENSIONS,
670 - 'selectors' => [
671 - '{{WRAPPER}} .ui-e-post-content' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;'
672 - ],
673 - 'condition' => array(
674 - 'box_style!' => 'overlay',
675 - ),
676 - ]
677 - );
678 - $this->add_control(
679 - 'content_gap',
680 - [
681 - 'label' => __('Content Space', 'uicore-elements'),
682 - 'type' => Controls_Manager::SLIDER,
683 - 'size_units' => ['em'],
684 - 'separator' => 'after',
685 - 'range' => [
686 - 'px' => [
687 - 'min' => 0,
688 - 'max' => 3,
689 - 'step' => 0.1,
690 - ],
691 - ],
692 - 'default' => [
693 - 'unit' => 'em',
694 - 'size' => 0,
695 - ],
696 - 'selectors' => [
697 - '{{WRAPPER}} ' => '--ui-e-content-space: {{SIZE}}em;',
698 - ],
699 - 'condition' => array(
700 - 'box_style!' => 'overlay',
701 - ),
702 - ]
703 - );
826 + ],
827 + 'default' => [
828 + 'unit' => 'em',
829 + 'size' => 0,
830 + ],
831 + 'selectors' => [
832 + '{{WRAPPER}} ' => '--ui-e-content-space: {{SIZE}}em;',
833 + ],
834 + 'condition' => array(
835 + 'box_style!' => 'overlay',
836 + ),
837 + ]
838 + );
704 839
705 - if($section){
840 + if ($section) {
706 841 $this->end_controls_section();
707 842 }
708 843 }
709 844 function TRAIT_register_post_button_style_controls($section = true)
710 845 {
711 - if($section){
846 + if ($section) {
712 847 $this->start_controls_section(
713 848 'section_button_style',
714 849 [
715 850 'label' => esc_html__('Button Style', 'uicore-elements'),
@@ -719,57 +854,57 @@
719 854 ),
720 855 ]
721 856 );
722 857 }
723 - $this->add_responsive_control(
724 - 'button_align',
725 - [
726 - 'label' => esc_html__( 'Alignment', 'uicore-elements' ),
727 - 'type' => Controls_Manager::CHOOSE,
728 - 'options' => [
729 - 'start' => [
730 - 'title' => esc_html__( 'Left', 'uicore-elements' ),
731 - 'icon' => 'eicon-text-align-left',
732 - ],
733 - 'center' => [
734 - 'title' => esc_html__( 'Center', 'uicore-elements' ),
735 - 'icon' => 'eicon-text-align-center',
736 - ],
737 - 'end' => [
738 - 'title' => esc_html__( 'Right', 'uicore-elements' ),
739 - 'icon' => 'eicon-text-align-right',
740 - ],
741 - 'normal' => [
742 - 'title' => esc_html__( 'Justified', 'uicore-elements' ),
743 - 'icon' => 'eicon-text-align-justify',
744 - ],
858 + $this->add_responsive_control(
859 + 'button_align',
860 + [
861 + 'label' => esc_html__('Alignment', 'uicore-elements'),
862 + 'type' => Controls_Manager::CHOOSE,
863 + 'options' => [
864 + 'start' => [
865 + 'title' => esc_html__('Left', 'uicore-elements'),
866 + 'icon' => 'eicon-text-align-left',
745 867 ],
746 - 'default' => 'start',
747 - 'selectors' => [
748 - '{{WRAPPER}} .ui-e-readmore' => 'align-self: {{VALUE}};',
868 + 'center' => [
869 + 'title' => esc_html__('Center', 'uicore-elements'),
870 + 'icon' => 'eicon-text-align-center',
749 871 ],
872 + 'end' => [
873 + 'title' => esc_html__('Right', 'uicore-elements'),
874 + 'icon' => 'eicon-text-align-right',
875 + ],
876 + 'normal' => [
877 + 'title' => esc_html__('Justified', 'uicore-elements'),
878 + 'icon' => 'eicon-text-align-justify',
879 + ],
880 + ],
881 + 'default' => 'start',
882 + 'selectors' => [
883 + '{{WRAPPER}} .ui-e-readmore' => 'align-self: {{VALUE}};',
884 + ],
750 885
886 + ]
887 + );
888 + $this->register_button_style_controls(
889 + [
890 + 'section_condition' => [
891 + 'show_button' => 'yes'
751 892 ]
752 - );
753 - $this->register_button_style_controls(
754 - [
755 - 'section_condition' => [
756 - 'show_button' => 'yes'
757 - ]
758 - ]
759 - );
760 - // Remove button alignment from Elementor button traits because (seens to be a bug), updating Selector CSS with update_control(), don't work as expected with responsiveness
761 - $this->remove_responsive_control('align');
893 + ]
894 + );
895 + // Remove button alignment from Elementor button traits because (seens to be a bug), updating Selector CSS with update_control(), don't work as expected with responsiveness
896 + $this->remove_responsive_control('align');
762 897
763 - $this->TRAIT_register_post_specific_controls('button_gap');
898 + $this->TRAIT_register_post_specific_controls('button_gap');
764 899
765 - if($section) {
900 + if ($section) {
766 901 $this->end_controls_section();
767 902 }
768 903 }
769 904 function TRAIT_register_post_meta_style_controls($section = true)
770 905 {
771 - if($section) {
906 + if ($section) {
772 907 $this->start_controls_section(
773 908 'section_style_extra_content',
774 909 [
775 910 'label' => __('Meta Style', 'uicore-elements'),
@@ -776,47 +911,47 @@
776 911 'tab' => Controls_Manager::TAB_STYLE,
777 912 ]
778 913 );
779 914 }
780 - $this->start_controls_tabs('style_extra_tabs');
781 - $this->start_controls_tab(
782 - 'style_top_tab',
783 - [
784 - 'label' => esc_html__('Top', 'uicore-elements'),
785 - ]
786 - );
787 - $this->get_meta_style_controls('top');
788 - $this->end_controls_tab();
915 + $this->start_controls_tabs('style_extra_tabs');
916 + $this->start_controls_tab(
917 + 'style_top_tab',
918 + [
919 + 'label' => esc_html__('Top', 'uicore-elements'),
920 + ]
921 + );
922 + $this->get_meta_style_controls('top');
923 + $this->end_controls_tab();
789 924
790 - $this->start_controls_tab(
791 - 'style_before_title_tab',
792 - [
793 - 'label' => esc_html__('Before Title', 'uicore-elements'),
794 - ]
795 - );
796 - $this->get_meta_style_controls('before_title');
797 - $this->end_controls_tab();
925 + $this->start_controls_tab(
926 + 'style_before_title_tab',
927 + [
928 + 'label' => esc_html__('Before Title', 'uicore-elements'),
929 + ]
930 + );
931 + $this->get_meta_style_controls('before_title');
932 + $this->end_controls_tab();
798 933
799 - $this->start_controls_tab(
800 - 'style_after_title_tab',
801 - [
802 - 'label' => esc_html__('After Title', 'uicore-elements'),
803 - ]
804 - );
805 - $this->get_meta_style_controls('after_title');
806 - $this->end_controls_tab();
934 + $this->start_controls_tab(
935 + 'style_after_title_tab',
936 + [
937 + 'label' => esc_html__('After Title', 'uicore-elements'),
938 + ]
939 + );
940 + $this->get_meta_style_controls('after_title');
941 + $this->end_controls_tab();
807 942
808 - $this->start_controls_tab(
809 - 'style_bottom_tab',
810 - [
811 - 'label' => esc_html__('Bottom', 'uicore-elements'),
812 - ]
813 - );
814 - $this->get_meta_style_controls('bottom');
815 - $this->end_controls_tab();
816 - $this->end_controls_tabs();
943 + $this->start_controls_tab(
944 + 'style_bottom_tab',
945 + [
946 + 'label' => esc_html__('Bottom', 'uicore-elements'),
947 + ]
948 + );
949 + $this->get_meta_style_controls('bottom');
950 + $this->end_controls_tab();
951 + $this->end_controls_tabs();
817 952
818 - if($section) {
953 + if ($section) {
819 954 $this->end_controls_section();
820 955 }
821 956 }
822 957 function TRAIT_register_post_animation_controls()
@@ -870,8 +1005,9 @@
870 1005 'default' => '',
871 1006 'options' => [
872 1007 '' => __('None', 'uicore-elements'),
873 1008 'ui-e-title-anim-underline' => __('Underline', 'uicore-elements'),
1009 + 'ui-e-title-anim-show' => __('Show', 'uicore-elements'),
874 1010 ],
875 1011 'prefix_class' => '',
876 1012 ]
877 1013 );
@@ -953,16 +1089,20 @@
953 1089 * @param array $settings Elementor controls settings.
954 1090 * @param object $default_query The default query object. Used to tell if is a frontend or rest api request.
955 1091 *
956 1092 * @return void Don't return anything, but sets the query object to $_query variable that can be accessed by the widget.
957 - */
1093 + */
958 1094 function TRAIT_query_posts($settings, $default_query)
959 1095 {
960 1096 $post_type = $settings['posts-filter_post_type'];
961 1097
962 - if ( $post_type === 'related' ) {
963 - $this->_query = Helper::get_related('random', $settings['item_limit']['size']);
964 -
1098 + if ($post_type === 'related') {
1099 + $current_post_id = $settings['__current_post_id'] ?? [];
1100 + $this->_query = Helper::get_related_ajax(
1101 + Query::get_queried_page($settings),
1102 + $settings['item_limit']['size'],
1103 + $current_post_id
1104 + );
965 1105 } else {
966 1106 $query_args = Query::get_query_args('posts-filter', $settings);
967 1107
968 1108 if ($post_type === 'current') {
@@ -967,17 +1107,16 @@
967 1107
968 1108 if ($post_type === 'current') {
969 1109
970 1110 // Makes sure widget will render some posts at editor screen
971 - if( $this->is_edit_mode() ){
1111 + if ($this->is_edit_mode()) {
972 1112 $query_args['post_type'] = 'post';
973 -
974 1113 } else {
975 1114 $query_args = $default_query;
976 1115
977 1116 /// TODO: very likely commit `38c618c` on Elements repo make this fallback useless. Test it
978 1117 // Post type fallback for APG
979 - if( isset($default_query['post_type']) || isset($default_query['query']['post_type']) ){
1118 + if (isset($default_query['post_type']) || isset($default_query['query']['post_type'])) {
980 1119 $post_type = $default_query['post_type'] ?? $default_query['query']['post_type'];
981 1120 } else {
982 1121 $post_type = 'post';
983 1122 }
@@ -1009,9 +1148,9 @@
1009 1148
1010 1149 // Render functions
1011 1150 function get_post_image()
1012 1151 {
1013 - if ( $this->is_option('image', 'yes', '!==') ) {
1152 + if ($this->is_option('image', 'yes', '!==')) {
1014 1153 return;
1015 1154 }
1016 1155
1017 1156 $pic_id = get_post_thumbnail_id();
@@ -1017,34 +1156,36 @@
1017 1156 $pic_id = get_post_thumbnail_id();
1018 1157 if (!$pic_id)
1019 1158 return;
1020 1159 $size = $this->get_settings_for_display('image_size_select') ?? 'uicore-medium';
1021 - ?>
1022 - <a class="ui-e-post-img-wrapp"
1023 - href="<?php echo esc_url(get_permalink()); ?>"
1024 - title="<?php echo esc_attr__('View Post:', 'uicore-elements') . the_title_attribute(['echo' => false]); ?>">
1160 +?>
1161 + <a class="ui-e-post-img-wrapp"
1162 + href="<?php echo esc_url(get_permalink()); ?>"
1163 + title="<?php echo esc_attr__('View Post:', 'uicore-elements') . the_title_attribute(['echo' => false]); ?>">
1025 1164
1026 - <?php if ($this->get_settings_for_display('masonry') === 'ui-e-maso') { ?>
1027 - <?php the_post_thumbnail($size, ['class' => 'ui-e-post-img']); ?>
1028 - <?php } else { ?>
1029 - <div class="ui-e-post-img" style="background-image:url(<?php echo esc_url( wp_get_attachment_image_url($pic_id, $size)); ?>)"></div>
1030 - <?php } ?>
1031 - </a>
1032 - <?php
1165 + <?php if ($this->get_settings_for_display('masonry') === 'ui-e-maso') { ?>
1166 + <?php the_post_thumbnail($size, ['class' => 'ui-e-post-img']); ?>
1167 + <?php } else { ?>
1168 + <div class="ui-e-post-img" style="background-image:url(<?php echo esc_url(wp_get_attachment_image_url($pic_id, $size)); ?>)"></div>
1169 + <?php } ?>
1170 + </a>
1171 + <?php
1033 1172
1034 1173 }
1035 - function get_post_title()
1174 + function get_post_title(string $tag)
1036 1175 {
1037 - if ( $this->is_option('title', 'yes', '!==') ) {
1176 + if ($this->is_option('title', 'yes', '!==')) {
1038 1177 return;
1039 1178 }
1040 - ?>
1041 - <a href="<?php echo esc_url( get_permalink() );?>" title="<?php echo esc_attr__('View Post:','uicore-elements') . esc_html(the_title_attribute(['echo'=>false])); ?>">
1042 - <h4 class="ui-e-post-title"><span><?php echo esc_html(get_the_title()); ?></span></h4>
1043 - </a>
1044 - <?php
1179 + ?>
1180 + <a href="<?php echo esc_url(get_permalink()); ?>" title="<?php echo esc_attr__('View Post:', 'uicore-elements') . esc_html(the_title_attribute(['echo' => false])); ?>">
1181 + <<?php echo Helper::esc_tag($tag); ?> class="ui-e-post-title">
1182 + <span> <?php echo esc_html(get_the_title()); ?> </span>
1183 + </<?php echo Helper::esc_tag($tag); ?>>
1184 + </a>
1185 + <?php
1045 1186 }
1046 - function get_post_meta($position)
1187 + function get_post_meta($position, $product_id = null)
1047 1188 {
1048 1189 $meta_list = $this->get_settings_for_display($position . '_meta');
1049 1190 if (!isset($meta_list[0]) || $meta_list[0]['type'] == '') {
1050 1191 return;
@@ -1050,18 +1191,18 @@
1050 1191 return;
1051 1192 }
1052 1193 echo ($position == 'top') ? '<div class="ui-e-post-top-meta">' : '';
1053 1194 echo ($position == 'after_title') ? '<div class="ui-e-meta-wrapp">' : '';
1054 - echo '<div class="ui-e-post-meta ui-e-'.esc_attr($position).'">';
1055 - foreach ($meta_list as $meta) {
1056 - if($meta['type'] != 'none'){
1057 - $this->display_meta($meta);
1195 + echo '<div class="ui-e-post-meta ui-e-' . esc_attr($position) . '">';
1196 + foreach ($meta_list as $meta) {
1197 + if ($meta['type'] != 'none') {
1198 + $this->display_meta($meta, $product_id);
1058 1199
1059 - if( next( $meta_list ) && $this->get_settings_for_display( $position.'_meta_separator' ) ) {
1060 - echo '<span class="ui-e-separator">'.esc_html($this->get_settings_for_display( $position.'_meta_separator' )).'</span>';
1061 - }
1200 + if (next($meta_list) && $this->get_settings_for_display($position . '_meta_separator')) {
1201 + echo '<span class="ui-e-separator">' . esc_html($this->get_settings_for_display($position . '_meta_separator')) . '</span>';
1062 1202 }
1063 1203 }
1204 + }
1064 1205 echo '</div>';
1065 1206 echo ($position == 'top' || $position == 'after_title') ? '</div>' : '';
1066 1207 }
1067 1208 /**
@@ -1075,12 +1216,12 @@
1075 1216 {
1076 1217 $settings = $this->get_settings_for_display();
1077 1218
1078 1219 // Render att slugs
1079 - $button_slug = 'button_'.$index;
1080 - $content_slug = 'content-wrapper_'.$index;
1081 - $icon_slug = 'icon-align_'.$index;
1082 - $text_slug = 'text_'.$index;
1220 + $button_slug = 'button_' . $index;
1221 + $content_slug = 'content-wrapper_' . $index;
1222 + $icon_slug = 'icon-align_' . $index;
1223 + $text_slug = 'text_' . $index;
1083 1224
1084 1225 $this->add_render_attribute($button_slug, [
1085 1226 'class' => ['elementor-button-link', 'elementor-button', 'ui-e-readmore'],
1086 1227 'role' => 'button',
@@ -1100,9 +1241,9 @@
1100 1241 $this->add_render_attribute($button_slug, 'class', 'elementor-animation-' . $settings['hover_animation']);
1101 1242 }
1102 1243
1103 1244 $btn_classes = isset($settings['icon_align'])
1104 - ? ['elementor-button-icon', 'elementor-align-icon-' . $settings['icon_align'] ]
1245 + ? ['elementor-button-icon', 'elementor-align-icon-' . $settings['icon_align']]
1105 1246 : 'elementor-button-icon';
1106 1247
1107 1248 $this->add_render_attribute([
1108 1249 $icon_slug => [
@@ -1112,9 +1253,9 @@
1112 1253 'class' => 'elementor-button-text',
1113 1254 ],
1114 1255 ]);
1115 1256
1116 - if( isset($settings['icon_align']) ){
1257 + if (isset($settings['icon_align'])) {
1117 1258 $this->add_render_attribute($content_slug, 'class', 'elementor-button-content');
1118 1259 }
1119 1260
1120 1261 $tbn_content = '<span ' . $this->get_render_attribute_string($content_slug) . '>';
@@ -1130,15 +1271,15 @@
1130 1271 $tbn_content .= '<span ' . $this->get_render_attribute_string($text_slug) . '>';
1131 1272 $tbn_content .= $settings['text'];
1132 1273 $tbn_content .= '</span> </span>';
1133 1274
1134 - ?>
1135 - <a href="<?php echo esc_url(get_permalink()); ?>" <?php $this->print_render_attribute_string($button_slug); ?>>
1136 - <?php
1137 - //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1138 - echo Helper::esc_svg( $tbn_content );
1139 - ?>
1140 - </a>
1275 + ?>
1276 + <a href="<?php echo esc_url(get_permalink()); ?>" <?php $this->print_render_attribute_string($button_slug); ?>>
1277 + <?php
1278 + //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1279 + echo Helper::esc_svg($tbn_content);
1280 + ?>
1281 + </a>
1141 1282 <?php
1142 1283 }
1143 1284
1144 1285 /**
@@ -1156,17 +1297,16 @@
1156 1297 $settings = $this->get_settings_for_display();
1157 1298 $excerpt_length = $settings['excerpt_trim'];
1158 1299
1159 1300 // Classnames but checking if we the widget is APG (legacy version)
1160 - $item_classes = $legacy ? ['ui-e-post-item', 'ui-e-item'] : ['ui-e-item'] ; // Single item lower wrap class receptor
1301 + $item_classes = $legacy ? ['ui-e-post-item', 'ui-e-item'] : ['ui-e-item']; // Single item lower wrap class receptor
1161 1302 $hover_item_class = $legacy ? 'anim_item' : 'item_hover_animation'; // item hover animation class
1162 1303
1163 1304 // If widget is not carousel type, we set animations classes directly on item selector
1164 - if(!$carousel) {
1305 + if (!$carousel) {
1165 1306 $item_classes[] = 'ui-e-animations-wrp';
1166 1307 $item_classes[] = $settings['animate_items'] === 'ui-e-grid-animate' ? 'elementor-invisible' : '';
1167 1308 $item_classes[] = $settings[$hover_item_class] !== '' ? $settings[$hover_item_class] : '';
1168 -
1169 1309 } else {
1170 1310 // Get entrance and item hover animation classes
1171 1311 $entrance = $this->is_option('animate_items', 'ui-e-grid-animate') ? 'elementor-invisible' : '';
1172 1312 $hover = isset($settings[$hover_item_class]) ? $settings[$hover_item_class] : '';
@@ -1175,59 +1315,68 @@
1175 1315 // Check if entrance or hover animation are set
1176 1316 $has_animation = !empty($entrance) || !empty($hover)
1177 1317
1178 1318 // Prints extra wrappers required by the carousel script
1179 - ?>
1319 + ?>
1180 1320 <div class="ui-e-wrp swiper-slide">
1181 - <?php if($has_animation) : ?>
1182 - <div class="ui-e-animations-wrp <?php echo esc_attr($animations);?>">
1183 - <?php endif; ?>
1321 + <?php if ($has_animation) : ?>
1322 + <div class="ui-e-animations-wrp <?php echo esc_attr($animations); ?>">
1323 + <?php endif; ?>
1184 1324
1185 - <?php } ?>
1325 + <?php } ?>
1186 1326
1187 - <div class="<?php echo esc_attr( implode(' ', $item_classes));?>">
1188 - <article <?php post_class(); ?>>
1189 - <div class="ui-e-post-top">
1190 - <?php $this->get_post_image(); ?>
1191 - <?php $this->get_post_meta('top'); ?>
1192 - </div>
1193 - <div class="ui-e-post-content">
1194 - <?php $this->get_post_meta('before_title'); ?>
1195 - <?php
1196 - if ( $this->is_option('title', 'yes') )
1197 - $this->get_post_title();
1198 - ?>
1199 - <?php $this->get_post_meta('after_title'); ?>
1200 - <?php
1201 - if ($this->get_settings_for_display('excerpt'))
1202 - echo wp_kses_post('<div class="ui-e-post-text">' . wp_trim_words(get_the_excerpt(), $excerpt_length) . '</div>');
1203 - ?>
1204 - <?php $this->get_post_meta('bottom'); // button
1205 - ?>
1206 - <?php
1207 - if ( $this->is_option('show_button', 'yes') ) {
1208 - // Add match height spacing element if carousel. May look intrusive, but is the simplest method compared
1209 - // to absolute positioning or catching last content element to apply margin.
1210 - if($carousel && $this->is_option('match_height', 'yes') ){
1211 - ?>
1327 + <div class="<?php echo esc_attr(implode(' ', $item_classes)); ?>">
1328 + <article <?php post_class(); ?>>
1329 + <div class="ui-e-post-top">
1330 + <?php $this->get_post_image(); ?>
1331 + <?php $this->get_post_meta('top'); ?>
1332 + </div>
1333 +
1334 + <?php if ($this->is_option('global_link', 'yes')) : ?>
1335 + <a href="<?php echo esc_url(get_permalink()); ?>"
1336 + class="ui-e-global-link"
1337 + aria-label="<?php echo esc_attr__('View Post:', 'uicore-elements') . esc_html(the_title_attribute(['echo' => false])); ?>"
1338 + title="<?php echo esc_attr__('View Post:', 'uicore-elements') . esc_html(the_title_attribute(['echo' => false])); ?>"> </a>
1339 + <?php endif; ?>
1340 +
1341 + <div class="ui-e-post-content">
1342 +
1343 + <?php $this->get_post_meta('before_title'); ?>
1344 + <?php
1345 + if ($this->is_option('title', 'yes'))
1346 + $this->get_post_title($settings['title_tag']);
1347 + ?>
1348 + <?php $this->get_post_meta('after_title'); ?>
1349 + <?php
1350 + if ($this->get_settings_for_display('excerpt'))
1351 + echo wp_kses_post('<div class="ui-e-post-text">' . wp_trim_words(get_the_excerpt(), $excerpt_length) . '</div>');
1352 + ?>
1353 + <?php $this->get_post_meta('bottom'); // button
1354 + ?>
1355 + <?php
1356 + if ($this->is_option('show_button', 'yes')) {
1357 + // Add match height spacing element if carousel. May look intrusive, but is the simplest method compared
1358 + // to absolute positioning or catching last content element to apply margin.
1359 + if ($carousel && $this->is_option('match_height', 'yes')) {
1360 + ?>
1212 1361 <span class="ui-e-match-height"></span>
1213 - <?php
1362 + <?php
1363 + }
1364 +
1365 + if (!isset($settings['button_position']) || empty($settings['button_position'])) {
1366 + $this->TRAIT_get_button($index);
1367 + }
1214 1368 }
1369 + ?>
1370 + </div>
1371 + </article>
1372 + </div>
1215 1373
1216 - if( !isset($settings['button_position']) || empty($settings['button_position']) ) {
1217 - $this->TRAIT_get_button($index);
1218 - }
1219 - }
1220 - ?>
1374 + <?php if ($carousel) { ?>
1221 1375 </div>
1222 - </article>
1376 + <?php if ($has_animation) : ?>
1223 1377 </div>
1378 + <?php endif; ?>
1224 1379
1225 - <?php if($carousel) { ?>
1226 - </div>
1227 - <?php if($has_animation) : ?>
1228 - </div>
1229 - <?php endif; ?>
1230 -
1231 - <?php }
1232 - }
1233 -}
1380 +<?php }
1381 + }
1382 + }