| 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 |
|
| 34 |
// Clear the pagelayer tags |
| 35 |
if(substr($tag, 0, 3) == 'pl_'){ |
| 36 |
$_tag = str_replace('pl_', '', $tag); |
| 37 |
$class = 'pagelayer-'.$_tag; |
| 38 |
} |
| 39 |
|
| 40 |
// Is there any function ? |
| 41 |
$func = @$pagelayer->shortcodes[$tag]['func']; |
| 42 |
|
| 43 |
// Create the element array. NOTE : This is similar to the JS el and is temporary |
| 44 |
$el = []; |
| 45 |
$el['atts'] = $atts; |
| 46 |
$el['oAtts'] = $atts; |
| 47 |
$el['id'] = pagelayer_RandomString(16); |
| 48 |
$el['tmp'] = []; |
| 49 |
$el['tag'] = $tag; |
| 50 |
$el['content'] = $content; |
| 51 |
$el['selector'] = '[pagelayer-id="'.$el['id'].'"]'; |
| 52 |
|
| 53 |
$innerHTML = @$pagelayer->shortcodes[$tag]['innerHTML']; |
| 54 |
if(!empty($innerHTML) && !empty($content)){ |
| 55 |
$el['oAtts'][$innerHTML] = $content; |
| 56 |
$el['atts'][$innerHTML] = $content; |
| 57 |
} |
| 58 |
|
| 59 |
// The default class |
| 60 |
$el['classes'][] = $class; |
| 61 |
|
| 62 |
//pagelayer_print($el); |
| 63 |
|
| 64 |
// Lets create the CSS, Classes, Attr. Also clean the dependent atts |
| 65 |
foreach($pagelayer->tabs as $tab){ |
| 66 |
|
| 67 |
if(empty($pagelayer->shortcodes[$tag][$tab])){ |
| 68 |
continue; |
| 69 |
} |
| 70 |
|
| 71 |
foreach($pagelayer->shortcodes[$tag][$tab] as $section => $Lsection){ |
| 72 |
|
| 73 |
$props = empty($pagelayer->shortcodes[$tag][$section]) ? @$pagelayer->styles[$section] : @$pagelayer->shortcodes[$tag][$section]; |
| 74 |
|
| 75 |
//echo $tab.' - '.$section.' - <br>'; |
| 76 |
|
| 77 |
if(empty($props)){ |
| 78 |
continue; |
| 79 |
} |
| 80 |
|
| 81 |
foreach($props as $prop => $param){ |
| 82 |
|
| 83 |
//echo $tab.' - '.$section.' - '.$prop.'<br>'; |
| 84 |
|
| 85 |
// No value set |
| 86 |
if(empty($el['atts'][$prop]) && empty($el['atts'][$prop.'_tablet']) && empty($el['atts'][$prop.'_mobile'])){ |
| 87 |
continue; |
| 88 |
} |
| 89 |
|
| 90 |
// Clean the not required atts |
| 91 |
if(!empty($param['req'])){ |
| 92 |
|
| 93 |
$set = true; |
| 94 |
|
| 95 |
foreach($param['req'] as $rk => $reqval){ |
| 96 |
$except = $rk{0} == '!' ? true : false; |
| 97 |
$rk = $except ? substr($rk, 1) : $rk; |
| 98 |
$val = @$el['atts'][$rk]; |
| 99 |
|
| 100 |
//echo $prop.' - '.$rk.' : '.$reqval.' == '.$val.'<br>'; |
| 101 |
|
| 102 |
// The value should not be there |
| 103 |
if($except){ |
| 104 |
|
| 105 |
if(!is_array($reqval) && $reqval == $val){ |
| 106 |
$set = false; |
| 107 |
break; |
| 108 |
} |
| 109 |
|
| 110 |
// Its an array and a value is found, then dont show |
| 111 |
if(is_array($reqval) && in_array($val, $reqval)){ |
| 112 |
$set = false; |
| 113 |
break; |
| 114 |
} |
| 115 |
|
| 116 |
// The value must be equal |
| 117 |
}else{ |
| 118 |
|
| 119 |
if(!is_array($reqval) && $reqval != $val){ |
| 120 |
$set = false; |
| 121 |
break; |
| 122 |
} |
| 123 |
|
| 124 |
// Its an array and no value is found, then dont show |
| 125 |
if(is_array($reqval) && !in_array($val, $reqval)){ |
| 126 |
$set = false; |
| 127 |
break; |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
} |
| 132 |
|
| 133 |
// Unset as we dont need |
| 134 |
if(empty($set)){ |
| 135 |
unset($el['atts'][$prop]); |
| 136 |
unset($el['atts'][$prop.'_tablet']); |
| 137 |
unset($el['atts'][$prop.'_mobile']); |
| 138 |
} |
| 139 |
|
| 140 |
} |
| 141 |
|
| 142 |
// We could have unset the value above, so we need to check again if the value is there |
| 143 |
if(empty($el['atts'][$prop]) && empty($el['atts'][$prop.'_tablet']) && empty($el['atts'][$prop.'_mobile'])){ |
| 144 |
continue; |
| 145 |
} |
| 146 |
|
| 147 |
// Handle the edit fields |
| 148 |
if(!empty($param['edit'])){ |
| 149 |
$el['edit'][$prop] = $param['edit']; |
| 150 |
} |
| 151 |
|
| 152 |
// Load any attachment values |
| 153 |
if(in_array($param['type'], ['image', 'video', 'audio', 'media'])){ |
| 154 |
|
| 155 |
$attachment = ($param['type'] == 'image') ? pagelayer_image($el['atts'][$prop]) : pagelayer_attachment($el['atts'][$prop]); |
| 156 |
|
| 157 |
if(!empty($attachment)){ |
| 158 |
foreach($attachment as $k => $v){ |
| 159 |
$el['tmp'][$prop.'-'.$k] = $v; |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
} |
| 164 |
|
| 165 |
// Handle the AddClasses |
| 166 |
if(!empty($param['addClass']) && !empty($el['atts'][$prop])){ |
| 167 |
|
| 168 |
// Convert to an array |
| 169 |
if(!is_array($param['addClass'])){ |
| 170 |
$param['addClass'] = array($param['addClass']); |
| 171 |
} |
| 172 |
|
| 173 |
// Loop through |
| 174 |
foreach($param['addClass'] as $k => $v){ |
| 175 |
$k = str_replace('{{element}}', '', $k); |
| 176 |
$el['classes'][] = [trim($k) => str_replace('{{val}}', $el['atts'][$prop], $v)]; |
| 177 |
} |
| 178 |
|
| 179 |
} |
| 180 |
|
| 181 |
// Handle the AddClasses |
| 182 |
if(!empty($param['addAttr']) && !empty($el['atts'][$prop])){ |
| 183 |
|
| 184 |
// Convert to an array |
| 185 |
if(!is_array($param['addAttr'])){ |
| 186 |
$param['addAttr'] = array($param['addAttr']); |
| 187 |
} |
| 188 |
|
| 189 |
// Loop through |
| 190 |
foreach($param['addAttr'] as $k => $v){ |
| 191 |
$k = str_replace('{{element}}', '', $k); |
| 192 |
$el['attr'][] = [trim($k) => $v]; |
| 193 |
} |
| 194 |
|
| 195 |
} |
| 196 |
|
| 197 |
// Handle the CSS |
| 198 |
if(!empty($param['css'])){ |
| 199 |
//echo $prop.'<br>'; |
| 200 |
// Convert to an array |
| 201 |
if(!is_array($param['css'])){ |
| 202 |
$param['css'] = array($param['css']); |
| 203 |
} |
| 204 |
|
| 205 |
$modes = [ |
| 206 |
'desktop' => '', |
| 207 |
'tablet' => '_tablet', |
| 208 |
'mobile' => '_mobile' |
| 209 |
]; |
| 210 |
|
| 211 |
// Loop the modes and check for values |
| 212 |
foreach($modes as $mk => $mv){ |
| 213 |
|
| 214 |
$M_prop = $prop.$mv; |
| 215 |
|
| 216 |
// Any value ? |
| 217 |
if(empty($el['atts'][$M_prop])){ |
| 218 |
continue; |
| 219 |
} |
| 220 |
|
| 221 |
// Loop through |
| 222 |
foreach($param['css'] as $k => $v){ |
| 223 |
|
| 224 |
// Make the selector |
| 225 |
$selector = (!is_numeric($k) ? str_replace('{{element}}', $el['selector'], $k) : $el['selector']); |
| 226 |
|
| 227 |
$ender = ''; |
| 228 |
|
| 229 |
if($mk == 'tablet'){ |
| 230 |
$selector = '@media (max-width: 768px) and (min-width: 361px){'.$selector; |
| 231 |
$ender = '}'; |
| 232 |
} |
| 233 |
|
| 234 |
if($mk == 'mobile'){ |
| 235 |
$selector = '@media (max-width: 360px){'.$selector; |
| 236 |
$ender = '}'; |
| 237 |
} |
| 238 |
|
| 239 |
// Make the CSS |
| 240 |
$el['css'][] = $selector.'{'.pagelayer_css_render($v, $el['atts'][$M_prop], @$param['sep']).'}'.$ender; |
| 241 |
} |
| 242 |
|
| 243 |
} |
| 244 |
|
| 245 |
} |
| 246 |
|
| 247 |
if($param['type'] == 'typography'){ |
| 248 |
$val = explode(',', $el['atts'][$prop]); |
| 249 |
|
| 250 |
if(!empty($val[0]) && !in_array($val[0], $pagelayer->runtime_fonts)){ |
| 251 |
$pagelayer->runtime_fonts[] = $val[0]; |
| 252 |
//pagelayer_print($pagelayer->runtime_fonts); |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
} |
| 257 |
|
| 258 |
} |
| 259 |
|
| 260 |
} |
| 261 |
|
| 262 |
//@pagelayer_print($el['css']); |
| 263 |
|
| 264 |
// Is there a function of the tag ? |
| 265 |
if(function_exists($func)){ |
| 266 |
call_user_func_array($func, array(&$el)); |
| 267 |
} |
| 268 |
|
| 269 |
// Create the default atts and tmp atts |
| 270 |
if(pagelayer_is_live()){ |
| 271 |
pagelayer_create_sc($el); |
| 272 |
} |
| 273 |
|
| 274 |
$div = '<div pagelayer-id="'.$el['id'].'"> |
| 275 |
<style pagelayer-style-id="'.$el['id'].'"></style>'; |
| 276 |
|
| 277 |
$is_group = !empty($pagelayer->shortcodes[$tag]['params']['elements']) ? true : false; |
| 278 |
|
| 279 |
// If there is an HTML AND you are not a GROUP, then make use of it, or append the real content |
| 280 |
if(!empty($pagelayer->shortcodes[$tag]['html'])){ |
| 281 |
|
| 282 |
// Create the HTML object |
| 283 |
$node = pQuery::parseStr($pagelayer->shortcodes[$tag]['html']); |
| 284 |
|
| 285 |
// Remove the if-ext |
| 286 |
foreach($node('[if-ext]') as $v){ |
| 287 |
$reqvar = pagelayer_var($v->attr('if-ext')); |
| 288 |
$v->removeAttr('if-ext'); |
| 289 |
|
| 290 |
// Is the element there ? |
| 291 |
if(empty($el['atts'][$reqvar])){ |
| 292 |
$v->after($v->html()); |
| 293 |
$v->remove(); |
| 294 |
} |
| 295 |
} |
| 296 |
|
| 297 |
// Remove the if |
| 298 |
foreach($node('[if]') as $v){ |
| 299 |
$reqvar = pagelayer_var($v->attr('if')); |
| 300 |
$v->removeAttr('if'); |
| 301 |
|
| 302 |
// Is the element there ? |
| 303 |
if(empty($el['atts'][$reqvar])){ |
| 304 |
$v->remove(); |
| 305 |
} |
| 306 |
} |
| 307 |
|
| 308 |
//die($node->html()); |
| 309 |
|
| 310 |
// Do we have a holder ? Mainly for groups |
| 311 |
if(!empty($pagelayer->shortcodes[$tag]['holder'])){ |
| 312 |
$node->query($pagelayer->shortcodes[$tag]['holder'])->html('{{pagelayer_do_shortcode}}'); |
| 313 |
$do_shortcode = 1; |
| 314 |
} |
| 315 |
|
| 316 |
$html = pagelayer_parse_vars($node->html(), $el); |
| 317 |
|
| 318 |
// Append to the DIV |
| 319 |
$div .= $html; |
| 320 |
|
| 321 |
// Is it a widget ? |
| 322 |
}elseif(!empty($pagelayer->shortcodes[$tag]['widget'])){ |
| 323 |
|
| 324 |
$class = $pagelayer->shortcodes[$tag]['widget']; |
| 325 |
$instance = []; |
| 326 |
|
| 327 |
// Is there any existing data ? |
| 328 |
if(!empty($el['atts']['widget_data'])){ |
| 329 |
$json = trim($el['atts']['widget_data']); |
| 330 |
$json = json_decode($json, true); |
| 331 |
//pagelayer_print($json);die(); |
| 332 |
if(!empty($json)){ |
| 333 |
$instance = $json; |
| 334 |
} |
| 335 |
} |
| 336 |
|
| 337 |
ob_start(); |
| 338 |
the_widget($class, $instance, array('widget_id'=>'arbitrary-instance-'.$el['id'], |
| 339 |
'before_widget' => '', |
| 340 |
'after_widget' => '', |
| 341 |
'before_title' => '', |
| 342 |
'after_title' => '' |
| 343 |
)); |
| 344 |
|
| 345 |
$div .= ob_get_contents(); |
| 346 |
ob_end_clean(); |
| 347 |
|
| 348 |
}else{ |
| 349 |
$div .= '{{pagelayer_do_shortcode}}'; |
| 350 |
$do_shortcode = 1; |
| 351 |
} |
| 352 |
|
| 353 |
// End the tag |
| 354 |
$div .= '</div>'; |
| 355 |
|
| 356 |
// Add classes and attributes |
| 357 |
if(!empty($el['classes']) || !empty($el['attr'])){ |
| 358 |
|
| 359 |
// Create the HTML object |
| 360 |
$node = pQuery::parseStr($div); |
| 361 |
|
| 362 |
// Add the editable values |
| 363 |
if(!empty($el['edit'])){ |
| 364 |
|
| 365 |
foreach($el['edit'] as $k => $v){ |
| 366 |
$node->query($v)->attr('pagelayer-editable', $k); |
| 367 |
} |
| 368 |
|
| 369 |
} |
| 370 |
|
| 371 |
// Add the classes |
| 372 |
if(!empty($el['classes'])){ |
| 373 |
|
| 374 |
//pagelayer_print($el['classes']); |
| 375 |
|
| 376 |
foreach($el['classes'] as $k => $v){ |
| 377 |
|
| 378 |
if(!is_array($v)){ |
| 379 |
$v = [$v]; |
| 380 |
} |
| 381 |
|
| 382 |
foreach($v as $kk => $vv){ |
| 383 |
//echo $kk.' - '.$vv."\n"; |
| 384 |
if(is_numeric($kk)){ |
| 385 |
$node->query($el['selector'])->addClass($vv); |
| 386 |
}else{ |
| 387 |
$node->query($kk)->addClass($vv); |
| 388 |
} |
| 389 |
|
| 390 |
} |
| 391 |
|
| 392 |
} |
| 393 |
|
| 394 |
//echo $node->html(); |
| 395 |
//die(); |
| 396 |
|
| 397 |
} |
| 398 |
|
| 399 |
// Add the attributes |
| 400 |
if(!empty($el['attr'])){ |
| 401 |
|
| 402 |
//pagelayer_print($el['attr']); |
| 403 |
|
| 404 |
foreach($el['attr'] as $k => $v){ |
| 405 |
|
| 406 |
if(!is_array($v)){ |
| 407 |
$v = [$v]; |
| 408 |
} |
| 409 |
|
| 410 |
foreach($v as $kk => $vv){ |
| 411 |
|
| 412 |
$att = explode('=', $vv, 2); |
| 413 |
$att[1] = pagelayer_parse_vars($att[1], $el); |
| 414 |
$att[1] = trim($att[1], '"'); |
| 415 |
|
| 416 |
if(is_numeric($kk)){ |
| 417 |
$node->query($el['selector'])->attr($att[0], $att[1]); |
| 418 |
}else{ |
| 419 |
$node->query($kk)->attr($att[0], $att[1]); |
| 420 |
} |
| 421 |
|
| 422 |
} |
| 423 |
|
| 424 |
} |
| 425 |
|
| 426 |
} |
| 427 |
|
| 428 |
$div = $node->html(); |
| 429 |
//die($div); |
| 430 |
|
| 431 |
} |
| 432 |
|
| 433 |
// Add the CSS if any or remove it |
| 434 |
$style = ''; |
| 435 |
if(!empty($el['css'])){ |
| 436 |
|
| 437 |
$style = '<style pagelayer-style-id="'.$el['id'].'"> |
| 438 |
'.implode("\n", pagelayer_parse_vars($el['css'], $el)).' |
| 439 |
</style>'; |
| 440 |
|
| 441 |
} |
| 442 |
|
| 443 |
$div = str_replace('<style pagelayer-style-id="'.$el['id'].'"></style>', $style, $div); |
| 444 |
|
| 445 |
// Is there an inner content which requires a SHORTCODE ? |
| 446 |
if(!empty($do_shortcode)){ |
| 447 |
$div = str_replace('{{pagelayer_do_shortcode}}', do_shortcode($el['content']), $div); |
| 448 |
} |
| 449 |
|
| 450 |
return $div; |
| 451 |
|
| 452 |
} |
| 453 |
|
| 454 |
// Creates the shortcode and returns a base64 encoded files |
| 455 |
function pagelayer_create_sc(&$el){ |
| 456 |
|
| 457 |
$a = $tmp = array(); |
| 458 |
|
| 459 |
if(!empty($el['oAtts'])){ |
| 460 |
|
| 461 |
foreach($el['oAtts'] as $k => $v){ |
| 462 |
$el['attr'][] = 'pagelayer-a-'.$k.'="'.$v.'"'; |
| 463 |
} |
| 464 |
|
| 465 |
} |
| 466 |
|
| 467 |
// Tmp atts |
| 468 |
if(!empty($el['tmp'])){ |
| 469 |
|
| 470 |
foreach($el['tmp'] as $k => $v){ |
| 471 |
$el['attr'][] = 'pagelayer-tmp-'.$k.'="'.$v.'"'; |
| 472 |
} |
| 473 |
|
| 474 |
} |
| 475 |
|
| 476 |
// Add the tag |
| 477 |
$el['attr'][] = 'pagelayer-tag="'.$el['tag'].'"'; |
| 478 |
|
| 479 |
// Make it a PageLayer element for editing |
| 480 |
$el['classes'][] = 'pagelayer-ele'; |
| 481 |
|
| 482 |
} |
| 483 |
|
| 484 |
// Converts {{val}} to val |
| 485 |
function pagelayer_var($var){ |
| 486 |
return substr($var, 2, -2); |
| 487 |
} |
| 488 |
|
| 489 |
// Parse the variables |
| 490 |
function pagelayer_parse_vars($str, &$el){ |
| 491 |
|
| 492 |
//pagelayer_print($el); |
| 493 |
if(is_array($el['tmp'])){ |
| 494 |
foreach($el['tmp'] as $k => $v){ |
| 495 |
$str = str_replace('{{{'.$k.'}}}', $el['tmp'][$k], $str); |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
if(is_array($el['atts'])){ |
| 500 |
foreach($el['atts'] as $k => $v){ |
| 501 |
$str = str_replace('{{'.$k.'}}', $el['atts'][$k], $str); |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
return $str; |
| 506 |
} |
| 507 |
|
| 508 |
// Make the rule |
| 509 |
function pagelayer_css_render($rule, $val, $sep = ','){ |
| 510 |
|
| 511 |
// Seperator |
| 512 |
$sep = empty($sep) ? ',' : $sep; |
| 513 |
|
| 514 |
// Replace the val |
| 515 |
$rule = str_replace('{{val}}', $val, $rule); |
| 516 |
|
| 517 |
// If there is an array |
| 518 |
if(preg_match('/\{val\[\d/is', $rule)){ |
| 519 |
$val = explode($sep, $val); |
| 520 |
foreach($val as $k => $v){ |
| 521 |
$rule = str_replace('{{val['.$k.']}}', $v, $rule); |
| 522 |
} |
| 523 |
} |
| 524 |
|
| 525 |
return $rule; |
| 526 |
|
| 527 |
} |
| 528 |
|
| 529 |
// ROW Handler |
| 530 |
function pagelayer_sc_row(&$el){ |
| 531 |
pagelayer_bg_video($el); |
| 532 |
|
| 533 |
if(!empty($el['atts']['row_shape_type_top'])){ |
| 534 |
$path_top = PAGELAYER_DIR.'/images/shapes/'.$el['atts']['row_shape_type_top'].'-top.svg'; |
| 535 |
$el['atts']['svg_top'] = file_get_contents($path_top); |
| 536 |
} |
| 537 |
|
| 538 |
if(!empty($el['atts']['row_shape_type_bottom'])){ |
| 539 |
$path_bottom = PAGELAYER_DIR.'/images/shapes/'.$el['atts']['row_shape_type_bottom'].'-bottom.svg'; |
| 540 |
$el['atts']['svg_bottom'] = file_get_contents($path_bottom); |
| 541 |
} |
| 542 |
} |
| 543 |
|
| 544 |
// Column Handler |
| 545 |
function pagelayer_sc_col(&$el){ |
| 546 |
|
| 547 |
// Add the default col class |
| 548 |
$el['classes'][] = 'pagelayer-col'; |
| 549 |
|
| 550 |
//return do_shortcode($el['content']); |
| 551 |
|
| 552 |
pagelayer_bg_video($el); |
| 553 |
|
| 554 |
} |
| 555 |
|
| 556 |
// Just for BG handling |
| 557 |
function pagelayer_bg_video(&$el){ |
| 558 |
|
| 559 |
if(empty($el['tmp']['bg_video_src-url'])){ |
| 560 |
return false; |
| 561 |
} |
| 562 |
|
| 563 |
// Get the video URL for the iframe |
| 564 |
$iframe_src = pagelayer_video_url($el['tmp']['bg_video_src-url']); |
| 565 |
|
| 566 |
$source = filter_var($el['tmp']['bg_video_src-url'], FILTER_SANITIZE_URL); |
| 567 |
$source = str_replace('&', '&', $source); |
| 568 |
$url = parse_url($source); |
| 569 |
|
| 570 |
$youtubeRegExp = '/youtube\.com|youtu\.be/is'; |
| 571 |
$vimeoRegExp = '/vimeo\.com/is'; |
| 572 |
|
| 573 |
if (!empty($source)) { |
| 574 |
|
| 575 |
if (preg_match($youtubeRegExp, $source)) { |
| 576 |
if (preg_match('/youtube\.com/is', $source)) { |
| 577 |
|
| 578 |
if (preg_match('/watch/is', $source)) { |
| 579 |
parse_str($url['query'], $parameters); |
| 580 |
|
| 581 |
if (isset($parameters['v']) && !empty($parameters['v'])) { |
| 582 |
$videoId = $parameters['v']; |
| 583 |
} |
| 584 |
|
| 585 |
} else if (preg_match('/embed/is', $url['path'])) { |
| 586 |
$path = explode('/', $url['path']); |
| 587 |
if (isset($path[2]) && !empty($path[2])) { |
| 588 |
$videoId = $path[2]; |
| 589 |
} |
| 590 |
} |
| 591 |
|
| 592 |
} else if (preg_match('/youtu\.be/is', $url['host'])) { |
| 593 |
$path = explode('/', $url['path']); |
| 594 |
|
| 595 |
if (isset($path[1]) && !empty($path[1])) { |
| 596 |
$videoId = $path[1]; |
| 597 |
} |
| 598 |
|
| 599 |
} |
| 600 |
|
| 601 |
$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>'; |
| 602 |
|
| 603 |
} else if (preg_match($vimeoRegExp, $source)) { |
| 604 |
|
| 605 |
$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>'; |
| 606 |
|
| 607 |
}else{ |
| 608 |
|
| 609 |
$el['atts']['vid_src'] = '<video autoplay loop>'. |
| 610 |
'<source src="'.$iframe_src.'" type="video/mp4">'. |
| 611 |
'</video>'; |
| 612 |
|
| 613 |
} |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
// Heading |
| 618 |
function pagelayer_sc_heading($atts, $content = '', $tag = ''){ |
| 619 |
//return '<div '.pagelayer_create_sc($tag, $atts, 'pagelayer-text').'>'.$content.'</div>'; |
| 620 |
} |
| 621 |
|
| 622 |
// Text |
| 623 |
function pagelayer_sc_text($atts, $content = '', $tag = ''){ |
| 624 |
//return '<div '.pagelayer_create_sc($tag, $atts, 'pagelayer-text').'>'.$content.'</div>'; |
| 625 |
} |
| 626 |
|
| 627 |
// Rich Text Handler |
| 628 |
function pagelayer_sc_code($atts, $content = '', $tag = ''){ |
| 629 |
//return '<div '.pagelayer_create_sc($tag, $atts, 'pagelayer-text').'>'.$content.'</div>'; |
| 630 |
} |
| 631 |
|
| 632 |
// List Handler |
| 633 |
function pagelayer_sc_list($atts, $content = '', $tag = ''){ |
| 634 |
return; |
| 635 |
$items = []; |
| 636 |
$list = $list_type = $icon_type = $icon_color = $text_color = $ul = $ol = $type = ''; |
| 637 |
$i_item = ''; |
| 638 |
if($atts['items']){ |
| 639 |
$items = preg_split('/\r\n|\r|\n/', ($atts['items'])); |
| 640 |
} |
| 641 |
|
| 642 |
$list_type = $atts['list_type']; |
| 643 |
$ul = array('circle', 'disc', 'square', 'armenian', 'georgian'); |
| 644 |
$ol = array('decimal', 'decimal-leading-zero', 'lower-latin', 'lower-roman', 'lower-greek', 'upper-latin', 'upper-roman'); |
| 645 |
|
| 646 |
$icon_type = $atts['icon']; |
| 647 |
$icon_color = $atts['icon_color']; |
| 648 |
$text_color = $atts['text_color']; |
| 649 |
|
| 650 |
if(in_array($list_type, $ul)){ |
| 651 |
|
| 652 |
$type = 'ul'; |
| 653 |
} |
| 654 |
|
| 655 |
if(in_array($list_type, $ol)){ |
| 656 |
$type = 'ol'; |
| 657 |
} |
| 658 |
|
| 659 |
if($list_type == 'icon'){ |
| 660 |
$type = 'ul'; |
| 661 |
$i_item = '<i class="'.$icon_type .'" style="color:'. $icon_color .'"></i>'; |
| 662 |
} |
| 663 |
if($list_type == 'none'){ |
| 664 |
$type = 'undefined'; |
| 665 |
} |
| 666 |
|
| 667 |
$list = '<'. $type .' class="pagelayer-list-item">'; |
| 668 |
|
| 669 |
foreach($items as $x){ |
| 670 |
$list .= '<li class="pagelayer-list-'.$list_type.'" >'. $i_item .'<span style="color:'. $text_color .'">'.$x.'</span></li>'; |
| 671 |
|
| 672 |
} |
| 673 |
|
| 674 |
$list .= '</'. $type .'>'; |
| 675 |
|
| 676 |
|
| 677 |
return '<div '.pagelayer_create_sc($tag, $atts, 'pagelayer-list').'>'.$list.'</div>'; |
| 678 |
} |
| 679 |
|
| 680 |
// Image Handler |
| 681 |
function pagelayer_sc_image(&$el){ |
| 682 |
|
| 683 |
// Decide the image URL |
| 684 |
$el['atts']['func_id'] = @$el['tmp']['id-'.$el['atts']['id-size'].'-url']; |
| 685 |
$el['atts']['func_id'] = empty($el['atts']['func_id']) ? @$el['tmp']['id-full-url'] : $el['atts']['func_id']; |
| 686 |
|
| 687 |
// What is the link ? |
| 688 |
if(!empty($el['atts']['link_type'])){ |
| 689 |
|
| 690 |
// Custom url |
| 691 |
if($el['atts']['link_type'] == 'custom_url'){ |
| 692 |
$el['atts']['func_link'] = $el['atts']['link']; |
| 693 |
} |
| 694 |
|
| 695 |
// Link to the media file itself |
| 696 |
if($el['atts']['link_type'] == 'media_file'){ |
| 697 |
$el['atts']['func_link'] = $el['atts']['func_id']; |
| 698 |
} |
| 699 |
|
| 700 |
// Lightbox |
| 701 |
if($el['atts']['link_type'] == 'lightbox'){ |
| 702 |
$el['atts']['func_link'] = $el['atts']['func_id']; |
| 703 |
} |
| 704 |
|
| 705 |
} |
| 706 |
|
| 707 |
//pagelayer_print($el); |
| 708 |
|
| 709 |
} |
| 710 |
|
| 711 |
// Image Slider Handler |
| 712 |
function pagelayer_sc_image_slider(&$el){ |
| 713 |
|
| 714 |
$ids = explode(',', $el['atts']['ids']); |
| 715 |
$urls = []; |
| 716 |
$all_urls = []; |
| 717 |
$final_urls = []; |
| 718 |
$ul = []; |
| 719 |
$size = $el['atts']['size']; |
| 720 |
|
| 721 |
// Make the image URL |
| 722 |
foreach($ids as $k => $v){ |
| 723 |
|
| 724 |
$image = pagelayer_image($v); |
| 725 |
|
| 726 |
$final_urls[$v] = empty($image[$size.'-url']) ? @$image['full-url'] : $image[$size.'-url']; |
| 727 |
|
| 728 |
$urls['i'.$v] = @$image['full-url']; |
| 729 |
|
| 730 |
foreach($image as $kk => $vv){ |
| 731 |
$si = strstr($kk, '-url', true); |
| 732 |
if(!empty($si)){ |
| 733 |
$all_urls['i'.$v][$si] = $vv; |
| 734 |
} |
| 735 |
} |
| 736 |
|
| 737 |
$li = '<li class="pagelayer-slider-item">'; |
| 738 |
|
| 739 |
// Any Link ? |
| 740 |
if(!empty($el['atts']['link_type'])){ |
| 741 |
$link = ($el['atts']['link_type'] == 'media_file' ? $final_urls[$v] : @$el['atts']['link']); |
| 742 |
$li .= '<a href="'.$link.'">'; |
| 743 |
} |
| 744 |
|
| 745 |
// The Image |
| 746 |
$li .= '<img src="'.$final_urls[$v].'">'; |
| 747 |
|
| 748 |
if(!empty($el['atts']['link_type'])){ |
| 749 |
$li .= '</a>'; |
| 750 |
} |
| 751 |
|
| 752 |
$li .= '</li>'; |
| 753 |
|
| 754 |
$ul[] = $li; |
| 755 |
|
| 756 |
} |
| 757 |
|
| 758 |
//pagelayer_print($urls); |
| 759 |
//pagelayer_print($final_urls); |
| 760 |
//pagelayer_print($all_urls); |
| 761 |
|
| 762 |
// Make the TMP vars |
| 763 |
if(!empty($urls)){ |
| 764 |
$el['tmp']['ids-urls'] = json_encode($urls); |
| 765 |
$el['tmp']['ids-all-urls'] = json_encode($all_urls); |
| 766 |
$el['atts']['ul'] = implode('', $ul); |
| 767 |
|
| 768 |
// Which arrows to show |
| 769 |
if(in_array(@$el['atts']['controls'], ['arrows', 'none'])){ |
| 770 |
$el['attr'][] = ['.pagelayer-image-slider-ul' => 'data-pager="false"']; |
| 771 |
} |
| 772 |
|
| 773 |
if(in_array(@$el['atts']['controls'], ['pager', 'none'])){ |
| 774 |
$el['attr'][] = ['.pagelayer-image-slider-ul' => 'data-controls="false"']; |
| 775 |
} |
| 776 |
} |
| 777 |
|
| 778 |
}; |
| 779 |
|
| 780 |
//Grid Gallery Handler |
| 781 |
function pagelayer_sc_grid_gallery(&$el){ |
| 782 |
|
| 783 |
$ids = explode(',', $el['atts']['ids']); |
| 784 |
$urls = []; |
| 785 |
$all_urls = []; |
| 786 |
$final_urls = []; |
| 787 |
$ul = []; |
| 788 |
$size = $el['atts']['size']; |
| 789 |
$i = 0; |
| 790 |
$col = $el['atts']['columns']; |
| 791 |
$gallery_rand = 'gallery-id-'.floor((rand() * 100) + 1); |
| 792 |
|
| 793 |
$ul[] = '<ul class="pagelayer-grid-gallery-ul">'; |
| 794 |
// Make the image URL |
| 795 |
foreach($ids as $k => $v){ |
| 796 |
|
| 797 |
$image = pagelayer_image($v); |
| 798 |
|
| 799 |
$final_urls[$v] = empty($image[$size.'-url']) ? @$image['full-url'] : $image[$size.'-url']; |
| 800 |
|
| 801 |
$urls['i'.$v] = @$image['full-url']; |
| 802 |
$links['i'.$v] = @$image['link']; |
| 803 |
$titles['i'.$v] = @$image['title']; |
| 804 |
$captions['i'.$v] = @$image['caption']; |
| 805 |
|
| 806 |
foreach($image as $kk => $vv){ |
| 807 |
$si = strstr($kk, '-url', true); |
| 808 |
if(!empty($si)){ |
| 809 |
$all_urls['i'.$v][$si] = $vv; |
| 810 |
} |
| 811 |
} |
| 812 |
|
| 813 |
if(($i % $col) == 0 && $i != 0 ){ |
| 814 |
$ul[] = '</ul><ul class="pagelayer-grid-gallery-ul">'; |
| 815 |
} |
| 816 |
|
| 817 |
$li = '<li class="pagelayer-gallery-item" >'; |
| 818 |
|
| 819 |
if(empty($el['atts']['link_to'])){ |
| 820 |
$li .= '<div>'; |
| 821 |
} |
| 822 |
|
| 823 |
// Any Link ? |
| 824 |
if(!empty($el['atts']['link_to']) && $el['atts']['link_to'] == 'media_file'){ |
| 825 |
$link = ($el['atts']['link_to'] == 'media_file' ? $final_urls[$v] : @$el['atts']['link']); |
| 826 |
$li .= '<a href="'.$link.'" class="pagelayer-ele-link">'; |
| 827 |
} |
| 828 |
|
| 829 |
// Any Link ? |
| 830 |
if(!empty($el['atts']['link_to']) && $el['atts']['link_to'] == 'attachment' ){ |
| 831 |
$link = $image['link']; |
| 832 |
$li .= '<a href="'.$link.'" class="pagelayer-ele-link">'; |
| 833 |
} |
| 834 |
|
| 835 |
if(!empty($el['atts']['link_to']) && $el['atts']['link_to'] == 'lightbox'){ |
| 836 |
$li .= '<a href="'.$image['full-url'].'" data-lightbox-gallery="'.$gallery_rand.'" alt="'.$image['alt'].'" class="pagelayer-ele-link" pagelayer-grid-gallery-type="'.$el['atts']['link_to'].'">'; |
| 837 |
} |
| 838 |
// The Image |
| 839 |
$li .= '<img src="'.$final_urls[$v].'" title="'.$image['title'].'" alt="'.$image['alt'].'">'; |
| 840 |
|
| 841 |
if(!empty($el['atts']['caption'])){ |
| 842 |
$li .= '<span class="pagelayer-grid-gallery-caption">'.$image['caption'].'</span>'; |
| 843 |
} |
| 844 |
|
| 845 |
if(!empty($el['atts']['link_to'])){ |
| 846 |
$li .= '</a>'; |
| 847 |
} |
| 848 |
|
| 849 |
if(empty($el['atts']['link_to'])){ |
| 850 |
$li .= '</div>'; |
| 851 |
} |
| 852 |
|
| 853 |
$li .= '</li>'; |
| 854 |
|
| 855 |
$ul[] = $li; |
| 856 |
$i++; |
| 857 |
} |
| 858 |
|
| 859 |
$ul[] = '</ul>'; |
| 860 |
|
| 861 |
//pagelayer_print($urls); |
| 862 |
//pagelayer_print($final_urls); |
| 863 |
//pagelayer_print($all_urls); |
| 864 |
|
| 865 |
// Make the TMP vars |
| 866 |
if(!empty($urls)){ |
| 867 |
$el['tmp']['ids-urls'] = json_encode($urls); |
| 868 |
$el['tmp']['ids-all-urls'] = json_encode($all_urls); |
| 869 |
$el['tmp']['ids-all-links'] = json_encode($links); |
| 870 |
$el['tmp']['ids-all-titles'] = json_encode($titles); |
| 871 |
$el['tmp']['ids-all-captions'] = json_encode($captions); |
| 872 |
$el['atts']['ul'] = implode('', $ul); |
| 873 |
$el['tmp']['gallery-random-id'] = $gallery_rand; |
| 874 |
|
| 875 |
} |
| 876 |
} |
| 877 |
|
| 878 |
// Image Handler |
| 879 |
function pagelayer_sc_audio(&$el){ |
| 880 |
|
| 881 |
return; |
| 882 |
|
| 883 |
$el['atts']['a_url'] = ''; |
| 884 |
|
| 885 |
if ($el['atts']['source'] == 'external'){ |
| 886 |
$el['atts']['a_url'] = $el['atts']['url']; |
| 887 |
} |
| 888 |
|
| 889 |
if ($el['atts']['source'] == 'library'){ |
| 890 |
|
| 891 |
$el['atts']['a_url'] = wp_get_attachment_url($el['atts']['id']); |
| 892 |
} |
| 893 |
if(!empty($el['atts']['a_url'])){ |
| 894 |
|
| 895 |
$filename=$el['atts']['a_url']; |
| 896 |
|
| 897 |
//Get the file extension |
| 898 |
|
| 899 |
$extension = pathinfo($filename, PATHINFO_EXTENSION); |
| 900 |
|
| 901 |
|
| 902 |
//Create source tag according to audio file |
| 903 |
switch($extension){ |
| 904 |
|
| 905 |
default: |
| 906 |
case 'mp3': |
| 907 |
$el['atts']['a_type'] = 'audio/mpeg'; |
| 908 |
break; |
| 909 |
|
| 910 |
case 'ogg': |
| 911 |
$el['atts']['a_type']= 'audio/ogg'; |
| 912 |
break; |
| 913 |
|
| 914 |
case 'wav': |
| 915 |
$el['atts']['a_type'] = 'audio/wav'; |
| 916 |
break; |
| 917 |
} |
| 918 |
} |
| 919 |
|
| 920 |
if(!empty($el['atts']['a_url']) && !empty($el['atts']['a_type'])){ |
| 921 |
$el['attr'][]= ['source' => 'src="{{a_url}}']; |
| 922 |
$el['attr'][]= ['source' => 'type="{{a_type}}']; |
| 923 |
} |
| 924 |
|
| 925 |
} |
| 926 |
|
| 927 |
// Social Share Handler |
| 928 |
function pagelayer_sc_share(&$el){ |
| 929 |
|
| 930 |
$labelList = array( |
| 931 |
'Facebook' => array( |
| 932 |
'icons' => array('facebook', 'facebook-official', 'facebook-square'), |
| 933 |
'url' => 'https://www.facebook.com/sharer/sharer.php?u=' |
| 934 |
), |
| 935 |
'Twitter' => array( |
| 936 |
'icons' => array('twitter', 'twitter-square'), |
| 937 |
'url' => 'https://twitter.com/share?url=' |
| 938 |
), |
| 939 |
'Google+' => array( |
| 940 |
'icons' => array('google-plus', 'google-plus-square'), |
| 941 |
'url' => 'https://plus.google.com/share?url=' |
| 942 |
), |
| 943 |
'Instagram' => array( |
| 944 |
'icons' => array('instagram'), |
| 945 |
'url' => '' |
| 946 |
), |
| 947 |
'Linkedin' => array( |
| 948 |
'icons' => array('linkedin', 'linkedin-square'), |
| 949 |
'url' => 'https://www.linkedin.com/shareArticle?url=' |
| 950 |
), |
| 951 |
'pinterest' => array( |
| 952 |
'icons' => array('pinterest', 'pinterest-p', 'pinterest-square'), |
| 953 |
'url' => '//www.pinterest.com/pin/create/button/?url=' |
| 954 |
), |
| 955 |
'Reddit' => array( |
| 956 |
'icons' => array('reddit-alien', 'reddit-square', 'reddit'), |
| 957 |
'url' => 'https://reddit.com/submit?url=' |
| 958 |
), |
| 959 |
'Skype' => array( |
| 960 |
'icons' => array('skype'), |
| 961 |
'url' => '' |
| 962 |
), |
| 963 |
'Stumbleupon' => array( |
| 964 |
'icons' => array('stumbleupon'), |
| 965 |
'url' => 'https://www.stumbleupon.com/submit?url=' |
| 966 |
), |
| 967 |
'Telegram' => array( |
| 968 |
'icons' => array('telegram'), |
| 969 |
'url' => 'https://t.me/share/url?url=' |
| 970 |
), |
| 971 |
'Tumblr' => array( |
| 972 |
'icons' => array('tumblr', 'tumblr-square'), |
| 973 |
'url' => 'https://www.tumblr.com/share/link?url=' |
| 974 |
), |
| 975 |
'VK' => array( |
| 976 |
'icons' => array('vk'), |
| 977 |
'url' => 'http://vk.com/share.php?url=' |
| 978 |
), |
| 979 |
'Weibo' => array( |
| 980 |
'icons' => array('weibo'), |
| 981 |
'url' => 'http://service.weibo.com/share/share.php?url=' |
| 982 |
), |
| 983 |
'WhatsApp' => array( |
| 984 |
'icons' => array('whatsapp'), |
| 985 |
'url' => 'whatsapp://send?text=' |
| 986 |
), |
| 987 |
'WordPress' => array( |
| 988 |
'icons' => array('wordpress'), |
| 989 |
'url' => 'https://wordpress.com/press-this.php?u=' |
| 990 |
), |
| 991 |
'Xing' => array( |
| 992 |
'icons' => array('xing', 'xing-square'), |
| 993 |
'url' => 'https://www.xing.com/spi/shares/new?url=' |
| 994 |
), |
| 995 |
'Delicious' => array( |
| 996 |
'icons' => array('delicious'), |
| 997 |
'url' => 'https://delicious.com/save?v=5&noui&jump=close&url=' |
| 998 |
), |
| 999 |
'Dribbble' => array( |
| 1000 |
'icons' => array('dribbble'), |
| 1001 |
'url' => '' |
| 1002 |
) |
| 1003 |
); |
| 1004 |
|
| 1005 |
if(!empty($el['atts']['text'])){ |
| 1006 |
$el['atts']['icon_label'] = $el['atts']['text']; |
| 1007 |
}else{ |
| 1008 |
foreach($labelList as $key => $val){ |
| 1009 |
if(in_array($el['atts']['icon'], $val['icons'])){ |
| 1010 |
$el['atts']['icon_label'] = $key; |
| 1011 |
break; |
| 1012 |
} |
| 1013 |
} |
| 1014 |
} |
| 1015 |
|
| 1016 |
foreach($labelList as $key => $val){ |
| 1017 |
if(in_array($el['atts']['icon'], $val['icons'])){ |
| 1018 |
$el['atts']['social_url'] = $val['url'].$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];; |
| 1019 |
break; |
| 1020 |
} |
| 1021 |
} |
| 1022 |
} |
| 1023 |
|
| 1024 |
// Posts Grid |
| 1025 |
function pagelayer_sc_wp_posts_grid($atts, $content = '', $tag = ''){ |
| 1026 |
|
| 1027 |
$args = array( |
| 1028 |
'numberposts' => -1, |
| 1029 |
'post_type' => 'post', |
| 1030 |
'post_status' => array('publish', 'pending', 'draft', 'future', 'private', 'inherit', 'trash') |
| 1031 |
); |
| 1032 |
$all_posts = get_posts($args); |
| 1033 |
|
| 1034 |
$html = '<div '.pagelayer_create_sc($tag, $atts, 'pagelayer-posts-grid').'>'; |
| 1035 |
|
| 1036 |
//pagelayer_print($all_posts); |
| 1037 |
foreach($all_posts as $pk => $pv){ |
| 1038 |
$post_link = get_permalink($pv->ID); |
| 1039 |
$html .= '<div> |
| 1040 |
<h2><a href="'.$post_link.'">'.$pv->post_title.'</a></h2> |
| 1041 |
<p>'.date('F jS, Y', strtotime($pv->post_date)).' | Published by <a href="'.site_url('author/'.get_the_author_meta('user_login', $pv->post_author)).'">'.get_the_author_meta('display_name', $pv->post_author).'</a></p> |
| 1042 |
<p>'.do_shortcode($pv->post_content).'</p> |
| 1043 |
<p><a href="'.$post_link.'">Read More</a></p> |
| 1044 |
</div>'; |
| 1045 |
} |
| 1046 |
|
| 1047 |
$html .= '</div>'; |
| 1048 |
|
| 1049 |
return $html; |
| 1050 |
} |
| 1051 |
|
| 1052 |
// Video Handler |
| 1053 |
function pagelayer_sc_video(&$el){ |
| 1054 |
|
| 1055 |
$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']; |
| 1056 |
$el['atts']['video_overlay_image-url'] = empty($el['atts']['video_overlay_image-url']) ? $el['atts']['video_overlay_image'] : $el['atts']['video_overlay_image-url']; |
| 1057 |
|
| 1058 |
// Get the video URL for the iframe |
| 1059 |
$el['atts']['vid_src'] = pagelayer_video_url($el['tmp']['src-url']); |
| 1060 |
|
| 1061 |
if($el['atts']['autoplay'] == "true"){ |
| 1062 |
$el['atts']['vid_src'] .="?&autoplay=1"; |
| 1063 |
}else{ |
| 1064 |
$el['atts']['vid_src'] .="?&autoplay=0"; |
| 1065 |
} |
| 1066 |
|
| 1067 |
if($el['atts']['mute'] == "true"){ |
| 1068 |
$el['atts']['vid_src'] .="&mute=1"; |
| 1069 |
}else{ |
| 1070 |
$el['atts']['vid_src'] .="&mute=0"; |
| 1071 |
} |
| 1072 |
|
| 1073 |
if($el['atts']['loop'] == "true"){ |
| 1074 |
$el['atts']['vid_src'] .="&loop=1"; |
| 1075 |
}else{ |
| 1076 |
$el['atts']['vid_src'] .="&loop=0"; |
| 1077 |
} |
| 1078 |
|
| 1079 |
$el['tmp']['ele_id'] = $el['id']; |
| 1080 |
|
| 1081 |
} |
| 1082 |
|
| 1083 |
// Video slider items Handler |
| 1084 |
function pagelayer_sc_video_slider(&$el){ |
| 1085 |
|
| 1086 |
$pager = (!empty($el['atts']['slider_pager']))? 'true': 'false'; |
| 1087 |
$loop = (!empty($el['atts']['slider_loop']))? 'true': 'false'; |
| 1088 |
$autoplay = (!empty($el['atts']['autoplay']) || !($el['atts']['autoplay']))? 'true' : 'false'; |
| 1089 |
$slideshow_speed = intval($el['atts']['slideshow_speed']); |
| 1090 |
$slideshow_start = intval($el['atts']['slideshow_start']); |
| 1091 |
|
| 1092 |
echo "<script type='text/javascript'> |
| 1093 |
jQuery(document).ready(function(){ |
| 1094 |
jQuery('".$el['selector']." .pagelayer-video-slider-holder').slippry({ |
| 1095 |
elements: 'div.pagelayer-video', |
| 1096 |
auto: ".$autoplay.", |
| 1097 |
speed: ".$slideshow_speed.", |
| 1098 |
transition: '".$el['atts']['slider_transition']."', |
| 1099 |
preload: '".$el['atts']['slider_preload']."', |
| 1100 |
pager: ".$pager.", |
| 1101 |
start : ".$slideshow_start.", |
| 1102 |
loop : ".$loop.", |
| 1103 |
|
| 1104 |
}); |
| 1105 |
}); |
| 1106 |
</script>"; |
| 1107 |
} |
| 1108 |
|
| 1109 |
// Splash Handler |
| 1110 |
function pagelayer_sc_splash(&$el){ |
| 1111 |
|
| 1112 |
$delay = intval($el['atts']['delay']); |
| 1113 |
echo '<script type="text/javascript"> |
| 1114 |
jQuery(document).ready(function(){ |
| 1115 |
if("'.$el['atts']['display'].'" == "once"){ |
| 1116 |
|
| 1117 |
if (!sessionStorage.isVisited) { |
| 1118 |
sessionStorage.isVisited = "true"; |
| 1119 |
jQuery("[pagelayer-id='.$el['id'].'] .pagelayer-splash-container").delay('.$delay.').fadeIn(); |
| 1120 |
} |
| 1121 |
}else{ |
| 1122 |
jQuery("[pagelayer-id='.$el['id'].'] .pagelayer-splash-container").delay('.$delay.').fadeIn(); |
| 1123 |
} |
| 1124 |
|
| 1125 |
jQuery("[pagelayer-id='.$el['id'].'] .pagelayer-splash-close").on("click", function(){ |
| 1126 |
jQuery("[pagelayer-id='.$el['id'].'] .pagelayer-splash-container").fadeOut(); |
| 1127 |
}); |
| 1128 |
}); |
| 1129 |
</script>'; |
| 1130 |
|
| 1131 |
} |
| 1132 |
|
| 1133 |
// Shortcodes Handler |
| 1134 |
function pagelayer_sc_shortcodes(&$el){ |
| 1135 |
$el['tmp']['shortcode'] = do_shortcode($el['atts']['data']); |
| 1136 |
} |
| 1137 |
|
| 1138 |
// Shortcodes Handler |
| 1139 |
function pagelayer_sc_wp_widgets(&$el){ |
| 1140 |
|
| 1141 |
global $wp_registered_sidebars; |
| 1142 |
|
| 1143 |
$data = ''; |
| 1144 |
foreach($wp_registered_sidebars as $v){ |
| 1145 |
if($el['atts']['sidebar'] == $v['id']){ |
| 1146 |
ob_start(); |
| 1147 |
dynamic_sidebar($v['id']); |
| 1148 |
$data = ob_get_clean(); |
| 1149 |
} |
| 1150 |
} |
| 1151 |
|
| 1152 |
$el['tmp']['data'] = $data; |
| 1153 |
} |
| 1154 |
|
| 1155 |
// Testimonial Handler |
| 1156 |
function pagelayer_sc_testimonial(&$el){ |
| 1157 |
|
| 1158 |
$el['atts']['func_image'] = @$el['tmp']['avatar-'.$el['atts']['custom_size'].'-url']; |
| 1159 |
$el['atts']['func_image'] = empty($el['atts']['func_image']) ? @$el['tmp']['avatar-full-url'] : $el['atts']['func_image']; |
| 1160 |
|
| 1161 |
if(!empty($image)){ |
| 1162 |
foreach($image as $k => $v){ |
| 1163 |
$el['tmp']['avatar-'.$k] = $v; |
| 1164 |
} |
| 1165 |
} |
| 1166 |
|
| 1167 |
} |
| 1168 |
|
| 1169 |
// Service Handler |
| 1170 |
function pagelayer_sc_service(&$el){ |
| 1171 |
|
| 1172 |
if(!empty($el['atts']['service_image'])){ |
| 1173 |
$el['atts']['func_image'] = @$el['tmp']['service_image-'.$el['atts']['service_image_size'].'-url']; |
| 1174 |
$el['atts']['func_image'] = empty($el['atts']['func_image']) ? @$el['tmp']['service_image-full-url'] : $el['atts']['func_image']; |
| 1175 |
} |
| 1176 |
} |
| 1177 |
|
| 1178 |
/*pagelayer_print($atts); |
| 1179 |
pagelayer_print($content); |
| 1180 |
die();*/ |
| 1181 |
|
| 1182 |
///////////////////////////////////// |
| 1183 |
// Miscellaneous Shortcode Functions |
| 1184 |
///////////////////////////////////// |
| 1185 |
|
| 1186 |
// The font family list |
| 1187 |
function pagelayer_font_family(){ |
| 1188 |
return array( |
| 1189 |
'arial' => 'Arial', |
| 1190 |
'terminal' => 'Terminal' |
| 1191 |
); |
| 1192 |
} |
| 1193 |
|
| 1194 |
// Supported Icons |
| 1195 |
function pagelayer_icon_class_list(){ |
| 1196 |
return array(); |
| 1197 |
} |
| 1198 |
|
| 1199 |
// The types of Posts |
| 1200 |
function pagelayer_post_types($page = false){ |
| 1201 |
|
| 1202 |
// Get the types |
| 1203 |
$args = array('public' => TRUE); |
| 1204 |
$types = get_post_types($args, 'objects'); |
| 1205 |
|
| 1206 |
// Unset Page if not required |
| 1207 |
if($page == false){ |
| 1208 |
unset($types['page']); |
| 1209 |
} |
| 1210 |
|
| 1211 |
// Remove Attachment types ! |
| 1212 |
unset($types['attachment']); |
| 1213 |
|
| 1214 |
foreach($types as $name => $type){ |
| 1215 |
$return[$name] = $type->labels->singular_name; |
| 1216 |
} |
| 1217 |
|
| 1218 |
return $return; |
| 1219 |
} |
| 1220 |
|
| 1221 |
// Get Taxonomies |
| 1222 |
function pagelayer_tax_list($item, $page = false){ |
| 1223 |
|
| 1224 |
// Get types |
| 1225 |
$types = pagelayer_post_types($page); |
| 1226 |
|
| 1227 |
// Loop thru |
| 1228 |
foreach($types as $slug => $label){ |
| 1229 |
|
| 1230 |
// Get the items |
| 1231 |
$items = get_object_taxonomies($slug, 'objects'); |
| 1232 |
|
| 1233 |
foreach($items as $name => $v) { |
| 1234 |
if(!isset($taxonomies[$name])){ |
| 1235 |
$taxonomies[$name] = array('label' => $v->labels->singular_name, 'posttypes' => array($label)); |
| 1236 |
}else{ |
| 1237 |
$taxonomies[$name]['posttypes'][] = $label; |
| 1238 |
} |
| 1239 |
} |
| 1240 |
} |
| 1241 |
|
| 1242 |
// Make it simple |
| 1243 |
foreach($taxonomies as $k => $v){ |
| 1244 |
$taxonomies[$k] = $v['label'].' ('.implode(', ', $v['posttypes']).')'; |
| 1245 |
} |
| 1246 |
|
| 1247 |
$pos = array_search($item, array_keys($taxonomies)); |
| 1248 |
if(!empty($pos)) { |
| 1249 |
$cut = array_splice($taxonomies, $pos, 1); |
| 1250 |
$taxonomies = $cut + $taxonomies; |
| 1251 |
} |
| 1252 |
|
| 1253 |
return $taxonomies; |
| 1254 |
} |
| 1255 |
|
| 1256 |
|