PluginProbe
Page Builder: Pagelayer – Drag and Drop website builder / 1.0.4
Page Builder: Pagelayer – Drag and Drop website builder v1.0.4
2.2.1 2.2.0 2.1.9 2.1.8 2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 trunk 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 1.0.0 1.0.2 1.0.3 1.0.4 1.0.5 All 129 releases
pagelayer / main / shortcode_functions.php

shortcode_functions.php in Page Builder: Pagelayer – Drag and Drop website builder 1.0.4, at main/shortcode_functions.php

1,051 lines 27.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 //////////////////////////////////////////////////////////////
4 //===========================================================
5 // class.php
6 //===========================================================
7 // PAGELAYER
8 // Inspired by the DESIRE to be the BEST OF ALL
9 // ----------------------------------------------------------
10 // Started by: Pulkit Gupta
11 // Date: 23rd Jan 2017
12 // Time: 23:00 hrs
13 // Site: http://pagelayer.com/wordpress (PAGELAYER)
14 // ----------------------------------------------------------
15 // Please Read the Terms of use at http://pagelayer.com/tos
16 // ----------------------------------------------------------
17 //===========================================================
18 // (c)Pagelayer Team
19 //===========================================================
20 //////////////////////////////////////////////////////////////
21
22 // Are we being accessed directly ?
23 if(!defined('PAGELAYER_VERSION')) {
24 exit('Hacking Attempt !');
25 }
26
27 // Is there a tag ?
28 function pagelayer_render_shortcode($atts, $content = '', $tag = ''){
29
30 global $pagelayer;
31
32 $_tag = $class = $tag;
33 $final_tag = $tag;
34
35 // Check if the tag is inner row and col then change it to row and col tag
36 if($tag == 'pl_inner_row'){
37 $tag = 'pl_row';
38 }elseif($tag == 'pl_inner_col'){
39 $tag = 'pl_col';
40 $final_tag = $tag;
41 }
42
43 // Clear the pagelayer tags
44 if(substr($tag, 0, 3) == 'pl_'){
45 $_tag = str_replace('pl_', '', $final_tag);
46 $class = 'pagelayer-'.$_tag;
47 }
48
49 // Is there any function ?
50 $func = @$pagelayer->shortcodes[$tag]['func'];
51 $atts = (array) $atts;
52 // Create the element array. NOTE : This is similar to the JS el and is temporary
53 $el = [];
54 $el['atts'] = $atts;
55 $el['oAtts'] = $atts;
56 $el['id'] = pagelayer_RandomString(16);
57 $el['tmp'] = [];
58 $el['tag'] = $final_tag;
59 $el['content'] = $content;
60 $el['selector'] = '[pagelayer-id="'.$el['id'].'"]';
61 $el['wrap'] = '[pagelayer-wrap-id="'.$el['id'].'"]';
62
63 $innerHTML = @$pagelayer->shortcodes[$tag]['innerHTML'];
64 if(!empty($innerHTML) && !empty($content)){
65 $el['oAtts'][$innerHTML] = $content;
66 $el['atts'][$innerHTML] = $content;
67 }
68
69 // The default class
70 $el['classes'][] = $class;
71
72 //pagelayer_print($el);
73
74 // Lets create the CSS, Classes, Attr. Also clean the dependent atts
75 foreach($pagelayer->tabs as $tab){
76
77 if(empty($pagelayer->shortcodes[$tag][$tab])){
78 continue;
79 }
80
81 foreach($pagelayer->shortcodes[$tag][$tab] as $section => $Lsection){
82
83 $props = empty($pagelayer->shortcodes[$tag][$section]) ? @$pagelayer->styles[$section] : @$pagelayer->shortcodes[$tag][$section];
84
85 //echo $tab.' - '.$section.' - <br>';
86
87 if(empty($props)){
88 continue;
89 }
90
91 foreach($props as $prop => $param){
92
93 //echo $tab.' - '.$section.' - '.$prop.'<br>';
94
95 // No value set
96 if(empty($el['atts'][$prop]) && empty($el['atts'][$prop.'_tablet']) && empty($el['atts'][$prop.'_mobile'])){
97 continue;
98 }
99
100 // Clean the not required atts
101 if(!empty($param['req'])){
102
103 $set = true;
104
105 foreach($param['req'] as $rk => $reqval){
106 $except = $rk{0} == '!' ? true : false;
107 $rk = $except ? substr($rk, 1) : $rk;
108 $val = @$el['atts'][$rk];
109
110 //echo $prop.' - '.$rk.' : '.$reqval.' == '.$val.'<br>';
111
112 // The value should not be there
113 if($except){
114
115 if(!is_array($reqval) && $reqval == $val){
116 $set = false;
117 break;
118 }
119
120 // Its an array and a value is found, then dont show
121 if(is_array($reqval) && in_array($val, $reqval)){
122 $set = false;
123 break;
124 }
125
126 // The value must be equal
127 }else{
128
129 if(!is_array($reqval) && $reqval != $val){
130 $set = false;
131 break;
132 }
133
134 // Its an array and no value is found, then dont show
135 if(is_array($reqval) && !in_array($val, $reqval)){
136 $set = false;
137 break;
138 }
139 }
140
141 }
142
143 // Unset as we dont need
144 if(empty($set)){
145 unset($el['atts'][$prop]);
146 unset($el['atts'][$prop.'_tablet']);
147 unset($el['atts'][$prop.'_mobile']);
148 }
149
150 }
151
152 // We could have unset the value above, so we need to check again if the value is there
153 if(empty($el['atts'][$prop]) && empty($el['atts'][$prop.'_tablet']) && empty($el['atts'][$prop.'_mobile'])){
154 continue;
155 }
156
157 // Handle the edit fields
158 if(!empty($param['edit'])){
159 $el['edit'][$prop] = $param['edit'];
160 }
161
162 // Backward compatibility of row
163 if($el['tag'] == 'pl_row' && $prop == 'content_pos' && !empty($el['atts'][$prop])){
164 if($el['atts'][$prop] == 'baseline'){
165 $el['atts'][$prop] = $el['oAtts'][$prop] = 'flex-start';
166 }else if($el['atts'][$prop] == 'end'){
167 $el['atts'][$prop] = $el['oAtts'][$prop] = 'flex-end';
168 }
169 }
170
171 // Backward compatibility of Icons
172 if($param['type'] == 'icon' && !empty($el['atts'][$prop]) && !preg_match('/\s/', $el['atts'][$prop])){
173 $el['atts'][$prop] = $el['oAtts'][$prop] = 'fa fa-'.$el['atts'][$prop];
174 }
175
176 // Backward compatibility of Box Shadow
177 if($param['type'] == 'box_shadow' && !empty($el['atts'][$prop]) && substr_count($el['atts'][$prop], ',') == 3){
178 $el['atts'][$prop] = $el['oAtts'][$prop] = $el['atts'][$prop].',0,';
179 }
180
181 // Backward compatibility of units. And also for the default set value if it is numeric
182 if(!empty($param['units']) && isset($el['atts'][$prop]) && is_numeric($el['atts'][$prop])){
183 $el['atts'][$prop] = $el['oAtts'][$prop] = $el['atts'][$prop].$param['units'][0];
184 }
185
186 // Load any attachment values
187 if(in_array($param['type'], ['image', 'video', 'audio', 'media'])){
188
189 $attachment = ($param['type'] == 'image') ? pagelayer_image($el['atts'][$prop]) : pagelayer_attachment($el['atts'][$prop]);
190
191 if(!empty($attachment)){
192 foreach($attachment as $k => $v){
193 $el['tmp'][$prop.'-'.$k] = $v;
194 }
195 }
196
197 }
198
199 // Handle the AddClasses
200 if(!empty($param['addClass']) && !empty($el['atts'][$prop])){
201
202 // Convert to an array
203 if(!is_array($param['addClass'])){
204 $param['addClass'] = array($param['addClass']);
205 }
206
207 // Loop through
208 foreach($param['addClass'] as $k => $v){
209 $k = str_replace('{{element}}', '', $k);
210 $el['classes'][] = [trim($k) => str_replace('{{val}}', $el['atts'][$prop], $v)];
211 }
212
213 }
214
215 // Handle the AddClasses
216 if(!empty($param['addAttr']) && !empty($el['atts'][$prop])){
217
218 // Convert to an array
219 if(!is_array($param['addAttr'])){
220 $param['addAttr'] = array($param['addAttr']);
221 }
222
223 // Loop through
224 foreach($param['addAttr'] as $k => $v){
225 $k = str_replace('{{element}}', '', $k);
226 $el['attr'][] = [trim($k) => $v];
227 }
228
229 }
230
231 // Handle the CSS
232 if(!empty($param['css'])){
233 //echo $prop.'<br>';
234 // Convert to an array
235 if(!is_array($param['css'])){
236 $param['css'] = array($param['css']);
237 }
238
239 $modes = [
240 'desktop' => '',
241 'tablet' => '_tablet',
242 'mobile' => '_mobile'
243 ];
244
245 // Loop the modes and check for values
246 foreach($modes as $mk => $mv){
247
248 $M_prop = $prop.$mv;
249
250 // Any value ?
251 if(empty($el['atts'][$M_prop])){
252 continue;
253 }
254
255 // Loop through
256 foreach($param['css'] as $k => $v){
257
258 // Make the selector
259 $selector = (!is_numeric($k) ? $k : $el['selector']);
260 $selector = pagelayer_parse_el_vars($selector, $el);
261
262 $ender = '';
263
264 if($mk == 'tablet'){
265 $selector = '@media (max-width: 768px) and (min-width: 361px){'.$selector;
266 $ender = '}';
267 }
268
269 if($mk == 'mobile'){
270 $selector = '@media (max-width: 360px){'.$selector;
271 $ender = '}';
272 }
273
274 if(!empty($selector)){
275 // Make the CSS
276 $el['css'][] = $selector.'{'.pagelayer_css_render($v, $el['atts'][$M_prop], @$param['sep']).'}'.$ender;
277 }else{
278 $el['css'][] = pagelayer_parse_el_vars($el['atts'][$M_prop],$el);
279 }
280 }
281
282 }
283
284 }
285
286 if($param['type'] == 'typography'){
287 $val = explode(',', $el['atts'][$prop]);
288
289 if(!empty($val[0]) && !in_array($val[0], $pagelayer->runtime_fonts)){
290 $pagelayer->runtime_fonts[] = $val[0];
291 //pagelayer_print($pagelayer->runtime_fonts);
292 }
293 }
294
295 }
296
297 }
298
299 }
300
301 //@pagelayer_print($el['css']);
302
303 // Is there a function of the tag ?
304 if(function_exists($func)){
305 call_user_func_array($func, array(&$el));
306 }
307
308 // Create the default atts and tmp atts
309 if(pagelayer_is_live()){
310 pagelayer_create_sc($el);
311 }
312
313 $div = '<div pagelayer-id="'.$el['id'].'">
314 <style pagelayer-style-id="'.$el['id'].'"></style>';
315
316 $is_group = !empty($pagelayer->shortcodes[$tag]['params']['elements']) ? true : false;
317
318 // If there is an HTML AND you are not a GROUP, then make use of it, or append the real content
319 if(!empty($pagelayer->shortcodes[$tag]['html'])){
320
321 // Create the HTML object
322 $node = pQuery::parseStr($pagelayer->shortcodes[$tag]['html']);
323
324 // Remove the if-ext
325 foreach($node('[if-ext]') as $v){
326 $reqvar = pagelayer_var($v->attr('if-ext'));
327 $v->removeAttr('if-ext');
328
329 // Is the element there ?
330 if(empty($el['atts'][$reqvar])){
331 $v->after($v->html());
332 $v->remove();
333 }
334 }
335
336 // Remove the if
337 foreach($node('[if]') as $v){
338 $reqvar = pagelayer_var($v->attr('if'));
339 $v->removeAttr('if');
340
341 // Is the element there ?
342 if(empty($el['atts'][$reqvar])){
343 $v->remove();
344 }
345 }
346
347 //die($node->html());
348
349 // Do we have a holder ? Mainly for groups
350 if(!empty($pagelayer->shortcodes[$tag]['holder'])){
351 $node->query($pagelayer->shortcodes[$tag]['holder'])->html('{{pagelayer_do_shortcode}}');
352 $do_shortcode = 1;
353 }
354
355 $html = pagelayer_parse_vars($node->html(), $el);
356
357 // Append to the DIV
358 $div .= $html;
359
360 // Is it a widget ?
361 }elseif(!empty($pagelayer->shortcodes[$tag]['widget'])){
362
363 $class = $pagelayer->shortcodes[$tag]['widget'];
364 $instance = [];
365
366 // Is there any existing data ?
367 if(!empty($el['atts']['widget_data'])){
368 $json = trim($el['atts']['widget_data']);
369 $json = json_decode($json, true);
370 //pagelayer_print($json);die();
371 if(!empty($json)){
372 $instance = $json;
373 }
374 }
375
376 ob_start();
377 the_widget($class, $instance, array('widget_id'=>'arbitrary-instance-'.$el['id'],
378 'before_widget' => '',
379 'after_widget' => '',
380 'before_title' => '',
381 'after_title' => ''
382 ));
383
384 $div .= ob_get_contents();
385 ob_end_clean();
386
387 }else{
388 $div .= '{{pagelayer_do_shortcode}}';
389 $do_shortcode = 1;
390 }
391
392 // End the tag
393 $div .= '</div>';
394
395 // Add classes and attributes
396 if(!empty($el['classes']) || !empty($el['attr'])){
397
398 // Create the HTML object
399 $node = pQuery::parseStr($div);
400
401 // Add the editable values
402 if(!empty($el['edit'])){
403
404 foreach($el['edit'] as $k => $v){
405 $node->query($v)->attr('pagelayer-editable', $k);
406 }
407
408 }
409
410 // Add the classes
411 if(!empty($el['classes'])){
412
413 //pagelayer_print($el['classes']);
414
415 foreach($el['classes'] as $k => $v){
416
417 if(!is_array($v)){
418 $v = [$v];
419 }
420
421 foreach($v as $kk => $vv){
422 //echo $kk.' - '.$vv."\n";
423 if(is_numeric($kk)){
424 $node->query($el['selector'])->addClass($vv);
425 }else{
426 $node->query($kk)->addClass($vv);
427 }
428
429 }
430
431 }
432
433 //echo $node->html();
434 //die();
435
436 }
437
438 // Add the attributes
439 if(!empty($el['attr'])){
440
441 //pagelayer_print($el['attr']);
442
443 foreach($el['attr'] as $k => $v){
444
445 if(!is_array($v)){
446 $v = [$v];
447 }
448
449 foreach($v as $kk => $vv){
450
451 $att = explode('=', $vv, 2);
452 $att[1] = pagelayer_parse_vars($att[1], $el);
453 $att[1] = trim($att[1], '"');
454
455 if(is_numeric($kk)){
456 $node->query($el['selector'])->attr($att[0], $att[1]);
457 }else{
458 $node->query($kk)->attr($att[0], $att[1]);
459 }
460
461 }
462
463 }
464
465 }
466
467 $div = $node->html();
468 //die($div);
469
470 }
471
472 // Add the CSS if any or remove it
473 $style = '';
474 if(!empty($el['css'])){
475
476 $style = '<style pagelayer-style-id="'.$el['id'].'">
477 '.implode("\n", pagelayer_parse_vars($el['css'], $el)).'
478 </style>';
479
480 if(!empty($pagelayer->shortcodes[$tag]['overide_css_selector'])){
481 $style = str_replace($el['selector'], $pagelayer->shortcodes[$tag]['overide_css_selector'], $style);
482 $style = str_replace($el['wrap'], $pagelayer->shortcodes[$tag]['overide_css_selector'], $style);
483 }
484
485 }
486
487 $div = str_replace('<style pagelayer-style-id="'.$el['id'].'"></style>', $style, $div);
488
489 // Is there an inner content which requires a SHORTCODE ?
490 if(!empty($do_shortcode)){
491 $div = str_replace('{{pagelayer_do_shortcode}}', do_shortcode($el['content']), $div);
492 }
493
494 return $div;
495
496 }
497
498 // Creates the shortcode and returns a base64 encoded files
499 function pagelayer_create_sc(&$el){
500
501 $a = $tmp = array();
502
503 if(!empty($el['oAtts'])){
504
505 foreach($el['oAtts'] as $k => $v){
506 $el['attr'][] = 'pagelayer-a-'.$k.'="'.$v.'"';
507 }
508
509 }
510
511 // Tmp atts
512 if(!empty($el['tmp'])){
513
514 foreach($el['tmp'] as $k => $v){
515 $el['attr'][] = 'pagelayer-tmp-'.$k.'="'.$v.'"';
516 }
517
518 }
519
520 // Add the tag
521 $el['attr'][] = 'pagelayer-tag="'.$el['tag'].'"';
522
523 // Make it a PageLayer element for editing
524 $el['classes'][] = 'pagelayer-ele';
525
526 }
527
528 // Converts {{val}} to val
529 function pagelayer_var($var){
530 return substr($var, 2, -2);
531 }
532
533 // Replace the variables
534 function pagelayer_parse_el_vars($str, &$el){
535
536 $str = str_replace('{{element}}', $el['selector'], $str);
537 $is_live = pagelayer_is_live();
538 if(!empty($is_live)){
539 $str = str_replace('{{wrap}}', $el['wrap'], $str);
540 }else{
541 $str = str_replace('{{wrap}}', $el['selector'], $str);
542 }
543 $str = str_replace('{{ele_id}}', $el['id'], $str);
544
545 return $str;
546
547 }
548
549 // Parse the variables
550 function pagelayer_parse_vars($str, &$el){
551
552 //pagelayer_print($el);
553 if(is_array($el['tmp'])){
554 foreach($el['tmp'] as $k => $v){
555 $str = str_replace('{{{'.$k.'}}}', $el['tmp'][$k], $str);
556 }
557 }
558
559 if(is_array($el['atts'])){
560 foreach($el['atts'] as $k => $v){
561 $str = str_replace('{{'.$k.'}}', $el['atts'][$k], $str);
562 }
563 }
564
565 return $str;
566 }
567
568 // Make the rule
569 function pagelayer_css_render($rule, $val, $sep = ','){
570
571 // Seperator
572 $sep = empty($sep) ? ',' : $sep;
573
574 // Replace the val
575 $rule = str_replace('{{val}}', pagelayer_hex8_to_rgba($val), $rule);
576
577 // If there is an array
578 if(preg_match('/\{val\[\d/is', $rule)){
579 $val = explode($sep, $val);
580 foreach($val as $k => $v){
581 $rule = str_replace('{{val['.$k.']}}', pagelayer_hex8_to_rgba($v), $rule);
582 }
583 }
584
585 return $rule;
586
587 }
588
589 // Post Property Handler
590 function pagelayer_sc_body(&$el){
591
592 global $post;
593
594 $el['oAtts']['post_title'] = $post->post_title;
595 $el['oAtts']['post_name'] = $post->post_name;
596 $el['oAtts']['post_excerpt'] = $post->post_excerpt;
597 $el['oAtts']['post_status'] = $post->post_status;
598 $el['oAtts']['featured_image'] = get_post_thumbnail_id($post);
599
600 // Load featured image details
601 if(!empty($el['oAtts']['featured_image'])){
602
603 $attachment = pagelayer_image($el['oAtts']['featured_image']);
604
605 if(!empty($attachment)){
606 foreach($attachment as $k => $v){
607 $el['tmp']['featured_image-'.$k] = $v;
608 }
609 }
610
611 }
612
613 }
614
615 // ROW Handler
616 function pagelayer_sc_row(&$el){
617
618 pagelayer_bg_video($el);
619
620 if(!empty($el['atts']['row_shape_type_top'])){
621 $path_top = PAGELAYER_DIR.'/images/shapes/'.$el['atts']['row_shape_type_top'].'-top.svg';
622 $el['atts']['svg_top'] = file_get_contents($path_top);
623 }
624
625 if(!empty($el['atts']['row_shape_type_bottom'])){
626 $path_bottom = PAGELAYER_DIR.'/images/shapes/'.$el['atts']['row_shape_type_bottom'].'-bottom.svg';
627 $el['atts']['svg_bottom'] = file_get_contents($path_bottom);
628 }
629
630 // Row background slider
631 if(!empty($el['atts']['bg_slider'])){
632 $ids = explode(',', $el['atts']['bg_slider']);
633 $urls = [];
634 $el['atts']['slider'] = '';
635
636 // Make the image URL
637 foreach($ids as $k => $v){
638
639 $image = pagelayer_image($v);
640 $urls['i'.$v] = @$image['url'];
641
642 $el['atts']['slider'] .= '<div class="pagelayer-bgimg-slide" style="background-image:url(\''.$image['url'].'\')"></div>';
643
644 }
645
646 if(!empty($urls)){
647 $el['tmp']['bg_slider-urls'] = json_encode($urls);
648 }
649
650 }
651 }
652
653 // Column Handler
654 function pagelayer_sc_col(&$el){
655
656 // Add the default col class
657 $el['classes'][] = 'pagelayer-col';
658
659 //return do_shortcode($el['content']);
660
661 pagelayer_bg_video($el);
662
663 // Column background slider
664 if(!empty($el['atts']['bg_slider'])){
665 $ids = explode(',', $el['atts']['bg_slider']);
666 $urls = [];
667 $el['atts']['slider'] = '';
668
669 // Make the image URL
670 foreach($ids as $k => $v){
671
672 $image = pagelayer_image($v);
673 $urls['i'.$v] = @$image['url'];
674
675 $el['atts']['slider'] .= '<div class="pagelayer-bgimg-slide" style="background-image:url(\''.$image['url'].'\')"></div>';
676
677 }
678
679 if(!empty($urls)){
680 $el['tmp']['bg_slider-urls'] = json_encode($urls);
681 }
682
683 }
684
685 }
686
687 // Just for BG handling
688 function pagelayer_bg_video(&$el){
689
690 if(empty($el['tmp']['bg_video_src-url'])){
691 return false;
692 }
693
694 // Get the video URL for the iframe
695 $iframe_src = pagelayer_video_url($el['tmp']['bg_video_src-url']);
696
697 $source = filter_var($el['tmp']['bg_video_src-url'], FILTER_SANITIZE_URL);
698 $source = str_replace('&amp;', '&', $source);
699 $url = parse_url($source);
700
701 $youtubeRegExp = '/youtube\.com|youtu\.be/is';
702 $vimeoRegExp = '/vimeo\.com/is';
703
704 if (!empty($source)) {
705
706 if (preg_match($youtubeRegExp, $source)) {
707 if (preg_match('/youtube\.com/is', $source)) {
708
709 if (preg_match('/watch/is', $source)) {
710 parse_str($url['query'], $parameters);
711
712 if (isset($parameters['v']) && !empty($parameters['v'])) {
713 $videoId = $parameters['v'];
714 }
715
716 } else if (preg_match('/embed/is', $url['path'])) {
717 $path = explode('/', $url['path']);
718 if (isset($path[2]) && !empty($path[2])) {
719 $videoId = $path[2];
720 }
721 }
722
723 } else if (preg_match('/youtu\.be/is', $url['host'])) {
724 $path = explode('/', $url['path']);
725
726 if (isset($path[1]) && !empty($path[1])) {
727 $videoId = $path[1];
728 }
729
730 }
731
732 $el['atts']['vid_src'] = '<iframe src="'.$iframe_src.'?autoplay=1&controls=0&showinfo=0&rel=0&loop=1&autohide=1&playlist='.$videoId.'" allowfullscreen="1" webkitallowfullscreen="1" mozallowfullscreen="1" frameborder="0"></iframe>';
733
734 } else if (preg_match($vimeoRegExp, $source)) {
735
736 $el['atts']['vid_src'] = '<iframe src="'.$iframe_src.'?background=1&autoplay=1&loop=1&byline=0&title=0" allowfullscreen="1" webkitallowfullscreen="1" mozallowfullscreen="1" frameborder="0"></iframe>';
737
738 }else{
739
740 $el['atts']['vid_src'] = '<video autoplay loop>'.
741 '<source src="'.$iframe_src.'" type="video/mp4">'.
742 '</video>';
743
744 }
745 }
746 }
747
748 // Image Handler
749 function pagelayer_sc_social(&$el){
750 $icon = explode(' fa-', $el['atts']['icon']);
751 $el['classes'][] = ['.pagelayer-icon-holder' => 'pagelayer-'.$icon[1]];
752 }
753
754 // Image Handler
755 function pagelayer_sc_image(&$el){
756
757 // Decide the image URL
758 $el['atts']['func_id'] = @$el['tmp']['id-'.$el['atts']['id-size'].'-url'];
759 $el['atts']['func_id'] = empty($el['atts']['func_id']) ? @$el['tmp']['id-url'] : $el['atts']['func_id'];
760
761 // What is the link ?
762 if(!empty($el['atts']['link_type'])){
763
764 // Custom url
765 if($el['atts']['link_type'] == 'custom_url'){
766 $el['atts']['func_link'] = $el['atts']['link'];
767 }
768
769 // Link to the media file itself
770 if($el['atts']['link_type'] == 'media_file'){
771 $el['atts']['func_link'] = $el['atts']['func_id'];
772 }
773
774 // Lightbox
775 if($el['atts']['link_type'] == 'lightbox'){
776 $el['atts']['func_link'] = $el['atts']['func_id'];
777 }
778
779 }
780
781 //pagelayer_print($el);
782
783 }
784
785 // Image Slider Handler
786 function pagelayer_sc_image_slider(&$el){
787
788 $ids = explode(',', $el['atts']['ids']);
789 $urls = [];
790 $all_urls = [];
791 $final_urls = [];
792 $ul = [];
793 $size = $el['atts']['size'];
794
795 // Make the image URL
796 foreach($ids as $k => $v){
797
798 $image = pagelayer_image($v);
799
800 $final_urls[$v] = empty($image[$size.'-url']) ? @$image['url'] : $image[$size.'-url'];
801
802 $urls['i'.$v] = @$image['url'];
803
804 foreach($image as $kk => $vv){
805 $si = strstr($kk, '-url', true);
806 if(!empty($si)){
807 $all_urls['i'.$v][$si] = $vv;
808 }
809 }
810
811 $li = '<li class="pagelayer-slider-item">';
812
813 // Any Link ?
814 if(!empty($el['atts']['link_type'])){
815 $link = ($el['atts']['link_type'] == 'media_file' ? $final_urls[$v] : @$el['atts']['link']);
816 $li .= '<a href="'.$link.'">';
817 }
818
819 // The Image
820 $li .= '<img class="pagelayer-img" src="'.$final_urls[$v].'">';
821
822 if(!empty($el['atts']['link_type'])){
823 $li .= '</a>';
824 }
825
826 $li .= '</li>';
827
828 $ul[] = $li;
829
830 }
831
832 //pagelayer_print($urls);
833 //pagelayer_print($final_urls);
834 //pagelayer_print($all_urls);
835
836 // Make the TMP vars
837 if(!empty($urls)){
838 $el['tmp']['ids-urls'] = json_encode($urls);
839 $el['tmp']['ids-all-urls'] = json_encode($all_urls);
840 $el['atts']['ul'] = implode('', $ul);
841
842 // Which arrows to show
843 if(in_array(@$el['atts']['controls'], ['arrows', 'none'])){
844 $el['attr'][] = ['.pagelayer-image-slider-ul' => 'data-pager="false"'];
845 }
846
847 if(in_array(@$el['atts']['controls'], ['pager', 'none'])){
848 $el['attr'][] = ['.pagelayer-image-slider-ul' => 'data-controls="false"'];
849 }
850 }
851
852 };
853
854 //Grid Gallery Handler
855 function pagelayer_sc_grid_gallery(&$el){
856
857 $ids = explode(',', $el['atts']['ids']);
858 $urls = [];
859 $all_urls = [];
860 $final_urls = [];
861 $ul = [];
862 $size = $el['atts']['size'];
863 $i = 0;
864 $col = $el['atts']['columns'];
865 $gallery_rand = 'gallery-id-'.floor((rand() * 100) + 1);
866
867 $ul[] = '<ul class="pagelayer-grid-gallery-ul">';
868 // Make the image URL
869 foreach($ids as $k => $v){
870
871 $image = pagelayer_image($v);
872
873 $final_urls[$v] = empty($image[$size.'-url']) ? @$image['url'] : $image[$size.'-url'];
874
875 $urls['i'.$v] = @$image['url'];
876 $links['i'.$v] = @$image['link'];
877 $titles['i'.$v] = @$image['title'];
878 $captions['i'.$v] = @$image['caption'];
879
880 foreach($image as $kk => $vv){
881 $si = strstr($kk, '-url', true);
882 if(!empty($si)){
883 $all_urls['i'.$v][$si] = $vv;
884 }
885 }
886
887 /* if(($i % $col) == 0 && $i != 0 ){
888 $ul[] = '</ul><ul class="pagelayer-grid-gallery-ul">';
889 } */
890
891 $li = '<li class="pagelayer-gallery-item" >';
892
893 if(empty($el['atts']['link_to'])){
894 $li .= '<div>';
895 }
896
897 // Any Link ?
898 if(!empty($el['atts']['link_to']) && $el['atts']['link_to'] == 'media_file'){
899 $link = ($el['atts']['link_to'] == 'media_file' ? $final_urls[$v] : @$el['atts']['link']);
900 $li .= '<a href="'.$link.'" class="pagelayer-ele-link">';
901 }
902
903 // Any Link ?
904 if(!empty($el['atts']['link_to']) && $el['atts']['link_to'] == 'attachment' ){
905 $link = $image['link'];
906 $li .= '<a href="'.$link.'" class="pagelayer-ele-link">';
907 }
908
909 if(!empty($el['atts']['link_to']) && $el['atts']['link_to'] == 'lightbox'){
910 $li .= '<a href="'.$image['url'].'" data-lightbox-gallery="'.$gallery_rand.'" alt="'.$image['alt'].'" class="pagelayer-ele-link" pagelayer-grid-gallery-type="'.$el['atts']['link_to'].'">';
911 }
912 // The Image
913 $li .= '<img class="pagelayer-img" src="'.$final_urls[$v].'" title="'.$image['title'].'" alt="'.$image['alt'].'">';
914
915 if(!empty($el['atts']['caption'])){
916 $li .= '<span class="pagelayer-grid-gallery-caption">'.$image['caption'].'</span>';
917 }
918
919 if(!empty($el['atts']['link_to'])){
920 $li .= '</a>';
921 }
922
923 if(empty($el['atts']['link_to'])){
924 $li .= '</div>';
925 }
926
927 $li .= '</li>';
928
929 $ul[] = $li;
930 $i++;
931 }
932
933 $ul[] = '</ul>';
934
935 //pagelayer_print($urls);
936 //pagelayer_print($final_urls);
937 //pagelayer_print($all_urls);
938
939 // Make the TMP vars
940 if(!empty($urls)){
941 $el['tmp']['ids-urls'] = json_encode($urls);
942 $el['tmp']['ids-all-urls'] = json_encode($all_urls);
943 $el['tmp']['ids-all-links'] = json_encode($links);
944 $el['tmp']['ids-all-titles'] = json_encode($titles);
945 $el['tmp']['ids-all-captions'] = json_encode($captions);
946 $el['atts']['ul'] = implode('', $ul);
947 $el['tmp']['gallery-random-id'] = $gallery_rand;
948
949 }
950 }
951
952 // Testimonial Handler
953 function pagelayer_sc_testimonial(&$el){
954
955 $el['atts']['func_image'] = @$el['tmp']['avatar-'.$el['atts']['custom_size'].'-url'];
956 $el['atts']['func_image'] = empty($el['atts']['func_image']) ? @$el['tmp']['avatar-url'] : $el['atts']['func_image'];
957
958 if(!empty($image)){
959 foreach($image as $k => $v){
960 $el['tmp']['avatar-'.$k] = $v;
961 }
962 }
963
964 }
965
966 // Video Handler
967 function pagelayer_sc_video(&$el){
968
969 $el['atts']['video_overlay_image-url'] = empty($el['tmp']['video_overlay_image-'.$el['atts']['custom_size'].'-url']) ? $el['tmp']['video_overlay_image-url'] : $el['tmp']['video_overlay_image-'.$el['atts']['custom_size'].'-url'];
970 $el['atts']['video_overlay_image-url'] = empty($el['atts']['video_overlay_image-url']) ? $el['atts']['video_overlay_image'] : $el['atts']['video_overlay_image-url'];
971
972 // Get the video URL for the iframe
973 $el['atts']['vid_src'] = pagelayer_video_url($el['tmp']['src-url']);
974
975 if($el['atts']['autoplay'] == "true"){
976 $el['atts']['vid_src'] .="?&autoplay=1";
977 }else{
978 $el['atts']['vid_src'] .="?&autoplay=0";
979 }
980
981 if($el['atts']['mute'] == "true"){
982 $el['atts']['vid_src'] .="&mute=1";
983 }else{
984 $el['atts']['vid_src'] .="&mute=0";
985 }
986
987 if($el['atts']['loop'] == "true"){
988 $el['atts']['vid_src'] .="&loop=1";
989 }else{
990 $el['atts']['vid_src'] .="&loop=0";
991 }
992
993 $el['tmp']['ele_id'] = $el['id'];
994
995 }
996
997
998 // Shortcodes Handler
999 function pagelayer_sc_shortcodes(&$el){
1000 $el['tmp']['shortcode'] = do_shortcode($el['atts']['data']);
1001 }
1002
1003 // Shortcodes Handler
1004 function pagelayer_sc_wp_widgets(&$el){
1005
1006 global $wp_registered_sidebars;
1007
1008 $data = '';
1009 foreach($wp_registered_sidebars as $v){
1010 if($el['atts']['sidebar'] == $v['id']){
1011 ob_start();
1012 dynamic_sidebar($v['id']);
1013 $data = ob_get_clean();
1014 }
1015 }
1016
1017 $el['tmp']['data'] = $data;
1018 }
1019
1020
1021 // Service Handler
1022 function pagelayer_sc_service(&$el){
1023
1024 if(!empty($el['atts']['service_image'])){
1025 $el['atts']['func_image'] = @$el['tmp']['service_image-'.$el['atts']['service_image_size'].'-url'];
1026 $el['atts']['func_image'] = empty($el['atts']['func_image']) ? @$el['tmp']['service_image-url'] : $el['atts']['func_image'];
1027 }
1028 }
1029
1030
1031 /*pagelayer_print($atts);
1032 pagelayer_print($content);
1033 die();*/
1034
1035 /////////////////////////////////////
1036 // Miscellaneous Shortcode Functions
1037 /////////////////////////////////////
1038
1039 // The font family list
1040 function pagelayer_font_family(){
1041 return array(
1042 'arial' => 'Arial',
1043 'terminal' => 'Terminal'
1044 );
1045 }
1046
1047 // Supported Icons
1048 function pagelayer_icon_class_list(){
1049 return array();
1050 }
1051