/** * 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); }
/** * 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); }
/** * 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; }
/** * 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; }
/** * 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) { $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); }
$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>