PluginProbe ʕ •ᴥ•ʔ
ECS – Ele Custom Skin for Elementor / 4.3.6
ECS – Ele Custom Skin for Elementor v4.3.6
4.3.6 4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.11 4.1.10 4.1.9 4.1.8 4.1.6 4.1.7 4.1.5 4.1.4 4.1.1 4.1.2 trunk 1.0.0 1.0.1 1.0.9 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.4 1.2.5 1.3.10 1.3.11 1.3.3 1.3.4 1.3.6 1.3.7 1.3.9 1.4.0 2.0.2 2.1.0 2.2.0 2.2.1 2.2.2 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 4.1.0
ele-custom-skin / includes / ajax-pagination.php
ele-custom-skin / includes Last commit date
admin-bar-menu.php 3 years ago ajax-pagination.php 2 years ago class-ecs-core.php 2 months ago class-ecs-module-base.php 1 month ago class-ecs-modules-manager.php 2 months ago dynamic-style.php 3 years ago ecs-dependencies.php 6 years ago ecs-notices.php 6 years ago enqueue-styles.php 2 years ago pro-features.php 2 months ago pro-preview.php 6 years ago
ajax-pagination.php
545 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4 class ECS_Ajax_Load {
5 private $post_id='';
6 private $current_page=1;
7 private $widget_id='';
8 private $theme_id='';
9 private $query=[];
10
11 public function __construct($args=[]) {//["post_id"=>2,"current_page"=>2,"max_num_pages"=>5,"widget_id"=>"65054a0"]
12
13 $this->init();
14
15 if (!isset($args['post_id']))//debug line comment it
16 if(!isset($_POST['ecs_ajax_settings'])) return;
17 else $args = json_decode( stripslashes( $_POST['ecs_ajax_settings'] ), true );
18
19 $this->post_id = $args['post_id'];
20 $this->current_page = $args['current_page'] + 1;
21 $this->widget_id = $args['widget_id'];
22 $this->theme_id = isset($args['theme_id']) ? $args['theme_id'] : $args['post_id'];
23 $this->query = json_decode( stripslashes( $_POST['query'] ), true );
24 if ($this->current_page > $args['max_num_pages']) return;
25 $this->init_ajax();
26
27 }
28
29 public function init() {
30 add_action( 'wp_enqueue_scripts', [$this,'enqueue_scripts'] ,99);
31 add_action( 'elementor/element/before_section_end', [$this,'post_pagination'],10,3);
32 add_action( 'elementor/element/after_section_end', [$this,'button_pagination_style'],10,3);
33 }
34
35 public function init_ajax(){
36 //add_action( 'wp_footer',[$this,'get_document_data'],99);// debug line comment it
37 add_action( 'wp_ajax_ecsload', [$this,'get_document_data']);
38 add_action( 'wp_ajax_nopriv_ecsload', [$this,'get_document_data']);
39 }
40
41 public function post_pagination($element, $section_id='', $args=''){
42
43 if ( ( 'archive-posts' === $element->get_name() || 'posts' === $element->get_name() ) && 'section_pagination' === $section_id ) {
44
45 $element->remove_control( 'pagination_type' );
46
47 $element->add_control(
48 'pagination_type',
49 [
50 'label' => __( 'Pagination', 'ele-custom-skin' ),
51 'type' => \Elementor\Controls_Manager::SELECT,
52 'default' => '',
53 'options' => [
54 '' => __( 'None', 'elementor-pro' ),
55 'numbers' => __( 'Numbers', 'elementor-pro' ),
56 'loadmore' => __( 'Load More (Custom Skin)', 'ele-custom-skin' ),
57 'lazyload' => __( 'Infinite Load (Custom Skin Pro)', 'ele-custom-skin' ),
58 'prev_next' => __( 'Previous/Next', 'elementor-pro' ),
59 'numbers_and_prev_next' => __( 'Numbers', 'elementor-pro' ) . ' + ' . __( 'Previous/Next', 'elementor-pro' ),
60 ],
61 ]
62 );
63 /* lazyload stuff*/
64 $element->add_control(
65 'lazyload_title',
66 [
67 'label' => __( 'Infinite Load', 'ele-custom-skin' ),
68 'type' => \Elementor\Controls_Manager::HEADING,
69 'separator' => 'before',
70 'condition' => [
71 'pagination_type' => 'lazyload',
72 ],
73 ]
74 );
75
76 $element->add_control(
77 'lazyload_animation',
78 [
79 'label' => __( 'Loading Animation', 'ele-custom-skin' ),
80 'type' => \Elementor\Controls_Manager::SELECT,
81 'default' => 'default',
82 'options' => ECS_Loading_Animation::get_lazy_load_animations_list(),
83 'condition' => [
84 'pagination_type' => 'lazyload',
85 ],
86 ]
87 );
88 $element->add_control(
89 'lazyload_color',
90 [
91 'label' => __( 'Animation Color', 'ele-custom-skin' ),
92 'type' => \Elementor\Controls_Manager::COLOR,
93 'selectors' => [
94 '{{WRAPPER}} .ecs-lazyload .ecs-ll-brcolor' => 'border-color: {{VALUE}};',
95 '{{WRAPPER}} .ecs-lazyload .ecs-ll-bgcolor' => 'background-color: {{VALUE}} !important;',
96 ],
97 'condition' => [
98 'pagination_type' => 'lazyload',
99 ],
100 ]
101 );
102
103 $element->add_control(
104 'lazyload_spacing',
105 [
106 'label' => __( 'Animation Spacing', 'ele-custom-skin' ),
107 'type' => \Elementor\Controls_Manager::SLIDER,
108 'range' => [
109 'px' => [
110 'max' => 250,
111 ],
112 ],
113 'default' =>[
114 'unit' => 'px',
115 'size' => '20',
116 ],
117 'selectors' => [
118 '{{WRAPPER}} .ecs-lazyload' => 'margin-top: {{SIZE}}{{UNIT}};',
119 ],
120 'condition' => [
121 'pagination_type' => 'lazyload',
122 ],
123 ]
124 );
125 $element->add_control(
126 'lazyload_size',
127 [
128 'label' => __( 'Animation Size', 'ele-custom-skin' ),
129 'type' => \Elementor\Controls_Manager::SLIDER,
130 'range' => [
131 'px' => [
132 'max' => 50,
133 ],
134 ],
135 'selectors' => [
136 '{{WRAPPER}} .ecs-lazyload .ecs-lazy-load-animation' => 'font-size: {{SIZE}}{{UNIT}};',
137 ],
138 'condition' => [
139 'pagination_type' => 'lazyload',
140 ],
141 ]
142 );
143
144
145 /* load more button stuff */
146
147 $element->add_control(
148 'loadmore_title',
149 [
150 'label' => __( 'Load More Button', 'ele-custom-skin' ),
151 'type' => \Elementor\Controls_Manager::HEADING,
152 'separator' => 'before',
153 'condition' => [
154 'pagination_type' => 'loadmore',
155 ],
156 ]
157 );
158
159 $element->add_control(
160 'loadmore_text',
161 [
162 'label' => __( 'Text', 'ele-custom-skin' ),
163 'type' => \Elementor\Controls_Manager::TEXT,
164 'default' => __( 'Load More', 'elementor' ),
165 'placeholder' => __( 'Load More', 'elementor' ),
166 'condition' => [
167 'pagination_type' => 'loadmore',
168 ],
169 ]
170 );
171
172 $element->add_control(
173 'loadmore_loading_text',
174 [
175 'label' => __( 'Loading Text', 'ele-custom-skin' ),
176 'type' => \Elementor\Controls_Manager::TEXT,
177 'default' => __( 'Loading...', 'elementor' ),
178 'placeholder' => __( 'Loading...', 'elementor' ),
179 'condition' => [
180 'pagination_type' => 'loadmore',
181 ],
182 ]
183 );
184
185 $element->add_control(
186 'loadmore_spacing',
187 [
188 'label' => __( 'Button Spacing', 'ele-custom-skin' ),
189 'type' => \Elementor\Controls_Manager::SLIDER,
190 'range' => [
191 'px' => [
192 'max' => 250,
193 ],
194 ],
195 'default' =>[
196 'unit' => 'px',
197 'size' => '20',
198 ],
199 'selectors' => [
200 '{{WRAPPER}} .ecs-load-more-button .elementor-button' => 'margin-top: {{SIZE}}{{UNIT}};',
201 ],
202 'condition' => [
203 'pagination_type' => 'loadmore',
204 ],
205 ]
206 );
207 $element->add_control(
208 'change_url',
209 [
210 'label' => __( 'Change URL on ajax load?', 'ele-custom-skin' ),
211 'type' => \Elementor\Controls_Manager::SWITCHER,
212 'label_off' => __( 'No', 'ele-custom-skin' ),
213 'label_on' => __( 'Yes', 'ele-custom-skin' ),
214 'return_value' => true,
215 'separator' => 'before',
216 'default' => false,
217 ]
218 );
219
220 $element->add_control(
221 'reinit_js',
222 [
223 'label' => __( 'Reinitialize Elementor JS on Ajax Pagination?', 'ele-custom-skin' ),
224 'description' => __( 'This is used for the elements loaded through AJAX Pagination. This is experimental feature and it may not work properly.', 'ele-custom-skin'),
225 'type' => \Elementor\Controls_Manager::SWITCHER,
226 'label_off' => __( 'No', 'ele-custom-skin' ),
227 'label_on' => __( 'Yes', 'ele-custom-skin' ),
228 'return_value' => true,
229 'separator' => 'before',
230 'default' => false,
231 ]
232 );
233
234
235 }
236 }
237
238 public function button_pagination_style($element, $section_id='', $args=''){
239
240 if ( ( 'archive-posts' === $element->get_name() || 'posts' === $element->get_name() ) && 'section_pagination_style' === $section_id ) {
241
242 $element->start_controls_section(
243 'loadmore_section_style',
244 [
245 'label' => __( 'Load More Button', 'ele-custom-skin' ),
246 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
247 'condition' => [
248 'pagination_type' => 'loadmore',
249 ],
250 ]
251 );
252
253 $element->add_group_control(
254 \Elementor\Group_Control_Typography::get_type(),
255 [
256 'name' => 'loadmore_typography',
257 'global' => [
258 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_ACCENT,
259 ],
260 'selector' => '{{WRAPPER}} .ecs-load-more-button .elementor-button',
261 ]
262 );
263
264 $element->add_group_control(
265 \Elementor\Group_Control_Text_Shadow::get_type(),
266 [
267 'name' => 'loadmore_text_shadow',
268 'selector' => '{{WRAPPER}} .ecs-load-more-button .elementor-button',
269 ]
270 );
271
272 $element->start_controls_tabs( 'ecs_load_more_tabs_button_style' );
273
274 $element->start_controls_tab(
275 'loadmore_tab_button_normal',
276 [
277 'label' => __( 'Normal', 'ele-custom-skin' ),
278 ]
279 );
280
281 $element->add_control(
282 'loadmore_button_text_color',
283 [
284 'label' => __( 'Text Color', 'ele-custom-skin' ),
285 'type' => \Elementor\Controls_Manager::COLOR,
286 'default' => '',
287 'selectors' => [
288 '{{WRAPPER}} .ecs-load-more-button .elementor-button' => 'fill: {{VALUE}}; color: {{VALUE}};',
289 ],
290 ]
291 );
292
293 $element->add_control(
294 'loadmore_background_color',
295 [
296 'label' => __( 'Background Color', 'ele-custom-skin' ),
297 'type' => \Elementor\Controls_Manager::COLOR,
298 'global' => [
299 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_ACCENT,
300 ],
301 'selectors' => [
302 '{{WRAPPER}} .ecs-load-more-button .elementor-button' => 'background-color: {{VALUE}};',
303 ],
304 ]
305 );
306
307 $element->end_controls_tab();
308
309 $element->start_controls_tab(
310 'loadmore_tab_button_hover',
311 [
312 'label' => __( 'Hover', 'ele-custom-skin' ),
313 ]
314 );
315
316 $element->add_control(
317 'loadmore_hover_color',
318 [
319 'label' => __( 'Text Color', 'ele-custom-skin' ),
320 'type' => \Elementor\Controls_Manager::COLOR,
321 'selectors' => [
322 '{{WRAPPER}} .ecs-load-more-button .elementor-button:hover, {{WRAPPER}} .ecs-load-more-button .elementor-button:focus' => 'color: {{VALUE}};',
323 '{{WRAPPER}} .ecs-load-more-button .elementor-button:hover svg, {{WRAPPER}} .ecs-load-more-button .elementor-button:focus svg' => 'fill: {{VALUE}};',
324 ],
325 ]
326 );
327
328 $element->add_control(
329 'loadmore_button_background_hover_color',
330 [
331 'label' => __( 'Background Color', 'ele-custom-skin' ),
332 'type' => \Elementor\Controls_Manager::COLOR,
333 'selectors' => [
334 '{{WRAPPER}} .ecs-load-more-button .elementor-button:hover, {{WRAPPER}} .elementor-button:focus' => 'background-color: {{VALUE}};',
335 ],
336 ]
337 );
338
339 $element->add_control(
340 'loadmore_button_hover_border_color',
341 [
342 'label' => __( 'Border Color', 'ele-custom-skin' ),
343 'type' => \Elementor\Controls_Manager::COLOR,
344 'condition' => [
345 'border_border!' => '',
346 ],
347 'selectors' => [
348 '{{WRAPPER}} .ecs-load-more-button .elementor-button:hover, {{WRAPPER}} .elementor-button:focus' => 'border-color: {{VALUE}};',
349 ],
350 ]
351 );
352
353 $element->add_control(
354 'loadmore_hover_animation',
355 [
356 'label' => __( 'Hover Animation', 'ele-custom-skin' ),
357 'type' => \Elementor\Controls_Manager::HOVER_ANIMATION,
358 ]
359 );
360
361 $element->end_controls_tab();
362
363 $element->end_controls_tabs();
364
365 $element->add_group_control(
366 \Elementor\Group_Control_Border::get_type(),
367 [
368 'name' => 'loadmore_border',
369 'selector' => '{{WRAPPER}} .elementor-button',
370 'separator' => 'before',
371 ]
372 );
373
374 $element->add_control(
375 'loadmore_border_radius',
376 [
377 'label' => __( 'Border Radius', 'ele-custom-skin' ),
378 'type' => \Elementor\Controls_Manager::DIMENSIONS,
379 'size_units' => [ 'px', '%' ],
380 'selectors' => [
381 '{{WRAPPER}} .ecs-load-more-button .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
382 ],
383 ]
384 );
385
386 $element->add_group_control(
387 \Elementor\Group_Control_Box_Shadow::get_type(),
388 [
389 'name' => 'loadmore_button_box_shadow',
390 'selector' => '{{WRAPPER}} .ecs-load-more-button .elementor-button',
391 ]
392 );
393
394 $element->add_responsive_control(
395 'loadmore_text_padding',
396 [
397 'label' => __( 'Padding', 'ele-custom-skin' ),
398 'type' => \Elementor\Controls_Manager::DIMENSIONS,
399 'size_units' => [ 'px', 'em', '%' ],
400 'selectors' => [
401 '{{WRAPPER}} .ecs-load-more-button .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
402 ],
403 'separator' => 'before',
404 ]
405 );
406 $element->end_controls_section();
407 }
408 }
409
410 private function get_element_data($id,$data){
411
412 foreach($data as $element){
413 //echo "[".$element['id']."] == (".$id.")";
414 if (isset($element['id']) && $element['id'] == $id) {
415 return $element;
416 } else {
417 //echo $element['id']." - ".count($element['elements'])." > ";//print_r($element['elements']);
418 if(count($element['elements'])) {
419 $element_children=$this->get_element_data($id,$element['elements']);
420 if ($element_children) return $element_children ;
421 }
422 //echo"am ajuns aici?";
423 }
424 }
425 return false;
426 }
427
428 public function get_document_data(){
429
430 global $wp_query;
431
432
433 $id = $this->widget_id;
434
435 $post_id = $this->post_id;
436 $theme_id = $this->theme_id;
437 $old_query = $wp_query->query_vars;
438
439
440 $this->query['paged'] = $this->current_page; // we need current(next) page to be loaded
441 $this->query['post_status'] = 'publish';
442
443 $wp_query = new \WP_Query($this->query);
444 wp_reset_postdata();//this fixes some issues with some get_the_ID users.
445 if (is_archive()){
446 $post_id = $theme_id;
447 }
448
449 $document = \Elementor\Plugin::$instance->documents->get_doc_for_frontend( $post_id );
450 $theme_document = \Elementor\Plugin::$instance->documents->get_doc_for_frontend( $theme_id );
451
452 $data[] = $this->get_element_data($id,$theme_document->get_elements_data());
453
454 // Change the current post, so widgets can use `documents->get_current`.
455 \Elementor\Plugin::$instance->documents->switch_to_document( $document );
456
457 ob_start();
458 $document->print_elements_with_wrapper( $data );
459 $content = ob_get_clean();
460 echo $this->clean_response($content,$id);
461
462 \Elementor\Plugin::$instance->documents->restore_document();
463 $wp_query->query_vars = $query_vars;
464
465 die;
466 }
467
468 private function clean_response($html,$id){
469 $content = "";
470 $dom = new DOMDocument();
471 libxml_use_internal_errors(true);
472 $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
473 //$dom->loadHTML($html);
474 $xpath = new DOMXPath($dom);
475 $childs = $xpath->query('//div[@data-id="'.$id.'"]/div[@class="elementor-widget-container"]/div/* | //div[@data-elementor-type="custom_grid"]');
476 // $childs = $xpath->query('//div[@data-elementor-type="custom_grid"]');
477 //return $dom->saveHTML($childs->item(0));
478 foreach($childs as $child){
479 $content .= $dom->saveHTML($child);
480 }
481 //$div = $div->item(0);
482 return $content;
483 }
484
485 public function enqueue_scripts(){
486
487 global $wp_query;
488
489 wp_register_script('ecs_ajax_load', plugin_dir_url(__DIR__) . 'assets/js/ecs_ajax_pagination.js',array('jquery'),ELECS_VER);
490
491 wp_localize_script( 'ecs_ajax_load', 'ecs_ajax_params', array(
492 'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', // WordPress AJAX
493 'posts' => json_encode( $wp_query->query_vars ),
494 ) );
495
496 wp_enqueue_script( 'ecs_ajax_load' );
497 }
498
499 }
500
501
502 class ECS_Loading_Animation {
503 private static function animations(){
504 return [
505 'default'=>[
506 'label' => __( 'Default', 'ele-custom-skin' ),
507 'html' => '<div class="lds-ellipsis ecs-lazy-load-animation"><div class="ecs-ll-bgcolor"></div><div class="ecs-ll-bgcolor"></div><div class="ecs-ll-bgcolor"></div><div class="ecs-ll-bgcolor"></div></div>',
508 ],
509 'progress_bar'=>[
510 'label' => __( 'Progress Bar', 'ele-custom-skin' ),
511 'html' => '<div class="barload-wrapper ecs-lazy-load-animation"><div class="barload-border ecs-ll-brcolor"><div class="barload-whitespace"><div class="barload-line ecs-ll-bgcolor"></div></div></div></div>',
512 ],
513 'running_dots'=>[
514 'label' => __( 'Running Dots', 'ele-custom-skin' ),
515 'html' => '<div class="ballsload-container ecs-lazy-load-animation"><div class="ecs-ll-bgcolor"></div><div class="ecs-ll-bgcolor"></div><div class="ecs-ll-bgcolor"></div><div class="ecs-ll-bgcolor"></div></div>',
516 ],
517 'ball_slide'=>[
518 'label' => __( 'Ball Slide', 'ele-custom-skin' ),
519 'html' => '<div id="movingBallG" class="ecs-lazy-load-animation"><div class="movingBallLineG ecs-ll-bgcolor"></div><div id="movingBallG_1" class="movingBallG ecs-ll-bgcolor"></div></div>',
520 ],
521
522 ];
523 }
524
525
526 public static function get_lazy_load_animations_html($animation){
527 $arrs = self::animations();
528 return $arrs[$animation]['html'];
529 }
530
531 public static function get_lazy_load_animations_list(){
532 $arrs = self::animations();
533 foreach ( $arrs as $key => $arr ) {
534 $options[ $key ] = $arr['label'];
535 }
536 return $options;
537 }
538
539 }
540
541
542
543 new ECS_Ajax_Load();
544
545