/** * 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); }
/** * 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)))); }
/** * 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'))); }
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'))); }
/** * print HTML template of shortcodes */ function element_tpl() { ob_start(); // Print template for WR PageBuilder elements $elements = $this->get_elements(); foreach ($elements as $type_list) { foreach ($type_list as $element) { // Get element type $element_type = $element->element_in_pgbldr(null, null, null, null, false); // Print template tag foreach ($element_type as $element_structure) { echo balanceTags("<script type='text/html' id='tmpl-{$element->config['shortcode']}'>\n{$element_structure}\n</script>\n"); } } } // Print widget template global $Wr_Pb_Widgets; if (class_exists('WR_Widget')) { foreach ($Wr_Pb_Widgets as $shortcode => $shortcode_obj) { // Instantiate Widget element $element = new WR_Widget(); // Prepare necessary variables $modal_title = $shortcode_obj['identity_name']; $content = $element->config['exception']['data-modal-title'] = $modal_title; $element->config['shortcode'] = $shortcode; $element->config['shortcode_structure'] = WR_Pb_Utils_Placeholder::add_placeholder("[wr_widget widget_id=\"{$shortcode}\"]%s[/wr_widget]", 'widget_title'); $element->config['el_type'] = 'widget'; // Get element type $element_type = $element->element_in_pgbldr(null, null, null, null, false); // Print template tag foreach ($element_type as $element_structure) { echo balanceTags("<script abc type='text/html' id='tmpl-{$shortcode}'>\n{$element_structure}\n</script>\n"); } } } // Allow printing extra footer do_action('wr_pb_footer'); ob_end_flush(); }
/** * 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)))); }