/** * 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_Megamenu_Helpers_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' => 'W', '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_Megamenu_Helpers_Shortcode::render_parameter('text_append', $_width); $output .= isset($element[$_idx_width_unit]) ? WR_Megamenu_Helpers_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' => 'H', '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_Megamenu_Helpers_Shortcode::render_parameter('text_append', $_height); $output .= isset($element[$_idx_height_unit]) ? WR_Megamenu_Helpers_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_MEGAMENU_TEXTDOMAIN) . '</i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= WR_Megamenu_Helpers_Shortcode::render_parameter('text_append', $_top); } 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_MEGAMENU_TEXTDOMAIN) . '</i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= WR_Megamenu_Helpers_Shortcode::render_parameter('text_append', $_right); } $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_MEGAMENU_TEXTDOMAIN) . '</i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= WR_Megamenu_Helpers_Shortcode::render_parameter('text_append', $_bottom); } 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_MEGAMENU_TEXTDOMAIN) . '</i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= WR_Megamenu_Helpers_Shortcode::render_parameter('text_append', $_left); } 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_Megamenu_Helpers_Shortcode::render_parameter($element_func, $element_); } } return parent::final_element($element, $output, $label); }
/** * get HTML of Modal Settings Box of Shortcode * @param array $options * @return string */ static function get_shortcode_modal_settings($settings, $shortcode = '', $input_params = null, $raw_shortcode = null) { $i = 0; $tabs = $contents = $actions = $general_actions = array(); foreach ($settings as $tab => $options) { $options = self::ignore_settings($options); if ($tab == 'action') { foreach ($options as $option) { $actions[] = WR_Megamenu_Helpers_Shortcode::render_parameter($option['type'], $option); } } else { if ($tab == 'generalaction') { foreach ($options as $option) { $option['id'] = isset($option['id']) ? 'param-' . $option['id'] : ''; $general_actions[] = WR_Megamenu_Helpers_Shortcode::render_parameter($option['type'], $option); } } else { $active = $i++ == 0 ? 'active' : ''; if (strtolower($tab) != 'notab') { $data_ = isset($settings[$tab]['settings']) ? $settings[$tab]['settings'] : array(); $data_['href'] = "#{$tab}"; $data_['data-toggle'] = 'tab'; $content_ = ucfirst($tab); $tabs[] = "<li class='{$active}'>" . self::tab_settings('a', $data_, $content_) . '</li>'; } $has_margin = 0; $param_html = array(); foreach ($options as $idx => $option) { // check if this element has Margin param (1) if (isset($option['name']) && $option['name'] == __('Margin', WR_MEGAMENU_TEXTDOMAIN) && $option['id'] != 'div_margin') { $has_margin = 1; } // if (1), don't use the 'auto extended margin ( top, bottom ) option' if ($has_margin && isset($option['id']) && $option['id'] == 'div_margin') { continue; } $type = $option['type']; $option['id'] = isset($option['id']) ? 'param-' . $option['id'] : "{$idx}"; if (!is_array($type)) { $param_html[$option['id']] = WR_Megamenu_Helpers_Shortcode::render_parameter($type, $option, $input_params); } else { $output_inner = ''; foreach ($type as $sub_options) { $sub_options['id'] = isset($sub_options['id']) ? 'param-' . $sub_options['id'] : ''; /* for sub option, auto assign bound = 0 {not wrapped by <div class='controls'></div> } */ $sub_options['bound'] = '0'; /* for sub option, auto assign 'input-small' class */ $sub_options['class'] = isset($sub_options['class']) ? $sub_options['class'] : ''; $type = $sub_options['type']; $output_inner .= WR_Megamenu_Helpers_Shortcode::render_parameter($type, $sub_options); } $option = WR_Megamenu_Helpers_Html::get_extra_info($option); $label = WR_Megamenu_Helpers_Html::get_label($option); $param_html[$option['id']] = WR_Megamenu_Helpers_Html::final_element($option, $output_inner, $label); } } if (!empty($param_html['param-copy_style_from'])) { array_pop($param_html); // move "auto extended margin ( top, bottom ) option" to top of output $style_copy = array_shift($param_html); // Shift Preview frame from the array $preview = array_shift($param_html); if (!empty($param_html['param-div_margin'])) { $margin = $param_html['param-div_margin']; $param_html = array_merge(array($preview, $style_copy, $margin), $param_html); } else { $param_html = array_merge(array($preview, $style_copy), $param_html); } } $param_html = implode('', $param_html); $content_tab = "<div class='tab-pane {$active} wr-mm-setting-tab' id='{$tab}'>{$param_html}</div>"; $contents[] = $content_tab; } } } return self::setting_tab_html($shortcode, $tabs, $contents, $general_actions, $settings, $actions); }
/** * Ajax function for get menu icons * * @return array */ function ajax_get_menu_icon() { if (!isset($_POST[WR_MEGAMENU_NONCE]) || !wp_verify_nonce($_POST[WR_MEGAMENU_NONCE], WR_MEGAMENU_NONCE)) { return; } $item_ids = !empty($_POST['item_ids']) ? $_POST['item_ids'] : ''; if (!$item_ids) { return; } $arr_results = array(); $arr_ids = explode(',', $item_ids); foreach ($arr_ids as $i => $item_id) { $item_id = (int) $item_id; if ($item_id) { $value = get_post_meta($item_id, '_icon_mega_', true); $icons = array('id' => 'icon_mega[' . $item_id . ']', 'showlabel' => '0', 'item_id' => $item_id, 'type' => 'icons', 'std' => $value, 'role' => 'title', 'title_prepend_type' => 'icon', 'tooltip' => __('Select an icon', WR_MEGAMENU_TEXTDOMAIN)); $icon_value = $value ? $value : 'icon-wand'; ob_start(); ?> <div class="panel-group" id="accordion<?php echo esc_attr($item_id); ?> "> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion<?php echo esc_attr($item_id); ?> " href="#collapseOne<?php echo esc_attr($item_id); ?> "> <i class="<?php echo esc_attr($icon_value); ?> "></i><?php _e('Icon', WR_MEGAMENU_TEXTDOMAIN); ?> <span class="caret pull-right"></span> </a> </h4> </div> <div id="collapseOne<?php echo esc_attr($item_id); ?> " class="panel-collapse collapse"> <div class="panel-body"> <?php echo balanceTags(WR_Megamenu_Helpers_Shortcode::render_parameter('icons', $icons)); ?> </div> </div> </div> </div> <?php $arr_results[] = array('id' => $item_id, 'html' => ob_get_clean()); } } echo json_encode($arr_results); exit; }
$exp = str_replace('____', '(.*? )', $exp); $form = preg_replace('/' . $exp . '/', 'param-$1', $form); // tab and content generate $tabs = array(); foreach (array('content') as $i => $tab) { $active = $i++ == 0 ? 'active' : ''; $data_['href'] = "#{$tab}"; $data_['data-toggle'] = 'tab'; $content_ = ucfirst($tab); $tabs[] = "<li class='{$active}'>" . WR_Megamenu_Helpers_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>"; $output = '<div class="wr-setting-resize">' . WR_Megamenu_Helpers_Modal::setting_tab_html($shortcode, $tabs, $contents, array(), '', array()) . '</div>'; $output .= '<div class="wr-preview-resize">' . WR_Megamenu_Helpers_Shortcode::render_parameter('preview') . '</div>'; echo balanceTags($output); } } ?> <div id="modalAction" class="wr-mm-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> <input type="hidden" id="wr_previewing" value="0" /> <input id="shortcode_type" type="hidden" value="<?php
esc_attr_e($tid); ?> "> <?php foreach ($styling_fields[$tid] as $field) { $field['id'] = isset($field['id']) ? 'param-' . $field['id'] : ''; if (!is_array($field['type'])) { echo balanceTags(WR_Megamenu_Helpers_Shortcode::render_parameter($field['type'], $field)); } else { $output = ''; foreach ($field['type'] as $sub_options) { $sub_options['id'] = isset($sub_options['id']) ? 'param-' . $sub_options['id'] : ''; $sub_options['bound'] = '0'; $sub_options['class'] = isset($sub_options['class']) ? $sub_options['class'] : ''; $type = $sub_options['type']; $output .= WR_Megamenu_Helpers_Shortcode::render_parameter($type, $sub_options); } $field = WR_Megamenu_Helpers_Html::get_extra_info($field); $label = WR_Megamenu_Helpers_Html::get_label($field); echo balanceTags(WR_Megamenu_Helpers_Html::final_element($field, $output, $label)); } } ?> </div> <?php $first = false; } ?> </div>
/** * 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_Megamenu_Helpers_Shortcode::render_parameter('checkbox', $element); }