Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 /**
  * 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'] : '';
     if ($sub_items) {
         foreach ($sub_items as $idx => $item) {
             $element = new $sub_item_type();
             // check if $item['std'] is empty or not
             $shortcode_data = '';
             if (!$label_item) {
                 $content = __($shortcode_name, WR_MEGAMENU_TEXTDOMAIN) . ' ' . __('Item', WR_MEGAMENU_TEXTDOMAIN) . ' ' . ($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_Megamenu_Helpers_Shortcode::extract_params($item['std']);
                 $params = WR_Megamenu_Helpers_Shortcode::generate_shortcode_params($element->items, NULL, $extract_params, TRUE, FALSE, $content);
                 $element->shortcode_data();
                 $params['extract_title'] = empty($params['extract_title']) ? __('(Untitled)', WR_MEGAMENU_TEXTDOMAIN) : $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);
             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_MEGAMENU_TEXTDOMAIN) . ' ' . __('Items', WR_MEGAMENU_TEXTDOMAIN);
     $html_element = "<div id='{$_element['id']}' class='form-group control-group clearfix'><label class='col-xs-3 control-label'>{$element_name}</label>\n\t\t\t\t<div class='item-container submodal_frame_2 controls col-xs-9 group-table {$_element['class']}'>\n                    <div class='item-container-content jsn-items-list'>\n                        {$html}\n                    </div>\n                </div>\n                </div>";
     return $html_element;
 }
Пример #3
0
 /**
  * define shortcode structure of element
  */
 function element_shortcode($atts = null, $content = null)
 {
     extract(shortcode_atts(array('span' => 'span6', 'style' => ''), $atts));
     $style = empty($style) ? '' : "style='{$style}'";
     $span = intval(substr($span, 4));
     $span_sm = intval($span * 3 / 2);
     $class = "col-md-{$span} col-sm-{$span_sm}";
     return '<div class="' . $class . '" ' . $style . '>' . WR_Megamenu_Helpers_Shortcode::remove_autop($content) . '</div>';
 }
Пример #4
0
 /**
  * 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);
 }
Пример #5
0
    /**
     * Group items
     *
     * @param type $element
     *
     * @return string
     */
    static function render($element)
    {
        $_element = $element;
        $label_item = isset($element['label_item']) ? $element['label_item'] : '';
        $add_item = isset($element['add_item_text']) ? $element['add_item_text'] : __('Add Item', WR_MEGAMENU_TEXTDOMAIN);
        $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();
                // check if $item['std'] is empty or not
                $shortcode_data = '';
                if (!$label_item) {
                    $content = __($shortcode_name, WR_MEGAMENU_TEXTDOMAIN) . ' ' . __('Item', WR_MEGAMENU_TEXTDOMAIN) . ' ' . ($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_Megamenu_Helpers_Shortcode::extract_params($item['std']);
                    $params = WR_Megamenu_Helpers_Shortcode::generate_shortcode_params($element->items, NULL, $extract_params, TRUE, FALSE, $content);
                    $element->shortcode_data();
                    $params['extract_title'] = empty($params['extract_title']) ? __('(Untitled)', WR_MEGAMENU_TEXTDOMAIN) : $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_MEGAMENU_TEXTDOMAIN) . ' ' . __('Items', WR_MEGAMENU_TEXTDOMAIN);
        $html_element = "<div id='{$_element['id']}' class='form-group control-group clearfix'><label class='col-xs-3 control-label'>{$element_name}</label>\n\t\t\t\t<div class='item-container has_submodal controls col-xs-9'>\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\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' data-shortcode-item='" . strtolower($sub_item_type) . "'><i class='icon-plus'></i>" . __($add_item, WR_MEGAMENU_TEXTDOMAIN) . '</a>
				</div></div>';
        return $html_element;
    }
Пример #6
0
 /**
  * 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);
 }
Пример #7
0
 /**
  * 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);
 }
Пример #8
0
 /**
  * get params & structure of shortcode
  * OVERWRIGE parent function
  */
 public function shortcode_data()
 {
     $params = WR_Megamenu_Helpers_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();
             // 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_Megamenu_Helpers_Shortcode::generate_shortcode_params($sub_sc->items, null, null, false, true);
                     // re-generate shortcode structure
                     $sub_shortcode['std'] = WR_Megamenu_Helpers_Shortcode::generate_shortcode_structure($sub_sc->config['shortcode'], $sub_sc->config['params']);
                 } else {
                     // MODIFY $instance->items
                     WR_Megamenu_Helpers_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_Megamenu_Helpers_Shortcode::extract_params(urldecode($params));
                 // MODIFY $instance->items
                 WR_Megamenu_Helpers_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_Megamenu_Helpers_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params'], $sub_items_content);
 }
Пример #9
0
    /**
     * generate HTML in WR MegaMenu 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();
        // Get HTML of Each Cell
        $shortcode_data_arr = array();
        foreach ($sub_items as $idx => $item) {
            $element_ = new $sub_item_type();
            $shortcode_data = '';
            $content = '&nbsp;';
            // 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_Megamenu_Helpers_Shortcode::extract_params($item['std']);
                $params = WR_Megamenu_Helpers_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);
            foreach ($element_type as $element_structure) {
                $items_html[] = $element_structure;
            }
        }
        // Wrap cell to a Table to display in WR MegaMenu
        $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_MEGAMENU_TEXTDOMAIN) . "' 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_MEGAMENU_TEXTDOMAIN) . "' 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 wrpb-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_MEGAMENU_TEXTDOMAIN) . '</button>
					<button class="btn btn-default table_action" data-target="table_column">' . __('Add Column', WR_MEGAMENU_TEXTDOMAIN) . '</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\t{$items_html}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>";
        return parent::final_element($element, $output, $label);
    }
Пример #10
0
 /**
  * define shortcode structure of element
  */
 function element_shortcode($atts = null, $content = null)
 {
     $extra_class = $style = $custom_script = '';
     if (isset($atts) && is_array($atts)) {
         $arr_styles = array();
         $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'];
                 $pattern_repeat = $atts['repeat'];
                 $pattern_stretch = $atts['stretch'];
                 $background = "background-image:url(\"{$pattern_img}\");";
                 switch ($pattern_repeat) {
                     case 'full':
                         $background_repeat = 'repeat';
                         break;
                     case 'vertical':
                         $background_repeat = 'repeat-y';
                         break;
                     case 'horizontal':
                         $background_repeat = 'repeat-x';
                         break;
                 }
                 $background .= "background-repeat:{$background_repeat};";
                 switch ($pattern_stretch) {
                     case 'none':
                         $background_size = '';
                         break;
                     case 'full':
                         $background_size = '100% 100%';
                         break;
                     case 'cover':
                         $background_size = 'cover';
                         break;
                     case 'contain':
                         $background_size = 'contain';
                         break;
                 }
                 $background .= !empty($background_size) ? "background-size:{$background_size};" : '';
                 break;
             case 'image':
                 $image = isset($atts['image']) ? $atts['image'] : '';
                 $image_position = $atts['position'];
                 if ($image) {
                     $background = "background-image:url(\"{$image}\");background-position:{$image_position};";
                 } else {
                     $background = '';
                 }
                 break;
         }
         $arr_styles[] = $background;
         if (isset($atts['paralax']) && $atts['paralax'] == 'yes') {
             $arr_styles[] = 'background-attachment:fixed;';
         }
         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'];
             $border = implode(' ', $border);
             $arr_styles[] = "border-top:{$border}; border-bottom:{$border};";
         }
         if (isset($atts['div_padding_top'])) {
             $arr_styles[] = "padding-top:{$atts['div_padding_top']}px;";
             $arr_styles[] = "padding-bottom:{$atts['div_padding_bottom']}px;";
         }
         // if ( $atts['width'] != 'full' ) {
         $pl = isset($atts['div_padding_left']) ? $atts['div_padding_left'] : 0;
         $pr = isset($atts['div_padding_right']) ? $atts['div_padding_right'] : 0;
         $arr_styles[] = "padding-left:{$pl}px;";
         $arr_styles[] = "padding-right:{$pr}px;";
         // }
         $arr_styles = implode('', $arr_styles);
         $style = !empty($arr_styles) ? "style='{$arr_styles}'" : '';
     }
     $extra_class .= !empty($atts['css_suffix']) ? ' ' . esc_attr($atts['css_suffix']) : '';
     $extra_class = ltrim($extra_class, ' ');
     $extra_id = !empty($atts['id_wrapper']) ? ' ' . esc_attr($atts['id_wrapper']) : '';
     $extra_id = !empty($extra_id) ? "id='" . ltrim($extra_id, ' ') . "'" : '';
     return $custom_script . "<div class='jsn-bootstrap3'>" . "<div {$extra_id} class='row {$extra_class}' {$style}>" . WR_Megamenu_Helpers_Shortcode::remove_autop($content) . '</div>' . '</div>';
 }
Пример #11
0
 /**
  * Render shortcode preview in a blank page
  * @return Ambigous <string, mixed>|WP_Error
  */
 function shortcode_iframe_preview()
 {
     global $wr_megamenu_element;
     if (isset($_GET['wr_shortcode_preview'])) {
         if (!isset($_GET['wr_shortcode_name']) || !isset($_POST['params'])) {
             return __('empty shortcode name / parameters', WR_MEGAMENU_TEXTDOMAIN);
         }
         if (!isset($_GET[WR_MEGAMENU_NONCE]) || !wp_verify_nonce($_GET[WR_MEGAMENU_NONCE], WR_MEGAMENU_NONCE)) {
             return;
         }
         $shortcode = esc_sql($_GET['wr_shortcode_name']);
         $params = urldecode($_POST['params']);
         $pattern = '/^\\[wr_megamenu_widget/i';
         if (!preg_match($pattern, trim($params))) {
             // get shortcode class
             $class = WR_Megamenu_Helpers_Shortcode::get_shortcode_class($shortcode);
             // get option settings of shortcode
             $elements = $wr_megamenu_element->get_elements();
             $element = isset($elements['element'][strtolower($class)]) ? $elements['element'][strtolower($class)] : null;
             if (!is_object($element)) {
                 $element = new $class();
             }
             if ($_POST['params']) {
                 $extract_params = WR_Megamenu_Helpers_Shortcode::extract_params($params, $shortcode);
             } else {
                 $extract_params = $element->config;
             }
             $element->shortcode_data();
             $_shortcode_content = $extract_params['_shortcode_content'];
             // Keep non-WR shortcode as they are in preview iframe
             $_shortcode_content = str_replace('[', '&#91;', $_shortcode_content);
             $_shortcode_content = str_replace('&#91;wr_', '[wr_', $_shortcode_content);
             $_shortcode_content = str_replace('&#91;/wr_', '[/wr_', $_shortcode_content);
             $content = $element->element_shortcode($extract_params, $_shortcode_content);
         } else {
             $class = 'WR_Megamenu_Widget';
             $content = '<script type="text/javascript">jQuery.noConflict();</script>';
             $content .= WR_Megamenu_Helpers_Shortcode::widget_content(array($params));
         }
         global $Wr_Megamenu_Preview_Class;
         $Wr_Megamenu_Preview_Class = $class;
         $html = '<div id="shortcode_inner_wrapper" class="jsn-bootstrap3">';
         $html .= $content;
         $html .= '</div>';
         echo balanceTags($html);
     }
 }
Пример #12
0
 /**
  * Enqueue assets for shortcodes
  *
  * @global type $Wr_Megamenu_By_Sc_Providers
  *
  * @param type  $this_	:   current shortcode object
  * @param type  $extra	:   frontend_assets/ admin_assets
  * @param type  $post_fix :   _frontend/ ''
  */
 public static function shortcode_enqueue_assets($this_, $extra, $post_fix = '')
 {
     $extra_js = isset($this_->config['exception']) && isset($this_->config['exception'][$extra]) && is_array($this_->config['exception'][$extra]);
     $assets = array_merge($extra_js ? $this_->config['exception'][$extra] : array(), array(str_replace('wr_', '', $this_->config['shortcode']) . $post_fix));
     foreach ($assets as $asset) {
         if (!preg_match('/\\.(css|js)$/', $asset)) {
             WR_Megamenu_Init_Assets::load($asset);
         } else {
             global $Wr_Megamenu_By_Sc_Providers;
             if (empty($Wr_Megamenu_By_Sc_Providers)) {
                 continue;
             }
             // load assets file in common assets directory of provider
             $default_assets = self::assets_default($this_, $asset);
             // if can't find the asset file, search in /assets folder of the shortcode
             if (!$default_assets) {
                 // Get path of directory contains all shortcodes of provider
                 $shortcode_dir = WR_Megamenu_Helpers_Shortcode::get_provider_info($this_->config['shortcode'], 'shortcode_dir');
                 if ($shortcode_dir == WR_MEGAMENU_LAYOUT_PATH) {
                     // this is core PB
                     $sc_path = WR_MEGAMENU_ELEMENT_PATH;
                     $sc_uri = WR_MEGAMENU_ROOT_URL . basename($sc_path);
                 } else {
                     // Get directory of shortcodes of this provider
                     $plugin_path = WR_Megamenu_Helpers_Shortcode::get_provider_info($this_->config['shortcode'], 'path');
                     $plugin_uri = WR_Megamenu_Helpers_Shortcode::get_provider_info($this_->config['shortcode'], 'uri');
                     $shortcode_dir_arr = (array) WR_Megamenu_Helpers_Shortcode::get_provider_info($this_->config['shortcode'], 'shortcode_dir');
                     $shortcode_dir = reset($shortcode_dir_arr);
                     $sc_path = $plugin_path . basename($shortcode_dir);
                     if (is_dir($sc_path)) {
                         $sc_uri = $plugin_uri . basename($shortcode_dir);
                     } else {
                         $sc_path = $plugin_path;
                         $sc_uri = $plugin_uri;
                     }
                 }
                 $ext_regex = '/(_frontend)*\\.(js|css)$/';
                 if (preg_match($ext_regex, $asset)) {
                     // load assets in directory of shortcodes
                     $require_sc = preg_replace($ext_regex, '', $asset);
                     self::assets_specific_shortcode($require_sc, $asset, $sc_path, $sc_uri);
                 } else {
                     // load js/css file in directory of current shortcode
                     $exts = array('js', 'css');
                     foreach ($exts as $ext) {
                         $require_sc = $this_->config['shortcode'];
                         $file = $asset . ".{$ext}";
                         // if this asset is processed, leave it
                         self::assets_check($file);
                         // enqueue or add to cache file
                         self::assets_specific_shortcode($require_sc, $file, $sc_path, $sc_uri);
                         // store it as processed asset
                         self::assets_check($file, true);
                     }
                 }
             }
         }
     }
 }
Пример #13
0
 /**
  * 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_Megamenu_Helpers_Shortcode::extract_params($widget_contents);
     if (empty($element['widget_id'])) {
         return '';
     }
     $widget = $element['widget_id'];
     // get widget settings parameters
     $instance = WR_Megamenu_Helpers_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();
     }
     // ouput
     ob_start();
     the_widget($widget, $instance, $args);
     $widget_content = ob_get_clean();
     return $widget_content;
 }
Пример #14
0
 /**
  * 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);
 }
Пример #15
0
 /**
  * Get params & structure of shortcode
  */
 public function shortcode_data()
 {
     $params = WR_Megamenu_Helpers_Shortcode::generate_shortcode_params($this->items, null, null, false, true);
     // add Margin parameter for Not child shortcode
     if (strpos($this->config['shortcode'], '_item') === false) {
         if ($this->config['shortcode'] == 'wr_submenu') {
             $this->config['params'] = array_merge(array('disabled_el' => 'no', 'css_suffix' => '', 'id_wrapper' => ''), $params);
         } else {
             $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_Megamenu_Helpers_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params']);
 }
Пример #16
0
    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>
Пример #17
0
 /**
  * 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);
 }
Пример #18
0
            $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 
Пример #19
0
 /**
  * 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_Megamenu_Helpers_Common::random_string();
     $script = $html_element = '';
     if (!empty($content)) {
         $content = WR_Megamenu_Helpers_Shortcode::remove_autop($content, true);
     }
     $html_element_style = '<style type="text/css">';
     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_Megamenu_Helpers_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 .= sprintf('%s .dropcap:first-letter { float:left;', "#{$random_id}");
                 $html_element_style .= implode(';', $styles);
                 $html_element_style .= '}';
             }
             $html_element .= "<div class='dropcap'>{$content}</div>";
         }
     } else {
         $html_element .= $content;
     }
     $html_element_style .= '.preview-text {line-height: ' . $line_height . 'px;}';
     $html_element_style .= '</style>';
     $preview = $html_element_style;
     $preview .= "<div class='preview-text'>" . $html_element . '</div>';
     $html = sprintf('<div class="wr_text" id="%s">', $random_id);
     $html .= $script;
     $html .= $preview;
     $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);
 }