/** * DEFINE shortcode content * * @param type $atts * @param type $content */ public function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $inner_content = WR_Pb_Helper_Shortcode::remove_autop($content); $custom_style = WR_Pb_Utils_Placeholder::get_placeholder('custom_style'); return "{$heading}<!--heading-->{$icon}<!--icon--><div id='pane{index}' class='tab-pane {active} {fade_effect}' {$custom_style}>\n\t\t\t{$inner_content}\n\t\t\t\t</div><!--seperate-->"; }
/** * * @param type $content : inner shortcode elements of this row * @param type $shortcode_data : not used * @return string */ public function element_in_pgbldr($content = '', $shortcode_data = '') { if (empty($content)) { $column = new WR_Column(); $column_html = $column->element_in_pgbldr(); $column_html = $column_html[0]; } else { $column_html = WR_Pb_Helper_Shortcode::do_shortcode_admin($content); } if (empty($shortcode_data)) { $shortcode_data = $this->config['shortcode_structure']; } // remove [/wr_row][wr_column...] from $shortcode_data $shortcode_data = explode('][', $shortcode_data); $shortcode_data = $shortcode_data[0] . ']'; // Remove empty value attributes of shortcode tag. $shortcode_data = preg_replace('/\\[*([a-z_]*[\\n\\s\\t]*=[\\n\\s\\t]*"")/', '', $shortcode_data); $custom_style = WR_Pb_Utils_Placeholder::get_placeholder('custom_style'); $row[] = '<div class="jsn-row-container ui-sortable row-fluid shortcode-container" ' . $custom_style . '> <textarea class="hidden" data-sc-info="shortcode_content" name="shortcode_content[]" >' . $shortcode_data . '</textarea> <div class="jsn-iconbar left"> <a href="javascript:void(0);" title="' . __('Move Up', WR_PBL) . '" class="jsn-move-up disabled"><i class="icon-chevron-up"></i></a> <a href="javascript:void(0);" title="' . __('Move Down', WR_PBL) . '" class="jsn-move-down disabled"><i class=" icon-chevron-down"></i></a> </div> <div class="wr-row-content"> ' . $column_html . ' </div> <div class="jsn-iconbar jsn-vertical"> <a href="javascript:void(0);" class="add-container" title="' . __('Add column', WR_PBL) . '"><i class="wr-icon-add-col"></i></a> <a href="javascript:void(0);" title="Edit row" data-shortcode="' . $this->config['shortcode'] . '" class="element-edit row" data-use-ajax="' . ($this->config['edit_using_ajax'] ? 1 : 0) . '"><i class="icon-pencil"></i></a> <a href="javascript:void(0);" class="item-delete row" title="' . __('Delete row', WR_PBL) . '"><i class="icon-trash"></i></a> </div> <textarea class="hidden" name="shortcode_content[]" >[/' . $this->config['shortcode'] . ']</textarea> </div>'; return $row; }
/** * 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> " : ''; $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); }
/** * DEFINE html structure of shortcode in Page Builder area * * @param string $content * @param string $shortcode_data: string stores params (which is modified default value) of shortcode * @param string $el_title: Element Title used to identifying elements in WR PageBuilder * @param int $index * @param bool $inlude_sc_structure * @param array $extra_params * Ex: param-tag=h6¶m-text=Your+heading¶m-font=custom¶m-font-family=arial * @return string */ public function element_in_pgbldr($content = '', $shortcode_data = '', $el_title = '', $index = '', $inlude_sc_structure = true, $extra_params = array()) { // Init neccessary data to render element in backend. $this->init_element(); $shortcode = $this->config['shortcode']; $is_sub_element = isset($this->config['sub_element']) ? true : false; $parent_shortcode = $is_sub_element ? str_replace('wr_item_', '', $shortcode) : $shortcode; $type = !empty($this->config['el_type']) ? $this->config['el_type'] : 'widget'; // Empty content if this is not sub element if (!$is_sub_element) { $content = ''; } $exception = isset($this->config['exception']) ? $this->config['exception'] : array(); $content = isset($exception['default_content']) ? $exception['default_content'] : $content; $modal_title = ''; // if is widget if ($type == 'widget') { global $Wr_Pb_Widgets; if (isset($Wr_Pb_Widgets[$shortcode]) && is_array($Wr_Pb_Widgets[$shortcode]) && isset($Wr_Pb_Widgets[$shortcode]['identity_name'])) { $modal_title = $Wr_Pb_Widgets[$shortcode]['identity_name']; $content = $this->config['exception']['data-modal-title'] = $modal_title; } } // if content is still empty, Generate it if (empty($content)) { if (!$is_sub_element) { $content = ucfirst(str_replace('wr_', '', $shortcode)); } else { if (isset($exception['item_text'])) { if (!empty($exception['item_text'])) { $content = WR_Pb_Utils_Placeholder::add_placeholder($exception['item_text'] . ' %s', 'index'); } } else { $content = WR_Pb_Utils_Placeholder::add_placeholder(__(ucfirst($parent_shortcode), WR_PBL) . ' ' . __('Item', WR_PBL) . ' %s', 'index'); } } } $content = !empty($el_title) ? $content . ': ' . "<span>{$el_title}</span>" : $content; // element name if ($type == 'element') { if (!$is_sub_element) { $name = ucfirst(str_replace('wr_', '', $shortcode)); } else { $name = __(ucfirst($parent_shortcode), WR_PBL) . ' ' . __('Item', WR_PBL); } } else { $name = $content; } if (empty($shortcode_data)) { $shortcode_data = $this->config['shortcode_structure']; } // Process index for subitem element if (!empty($index)) { $shortcode_data = str_replace('_WR_INDEX_', $index, $shortcode_data); } $shortcode_data = stripslashes($shortcode_data); $element_wrapper = !empty($exception['item_wrapper']) ? $exception['item_wrapper'] : ($is_sub_element ? 'li' : 'div'); $content_class = $is_sub_element ? 'jsn-item-content' : 'wr-pb-element'; $modal_title = empty($modal_title) ? !empty($exception['data-modal-title']) ? "data-modal-title='{$exception['data-modal-title']}'" : '' : $modal_title; $element_type = "data-el-type='{$type}'"; $edit_using_ajax = isset($this->config['edit_using_ajax']) && $this->config['edit_using_ajax'] ? sprintf("data-using-ajax='%s'", esc_attr($this->config['edit_using_ajax'])) : ''; $data = array('element_wrapper' => $element_wrapper, 'modal_title' => $modal_title, 'element_type' => $element_type, 'edit_using_ajax' => $edit_using_ajax, 'edit_inline' => isset($this->config['edit_inline']) ? 1 : 0, 'name' => $name, 'shortcode' => $shortcode, 'shortcode_data' => $shortcode_data, 'content_class' => $content_class, 'content' => $content, 'action_btn' => empty($exception['action_btn']) ? '' : $exception['action_btn'], 'is_sub_element' => $is_sub_element); // Merge extra params if it exists. if (!empty($extra_params)) { $data = array_merge($data, $extra_params); } $extra = array(); if (isset($this->config['exception']['disable_preview_container'])) { $extra = array('has_preview' => FALSE); } $data = array_merge($data, $extra); $html_preview = WR_Pb_Helper_Functions::get_element_item_html($data, $inlude_sc_structure); return array($html_preview); }
/** * Handle empty icon & heading for Carousel, ,Tab, Accordion, List item * * @param type $heading * @param type $icon */ static function heading_icon(&$heading, &$icon, $heading_empty = false) { if (strpos($heading, WR_Pb_Utils_Placeholder::get_placeholder('index')) !== false) { $heading = ''; } if (empty($icon) && empty($heading)) { $heading = !$heading_empty ? __('(Untitled)', WR_PBL) : ''; } }
/** * DEFINE setting options of shortcode */ public function element_items() { $this->items = array('Notab' => array(array('name' => __('Heading', WR_PBL), 'id' => 'heading', 'type' => 'text_field', 'class' => 'jsn-input-xxlarge-fluid', 'role' => 'title', 'std' => __(WR_Pb_Utils_Placeholder::add_placeholder('List Item %s', 'index'), WR_PBL)), array('name' => __('Body', WR_PBL), 'id' => 'body', 'role' => 'content', 'type' => 'text_area', 'container_class' => 'wr_tinymce_replace', 'std' => WR_Pb_Helper_Type::lorem_text()), array('name' => __('Icon', WR_PBL), 'id' => 'icon', 'type' => 'icons', 'std' => '', 'role' => 'title_prepend', 'title_prepend_type' => 'icon'))); }
/** * DEFINE setting options of shortcode */ public function element_items() { $this->items = array('Notab' => array(array('name' => __('Title', WR_PBL), 'id' => 'elm_title', 'type' => 'text_field', 'role' => 'title', 'std' => __(WR_Pb_Utils_Placeholder::add_placeholder('Testimonial Item %s', 'index'), WR_PBL)), array('name' => __('Client\'s Name', WR_PBL), 'type' => array(array('id' => 'name', 'type' => 'text_field', 'std' => '', 'placeholder' => 'John Doe', 'parent_class' => 'combo-item input-append-inline'), array('id' => 'name_height', 'type' => 'text_append', 'type_input' => 'number', 'class' => 'input-mini', 'std' => '12', 'append' => 'px', 'validate' => 'number', 'parent_class' => 'combo-item input-append-inline'), array('id' => 'name_color', 'type' => 'color_picker', 'std' => '', 'parent_class' => 'combo-item')), 'tooltip' => __('Client\'s Name Description', WR_PBL), 'container_class' => 'combo-group'), array('name' => __('Client\'s Position', WR_PBL), 'id' => 'job_title', 'type' => 'text_field', 'std' => __('', WR_PBL), 'tooltip' => __('Client\'s Position Description', WR_PBL), 'placeholder' => 'CEO'), array('name' => __('Feedback Content', WR_PBL), 'id' => 'body', 'role' => 'content', 'type' => 'tiny_mce', 'std' => WR_Pb_Helper_Type::lorem_text()), array('name' => __('Country', WR_PBL), 'id' => 'country', 'type' => 'text_field', 'std' => __('', WR_PBL), 'tooltip' => __('Country Description', WR_PBL)), array('name' => __('Company', WR_PBL), 'id' => 'company', 'type' => 'text_field', 'std' => __('', WR_PBL), 'tooltip' => __('Company Description', WR_PBL)), array('name' => __('Website URL', WR_PBL), 'id' => 'web_url', 'type' => 'text_field', 'std' => __('http://', WR_PBL), 'tooltip' => __('Website URL Description', WR_PBL)), array('name' => __('Avatar', WR_PBL), 'id' => 'image_file', 'type' => 'select_media', 'std' => '', 'class' => 'jsn-input-large-fluid', 'tooltip' => __('Image File for User', WR_PBL)))); }
public function element_items() { $this->items = array('Notab' => array(array('name' => __('Title', WR_PBL), 'id' => 'gmi_title', 'type' => 'text_field', 'role' => 'title', 'std' => __(WR_Pb_Utils_Placeholder::add_placeholder('Marker %s', 'index'), WR_PBL), 'tooltip' => __('Title', WR_PBL)), array('name' => __('Description', WR_PBL), 'id' => 'gmi_desc_content', 'role' => 'content', 'type' => 'text_area', 'std' => __('Description of marker', WR_PBL), 'tooltip' => __('Description', WR_PBL), 'container_class' => 'wr_tinymce_replace'), array('name' => __('Link URL', WR_PBL), 'id' => 'gmi_url', 'type' => 'text_field', 'std' => 'http://', 'tooltip' => __('Link URL', WR_PBL)), array('name' => __('Image', WR_PBL), 'id' => 'gmi_image', 'type' => 'select_media', 'std' => '', 'class' => 'jsn-input-large-fluid', 'tooltip' => __('Image', WR_PBL), 'filter_type' => 'image'), array('name' => __('Location', WR_PBL), 'id' => 'gmi_location', 'type' => array(array('id' => 'gmi_long', 'type' => 'text_append', 'input_type' => 'number', 'class' => 'jsn-input-number input-small', 'std' => rand(0, 10), 'parent_class' => 'input-group-inline', 'append_before' => __('Long', WR_PBL)), array('id' => 'gmi_lat', 'type' => 'text_append', 'input_type' => 'number', 'class' => 'jsn-input-number input-small', 'std' => rand(0, 10), 'parent_class' => 'input-group-inline', 'append_before' => __('Lat', WR_PBL))), 'tooltip' => __('Location', WR_PBL), 'container_class' => 'combo-group'), array('name' => __('Enable Direction', WR_PBL), 'id' => 'gmi_enable_direct', 'type' => 'radio', 'std' => 'no', 'options' => array('yes' => __('Yes', WR_PBL), 'no' => __('No', WR_PBL)), 'tooltip' => 'Enable Direction', 'has_depend' => '1'), array('name' => __('Destination', WR_PBL), 'id' => 'gmi_destination', 'type' => 'destination', 'tooltip' => __('Destination', WR_PBL), 'dependency' => array('gmi_enable_direct', '=', 'yes')))); }
/** * DEFINE setting options of shortcode */ public function element_items() { $this->items = array('Notab' => array(array('name' => __('Image File', WR_PBL), 'id' => 'image_file', 'type' => 'select_media', 'std' => '', 'class' => 'jsn-input-large-fluid'), array('name' => __('Heading', WR_PBL), 'id' => 'heading', 'type' => 'text_field', 'class' => 'input-sm', 'role' => 'title', 'std' => __(WR_Pb_Utils_Placeholder::add_placeholder('Carousel Item %s', 'index'), WR_PBL)), array('name' => __('Alt Description', WR_PBL), 'id' => 'alt', 'type' => 'text_field', 'class' => 'input-sm', 'std' => __(WR_Pb_Utils_Placeholder::add_placeholder('Item description %s', 'index'), WR_PBL)), array('name' => __('Body', WR_PBL), 'id' => 'body', 'role' => 'content', 'type' => 'text_area', 'container_class' => 'wr_tinymce_replace', 'std' => WR_Pb_Helper_Type::lorem_text(12) . '<a href="#"> link</a>'), array('name' => __('Icon', WR_PBL), 'id' => 'icon', 'type' => 'icons', 'std' => '', 'role' => 'title_prepend', 'title_prepend_type' => 'icon'))); }
/** * 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 < and > $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; }
/** * 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 < and > $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; }
/** * 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; }
/** * DEFINE setting options of shortcode */ public function element_items() { $this->items = array('Notab' => array(array('name' => __('Heading', WR_PBL), 'id' => 'heading', 'type' => 'text_field', 'class' => 'input-sm', 'role' => 'title', 'std' => __(WR_Pb_Utils_Placeholder::add_placeholder('Accordion Item %s', 'index'), WR_PBL)), array('name' => __('Body', WR_PBL), 'id' => 'body', 'role' => 'content', 'type' => 'text_area', 'container_class' => 'wr_tinymce_replace', 'std' => WR_Pb_Helper_Type::lorem_text()), array('name' => __('Icon', WR_PBL), 'id' => 'icon', 'type' => 'icons', 'std' => '', 'role' => 'title_prepend', 'title_prepend_type' => 'icon'), array('name' => __('Tag Name', WR_PBL), 'id' => 'tag', 'type' => 'tag', 'std' => '', 'tooltip' => __('Used for items filtering', WR_PBL)))); }
/** * Define shortcode settings. * * @return void */ public function element_items() { $this->items = array('Notab' => array(array('name' => __('Text', WR_PBL), 'id' => 'button_text', 'type' => 'text_field', 'std' => __(WR_Pb_Utils_Placeholder::add_placeholder('ButtonBar Item %s', 'index'), WR_PBL), 'role' => 'title'), array('name' => __('On Click', WR_PBL), 'id' => 'link_type', 'type' => 'select', 'class' => 'input-sm', 'std' => 'url', 'options' => WR_Pb_Helper_Type::get_link_types(), 'has_depend' => '1', 'tooltip' => __('Select link types: link to post, page, category...', WR_PBL)), array('name' => __('URL', WR_PBL), 'id' => 'button_type_url', 'type' => 'text_field', 'class' => 'input-sm', 'std' => 'http://', 'dependency' => array('link_type', '=', 'url')), array('name' => __('Single Item', WR_PBL), 'id' => 'single_item', 'type' => 'type_group', 'std' => '', 'items' => WR_Pb_Helper_Type::get_single_item_button_bar('link_type', array('type' => 'items_list', 'options_type' => 'select', 'class' => 'select2-select', 'ul_wrap' => false))), array('name' => __('Open in', WR_PBL), 'id' => 'open_in', 'type' => 'select', 'class' => 'input-sm', 'std' => WR_Pb_Helper_Type::get_first_option(WR_Pb_Helper_Type::get_open_in_options()), 'options' => WR_Pb_Helper_Type::get_open_in_options(), 'dependency' => array('link_type', '!=', 'no_link'), 'tooltip' => __('Select type of opening action when click on element', WR_PBL)), array('name' => __('Icon', WR_PBL), 'id' => 'icon', 'type' => 'icons', 'std' => '', 'role' => 'title_prepend', 'title_prepend_type' => 'icon'), array('name' => __('Size', WR_PBL), 'id' => 'button_size', 'type' => 'select', 'class' => 'input-sm', 'std' => WR_Pb_Helper_Type::get_first_option(WR_Pb_Helper_Type::get_button_size()), 'options' => WR_Pb_Helper_Type::get_button_size(), 'has_depend' => '1'), array('name' => __('Custom dimensions', WR_PBL), 'id' => 'custom_dimensions', 'type' => array(array('id' => 'button_width', 'type' => 'text_append', 'type_input' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => '', 'append_before' => '<i class="input-mini wr-label-prefix">' . __('Width', WR_PBL) . '</i>', 'append' => 'px', 'validate' => 'number'), array('id' => 'button_height', 'type' => 'text_append', 'type_input' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => '', 'append_before' => '<i class="input-mini wr-label-prefix">' . __('Height', WR_PBL) . '</i>', 'append' => 'px', 'validate' => 'number')), 'container_class' => 'combo-group', 'dependency' => array('button_size', '=', 'custom')), array('name' => __('Color', WR_PBL), 'id' => 'button_color', 'type' => 'select', 'std' => WR_Pb_Helper_Type::get_first_option(WR_Pb_Helper_Type::get_button_color()), 'options' => WR_Pb_Helper_Type::get_button_color(), 'container_class' => 'color_select2', 'tooltip' => __('Select the color of the button', WR_PBL)))); }