Ejemplo n.º 1
5
/**
 * Dropdown(select with options) shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 * @return string - html string.
 */
function vc_dropdown_form_field($settings, $value)
{
    $output = '';
    $css_option = str_replace('#', 'hash-', vc_get_dropdown_option($settings, $value));
    $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    if (!empty($settings['value'])) {
        foreach ($settings['value'] as $index => $data) {
            if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
                $option_label = $data;
                $option_value = $data;
            } elseif (is_numeric($index) && is_array($data)) {
                $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
                $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
            } else {
                $option_value = $data;
                $option_label = $index;
            }
            $selected = '';
            $option_value_string = (string) $option_value;
            $value_string = (string) $value;
            if ('' !== $value && $option_value_string === $value_string) {
                $selected = ' selected="selected"';
            }
            $option_class = str_replace('#', 'hash-', $option_value);
            $output .= '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($option_value) . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
        }
    }
    $output .= '</select>';
    return $output;
}
Ejemplo n.º 2
0
/**
 * Dropdown(select with options) shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 * @return string - html string.
 */
function vc_dropdown_form_field($settings, $value)
{
    $output = '';
    $css_option = vc_get_dropdown_option($settings, $value);
    $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    if (!empty($settings['value'])) {
        foreach ($settings['value'] as $index => $data) {
            if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
                $option_label = $data;
                $option_value = $data;
            } elseif (is_numeric($index) && is_array($data)) {
                $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
                $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
            } else {
                $option_value = $data;
                $option_label = $index;
            }
            $option_label = __($option_label, "js_composer");
            //$val = strtolower(str_replace(array(" "), array("_"), $val));
            //$val = strtolower(str_replace(array(" "), array("_"), $val)); //issue #464 github
            $selected = '';
            if ($value !== '' && (string) $option_value === (string) $value) {
                $selected = ' selected="selected"';
            }
            $output .= '<option class="' . $option_value . '" value="' . $option_value . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
        }
    }
    $output .= '</select>';
    return $output;
}
 function wt_multidropdown_settings_field($settings, $value)
 {
     $css_option = vc_get_dropdown_option($settings, $value);
     $dependency = vc_generate_dependencies_attributes($settings);
     $param_name = isset($settings['param_name']) ? $settings['param_name'] : '';
     $type = isset($settings['type']) ? $settings['type'] . '_field' : '';
     $current_value = explode(",", $value);
     // if exists $settings['target'] then auto fill the options for multidropdown related to target value
     isset($settings['target']) ? $target = 'true' : ($target = 'false');
     if ($target == 'false') {
         $values = is_array($settings['value']) ? $settings['value'] : array();
     } else {
         $values = WT_VCSC_GetSelectTargetOptions($settings['target']);
     }
     $output = '';
     $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $param_name . ' ' . $type . '" data-option="' . $css_option . '"  multiple ' . $dependency . '>';
     foreach ($values as $text_val => $val) {
         if (is_numeric($text_val) && (is_string($val) || is_numeric($val))) {
             $text_val = $val;
         }
         $text_val = htmlspecialchars(__($text_val, "wt_vcsc"));
         $selected = in_array($val, $current_value) ? ' selected="selected"' : '';
         $output .= '<option value="' . $val . '"' . $selected . '>' . $text_val . '</option>';
     }
     $output .= '</select>';
     return $output;
 }
Ejemplo n.º 4
0
function dropdown_multi_settings_field($settings, $value)
{
    $output = '';
    $css_option = vc_get_dropdown_option($settings, $value);
    $output .= '<select multiple name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '" data-value="' . $value . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    foreach ($settings['value'] as $index => $data) {
        if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
            $option_label = $data;
            $option_value = $data;
        } elseif (is_numeric($index) && is_array($data)) {
            $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
            $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
        } else {
            $option_value = $data;
            $option_label = $index;
        }
        $option_label = $option_label;
        $selected = '';
        if ($value !== '' && (string) $option_value === (string) $value) {
            $selected = ' selected="selected"';
        }
        $output .= '<option class="' . $option_value . '" value="' . $option_value . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
    }
    $output .= '</select>';
    return $output;
}
Ejemplo n.º 5
0
 public function dropdown_group_param($param, $param_value)
 {
     $css_option = vc_get_dropdown_option($param, $param_value);
     $param_line = '';
     $param_line .= '<select name="' . $param['param_name'] . '" class="dh-chosen-select wpb_vc_param_value wpb-input wpb-select ' . $param['param_name'] . ' ' . $param['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
     foreach ($param['optgroup'] as $text_opt => $opt) {
         if (is_array($opt)) {
             $param_line .= '<optgroup label="' . $text_opt . '">';
             foreach ($opt as $text_val => $val) {
                 if (is_numeric($text_val) && (is_string($val) || is_numeric($val))) {
                     $text_val = $val;
                 }
                 $selected = '';
                 if ($param_value !== '' && (string) $val === (string) $param_value) {
                     $selected = ' selected="selected"';
                 }
                 $param_line .= '<option class="' . $val . '" value="' . $val . '"' . $selected . '>' . htmlspecialchars($text_val) . '</option>';
             }
             $param_line .= '</optgroup>';
         } elseif (is_string($opt)) {
             if (is_numeric($text_opt) && (is_string($opt) || is_numeric($opt))) {
                 $text_opt = $opt;
             }
             $selected = '';
             if ($param_value !== '' && (string) $opt === (string) $param_value) {
                 $selected = ' selected="selected"';
             }
             $param_line .= '<option class="' . $opt . '" value="' . $opt . '"' . $selected . '>' . htmlspecialchars($text_opt) . '</option>';
         }
     }
     $param_line .= '</select>';
     return $param_line;
 }
Ejemplo n.º 6
0
 protected function singleParamEditForm($param, $param_value)
 {
     $param_line = '';
     // Textfield - input
     if ($param['type'] == 'textfield') {
         $value = __($param_value, "js_composer");
         $value = htmlspecialchars($value);
         //$value = $param_value;
         $param_line .= '<input name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-textinput ' . $param['param_name'] . ' ' . $param['type'] . '" type="text" value="' . $value . '"/>';
     } else {
         if ($param['type'] == 'dropdown') {
             $css_option = vc_get_dropdown_option($param, $param_value);
             $param_line .= '<select name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $param['param_name'] . ' ' . $param['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
             foreach ($param['value'] as $text_val => $val) {
                 if (is_numeric($text_val) && (is_string($val) || is_numeric($val))) {
                     $text_val = $val;
                 }
                 $text_val = __($text_val, "js_composer");
                 //$val = strtolower(str_replace(array(" "), array("_"), $val));
                 //$val = strtolower(str_replace(array(" "), array("_"), $val)); //issue #464 github
                 $selected = '';
                 if ($param_value !== '' && (string) $val === (string) $param_value) {
                     $selected = ' selected="selected"';
                 }
                 $param_line .= '<option class="' . $val . '" value="' . $val . '"' . $selected . '>' . htmlspecialchars($text_val) . '</option>';
             }
             $param_line .= '</select>';
         } else {
             if ($param['type'] == 'textarea_html') {
                 if ($this->html_editor_already_is_used !== false) {
                     $param_value = __($param_value, "js_composer");
                     $param_line .= '<textarea name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-textarea ' . $param['param_name'] . ' textarea">' . $param_value . '</textarea>';
                     $param_line .= '<div class="updated"><p>' . __('Field type is changed from `textarea_html` to `textarea`, because it is already used by `' . $this->html_editor_already_is_used . '` field. Textarea_html field\'s type can be used only once per shortcode.', 'js_composer') . '</p></div>';
                 } else {
                     $this->html_editor_already_is_used = $param['param_name'];
                     $param_line .= do_shortcode_param_settings_field('textarea_html', $param, $param_value);
                 }
                 // $param_line .= $this->getTinyHtmlTextArea($param, $param_value);
             } else {
                 if ($param['type'] == 'checkbox') {
                     // param_line .= '<input class="wpb_vc_param_value wpb-checkboxes" type="hidden" value="" name="'.$param['param_name'].'"/>';
                     $current_value = explode(",", $param_value);
                     $values = is_array($param['value']) ? $param['value'] : array();
                     foreach ($values as $label => $v) {
                         $checked = in_array($v, $current_value) ? ' checked="checked"' : '';
                         $param_line .= ' <input id="' . $param['param_name'] . '-' . $v . '" value="' . $v . '" class="wpb_vc_param_value ' . $param['param_name'] . ' ' . $param['type'] . '" type="checkbox" name="' . $param['param_name'] . '"' . $checked . '> ' . __($label, "js_composer");
                     }
                 } else {
                     if ($param['type'] == 'posttypes') {
                         // $param_line .= '<input class="wpb_vc_param_value wpb-checkboxes" type="hidden" value="" name="'.$param['param_name'].'"/>';
                         $args = array('public' => true);
                         $post_types = get_post_types($args);
                         foreach ($post_types as $post_type) {
                             $checked = "";
                             if ($post_type != 'attachment') {
                                 if (in_array($post_type, explode(",", $param_value))) {
                                     $checked = ' checked="checked"';
                                 }
                                 $param_line .= ' <input id="' . $param['param_name'] . '-' . $post_type . '" value="' . $post_type . '" class="wpb_vc_param_value ' . $param['param_name'] . ' ' . $param['type'] . '" type="checkbox" name="' . $param['param_name'] . '"' . $checked . '> ' . $post_type;
                             }
                         }
                     } else {
                         if ($param['type'] == 'taxonomies' || $param['type'] == 'taxomonies') {
                             // $param_line .= '<input class="wpb_vc_param_value wpb-checkboxes" type="hidden" value="" name=""/>';
                             $post_types = get_post_types(array('public' => false, 'name' => 'attachment'), 'names', 'NOT');
                             foreach ($post_types as $type) {
                                 $taxonomies = get_object_taxonomies($type, '');
                                 foreach ($taxonomies as $tax) {
                                     $checked = "";
                                     if (in_array($tax->name, explode(",", $param_value))) {
                                         $checked = ' checked="checked"';
                                     }
                                     $param_line .= ' <label data-post-type="' . $type . '"><input id="' . $param['param_name'] . '-' . $tax->name . '" value="' . $tax->name . '" data-post-type="' . $type . '" class="wpb_vc_param_value ' . $param['param_name'] . ' ' . $param['type'] . '" type="checkbox" name="' . $param['param_name'] . '"' . $checked . '> ' . $tax->label . '</label>';
                                 }
                             }
                         } else {
                             if ($param['type'] == 'exploded_textarea') {
                                 $param_value = str_replace(",", "\n", $param_value);
                                 $param_line .= '<textarea name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-textarea ' . $param['param_name'] . ' ' . $param['type'] . '">' . $param_value . '</textarea>';
                             } else {
                                 if ($param['type'] == 'textarea_raw_html') {
                                     // $param_value = __($param_value, "js_composer");
                                     $param_line .= '<textarea name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-textarea_raw_html ' . $param['param_name'] . ' ' . $param['type'] . '" rows="16">' . htmlentities(rawurldecode(base64_decode($param_value)), ENT_COMPAT, 'UTF-8') . '</textarea>';
                                 } else {
                                     if ($param['type'] == 'textarea_safe') {
                                         // $param_value = __($param_value, "js_composer");
                                         $param_line .= '<textarea name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-textarea_raw_html ' . $param['param_name'] . ' ' . $param['type'] . '">' . vc_value_from_safe($param_value, true) . '</textarea>';
                                     } else {
                                         if ($param['type'] == 'textarea') {
                                             $param_value = __($param_value, "js_composer");
                                             $param_line .= '<textarea name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-textarea ' . $param['param_name'] . ' ' . $param['type'] . '">' . $param_value . '</textarea>';
                                         } else {
                                             if ($param['type'] == 'attach_images') {
                                                 // TODO: More native way
                                                 $param_value = wpb_removeNotExistingImgIDs($param_value);
                                                 $param_line .= '<input type="hidden" class="wpb_vc_param_value gallery_widget_attached_images_ids ' . $param['param_name'] . ' ' . $param['type'] . '" name="' . $param['param_name'] . '" value="' . $param_value . '"/>';
                                                 //$param_line .= '<a class="button gallery_widget_add_images" href="#" title="'.__('Add images', "js_composer").'">'.__('Add images', "js_composer").'</a>';
                                                 $param_line .= '<div class="gallery_widget_attached_images">';
                                                 $param_line .= '<ul class="gallery_widget_attached_images_list">';
                                                 $param_line .= $param_value != '' ? fieldAttachedImages(explode(",", $param_value)) : '';
                                                 $param_line .= '</ul>';
                                                 $param_line .= '</div>';
                                                 $param_line .= '<div class="gallery_widget_site_images">';
                                                 // $param_line .= siteAttachedImages(explode(",", $param_value));
                                                 $param_line .= '</div>';
                                                 $param_line .= '<a class="gallery_widget_add_images" href="#" title="' . __('Add images', "js_composer") . '">' . __('Add images', "js_composer") . '</a>';
                                                 //class: button
                                                 //$param_line .= '<div class="wpb_clear"></div>';
                                             } else {
                                                 if ($param['type'] == 'attach_image') {
                                                     $param_value = wpb_removeNotExistingImgIDs(preg_replace('/[^\\d]/', '', $param_value));
                                                     $param_line .= '<input type="hidden" class="wpb_vc_param_value gallery_widget_attached_images_ids ' . $param['param_name'] . ' ' . $param['type'] . '" name="' . $param['param_name'] . '" value="' . $param_value . '"/>';
                                                     //$param_line .= '<a class="button gallery_widget_add_images" href="#" use-single="true" title="'.__('Add image', "js_composer").'">'.__('Add image', "js_composer").'</a>';
                                                     $param_line .= '<div class="gallery_widget_attached_images">';
                                                     $param_line .= '<ul class="gallery_widget_attached_images_list">';
                                                     $param_line .= $param_value != '' ? fieldAttachedImages(explode(",", $param_value)) : '';
                                                     $param_line .= '</ul>';
                                                     $param_line .= '</div>';
                                                     $param_line .= '<div class="gallery_widget_site_images">';
                                                     // $param_line .= siteAttachedImages(explode(",", $param_value));
                                                     $param_line .= '</div>';
                                                     $param_line .= '<a class="gallery_widget_add_images" href="#" use-single="true" title="' . __('Add image', "js_composer") . '">' . __('Add image', "js_composer") . '</a>';
                                                     //class: button
                                                     //$param_line .= '<div class="wpb_clear"></div>';
                                                 } else {
                                                     if ($param['type'] == 'widgetised_sidebars') {
                                                         $wpb_sidebar_ids = array();
                                                         $sidebars = $GLOBALS['wp_registered_sidebars'];
                                                         $param_line .= '<select name="' . $param['param_name'] . '" class="wpb_vc_param_value dropdown wpb-input wpb-select ' . $param['param_name'] . ' ' . $param['type'] . '">';
                                                         foreach ($sidebars as $sidebar) {
                                                             $selected = '';
                                                             if ($sidebar["id"] == $param_value) {
                                                                 $selected = ' selected="selected"';
                                                             }
                                                             $sidebar_name = __($sidebar["name"], "js_composer");
                                                             $param_line .= '<option value="' . $sidebar["id"] . '"' . $selected . '>' . $sidebar_name . '</option>';
                                                         }
                                                         $param_line .= '</select>';
                                                     } else {
                                                         $param_line .= do_shortcode_param_settings_field($param['type'], $param, $param_value);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $param_line;
 }
/**
 * Creates multiple select forms for VC 
 * @param  [string] $param
 * @param  [string] $param_value
 * @return [html]  $param_line
 */
function rt_vc_multiple_select_forrms($param, $param_value)
{
    $css_option = vc_get_dropdown_option($param, $param_value);
    $param_line = '<select multiple name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select rt-multi-select ' . $param['param_name'] . ' ' . $param['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    $selected_values = !is_array($param_value) ? explode(",", $param_value) : $param_value;
    foreach ($param['value'] as $text_val => $val) {
        if (is_numeric($text_val) && (is_string($val) || is_numeric($val))) {
            $text_val = $val;
        }
        $text_val = __($text_val, "js_composer");
        $selected = '';
        if (in_array($val, $selected_values)) {
            $selected = ' selected="selected"';
        }
        $param_line .= '<option class="' . $val . '" value="' . $val . '"' . $selected . '>' . htmlspecialchars($text_val) . '</option>';
    }
    $param_line .= '</select>';
    return $param_line;
}