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/pagination-component.php +418 -385 1.2.11.3.17 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 namespace UiCoreElements\Utils;
3 4
4 5 use UicoreElements\Helper;
5 6
@@ -14,20 +15,14 @@
14 15 * Paginations Trait Component
15 16 *
16 17 */
17 18
18 -trait Pagination_Trait {
19 +trait Pagination_Trait
20 +{
19 21
20 - function pagination_options()
21 - {
22 - return [
23 - 'numbers' => esc_html__('Numbers', 'uicore-elements'),
24 - 'load_more' => esc_html__('Load More', 'uicore-elements'),
25 - ];
26 - }
27 22 function TRAIT_register_pagination_controls($section = true)
28 23 {
29 - if($section){
24 + if ($section) {
30 25 $this->start_controls_section(
31 26 'section_pagination',
32 27 [
33 28 'label' => esc_html__('Pagination', 'uicore-elements'),
@@ -34,38 +29,57 @@
34 29 ]
35 30 );
36 31 }
37 32
38 - $this->add_control(
39 - 'pagination',
40 - [
41 - 'label' => __( 'Pagination', 'uicore-elements' ),
42 - 'type' => Controls_Manager::SWITCHER,
43 - 'default'=> 'no',
44 - 'render_type' => 'template',
45 - ]
46 - );
47 - $this->add_control(
48 - 'pagination_type',
49 - [
50 - 'label' => esc_html__('Pagination Type', 'uicore-elements'),
51 - 'type' => Controls_Manager::SELECT,
52 - 'default' => 'numbers',
53 - 'options' => $this->pagination_options(),
54 - 'frontend_available' => true,
55 - 'condition' => [
56 - 'pagination' => 'yes',
33 + $this->add_control(
34 + 'pagination',
35 + [
36 + 'label' => __('Pagination', 'uicore-elements'),
37 + 'type' => Controls_Manager::SWITCHER,
38 + 'default' => 'no',
39 + 'render_type' => 'template',
40 + ]
41 + );
42 + $this->add_control(
43 + 'pagination_type',
44 + [
45 + 'label' => esc_html__('Pagination Type', 'uicore-elements'),
46 + 'type' => Controls_Manager::SELECT,
47 + 'default' => 'numbers',
48 + 'options' => [
49 + 'numbers' => esc_html__('Numbers', 'uicore-elements'),
50 + 'load_more' => esc_html__('Load More', 'uicore-elements'),
51 + ],
52 + 'frontend_available' => true,
53 + 'condition' => [
54 + 'pagination' => 'yes',
55 + ],
56 + ]
57 + );
58 + $this->add_control(
59 + 'load_more_qty',
60 + [
61 + 'label' => esc_html__('Posts per Load', 'uicore-elements'),
62 + 'type' => Controls_Manager::SLIDER,
63 + 'range' => [
64 + 'px' => [
65 + 'min' => -1,
66 + 'max' => 100,
57 67 ],
58 - ]
59 - );
68 + ],
69 + 'condition' => array(
70 + 'pagination_type' => 'load_more',
71 + ),
72 + ]
73 + );
60 74
61 - if($section){
75 + if ($section) {
62 76 $this->end_controls_section();
63 77 }
64 78 }
65 79 function TRAIT_register_pagination_style_controls($section = true)
66 80 {
67 - if($section){
81 + if ($section) {
68 82 $this->start_controls_section(
69 83 'section_style_pagination',
70 84 [
71 85 'label' => __('Pagination Style', 'uicore-elements'),
@@ -76,352 +90,359 @@
76 90 ]
77 91 );
78 92 }
79 93
80 - $this->add_group_control(
81 - Group_Control_Typography::get_type(),
82 - [
83 - 'name' => 'pagination_typography',
84 - 'label' => esc_html__( 'Typography', 'uicore-elements' ),
85 - 'selector' => '{{WRAPPER}} .uicore-page-item, {{WRAPPER}} .ui-e-load-more',
86 - ]
87 - );
88 - $this->add_responsive_control(
89 - 'icon_size',
90 - [
91 - 'label' => __( 'Previous/Next Icon Size', 'uicore-elements' ),
92 - 'type' => Controls_Manager::SLIDER,
93 - 'size_units' => [ 'px' ],
94 - 'range' => [
95 - 'px' => [
96 - 'min' => 0,
97 - 'max' => 30,
98 - 'step' => 1,
99 - ],
94 + $this->add_group_control(
95 + Group_Control_Typography::get_type(),
96 + [
97 + 'name' => 'pagination_typography',
98 + 'label' => esc_html__('Typography', 'uicore-elements'),
99 + 'selector' => '{{WRAPPER}} .uicore-page-item, {{WRAPPER}} .ui-e-load-more',
100 + ]
101 + );
102 + $this->add_responsive_control(
103 + 'icon_size',
104 + [
105 + 'label' => __('Previous/Next Icon Size', 'uicore-elements'),
106 + 'type' => Controls_Manager::SLIDER,
107 + 'size_units' => ['px'],
108 + 'range' => [
109 + 'px' => [
110 + 'min' => 0,
111 + 'max' => 30,
112 + 'step' => 1,
100 113 ],
101 - 'default' => [
102 - 'unit' => 'px',
103 - 'size' => 16,
104 - ],
105 - 'selectors' => [
106 - '{{WRAPPER}} .uicore-pagination a.prev svg, {{WRAPPER}} .uicore-pagination a.next svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}',
107 - '{{WRAPPER}} .uicore-pagination a.prev i, {{WRAPPER}} .uicore-pagination a.next i' => 'font-size: {{SIZE}}{{UNIT}};',
108 - ],
109 - 'condition' => [
110 - 'pagination_type' => 'numbers'
111 - ]
114 + ],
115 + 'default' => [
116 + 'unit' => 'px',
117 + 'size' => 16,
118 + ],
119 + 'selectors' => [
120 + '{{WRAPPER}} .uicore-pagination a.prev svg, {{WRAPPER}} .uicore-pagination a.next svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}',
121 + '{{WRAPPER}} .uicore-pagination a.prev i, {{WRAPPER}} .uicore-pagination a.next i' => 'font-size: {{SIZE}}{{UNIT}};',
122 + ],
123 + 'condition' => [
124 + 'pagination_type' => 'numbers'
112 125 ]
113 - );
114 - $this->add_responsive_control(
115 - 'pagination_top',
116 - [
117 - 'label' => __( 'Pagination Top Space', 'uicore-elements' ),
118 - 'type' => Controls_Manager::SLIDER,
119 - 'size_units' => [ 'px' ],
120 - 'range' => [
121 - 'px' => [
122 - 'min' => 0,
123 - 'max' => 500,
124 - 'step' => 1,
125 - ],
126 + ]
127 + );
128 + $this->add_responsive_control(
129 + 'pagination_top',
130 + [
131 + 'label' => __('Pagination Top Space', 'uicore-elements'),
132 + 'type' => Controls_Manager::SLIDER,
133 + 'size_units' => ['px'],
134 + 'range' => [
135 + 'px' => [
136 + 'min' => 0,
137 + 'max' => 500,
138 + 'step' => 1,
126 139 ],
127 - 'default' => [
128 - 'unit' => 'px',
129 - 'size' => 50,
140 + ],
141 + 'default' => [
142 + 'unit' => 'px',
143 + 'size' => 50,
144 + ],
145 + 'selectors' => [
146 + '{{WRAPPER}} .uicore-pagination' => 'margin-top: {{SIZE}}px;',
147 + '{{WRAPPER}} .ui-e-load-more' => 'margin-top: {{SIZE}}px;',
148 + ],
149 + ]
150 + );
151 + $this->add_control(
152 + 'pagination_align',
153 + [
154 + 'label' => esc_html__('Pagination Alignment', 'uicore-elements'),
155 + 'type' => Controls_Manager::CHOOSE,
156 + 'options' => [
157 + 'start' => [
158 + 'title' => esc_html__('Left', 'uicore-elements'),
159 + 'icon' => 'eicon-text-align-left',
130 160 ],
131 - 'selectors' => [
132 - '{{WRAPPER}} .uicore-pagination' => 'margin-top: {{SIZE}}px;',
133 - '{{WRAPPER}} .ui-e-load-more' => 'margin-top: {{SIZE}}px;',
161 + 'center' => [
162 + 'title' => esc_html__('Center', 'uicore-elements'),
163 + 'icon' => 'eicon-text-align-center',
134 164 ],
135 - ]
136 - );
137 - $this->add_control(
138 - 'pagination_align',
139 - [
140 - 'label' => esc_html__( 'Pagination Alignment', 'uicore-elements' ),
141 - 'type' => Controls_Manager::CHOOSE,
142 - 'options' => [
143 - 'start' => [
144 - 'title' => esc_html__( 'Left', 'uicore-elements' ),
145 - 'icon' => 'eicon-text-align-left',
146 - ],
147 - 'center' => [
148 - 'title' => esc_html__( 'Center', 'uicore-elements' ),
149 - 'icon' => 'eicon-text-align-center',
150 - ],
165 + ],
166 + 'selectors' => [
167 + '{{WRAPPER}} .uicore-pagination ul' => 'justify-content: {{VALUE}};',
168 + '{{WRAPPER}} .ui-e-pagination' => 'text-align: {{VALUE}};',
169 + ],
170 + ]
171 + );
172 + // Number Specific
173 + $this->add_control(
174 + 'pagination_padding',
175 + [
176 + 'label' => __('Items Padding', 'uicore-elements'),
177 + 'type' => Controls_Manager::SLIDER,
178 + 'size_units' => ['em'],
179 + 'range' => [
180 + 'em' => [
181 + 'min' => 0,
182 + 'max' => 3,
183 + 'step' => 0.1,
151 184 ],
152 - 'selectors' => [
153 - '{{WRAPPER}} .uicore-pagination ul' => 'justify-content: {{VALUE}};',
154 - '{{WRAPPER}} .ui-e-pagination' => 'text-align: {{VALUE}};',
185 + ],
186 + 'default' => [
187 + 'unit' => 'em',
188 + 'size' => 0.4,
189 + ],
190 + 'selectors' => [
191 + '{{WRAPPER}} .uicore-pagination ul li > *' => ' width: calc(1em + {{SIZE}}em);line-height: calc(1em + {{SIZE}}em);',
192 + ],
193 + 'condition' => array(
194 + 'pagination_type' => 'numbers',
195 + ),
196 + ]
197 + );
198 + $this->add_control(
199 + 'pagination_gap',
200 + [
201 + 'label' => __('Items Gap', 'uicore-elements'),
202 + 'type' => Controls_Manager::SLIDER,
203 + 'size_units' => ['em'],
204 + 'range' => [
205 + 'em' => [
206 + 'min' => 0,
207 + 'max' => 3,
208 + 'step' => 0.1,
155 209 ],
156 - ]
157 - );
158 - // Number Specific
159 - $this->add_control(
160 - 'pagination_padding',
161 - [
162 - 'label' => __( 'Items Padding', 'uicore-elements' ),
163 - 'type' => Controls_Manager::SLIDER,
164 - 'size_units' => [ 'em' ],
165 - 'range' => [
166 - 'em' => [
167 - 'min' => 0,
168 - 'max' => 3,
169 - 'step' => 0.1,
170 - ],
210 + ],
211 + 'default' => [
212 + 'unit' => 'em',
213 + 'size' => 0.4,
214 + ],
215 + 'selectors' => [
216 + '{{WRAPPER}} .uicore-pagination ul' => 'gap: {{SIZE}}em;',
217 + ],
218 + 'condition' => array(
219 + 'pagination_type' => 'numbers',
220 + ),
221 + ]
222 + );
223 + $this->add_control(
224 + 'pagination_radius',
225 + [
226 + 'label' => __('Items Border Radius', 'uicore-elements'),
227 + 'type' => Controls_Manager::SLIDER,
228 + 'size_units' => ['em'],
229 + 'range' => [
230 + 'em' => [
231 + 'min' => 0,
232 + 'max' => 3,
233 + 'step' => 0.1,
171 234 ],
172 - 'default' => [
173 - 'unit' => 'em',
174 - 'size' => 0.4,
175 - ],
176 - 'selectors' => [
177 - '{{WRAPPER}} .uicore-pagination ul li > *' => ' width: calc(1em + {{SIZE}}em);line-height: calc(1em + {{SIZE}}em);',
178 - ],
179 - 'condition' => array(
180 - 'pagination_type' => 'numbers',
181 - ),
235 + ],
236 + 'default' => [
237 + 'unit' => 'em',
238 + 'size' => 0.2,
239 + ],
240 + 'selectors' => [
241 + '{{WRAPPER}} .uicore-pagination ul li' => 'border-radius: {{SIZE}}em;',
242 + ],
243 + 'condition' => array(
244 + 'pagination_type' => 'numbers',
245 + ),
246 + ]
247 + );
248 + // Load More Specific
249 + $this->add_control(
250 + 'load_more_padding',
251 + [
252 + 'label' => esc_html__('Button Padding', 'uicore-elements'),
253 + 'type' => Controls_Manager::DIMENSIONS,
254 + 'size_units' => ['px', '%', 'em'],
255 + 'selectors' => [
256 + '{{WRAPPER}} .ui-e-load-more' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
257 + ],
258 + 'condition' => array(
259 + 'pagination_type' => 'load_more'
260 + ),
261 + ]
262 + );
263 + $this->add_control(
264 + 'load_more_radius',
265 + [
266 + 'label' => esc_html__('Button Radius', 'uicore-elements'),
267 + 'type' => Controls_Manager::DIMENSIONS,
268 + 'size_units' => ['px', '%', 'em'],
269 + 'selectors' => [
270 + '{{WRAPPER}} .ui-e-load-more' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
271 + ],
272 + 'condition' => array(
273 + 'pagination_type' => 'load_more'
274 + ),
275 + ]
276 + );
277 + // General Again
278 + $this->start_controls_tabs(
279 + 'pagination_item',
280 + [
281 + 'condition' => [
282 + 'pagination' => 'yes',
283 + ],
284 + ]
285 + );
286 + $this->start_controls_tab(
287 + 'pagination_normal_tab',
288 + [
289 + 'label' => esc_html__('Normal', 'uicore-elements'),
290 + ]
291 + );
292 + $this->add_control(
293 + 'pagination_bg',
294 + [
295 + 'label' => esc_html__('Background', 'uicore-elements'),
296 + 'type' => Controls_Manager::COLOR,
297 + 'default' => '',
298 + 'selectors' => [
299 + '{{WRAPPER}} .uicore-pagination li' => 'background: {{VALUE}};',
300 + '{{WRAPPER}} .ui-e-load-more' => 'background: {{VALUE}};',
301 + ],
302 + ]
303 + );
304 + $this->add_control(
305 + 'pagination_color',
306 + [
307 + 'label' => esc_html__('Color', 'uicore-elements'),
308 + 'type' => Controls_Manager::COLOR,
309 + 'default' => '',
310 + 'selectors' => [
311 + '{{WRAPPER}} .uicore-pagination li a' => 'color: {{VALUE}};',
312 + '{{WRAPPER}} .uicore-pagination svg' => 'fill: {{VALUE}};',
313 + '{{WRAPPER}} .ui-e-load-more' => 'color: {{VALUE}};',
314 + ],
315 + ]
316 + );
317 + $this->add_group_control(
318 + Group_Control_Border::get_type(),
319 + [
320 + 'name' => 'pagination_border',
321 + 'selector' => '{{WRAPPER}} .uicore-pagination ul li, {{WRAPPER}} .ui-e-load-more',
322 + 'separator' => 'before',
323 + ]
324 + );
325 + $this->add_group_control(
326 + Group_Control_Box_Shadow::get_type(),
327 + [
328 + 'name' => 'pagination_shadow',
329 + 'selector' => '{{WRAPPER}} .uicore-pagination ul li, {{WRAPPER}} .ui-e-load-more',
330 + ]
331 + );
332 + $this->end_controls_tab();
333 +
334 + $this->start_controls_tab(
335 + 'pagination_hover_tab',
336 + [
337 + 'label' => esc_html__('Hover', 'uicore-elements'),
338 + ]
339 + );
340 + $this->add_control(
341 + 'pagination_hover_bg',
342 + [
343 + 'label' => esc_html__('Background', 'uicore-elements'),
344 + 'type' => Controls_Manager::COLOR,
345 + 'default' => '',
346 + 'selectors' => [
347 + '{{WRAPPER}} .uicore-pagination ul li:hover:not(.uicore-active)' => 'background: {{VALUE}};',
348 + '{{WRAPPER}} .ui-e-load-more:hover' => 'background: {{VALUE}};',
349 + ],
350 + ]
351 + );
352 + $this->add_control(
353 + 'pagination_hover_color',
354 + [
355 + 'label' => esc_html__('Color', 'uicore-elements'),
356 + 'type' => Controls_Manager::COLOR,
357 + 'default' => '',
358 + 'selectors' => [
359 + '{{WRAPPER}} .uicore-pagination li:hover:not(.uicore-active) a' => 'color: {{VALUE}};',
360 + '{{WRAPPER}} .uicore-pagination li:hover:not(.uicore-active) svg' => 'fill: {{VALUE}};',
361 + '{{WRAPPER}} .ui-e-load-more:hover' => 'color: {{VALUE}};',
362 + ],
363 + ]
364 + );
365 + $this->add_group_control(
366 + Group_Control_Border::get_type(),
367 + [
368 + 'name' => 'pagination_border_hover',
369 + 'selector' => '{{WRAPPER}} .uicore-pagination ul li:hover:not(.uicore-active), {{WRAPPER}} .ui-e-load-more:hover',
370 + 'separator' => 'before',
371 + ]
372 + );
373 + $this->add_group_control(
374 + Group_Control_Box_Shadow::get_type(),
375 + [
376 + 'name' => 'pagination_shadow_hover',
377 + 'selector' => '{{WRAPPER}} .uicore-pagination ul li:hover:not(.uicore-active), {{WRAPPER}} .ui-e-load-more:hover',
378 + ]
379 + );
380 + $this->end_controls_tab();
381 + // Number specific
382 + $this->start_controls_tab(
383 + 'pagination_active_tab',
384 + [
385 + 'label' => esc_html__('Active', 'uicore-elements'),
386 + 'condition' => [
387 + 'pagination_type' => 'numbers',
182 388 ]
183 - );
184 - $this->add_control(
185 - 'pagination_gap',
186 - [
187 - 'label' => __( 'Items Gap', 'uicore-elements' ),
188 - 'type' => Controls_Manager::SLIDER,
189 - 'size_units' => [ 'em' ],
190 - 'range' => [
191 - 'em' => [
192 - 'min' => 0,
193 - 'max' => 3,
194 - 'step' => 0.1,
195 - ],
196 - ],
197 - 'default' => [
198 - 'unit' => 'em',
199 - 'size' => 0.4,
200 - ],
201 - 'selectors' => [
202 - '{{WRAPPER}} .uicore-pagination ul' => 'gap: {{SIZE}}em;',
203 - ],
204 - 'condition' => array(
205 - 'pagination_type' => 'numbers',
206 - ),
389 + ]
390 + );
391 + $this->add_control(
392 + 'pagination_active_bg',
393 + [
394 + 'label' => esc_html__('Background', 'uicore-elements'),
395 + 'type' => Controls_Manager::COLOR,
396 + 'default' => '',
397 + 'selectors' => [
398 + '{{WRAPPER}} .uicore-page-link.current' => 'background: {{VALUE}};',
399 + ],
400 + 'condition' => [
401 + 'pagination_type' => 'numbers',
207 402 ]
208 - );
209 - $this->add_control(
210 - 'pagination_radius',
211 - [
212 - 'label' => __( 'Items Border Radius', 'uicore-elements' ),
213 - 'type' => Controls_Manager::SLIDER,
214 - 'size_units' => [ 'em' ],
215 - 'range' => [
216 - 'em' => [
217 - 'min' => 0,
218 - 'max' => 3,
219 - 'step' => 0.1,
220 - ],
221 - ],
222 - 'default' => [
223 - 'unit' => 'em',
224 - 'size' => 0.2,
225 - ],
226 - 'selectors' => [
227 - '{{WRAPPER}} .uicore-pagination ul li' => 'border-radius: {{SIZE}}em;',
228 - ],
229 - 'condition' => array(
230 - 'pagination_type' => 'numbers',
231 - ),
403 + ]
404 + );
405 + $this->add_control(
406 + 'pagination_active_color',
407 + [
408 + 'label' => esc_html__('Color', 'uicore-elements'),
409 + 'type' => Controls_Manager::COLOR,
410 + 'default' => '',
411 + 'selectors' => [
412 + '{{WRAPPER}} .uicore-page-link.current' => 'color: {{VALUE}};',
413 + ],
414 + 'condition' => [
415 + 'pagination_type' => 'numbers',
232 416 ]
233 - );
234 - // Load More Specific
235 - $this->add_control(
236 - 'load_more_padding',
237 - [
238 - 'label' => esc_html__( 'Button Padding', 'uicore-elements' ),
239 - 'type' => Controls_Manager::DIMENSIONS,
240 - 'size_units' => [ 'px', '%', 'em'],
241 - 'selectors' => [
242 - '{{WRAPPER}} .ui-e-load-more' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
243 - ],
244 - 'condition' => array(
245 - 'pagination_type' => 'load_more'
246 - ),
417 + ]
418 + );
419 + $this->add_group_control(
420 + Group_Control_Border::get_type(),
421 + [
422 + 'name' => 'pagination_border_active',
423 + 'selector' => '{{WRAPPER}} .uicore-pagination li.uicore-active',
424 + 'separator' => 'before',
425 + 'condition' => [
426 + 'pagination_type' => 'numbers',
247 427 ]
248 - );
249 - $this->add_control(
250 - 'load_more_radius',
251 - [
252 - 'label' => esc_html__( 'Button Radius', 'uicore-elements' ),
253 - 'type' => Controls_Manager::DIMENSIONS,
254 - 'size_units' => [ 'px', '%', 'em'],
255 - 'selectors' => [
256 - '{{WRAPPER}} .ui-e-load-more' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
257 - ],
258 - 'condition' => array(
259 - 'pagination_type' => 'load_more'
260 - ),
428 + ]
429 + );
430 + $this->add_group_control(
431 + Group_Control_Box_Shadow::get_type(),
432 + [
433 + 'name' => 'pagination_shadow_active',
434 + 'selector' => '{{WRAPPER}} .uicore-pagination li.uicore-active',
435 + 'condition' => [
436 + 'pagination_type' => 'numbers',
261 437 ]
262 - );
263 - // General Again
264 - $this->start_controls_tabs(
265 - 'pagination_item', [
266 - 'condition' => [
267 - 'pagination' => 'yes',
268 - ],
269 - ]
270 - );
271 - $this->start_controls_tab(
272 - 'pagination_normal_tab',
273 - [
274 - 'label' => esc_html__( 'Normal', 'uicore-elements' ),
275 - ]
276 - );
277 - $this->add_control(
278 - 'pagination_bg',
279 - [
280 - 'label' => esc_html__( 'Background', 'uicore-elements' ),
281 - 'type' => Controls_Manager::COLOR,
282 - 'default' => '',
283 - 'selectors' => [
284 - '{{WRAPPER}} .uicore-pagination li' => 'background: {{VALUE}};',
285 - '{{WRAPPER}} .ui-e-load-more' => 'background: {{VALUE}};',
286 - ],
287 - ]
288 - );
289 - $this->add_control(
290 - 'pagination_color',
291 - [
292 - 'label' => esc_html__( 'Color', 'uicore-elements' ),
293 - 'type' => Controls_Manager::COLOR,
294 - 'default' => '',
295 - 'selectors' => [
296 - '{{WRAPPER}} .uicore-pagination li a' => 'color: {{VALUE}};',
297 - '{{WRAPPER}} .uicore-pagination svg' => 'fill: {{VALUE}};',
298 - '{{WRAPPER}} .ui-e-load-more' => 'color: {{VALUE}};',
299 - ],
300 - ]
301 - );
302 - $this->add_group_control(
303 - Group_Control_Border::get_type(),
304 - [
305 - 'name' => 'pagination_border',
306 - 'selector' => '{{WRAPPER}} .uicore-pagination ul li, {{WRAPPER}} .ui-e-load-more',
307 - 'separator' => 'before',
308 - ]
309 - );
310 - $this->add_group_control(
311 - Group_Control_Box_Shadow::get_type(),
312 - [
313 - 'name' => 'pagination_shadow',
314 - 'selector' => '{{WRAPPER}} .uicore-pagination ul li, {{WRAPPER}} .ui-e-load-more',
315 - ]
316 - );
317 - $this->end_controls_tab();
438 + ]
439 + );
440 + $this->end_controls_tab();
318 441
319 - $this->start_controls_tab(
320 - 'pagination_hover_tab',
321 - [
322 - 'label' => esc_html__( 'Hover', 'uicore-elements' ),
323 - ]
324 - );
325 - $this->add_control(
326 - 'pagination_hover_bg',
327 - [
328 - 'label' => esc_html__( 'Background', 'uicore-elements' ),
329 - 'type' => Controls_Manager::COLOR,
330 - 'default' => '',
331 - 'selectors' => [
332 - '{{WRAPPER}} .uicore-pagination ul li:hover:not(.uicore-active)' => 'background: {{VALUE}};',
333 - '{{WRAPPER}} .ui-e-load-more:hover' => 'background: {{VALUE}};',
334 - ],
335 - ]
336 - );
337 - $this->add_control('pagination_hover_color', [
338 - 'label' => esc_html__( 'Color', 'uicore-elements' ),
339 - 'type' => Controls_Manager::COLOR,
340 - 'default' => '',
341 - 'selectors' => [
342 - '{{WRAPPER}} .uicore-pagination li:hover:not(.uicore-active) a' => 'color: {{VALUE}};',
343 - '{{WRAPPER}} .uicore-pagination li:hover:not(.uicore-active) svg' => 'fill: {{VALUE}};',
344 - '{{WRAPPER}} .ui-e-load-more:hover' => 'color: {{VALUE}};',
345 - ],
346 - ]
347 - );
348 - $this->add_group_control(
349 - Group_Control_Border::get_type(),
350 - [
351 - 'name' => 'pagination_border_hover',
352 - 'selector' => '{{WRAPPER}} .uicore-pagination ul li:hover:not(.uicore-active), {{WRAPPER}} .ui-e-load-more:hover',
353 - 'separator' => 'before',
354 - ]
355 - );
356 - $this->add_group_control(
357 - Group_Control_Box_Shadow::get_type(),
358 - [
359 - 'name' => 'pagination_shadow_hover',
360 - 'selector' => '{{WRAPPER}} .uicore-pagination ul li:hover:not(.uicore-active), {{WRAPPER}} .ui-e-load-more:hover',
361 - ]
362 - );
363 - $this->end_controls_tab();
364 - // Number specific
365 - $this->start_controls_tab(
366 - 'pagination_active_tab',
367 - [
368 - 'label' => esc_html__( 'Active', 'uicore-elements' ),
369 - 'condition' => [
370 - 'pagination_type' => 'numbers',
371 - ]
372 - ]
373 - );
374 - $this->add_control('pagination_active_bg', [
375 - 'label' => esc_html__( 'Background', 'uicore-elements' ),
376 - 'type' => Controls_Manager::COLOR,
377 - 'default' => '',
378 - 'selectors' => [
379 - '{{WRAPPER}} .uicore-page-link.current' => 'background: {{VALUE}};',
380 - ],
381 - 'condition' => [
382 - 'pagination_type' => 'numbers',
383 - ]
384 - ]
385 - );
386 - $this->add_control('pagination_active_color', [
387 - 'label' => esc_html__( 'Color', 'uicore-elements' ),
388 - 'type' => Controls_Manager::COLOR,
389 - 'default' => '',
390 - 'selectors' => [
391 - '{{WRAPPER}} .uicore-page-link.current' => 'color: {{VALUE}};',
392 - ],
393 - 'condition' => [
394 - 'pagination_type' => 'numbers',
395 - ]
396 - ]
397 - );
398 - $this->add_group_control(
399 - Group_Control_Border::get_type(),
400 - [
401 - 'name' => 'pagination_border_active',
402 - 'selector' => '{{WRAPPER}} .uicore-pagination li.uicore-active',
403 - 'separator' => 'before',
404 - 'condition' => [
405 - 'pagination_type' => 'numbers',
406 - ]
407 - ]
408 - );
409 - $this->add_group_control(
410 - Group_Control_Box_Shadow::get_type(),
411 - [
412 - 'name' => 'pagination_shadow_active',
413 - 'selector' => '{{WRAPPER}} .uicore-pagination li.uicore-active',
414 - 'condition' => [
415 - 'pagination_type' => 'numbers',
416 - ]
417 - ]
418 - );
419 - $this->end_controls_tab();
442 + $this->end_controls_tabs();
420 443
421 - $this->end_controls_tabs();
422 -
423 - if($section){
444 + if ($section) {
424 445 $this->end_controls_section();
425 446 }
426 447 }
427 448
@@ -435,16 +456,20 @@
435 456 */
436 457 function render_numbers($is_product, $args = [])
437 458 {
438 459
439 - if ( $is_product ){
460 + if ($is_product) {
440 461 $query = $this->get_query();
441 462
463 + // Currently we alow users to use number pagination in contexts that shouldn't be used. E.g: in related posts on single product pages
464 + if (!isset($query)) {
465 + return;
466 + }
467 +
442 468 $total_items = Helper::get_framework_visible_posts('product');
443 - $total_count = wc_get_products( array_merge($query, ['limit' => -1, 'return' => 'ids']) ); // Fetch all products - TODO: -1 is very bad for performance
444 - $total = ceil( count($total_count) / $total_items );
469 + $total_count = wc_get_products(array_merge($query, ['limit' => -1, 'return' => 'ids'])); // Fetch all products - TODO: -1 is very bad for performance
470 + $total = ceil(count($total_count) / $total_items);
445 471 $current_page = max(1, get_query_var('paged'));
446 -
447 472 } else {
448 473 global $query;
449 474 }
450 475
@@ -460,11 +485,11 @@
460 485 ]);
461 486
462 487
463 488 // Build woo pagination args
464 - if ( $is_product ) {
489 + if ($is_product) {
465 490
466 - if ( $total && $total <= 1 ) {
491 + if ($total && $total <= 1) {
467 492 return;
468 493 }
469 494
470 495 $args = apply_filters('woocommerce_pagination_args', [
@@ -473,15 +498,15 @@
473 498 'total' => $total,
474 499 'prev_text' => '',
475 500 'next_text' => '',
476 501 'type' => 'array',
477 - 'base' => esc_url_raw( add_query_arg( 'product-page', '%#%', false ) ),
502 + 'base' => esc_url_raw(add_query_arg('product-page', '%#%', false)),
478 503 'screen_reader_text' => _x('Products navigation', 'Frontend - Pagination', 'uicore-elements'),
479 504 ]);
480 505
481 - if ( ! wc_get_loop_prop( 'is_shortcode' ) ) {
506 + if (! wc_get_loop_prop('is_shortcode')) {
482 507 $args['format'] = '';
483 - $args['base'] = esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) );
508 + $args['base'] = esc_url_raw(str_replace(999999999, '%#%', remove_query_arg('add-to-cart', get_pagenum_link(999999999, false))));
484 509 }
485 510 }
486 511
487 512 $links = paginate_links($args);
@@ -488,39 +513,47 @@
488 513 $class = 'uicore-pagination';
489 514 $class .= !defined('UICORE_ASSETS') ? ' ui-e-pagination' : '';
490 515
491 516 if (is_array($links) || is_object($links)) { ?>
492 - <nav aria-label="<?php echo esc_attr($args['screen_reader_text']); ?>" class="<?php echo esc_attr($class);?>">
517 + <nav aria-label="<?php echo esc_attr($args['screen_reader_text']); ?>" class="<?php echo esc_attr($class); ?>">
493 518 <ul>
494 519 <?php foreach ($links as $key => $link) :
495 520 // If next/prev buttons and Uicore Framework is not active, get arrow icon and append it
496 - if ( (strpos($link, 'prev') || strpos($link, 'next')) && !defined('UICORE_ASSETS') ) {
521 + if ((strpos($link, 'prev') || strpos($link, 'next')) && !defined('UICORE_ASSETS')) {
497 522 $svg = \file_get_contents(UICORE_ELEMENTS_ASSETS . '/media/svg/pagination-icon.svg');
498 523 $link = str_replace('</a>', $svg . '</a>', $link);
499 524 }
500 - ?>
525 + ?>
501 526 <li class="uicore-page-item <?php echo strpos($link, 'current') ? 'uicore-active' : ''; ?>">
502 - <?php echo wp_kses_post( str_replace('page-numbers', 'uicore-page-link', $link)); ?>
527 + <?php echo wp_kses_post(str_replace('page-numbers', 'uicore-page-link', $link)); ?>
503 528 </li>
504 529 <?php endforeach; ?>
505 530 </ul>
506 531 </nav>
507 - <?php }
532 + <?php }
508 533 }
509 - function render_load_more()
534 + function render_load_more($postID)
510 535 {
511 - // No logic here. It's handled by ajax-request script and rest-api endpoint
536 + // Script may get the current page ID to set as exclusion list on related posts query
512 537 ?>
513 - <nav aria-label="Posts navigation" class="ui-e-pagination">
514 - <button class="ui-e-load-more elementor-button">Load more</button>
515 - </nav>
516 - <?php
538 + <nav data-ui-e-current-page="<?php echo esc_attr($postID); ?>" aria-label="Posts navigation" class="ui-e-pagination">
539 + <button class="ui-e-load-more elementor-button">Load more</button>
540 + </nav>
541 +<?php
517 542 }
518 - function TRAIT_render_pagination($settings, $is_product = false)
543 +
544 + /**
545 + * Render pagination for post/product widgets
546 + *
547 + * @param array $settings - The settings of the widget
548 + * @param int $postID - The ID of the post or product
549 + * @param bool $is_product - Whether the pagination is for products. Default is false.
550 + */
551 + function TRAIT_render_pagination($settings, $postID, $is_product = false)
519 552 {
520 - if( $settings['pagination'] === 'yes'){
521 - if( $settings['pagination_type'] === 'load_more'){
522 - $this->render_load_more();
553 + if ($this->is_option('pagination', 'yes')) {
554 + if ($this->is_option('pagination_type', 'load_more')) {
555 + $this->render_load_more($postID);
523 556 } else {
524 557 $this->render_numbers($is_product);
525 558 }
526 559 }