Example #1
0
 /**
  * Generate HTML code from shortcode content.
  *
  * @param   array   $atts     Shortcode attributes.
  * @param   string  $content  Current content.
  *
  * @return  string
  */
 public function element_shortcode_full($atts = null, $content = null)
 {
     $arr_params = shortcode_atts($this->config['params'], $atts);
     $initial_open = intval($arr_params['initial_open']);
     $tab_position = $arr_params['tab_position'];
     $random_id = WR_Pb_Utils_Common::random_string();
     $tab_navigator = array();
     $tab_navigator[] = '<ul class="nav nav-tabs">';
     $sub_shortcode = do_shortcode($content);
     $items = explode('<!--seperate-->', $sub_shortcode);
     $items = array_filter($items);
     $initial_open = $initial_open > count($items) ? 1 : $initial_open;
     $fade_effect = '';
     if ($arr_params['fade_effect'] == 'yes') {
         $fade_effect = 'fade in';
     }
     foreach ($items as $idx => $item) {
         // Extract icon & heading
         $ex_heading = explode('<!--heading-->', $item);
         $ex_icon = explode('<!--icon-->', isset($ex_heading[1]) ? $ex_heading[1] : '');
         $new_key = $random_id . $idx;
         $active = $idx + 1 == $initial_open ? 'active' : '';
         $item = isset($ex_icon[1]) ? $ex_icon[1] : '';
         $item = str_replace('{index}', $new_key, $item);
         $item = str_replace('{active}', $active, $item);
         $item = str_replace('{fade_effect}', $fade_effect, $item);
         $items[$idx] = $item;
         $icon = !empty($ex_icon[0]) ? "<i class='{$ex_icon[0]}'></i>&nbsp;" : '';
         $heading = !empty($ex_heading[0]) ? $ex_heading[0] : __('Tab Item ') . ' ' . $idx;
         WR_Pb_Helper_Functions::heading_icon($heading, $icon);
         $active_li = $idx + 1 == $initial_open ? "class='active'" : '';
         $tab_navigator[] = "<li {$active_li}><a href='#pane{$new_key}'>{$icon}{$heading}</a></li>";
     }
     $sub_shortcode = implode('', $items);
     $tab_content = "<div class='tab-content'>{$sub_shortcode}</div>";
     // update min-height of each tab content in case tap position is left/right
     if (in_array($tab_position, array('left', 'right'))) {
         $min_height = 36 * count($items);
         $tab_content = WR_Pb_Utils_Placeholder::remove_placeholder($tab_content, 'custom_style', "style='min-height: {$min_height}px'");
     }
     $tab_navigator[] = '</ul>';
     $tab_positions = array('top' => '', 'left' => 'tabs-left', 'right' => 'tabs-right', 'bottom' => 'tabs-below');
     $extra_class = $tab_positions[$tab_position];
     if ($tab_position == 'bottom') {
         $tab_content .= implode('', $tab_navigator);
     } else {
         $tab_content = implode('', $tab_navigator) . $tab_content;
     }
     $html_element = "<div class='tabbable {$extra_class}' id='tab_{ID}'>{$tab_content}</div>";
     $html_element = str_replace('{ID}', "{$random_id}", $html_element);
     return $this->element_wrapper($html_element, $arr_params);
 }
Example #2
0
 /**
  * Show WR PageBuilder content for Frontend post
  *
  * @param string $content
  * @return string
  */
 function pagebuilder_to_frontend($content)
 {
     global $post;
     // Get what tab (Classic - Pagebuilder) is active when Save content of this post
     $wr_page_active_tab = get_post_meta($post->ID, '_wr_page_active_tab', true);
     $wr_deactivate_pb = get_post_meta($post->ID, '_wr_deactivate_pb', true);
     // Check password protected in post
     $allow_show_post = false;
     if ('publish' == $post->post_status && empty($post->post_password)) {
         $allow_show_post = true;
     }
     // if Pagebuilder is active when save and pagebuilder is not deactivate on this post
     if ($wr_page_active_tab && empty($wr_deactivate_pb) && $allow_show_post == true) {
         $wr_pagebuilder_content = get_post_meta($post->ID, '_wr_page_builder_content', true);
         if (!empty($wr_pagebuilder_content)) {
             // remove placeholder text which was inserted to &lt; and &gt;
             $wr_pagebuilder_content = WR_Pb_Utils_Placeholder::remove_placeholder($wr_pagebuilder_content, 'wrapper_append', '');
             $wr_pagebuilder_content = preg_replace_callback('/\\[wr_widget\\s+([A-Za-z0-9_-]+=\\"[^"\']*\\"\\s*)*\\s*\\](.*)\\[\\/wr_widget\\]/Us', array('WR_Pb_Helper_Shortcode', 'widget_content'), $wr_pagebuilder_content);
             $content = $wr_pagebuilder_content;
         }
     }
     return $content;
 }
Example #3
0
 /**
  * Do shortcode & Return final html output for frontend
  *
  * @param type $content
  */
 public static function doshortcode_content($wr_pagebuilder_content)
 {
     // remove placeholder text which was inserted to &lt; and &gt;
     $wr_pagebuilder_content = WR_Pb_Utils_Placeholder::remove_placeholder($wr_pagebuilder_content, 'wrapper_append', '');
     $wr_pagebuilder_content = preg_replace_callback('/\\[wr_widget\\s+([A-Za-z0-9_-]+=\\"[^"\']*\\"\\s*)*\\s*\\](.*)\\[\\/wr_widget\\]/Us', array('self', 'widget_content'), $wr_pagebuilder_content);
     $output = do_shortcode($wr_pagebuilder_content);
     return $output;
 }
Example #4
0
 /**
  * Get style info
  *
  * @param array $element
  * @param type $output
  * @return type
  */
 static function get_style($element, $output)
 {
     $style = !empty($element['style']) ? $element['style'] : '';
     if (is_array($element['style'])) {
         $styles = array();
         foreach ($element['style'] as $att_name => $att_value) {
             $styles[] = "{$att_name} : {$att_value}";
         }
         $styles = "style = '" . implode(';', $styles) . "'";
     } else {
         $styles = '';
     }
     $output = WR_Pb_Utils_Placeholder::remove_placeholder($output, 'custom_style', $styles);
     return $output;
 }