/** * Do shortcode & Return final html output for frontend * * @param type $content */ public static function doshortcode_content($ig_pagebuilder_content) { // remove placeholder text which was inserted to < and > $ig_pagebuilder_content = IG_Pb_Utils_Placeholder::remove_placeholder($ig_pagebuilder_content, 'wrapper_append', ''); $ig_pagebuilder_content = preg_replace_callback('/\\[ig_widget\\s+([A-Za-z0-9_-]+=\\"[^"\']*\\"\\s*)*\\s*\\](.*)\\[\\/ig_widget\\]/Us', array('self', 'widget_content'), $ig_pagebuilder_content); $output = do_shortcode($ig_pagebuilder_content); return $output; }
/** * Show IG 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 $ig_page_active_tab = get_post_meta($post->ID, '_ig_page_active_tab', true); $ig_deactivate_pb = get_post_meta($post->ID, '_ig_deactivate_pb', true); // if Pagebuilder is active when save and pagebuilder is not deactivate on this post if ($ig_page_active_tab && empty($ig_deactivate_pb)) { $ig_pagebuilder_content = get_post_meta($post->ID, '_ig_page_builder_content', true); if (!empty($ig_pagebuilder_content)) { // remove placeholder text which was inserted to < and > $ig_pagebuilder_content = IG_Pb_Utils_Placeholder::remove_placeholder($ig_pagebuilder_content, 'wrapper_append', ''); $ig_pagebuilder_content = preg_replace_callback('/\\[ig_widget\\s+([A-Za-z0-9_-]+=\\"[^"\']*\\"\\s*)*\\s*\\](.*)\\[\\/ig_widget\\]/Us', array('IG_Pb_Helper_Shortcode', 'widget_content'), $ig_pagebuilder_content); $content = $ig_pagebuilder_content; } } return $content; }
/** * 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 = IG_Pb_Utils_Common::random_string(); $tab_navigator = array(); $tab_navigator[] = '<ul class="nav nav-tabs">'; $sub_shortcode = IG_Pb_Helper_Shortcode::remove_autop($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> " : ''; $heading = !empty($ex_heading[0]) ? $ex_heading[0] : __('Tab Item ') . ' ' . $idx; IG_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}' data-toggle='tab'>{$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 = IG_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); }