1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
<?php if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); }
/** * WPBakery WPBakery Page Builder shortcode default attributes functions for rendering. * * @package WPBakeryPageBuilder * @since 4.4 */ /** * Textfield shortcode attribute type generator. * * @param $settings * @param $value * * @return string - html string. * @since 4.4 */ function vc_textfield_form_field( $settings, $value ) { $value = htmlspecialchars( $value );
return '<input name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textinput ' . $settings['param_name'] . ' ' . $settings['type'] . '" type="text" value="' . $value . '"/>'; }
/** * Dropdown(select with options) shortcode attribute type generator. * * @param $settings * @param $value * * @return string - html string. * @since 4.4 */ 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; }
/** * Checkbox shortcode attribute type generator. * * @param $settings * @param string $value * * @return string - html string. * @since 4.4 */ function vc_checkbox_form_field( $settings, $value ) { $output = ''; if ( is_array( $value ) ) { $value = ''; // fix #1239 } $current_value = strlen( $value ) > 0 ? explode( ',', $value ) : array(); $values = isset( $settings['value'] ) && is_array( $settings['value'] ) ? $settings['value'] : array( esc_html__( 'Yes', 'js_composer' ) => 'true' ); if ( ! empty( $values ) ) { foreach ( $values as $label => $v ) { // NOTE!! Don't use strict compare here for BC! // @codingStandardsIgnoreLine $checked = in_array( $v, $current_value ) ? 'checked' : ''; $output .= ' <label class="vc_checkbox-label"><input id="' . $settings['param_name'] . '-' . $v . '" value="' . $v . '" class="wpb_vc_param_value ' . $settings['param_name'] . ' ' . $settings['type'] . '" type="checkbox" name="' . $settings['param_name'] . '" ' . $checked . '>' . $label . '</label>'; } }
return $output; }
add_filter( 'vc_map_get_param_defaults', 'vc_checkbox_param_defaults', 10, 2 ); /** * @param $value * @param $param * @return mixed|string */ function vc_checkbox_param_defaults( $value, $param ) { if ( 'checkbox' === $param['type'] ) { $value = ''; if ( isset( $param['std'] ) ) { $value = $param['std']; } }
return $value; }
/** * Checkbox shortcode attribute type generator. * * @param $settings * @param $value * * @return string - html string. * @since 4.4 */ function vc_posttypes_form_field( $settings, $value ) { $output = ''; $args = array( 'public' => true, ); $post_types = get_post_types( $args ); foreach ( $post_types as $post_type ) { $checked = ''; if ( 'attachment' !== $post_type ) { if ( in_array( $post_type, explode( ',', $value ), true ) ) { $checked = 'checked="checked"'; } $output .= '<label class="vc_checkbox-label"><input id="' . $settings['param_name'] . '-' . $post_type . '" value="' . $post_type . '" class="wpb_vc_param_value ' . $settings['param_name'] . ' ' . $settings['type'] . '" type="checkbox" name="' . $settings['param_name'] . '" ' . $checked . '> ' . $post_type . '</label>'; } }
return $output; }
/** * Taxonomies shortcode attribute type generator. * * @param $settings * @param $value * * @return string - html string. * @since 4.4 */ function vc_taxonomies_form_field( $settings, $value ) { $output = ''; $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( ',', $value ), true ) ) { $checked = 'checked'; } $output .= ' <label class="vc_checkbox-label" data-post-type="' . $type . '"><input id="' . $settings['param_name'] . '-' . $tax->name . '" value="' . $tax->name . '" data-post-type="' . $type . '" class="wpb_vc_param_value ' . $settings['param_name'] . ' ' . $settings['type'] . '" type="checkbox" name="' . $settings['param_name'] . '" ' . $checked . '> ' . $tax->label . '</label>'; } }
return $output; }
/** * Exploded textarea shortcode attribute type generator. * * Data saved and coma-separated values are merged with line breaks and returned in a textarea. * * @param $settings * @param $value * * @return string - html string. * @since 4.4 */ function vc_exploded_textarea_form_field( $settings, $value ) { $value = str_replace( ',', "\n", $value );
return '<textarea name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textarea ' . $settings['param_name'] . ' ' . $settings['type'] . '">' . $value . '</textarea>'; }
/** * Safe Textarea shortcode attribute type generator. * * @param $settings * @param $value * * @return string - html string. * @since 4.8.2 */ function vc_exploded_textarea_safe_form_field( $settings, $value ) { $value = vc_value_from_safe( $value, true ); $value = str_replace( ',', "\n", $value );
return '<textarea name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textarea ' . $settings['param_name'] . ' ' . $settings['type'] . '">' . $value . '</textarea>'; }
/** * Textarea raw html shortcode attribute type generator. * * This attribute type allows safely add custom html to your post/page. * * @param $settings * @param $value * * @return string - html string. * @since 4.4 */ function vc_textarea_raw_html_form_field( $settings, $value ) { // @codingStandardsIgnoreLine return sprintf( '<textarea name="%s" class="wpb_vc_param_value wpb-textarea_raw_html %s %s" rows="16">%s</textarea>', $settings['param_name'], $settings['param_name'], $settings['type'], htmlentities( rawurldecode( base64_decode( $value ) ), ENT_COMPAT, 'UTF-8' ) ); }
/** * Safe Textarea shortcode attribute type generator. * * @param $settings * @param $value * * @return string - html string. * @since 4.4 */ function vc_textarea_safe_form_field( $settings, $value ) { return '<textarea name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textarea_raw_html ' . $settings['param_name'] . ' ' . $settings['type'] . '">' . vc_value_from_safe( $value, true ) . '</textarea>';
}
/** * Textarea shortcode attribute type generator. * * @param $settings * @param $value * * @return string - html string. * @since 4.4 */ function vc_textarea_form_field( $settings, $value ) { return '<textarea name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textarea ' . $settings['param_name'] . ' ' . $settings['type'] . '">' . $value . '</textarea>'; }
/** * Attach images shortcode attribute type generator. * * @param $settings * @param $value * * @param $tag * @param bool $single * * @return string - html string. * @since 4.4 * */ 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 ' . esc_attr( $settings['param_name'] ) . ' ' . esc_attr( $settings['type'] ) . '" name="' . esc_attr( $settings['param_name'] ) . '" value="' . $value . '"/>'; $output .= '<div class="gallery_widget_attached_images">'; $output .= '<ul class="gallery_widget_attached_images_list">'; $output .= ( '' !== $param_value ) ? vc_field_attached_images( 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="javascript:;" use-single="true" title="' . esc_attr__( 'Add image', 'js_composer' ) . '"><i class="vc-composer-icon vc-c-icon-add"></i>' . esc_html__( 'Add image', 'js_composer' ) . '</a>'; } else { $output .= '<a class="gallery_widget_add_images" href="javascript:;" title="' . esc_attr__( 'Add images', 'js_composer' ) . '"><i class="vc-composer-icon vc-c-icon-add"></i>' . esc_html__( 'Add images', 'js_composer' ) . '</a>'; }
return $output; }
/** * Attach image shortcode attribute type generator. * * @param $settings * @param $value * * @param $tag * * @return string - html string. * @since 4.4 */ function vc_attach_image_form_field( $settings, $value, $tag ) { return vc_attach_images_form_field( $settings, $value, $tag, true ); }
/** * Widgetised sidebars shortcode attribute type generator. * * @param $settings * @param $value * * @return string - html string. * @since 4.4 */ function vc_widgetised_sidebars_form_field( $settings, $value ) { $output = ''; $sidebars = $GLOBALS['wp_registered_sidebars'];
$output .= '<select name="' . esc_attr( $settings['param_name'] ) . '" class="wpb_vc_param_value dropdown wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . '">'; foreach ( $sidebars as $sidebar ) { $selected = ''; if ( $sidebar['id'] === $value ) { $selected = 'selected'; } $sidebar_name = $sidebar['name']; $output .= '<option value="' . esc_attr( $sidebar['id'] ) . '" ' . $selected . '>' . $sidebar_name . '</option>'; } $output .= '</select>';
return $output; }
|