ip_method;
$pagelayer->ip_method = (int) $method;
if(isset($_SERVER["REMOTE_ADDR"])){
$ip = $_SERVER["REMOTE_ADDR"];
}
if(isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && $method == 1){
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
if(isset($_SERVER["HTTP_CLIENT_IP"]) && $method == 2){
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
// Hacking fix for X-Forwarded-For
if(!pagelayer_valid_ip($ip)){
return '';
}
return $ip;
}
// Execute a select query and return an array
function pagelayer_selectquery($query, $array = 0){
global $wpdb;
$result = $wpdb->get_results($query, 'ARRAY_A');
if(empty($array)){
return current($result);
}else{
return $result;
}
}
// Check if an IP is valid
function pagelayer_valid_ip($ip){
// IPv6
if(pagelayer_valid_ipv6($ip)){
return true;
}
// IPv4
if(!ip2long($ip)){
return false;
}
return true;
}
function pagelayer_valid_ipv6($ip){
$pattern = '/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/';
if(!preg_match($pattern, $ip)){
return false;
}
return true;
}
// Check if a field is posted via POST else return default value
function pagelayer_optpost($name, $default = ''){
if(!empty($_POST[$name])){
return pagelayer_inputsec(pagelayer_htmlizer(trim($_POST[$name])));
}
return $default;
}
// Check if a field is posted via GET else return default value
function pagelayer_optget($name, $default = ''){
if(!empty($_GET[$name])){
return pagelayer_inputsec(pagelayer_htmlizer(trim($_GET[$name])));
}
return $default;
}
// Check if a field is posted via GET or POST else return default value
function pagelayer_optreq($name, $default = ''){
if(!empty($_REQUEST[$name])){
return pagelayer_inputsec(pagelayer_htmlizer(trim($_REQUEST[$name])));
}
return $default;
}
// For filling in posted values
function pagelayer_POSTval($name, $default = ''){
return (!empty($_POST) ? (!isset($_POST[$name]) ? '' : esc_html($_POST[$name])) : $default);
}
function pagelayer_POSTchecked($name, $default = false){
return (!empty($_POST) ? (isset($_POST[$name]) ? 'checked="checked"' : '') : (!empty($default) ? 'checked="checked"' : ''));
}
function pagelayer_POSTselect($name, $value, $default = false){
if(empty($_POST)){
if(!empty($default)){
return 'selected="selected"';
}
}else{
if(isset($_POST[$name])){
if(trim($_POST[$name]) == $value){
return 'selected="selected"';
}
}
}
}
function pagelayer_inputsec($string){
$string = addslashes($string);
// This is to replace ` which can cause the command to be executed in exec()
$string = str_replace('`', '\`', $string);
return $string;
}
function pagelayer_htmlizer($string){
$string = htmlentities($string, ENT_QUOTES, 'UTF-8');
preg_match_all('/(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)/', $string, $matches);//r_print($matches);
foreach($matches[1] as $mk => $mv){
$tmp_m = pagelayer_entity_check($matches[2][$mk]);
$string = str_replace($matches[1][$mk], $tmp_m, $string);
}
return $string;
}
function pagelayer_entity_check($string){
//Convert Hexadecimal to Decimal
$num = ((substr($string, 0, 1) === 'x') ? hexdec(substr($string, 1)) : (int) $string);
//Squares and Spaces - return nothing
$string = (($num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num < 0x20) ? '' : ''.$num.';');
return $string;
}
// Check if a checkbox is selected
function pagelayer_is_checked($post){
if(!empty($_POST[$post])){
return true;
}
return false;
}
// Report an error
function pagelayer_report_error($error = array()){
if(empty($error)){
return true;
}
$error_string = 'Please fix the below error(s) : ';
foreach($error as $ek => $ev){
$error_string .= '* '.$ev.' ';
}
echo '
'
. __pl($error_string)
. '
';
}
// Report a notice
function pagelayer_report_notice($notice = array()){
global $wp_version;
if(empty($notice)){
return true;
}
// Which class do we have to use ?
if(version_compare($wp_version, '3.8', '<')){
$notice_class = 'updated';
}else{
$notice_class = 'updated';
}
$notice_string = 'Please check the below notice(s) : ';
foreach($notice as $ek => $ev){
$notice_string .= '* '.$ev.' ';
}
echo '
';
}
function pagelayer_cleanpath($path){
$path = str_replace('\\\\', '/', $path);
$path = str_replace('\\', '/', $path);
$path = str_replace('//', '/', $path);
return rtrim($path, '/');
}
// Returns the Numeric Value of results Per Page
function pagelayer_get_page($get = 'page', $resperpage = 50){
$resperpage = (!empty($_REQUEST['reslen']) && is_numeric($_REQUEST['reslen']) ? (int) pagelayer_optreq('reslen') : $resperpage);
if(pagelayer_optget($get)){
$pg = (int) pagelayer_optget($get);
$pg = $pg - 1;
$page = ($pg * $resperpage);
$page = ($page <= 0 ? 0 : $page);
}else{
$page = 0;
}
return $page;
}
// Are we editing from the Admin panel ?
function pagelayer_is_editing($force = false){
global $post, $pagelayer;
if(!empty($force)){
return true;
}
if(!is_admin()){
return false;
}
$current_file = basename($_SERVER['PHP_SELF']);
$type = get_post_type();
//echo $type;return false;
//$page = pagelayer_optreq('page');
// Are we in the live editor mode OR is this a post which is supported
if((pagelayer_supported_type($type) && in_array($current_file, array('post.php', 'post-new.php'))) || pagelayer_is_live()){
return true;
}else{
return false;
}
}
// Is the given post type editable by us ?
function pagelayer_supported_type($type){
global $pagelayer;
$type = trim($type);
if(in_array($type, $pagelayer->settings['post_types'])){
return true;
}
return false;
}
function pagelayer_shortlink($id){
$post = get_post( $id );
if ( ! empty( $post->ID ) ) {
$post_id = $post->ID;
}
$post_type = get_post_type_object( $post->post_type );
if ( 'page' === $post->post_type && get_option( 'page_on_front' ) == $post->ID && 'page' === get_option( 'show_on_front' ) ) {
$link = home_url( '/' );
} elseif ( $post_type->public ) {
$link = home_url( '?p=' . $post_id );
}
if(function_exists('is_post_status_viewable') && !is_post_status_viewable($post_id)){
$link = get_permalink( $post->ID );
}
$link .= substr_count($link, '?') > 0 ? '' : '?';
return $link;
}
// Pagelayer live link
function pagelayer_livelink($id){
return pagelayer_shortlink($id).'&pagelayer-live=1';
}
// Are we in live mode ?
function pagelayer_is_live(&$error = array()){
global $post;
// Are we seeing the post ?
if(!isset($post) || !isset($post->ID) || empty($post->ID)){
$error[] = 'Post ID is missing or blank - '.@$post->ID;
return false;
}
$parID = $post->ID;
// Is revision?
if(wp_is_post_revision($post->ID) ){
$parID = wp_get_post_parent_id($post->ID);
}
// Are you allowed to edit ?
if(!pagelayer_user_can_edit($parID)){
$error[] = 'You dont have editing rights for this page - '.$parID;
return false;
}
// Is it the live mode ?
if(pagelayer_optreq('pagelayer-live')){
$error[] = 'pagelayer-live is missing';
return true;
}
return false;
}
// Are we in live IFRAME mode ?
function pagelayer_is_live_iframe(&$error = array()){
// Are we seeing the post ?
if(!pagelayer_is_live($error)){
return false;
}
// Is it the live mode ?
if(pagelayer_optreq('pagelayer-iframe')){
return true;
}
$error[] = 'pagelayer-iframe missing in GET';
return false;
}
// Are we editing a live template
function pagelayer_is_live_template($post = []){
// Are we seeing the post ?
if(!pagelayer_is_live()){
return false;
}
if(!$post){
$post = $GLOBALS['post'];
}
if($post->post_type == 'pagelayer-template'){
return true;
}
return false;
}
// Can the current user edit the post ?
function pagelayer_user_can_edit($post = NULL){
global $wp_the_query, $current_user, $pagelayer;
$post = get_post($post);
if(empty($post)){
return false;
}
// No trash editing
if(get_post_status($post->ID) === 'trash'){
return false;
}
// Is pagelayer supposed to edit this ?
if(!in_array($post->post_type, $pagelayer->settings['post_types']) && $post->post_type != 'pagelayer-template'){
return false;
}
// Get the post type object
$object = get_post_type_object($post->post_type);
// Is this type editable by the user ?
if(!current_user_can($object->cap->edit_posts)){
return false;
}
// Is this type editable ?
if(!isset($object->cap->edit_post)){
return false;
}
// Can this user edit the post type ?
if(!current_user_can($object->cap->edit_post, $post->ID)){
return false;
}
// Page for blogs not allowed
if(get_option('page_for_posts') === $post->ID){
return false;
}
return true;
}
// Language sting function
function __pl($key){
global $pagelayer;
if(!empty($pagelayer->l[$key])){
return $pagelayer->l[$key];
}
return $key;
}
// Give the list of icon sources
function pagelayer_icon_sources(){
return array();
}
// Sets the memory limit
function pagelayer_memory_limit($mb){
$bytes = ($mb * 1024 * 1024);
$mb_str = (string) $mb.'M';
// Some servers might have ini_get disabled
if(function_exists('ini_get')){
$memory_limit = @ini_get('memory_limit');
}
if(empty($memory_limit)){
return;
}
$memory_limit_bytes = (strpos($memory_limit, 'M') ? (intval($memory_limit) * 1024 * 1024) : intval($memory_limit));
//$memory_limit_bytes > 0 is for memory limit = -1
if($memory_limit_bytes <= $bytes && $memory_limit_bytes > 0){
// Some servers might have ini_set disabled
if(function_exists('ini_set')){
@ini_set('memory_limit', $mb_str);
}
}
}
// Pagelayer the content
function pagelayer_the_content($content, $dump = false){
global $pagelayer;
$content = pagelayer_sanitize_content( $content );
$content = do_blocks( $content );
$content = do_shortcode( $content );
if($dump){
preg_match_all('/
]*)pagelayer-id="([^"]*)"([^>]*)>/', $content, $matches);
foreach($matches[0] as $k => $div){
$id = $matches[2][$k];
if(empty($pagelayer->data_attr[$id])){
continue;
}
$data_attr = '';
$content = str_replace($div, $div.$data_attr, $content);
}
}
return $content;
}
function pagelayer_create_id(){
return pagelayer_RandomString(3).rand(1000, 9999);
}
// Loads the shortcodes
function pagelayer_load_shortcodes(){
global $pagelayer, $post;
if(!empty($pagelayer->shortcode_loaded)){
return;
}
pagelayer_memory_limit(128);
// We have loaded
$pagelayer->shortcode_loaded = 1;
// pQuery
include_once(PAGELAYER_DIR.'/lib/pquery/IQuery.php');
include_once(PAGELAYER_DIR.'/lib/pquery/gan_formatter.php');
include_once(PAGELAYER_DIR.'/lib/pquery/gan_node_html.php');
include_once(PAGELAYER_DIR.'/lib/pquery/gan_tokenizer.php');
include_once(PAGELAYER_DIR.'/lib/pquery/gan_parser_html.php');
include_once(PAGELAYER_DIR.'/lib/pquery/gan_selector_html.php');
include_once(PAGELAYER_DIR.'/lib/pquery/gan_xml2array.php');
include_once(PAGELAYER_DIR.'/lib/pquery/pQuery.php');
include_once(PAGELAYER_DIR.'/main/shortcode_functions.php');
if(defined('PAGELAYER_PREMIUM')){
include_once(PAGELAYER_DIR.'/main/freemium_functions.php');
include_once(PAGELAYER_DIR.'/main/premium_functions.php');
}
include_once(PAGELAYER_DIR.'/main/shortcodes.php');
// Apply filter to load custom widgets
do_action('pagelayer_load_custom_widgets');
// Render Pagelayer element by blocks
add_action('pre_render_block', 'pagelayer_render_blocks', 10, 2);
// Add global widget data
if(defined('PAGELAYER_PREMIUM')){
// Get global widget templates id by type
$args = [
'post_type' => $pagelayer->builder['name'],
'status' => 'publish',
'meta_key' => 'pagelayer_template_type',
'meta_value' => array('global_widget', 'section', 'global_section'),
'posts_per_page' => -1
];
$query = new WP_Query($args);
$tmp_list = [];
$global_widgets = array();
$global_widgets['global_widget'] = array();
$global_widgets['section'] = array();
$global_widgets['global_section'] = array();
foreach($query->posts as $template){
// The type
$pagelayer_template_type = get_post_meta($template->ID, 'pagelayer_template_type', true);
$global_data = [];
$global_data['post_id'] = $template->ID;
$global_data['title'] = $template->post_title;
$global_data['$'] = pagelayer_the_content($template->post_content, true);
$global_widgets[$pagelayer_template_type][$template->ID] = $global_data;
}
$pagelayer->global_widgets = $global_widgets['global_widget'];
$pagelayer->saved_sections = $global_widgets['section'];
$pagelayer->global_sections = $global_widgets['global_section'];
}
}
// Add the shortcodes to the pagelayer list
function pagelayer_add_shortcode($tag, $params = array()){
global $pagelayer, $post;
if($tag == 'pl_row'){
$inner_tag = 'pl_inner_row';
add_shortcode($inner_tag, 'pagelayer_render_shortcode');
}
if($tag == 'pl_col'){
$inner_tag = 'pl_inner_col';
add_shortcode($inner_tag, 'pagelayer_render_shortcode');
}
add_shortcode($tag, 'pagelayer_render_shortcode');//$params['func']);
//unset($params['func']);
// Is there a group ?
if(empty($params['group'])){
$params['group'] = 'misc';
}
// Add the advanced styling group
$params['options'] = [
'ele_bg_styles' => __pl('ele_bg_styles'),
'ele_styles' => __pl('ele_styles'),
'border_styles' => __pl('border_styles'),
'font_style' => __pl('font_style'),
'position_styles' => __pl('position_styles'),
'animation_styles' => __pl('animation_styles'),
'motion_effects' => __pl('Motion Effects'),
'responsive_styles' => __pl('responsive_styles'),
'attributes' => __pl('Attributes'),
'custom_styles' => __pl('custom_styles'),
];
if(!empty($params['skip_props_cat'])){
foreach($params['skip_props_cat'] as $k => $v){
unset($params['options'][$v]);
}
}
// Are the settings there which hold the params ?
if(empty($params['settings'])){
$params['settings'] = [
'params' => $params['name'],
];
}
// Disable the style options
if(!empty($params['styles'])){
$params['settings'] = array_merge($params['settings'], $params['styles']);
unset($params['styles']);
}
/*// The following is for testing only
$r = [];
foreach($pagelayer->styles as $k => $v){
foreach($v as $kk => $vv){
$r[$kk] = $kk;
}
}
//print_r($r);die();
foreach($params['settings'] as $k => $v){
if(empty($params[$k])) continue;
foreach($params[$k] as $kk => $vv){
if(!empty($r[$kk])){
echo 'Duplicate KEY '.$kk.' in Shortcode '.$tag." ";
}
}
}
//die();*/
$params = apply_filters( 'pagelayer_shortcode_params', $params, $tag );
// Insert the shortcode
$pagelayer->shortcodes[$tag] = $params;
$pagelayer->groups[$params['group']][] = $tag;
// Export the default values
foreach($pagelayer->tabs as $tab){
if(empty($pagelayer->shortcodes[$tag][$tab])){
continue;
}
foreach($pagelayer->shortcodes[$tag][$tab] as $section => $Lsection){
$props = empty($pagelayer->shortcodes[$tag][$section]) ? @$pagelayer->styles[$section] : @$pagelayer->shortcodes[$tag][$section];
//echo $tab.' - '.$section.' - ';
if(empty($props)){
continue;
}
foreach($props as $prop => $param){
if(isset($param['export-def']) && isset($param['default']) && $param['export-def'] == 1)
// Set default values to export for JS
$pagelayer->default_params[$tag][$prop] = $param['default'];
}
}
}
}
// Add a freemium shortcode i.e. available for render, but not to drag or edit
function pagelayer_freemium_shortcode($tag, $params = array()){
// If we are the free version, we just allow render and some edits
if(!defined('PAGELAYER_PREMIUM')){
$params['not_visible'] = 1;
$params['freemium'] = 1;
$cats = empty($params['styles']) ? array() : $params['styles'];
if(!empty($params['settings'])){
$cats = array_merge($cats, $params['settings']);
}
$cats['params'] = $params['name'];
//pagelayer_print($cats);
foreach($cats as $k => $v){
if(empty($params[$k])) continue;
foreach($params[$k] as $kk => $vv){
if(empty($params[$k][$kk]['np'])){
$params[$k][$kk]['pro'] = 1;
}
}
}
}
return pagelayer_add_shortcode($tag, $params);
}
// Returns the permalink values
function pagelayer_permalink($id){
if(is_numeric($id)){
$id = (int) @$id;
$perma = get_permalink($id);
if(!empty($perma)){
$id = $perma;
}
}
$id = apply_filters('pagelayer_permalink', $id);
return $id;
}
// Returns the Image values
function pagelayer_image($id = 0){
global $pagelayer;
$ret = [];
// External image ?
if(pagelayer_is_external_img($id)){
$ret['url'] = $id;
// Attachment
}elseif(!empty($id)){
$id = (int) @$id;
$image = get_post($id);
// Is there an attachment which is an image ?
if(!empty($image) && $image->post_type == 'attachment' && wp_attachment_is_image($id)){
// Need to export necessary media
if(!empty($pagelayer->export_mode)){
$pagelayer->media_to_export[] = $id;
}
$sizes = get_intermediate_image_sizes();
array_unshift($sizes, 'full');
foreach($sizes as $size){
$src = wp_get_attachment_image_src($id, $size);
$ret[$size.'-url'] = $src[0];
}
// Title and Alt
$title = esc_attr($image->post_title);
$alt = get_post_meta($id, '_wp_attachment_image_alt', true);
$alt = empty($alt) ? $image->post_excerpt : $alt;
$alt = empty($alt) ? $image->post_title : $alt;
$alt = empty($alt) ? '' : trim(strip_tags($alt));
$link = get_attachment_link($id);
$caption = wp_get_attachment_caption($id);
$caption = !empty($caption) ? $caption : '';
}
}
// First preference to full url
if(!empty($ret['full-url'])){
$ret['url'] = $ret['full-url'];
}
// No image
if(empty($ret['url'])){
$ret['url'] = PAGELAYER_URL.'/images/default-image.png';
}
$ret['alt'] = @$alt;
$ret['title'] = @$title;
$ret['link'] = @$link;
$ret['caption'] = @$caption;
$ret = apply_filters('pagelayer_image', $ret);
if(pagelayer_is_default_img($ret['url'])){
$ret['no-image-set'] = 1;
}
return $ret;
}
// Checks if the given parameter is an external link or a wp attachment id
function pagelayer_is_external_img($img = ''){
if(empty($img)){
return false;
}
if(preg_match('#http://#is', $img) || preg_match('#https://#is', $img) || preg_match('#^{{#is', $img)){
return true;
}
return false;
}
// Checks if the given parameter is the default image
function pagelayer_is_default_img($img){
if($img == PAGELAYER_URL.'/images/default-image.png'){
return true;
}
return false;
}
// Returns the attachment url
function pagelayer_attachment($id){
$ret = [];
// External url ?
if(pagelayer_is_external_img($id)){
$ret['url'] = $id;
// Attachment
}elseif(!empty($id)){
// Need to export necessary media
if(!empty($pagelayer->export_mode)){
$pagelayer->media_to_export[] = $id;
}
$ret['url'] = wp_get_attachment_url($id);
}
$ret = apply_filters('pagelayer_attachment', $ret);
return $ret;
}
// Convert the regular URL of a Video to a Embed URL
// Todo : Check
function pagelayer_video_url($source){
if (!empty($source)) {
$source = esc_url( $source );
$source = str_replace('&', '&', $source);
$url = parse_url($source);
$videoSite ='';
$youtubeRegExp = '/youtube\.com|youtu\.be/is';
$vimeoRegExp = '/vimeo\.com/is';
if (preg_match($youtubeRegExp, $source)) {
$videoSite = 'youtube';
} else if (preg_match($vimeoRegExp, $source)) {
$videoSite = 'vimeo';
}
switch ($videoSite) {
case 'youtube':
if (preg_match('/youtube\.com/is', $source)) {
if (preg_match('/watch/is', $source)) {
parse_str($url['query'], $parameters);
if (isset($parameters['v']) && !empty($parameters['v'])) {
$videoId = $parameters['v'];
}
} else if (preg_match('/embed/is', $url['path'])) {
$path = explode('/', $url['path']);
if (isset($path[2]) && !empty($path[2])) {
$videoId = $path[2];
}
}
} else if (preg_match('/youtu\.be/is', $url['host'])) {
$path = explode('/', $url['path']);
if (isset($path[1]) && !empty($path[1])) {
$videoId = $path[1];
}
}
return '//youtube.com/embed/'.$videoId;
break;
case 'vimeo':
if (preg_match('/player\.vimeo\.com/is', $url['host']) && preg_match('/video/is', $url['path'])) {
$path = explode('/', $url['path']);
if (isset($path[2]) && !empty($path[2])) {
$videoId = $path[2];
}
} else if (preg_match('/vimeo\.com/is', $url['host'])) {
$path = explode('/', $url['path']);
if (isset($path[1]) && !empty($path[1])) {
$videoId = $path[1];
}
}
return '//player.vimeo.com/video/'.$videoId;
break;
default:
return $source;
}
}
}
// As per the JS specification
function pagelayer_escapeHTML($str){
$replace = [
']' => ']',
'[' => '[',
//'=' => '=',
'<' => '<',
'>' => '>',
'"' => '"',
//'&' => '&',
'\'' => ''',
'\\' => '\'
];
$str = str_replace(array_keys($replace), array_values($replace), $str);
return $str;
}
// As per the JS specification
function pagelayer_unescapeHTML($str){
$replace = [
'#93' => ']',
'#91' => '[',
//'#61' => '=',
'lt' => '<',
'gt' => '>',
'quot' => '"',
//'amp' => '&',
'#39' => '\'',
'#92' => '\\'
];
foreach($replace as $k => $v){
$str = str_replace('&'.$k.';', $v, $str);
}
return $str;
}
// Check for XSS codes in our shortcodes submitted
function pagelayer_xss_content($data){
$data = pagelayer_unescapeHTML($data);
$data = preg_split('/\s/', $data);
$data = implode('', $data);
//echo $data;
if(preg_match('/["\']javascript\:/is', $data)){
return 'javascript';
}
if(preg_match('/["\']vbscript\:/is', $data)){
return 'vbscript';
}
if(preg_match('/\-moz\-binding\:/is', $data)){
return '-moz-binding';
}
if(preg_match('/expression\(/is', $data)){
return 'expression';
}
if(preg_match('/\<(iframe|frame|script|style|link|applet|embed|xml|svg|object|layer|ilayer|meta)/is', $data, $matches)){
return $matches[1];
}
$not_allowed = array('onclick', 'ondblclick', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onload', 'onunload', 'onchange', 'onsubmit', 'onreset', 'onselect', 'onblur', 'onfocus', 'onkeydown', 'onkeypress', 'onkeyup', 'onafterprint', 'onbeforeprint', 'onbeforeunload', 'onerror', 'onhashchange', 'onmessage', 'onoffline', 'ononline', 'onpagehide', 'onpageshow', 'onpopstate', 'onresize', 'onstorage', 'oncontextmenu', 'oninput', 'oninvalid', 'onsearch', 'onkeydown', 'onmousewheel', 'onwheel', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onscroll', 'oncopy', 'oncut', 'onpaste', 'onabort', 'oncanplay', 'oncanplaythrough', 'oncuechange', 'ondurationchange', 'onemptied', 'onended', 'onloadeddata', 'onloadedmetadata', 'onloadstart', 'onpause', 'onplay', 'onplaying', 'onprogress', 'onratechange', 'onseeked', 'onseeking', 'onstalled', 'onsuspend', 'ontimeupdate', 'onvolumechange', 'onwaiting', 'ontoggle');
$not_allowed = implode('|', $not_allowed);
if(preg_match('/('.($not_allowed).')=/is', $data, $matches)){
return $matches[1];
}
return;
}
function pagelayer_getting_started_notice(){
// Is Sitepad setup done?
$setup_done = get_option('sp_setup_done');
if(defined('SITEPAD') && empty($setup_done)){
return;
}
// If SitePad used custom BRAND SM
if(defined('BRAND_SM_CUSTOM')){
return;
}
echo '
';
if(defined('SITEPAD')){
echo ''.__('Thanks for choosing '.BRAND_SM .'. We recommend that you see the short and sweet Getting Started Video to know the basics of '.BRAND_SM.'.');
}else{
echo ''.__('Thanks for choosing Pagelayer. We recommend that you see the short and sweet Getting Started Video to know the basics of Pagelayer.', 'pagelayer');
}
echo '
';
}
// Show promo notice on dashboard
function pagelayer_show_promo(){
global $pagelayer_promo_opts;
$opts = $pagelayer_promo_opts;
echo '
Pagelayer Pro has many more features like 60+ widgets, 400+ sections, Theme Builder, WooCommerce Builder, Theme Creator and Exporter, Form Builder, Popup Builder, etc.';
if(date('Ymd') <= 20200331){
echo ' Promotional Offer : If you buy Pagelayer Pro before 31st March, 2020 then you will get an additional year free and your license will expire on 31st March, 2022.';
}
echo '
';
}
// Are we to show a promo ?
function pagelayer_maybe_promo($opts){
global $pagelayer_promo_opts;
// There must be an interval
if(empty($opts['interval'])){
return false;
}
// Are we to show a promo
$opt_name = 'pagelayer_promo_time';
$promo_time = get_option($opt_name);
// First time access
if(empty($promo_time)){
update_option($opt_name, time() + (!empty($opts['after']) ? $opts['after'] * 86400 : 0));
$promo_time = get_option($opt_name);
}
// Is there interval elapsed
if(time() > $promo_time){
$pagelayer_promo_opts = $opts;
add_action('admin_notices', 'pagelayer_show_promo');
}
// Are we to disable the promo
if(isset($_GET['pagelayer_promo']) && (int)$_GET['pagelayer_promo'] == 0){
update_option($opt_name, time() + ($opts['interval'] * 86400));
die('DONE');
}
}
// Show the Pro notice
function pagelayer_show_pro_notice(){
if(defined('PAGELAYER_PREMIUM')){
return;
}
echo '
'.__('This feature is a part of Pagelayer Pro. You will need to purchase Pagelayer Pro to use this feature.').'
';
}
// Show the Pro Div
function pagelayer_show_pro_div($head = '', $message = '', $admin_css = 1){
if(defined('PAGELAYER_PREMIUM')){
return;
}
if(basename(get_template_directory()) == 'popularfx'){
$pro_url = 'https://popularfx.com/pricing?from=pagelayer-plugin';
$pro_txt = 'PopularFX Pro';
}else{
$pro_url = PAGELAYER_PRO_URL;
$pro_txt = 'Pagelayer Pro';
}
if(!empty($admin_css)){
wp_enqueue_style( 'pagelayer-admin', PAGELAYER_CSS.'/pagelayer-admin.css', array(), PAGELAYER_VERSION);
}
echo '
';
if(!empty($head)){
echo '
'.$head.'
';
}
echo '
';
if(empty($message)){
echo __('This feature is a part of '.$pro_txt.'. You will need to purchase '.$pro_txt.' to use this feature.');
}else{
echo $message;
echo ' '.__('This feature is a part of '.$pro_txt.'.');
}
echo '