| 1 |
<?php |
| 2 |
|
| 3 |
////////////////////////////////////////////////////////////// |
| 4 |
//=========================================================== |
| 5 |
// PAGELAYER |
| 6 |
// Inspired by the DESIRE to be the BEST OF ALL |
| 7 |
// ---------------------------------------------------------- |
| 8 |
// Started by: Pulkit Gupta |
| 9 |
// Date: 23rd Jan 2017 |
| 10 |
// Time: 23:00 hrs |
| 11 |
// Site: http://pagelayer.com/wordpress (PAGELAYER) |
| 12 |
// ---------------------------------------------------------- |
| 13 |
// Please Read the Terms of use at http://pagelayer.com/tos |
| 14 |
// ---------------------------------------------------------- |
| 15 |
//=========================================================== |
| 16 |
// (c)Pagelayer Team |
| 17 |
//=========================================================== |
| 18 |
////////////////////////////////////////////////////////////// |
| 19 |
|
| 20 |
// Are we being accessed directly ? |
| 21 |
if(!defined('PAGELAYER_VERSION')) { |
| 22 |
exit('Hacking Attempt !'); |
| 23 |
} |
| 24 |
|
| 25 |
function pagelayer_do_shortcode_to_block( $content, $ignore_html = false ) { |
| 26 |
global $shortcode_tags; |
| 27 |
|
| 28 |
if ( false === strpos( $content, '[' ) ) { |
| 29 |
return $content; |
| 30 |
} |
| 31 |
|
| 32 |
// Find all registered tag names in $content. |
| 33 |
preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); |
| 34 |
$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); |
| 35 |
|
| 36 |
if( empty( $tagnames ) ){ |
| 37 |
return $content; |
| 38 |
} |
| 39 |
|
| 40 |
$content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ); |
| 41 |
|
| 42 |
$pattern = get_shortcode_regex( $tagnames ); |
| 43 |
$content = preg_replace_callback( "/$pattern/", 'pagelayer_do_shortcode_tag', $content ); |
| 44 |
|
| 45 |
return $content; |
| 46 |
} |
| 47 |
|
| 48 |
function pagelayer_do_shortcode_tag($m){ |
| 49 |
|
| 50 |
// Allow [[foo]] syntax for escaping a tag. |
| 51 |
if ( '[' === $m[1] && ']' === $m[6] ) { |
| 52 |
return substr( $m[0], 1, -1 ); |
| 53 |
} |
| 54 |
|
| 55 |
$tag = $m[2]; |
| 56 |
$attr = shortcode_parse_atts( $m[3] ); |
| 57 |
$content = isset( $m[5] ) ? $m[5] : null; |
| 58 |
|
| 59 |
$output = $m[1] . pagelayer_shortcode_to_block( $attr, $content, $tag ) . $m[6]; |
| 60 |
|
| 61 |
return $output; |
| 62 |
} |
| 63 |
|
| 64 |
function pagelayer_shortcode_to_block($attr, $content, $tag){ |
| 65 |
|
| 66 |
if($tag == 'pl_post_props'){ |
| 67 |
return ''; |
| 68 |
} |
| 69 |
|
| 70 |
if($tag == 'pl_inner_col'){ |
| 71 |
$tag = 'pl_col'; |
| 72 |
} |
| 73 |
|
| 74 |
if($tag == 'pl_inner_row'){ |
| 75 |
$tag = 'pl_row'; |
| 76 |
} |
| 77 |
|
| 78 |
$block_name = 'pagelayer/'.str_replace('_', '-', $tag); |
| 79 |
|
| 80 |
$func = 'pagelayer_fix_block_'.$tag; |
| 81 |
|
| 82 |
// Is there a function of the tag ? |
| 83 |
if(function_exists($func)){ |
| 84 |
call_user_func_array($func, array(&$block_name, &$attr, &$content)); |
| 85 |
} |
| 86 |
|
| 87 |
$content = pagelayer_do_shortcode_to_block($content); |
| 88 |
|
| 89 |
return get_comment_delimited_block_content( $block_name, $attr, $content ); |
| 90 |
} |
| 91 |
|
| 92 |
function pagelayer_fix_block_pl_accordion_item(&$block_name, &$attr, &$content){ |
| 93 |
|
| 94 |
if(pagelayer_has_blocks($content) || false !== strpos( $content, '[pl_' )){ |
| 95 |
return; |
| 96 |
} |
| 97 |
|
| 98 |
pagelayer_content_to_block($content); |
| 99 |
} |
| 100 |
|
| 101 |
function pagelayer_content_to_block(&$content){ |
| 102 |
|
| 103 |
$content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-row {"stretch":"auto"} --> |
| 104 |
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-col {"overlay_hover_delay":"400"} --> |
| 105 |
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-text -->'.$content.'<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-text --> |
| 106 |
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-col --> |
| 107 |
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-row -->'; |
| 108 |
} |