Пример #1
0
/**
 * Attach images shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 *
 * @param $tag
 * @param bool $single
 *
 * @return string - html string.
 */
function vc_attach_images_form_field($settings, $value, $tag, $single = false)
{
    $output = '';
    $param_value = wpb_removeNotExistingImgIDs($value);
    $output .= '<input type="hidden" class="wpb_vc_param_value gallery_widget_attached_images_ids ' . $settings['param_name'] . ' ' . $settings['type'] . '" name="' . $settings['param_name'] . '" value="' . $value . '"/>';
    $output .= '<div class="gallery_widget_attached_images">';
    $output .= '<ul class="gallery_widget_attached_images_list">';
    $output .= '' !== $param_value ? fieldAttachedImages(explode(',', $value)) : '';
    $output .= '</ul>';
    $output .= '</div>';
    $output .= '<div class="gallery_widget_site_images">';
    $output .= '</div>';
    if (true === $single) {
        $output .= '<a class="gallery_widget_add_images" href="#" use-single="true" title="' . __('Add image', 'js_composer') . '">' . __('Add image', 'js_composer') . '</a>';
        //class: button
    } else {
        $output .= '<a class="gallery_widget_add_images" href="#" title="' . __('Add images', 'js_composer') . '">' . __('Add images', 'js_composer') . '</a>';
        //class: button
    }
    return $output;
}
Пример #2
0
 /**
  * Todo: move it
  * @since 4.2
  */
 public function galleryHTML()
 {
     $images = vc_post_param('content');
     if (!empty($images)) {
         echo fieldAttachedImages(explode(",", $images));
     }
     die;
 }
Пример #3
0
 public function galleryHTMLJavascript_callback()
 {
     $images = $this->post('content');
     if (!empty($images)) {
         echo fieldAttachedImages(explode(",", $images));
     }
     die;
 }
Пример #4
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;
 }
Пример #5
0
 /**
  * @todo move it
  * @since 4.2
  */
 public function galleryHTML()
 {
     // @todo again, this method should be moved (comment added on 4.8)
     vc_user_access()->checkAdminNonce()->validateDie()->wpAny('edit_posts', 'edit_pages')->validateDie();
     $images = vc_post_param('content');
     if (!empty($images)) {
         echo fieldAttachedImages(explode(',', $images));
     }
     die;
 }
Пример #6
0
function fws_image_settings_field($param, $value)
{
    $param_line = '';
    $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="' . $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">';
    if (strpos($value, "http://") !== false || strpos($value, "https://") !== false) {
        //$param_value = fjarrett_get_attachment_id_by_url($param_value);
        $param_line .= '<li class="added">
				<img src="' . $value . '" />
				<a href="#" class="icon-remove"></a>
			</li>';
    } else {
        $param_line .= $value != '' ? fieldAttachedImages(explode(",", $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>';
    return $param_line;
}
Пример #7
0
 protected function singleParamEditForm($param, $param_value)
 {
     $param_line = '';
     // Textfield - input
     if ($param['type'] == 'textfield') {
         $value = __($param_value, "js_composer");
         $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') {
             $param_line .= '<select name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $param['param_name'] . ' ' . $param['type'] . '">';
             foreach ($param['value'] as $text_val => $val) {
                 if (is_numeric($text_val) && is_string($val) || is_numeric($text_val) && is_numeric($val)) {
                     $text_val = $val;
                 }
                 $text_val = __($text_val, "js_composer");
                 $val = strtolower(str_replace(array(" "), array("_"), $val));
                 $selected = '';
                 if ($val == $param_value) {
                     $selected = ' selected="selected"';
                 }
                 $param_line .= '<option class="' . $val . '" value="' . $val . '"' . $selected . '>' . $text_val . '</option>';
             }
             $param_line .= '</select>';
         } else {
             if ($param['type'] == 'select-multiple') {
                 $param_line .= '<select name="' . $param['param_name'] . '" class="wpb_vc_param_value ' . $param['param_name'] . ' ' . $param['type'] . '" type="hidden" value="" name="" multiple>';
                 $selected_values = explode(",", $param_value);
                 foreach ($param['value'] as $text_val => $val) {
                     if (is_numeric($text_val) && is_string($val) || is_numeric($text_val) && is_numeric($val)) {
                         $text_val = $val;
                     }
                     $text_val = __($text_val, "swift_page_builder");
                     $selected = '';
                     if (in_array($val, $selected_values)) {
                         $selected = ' selected="selected"';
                     }
                     $param_line .= '<option id="' . $text_val . '" value="' . $val . '"' . $selected . '>' . $text_val . '</option>';
                 }
                 $param_line .= '</select>';
             } else {
                 if ($param['type'] == 'textarea_html') {
                     $param_line .= $this->getTinyHtmlTextArea($param, $param_value);
                 } else {
                     if ($param['type'] == 'posttypes') {
                         $param_line .= '<input class="wpb_vc_param_value wpb-checkboxes" type="hidden" value="" 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="' . $post_type . '" class="' . $param['param_name'] . ' ' . $param['type'] . '" type="checkbox" name="' . $param['param_name'] . '"' . $checked . '> ' . $post_type;
                             }
                         }
                     } 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') {
                                     $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 .= '<div class="wpb_clear"></div>';
                                     } else {
                                         if ($param['type'] == 'attach_image') {
                                             // TODO: More native way
                                             $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 .= '<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 {
                                                 if ($param['type'] == 'altbg_preview') {
                                                     $param_line .= '<div class="altbg-preview"><p>Alt Background Preview</p></div>';
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $param_line;
 }
Пример #8
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 .= '<div class="content"><input name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-textinput ' . $param['param_name'] . ' ' . $param['type'] . '" type="text" value="' . esc_attr($value) . '"/></div>';
     }
     // Radio
     if ($param['type'] == 'radios') {
         $param_line .= '<div class="content">';
         foreach ($param['value'] as $option => $value) {
             $param_line .= '<label for="option-' . $param['param_name'] . '-' . $value . '">' . $option . '</label>';
             $param_line .= '<input type="radio" name="' . $param['param_name'] . '" value="' . $value . '" id="option-' . $param['param_name'] . '-' . $value . '"' . ($value == $param['default'] ? ' checked="checked"' : '') . ' />';
         }
         $param_line .= '</div>';
     } else {
         if ($param['type'] == 'dropdown' || $param['type'] == 'radio') {
             $param_line .= '<div class="content"><select name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $param['param_name'] . ' ' . $param['type'] . '">';
             foreach ($param['value'] as $text_val => $val) {
                 if (is_numeric($text_val) && is_string($val) || is_numeric($text_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 ($val == $param_value) {
                     $selected = ' selected="selected"';
                 }
                 $param_line .= '<option class="' . $val . '" value="' . $val . '"' . $selected . '>' . $text_val . '</option>';
             }
             $param_line .= '</select></div>';
         } else {
             if ($param['type'] == 'dropdown_multiple') {
                 $param_line .= '<select name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-checkboxes ' . $param['param_name'] . ' ' . $param['type'] . ' multiple" value="" multiple>';
                 $selected_values = explode(",", $param_value);
                 foreach ($param['value'] as $text_val => $val) {
                     if (is_numeric($text_val) && is_string($val) || is_numeric($text_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 id="' . $text_val . '" value="' . $val . '"' . $selected . '>' . $text_val . '</option>';
                 }
                 $param_line .= '</select>';
             } else {
                 if ($param['type'] == 'textarea_html') {
                     $class = '';
                     if (isset($param['shortcode_btn'])) {
                         $class = $param['shortcode_btn'] === 'only' ? ' md-sh-only' : ' md-sh';
                     }
                     $data = isset($param['shortcode']) ? ' data-sh="' . $param['shortcode'] . '"' : '';
                     $param_line .= '<div class="content full tinymce' . $class . '"' . $data . '>';
                     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 .= '</div>';
                 } else {
                     if ($param['type'] == 'checkbox') {
                         $param_line .= '<div class="content"><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="' . $param['param_name'] . ' ' . $param['type'] . '" type="checkbox" name="' . $param['param_name'] . '"' . $checked . '> ' . __($label, "js_composer");
                         }
                         $param_line .= '</div>';
                     } 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="' . $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="' . $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 .= '<div class="content"><textarea name="' . $param['param_name'] . '" class="textarea wpb_vc_param_value wpb-textarea ' . $param['param_name'] . ' ' . $param['type'] . '">' . $param_value . '</textarea></div>';
                                 } else {
                                     if ($param['type'] == 'textarea_raw_html') {
                                         // $param_value = __($param_value, "js_composer");
                                         $param_line .= '<div class="content"><textarea name="' . $param['param_name'] . '" class="textarea 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></div>';
                                     } else {
                                         if ($param['type'] == 'textarea') {
                                             $param_value = __($param_value, "js_composer");
                                             $param_line .= '<div class="content"><textarea name="' . $param['param_name'] . '" class="textarea wpb_vc_param_value wpb-textarea ' . $param['param_name'] . ' ' . $param['type'] . '">' . $param_value . '</textarea></div>';
                                         } 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 {
                                                         if ($param['type'] == 'icons') {
                                                             $current_value = explode(",", $param_value);
                                                             $param_line .= '<div class="icons-item">';
                                                             $param_line .= '<input class="wpb_vc_param_value wpb-checkboxes" type="hidden" value="' . $current_value[0] . '" name="' . $param['param_name'] . '"/>';
                                                             $values = is_array($param['value']) ? $param['value'] : array();
                                                             foreach ($values as $v) {
                                                                 $v == $current_value[0] ? $active = ' class="active"' : ($active = '');
                                                                 $param_line .= '<a href="#"' . $active . '><i class="' . $v . '"></i></a>';
                                                             }
                                                             $param_line .= '</div>';
                                                         } else {
                                                             if ($param['type'] == 'textarea_shortcode') {
                                                                 $args = array('editor_class' => 'wpb_vc_param_value wpb-textarea visual_composer_tinymce ' . $param['param_name'] . ' ' . $param['type'], 'media_buttons' => false, 'wpautop' => false);
                                                                 ob_start();
                                                                 wp_editor($param['value'], 'wp_editor_' . $param['param_name'], $args);
                                                                 $wp_editor = ob_get_contents();
                                                                 ob_end_clean();
                                                                 $param_line .= $wp_editor;
                                                                 $param_line .= '<input type="text" name="vc_textarea_shortcode_content" class="vc_textarea_shortcode_content" value="' . htmlspecialchars($param['value']) . '"/>';
                                                             } else {
                                                                 if ($param['type'] == 'slider') {
                                                                     $value = $param_value;
                                                                     if (!$value) {
                                                                         $value = intval($param['default']);
                                                                     }
                                                                     $min = isset($param['min']) ? $param['min'] : 0;
                                                                     $max = isset($param['max']) ? $param['max'] : 300;
                                                                     $suffix = isset($param['suffix']) ? $param['suffix'] : 'px';
                                                                     $param_line .= '<div class="content"><div class="slider-input" data-value="' . $value . '" data-min="' . $min . '" data-max="' . $max . '"></div><input name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-textinput ' . $param['param_name'] . ' ' . $param['type'] . ' slider-amount" type="text" value="' . $value . '"/> <strong>' . $suffix . '</strong></div>';
                                                                 } else {
                                                                     $param_line .= do_shortcode_param_settings_field($param['type'], $param, $param_value);
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $param_line;
 }
Пример #9
0
 /**
  * @todo move it
  * @since 4.2
  */
 public function galleryHTML()
 {
     if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         wp_send_json(array('success' => false));
     }
     $images = vc_post_param('content');
     if (!empty($images)) {
         echo fieldAttachedImages(explode(',', $images));
     }
     die;
 }
Пример #10
0
 protected function singleParamEditForm($param, $param_value)
 {
     $param_line = '';
     $dependency = '';
     if (!empty($param['dependency']) && isset($param['dependency']['element'])) {
         $dependency = ' data-dependency-element="true"';
     }
     // Textfield - input
     if ($param['type'] == 'textfield') {
         $value = __($param_value, "js_composer");
         $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 . '" ' . $dependency . '/>';
     } else {
         if ($param['type'] == 'dropdown') {
             $param_line .= '<select name="' . $param['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $param['param_name'] . ' ' . $param['type'] . '"' . $dependency . '>';
             foreach ($param['value'] as $text_val => $val) {
                 if (is_numeric($text_val) && is_string($val) || is_numeric($text_val) && is_numeric($val)) {
                     $text_val = $val;
                 }
                 $text_val = __($text_val, "js_composer");
                 $val = strtolower(str_replace(array(" "), array("_"), $val));
                 $selected = '';
                 if ($val == $param_value) {
                     $selected = ' selected="selected"';
                 }
                 $param_line .= '<option class="' . $val . '" value="' . $val . '"' . $selected . '>' . $text_val . '</option>';
             }
             $param_line .= '</select>';
         } else {
             if ($param['type'] == 'textarea_html') {
                 $param_line .= do_shortcode_param_settings_field('textarea_html', $param, $param_value);
                 // $param_line .= $this->getTinyHtmlTextArea($param, $param_value, $dependency);
             } else {
                 if ($param['type'] == 'posttypes') {
                     $param_line .= '<input class="wpb_vc_param_value wpb-checkboxes" type="hidden" value="" name="" ' . $dependency . '/>';
                     $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="' . $param['param_name'] . ' ' . $param['type'] . '" type="checkbox" name="' . $param['param_name'] . '"' . $checked . '' . $dependency . '> ' . $post_type;
                         }
                     }
                 } else {
                     if ($param['type'] == 'taxomonies') {
                         $param_line .= '<input class="wpb_vc_param_value wpb-checkboxes" type="hidden" value="" name="" ' . $dependency . '/>';
                         $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="' . $param['param_name'] . ' ' . $param['type'] . '" type="checkbox" name="' . $param['param_name'] . '"' . $checked . '' . $dependency . '> ' . $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'] . '"' . $dependency . '>' . $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"' . $dependency . '>' . htmlentities(rawurldecode(base64_decode($param_value)), ENT_COMPAT, 'UTF-8') . '</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'] . '"' . $dependency . '>' . $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 . '" ' . $dependency . '/>';
                                         //$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 . '" ' . $dependency . '/>';
                                             //$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'] . '"' . $dependency . '>';
                                                 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;
 }