static function createStyleAttribute($style) { $ret = null; $Validation = new PBValidation(); foreach ($style as $index => $value) { if ($Validation->isEmpty($value)) { continue; } $ret .= $index . ':' . $value . ';'; } return $Validation->isEmpty($ret) ? null : ' style="' . $ret . '"'; }
function processShortcodeRedirect($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $Validation = new PBValidation(); if ($Validation->isEmpty($attribute['url']) && $Validation->isEmpty($attribute['post_id'])) { return; } $url = $Validation->isEmpty($attribute['url']) ? get_permalink($attribute['post_id']) : $attribute['url']; ob_start(); wp_redirect($url, $attribute['status']); ob_end_flush(); exit; }
function processShortcodeCounterListItem($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); if ($Validation->isEmpty($attribute['name'])) { return $html; } if (!$Validation->isNumber($attribute['value'], 0, 99999, false)) { return $html; } $lineCharacterAfter = null; $lineCharacterBefore = null; if ($Validation->isNotEmpty($this->character['before'])) { $lineCharacterBefore = '<span' . PBHelper::createClassAttribute(array('pb-counter-list-value-character-before')) . '>' . esc_html($this->character['before']) . '</span>'; } if ($Validation->isNotEmpty($this->character['after'])) { $lineCharacterAfter = '<span' . PBHelper::createClassAttribute(array('pb-counter-list-value-character-after')) . '>' . esc_html($this->character['after']) . '</span>'; } $html = ' <li class="pb-value-' . (int) $attribute['value'] . '"> <span class="pb-counter-list-label">' . esc_html($attribute['name']) . '</span> <span class="pb-counter-list-value"> ' . $lineCharacterBefore . ' <span class="pb-counter-list-value-value">' . (int) $attribute['value'] . '</span> ' . $lineCharacterAfter . ' </span> <span class="pb-counter-list-foreground"></span> <span class="pb-counter-list-background"></span> </li> '; return PBHelper::formatHTML($html); }
function processShortcodeHeaderSubheaderSubheader($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $style = array(); $Font = new PBFont(); $Header = new PBHeader(); $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } if (!array_key_exists($attribute['important'], $Header->important)) { return $html; } if ($Validation->isNumber($attribute['font_size'], 1, 200, true)) { $style['font-size'] = $attribute['font_size'] . 'px'; } if (array_key_exists($attribute['font_weight'], $Font->weight)) { $style['font-weight'] = $attribute['font_weight']; } if (array_key_exists($attribute['font_style'], $Font->style)) { $style['font-style'] = $attribute['font_style']; } if ($Validation->isColor($attribute['font_color'])) { $style['color'] = PBColor::getColor($attribute['font_color']); } if ($Validation->isNotEmpty($attribute['line_height'])) { $style['line-height'] = $attribute['line_height']; } $class = array(array('pb-subheader'), array('pb-subheader-content')); $html = '<h' . (int) $attribute['important'] . PBHelper::createClassAttribute($class[0]) . PBHelper::createStyleAttribute($style) . '><span' . PBHelper::createClassAttribute($class[1]) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '</span></h' . (int) $attribute['important'] . '>'; return PBHelper::formatHTML($html, $content); }
function processAttribute($shortcode, $attr) { $default = array(); $Validation = new PBValidation(); $repeat = 1; $shortcode = str_replace(PLUGIN_PAGE_BUILDER_SHORTCODE_PREFIX . $this->getComponentId(), '', $shortcode, $repeat); if (mb_substr($shortcode, 0, 1) == '_') { $shortcode = mb_substr($shortcode, 1); } foreach ($this->component['structure']['element'] as $element) { $path = mb_split('/', preg_replace('/\\*/', '', $element['shortcode']['path'])); $count = count($path); if (!(mb_substr($path[$count - 1], 0, 1) == '@' && $path[$count - 1] != '@content')) { continue; } $name = mb_substr($path[$count - 1], 1); if ($name == 'param') { $name = $element['id']; } if ($count == 1) { if ($Validation->isEmpty($shortcode)) { $default[$name] = $element['shortcode']['default']; } } else { if ($shortcode == $path[$count - 2]) { $default[$name] = $element['shortcode']['default']; } } } return shortcode_atts($default, $attr); }
function processShortcodeIframe($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $Validation = new PBValidation(); if ($Validation->isEmpty($attribute['src'])) { return null; } $style = array(array(), array()); if ((int) $attribute['width'] > 0) { $style[0]['width'] = (int) $attribute['width'] . 'px'; } if ((int) $attribute['height'] > 0) { $style[1]['height'] = (int) $attribute['height'] . 'px'; $style[1]['padding-bottom'] = '0px'; } $class = array(array('pb-iframe', $attribute['css_class']), array('pb-iframe-content')); $html = ' <div' . PBHelper::createClassAttribute($class[0]) . PBHelper::createStyleAttribute($style[0]) . '> <div' . PBHelper::createClassAttribute($class[1]) . PBHelper::createStyleAttribute($style[1]) . '> <iframe src="' . esc_attr($attribute['src']) . '"></iframe> </div> </div> '; return PBHelper::formatCode($html); }
function processShortcodeVerticalGrid($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); $this->lineNumber = 0; $this->lineStyle = array('even' => array('name' => null, 'value' => null), 'odd' => array('name' => null, 'value' => null)); if ($Validation->isEmpty($content)) { return $html; } $style = array(); if ($Validation->isNumber($attribute['column_name_width'], 1, 100)) { $style['odd']['name']['width'] = $attribute['column_name_width'] . '%'; $style['even']['name']['width'] = $attribute['column_name_width'] . '%'; } if ($Validation->isNumber($attribute['column_value_width'], 1, 100)) { $style['odd']['value']['width'] = $attribute['column_value_width'] . '%'; $style['even']['value']['width'] = $attribute['column_value_width'] . '%'; } if ($Validation->isColor($attribute['line_even_column_name_text_color'])) { $style['even']['name']['color'] = PBColor::getColor($attribute['line_even_column_name_text_color']); } if ($Validation->isColor($attribute['line_even_column_value_text_color'])) { $style['even']['value']['color'] = PBColor::getColor($attribute['line_even_column_value_text_color']); } if ($Validation->isColor($attribute['line_even_column_name_bg_color'])) { $style['even']['name']['background-color'] = PBColor::getColor($attribute['line_even_column_name_bg_color']); } if ($Validation->isColor($attribute['line_even_column_value_bg_color'])) { $style['even']['value']['background-color'] = PBColor::getColor($attribute['line_even_column_value_bg_color']); } if ($Validation->isColor($attribute['line_odd_column_name_text_color'])) { $style['odd']['name']['color'] = PBColor::getColor($attribute['line_odd_column_name_text_color']); } if ($Validation->isColor($attribute['line_odd_column_value_text_color'])) { $style['odd']['value']['color'] = PBColor::getColor($attribute['line_odd_column_value_text_color']); } if ($Validation->isColor($attribute['line_odd_column_name_bg_color'])) { $style['odd']['name']['background-color'] = PBColor::getColor($attribute['line_odd_column_name_bg_color']); } if ($Validation->isColor($attribute['line_odd_column_value_bg_color'])) { $style['odd']['value']['background-color'] = PBColor::getColor($attribute['line_odd_column_value_bg_color']); } $this->lineStyle['even']['name'] = PBHelper::createStyleAttribute($style['even']['name']); $this->lineStyle['even']['value'] = PBHelper::createStyleAttribute($style['even']['value']); $this->lineStyle['odd']['name'] = PBHelper::createStyleAttribute($style['odd']['name']); $this->lineStyle['odd']['value'] = PBHelper::createStyleAttribute($style['odd']['value']); $class = array('pb-vertical-grid', 'pb-clear-fix', $attribute['css_class']); $html = ' <div' . PBHelper::createClassAttribute($class) . '> <ul' . PBHelper::createClassAttribute(array('pb-reset-list')) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '</ul> </div> '; return PBHelper::formatHTML($html, PBHelper::formatContent($content, true, false, false)); }
function processShortcodeRedirect($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $Validation = new PBValidation(); if ($Validation->isEmpty($attribute['url']) && $Validation->isEmpty($attribute['post_id'])) { return; } if ($Validation->isEmpty($attribute['url'])) { if ($Validation->isNumber($attribute['post_id'], 1, 99999999)) { $url = get_permalink($attribute['post_id']); } else { return; } } else { $url = $attribute['url']; } if (ob_get_contents()) { ob_clean(); } wp_redirect($url, $attribute['status']); ob_end_flush(); exit; }
function processShortcodeBackgroundVideo($attribute, $content, $tag) { $html = null; $option = array(); $Validation = new PBValidation(); $attribute = $this->processAttribute($tag, $attribute); if (!$Validation->isBool($attribute['loop'])) { return $html; } if (!$Validation->isBool($attribute['muted'])) { return $html; } if (!$Validation->isNumber($attribute['volume'], 0, 100)) { return $html; } if (!$Validation->isFloat($attribute['playback_rate'], -999.99, 999.99)) { return $html; } if ($Validation->isEmpty($attribute['video_format_webm']) && $Validation->isEmpty($attribute['video_format_ogg']) && $Validation->isEmpty($attribute['video_format_mp4'])) { return $html; } $key = array('loop', 'muted', 'poster', 'volume', 'position', 'playback_rate', 'video_format_mp4', 'video_format_ogg', 'video_format_webm'); foreach ($key as $value) { $option[$value] = $attribute[$value]; } $html = ' <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $(\'body\').PBBackgroundVideo(' . json_encode($option) . '); }); </script> </div> '; return $html; }
function processShortcodeAudio($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $option = array(); $this->track = array(); $this->trackIndex = 0; $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } if (!$Validation->isNumber($attribute['volume'], 0, 100)) { return $html; } if (!$Validation->isBool($attribute['muted'])) { return $html; } if (!$Validation->isBool($attribute['playlist_enable'])) { return $html; } $attribute['volume'] /= 100; $key = array('muted', 'volume', 'playlist_enable'); foreach ($key as $value) { $option[$value] = $attribute[$value]; } $id = PBHelper::createId('audio'); $idPlayer = PBHelper::createId('audio_player'); $idPlayerContainer = PBHelper::createId('audio_player_container'); do_shortcode($content); if (!count($this->track)) { return $html; } $html .= $this->createJPlayerTemplate($id, $idPlayer, $idPlayerContainer); $html .= ' <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $(\'#' . $id . '\').PBAudio(' . json_encode(array('idPlayer' => $idPlayer, 'idPlayerContainer' => $idPlayerContainer)) . ',' . json_encode($option) . ',' . json_encode($this->track) . '); }); </script> </div> '; return PBHelper::formatHTML($html); }
function processShortcodeBlockquote($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } $class = array('pb-blockquote', $attribute['css_class']); if ($Validation->isNotEmpty($attribute['author'])) { $html = '<div class="pb-blockquote-author">— ' . $attribute['author'] . '</div>'; } $html = ' <div' . PBHelper::createClassAttribute($class) . '> <blockquote> ' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . ' </blockquote> ' . $html . ' </div> '; return PBHelper::formatHTML($html, PBHelper::formatContent($content)); }
function processShortcodePreformattedText($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } if (!$Validation->isBool($attribute['open_default'])) { return $html; } $class = array('pb-preformatted-text'); if ($attribute['open_default'] == 1) { array_push($class, 'pb-preformatted-text-visible'); } array_push($class, $attribute['css_class']); $id = PBHelper::createId('pb_preformatted_text'); $content = nl2br(trim(preg_replace(array('/\\[/', '/\\]/'), array('[', ']'), htmlspecialchars($content)))); $html = ' <div id="' . $id . '"' . PBHelper::createClassAttribute($class) . '> <a href="#"> <span class="pb-preformatted-text-label-open">' . esc_html($attribute['label_open']) . '</span> <span class="pb-preformatted-text-label-close">' . esc_html($attribute['label_close']) . '</span> </a> <pre>' . $content . '</pre> </div> <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $("#' . $id . '").PBPreformattedText(); }); </script> </div> '; return PBHelper::formatHTML($html); }
function processShortcodeContactFormLayoutLine($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Layout = new PBLayout(); $Validation = new PBValidation(); if (!$Layout->isLayout($attribute['layout'])) { return $html; } $columnCount = $Layout->getLayoutColumnCount($attribute['layout']); for ($i = 1; $i <= $columnCount; $i++) { $fieldHTML = null; if (!$Validation->isEmpty($attribute['column_' . $i . '_name'])) { $field = mb_split(',', $attribute['column_' . $i . '_name']); foreach ($field as $fieldValue) { $this->fieldCounter++; $class = array('pb-clear-fix', 'pb-contact-form-field'); $fieldHTML .= ' <div' . PBHelper::createClassAttribute($class) . '>' . $this->createField($fieldValue) . '</div> '; } } $class = array('pb-layout-' . $Layout->getLayoutColumnCSSClass($attribute['layout'], $i - 1), $attribute['column_' . $i . '_css_class']); $html .= ' <li' . PBHelper::createClassAttribute($class) . '>' . $fieldHTML . '</li> '; } $class = array('pb-reset-list', 'pb-clear-fix', $Layout->getLayoutCSSClass($attribute['layout'])); $html = ' <ul' . PBHelper::createClassAttribute($class) . '> ' . $html . ' </ul> '; return PBHelper::formatHTML($html); }
function processShortcodeBoxHeader($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $style = array(); $Align = new PBAlign(); $Header = new PBHeader(); $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } if (!array_key_exists($attribute['align'], $Align->align)) { return $html; } if (!array_key_exists($attribute['important'], $Header->important)) { return $html; } if ($Validation->isColor($attribute['text_color'])) { $style['color'] = PBColor::getColor($attribute['text_color']); } $class = array('pb-box-header', 'pb-clear-fix', $Align->getCSSClass($attribute['align'])); $html = ' <h' . $attribute['important'] . PBHelper::createClassAttribute($class) . PBHelper::createStyleAttribute($style) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '</h' . $attribute['important'] . '> '; return PBHelper::formatHTML($html, $content); }
function processShortcodeTestimonialItemAuthorCompany($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } $html = '<div' . PBHelper::createClassAttribute(array('pb-testimonial-author-company')) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '</div>'; return PBHelper::formatHTML($html, $content); }
function processShortcodeClassItemButton($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } if ($Validation->isEmpty($attribute['url'])) { return $html; } $class = array('pb-class-item-button'); $html = ' <div' . PBHelper::createClassAttribute($class) . '> <a href="' . esc_attr($attribute['url']) . '">' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '<i class="pb-button-arrow pb-button-arrow-right"></i></a> </div> '; return PBHelper::formatHTML($html, $content); }
function processShortcodeButton($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $option = array(); $class = array_fill(0, 4, array()); $style = array_fill(0, 4, array()); $Font = new PBFont(); $Window = new PBWindow(); $Border = new PBBorder(); $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } if ($Validation->isEmpty($attribute['src'])) { return $html; } if (!$Validation->isBool($attribute['arrow_enable'])) { return $html; } if (!$Validation->isBool($attribute['icon_enable'])) { return $html; } if (!array_key_exists($attribute['size'], $this->buttonSize)) { return $html; } if (!array_key_exists($attribute['src_target'], $Window->linkTarget)) { return $html; } if ($attribute['icon_enable'] == 1) { if ($Validation->isEmpty($attribute['icon'])) { return $html; } if (!in_array($attribute['icon_position'], array_keys($this->buttonIconPosition))) { return $html; } } /***/ if ($Validation->isColor($attribute['text_color'])) { $style[1]['color'] = PBColor::getColor($attribute['text_color']); $option['out']['color'] = $style[1]['color']; } if ($Validation->isColor($attribute['bg_color'])) { $style[1]['background-color'] = PBColor::getColor($attribute['bg_color']); $option['out']['background-color'] = $style[1]['background-color']; } if ($attribute['border_style'] != -1) { if (array_key_exists($attribute['border_style'], $Border->style)) { $style[1]['border-style'] = $attribute['border_style']; $option['out']['border-style'] = $style[1]['border-style']; } } if ($Validation->isColor($attribute['border_color'])) { $style[1]['border-color'] = PBColor::getColor($attribute['border_color']); $option['out']['border-color'] = $style[1]['border-color']; } if ($Validation->isNumber($attribute['border_width'], 0, 999)) { $style[1]['border-width'] = $attribute['border_width'] . 'px'; $option['out']['border-width'] = $style[1]['border-width']; } if ($Validation->isNumber($attribute['border_radius'], 0, 999)) { $style[1]['border-radius'] = $attribute['border_radius'] . 'px'; $option['out']['border-radius'] = $style[1]['border-radius']; } if ($attribute['font_weight'] != -1) { if (array_key_exists($attribute['font_weight'], $Font->weight)) { $style[1]['font-weight'] = $attribute['font_weight']; $option['out']['font-weight'] = $style[1]['font-weight']; } } /***/ if ($Validation->isColor($attribute['text_color_hover'])) { $option['in']['color'] = PBColor::getColor($attribute['text_color_hover']); } if ($Validation->isColor($attribute['bg_color_hover'])) { $option['in']['background-color'] = PBColor::getColor($attribute['bg_color_hover']); } if ($attribute['border_style_hover'] != -1) { if (array_key_exists($attribute['border_style_hover'], $Border->style)) { $option['in']['border-style'] = $attribute['border_style_hover']; } } if ($Validation->isColor($attribute['border_color_hover'])) { $option['in']['border-color'] = PBColor::getColor($attribute['border_color_hover']); } if ($Validation->isNumber($attribute['border_width_hover'], 0, 999)) { $option['in']['border-width'] = $attribute['border_width_hover'] . 'px'; } if ($Validation->isNumber($attribute['border_radius_hover'], 0, 999)) { $option['in']['border-radius'] = $attribute['border_radius_hover'] . 'px'; } if ($attribute['font_weight'] != -1) { if (array_key_exists($attribute['font_weight_hover'], $Font->weight)) { $option['in']['font-weight'] = $attribute['font_weight_hover']; } } /***/ $class[0] = array('pb-button'); $class[1] = array($Window->getTargetCSSClass($attribute['src_target'])); $class[2] = array('pb-button-icon'); $class[3] = array('pb-button-content'); array_push($class[0], 'pb-button-size-' . $attribute['size']); if ($attribute['icon_enable'] == 1) { array_push($class[0], 'pb-button-icon'); array_push($class[0], 'pb-button-icon-position-' . $attribute['icon_position']); array_push($class[2], 'pb-button-icon-' . PBHelper::createHash($attribute['icon'])); } $class[0][] = $attribute['css_class']; $id = PBHelper::createId('pb_button'); $html = ' <div' . PBHelper::createClassAttribute($class[0]) . ' id="' . $id . '"> <a href="' . esc_attr($attribute['src']) . '"' . PBHelper::createClassAttribute($class[1]) . PBHelper::createStyleAttribute($style[1]) . '> <span class="pb-button-box"> <span' . PBHelper::createClassAttribute($class[2]) . PBHelper::createStyleAttribute($style[2]) . '></span> <span' . PBHelper::createClassAttribute($class[3]) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . ($attribute['arrow_enable'] == 1 ? '<i class="pb-button-arrow pb-button-arrow-right"></i>' : null) . '</span> </span> </a> <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $(\'#' . $id . '\').PBButton(' . json_encode($option) . '); }); </script> </div> </div> '; return PBHelper::formatHTML($html, $content); }
function processShortcodeTwitterUserTimeline($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $Easing = new PBEasing(); $Validation = new PBValidation(); $CarouFredSel = new PBCarouFredSel(); if ($Validation->isEmpty($attribute['twitter_username'])) { return null; } if ($Validation->isEmpty($attribute['twitter_consumer_key'])) { return null; } if ($Validation->isEmpty($attribute['twitter_consumer_key_secret'])) { return null; } if ($Validation->isEmpty($attribute['twitter_access_token'])) { return null; } if ($Validation->isEmpty($attribute['twitter_access_token_secret'])) { return null; } if (!$Validation->isNumber($attribute['twitter_tweet_number'], 1, 200)) { return null; } if (!$Validation->isBool($attribute['carousel_enable'])) { return null; } if (!$Validation->isBool($attribute['carousel_autoplay_enable'])) { return null; } if (!$Validation->isBool($attribute['carousel_circular_enable'])) { return null; } if (!$Validation->isBool($attribute['carousel_infinite_enable'])) { return null; } if (!$Validation->isBool($attribute['carousel_scroll_pause_hover'])) { return null; } if (!array_key_exists($attribute['carousel_scroll_fx'], $CarouFredSel->scrollFX)) { return null; } if (!array_key_exists($attribute['carousel_scroll_easing'], $Easing->easingType)) { return null; } if (!$Validation->isNumber($attribute['carousel_scroll_duration'], 1, 99999)) { return null; } $this->includeLibrary('twitteroauth/twitteroauth.php'); $connection = new TwitterOAuth($attribute['twitter_consumer_key'], $attribute['twitter_consumer_key_secret'], $attribute['twitter_access_token'], $attribute['twitter_access_token_secret']); $tweet = $connection->get('https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=' . $attribute['twitter_username'] . '&count=' . $attribute['twitter_tweet_number']); if (is_null($tweet)) { return null; } if (is_wp_error($tweet)) { return null; } if (array_key_exists('errors', $tweet)) { if (count($tweet['errors'])) { return; } } $data = array(); $data['tweet'] = $tweet; $data['attribute'] = $attribute; $data['id'] = PBHelper::createId('pb_twitter_user_timeline'); $data['option'] = PBHelper::getValueFromArray($attribute, array('carousel_enable', 'carousel_autoplay_enable', 'carousel_circular_enable', 'carousel_infinite_enable', 'carousel_scroll_pause_hover', 'carousel_scroll_fx', 'carousel_scroll_easing', 'carousel_scroll_duration')); $Template = new PBTemplate($data, $this->getTemplateFullPath('template')); return $Template->output(true); }
function getComponentDescription($description) { $Validation = new PBValidation(); if ($Validation->isEmpty($description)) { $description = __('no description', PLUGIN_PAGE_BUILDER_DOMAIN); } return $description; }
function processShortcodeFeatureItemContent($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } $class = array('pb-feature-content'); $html = '<div' . PBHelper::createClassAttribute($class) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '</div>'; return PBHelper::formatHTML($html, PBHelper::formatContent($content)); }
function processShortcodeCounterBoxItemHeader($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } $html = ' <h' . PBComponentData::get($this->getComponentId(), 'header_important_default') . PBHelper::createClassAttribute(array('pb-counter-box-header')) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '</h' . PBComponentData::get($this->getComponentId(), 'header_important_default') . '> '; return PBHelper::formatHTML($html, $content); }
function processShortcodeRecentPost($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Layout = new PBLayout(); $Validation = new PBValidation(); $ImageHover = new PBImageHover(); if (!PBFile::isWPImage($attribute['image_size'])) { return $html; } if (!array_key_exists($attribute['layout'], $this->layout)) { return $html; } if (!array_key_exists($attribute['template'], $this->template)) { return $html; } if (!$Validation->isNumber($attribute['post_count'], 1, 999)) { return $html; } if (!$Validation->isBool($attribute['preloader_enable'])) { return $html; } if (!$Validation->isBool($attribute['hover_enable'])) { return $html; } if (!array_key_exists($attribute['hover_type'], $ImageHover->type)) { return $html; } if (!$Validation->isBool($attribute['date_enable'])) { return $html; } if (!$Validation->isBool($attribute['image_enable'])) { return $html; } if (!$Validation->isBool($attribute['header_enable'])) { return $html; } if (!$Validation->isBool($attribute['author_enable'])) { return $html; } if (!$Validation->isBool($attribute['excerpt_enable'])) { return $html; } if (!$Validation->isBool($attribute['category_enable'])) { return $html; } $option = array(); $key = array('hover_type', 'hover_enable', 'preloader_enable'); foreach ($key as $index) { $option[$index] = $attribute[$index]; } $data = $this->getPost($attribute); if ($data === false) { return null; } if (!count($data->posts)) { return null; } $i = 0; global $post; $bPost = $post; while ($data->have_posts()) { $data->the_post(); $class = array('pb-layout-' . $Layout->getLayoutColumnCSSClass($attribute['layout'], $i)); $meta = array('date' => null, 'comment_count' => null, 'image' => null, 'header' => null, 'excerpt' => null, 'meta' => null); if ($attribute['date_enable']) { $meta['date'] = '<div class="pb-recent-post-date">' . get_the_date() . '</div>'; } if ($attribute['image_enable']) { if (has_post_thumbnail()) { $commentCountHTML = null; if ($attribute['template'] == 1) { if ($attribute['comment_count_enable'] == 1 && comments_open(get_the_id())) { $commentCount = wp_count_comments(get_the_id()); $commentCountHTML = '<div class="pb-recent-post-comment-count"><span class="pb-recent-post-comment-count-value">' . $commentCount->approved . '</span><span class="pb-recent-post-comment-count-arrow"></span></div>'; } } $classImage = array(array('pb-recent-post-image', 'pb-image-box'), array('pb-image')); if ($attribute['preloader_enable'] == 1) { array_push($classImage[0], 'pb-image-preloader', 'pb-image-preloader-animation-enable'); } if ($attribute['hover_enable'] == 1) { array_push($classImage[0], 'pb-image-hover', 'pb-image-hover-type-' . $attribute['hover_type']); } if ($attribute['hover_enable'] == 1) { $meta['image'] = '<a href="' . get_permalink(get_the_ID()) . '"' . PBHelper::createClassAttribute($classImage[1]) . '>' . get_the_post_thumbnail(get_the_ID(), $attribute['image_size']) . '<span><span><span></span></span></span></a>'; } else { $meta['image'] = '<div' . PBHelper::createClassAttribute($classImage[1]) . '>' . get_the_post_thumbnail(get_the_ID(), $attribute['image_size']) . '</div>'; } $meta['image'] = '<div' . PBHelper::createClassAttribute($classImage[0]) . '>' . $meta['image'] . $commentCountHTML . '</div>'; } } if ($attribute['header_enable']) { $meta['header'] = '<h' . PBComponentData::get($this->getComponentId(), 'header_important_default') . ' class="pb-recent-post-header"><a href="' . get_permalink(get_the_ID()) . '">' . get_the_title() . '</a></h' . PBComponentData::get($this->getComponentId(), 'header_important_default') . '>'; } if ($attribute['excerpt_enable']) { $meta['excerpt'] = '<div class="pb-recent-post-excerpt">' . get_the_excerpt() . '</div>'; } if ($attribute['author_enable'] || $attribute['category_enable'] || $attribute['template'] == 2 && $attribute['comment_count_enable'] == 1 && comments_open(get_the_id())) { $authorHTML = null; $categoryHTML = null; $commentCountHTML = null; if ($attribute['author_enable']) { $authorHTML = '<div class="pb-recent-post-meta-author">' . get_the_author() . '</div>'; } $category = get_the_category(get_the_ID()); $count = count($category); if ($count) { foreach ($category as $index => $value) { $separator = $index == $count - 1 ? '' : ', '; $title = $Validation->isEmpty($value->description) ? sprintf(__('View all posts filed under %s', PLUGIN_PAGE_BUILDER_DOMAIN), $value->name) : strip_tags(apply_filters('category_description', $value->description, $value)); $categoryHTML .= '<li><a href="' . get_category_link($value->term_id) . '" title="' . esc_attr($title) . '">' . esc_html($value->name) . '</a>' . $separator . '</li>'; } $categoryHTML = '<div class="pb-recent-post-meta-category"><ul class="pb-reset-list">' . $categoryHTML . '</ul></div>'; } if ($attribute['template'] == 2) { if ($attribute['comment_count_enable'] == 1 && comments_open(get_the_id())) { $commentCount = wp_count_comments(get_the_id()); $commentCountHTML = '<div class="pb-recent-post-meta-comment-count">' . __(sprintf('%d Comments', $commentCount->approved), PLUGIN_PAGE_BUILDER_DOMAIN) . '</div>'; } } $meta['meta'] = '<div class="pb-recent-post-meta pb-clear-fix">' . $authorHTML . $categoryHTML . $commentCountHTML . '</div>'; } $templateHTML = array(); $templateOrder = array('date', 'image', 'header', 'excerpt', 'meta'); if ($attribute['template'] == 2) { $templateOrder = array('image', 'header', 'date', 'excerpt', 'meta'); } foreach ($templateOrder as $value) { if (isset($meta[$value])) { $templateHTML[$value] = $meta[$value]; } } $html .= '<li' . PBHelper::createClassAttribute($class) . '><div>' . implode($templateHTML) . '</div></li>'; $i++; } wp_reset_query(); $post = $bPost; $id = PBHelper::createId('pb_recent_post'); $class = array(); $class[0] = array('pb-recent-post', 'pb-recent-post-template-' . $attribute['template'], $attribute['css_class']); $class[1] = array('pb-clear-fix', 'pb-reset-list', $Layout->getLayoutCSSClass($attribute['layout'])); $html = ' <div' . PBHelper::createClassAttribute($class[0]) . ' id="' . $id . '"> <ul' . PBHelper::createClassAttribute($class[1]) . '> ' . $html . ' </ul> </div> <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $("#' . $id . '").PBRecentPost(' . json_encode($option) . '); }); </script> </div> '; return PBHelper::formatHTML($html); }
function processShortcodeCallToActionButton($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $style = array(); $option = array(); $Window = new PBWindow(); $Validation = new PBValidation(); $src = !$Validation->isEmpty($attribute['src']) ? $attribute['src'] : '#'; $class = array($Window->getTargetCSSClass($attribute['src_target'])); if ($Validation->isColor($attribute['text_color'])) { $style['color'] = PBColor::getColor($attribute['text_color']); $option['out']['color'] = $style['color']; } if ($Validation->isColor($attribute['bg_color'])) { $style['background-color'] = PBColor::getColor($attribute['bg_color']); $option['out']['background-color'] = $style['background-color']; } if ($Validation->isColor($attribute['border_color'])) { $style['border-color'] = PBColor::getColor($attribute['border_color']); $option['out']['border-color'] = $style['border-color']; } if ($Validation->isColor($attribute['text_color_hover'])) { $option['in']['color'] = PBColor::getColor($attribute['text_color_hover']); } if ($Validation->isColor($attribute['bg_color_hover'])) { $option['in']['background-color'] = PBColor::getColor($attribute['bg_color_hover']); } if ($Validation->isColor($attribute['border_color_hover'])) { $option['in']['border-color'] = PBColor::getColor($attribute['border_color_hover']); } if ($Validation->isNumber($attribute['padding_top'], 0, 9999)) { $style['padding-top'] = $attribute['padding_top'] . 'px'; } if ($Validation->isNumber($attribute['padding_right'], 0, 9999)) { $style['padding-right'] = $attribute['padding_right'] . 'px'; } if ($Validation->isNumber($attribute['padding_bottom'], 0, 9999)) { $style['padding-bottom'] = $attribute['padding_bottom'] . 'px'; } if ($Validation->isNumber($attribute['padding_left'], 0, 9999)) { $style['padding-left'] = $attribute['padding_left'] . 'px'; } if ($Validation->isNumber($attribute['margin_top'], -9999, 9999)) { $style['margin-top'] = $attribute['margin_top'] . 'px'; } if ($Validation->isNumber($attribute['margin_bottom'], -9999, 9999)) { $style['margin-bottom'] = $attribute['margin_bottom'] . 'px'; } $html = ' <div> <a href="' . $src . '"' . PBHelper::createClassAttribute($class) . PBHelper::createStyleAttribute($style) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '<i class="pb-button-arrow pb-button-arrow-right"></i></a> <input type="hidden" value="' . esc_attr(json_encode($option)) . '"/> </div> '; return PBHelper::formatHTML($html, $content); }
function adminSaveMetaBox($postId) { if ($_POST) { if (PBHelper::checkSavePost($postId, PLUGIN_PAGE_BUILDER_CONTEXT . '_team_noncename', 'adminSaveMetaBox') === false) { return false; } $option = PBHelper::getPOSTOption('team'); $Validation = new PBValidation(); /***/ PBHelper::removeUIndex($option, 'team_skill_name', 'team_skill_level', 'team_skill_order'); $skill = array('team_skill_name' => $option['team_skill_name'], 'team_skill_level' => $option['team_skill_level'], 'team_skill_order' => $option['team_skill_order']); unset($option['team_skill_name'], $option['team_skill_level'], $option['team_skill_order']); foreach ($skill['team_skill_name'] as $index => $value) { if ($Validation->isEmpty($value)) { continue; } if (!array_key_exists($index, $skill['team_skill_level'])) { continue; } if (!$Validation->isNumber($skill['team_skill_level'][$index], 1, 100)) { continue; } $option['team_skill'][] = array('team_skill_name' => $value, 'team_skill_level' => $skill['team_skill_level'][$index], 'team_skill_order' => array_key_exists($index, $skill['team_skill_order']) ? $skill['team_skill_order'][$index] : 0); } /***/ PBHelper::removeUIndex($option, 'team_social_name', 'team_social_url', 'team_social_order'); $social = array('team_social_name' => $option['team_social_name'], 'team_social_url' => $option['team_social_url'], 'team_social_order' => $option['team_social_order']); unset($option['team_social_name'], $option['team_social_url'], $option['team_social_order']); foreach ($social['team_social_name'] as $index => $value) { if (!array_key_exists($value, $this->social)) { continue; } if (!array_key_exists($index, $social['team_social_url'])) { continue; } if (!$Validation->isURL($social['team_social_url'][$index])) { continue; } $option['team_social'][] = array('team_social_name' => $value, 'team_social_url' => $social['team_social_url'][$index], 'team_social_order' => array_key_exists($index, $social['team_social_order']) ? $social['team_social_order'][$index] : 0); } PBMeta::update($postId, $option); } }
function processShortcodeGallery($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $elementHTML = null; $Layout = new PBLayout(); $Validation = new PBValidation(); $ImageHover = new PBImageHover(); $file = PBFile::getImage(explode(',', $attribute['image'])); if ($file === false) { return $html; } if (!count($file->posts)) { return $html; } if (!PBFile::isWPImage($attribute['image_size'])) { return $html; } if (!array_key_exists($attribute['layout'], $this->layout)) { return $html; } if (!$Validation->isBool($attribute['hover_enable'])) { return $html; } if (!array_key_exists($attribute['hover_type'], $ImageHover->type)) { return $html; } if (!$Validation->isBool($attribute['caption_enable'])) { return $html; } if (!$Validation->isBool($attribute['preloader_enable'])) { return $html; } if (!$Validation->isBool($attribute['description_enable'])) { return $html; } if (!$Validation->isBool($attribute['layout_full_width_enable'])) { return $html; } $key = array('hover_type', 'hover_enable', 'preloader_enable', 'layout_full_width_enable'); foreach ($key as $index) { $option[$index] = $attribute[$index]; } $id = PBHelper::createId('pb_gallery'); global $post; $bPost = $post; $i = 0; while ($file->have_posts()) { global $post; $file->the_post(); $full = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), $attribute['image_size']); $meta = PBMeta::get($post); PBHelper::removeUIndex($meta, 'media_library_video_url', 'media_library_url'); $class = array(); $class[0] = array('pb-layout-' . $Layout->getLayoutColumnCSSClass($attribute['layout'], $i)); $class[1] = array('pb-image-box'); $class[2] = array('pb-image'); if ($attribute['preloader_enable'] == 1) { array_push($class[1], 'pb-image-preloader', 'pb-image-preloader-animation-enable'); } if ($attribute['hover_enable'] == 1) { array_push($class[1], 'pb-image-hover', 'pb-image-hover-type-' . $attribute['hover_type']); } /****/ $imageTextHTML = null; if ($Validation->isNotEmpty($post->post_excerpt) && $attribute['caption_enable'] == 1) { $imageTextHTML .= '<' . PBComponentData::get($this->getComponentId(), 'image_text_caption_header_tag') . ' class="pb-image-text-caption">' . get_the_excerpt() . '</' . PBComponentData::get($this->getComponentId(), 'image_text_caption_header_tag') . '>'; } if ($Validation->isNotEmpty($post->post_content) && $attribute['description_enable'] == 1) { $imageTextHTML .= '<div class="pb-image-text-description">' . get_the_content() . '</div>'; } if ($Validation->isNotEmpty($imageTextHTML)) { $imageTextHTML = '<div class="pb-image-text">' . $imageTextHTML . '</div>'; } if ($Validation->isNotEmpty($imageTextHTML)) { $imageTextHTML .= '<div class="pb-image-text-fancybox"><b>' . get_the_excerpt() . '</b> ' . get_the_content() . '</div>'; } /****/ $url = null; $rel = null; if ($Validation->isVideoURL($meta['media_library_video_url'])) { $url = $meta['media_library_video_url']; array_push($class[1], 'pb-image-type-video'); } elseif ($Validation->isURL($meta['media_library_url'])) { $url = $meta['media_library_url']; array_push($class[1], 'pb-image-type-link'); } else { $rel = $id; $url = $full[0]; array_push($class[1], 'pb-image-type-image'); } /****/ $imageHTML = null; if ($attribute['hover_enable'] == 1) { $imageHTML = '<a href="' . $url . '"' . PBHelper::createClassAttribute($class[2]) . ($Validation->isEmpty($rel) ? null : ' data-fancybox-group="' . esc_attr($rel) . '"') . '><img src="' . $thumbnail[0] . '" alt=""/><span><span><span></span></span></span></a>'; } else { $imageHTML = '<div' . PBHelper::createClassAttribute($class[2]) . '><img src="' . $thumbnail[0] . '" alt=""/></div>'; } /****/ if ($Validation->isNotEmpty($imageTextHTML)) { array_push($class[1], 'pb-image-text-enable'); } $elementHTML .= '<li' . PBHelper::createClassAttribute($class[0]) . '><div' . PBHelper::createClassAttribute($class[1]) . '>' . $imageHTML . $imageTextHTML . '</div></li>'; $i++; } wp_reset_query(); $post = $bPost; $class = array(); $class[0] = array('pb-gallery', 'pb-clear-fix', $attribute['css_class']); $class[1] = array($Layout->getLayoutCSSClass($attribute['layout']), 'pb-reset-list', 'pb-clear-fix'); if ($attribute['layout_full_width_enable'] == 1) { array_push($class[1], 'pb-layout-full-width'); } $html = ' <div' . PBHelper::createClassAttribute($class[0]) . ' id="' . $id . '"> <ul' . PBHelper::createClassAttribute($class[1]) . '> ' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . ' </ul> </div> <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $(\'#' . $id . '\').PBGallery(' . json_encode($option) . '); }); </script> </div> '; return PBHelper::formatHTML($html, $elementHTML); }
function processShortcodePricingPlanItemPriceSuffix($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); if ($Validation->isEmpty($content)) { return $html; } $class = array('pb-pricing-plan-item-price-box-suffix'); $html = '<span' . PBHelper::createClassAttribute($class) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '</span>'; return PBHelper::formatHTML($html, $content); }
function createFieldLegend($legend) { $Validation = new PBValidation(); if ($Validation->isEmpty($legend)) { return null; } return '<span class="pb-field-legend">' . $this->addCharToEnd($legend, ':') . '</span>'; }
function processShortcodeGoogleMap($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $Validation = new PBValidation(); if ($Validation->isEmpty($attribute['coordinate_lat'])) { return null; } if ($Validation->isEmpty($attribute['coordinate_lng'])) { return null; } if ($Validation->isEmpty($attribute['coordinate_marker_lat'])) { return null; } if ($Validation->isEmpty($attribute['coordinate_marker_lng'])) { return null; } if (!$Validation->isNumber($attribute['marker_image_origin_x'], -99999, 99999)) { return null; } if (!$Validation->isNumber($attribute['marker_image_origin_y'], -99999, 99999)) { return null; } if (!$Validation->isNumber($attribute['marker_image_anchor_x'], -99999, 99999)) { return null; } if (!$Validation->isNumber($attribute['marker_image_anchor_y'], -99999, 99999)) { return null; } if (!$Validation->isNumber($attribute['width'], 1, 100)) { return null; } if (!$Validation->isNumber($attribute['height'], 1, 9999)) { return null; } if (!$Validation->isBool($attribute['draggable'])) { return null; } if (!$Validation->isBool($attribute['scrollwheel'])) { return null; } if (!array_key_exists($attribute['map_type_id'], $this->mapTypeId)) { return null; } if (!array_key_exists($attribute['map_type_control_position'], $this->position)) { return null; } if (!array_key_exists($attribute['map_type_control_style'], $this->mapTypeControlStyle)) { return null; } if (!$Validation->isBool($attribute['map_type_control_enable'])) { return null; } if (!$Validation->isNumber($attribute['zoom_level'], 1, 21)) { return null; } if (!$Validation->isBool($attribute['zoom_control_enable'])) { return null; } if (!array_key_exists($attribute['zoom_position'], $this->position)) { return null; } if (!array_key_exists($attribute['zoom_control_style'], $this->zoomControlStyle)) { return null; } if (!$Validation->isBool($attribute['pan_control_enable'])) { return null; } if (!array_key_exists($attribute['pan_control_position'], $this->position)) { return null; } if (!$Validation->isBool($attribute['scale_control_enable'])) { return null; } if (!array_key_exists($attribute['scale_control_position'], $this->position)) { return null; } if (!$Validation->isBool($attribute['street_view_enable'])) { return null; } if (!array_key_exists($attribute['street_view_position'], $this->position)) { return null; } $id = PBHelper::createId('google_map'); $class = array('pb-google-map', $attribute['css_class']); $attribute['style'] = '[' . mb_substr(do_shortcode($content), 1) . ']'; $html = ' <div id="' . $id . '"' . PBHelper::createClassAttribute($class) . '></div> <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $(\'#' . $id . '\').PBGoogleMap(' . json_encode($attribute) . '); }); </script> </div> '; return PBHelper::formatHTML($html); }