/** * Group items * * @param type $element * * @return string */ static function render($element) { $_element = $element; $label_item = isset($element['label_item']) ? $element['label_item'] : ''; $sub_items = $_element['sub_items']; $overwrite_shortcode_data = isset($element['overwrite_shortcode_data']) ? $element['overwrite_shortcode_data'] : true; $sub_item_type = $element['sub_item_type']; $items_html = array(); $shortcode_name = str_replace('WR_', '', $element['shortcode']); // get id of parameter to extract $extract_title = isset($element['extract_title']) ? $element['extract_title'] : ''; $extra_params = array('drag_handle' => false); if ($sub_items) { foreach ($sub_items as $idx => $item) { $el = new $sub_item_type(); $el->init_element(); // check if $item['std'] is empty or not $shortcode_data = ''; if (!$label_item) { $content = __($shortcode_name, WR_PBL) . ' ' . __('Item', WR_PBL) . ' ' . ($idx + 1); } else { $content = $label_item . ($idx + 1); } if (isset($_element['no_title'])) { $content = $_element['no_title']; } if (!empty($item['std'])) { // keep shortcode data as it is $shortcode_data = $item['std']; // reassign params for shortcode base on std string $extract_params = WR_Pb_Helper_Shortcode::extract_params($item['std']); $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($el->items, NULL, $extract_params, TRUE, FALSE, $content); $el->shortcode_data(); $params['extract_title'] = empty($params['extract_title']) ? __('(Untitled)', WR_PBL) : $params['extract_title']; $content = $params['extract_title']; if ($overwrite_shortcode_data) { $shortcode_data = $el->config['shortcode_structure']; } } $element_type = (array) $el->element_in_pgbldr($content, $shortcode_data, '', '', true, $extra_params); foreach ($element_type as $element_structure) { $items_html[$shortcode_data] = $element_structure; } } } $style = isset($_element['style']) ? 'style="' . $_element['style'] . '"' : ''; // Wrap item html to table $html = ''; foreach ($items_html as $shortcode_data => $item_html) { if (!empty($extract_title)) { $attrs = shortcode_parse_atts($shortcode_data); $title = isset($attrs[$extract_title]) ? $attrs[$extract_title] : ''; $html .= sprintf('<tr><td><b>%s</b></td><td>%s</td></tr>', $title, $item_html); } } $html = sprintf('<table class="%s" %s>%s</table>', 'table table-bordered', $style, balanceTags($html)); $element_name = isset($_element['name']) ? $_element['name'] : __(ucwords(!$label_item ? $shortcode_name : $label_item), WR_PBL) . ' ' . __('Items', WR_PBL); $html_element = "<div id='{$_element['id']}' class='form-group control-group clearfix'><label class='control-label'>{$element_name}</label>\n\t\t\t\t<div class='item-container submodal_frame_2 controls group-table {$_element['class']}'>\n <div class='item-container-content jsn-items-list'>\n {$html}\n </div>\n </div>\n </div>"; return $html_element; }
/** * List of other option types ( checkbox, select... ) * @param type $element * @return type */ static function render($element) { $element = parent::get_extra_info($element); $label = parent::get_label($element); $options_type = isset($element['options_type']) ? $element['options_type'] : ''; $ul_wrap = isset($element['ul_wrap']) ? $element['ul_wrap'] : true; $output = ''; $element_clone = $element; $element_clone['wrapper_item_start'] = "<li class='jsn-item jsn-iconbar-trigger'>"; $element_clone['wrapper_item_end'] = '</li>'; $element_clone['blank_output'] = '1'; $element['class'] = str_replace('form-control', '', $element['class']); $element_clone['class'] = (isset($element['class']) ? $element['class'] : '') . ' ' . $options_type; // re-arrange $element['options'] array by the order of value in $element['std'] $element_clone['std'] = str_replace(',', '__#__', $element_clone['std']); if (!isset($element_clone['no_order'])) { $std_val = explode('__#__', $element_clone['std']); $std = array(); foreach ($std_val as $value) { if (trim($value) != '' && isset($element_clone['options'][$value])) { $std[$value] = $element_clone['options'][$value]; } } // other option value which is not defined in std foreach ($element_clone['options'] as $key => $value) { if (!in_array($key, $std_val)) { $std[$key] = $value; } } $element_clone['options'] = $std; } $output = WR_Pb_Helper_Shortcode::render_parameter($options_type, $element_clone); $output = $ul_wrap ? "<ul class='jsn-items-list ui-sortable'>{$output}</ul>" : $output; return parent::final_element($element, $output, $label); }
/** * 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-->"; }
/** * DEFINE shortcode content * * @param type $atts * @param type $content */ public function element_shortcode_full($atts = null, $content = null) { extract(shortcode_atts($this->config['params'], $atts)); // tag1,tag2 => tag1 tag2 , to filter $tag = str_replace(' ', '_', $tag); $tag = str_replace(',', ' ', $tag); $inner_content = WR_Pb_Helper_Shortcode::remove_autop($content); WR_Pb_Helper_Functions::heading_icon($heading, $icon); return "\n\t\t\t<div class='panel panel-default' data-tag='{$tag}'>\n\t\t\t\t<div class='panel-heading'>\n\t\t\t\t\t<h4 class='panel-title'>\n\t\t\t\t\t\t<a data-toggle='collapse' href='#collapse{index}'>\n\t\t\t\t\t\t\t<i class='{$icon}'></i>{$heading}\n\t\t\t\t\t\t\t<i class='wr-icon-accordion'></i>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</h4>\n\t\t\t\t</div>\n\t\t\t\t<div id='collapse{index}' class='panel-collapse collapse {show_hide}'>\n\t\t\t\t <div class='panel-body'>\n\t\t\t\t {$inner_content}\n\t\t\t\t </div>\n\t\t\t\t</div>\n\t\t\t</div><!--seperate-->"; }
/** * DEFINE shortcode content * * @param type $atts * @param type $content */ public function element_shortcode_full($atts = null, $content = null) { extract(shortcode_atts($this->config['params'], $atts)); $rowstyle = !$rowstyle || strtolower($rowstyle) == 'default' ? '' : $rowstyle; if (in_array($tagname, array('tr_start', 'tr_end'))) { return "{$tagname}<!--seperate-->"; } $width_type = $width_type == 'percentage' ? '%' : $width_type; $width = !empty($width_value) ? "width='{$width_value}{$width_type}'" : ''; $empty = empty($content) ? '<!--empty-->' : ''; return "<CELL_WRAPPER class='{$rowstyle}' rowspan='{$rowspan}' colspan='{$colspan}' {$width}>" . WR_Pb_Helper_Shortcode::remove_autop($content) . "</CELL_WRAPPER>{$empty}<!--seperate-->"; }
/** * Group items * * @param type $element * * @return string */ static function render($element) { $_element = $element; $add_item = isset($element['add_item_text']) ? $element['add_item_text'] : __('Add Item', WR_PBL); $sub_items = $_element['sub_items']; $overwrite_shortcode_data = isset($element['overwrite_shortcode_data']) ? $element['overwrite_shortcode_data'] : true; $sub_item_type = $element['sub_item_type']; $items_html = array(); $shortcode_name = str_replace('WR_', '', $element['shortcode']); if ($sub_items) { foreach ($sub_items as $idx => $item) { $element = new $sub_item_type(); $element->init_element(); $label_item = isset($element->config['exception']['item_text']) ? $element->config['exception']['item_text'] : ''; // check if $item['std'] is empty or not $shortcode_data = ''; if (!$label_item) { $content = __($shortcode_name, WR_PBL) . ' ' . __('Item', WR_PBL) . ' ' . ($idx + 1); } else { $content = rtrim($label_item) . ' ' . ($idx + 1); } if (isset($_element['no_title'])) { $content = $_element['no_title']; } if (!empty($item['std'])) { // keep shortcode data as it is $shortcode_data = $item['std']; // reassign params for shortcode base on std string $extract_params = WR_Pb_Helper_Shortcode::extract_params($item['std']); $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($element->items, NULL, $extract_params, TRUE, FALSE, $content); $element->shortcode_data(); $params['extract_title'] = empty($params['extract_title']) ? __('(Untitled)', WR_PBL) : $params['extract_title']; $content = $params['extract_title']; if ($overwrite_shortcode_data) { $shortcode_data = $element->config['shortcode_structure']; } } $element_type = (array) $element->element_in_pgbldr($content, $shortcode_data, '', $idx + 1); foreach ($element_type as $element_structure) { $items_html[] = $element_structure; } } } $style = isset($_element['style']) ? 'style="' . $_element['style'] . '"' : ''; $items_html = implode('', $items_html); $element_name = isset($_element['name']) ? $_element['name'] : __(ucwords(!$label_item ? $shortcode_name : $label_item), WR_PBL); $element_name = str_replace('Item', '', $element_name) . ' ' . __('Items', WR_PBL); $group_heading = WR_Pb_Helper_Html_Fieldset::render(array('name' => $element_name, 'id' => '', 'type' => 'fieldset')); $html_element = "<div id='{$_element['id']}' class='form-group control-group clearfix'>{$group_heading}\n\t\t\t\t<div class='item-container has_submodal controls'>\n\t\t\t\t\t<ul {$style} class='ui-sortable jsn-items-list item-container-content jsn-rounded-medium' id='group_elements'>\n\t\t\t\t\t{$items_html}\n\t\t\t\t\t</ul>\n\t\t\t\t\t<a href='javascript:void(0);' class='jsn-add-more wr-more-element in-modal' item_common_title='" . __($shortcode_name, WR_PBL) . ' ' . __('Item', WR_PBL) . "' data-shortcode-item='" . strtolower($sub_item_type) . "'><i class='icon-plus'></i>" . __($add_item, WR_PBL) . '</a> </div></div>'; return $html_element; }
/** * Dimension type, which defines Width, Height of element * @param type $element * @param type $input_params * @return type */ static function render($element, $input_params) { $element = parent::get_extra_info($element); $label = parent::get_label($element); $element['dimension_elements'] = isset($element['dimension_elements']) ? explode(',', str_replace(' ', '', $element['dimension_elements'])) : array('w', 'h'); $_no_prefix_id = str_replace('param-', '', $element['id']); $output = ''; if (in_array('w', $element['dimension_elements'])) { $_idx_width = $_no_prefix_id . '_width'; $_idx_width_unit = $_no_prefix_id . '_width_unit'; $element['width_std'] = isset($element[$_idx_width]) ? $element[$_idx_width]['std'] : ''; $element['width_std'] = isset($input_params[$_idx_width]) ? $input_params[$_idx_width] : $element['width_std']; // Width and Width unit $_width = array('id' => $element['id'] . '_width', 'type' => 'text_append', 'type_input' => 'number', 'class' => 'jsn-input-number input-mini input-sm', 'parent_class' => 'input-group-inline', 'std' => $element['width_std'], 'append_before' => 'Width', 'validate' => 'number', 'bound' => '0'); if (isset($element[$_idx_width_unit])) { $element['width_unit_std'] = isset($element[$_idx_width_unit]) ? $element[$_idx_width_unit]['std'] : ''; $element['width_unit_std'] = isset($input_params[$_idx_width_unit]) ? $input_params[$_idx_width_unit] : $element['width_unit_std']; $_w_unit = array('id' => $element['id'] . '_width_unit', 'type' => 'select', 'class' => 'input-mini input-sm', 'bound' => '0'); $_w_unit = array_merge($_w_unit, $element[$_idx_width_unit]); $_w_unit['std'] = $element['width_unit_std']; $_append = ''; } else { $_width = array_merge($_width, array('append' => 'px')); } $output .= WR_Pb_Helper_Shortcode::render_parameter('text_append', $_width); $output .= isset($element[$_idx_width_unit]) ? WR_Pb_Helper_Shortcode::render_parameter('select', $_w_unit) : ''; } // Height and Height Unit if (in_array('h', $element['dimension_elements'])) { $_idx_height = $_no_prefix_id . '_height'; $_idx_height_unit = $_no_prefix_id . '_height_unit'; $element['height_std'] = isset($element[$_idx_height]) ? $element[$_idx_height]['std'] : ''; $element['height_std'] = isset($input_params[$_idx_height]) ? $input_params[$_idx_height] : $element['height_std']; $_append = 'px'; $_height = array('id' => $element['id'] . '_height', 'type_input' => 'number', 'class' => 'jsn-input-number input-mini input-sm', 'parent_class' => 'input-group-inline', 'std' => $element['height_std'], 'append_before' => 'Height', 'validate' => 'number', 'bound' => '0'); if (isset($element[$_idx_height_unit])) { $element['height_unit_std'] = isset($element[$_idx_width_unit]) ? $element[$_idx_width_unit]['std'] : ''; $element['height_unit_std'] = isset($input_params[$_idx_width_unit]) ? $input_params[$_idx_width_unit] : $element['width_unit_std']; $_h_unit = array('id' => $element['id'] . '_height_unit', 'type' => 'select', 'class' => 'input-mini input-sm', 'bound' => '0'); $_h_unit = array_merge($_h_unit, $element[$_idx_height_unit]); $_h_unit['std'] = $element['height_unit_std']; $_append = ''; } else { $_height = array_merge($_height, array('append' => 'px')); } $output .= WR_Pb_Helper_Shortcode::render_parameter('text_append', $_height); $output .= isset($element[$_idx_height_unit]) ? WR_Pb_Helper_Shortcode::render_parameter('select', $_h_unit) : ''; } return parent::final_element($element, $output, $label); }
/** * Option to Define top/right/bottom/left margin for element * @param type $element * @param type $input_params * @return type */ static function render($element, $input_params) { $element = parent::get_extra_info($element); $label = parent::get_label($element); $_no_prefix_id = str_replace('param-', '', $element['id']); // Set default margin element // t: top // r: right // b: bottom // l: left $element['margin_elements'] = isset($element['margin_elements']) ? explode(',', str_replace(' ', '', $element['margin_elements'])) : array('t', 'r', 'b', 'l'); $output = ''; $_br = false; if (in_array('t', $element['margin_elements'])) { $_idx_top = $_no_prefix_id . '_top'; $_br = true; $element['top_std'] = isset($element[$_idx_top]) ? $element[$_idx_top]['std'] : ''; $element['top_std'] = isset($input_params[$_idx_top]) ? $input_params[$_idx_top] : $element['top_std']; $_top = array('id' => $element['id'] . '_top', 'type' => 'text_append', 'type_input' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => $element['top_std'], 'append_before' => '<i class="input-mini wr-label-prefix">' . __('Top', WR_PBL) . '</i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= WR_Pb_Helper_Shortcode::render_parameter('text_append', $_top); } if (in_array('l', $element['margin_elements'])) { $_idx_left = $_no_prefix_id . '_left'; $element['left_std'] = isset($element[$_idx_left]) ? $element[$_idx_left]['std'] : ''; $element['left_std'] = isset($input_params[$_idx_left]) ? $input_params[$_idx_left] : $element['left_std']; $_left = array('id' => $element['id'] . '_left', 'type_input' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => $element['left_std'], 'append_before' => '<i class="input-mini wr-label-prefix">' . __('Left', WR_PBL) . '</i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= WR_Pb_Helper_Shortcode::render_parameter('text_append', $_left); } $output .= $_br ? '<div class="clearbreak"></div>' : ''; if (in_array('b', $element['margin_elements'])) { $_idx_bottom = $_no_prefix_id . '_bottom'; $element['bottom_std'] = isset($element[$_idx_bottom]) ? $element[$_idx_bottom]['std'] : ''; $element['bottom_std'] = isset($input_params[$_idx_bottom]) ? $input_params[$_idx_bottom] : $element['bottom_std']; $_bottom = array('id' => $element['id'] . '_bottom', 'type_input' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => $element['bottom_std'], 'append_before' => '<i class="input-mini wr-label-prefix">' . __('Bottom', WR_PBL) . '</i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= WR_Pb_Helper_Shortcode::render_parameter('text_append', $_bottom); } if (in_array('r', $element['margin_elements'])) { $_idx_right = $_no_prefix_id . '_right'; $_br = true; $element['right_std'] = isset($element[$_idx_right]) ? $element[$_idx_right]['std'] : ''; $element['right_std'] = isset($input_params[$_idx_right]) ? $input_params[$_idx_right] : $element['right_std']; $_right = array('id' => $element['id'] . '_right', 'type_input' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => $element['right_std'], 'append_before' => '<i class="input-mini wr-label-prefix">' . __('Right', WR_PBL) . '</i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= WR_Pb_Helper_Shortcode::render_parameter('text_append', $_right); } return parent::final_element($element, $output, $label); }
/** * List of "items_list" * @param type $element * @return type */ static function render($element) { $element = parent::get_extra_info($element); $label = parent::get_label($element); $output = ''; $items = isset($element['items']) ? $element['items'] : ''; if (is_array($items)) { foreach ($items as $element_) { $element_func = $element_['type']; $element_['wrap'] = '0'; $element_['wrap_class'] = ''; $element_['std'] = $element['std']; $element_['id'] = $element['id']; $output .= WR_Pb_Helper_Shortcode::render_parameter($element_func, $element_); } } return parent::final_element($element, $output, $label); }
/** * get params & structure of shortcode * OVERWRIGE parent function */ public function shortcode_data() { $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($this->items); $this->config['params'] = array_merge(array('div_margin_top' => '', 'div_margin_bottom' => '', 'disabled_el' => 'no', 'css_suffix' => ''), $params); // get content of sub-shortcode $sub_items_content = array(); $sub_items = isset($this->config['params']['sub_items_content']) ? $this->config['params']['sub_items_content'] : array(); foreach ($sub_items as $sub_item_type => &$sub_shortcodes) { foreach ($sub_shortcodes as $sub_shortcode) { $sub_sc = new $sub_item_type(); $sub_sc->init_element(); // empty std if (empty($sub_shortcode['std'])) { // only empty 'std' if (count($sub_shortcode) == 1) { // get default shortcode structure of sub-shortcode $sub_sc->config['params'] = WR_Pb_Helper_Shortcode::generate_shortcode_params($sub_sc->items, null, null, false, true); // re-generate shortcode structure $sub_shortcode['std'] = WR_Pb_Helper_Shortcode::generate_shortcode_structure($sub_sc->config['shortcode'], $sub_sc->config['params']); } else { // MODIFY $instance->items WR_Pb_Helper_Shortcode::generate_shortcode_params($sub_sc->items, NULL, $sub_shortcode, TRUE); // re-generate shortcode structure $sub_sc->shortcode_data(); // get updated std of sub-shortcode $sub_shortcode['std'] = $sub_sc->config['shortcode_structure']; } } else { // if std of sub-shortcode is predefined ( such as GoogleMap ) $params = stripslashes($sub_shortcode['std']); $extract_params = WR_Pb_Helper_Shortcode::extract_params(urldecode($params)); // MODIFY $instance->items WR_Pb_Helper_Shortcode::generate_shortcode_params($sub_sc->items, NULL, $extract_params, TRUE); // re-generate shortcode structure $sub_sc->shortcode_data(); } $sub_items_content[] = $sub_shortcode['std']; } } $sub_items_content = implode('', $sub_items_content); // END get content of sub-shortcode $this->config['shortcode_structure'] = WR_Pb_Helper_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params'], $sub_items_content); }
/** * DEFINE shortcode content * * @param type $atts * @param type $content */ public function element_shortcode_full($atts = null, $content = null) { extract(shortcode_atts($this->config['params'], $atts)); $content_class = !empty($image_file) ? 'carousel-caption' : 'carousel-content'; $img = !empty($image_file) ? "<img width='{WIDTH}' height='{HEIGHT}' src='{$image_file}' alt='{$alt}' style='height : {HEIGHT}px;'>" : ''; // remove image shortcode in content $content = WR_Pb_Helper_Shortcode::remove_wr_shortcodes($content, 'wr_image'); $inner_content = WR_Pb_Helper_Shortcode::remove_autop($content); WR_Pb_Helper_Functions::heading_icon($heading, $icon, true); $heading = trim($heading); $inner_content = trim($inner_content); if (empty($heading) && empty($inner_content)) { $html_content = ""; } else { $html_content = "<div class='{$content_class}'>"; $html_content .= !empty($heading) ? "<h4><i class='{$icon}'></i>{$heading}</h4>" : ''; $html_content .= !empty($inner_content) ? "<p>{$inner_content}</p>" : ''; $html_content .= "</div>"; } return "<div class='{active} item'>{$img}{$html_content}</div><!--seperate-->"; }
/** * 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); $link = ''; $exclude_params = array('tag', 'text', 'preview'); $arr_styles = array(); if (strtolower($arr_params['font_face_type']) == 'google fonts' and $arr_params['font'] != 'inherit') { wp_enqueue_style('wr-google-fonts', "http://fonts.googleapis.com/css?family={$arr_params['font_face_value']}"); } if ($arr_params['font'] != 'inherit') { if ($arr_params['font_face_value']) { $arr_styles[] = 'font-family: ' . $arr_params['font_face_value']; } if ($arr_params['font_size_value']) { $arr_styles[] = 'font-size: ' . $arr_params['font_size_value'] . 'px'; } if ($arr_params['color']) { $arr_styles[] = 'color: ' . $arr_params['color']; } if ($arr_params['font_style'] == 'bold') { $arr_styles[] = 'font-weight: 700 !important'; } else { if ($arr_params['font_style'] == 'normal') { $arr_styles[] = 'font-weight: normal !important'; } else { $arr_styles[] = 'font-style: ' . $arr_params['font_style']; } } } $arr_icon_styles = array(); $arr_icon_class = array(); $arr_icon_class[] = ''; if ($arr_params['icon_position']) { $icon_position = strtolower($arr_params['icon_position']); $arr_icon_class[] = $icon_position != 'inherit' ? "wr-position-{$icon_position}" : ''; } if (strtolower($arr_params['icon_background_type']) != '') { $arr_icon_class[] = "wr-shape-{$arr_params['icon_background_type']}"; } if ($arr_params['icon_size_value']) { $arr_icon_class[] = "wr-icon-{$arr_params['icon_size_value']}"; } if ($arr_params['icon_background_color']) { $arr_icon_styles[] = 'background-color: ' . $arr_params['icon_background_color']; } if ($arr_params['icon_c_color']) { $arr_icon_styles[] = 'color: ' . $arr_params['icon_c_color']; } $html_elements = ''; $sub_shortcode = WR_Pb_Helper_Shortcode::remove_autop($content); $items = explode('<!--seperate-->', $sub_shortcode); // remove empty element $items = array_filter($items); $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open; foreach ($items as $idx => $item) { $open = $idx + 1 == $initial_open ? 'in' : ''; $items[$idx] = $item; } $sub_shortcode = implode('', $items); $sub_shortcode = implode('', $items); if (!empty($sub_shortcode)) { $parent_class = implode(' ', $arr_icon_class); $html_elements = "<ul class='wr-list-icons {$parent_class}'>"; $sub_htmls = do_shortcode($sub_shortcode); $sub_htmls = str_replace('wr-sub-icons', 'wr-icon-base', $sub_htmls); $sub_htmls = str_replace('wr-styles', implode(';', $arr_icon_styles), $sub_htmls); $sub_htmls = str_replace('wr-list-title', implode(';', $arr_styles), $sub_htmls); if ($arr_params['show_icon'] == 'no') { $pattern = '\\[(\\[?)(icon)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls); } else { $sub_htmls = str_replace('[icon]', '', $sub_htmls); $sub_htmls = str_replace('[/icon]', '', $sub_htmls); } if ($arr_params['show_heading'] == 'no') { $pattern = '\\[(\\[?)(heading)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls); } else { $sub_htmls = str_replace('[heading]', '', $sub_htmls); $sub_htmls = str_replace('[/heading]', '', $sub_htmls); } $html_elements .= $sub_htmls; $html_elements .= '</ul>'; } return $this->element_wrapper($link . $html_elements, $arr_params); }
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $random_id = WR_Pb_Utils_Common::random_string(); $script = $html_element = ''; if (!empty($content)) { $content = WR_Pb_Helper_Shortcode::remove_autop($content); } if (isset($enable_dropcap) && $enable_dropcap == 'yes') { if ($content) { $styles = array(); if ($dropcap_font_face_type == 'google fonts' and $dropcap_font_face_value != '') { $script .= WR_Pb_Helper_Functions::add_google_font_link_tag($dropcap_font_face_value); $styles[] = 'font-family:' . $dropcap_font_face_value; } elseif ($dropcap_font_face_type == 'standard fonts' and $dropcap_font_face_value) { $styles[] = 'font-family:' . $dropcap_font_face_value; } if (intval($dropcap_font_size) > 0) { $styles[] = 'font-size:' . intval($dropcap_font_size) . 'px'; $styles[] = 'line-height:' . intval($dropcap_font_size) . 'px'; } switch ($dropcap_font_style) { case 'bold': $styles[] = 'font-weight:700'; break; case 'italic': $styles[] = 'font-style:italic'; break; case 'normal': $styles[] = 'font-weight:normal'; break; } if (strpos($dropcap_font_color, '#') !== false) { $styles[] = 'color:' . $dropcap_font_color; } if (count($styles)) { $html_element .= '<style type="text/css">'; $html_element .= sprintf('%1$s .dropcap:first-letter, %1$s .dropcap p:first-letter { float:left;', "#{$random_id}"); $html_element .= implode(';', $styles); $html_element .= '}'; $html_element .= '</style>'; } $html_element .= "<div class='dropcap'>{$content}</div>"; } } else { $html_element .= $content; } $html = sprintf('<div class="wr_text" id="%s">', $random_id); $html .= $script; $html .= $html_element; $html .= '</div>'; // Process margins if (isset($arr_params['text_margin_top'])) { $arr_params['div_margin_top'] = $arr_params['text_margin_top']; } if (isset($arr_params['text_margin_bottom'])) { $arr_params['div_margin_bottom'] = $arr_params['text_margin_bottom']; } if (isset($arr_params['text_margin_right'])) { $arr_params['div_margin_right'] = $arr_params['text_margin_right']; } if (isset($arr_params['text_margin_left'])) { $arr_params['div_margin_left'] = $arr_params['text_margin_left']; } return $this->element_wrapper($html, $arr_params); }
/** * define shortcode structure of element */ function element_shortcode($atts = null, $content = null) { extract(shortcode_atts(array('span' => 'span12', 'hidden_on' => '', 'style' => ''), $atts)); $style = empty($style) ? '' : "style='{$style}'"; $span = intval(substr($span, 4)); $hidden_on = trim(str_replace('__#__', ' ', $hidden_on)); $class = "col-md-{$span} col-sm-{$span} col-xs-12 {$hidden_on}"; $content = WR_Pb_Helper_Shortcode::remove_autop($content); return '<div class="' . $class . '" ' . $style . '>' . $content . '</div>'; }
/** * define shortcode structure of element */ function element_shortcode($atts = null, $content = null) { $extra_class = $style = $custom_script = $extra_content = $data_attr = ''; $extra_id = !empty($atts['id_wrapper']) ? esc_attr($atts['id_wrapper']) : WR_Pb_Utils_Common::random_string(); if (isset($atts) && is_array($atts)) { $arr_styles = array(); switch ($atts['width']) { case 'full': $extra_class = 'wr_fullwidth'; // some overwrite css to enable row full width $script = "\$('body').addClass('wr-full-width');"; $custom_script = WR_Pb_Helper_Functions::script_box($script); $arr_styles[] = '-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;width: 100%;padding-left: 1000px;padding-right: 1000px;margin:0 -1000px;'; break; case 'boxed': ///$arr_styles[] = "width: 100%;"; break; } $background = ''; switch ($atts['background']) { case 'none': if ($atts['width'] == 'full') { $background = 'background: none;'; } break; case 'solid': $solid_color = $atts['solid_color_value']; $background = "background-color: {$solid_color};"; break; case 'gradient': $background = $atts['gradient_color_css']; break; case 'pattern': $pattern_img = $atts['pattern']; $background = "background-image:url(\"{$pattern_img}\");"; $background_repeat = self::background_repeat($atts['repeat']); if (!empty($background_repeat)) { $background .= "background-repeat:{$background_repeat};"; } break; case 'image': $image = $atts['image']; $image_position = $atts['position']; $background = "background-image:url(\"{$image}\");background-position:{$image_position};"; // Background repeat $background_repeat = self::background_repeat($atts['img_repeat']); if (!empty($background_repeat)) { $background .= "background-repeat:{$background_repeat};"; } break; case 'video': $url = $atts['video_url']; // Youtube video if (preg_match('/youtube\\.com/', $url)) { $extra_class .= ' wr_video_bg'; parse_str($url, $youtube_url); $data_attr = sprintf("data-property=\"{videoURL:'http://youtu.be/%s', containment:'%s', autoPlay:%s, mute:true, startAt:0, opacity:1, showControls:false}\"", reset($youtube_url), "#{$extra_id}", $atts['autoplay']); add_action('wp_footer', array(__CLASS__, 'enqueue_player_scripts')); add_action('wp_footer', array(__CLASS__, 'print_player_scripts')); } break; } $arr_styles[] = $background; // Paralax background if (isset($atts['paralax']) && $atts['paralax'] == 'yes') { $data_attr .= " data-stellar-background-ratio='-.3'"; } // Border if (isset($atts['border_width_value_']) && intval($atts['border_width_value_'])) { $border = array(); $border[] = $atts['border_width_value_'] . 'px'; $border[] = $atts['border_style']; $border[] = $atts['border_color']; $arr_styles[] = sprintf('border-top:%1$s; border-bottom:%1$s;', implode(' ', $border)); } // Padding $arr_styles[] = "padding-top:{$atts['div_padding_top']}px;"; $arr_styles[] = "padding-bottom:{$atts['div_padding_bottom']}px;"; if ($atts['width'] != 'full') { $arr_styles[] = "padding-left:{$atts['div_padding_left']}px;"; $arr_styles[] = "padding-right:{$atts['div_padding_right']}px;"; } $style = $arr_styles ? sprintf("style='%s'", implode('', $arr_styles)) : ''; } $extra_class .= !empty($atts['css_suffix']) ? ' ' . esc_attr($atts['css_suffix']) : ''; $content = WR_Pb_Helper_Shortcode::remove_autop($content); return $custom_script . sprintf("<div class='jsn-bootstrap3'><div id='%s' class='row %s' %s>%s</div></div>", $extra_id, ltrim($extra_class, ' '), $data_attr . ' ' . $style, balanceTags($extra_content . $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']); $multi_open = $arr_params['multi_open']; $filter = $arr_params['filter']; $random_id = WR_Pb_Utils_Common::random_string(); $script = ''; extract($arr_params); if ($multi_open == 'no') { $script .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t{\n\t\t\t\t\t// Bind event click accordion\n\t\t\t\t\t\$( '#accordion_{$random_id} .panel-title a' ).on('click', function (e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\$('#accordion_{$random_id} .in').collapse('hide');\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t} )( jQuery )</script>"; } $sub_shortcode = do_shortcode($content); $items = explode('<!--seperate-->', $sub_shortcode); // remove empty element $items = array_filter($items); // update id, class for each item $initial_open = $initial_open > count($items) ? 1 : $initial_open; foreach ($items as $idx => $item) { $open = $idx + 1 == $initial_open ? 'in' : ''; $item = str_replace('{index}', $random_id . $idx, $item); $item = str_replace('{show_hide}', $open, $item); $items[$idx] = $item; } $sub_shortcode = implode('', $items); $filter_html = ''; if ($filter == 'yes') { $sub_sc_data = WR_Pb_Helper_Shortcode::extract_sub_shortcode($content); $sub_sc_data = reset($sub_sc_data); // tags to filter item $tags = array('all'); foreach ($sub_sc_data as $shortcode) { $extract_params = shortcode_parse_atts($shortcode); $tags[] = $extract_params['tag']; } $tags = array_filter($tags); if (count($tags) > 1) { $tags = implode(',', $tags); $tags = explode(',', $tags); $tags = array_unique($tags); $filter_html = WR_Pb_Helper_Shortcode::render_parameter('filter_list', $tags, $random_id); // remove "All" tag array_shift($tags); $inner_tags = implode(',', $tags); $script .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t{\n\t\t\t\t\twindow.parent.jQuery.noConflict()( '#jsn_view_modal').contents().find( '#wr_share_data' ).text( '{$inner_tags}')\n\t\t\t\t\tvar parent_criteria = '#filter_{$random_id}'\n\t\t\t\t\tvar clientsClone = \$( '#accordion_{$random_id}' );\n\t\t\t\t\tvar tag_to_filter = 'div';\n\t\t\t\t\tvar class_to_filter = '.panel-default';\n\n\t\t\t\t\t\$( parent_criteria + ' a' ).click( function(e ) {\n\t\t\t\t\t\t// stop running filter\n\t\t\t\t\t\t\$( class_to_filter ).each(function(){\n\t\t\t\t\t\t\t\$( this ).stop( true )\n\t\t\t\t\t\t})\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\t//active clicked criteria\n\t\t\t\t\t\t\$( parent_criteria + ' li' ).removeClass( 'active' );\n\t\t\t\t\t\t\$( this ).parent().addClass( 'active' );\n\n\t\t\t\t\t\tvar filterData = \$( this ).attr( 'class' );\n\t\t\t\t\t\tvar filters;\n\t\t\t\t\t\tif( filterData == 'all' ){\n\t\t\t\t\t\t\tfilters = clientsClone.find( tag_to_filter );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfilters = clientsClone.find( tag_to_filter + '[data-tag~='+ filterData +']' );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclientsClone.find( class_to_filter ).each(function(){\n\t\t\t\t\t\t\t\$( this ).fadeOut()\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfilters.each(function(){\n\t\t\t\t\t\t\t\$( this ).fadeIn()\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t} )( jQuery )</script>"; } } $html = '<div class="panel-group" id="accordion_{ID}">' . $sub_shortcode . '</div>'; $html = str_replace('{ID}', $random_id, $html); return $this->element_wrapper($filter_html . $html . $script, $arr_params); }
/** * Get params & structure of shortcode */ public function shortcode_data() { $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($this->items, null, null, false, true); // add Margin parameter for Not child shortcode if (strpos($this->config['shortcode'], '_item') === false) { $this->config['params'] = array_merge(array('div_margin_top' => '10', 'div_margin_bottom' => '10', 'disabled_el' => 'no', 'css_suffix' => '', 'id_wrapper' => ''), $params); } else { $this->config['params'] = $params; } $this->config['shortcode_structure'] = WR_Pb_Helper_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params']); }
/** * Radio * @param type $element * @return string */ static function render($element) { $element['class'] = isset($element['class']) ? $element['class'] : 'radio-inline'; $element['type_input'] = 'radio'; return WR_Pb_Helper_Shortcode::render_parameter('checkbox', $element); }
/** * 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) { $html_element = ''; $arr_sub_shortcodes = self::sync_sub_content($content); $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $arr_elements = explode('__#__', $prtbl_elements); // Build html for cols label. $pr_tbl_label_html = '<div class="wr-prtbl-cols first">'; // Append blank header $header_ = '<div class="wr-prtbl-title">'; if (in_array('image', $arr_elements)) { $header_ .= '<div class="wr-prtbl-image"></div>'; } $header_ .= '<h3> </h3></div>'; if (in_array('price', $arr_elements) || in_array('description', $arr_elements)) { $header_ .= '<div class="wr-prtbl-meta">'; // append blank price if (in_array('price', $arr_elements)) { $header_ .= '<div class="wr-prtbl-price"> </div>'; } // append blank price if (in_array('description', $arr_elements)) { $header_ .= '<p class="wr-prtbl-desc"> </p>'; } $header_ .= '</div>'; } // Process deactive pricing table item attribute set_transient('pricingtable_attrs', ''); $pattern = '\\[(\\[?)(wr_item_pricing_table_attr)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; preg_match_all("/{$pattern}/s", $arr_sub_shortcodes['wr_item_pricing_table_attr'], $matches); $arr_prtbl_atts = $matches[0]; $arr_disable_el = array(); foreach ($arr_prtbl_atts as $i => $att) { if (!empty($att)) { $att_extract_params = WR_Pb_Helper_Shortcode::extract_params($att); if (isset($att_extract_params['disabled_el']) && $att_extract_params['disabled_el'] == 'yes' && isset($att_extract_params['prtbl_item_attr_id'])) { $arr_disable_el[] = $att_extract_params['prtbl_item_attr_id']; } } } set_transient('pricingtable_attrs', json_encode($arr_disable_el)); $pr_tbl_label_html .= sprintf('<div class="wr-prtbl-header">%s</div>', balanceTags($header_)); if (isset($arr_sub_shortcodes['wr_item_pricing_table_attr']) && !empty($arr_sub_shortcodes['wr_item_pricing_table_attr'])) { $pr_tbl_label_html .= '<ul class="wr-prtbl-features">'; $pr_tbl_label_html .= do_shortcode($arr_sub_shortcodes['wr_item_pricing_table_attr']); $pr_tbl_label_html .= '</ul>'; } $pr_tbl_label_html .= '<div class="wr-prtbl-footer"></div>'; $pr_tbl_label_html .= '</div>'; // Build html for cols value. $pr_tbl_col_value_html = ''; if (isset($arr_sub_shortcodes['wr_item_pricing_table']) && !empty($arr_sub_shortcodes['wr_item_pricing_table'])) { $pr_tbl_col_value_html = do_shortcode(implode('', $arr_sub_shortcodes['wr_item_pricing_table'])); $pr_tbl_col_value_html = $this->check_field_allow('title', 'prtbl_item_title', $arr_elements, $pr_tbl_col_value_html); $pr_tbl_col_value_html = $this->check_field_allow('description', 'prtbl_item_desc', $arr_elements, $pr_tbl_col_value_html); $pr_tbl_col_value_html = $this->check_field_allow('image', 'prtbl_item_image', $arr_elements, $pr_tbl_col_value_html); $pr_tbl_col_value_html = $this->check_field_allow('button', 'prtbl_item_button', $arr_elements, $pr_tbl_col_value_html); $pr_tbl_col_value_html = $this->check_field_allow('price', 'prtbl_item_price', $arr_elements, $pr_tbl_col_value_html); if (!in_array('price', $arr_elements) && !in_array('description', $arr_elements)) { $pattern = '\\[(\\[?)(prtbl_item_meta)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $pr_tbl_col_value_html = preg_replace("/{$pattern}/s", '', $pr_tbl_col_value_html); } else { $pr_tbl_col_value_html = str_replace("[prtbl_item_meta]", '', $pr_tbl_col_value_html); $pr_tbl_col_value_html = str_replace("[/prtbl_item_meta]", '', $pr_tbl_col_value_html); } } $count_columns = isset($arr_sub_shortcodes['wr_item_pricing_table']) ? count($arr_sub_shortcodes['wr_item_pricing_table']) + 1 : 1; $html_element = $pr_tbl_label_html . $pr_tbl_col_value_html; return $this->element_wrapper($html_element, $arr_params, "table-{$count_columns}-col"); }
/** * Generate Setting HTML for each shortcode * * @global object $Wr_Pb * @param string $shortcode The current shortcode * @param array $params The shortcode content * @param string $el_title Title of shortcode * @param bool $no_tab * * @return string */ public static function shortcode_modal_settings($shortcode, $params, $el_title = '', $no_tab = false) { $html = ''; // get shortcode class $class = WR_Pb_Helper_Shortcode::get_shortcode_class($shortcode); if (class_exists($class)) { global $Wr_Pb; $settings_html = ''; $elements = $Wr_Pb->get_elements(); $instance = isset($elements['element'][strtolower($class)]) ? $elements['element'][strtolower($class)] : null; if (!is_object($instance)) { $instance = new $class(); } $instance->init_element(); $has_preview = false; // Generate default params if they were not posted. if (empty($params)) { $params = $instance->config['shortcode_structure']; } if (!empty($params)) { $params = str_replace('#_EDITTED', '', $params); $extract_params = WR_Pb_Helper_Shortcode::extract_params($params, $shortcode); // if have sub-shortcode, extract sub shortcodes content if (!empty($instance->config['has_subshortcode'])) { $sub_sc_data = WR_Pb_Helper_Shortcode::extract_sub_shortcode($params, true); $sub_sc_data = apply_filters('wr_pb_sub_items_filter', $sub_sc_data, $shortcode, isset($_COOKIE['wr_pb_data_for_modal']) ? $_COOKIE['wr_pb_data_for_modal'] : ''); $extract_params['sub_items_content'] = $sub_sc_data; } // Set auto title for the subitem if have $extract_title = isset($el_title) && $el_title != __('(Untitled)', WR_PBL) ? $el_title : ''; // MODIFY $instance->items WR_Pb_Helper_Shortcode::generate_shortcode_params($instance->items, NULL, $extract_params, TRUE, FALSE, $extract_title, $has_preview); // if have sub-shortcode, re-generate shortcode structure if (!empty($instance->config['has_subshortcode'])) { $instance->shortcode_data(); } } // get Modal setting box $settings = $instance->items; $settings_html .= WR_Pb_Objects_Modal::get_shortcode_modal_settings($settings, $shortcode, $extract_params, $params, $has_preview, $no_tab); // Add preview if ($has_preview) { $settings_html .= WR_Pb_Helper_Shortcode::render_parameter('preview'); } $html = balanceTags($settings_html); } return $html; }
<?php _e('Convert and Publish'); ?> </span> </button> </div> </div> </div> <?php } ?> <?php } else { $pagebuilder_content = get_post_meta($post->ID, '_wr_page_builder_content', true); if (!empty($pagebuilder_content)) { $builder = new WR_Pb_Helper_Shortcode(); echo balanceTags($builder->do_shortcode_admin($pagebuilder_content)); } ?> <a href="javascript:void(0);" id="jsn-add-container" class="jsn-add-more"><i class="wr-icon-add-row"></i> <?php _e('Add Row', WR_PBL); ?> </a> <?php // Default layouts include WR_PB_TPL_PATH . '/default-layouts.php'; ?> <input type="hidden" id="wr-select-media" value="" /> <?php }
/** * Replace widget shortcode by Widget output * * @param type $widget_shortcode * * @return type */ public static function widget_content($widget_shortcode) { $widget_contents = urldecode($widget_shortcode[0]); // get widget class $element = WR_Pb_Helper_Shortcode::extract_params($widget_contents); if (empty($element['widget_id'])) { return ''; } $widget = $element['widget_id']; // get widget settings parameters $instance = WR_Pb_Helper_Shortcode::extract_widget_params($widget_contents); $args = array('widget_id' => strtolower($widget)); // fix problem of woocommerce global $woocommerce; if (isset($woocommerce) && empty($woocommerce->query)) { $woocommerce->query = new WC_Query(); } // init the widget $w = new $widget(); $sidebars_widgets = wp_get_sidebars_widgets(); // Set a dummy sidebar $sidebars_widgets['dummy_wrpb_sidebar'][] = $w->id_base; wp_set_sidebars_widgets($sidebars_widgets); // ouput ob_start(); the_widget($widget, $instance, $args); $widget_content = ob_get_clean(); return $widget_content; }
/** * Merge new style params to existed shortcode content * * @return type */ function merge_style_params() { if (!isset($_POST[WR_NONCE]) || !wp_verify_nonce($_POST[WR_NONCE], WR_NONCE)) { return; } $shortcode_name = $_POST['shortcode_name']; $structure = str_replace("\\", "", $_POST['content']); $alter_structure = str_replace("\\", "", $_POST['new_style_content']); // Extract params of current element $params = WR_Pb_Helper_Shortcode::extract_params($structure, $shortcode_name); // Extract styling params of copied element $alter_params = WR_Pb_Helper_Shortcode::get_styling_atts($shortcode_name, $alter_structure); // Alter params of current element by copied element's params if (count($alter_params)) { foreach ($alter_params as $k => $v) { $params[$k] = $v; } } $_shortcode_content = ''; // Exclude shortcode_content from param list if (isset($params['_shortcode_content'])) { $_shortcode_content = $params['_shortcode_content']; unset($params['_shortcode_content']); } $new_shortcode_structure = WR_Pb_Helper_Shortcode::join_params($params, $shortcode_name, $_shortcode_content); // Print out new shortcode structure. echo $new_shortcode_structure; exit; }
$exp = preg_quote($widget->get_field_id('____')); $exp = str_replace('____', '(.*? )', $exp); $form = preg_replace('/' . $exp . '/', '$1', $form); // tab and content generate $tabs = array(); foreach (array('content', 'styling') as $i => $tab) { $active = $i++ == 0 ? 'active' : ''; $data_['href'] = "#{$tab}"; $data_['data-toggle'] = 'tab'; $content_ = ucfirst($tab); $tabs[] = "<li class='{$active}'>" . WR_Pb_Objects_Modal::tab_settings('a', $data_, $content_) . '</li>'; } // content $contents = array(); $contents[] = "<div class='tab-pane active' id='content'><form id='wr-widget-form'>{$form}</form></div>"; $contents[] = "<div class='tab-pane' id='styling'>" . WR_Pb_Helper_Shortcode::render_parameter('preview') . '</div>'; $output = WR_Pb_Objects_Modal::setting_tab_html($shortcode, $tabs, $contents, array(), '', array()); echo balanceTags($output); } } ?> <div id="modalAction" class="wr-pb-setting-tab"></div> </div> <textarea class="hidden" id="shortcode_content"> <?php echo esc_attr($params); ?> </textarea> <textarea class="hidden" id="wr_share_data"></textarea> <textarea class="hidden" id="wr_merge_data"></textarea> <textarea class="hidden" id="wr_extract_data"></textarea>
/** * Get post excerpt (can't use WP excerpt function, because post content contains IGPB shortcodes) * * @param type $post_content * * @return type */ static function post_excerpt($post_content) { $excerpt = WR_Pb_Helper_Shortcode::remove_wr_shortcodes($post_content); return strip_tags($excerpt); }
/** * 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); $html_element = ''; $sub_shortcode = WR_Pb_Helper_Shortcode::remove_autop($content, false); $items = explode('<!--seperate-->', $sub_shortcode); // remove empty element $items = array_filter($items); $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open; foreach ($items as $idx => $item) { $open = $idx + 1 == $initial_open ? 'in' : ''; $items[$idx] = $item; } $sub_shortcode = implode('', $items); $sub_htmls = $sub_shortcode; $arr_params['buttonbar_show_title'] = explode('__#__', $arr_params['buttonbar_show_title']); if (in_array('yes', $arr_params['buttonbar_show_title'])) { $sub_htmls = str_replace('[title]', '', $sub_htmls); $sub_htmls = str_replace('[/title]', '', $sub_htmls); } else { $pattern = '\\[(\\[?)(title)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $sub_htmls = preg_replace('/' . $pattern . '/s', '', $sub_htmls); } $arr_params['buttonbar_show_icon'] = explode('__#__', $arr_params['buttonbar_show_icon']); if (in_array('yes', $arr_params['buttonbar_show_icon'])) { $sub_htmls = str_replace('[icon]', '', $sub_htmls); $sub_htmls = str_replace('[/icon]', '', $sub_htmls); } else { $pattern = '\\[(\\[?)(icon)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $sub_htmls = preg_replace('/' . $pattern . '/s', '', $sub_htmls); } // button margin between $distance_between = isset($arr_params['distance_between']) ? intval($arr_params['distance_between']) : ''; $sub_htmls = str_replace('[style]', $distance_between ? "margin-right:{$distance_between}px" : '', $sub_htmls); if ($arr_params['buttonbar_group'] == 'yes__#__ ') { $html_element = "<div class='btn-group'>" . $sub_htmls . '</div>'; } else { $html_element = $sub_htmls; } $cls_alignment = ''; if (strtolower($arr_params['buttonbar_alignment']) != 'inherit') { if (strtolower($arr_params['buttonbar_alignment']) == 'left') { $cls_alignment = 'pull-left'; } if (strtolower($arr_params['buttonbar_alignment']) == 'right') { $cls_alignment = 'pull-right'; } if (strtolower($arr_params['buttonbar_alignment']) == 'center') { $cls_alignment = 'text-center'; } } $html_element = "<div class='btn-toolbar {$cls_alignment}'>{$html_element}</div>"; // Set button bar margin if (isset($arr_params['buttonbar_margin_top'])) { $arr_params['div_margin_top'] = $arr_params['buttonbar_margin_top']; } if (isset($arr_params['buttonbar_margin_left'])) { $arr_params['div_margin_left'] = $arr_params['buttonbar_margin_left']; } if (isset($arr_params['buttonbar_margin_right'])) { $arr_params['div_margin_right'] = $arr_params['buttonbar_margin_right']; } if (isset($arr_params['buttonbar_margin_bottom'])) { $arr_params['div_margin_bottom'] = $arr_params['buttonbar_margin_bottom']; } return $this->element_wrapper($html_element, $arr_params); }
/** * generate HTML in WR PageBuilder for Table type * @param sub_item_type $element * @return type */ static function render($element) { $label = parent::get_label($element); $sub_items = $element['sub_items']; $sub_item_type = $element['sub_item_type']; $items_html = array(); $sample_table_item = ''; // Get HTML of Each Cell $shortcode_data_arr = array(); // Add extra params to disable drag handle $extra_params = array('drag_handle' => false); foreach ($sub_items as $idx => $item) { $element_ = new $sub_item_type(); $element_->init_element(); $shortcode_data = ''; $content = ' '; // don't leave it empty if (!empty($item['std'])) { // keep shortcode data as it is $shortcode_data = $item['std']; // reassign params for shortcode base on std string $extract_params = WR_Pb_Helper_Shortcode::extract_params($item['std']); $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($element_->items, NULL, $extract_params, TRUE, FALSE, $content); $element_->shortcode_data(); if (!empty($params['extract_title'])) { $content = $params['extract_title']; $shortcode_data = $element_->config['shortcode_structure']; } $shortcode_data_arr[$idx] = $shortcode_data; } $element_type = $element_->element_in_pgbldr($content, $shortcode_data, '', '', true, $extra_params); // Create sample table item data if (!$sample_table_item) { $sample_table_item = $element_->element_in_pgbldr(null, null, '', '', true, $extra_params); } foreach ($element_type as $element_structure) { $items_html[] = $element_structure; } } // Wrap cell to a Table to display in WR PageBuilder $row = 0; $updated_html = array(); $columns_count = array(); foreach ($items_html as $idx => $cell) { if (!isset($columns_count[$row])) { $columns_count[$row] = 0; } else { $columns_count[$row]++; } $cell_html = ''; $cell_wrap = $row == 0 ? 'th' : 'td'; if (strpos($cell, "[wr_item_table tagname='tr_start' ][/wr_item_table]") !== false) { $cell_html .= '<tr>'; } else { if (strpos($cell, "[wr_item_table tagname='tr_end' ][/wr_item_table]") !== false) { // Delete button on right side of table $action_html = $row == 0 ? '' : "<a href='#' title='" . __('Delete', WR_PBL) . "' onclick='return false;' data-target='row_table' class='element-delete'><i class='icon-trash'></i></a>"; $cell_html .= "<{$cell_wrap} valign='middle' class='wr-delete-column-td'><div class='jsn-iconbar'>{$action_html}</div></{$cell_wrap}>"; $cell_html .= '</tr>'; $row++; } else { extract(shortcode_parse_atts($shortcode_data_arr[$idx])); $width = !empty($width_value) ? "width='{$width_value}{$width_type}'" : ''; $cell_html .= "<{$cell_wrap} rowspan='{$rowspan}' colspan='{$colspan}' {$width}>{$cell}</{$cell_wrap}>"; } } $updated_html[] = $cell_html; } // Delete button below the table $bottom_row = "<tr class='wr-row-of-delete'>"; for ($i = 0; $i < max($columns_count) - 1; $i++) { $bottom_row .= "<td><div class='jsn-iconbar'><a href='#' title='" . __('Delete', WR_PBL) . "' onclick='return false;' data-target='column_table' class='element-delete'><i class='icon-trash'></i></a></div></td>"; } $bottom_row .= '</tr>'; $updated_html[] = $bottom_row; $items_html = "<table class='table table-bordered igpb-table-exceprt' id='table_content'>" . implode('', $updated_html) . '</table>'; // end Wrap $buttons = '<button class="btn btn-default table_action" data-target="table_row">' . __('Add Row', WR_PBL) . '</button> <button class="btn btn-default table_action" data-target="table_column">' . __('Add Column', WR_PBL) . '</button>'; $output = "<div class='item-container has_submodal table_element'>\n\t\t\t\t\t\t<div class='jsn-fieldset-filter'><div class='btn-toolbar clearafter'>{$buttons}</div></div>\n\t\t\t\t\t\t<div class='ui-sortable item-container-content'>\n\t\t\t\t\t\t{$items_html}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; $sample_tmpl_id = strtolower($sub_item_type); $output .= isset($sample_table_item[0]) ? "<script id='tmpl-" . $sample_tmpl_id . "-sample' type='text/html'>" . $sample_table_item[0] . "</script>" : ''; return parent::final_element($element, $output, $label); }
/** * Filter Content when output HTML for shortcode inside PageBuilder Admin * * @param string $content * * @return string */ public function content_in_pagebuilder($content, $shortcode_data, $shortcode) { if ($shortcode == $this->config['shortcode']) { $params = shortcode_parse_atts($shortcode_data); if (isset($params['prtbl_item_attr_type']) && $params['prtbl_item_attr_type'] == 'checkbox') { $check_value = isset($params['prtbl_item_attr_value']) ? $params['prtbl_item_attr_value'] : 'no'; $option = array('id' => 'prtbl_item_attr_type_' . $params['prtbl_item_attr_id'], 'type' => 'radio', 'std' => $check_value, 'options' => array('yes' => __('Yes', WR_PBL), 'no' => __('No', WR_PBL)), 'parent_class' => 'no-hover-subitem prtbl_item_attr_type'); $content = WR_Pb_Helper_Shortcode::render_parameter('radio', $option); } if ($content == '(Untitled)') { $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); extract($arr_params); $random_id = WR_Pb_Utils_Common::random_string(); $testimonial_id = "testimonial_{$random_id}"; $styles = "style='width:100%'"; $image_container_style = $author_image_style != 'no-styling' ? "{$author_image_style}" : ''; $content_elements = array_filter(explode('__#__', $content_elements)); $testimonial_indicators = array(); $testimonial_indicators[] = '<ol class="carousel-indicators">'; $sub_shortcode = do_shortcode($content); $testimonial_content = array(); $items = explode('<!--seperate-->', $sub_shortcode); $items = array_filter($items); $count_items = count($items); foreach ($items as $idx => $item) { $item = unserialize($item); if ($idx % $items_per_slide == 0) { $active = $idx == 0 ? 'active' : ''; $testimonial_content[] = "<div class='item row {$active}'>"; $active_li = $idx == 0 ? "class='active'" : ''; $testimonial_indicators[] = "<li {$active_li}></li>"; } $divide = $count_items > $items_per_slide ? $items_per_slide : $count_items; $colmd = 'col-md-' . 12 / $divide; $colsm = 'col-sm-' . 12 / $divide; $item_html = "<div class='wr-testimonial-item {$colmd} {$colsm}'>"; $testimonial_info = array(); if (in_array('content', $content_elements)) { $item_content = WR_Pb_Helper_Shortcode::remove_autop($item['testimonial_content']); $item_content = WR_Pb_Utils_Common::trim_content($item_content, $content_count, $content_type); $testimonial_info['content'] = "<div class='wr-testimonial-box top'><div class='arrow'></div><div class='wr-testimonial-content'><p>" . $item_content . '</p></div></div>'; } if (isset($item['image_file']) && !empty($item['image_file'])) { $data = getimagesize($item['image_file']); $width = $data[0]; $height = $data[1]; $img = "<div class='wr-testimonial-avatar'><img width='{$width}' height='{$height}' class='{$image_container_style}' src='{$item['image_file']}' /></div>"; } else { $img = ''; } $testimonial_info['image'] = in_array('image', $content_elements) ? $img : ''; // Process company field if (isset($item['company']) && $item['company'] != '') { $company_link = "<a href='{$item['web_url']}'>{$item['company']}</a>"; } else { $company_link = "<a href='{$item['web_url']}'>{$item['web_url']}</a>"; } if (!isset($item['web_url']) || empty($item['web_url'])) { $company_link = $item['company']; } // Process testimonial metadata $arr_style = array(); if (isset($item['name_height'])) { $arr_style[] = 'font-size: ' . $item['name_height'] . 'px'; } if (isset($item['name_color'])) { $arr_style[] = 'color: ' . $item['name_color']; } $style = $arr_style ? "style='" . implode(';', $arr_style) . "'" : ''; $name = isset($item['name']) && in_array('name', $content_elements) ? "<strong {$style} class='wr-testimonial-name'>{$item['name']}</strong>" : ''; $job_title = isset($item['job_title']) && in_array('job_title', $content_elements) ? "<span class='wr-testimonial-jobtitle'>{$item['job_title']}</span>" : ''; $country = isset($item['country']) && in_array('country', $content_elements) ? "<span class='wr-testimonial-country'>{$item['country']}</span>" : ''; if ($company_link) { $company = in_array('company', $content_elements) ? "<span class='wr-testimonial-link'>{$company_link}</span>" : ''; } $html_metadata = ''; if ($name != '' || $job_title != '' || $country != '' || $company != '') { $html_metadata .= '<div class="wr-testimonial-meta">'; $html_metadata .= $name . $job_title . $country . $company; $html_metadata .= '</div>'; } foreach ($content_elements as $element) { $item_html .= isset($testimonial_info[$element]) ? $testimonial_info[$element] : ''; } $item_html .= $html_metadata; $item_html .= '</div>'; $testimonial_content[] = $item_html; if (($idx + 1) % $items_per_slide == 0 || $idx + 1 == count($items)) { $testimonial_content[] = '</div>'; } } $testimonial_content = "<div class='carousel-inner'>" . implode('', $testimonial_content) . '</div>'; $testimonial_indicators[] = '</ol>'; $testimonial_indicators = implode('', $testimonial_indicators); $script = "<script type='text/javascript'>\n\t\t(function (\$){\n\t\t\t\$( document ).ready(function(){\n\t\t\t\tif( \$( '#{$testimonial_id}' ).length ){\n\t\t\t\t\t\$( '#{$testimonial_id} .carousel-indicators li' ).each(function (i) {\n\t\t\t\t\t\t\$(this).on('click', function () {\n\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel(i);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t} )( jQuery );\n\t\t</script>"; $slider_elements = explode('__#__', $slider_elements); if ($count_items <= $items_per_slide || !in_array('indicator', $slider_elements)) { $testimonial_indicators = ''; } $testimonial_navigator = $count_items > $items_per_slide && in_array('arrows', $slider_elements) ? "<a class='carousel-control left icon-arrow-left wr-arrow-left'></a><a class='carousel-control right icon-arrow-right wr-arrow-right'></a>" : ''; $html = "<div class='carousel slide wr-testimonial' {$styles} id='{$testimonial_id}'>{$testimonial_indicators} {$testimonial_content} {$testimonial_navigator}</div>"; return $this->element_wrapper($script . $html, $arr_params); }
/** * 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) { $script = ''; if (!empty($atts) and is_array($atts)) { if (!isset($atts['border_bottom_width_value_'])) { $atts['border_bottom_width_value_'] = ''; $atts['border_bottom_style'] = ''; $atts['border_bottom_color'] = ''; } if (!isset($atts['padding_bottom_value_'])) { $atts['padding_bottom_value_'] = ''; } if (!isset($attrs['font_size_value_'])) { $attrs['font_size_value_'] = ''; } } // Reload shortcode params: because we get Heading Text from "text" param WR_Pb_Helper_Shortcode::generate_shortcode_params($this->items, NULL, $atts); $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $style = array(); $exclude_params = array('tag', 'text', 'preview'); $stylesheet = $font_style = ''; // Override custom style if (!empty($arr_params) and is_array($arr_params)) { if ($arr_params['font'] == 'inherit' || $arr_params['font'] == 'Inherit') { unset($arr_params['font']); unset($arr_params['font_face_type']); unset($arr_params['font_face_value']); unset($arr_params['font_size_value_']); unset($arr_params['font_style']); unset($arr_params['color']); } if (isset($arr_params['font']) && $arr_params['font'] == 'custom') { unset($arr_params['font']); if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'bold') { $arr_params['font_weight'] = '700'; unset($arr_params['font_style']); } if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'normal') { $arr_params['font_weight'] = 'normal'; unset($arr_params['font_style']); } } if (isset($arr_params['font_size_value_']) && $arr_params['font_size_value_'] == '') { unset($arr_params['font_size_value_']); } if ($arr_params['border_bottom_width_value_'] == '') { unset($arr_params['border_bottom_width_value_']); unset($arr_params['border_bottom_style']); unset($arr_params['border_bottom_color']); } if ($arr_params['padding_bottom_value_'] == '') { unset($arr_params['padding_bottom_value_']); } if ($arr_params['text_align'] == 'inherit' || $arr_params['text_align'] == 'Inherit') { unset($arr_params['text_align']); } } foreach ($arr_params as $key => $value) { if ($value != '') { if ($key == 'font_face_type') { if ($value == __('Standard fonts', WR_PBL) || $value == 'standard fonts') { $font_style = 'font-family:' . $arr_params['font_face_value']; } elseif ($value == __('Google fonts', WR_PBL) || $value == 'google fonts') { $script = WR_Pb_Helper_Functions::add_google_font_link_tag($arr_params['font_face_value']); $font_style = 'font-family:' . $arr_params['font_face_value']; } } elseif ($key != 'font_face_value') { $key = WR_Pb_Helper_Functions::remove_tag($key); if (!in_array($key, $exclude_params)) { switch ($key) { case 'border_bottom_width_value_': $style[$key] = 'border-bottom-width:' . $value . 'px'; break; case 'text_align': $style[$key] = 'text-align:' . $value; break; case 'font_size_value_': $style[$key] = 'font-size:' . $value . 'px'; break; case 'font_style': $style[$key] = 'font-style:' . $value; break; case 'border_bottom_style': $style[$key] = 'border-bottom-style:' . $value; break; case 'border_bottom_color': $style[$key] = 'border-bottom-color:' . $value; break; case 'padding_bottom_value_': $style[$key] = 'padding-bottom:' . $value . 'px'; break; case 'font_weight': $style[$key] = 'font-weight:' . $value; break; case 'color': $style[$key] = 'color:' . $value; break; } } } } } // Finalize style $style = implode(';', $style) . ';' . $font_style; if ($style == ';') { $style = ''; } extract($arr_params); if ($enable_underline == 'yes') { } // Process heading margins if (isset($arr_params['heading_margin_top'])) { $arr_params['div_margin_top'] = $arr_params['heading_margin_top']; } if (isset($arr_params['heading_margin_bottom'])) { $arr_params['div_margin_bottom'] = $arr_params['heading_margin_bottom']; } if (isset($arr_params['heading_margin_right'])) { $arr_params['div_margin_right'] = $arr_params['heading_margin_right']; } if (isset($arr_params['heading_margin_left'])) { $arr_params['div_margin_left'] = $arr_params['heading_margin_left']; } // Finalize HTML code $true_element = "<{$arr_params['tag']} style='{$style}'>" . do_shortcode($content) . "</{$arr_params['tag']}>"; return $this->element_wrapper($script . $stylesheet . $true_element, $arr_params); }