function getValue($componentId, $key, $data = null, &$value = null) { if (!is_array($key)) { $key = array($key); } if (is_null($data)) { $data = $_SESSION[$componentId]; } $index = $key[0]; if (count($key) == 1) { PBHelper::removeUIndex($data, $index); return $data[$index]; } else { $key = array_slice($key, 1); return $this->getValue($componentId, $key, $data[$index]); } return false; }
function create() { $html = null; $element = array(); $panelHTML = array(); $Validation = new PBValidation(); foreach ($this->componentData['structure']['element'] as $elementData) { $panelId = $elementData['ui']['panel']; $multiId = $elementData['ui']['multi']; $groupId = $elementData['ui']['group']; $element[$panelId][$multiId][$groupId][] = $elementData; } foreach ($element as $panelId => $panelData) { foreach ($panelData as $multiId => $multiData) { if ($multiId != 0) { if (!isset($panelHTML[$panelId])) { $panelHTML[$panelId] = null; } $elementMultiId = array(); foreach ($multiData as $groupData) { foreach ($groupData as $elementData) { $elementMultiId[$elementData['id']] = $elementData['id']; } } $count = 1; foreach ($elementMultiId as $elementMultiIdId) { if (array_key_exists($elementMultiIdId, $this->componentValue)) { $count = count($this->componentValue[$elementMultiIdId]) > $count ? count($this->componentValue[$elementMultiIdId]) : $count; } } for ($j = 0; $j < $count; $j++) { $elementHTML = null; $i = 0; $fieldCount = 0; foreach ($multiData as $groupId => $groupData) { foreach ($groupData as $elementData) { if ($this->displayField($elementData['visibility'])) { if ($groupId == 0) { $fieldCount += count($groupData); } else { $fieldCount++; } break; } } } foreach ($multiData as $groupId => $groupData) { if ($groupId != 0) { $html = null; foreach ($groupData as $elementData) { if (!$this->displayField($elementData['visibility'])) { continue; } $id = $elementData['id']; PBHelper::removeUIndex($this->componentValue[$id], $j); $html .= ' <div> ' . $this->createFieldLegend($elementData['ui']['text']['label']) . ' ' . $this->createField($elementData, $this->componentValue[$id][$j]) . ' </div> '; } PBHelper::removeUIndex($this->componentData['structure']['ui']['group'][$groupId], 'header', 'subheader'); if ($Validation->isNotEmpty($html)) { $i++; $elementHTML .= ' <li> ' . $this->createGroupHeader($this->componentData['structure']['ui']['group'][$groupId]['header']) . ' ' . $this->createGroupSubheader($this->componentData['structure']['ui']['group'][$groupId]['header'], $this->componentData['structure']['ui']['group'][$groupId]['subheader']) . ' ' . $html . ' ' . ($i == $fieldCount ? '<a href="#" class="pb-link-remove">' . __('Remove') . '</a>' : null) . ' </li> '; } } else { foreach ($groupData as $elementData) { if (!$this->displayField($elementData['visibility'])) { continue; } $i++; $id = $elementData['id']; PBHelper::removeUIndex($this->componentValue[$id], $j); $elementHTML .= ' <li> ' . $this->createGroupHeader($elementData['ui']['text']['header']) . ' ' . $this->createGroupSubheader($elementData['ui']['text']['header'], $elementData['ui']['text']['subheader']) . ' <div> ' . $this->createFieldLegend($elementData['ui']['text']['label']) . ' ' . $this->createField($elementData, $this->componentValue[$id][$j]) . ' </div> ' . ($i == $fieldCount ? '<a href="#" class="pb-link-remove">' . __('Remove') . '</a>' : null) . ' </li> '; } } } if ($Validation->isNotEmpty($elementHTML)) { $panelHTML[$panelId] .= ' <div> <h3>' . $this->componentData['structure']['ui']['multi'][$multiId]['header'] . '</h3> <ul class="pb-field-list"> ' . $elementHTML . ' </ul> </div> '; } } if ($Validation->isNotEmpty($panelHTML[$panelId])) { $panelHTML[$panelId] = ' <li> <div class="pb-multi-field"> ' . $panelHTML[$panelId] . ' </div> <a href="#" class="pb-link-add">' . __('Add new', PLUGIN_PAGE_BUILDER_DOMAIN) . '</a> </li> '; } } else { foreach ($multiData as $groupId => $groupData) { if (!isset($panelHTML[$panelId])) { $panelHTML[$panelId] = null; } if ($groupId != 0) { $elementHTML = null; foreach ($groupData as $elementData) { if (!$this->displayField($elementData['visibility'])) { continue; } $id = $elementData['id']; PBHelper::removeUIndex($this->componentValue, $id); $elementHTML .= ' <div> ' . $this->createFieldLegend($elementData['ui']['text']['label']) . ' ' . $this->createField($elementData, $this->componentValue[$id]) . ' </div> '; } PBHelper::removeUIndex($this->componentData['structure']['ui']['group'][$groupId], 'header', 'subheader'); if ($Validation->isNotEmpty($elementHTML)) { $panelHTML[$panelId] .= ' <li> ' . $this->createGroupHeader($this->componentData['structure']['ui']['group'][$groupId]['header']) . ' ' . $this->createGroupSubheader($this->componentData['structure']['ui']['group'][$groupId]['header'], $this->componentData['structure']['ui']['group'][$groupId]['subheader']) . ' ' . $elementHTML . ' </li> '; } } else { foreach ($groupData as $elementData) { if (!$this->displayField($elementData['visibility'])) { continue; } $id = $elementData['id']; PBHelper::removeUIndex($this->componentValue, $id); $panelHTML[$panelId] .= ' <li> ' . $this->createGroupHeader($elementData['ui']['text']['header']) . ' ' . $this->createGroupSubheader($elementData['ui']['text']['header'], $elementData['ui']['text']['subheader']) . ' <div> ' . $this->createFieldLegend($elementData['ui']['text']['label']) . ' ' . $this->createField($elementData, $this->componentValue[$id]) . ' </div> </li> '; } } } } } } if (PBHelper::isArray($this->componentData['structure'], array('ui', 'panel'))) { $tabBar = null; $tabContent = null; foreach ($panelHTML as $index => $value) { $tabBar .= ' <li> <a href="#tab-' . $index . '">' . $this->componentData['structure']['ui']['panel'][$index]['header'] . '</a> </li> '; $tabContent .= ' <div id="tab-' . $index . '"> <div> <ul class="pb-reset-list pb-field-list"> ' . $value . ' </ul> </div> </div> '; } $html = ' <div class="pb-tab"> <ul> ' . $tabBar . ' </ul> ' . $tabContent . ' </div> '; } else { $html = ' <ul class="pb-reset-list pb-field-list"> ' . $panelHTML[0] . ' </ul> '; } $html = ' <div class="pb"> <form name="pb-component-edit-form" id="pb-component-edit-form" action=""> ' . $html . ' </form> </div> '; return $html; }
function mediaLibraryAdd($form_fields, $post) { $option = PBMeta::get($post); if (PBData::get('media_library_url_field_enable')) { PBHelper::removeUIndex($option, 'media_library_url'); $form_fields['media_library_url'] = array('label' => __('URL', PLUGIN_PAGE_BUILDER_DOMAIN), 'input' => 'text', 'value' => $option['media_library_url'], 'helps' => __('URL of the page which has to be opened when user has clicked on image', PLUGIN_PAGE_BUILDER_DOMAIN)); } if (PBData::get('media_library_video_url_field_enable')) { PBHelper::removeUIndex($option, 'media_library_video_url'); $form_fields['media_library_video_url'] = array('label' => __('Video URL', PLUGIN_PAGE_BUILDER_DOMAIN), 'input' => 'text', 'value' => $option['media_library_video_url'], 'helps' => __('URL of the video. Supported services: youtube.com, vimeo.com, dailymotion.com, metacafe.com', PLUGIN_PAGE_BUILDER_DOMAIN)); } return $form_fields; }
function processShortcodeSocialIcon($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $style = array(); $social = array(); $Window = new PBWindow(); $Validation = new PBValidation(); if (!array_key_exists($attribute['target'], $Window->linkTarget)) { return $html; } if (!$Validation->isBool($attribute['native_color_enable'])) { return $html; } foreach ($this->social as $index => $value) { $url = 'profile_' . $index . '_url'; $order = 'profile_' . $index . '_order'; PBHelper::removeUIndex($attribute, $url, $order); if (!$Validation->isURL($attribute[$url])) { continue; } $orderValue = (int) $attribute[$order]; $socialData = array('id' => $index, 'url' => $attribute[$url]); if ($Validation->isNumber($attribute[$order], 0, 99)) { if (isset($social[$orderValue])) { array_push($social, $socialData); } else { $social[$orderValue] = $socialData; } } else { array_push($social, $socialData); } } ksort($social); if (!count($social)) { return; } $option = array('in' => array(), 'out' => array()); if ($Validation->isNumber($attribute['width'], 0, 999)) { $style['width'] = $attribute['width'] . 'px'; } if ($Validation->isNumber($attribute['height'], 0, 999)) { $style['height'] = $attribute['height'] . 'px'; } $borderRadius = null; if ($Validation->isNumber($attribute['border_radius_top_left'], 0, 999)) { $borderRadius .= ' ' . $attribute['border_radius_top_left'] . 'px'; } else { $borderRadius .= ' 0px'; } if ($Validation->isNumber($attribute['border_radius_top_right'], 0, 999)) { $borderRadius .= ' ' . $attribute['border_radius_top_right'] . 'px'; } else { $borderRadius .= ' 0px'; } if ($Validation->isNumber($attribute['border_radius_bottom_right'], 0, 999)) { $borderRadius .= ' ' . $attribute['border_radius_bottom_right'] . 'px'; } else { $borderRadius .= ' 0px'; } if ($Validation->isNumber($attribute['border_radius_bottom_left'], 0, 999)) { $borderRadius .= ' ' . $attribute['border_radius_bottom_left'] . 'px'; } else { $borderRadius .= ' 0px'; } $borderRadius = trim($borderRadius); $style['-webkit-border-radius'] = $borderRadius; $style['-moz-border-radius'] = $borderRadius; $style['border-radius'] = $borderRadius; if ($Validation->isNumber($attribute['border_width'], 0, 999)) { $style['border-width'] = $attribute['border_width'] . 'px'; $option['out']['border-width'] = $style['border-width']; } 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->isNumber($attribute['border_width_hover'], 0, 999)) { $option['in']['border-width'] = $attribute['border_width_hover'] . 'px'; } 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']); } foreach ($social as $index => $value) { $class = array('pb-social-icon-' . $value['id'], $Window->getTargetCSSClass($attribute['target'])); $html .= ' <li><a href="' . esc_attr($value['url']) . '"' . PBHelper::createClassAttribute($class) . PBHelper::createStyleAttribute($style) . '></a></li> '; } $id = PBHelper::createId('pb_social_icon'); $class = array('pb-social-icon'); if ($attribute['native_color_enable'] == 1) { array_push($class, 'pb-social-icon-color-native'); } array_push($class, 'pb-reset-list', 'pb-clear-fix', $attribute['css_class']); $html = ' <ul' . PBHelper::createClassAttribute($class) . ' id="' . esc_attr($id) . '"> ' . $html . ' </ul> <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $(\'#' . $id . '\').PBSocialIcon(' . json_encode($option) . '); }); </script> </div> '; return PBHelper::formatHTML($html); }
function processShortcodeNivoSlider($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $option = array(); $html = null; $imageHTML = null; $imageBoxHTML = null; $paginationHTML = null; $Validation = new PBValidation(); $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['transition_effect'], $this->effect)) { return $html; } if (!$Validation->isNumber($attribute['count_slice'], 0, 999)) { return $html; } if (!$Validation->isNumber($attribute['count_column'], 0, 999)) { return $html; } if (!$Validation->isNumber($attribute['count_row'], 0, 999)) { return $html; } if (!$Validation->isNumber($attribute['transition_speed'], 0, 99999)) { return $html; } if (!$Validation->isNumber($attribute['pause_time'], 0, 99999)) { return $html; } if (!$Validation->isNumber($attribute['start_slide'], 0, 999)) { return $html; } if (!$Validation->isBool($attribute['preloader_enable'])) { return $html; } if (!$Validation->isBool($attribute['direction_navigation_enable'])) { return $html; } if (!$Validation->isBool($attribute['control_navigation_enable'])) { return $html; } if (!$Validation->isBool($attribute['control_navigation_thumbs_enable'])) { return $html; } if (!$Validation->isBool($attribute['pause_on_hover'])) { return $html; } if (!$Validation->isBool($attribute['manual_advance_enable'])) { return $html; } if (!$Validation->isBool($attribute['random_start_enable'])) { return $html; } $key = array('transition_effect', 'count_slice', 'count_column', 'count_row', 'transition_speed', 'pause_time', 'start_slide', 'preloader_enable', 'direction_navigation_enable', 'control_navigation_enable', 'control_navigation_thumbs_enable', 'pause_on_hover', 'manual_advance_enable', 'random_start_enable'); foreach ($key as $index) { $option[$index] = $attribute[$index]; } $class = array(array(), array()); if ($attribute['preloader_enable'] == 1) { array_push($class[0], 'pb-image-box', 'pb-image-preloader'); } array_push($class[1], 'pb-image'); global $post; $bPost = $post; while ($file->have_posts()) { $file->the_post(); $src = wp_get_attachment_image_src(get_the_ID(), $attribute['image_size']); $url = null; $meta = PBMeta::get($post->ID); PBHelper::removeUIndex($meta, 'media_library_url'); if ($Validation->isNotEmpty($attribute['url'])) { $url = $attribute['url']; } elseif ($Validation->isNotEmpty($meta['media_library_url'])) { $url = $meta['media_library_url']; } if ($Validation->isNotEmpty($url)) { $imageHTML = '<a href="' . esc_attr($url) . '"><img src="' . $src[0] . '" alt=""/></a>'; } else { $imageHTML = '<img src="' . $src[0] . '" alt="" data-thumb="' . $src[0] . '"/>'; } $imageBoxHTML .= ' <div' . PBHelper::createClassAttribute($class[0]) . '> <div' . PBHelper::createClassAttribute($class[1]) . '>' . $imageHTML . '</div> </div> '; } wp_reset_query(); $post = $bPost; $id = PBHelper::createId('pb_nivo_slider'); $class = array(array(), array()); array_push($class[0], 'pb-nivo-slider', $attribute['css_class']); if ($attribute['preloader_enable'] == 1) { array_push($class[1], 'pb-preloader'); } $html = ' <div' . PBHelper::createClassAttribute($class[0]) . '> <div' . PBHelper::createClassAttribute($class[1]) . ' id="' . $id . '"> ' . $imageBoxHTML . ' ' . $paginationHTML . ' </div> </div> <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $(\'#' . $id . '\').PBNivoSlider(' . json_encode($option) . '); }); </script> </div> '; return PBHelper::formatHTML($html); }
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 processShortcodeZAccordion($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $Image = new PBImage(); $Easing = new PBEasing(); $Validation = new PBValidation(); $html = null; $imageHTML = null; $imageBoxHTML = null; $option = array(); if (!array_key_exists($attribute['data_source'], $this->dataSource)) { return $html; } if ($attribute['data_source'] == 1) { $query = PBFile::getImage(explode(',', $attribute['image'])); if ($query === false) { return $html; } if (!count($query->posts)) { return $html; } } else { $argument = array('meta_query' => array(array('key' => '_thumbnail_id'))); if ($Validation->isNotEmpty($attribute['post_type'])) { $argument['post_type'] = explode(',', $attribute['post_type']); } if ($Validation->isNotEmpty($attribute['post_status'])) { $argument['post_status'] = explode(',', $attribute['post_status']); } if ($Validation->isNotEmpty($attribute['post__in'])) { $argument['post__in'] = explode(',', $attribute['post__in']); } if ($Validation->isNotEmpty($attribute['post__not_in'])) { $argument['post__not_in'] = explode(',', $attribute['post__not_in']); } if ($Validation->isNotEmpty($attribute['posts_per_page'])) { $argument['posts_per_page'] = $attribute['posts_per_page'] == -2 ? -1 : $attribute['posts_per_page']; } if ($Validation->isNotEmpty($attribute['orderby'])) { $argument['orderby'] = $attribute['orderby']; } if ($Validation->isNotEmpty($attribute['order'])) { $argument['order'] = $attribute['order']; } $query = new WP_Query($argument); if ($query === false) { return $html; } if ($query->post_count == 0) { return $html; } } if (!PBFile::isWPImage($attribute['image_size'])) { return $html; } if (!$Validation->isBool($attribute['preloader_enable'])) { return $html; } if (!$Validation->isNumber($attribute['starting_slide'], 0, 999)) { return $html; } if (!$Validation->isNumber($attribute['timeout'], 0, 99999)) { return $html; } if (!$Validation->isNumber($attribute['speed'], 0, 99999)) { return $html; } if (!$Validation->isBool($attribute['auto'])) { return $html; } if (!$Validation->isBool($attribute['pause'])) { return $html; } if (!array_key_exists($attribute['easing'], $Easing->easingType)) { return $html; } if (!array_key_exists($attribute['trigger'], $this->tabOpenTriggerEvent)) { return $html; } if (!$Validation->isBool($attribute['display_slide_title'])) { return $html; } if (!$Validation->isBool($attribute['display_slide_excerpt'])) { return $html; } $imageSize = $Image->getImageDimension($attribute['image_size']); if ($imageSize === false) { return $html; } $key = array('preloader_enable', 'starting_slide', 'timeout', 'speed', 'auto', 'pause', 'easing', 'trigger', 'display_slide_title', 'display_slide_excerpt'); foreach ($key as $index) { $option[$index] = $attribute[$index]; } $option['width'] = $imageSize['width']; $option['height'] = $imageSize['height']; $class = array(array(), array(), array(), array()); array_push($class[0], 'pb-zaccordion', $attribute['css_class']); array_push($class[1], 'pb-reset-list'); if ($attribute['preloader_enable'] == 1) { array_push($class[1], 'pb-preloader'); array_push($class[2], 'pb-image-box', 'pb-image-preloader'); } array_push($class[3], 'pb-image'); global $post; $bPost = $post; while ($query->have_posts()) { $query->the_post(); $url = null; if ($attribute['data_source'] == 1) { $meta = PBMeta::get($post->ID); PBHelper::removeUIndex($meta, 'media_library_url'); if ($Validation->isNotEmpty($attribute['url'])) { $url = $attribute['url']; } elseif ($Validation->isNotEmpty($meta['media_library_url'])) { $url = $meta['media_library_url']; } $src = wp_get_attachment_image_src(get_the_ID(), $attribute['image_size']); } else { $url = get_the_permalink(); $src = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), $attribute['image_size']); } $captionHTML = null; if ($attribute['display_slide_title'] == 1) { $captionHTML .= '<span' . PBHelper::createClassAttribute(array('pb-zaccordion-caption-box-title')) . '>' . ($attribute['data_source'] == 1 ? strip_tags(get_the_excerpt()) : get_the_title()) . '</span>'; } if ($attribute['display_slide_excerpt'] == 1) { $captionHTML .= '<span' . PBHelper::createClassAttribute(array('pb-zaccordion-caption-box-excerpt')) . '>' . ($attribute['data_source'] == 1 ? get_the_content() : strip_tags(get_the_excerpt())) . '</span>'; } if ($Validation->isNotEmpty($captionHTML)) { $captionHTML = '<span' . PBHelper::createClassAttribute(array('pb-zaccordion-caption-box"')) . '>' . $captionHTML . '</span>'; } $imageHTML = null; if ($Validation->isNotEmpty($url)) { $imageHTML = '<a href="' . esc_attr($url) . '"' . PBHelper::createClassAttribute($class[3]) . '><img src="' . $src[0] . '" alt=""/>' . $captionHTML . '</a>'; } else { $imageHTML = '<img src="' . $src[0] . '" alt="" data-thumb="' . $src[0] . '"/>' . $captionHTML; } $imageBoxHTML .= ' <li> <div' . PBHelper::createClassAttribute($class[2]) . '>' . $imageHTML . '</div> </li> '; } wp_reset_query(); $post = $bPost; $id = PBHelper::createId('accordion'); $html = ' <div' . PBHelper::createClassAttribute($class[0]) . '> <ul' . PBHelper::createClassAttribute($class[1]) . ' id="' . $id . '"> ' . $imageBoxHTML . ' </ul> </div> <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $(\'#' . $id . '\').PBZAccordion(' . json_encode($option) . '); }); </script> </div> '; return PBHelper::formatHTML($html); }
function createResponse() { if (ob_get_contents()) { ob_clean(); } $response = array(); $response['error'] = 0; $response['field'] = array(); $Validation = new PBValidation(); $Session = new PBSession(); $Session->create(); $id = $_POST['id']; $formMetaData = $Session->getValue($this->getComponentId(), $id); if ($formMetaData === false) { exit; } $response['debug'] = $formMetaData['debug']; $response['reset'] = $formMetaData['reset']; if (!array_key_exists('field', $formMetaData)) { exit; } if (!is_array($formMetaData['field'])) { exit; } if (!count($formMetaData['field'])) { exit; } $response['notice']['error'] = $formMetaData['notice']['error']; $response['notice']['success'] = $formMetaData['notice']['success']; $replace = array(); foreach ($formMetaData['field'] as $fieldIndex => $fieldData) { if ($fieldData['type'] == 'submit') { continue; } if (!array_key_exists($fieldIndex, $_POST)) { $response['error'] = 1; continue; } $value = $_POST[$fieldIndex]; if ($Validation->isNotEmpty($fieldData['name'])) { if (!array_key_exists($fieldData['name'], $replace)) { $replace[$fieldData['name']] = $value; } } if ($fieldData['type'] == 'email') { if ($Validation->isNotEmpty($value) || $fieldData['mandatory'] == 1) { if (!$Validation->isEmailAddress($value)) { $response['error'] = 1; $response['field'][$fieldIndex]['notice'] = $fieldData['notice']; } } } else { if ($fieldData['mandatory'] == 1) { if ($Validation->isEmpty($value)) { $response['error'] = 1; $response['field'][$fieldIndex]['notice'] = $fieldData['notice']; } } } } if ($response['error'] == 1) { PBHelper::ajaxResponse($response); } PBInclude::includeClass(PLUGIN_PAGE_BUILDER_LIBRARY_PATH . 'phpMailer/PHPMailerAutoload.php', array('PHPMailer')); $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; foreach ($replace as $index => $value) { $formMetaData['sender']['name'] = preg_replace('/\\(' . $index . '\\)/', $value, $formMetaData['sender']['name']); $formMetaData['sender']['email'] = preg_replace('/\\(' . $index . '\\)/', $value, $formMetaData['sender']['email']); } if ($Validation->isEmailAddress($formMetaData['sender']['email']) && $Validation->isNotEmpty($formMetaData['sender']['name'])) { $mail->SetFrom($formMetaData['sender']['email'], $formMetaData['sender']['name']); $mail->AddReplyTo($formMetaData['sender']['email'], $formMetaData['sender']['name']); } $mail->AddAddress($formMetaData['recipient']['email'], $formMetaData['recipient']['name']); $recipientAdditionalData = mb_split(';', $formMetaData['recipient']['additional']); foreach ($recipientAdditionalData as $value) { $recipientAdditional = mb_split(':', $value); PBHelper::removeUIndex($recipientAdditional, 0, 1); if ($Validation->isEmailAddress($recipientAdditional[1]) && $Validation->isNotEmpty($recipientAdditional[0])) { $mail->AddAddress($recipientAdditional[1], $recipientAdditional[0]); } } if ($formMetaData['debug'] == 1) { $mail->SMTPDebug = true; } if ($Validation->isNotEmpty($formMetaData['sender']['smtp_host'])) { $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->Port = $formMetaData['sender']['smtp_port']; $mail->Host = $formMetaData['sender']['smtp_host']; $mail->Username = $formMetaData['sender']['smtp_username']; $mail->Password = $formMetaData['sender']['smtp_password']; $mail->SMTPSecure = $formMetaData['sender']['smtp_secure_connection_type']; } $mail->Subject = $formMetaData['message_subject']; $value = array_map('htmlspecialchars', $replace); $body = $formMetaData['message_content']; foreach ($replace as $index => $value) { $body = preg_replace('/\\[' . $index . '\\]/', $value, $body); } $mail->MsgHTML(apply_filters('the_content', $body)); if (!$mail->Send()) { $response['error'] = 1; PBHelper::ajaxResponse($response); } PBHelper::ajaxResponse($response); }
function setupNavigationMenuItemField($menu_item) { $meta = PBMeta::get($menu_item->ID); PBHelper::removeUIndex($meta, 'menu_item_icon', 'menu_item_mega_menu_enable', 'menu_item_mega_menu_layout'); $menu_item->icon = $meta['menu_item_icon']; $menu_item->mega_menu_enable = $meta['menu_item_mega_menu_enable']; $menu_item->mega_menu_layout = $meta['menu_item_mega_menu_layout']; return $menu_item; }
function adminManageColumn($column) { global $post; $option = PBMeta::get($post); PBHelper::removeUIndex($option, 'team_first_name', 'team_second_name'); switch ($column) { case 'team_image': if (has_post_thumbnail($post->ID)) { echo '<a href="' . get_edit_post_link($post->ID) . '">' . get_the_post_thumbnail($post->ID, 'thumbnail') . '</a><br/>'; } break; case 'team_name': echo '<a href="' . get_edit_post_link($post->ID) . '">' . trim($option['team_first_name'] . ' ' . $option['team_second_name']) . '</a><br/>'; break; } return $column; }
function processShortcodeFlexSlider($attribute, $content, $tag) { $Easing = new PBEasing(); $attribute = $this->processAttribute($tag, $attribute); $option = array(); $class = array(array(), array(), array(), array()); $html = null; $imageHTML = null; $imageBoxHTML = null; $Validation = new PBValidation(); $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['easing'], $Easing->easingType)) { return $html; } if (!array_key_exists($attribute['animation'], $this->animation)) { return $html; } if (!array_key_exists($attribute['direction'], $this->direction)) { return $html; } if (!$Validation->isBool($attribute['preloader_enable'])) { return $html; } if (!$Validation->isNumber($attribute['start_at'], 0, 999)) { return $html; } if (!$Validation->isNumber($attribute['init_delay'], 0, 99999)) { return $html; } if (!$Validation->isNumber($attribute['slideshow_speed'], 0, 99999)) { return $html; } if (!$Validation->isNumber($attribute['animation_speed'], 0, 99999)) { return $html; } if (!$Validation->isBool($attribute['touch'])) { return $html; } if (!$Validation->isBool($attribute['reverse'])) { return $html; } if (!$Validation->isBool($attribute['use_css'])) { return $html; } if (!$Validation->isBool($attribute['keyboard'])) { return $html; } if (!$Validation->isBool($attribute['slideshow'])) { return $html; } if (!$Validation->isBool($attribute['randomize'])) { return $html; } if (!$Validation->isBool($attribute['mousewheel'])) { return $html; } if (!$Validation->isBool($attribute['control_nav'])) { return $html; } if (!$Validation->isBool($attribute['direction_nav'])) { return $html; } if (!$Validation->isBool($attribute['smooth_height'])) { return $html; } if (!$Validation->isBool($attribute['animation_loop'])) { return $html; } if (!$Validation->isBool($attribute['pause_on_hover'])) { return $html; } if (!$Validation->isBool($attribute['pause_on_action'])) { return $html; } if (!$Validation->isBool($attribute['multiple_keyboard'])) { return $html; } $key = array('easing', 'animation', 'direction', 'start_at', 'init_delay', 'slideshow_speed', 'animation_speed', 'preloader_enable', 'touch', 'use_css', 'reverse', 'keyboard', 'slideshow', 'randomize', 'mousewheel', 'control_nav', 'direction_nav', 'smooth_height', 'pause_on_hover', 'animation_loop', 'pause_on_action', 'multiple_keyboard'); foreach ($key as $index) { $option[$index] = $attribute[$index]; } if ($attribute['preloader_enable'] == 1) { array_push($class[0], 'pb-image-box', 'pb-image-preloader'); } array_push($class[1], 'pb-image'); global $post; $bPost = $post; while ($file->have_posts()) { $file->the_post(); $src = wp_get_attachment_image_src(get_the_ID(), $attribute['image_size']); $url = null; $meta = PBMeta::get($post->ID); PBHelper::removeUIndex($meta, 'media_library_url'); if ($Validation->isNotEmpty($attribute['url'])) { $url = $attribute['url']; } elseif ($Validation->isNotEmpty($meta['media_library_url'])) { $url = $meta['media_library_url']; } if ($Validation->isNotEmpty($url)) { $imageHTML = '<a href="' . esc_attr($url) . '"><img src="' . $src[0] . '" alt=""/></a>'; } else { $imageHTML = '<img src="' . $src[0] . '" alt="" data-thumb="' . $src[0] . '"/>'; } $imageBoxHTML .= ' <li' . PBHelper::createClassAttribute($class[0]) . '> <div' . PBHelper::createClassAttribute($class[1]) . '>' . $imageHTML . '</div> </li> '; } wp_reset_query(); $post = $bPost; $id = PBHelper::createId('pb_flex_slider'); array_push($class[2], 'pb-flex-slider', $attribute['css_class']); if ($attribute['preloader_enable'] == 1) { array_push($class[2], 'pb-preloader'); } array_push($class[3], 'pb-reset-list', 'slides'); $html = ' <div' . PBHelper::createClassAttribute($class[2]) . ' id="' . $id . '"> <ul' . PBHelper::createClassAttribute($class[3]) . '> ' . $imageBoxHTML . ' </ul> </div> <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $(\'#' . $id . '\').PBFlexSlider(' . json_encode($option) . '); }); </script> </div> '; return PBHelper::formatHTML($html); }
function validateProperty($property) { $data = array(); $Validation = new PBValidation(); foreach ($property as $name => $value) { $unit = 'px'; if (is_array($value)) { if (isset($value['unit'])) { $unit = $value['unit']; } if (isset($value['value'])) { $value = $value['value']; } } switch ($name) { case 'left': case 'width': case 'height': case 'font-size': case 'padding-top': case 'padding-left': case 'padding-right': case 'padding-bottom': if ($Validation->isNumber($value, 0, 9999)) { $data[$name] = $value . $unit; } break; case 'top': case 'margin-top': case 'margin-left': case 'margin-right': case 'margin-bottom': if ($Validation->isNumber($value, -9999, 9999)) { $data[$name] = $value . $unit; } break; case 'color': case 'border-color': case 'border-top-color': case 'border-right-color': case 'border-bottom-color': case 'border-left-color': case 'outline-color': case 'background-color': $value = PBColor::getColor($value); if ($Validation->isNotEmpty($value)) { $data[$name] = $value; } break; case 'font-family': foreach ((array) $value as $family) { if ($Validation->isNotEmpty($family)) { PBHelper::removeUIndex($data, $name); if ($Validation->isNotEmpty($data[$name])) { $data[$name] .= ','; } $data[$name] .= '\'' . $family . '\''; } } break; case 'font-style': if (isset($this->fontStyle[$value])) { $data[$name] = $value; } break; case 'font-weight': if (isset($this->fontWeight[$value])) { $data[$name] = $value; } break; case 'display': case 'background': case 'background-repeat': case 'background-position': if ($Validation->isNotEmpty($value)) { $data[$name] = $value; } break; case 'background-image': if ($Validation->isNotEmpty($value)) { $data[$name] = 'url(\'' . $value . '\')'; } break; } } return $data; }
function processShortcodeSupersized($attribute, $content, $tag) { $attribute = $this->processAttribute($tag, $attribute); $html = null; $Validation = new PBValidation(); $file = PBFile::getImage(explode(',', $attribute['image'])); if ($file === false) { return $html; } if (!count($file->posts)) { return $html; } if (!$Validation->isBool($attribute['autoplay'])) { return $html; } if (!$Validation->isBool($attribute['fit_always'])) { return $html; } if (!$Validation->isBool($attribute['fit_landscape'])) { return $html; } if (!$Validation->isBool($attribute['fit_portrait'])) { return $html; } if (!$Validation->isBool($attribute['horizontal_center'])) { return $html; } if (!$Validation->isBool($attribute['vertical_center'])) { return $html; } if (!$Validation->isNumber($attribute['min_width'], 0, 99999)) { return $html; } if (!$Validation->isNumber($attribute['min_height'], 0, 99999)) { return $html; } if (!$Validation->isBool($attribute['image_protect'])) { return $html; } if (!$Validation->isBool($attribute['keyboard_nav'])) { return $html; } if (!$Validation->isBool($attribute['new_window'])) { return $html; } if (!$Validation->isBool($attribute['pause_hover'])) { return $html; } if (!$Validation->isBool($attribute['random'])) { return $html; } if (!$Validation->isNumber($attribute['start_slide'], 0, 99999)) { return $html; } if (!$Validation->isBool($attribute['stop_loop'])) { return $html; } if (!array_key_exists($attribute['performance'], $this->performance)) { return $html; } if (!array_key_exists($attribute['transition'], $this->transition)) { return $html; } if (!$Validation->isNumber($attribute['transition_speed'], 0, 99999)) { return $html; } if (!$Validation->isNumber($attribute['slide_interval'], 0, 99999)) { return $html; } $option = array(); $key = array('autoplay', 'fit_always', 'fit_landscape', 'fit_portrait', 'horizontal_center', 'vertical_center', 'min_width', 'min_height', 'image_protect', 'keyboard_nav', 'new_window', 'pause_hover', 'random', 'start_slide', 'stop_loop', 'performance', 'transition', 'transition_speed', 'slide_interval', 'css_class'); foreach ($key as $index) { $option[$index] = $attribute[$index]; } global $post; $bPost = $post; $i = 0; while ($file->have_posts()) { global $post; $file->the_post(); $meta = PBMeta::get($post); PBHelper::removeUIndex($meta, 'media_library_url'); $full = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $option['slides'][$i]['url'] = $meta['media_library_url']; $option['slides'][$i]['image'] = $full[0]; $option['slides'][$i]['title'] = get_the_title(); $i++; } wp_reset_query(); $post = $bPost; $html = ' <div class="pb-script-tag"> <script type="text/javascript"> jQuery(document).ready(function($) { $().PBSupersized(' . json_encode($option) . '); }); </script> </div> '; return PBHelper::formatHTML($html); }
function setComponentValueMultiField($elementData, $index) { $id = $elementData['id']; if (!array_key_exists($id, $this->componentValue)) { $this->componentValue[$id] = array(); } if (!is_array($this->componentValue[$id])) { $this->componentValue[$id] = array(); } if (!array_key_exists($index, $this->componentValue[$id])) { if (array_key_exists('element', $elementData['ui'])) { if (array_key_exists('value', $elementData['ui']['element'])) { $this->componentValue[$id][$index] = $elementData['ui']['element']['value']; } } } PBHelper::removeUIndex($this->componentValue[$id], $index); }