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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
<?php if(!class_exists('Ult_Content_Box')) { class Ult_Content_Box { function __construct() { if ( Ultimate_VC_Addons::$uavc_editor_enable ) { add_action( 'init', array( $this, 'ult_content_box_init' ) ); } add_shortcode("ult_content_box",array($this,"ult_content_box_callback")); add_action( 'wp_enqueue_scripts', array( $this, 'ult_content_box_scripts' ), 1 ); } function ult_content_box_callback($atts, $content = null){ extract( shortcode_atts( array( 'bg_type' => 'bg_color', 'bg_image' => '', 'bg_color' => '', 'bg_repeat' => 'repeat', 'bg_size' => 'cover', 'bg_position' => 'center center', 'border' => '', 'box_shadow' => '', 'box_shadow_color' => '', 'padding' => '', 'margin' => '', 'link' => '', 'hover_bg_color' => '', 'hover_border_color' => '', 'hover_box_shadow' => '', 'box_hover_shadow_color' => '', 'min_height' => '', 'el_class' => '', 'trans_property' => 'all', 'trans_duration' => '700', 'trans_function' => 'ease', 'responsive_margin' => '', /*'img_overlay_hover_effect' => '',*/ ), $atts ) );
/* init var's */ $style = $url = $link_title = $target = $responsive_margins = $normal_margins = $hover = $shadow = $data_attr = $target = $link_title = $rel = '';
if($bg_type!='') { switch ($bg_type) { case 'bg_color': /* background color */ if($bg_color!='') { $style .= 'background-color:'.$bg_color.';'; $data_attr .= ' data-bg="'.esc_attr( $bg_color ).'" '; } if($hover_bg_color!='') { $hover .= ' data-hover_bg_color="'.esc_attr($hover_bg_color).'" '; } break; case 'bg_image': if($bg_image != '') { $img = wp_get_attachment_image_src( $bg_image, 'large'); $style .= "background-image:url('".esc_url($img[0])."');"; $style .= 'background-size: '.esc_attr($bg_size).';'; $style .= 'background-repeat: '.esc_attr($bg_repeat).';'; $style .= 'background-position: '.esc_attr($bg_position).';'; $style .= 'background-color: rgba(0, 0, 0, 0);'; } break; } }
/* box shadow */ if($box_shadow!='' ) { $style .= apply_filters('Ultimate_GetBoxShadow', $box_shadow, 'css'); }
/* box shadow - {HOVER} */ if($hover_box_shadow!='' ) {
$data = apply_filters('Ultimate_GetBoxShadow', $hover_box_shadow, 'data');
if ( strpos($data,'none') !== false ) { $data = 'none'; } // Apply default box shadow if ( strpos($data,'inherit') !== false ) { if($box_shadow!='') { $data = apply_filters('Ultimate_GetBoxShadow', $box_shadow, 'data'); } }
$hover .= ' data-hover_box_shadow="'.esc_attr($data).'" '; }
/* border */ if($border!=''){ $border_array = explode('|', $border); $border_color = ''; foreach ($border_array as $border_val) { $border_value_array = explode(':', $border_val); if(isset($border_value_array[0]) && $border_value_array[0] === 'border-color') { $border_color = (isset($border_value_array[1])) ? rtrim($border_value_array[1], ';') : ''; } } $temp_border = str_replace( '|', '', $border ); $style .= $temp_border; $data_attr .= ' data-border_color="'.esc_attr($border_color).'" '; }
/* link */ if($link!='') { $href = vc_build_link($link); $url = ( isset( $href['url'] ) && $href['url'] !== '' ) ? $href['url'] : ''; $target = ( isset( $href['target'] ) && $href['target'] !== '' ) ? esc_attr( trim( $href['target'] ) ) : ''; $link_title = ( isset( $href['title'] ) && $href['title'] !== '' ) ? esc_attr($href['title']) : ''; $rel = ( isset( $href['rel'] ) && $href['rel'] !== '' ) ? esc_attr($href['rel']) : ''; }
/* padding */ if($padding!=''){ $style .= $padding; }
/* margin */ if($margin!=''){ $style .= $margin; }
// HOVER if($hover_border_color!='') { $hover .= ' data-hover_border_color="'.esc_attr($hover_border_color).'" '; } if($min_height!='') { $style .= 'min-height:'.esc_attr($min_height).'px;'; }
// Transition Effect if($trans_property!='' && $trans_duration!='' && $trans_function!='') { $style .= '-webkit-transition: '.$trans_property.' '.$trans_duration.'ms '.$trans_function.';'; $style .= '-moz-transition: '.$trans_property.' '.$trans_duration.'ms '.$trans_function.';'; $style .= '-ms-transition: '.$trans_property.' '.$trans_duration.'ms '.$trans_function.';'; $style .= '-o-transition: '.$trans_property.' '.$trans_duration.'ms '.$trans_function.';'; $style .= 'transition: '.$trans_property.' '.$trans_duration.'ms '.$trans_function.';'; }
/* Margins - Responsive */ if($responsive_margin!='') { $responsive_margins .= ' data-responsive_margins="'.esc_attr($responsive_margin).'" '; } /* Margins - Normal */ if($margin!='') { $normal_margins .= ' data-normal_margins="'.esc_attr($margin).'" '; }
$output = '<div class="ult-content-box-container '.esc_attr($el_class).'" >'; if($link!='') { $output .= ' <a class="ult-content-box-anchor" '. Ultimate_VC_Addons::uavc_link_init($url, $target, $link_title, $rel ).'>'; } $output .= ' <div class="ult-content-box" style="'.esc_attr($style).'" '.$hover.' '.$responsive_margins.' '.$normal_margins.' '.$data_attr.'>'; $output .= do_shortcode( $content ); $output .= ' </div>'; if($link!='') { $output .= ' </a>'; } $output .= '</div>';
return $output; }
function ult_content_box_init() { if(function_exists("vc_map")){ vc_map( array( "name" => __("Content Box", "ultimate_vc"), "base" => "ult_content_box", "icon" => "vc_icon_content_box", "class" => "vc_icon_content_box", "as_parent" => array('except' => 'ult_content_box'), //"as_parent" => '', ///"content_element" => true, "controls" => "full", "show_settings_on_create" => true, //"is_container" => true, "category" => "Ultimate VC Addons", "description" => __("Content Box.","ultimate_vc"), "js_view" => 'VcColumnView', "params" => array( array( "type" => "dropdown", "heading" => __("Background Type","ultimate_vc"), "param_name" => "bg_type", "value" => array( __("Background Color","ultimate_vc") => "bg_color", __("Background Image","ultimate_vc") => "bg_image", ), ), /*array( "type" => "dropdown", "class" => "", "heading" => __("Transition Property","ultimate_vc"), "param_name" => "trans_property", "value" => array( __("All", "ultimate_vc") => 'all', __("Background", "ultimate_vc") => 'background', __("Color", "ultimate_vc") => 'color', __("Height", "ultimate_vc") => 'height', __("Width", "ultimate_vc") => 'width', __("Outline", "ultimate_vc") => 'outline', ), "group"=> "Effect", ),*/ array( "type" => "colorpicker", "heading" => __("Background Color","ultimate_vc"), "param_name" => "bg_color", "dependency" => Array("element" => "bg_type", "value" => "bg_color" ), ), array( "type" => "attach_image", "heading" => __("Background Image", 'ultimate_vc'), "param_name" => "bg_image", "description" => __("Set background image for content box.", 'ultimate_vc'), "dependency" => Array("element" => "bg_type", "value" => "bg_image" ), ), array( "type" => "ultimate_border", "heading" => __("Border","ultimate_vc"), "param_name" => "border", "unit" => "px", // [required] px,em,%,all Default all "positions" => array( __("Top","ultimate_vc") => "", __("Right","ultimate_vc") => "", __("Bottom","ultimate_vc") => "", __("Left","ultimate_vc") => "" ), //"enable_radius" => false, // Enable border-radius. default true "radius" => array( __("Top Left","ultimate_vc") => "", // use 'Top Left' __("Top Right","ultimate_vc") => "", // use 'Top Right' __("Bottom Right","ultimate_vc") => "", // use 'Bottom Right' __("Bottom Left","ultimate_vc") => "" // use 'Bottom Left' ), //"label_color" => __("Border Color","ultimate_vc"), // label for 'border color' default 'Border Color' //"label_radius" => __("Border Radius","ultimate_vc"), // label for 'radius' default 'Border Redius' //"label_border" => "Border Style", // label for 'style' default 'Border Style' ), array( "type" => "ultimate_boxshadow", "heading" => __("Box Shadow", "ultimate_vc"), "param_name" => "box_shadow", "unit" => "px", // [required] px,em,%,all Default all "positions" => array( __("Horizontal","ultimate_vc") => "", __("Vertical","ultimate_vc") => "", __("Blur","ultimate_vc") => "", __("Spread","ultimate_vc") => "" ), //"enable_color" => false, //"label_style" => __("Style","ultimate_vc"), //"label_color" => __("Shadow Color","ultimate_vc"), ), /*array( "type" => "colorpicker", "edit_field_class" => "vc_col-sm-12 vc_column box_shadow_ultimate_box_shadow_color", // color dependency "heading" => __("Shadow Color","ultimate_vc"), "param_name" => "box_shadow_color", ),*/
// Spacing array( "type" => "ult_param_heading", "param_name" => "content_spacing", "text" => __("Spacing","ultimate_vc"), "value" => "", 'edit_field_class' => 'ult-param-heading-wrapper vc_column vc_col-sm-12', ), array( "type" => "ultimate_spacing", "heading" => __("Padding", "ultimate_vc"), "param_name" => "padding", "mode" => "padding", // margin/padding "unit" => "px", // [required] px,em,%,all Default all "positions" => array( // Also set 'defaults' __("Top","ultimate_vc") => "", __("Right","ultimate_vc") => "", __("Bottom","ultimate_vc") => "", __("Left","ultimate_vc") => "" ), ), array( "type" => "ultimate_spacing", "heading" => __("Margin", "ultimate_vc"), "param_name" => "margin", "mode" => "margin", // margin/padding "unit" => "px", // [required] px,em,%,all Default all "positions" => array( // Also set 'defaults' __("Top","ultimate_vc") => "", __("Right","ultimate_vc") => "", __("Bottom","ultimate_vc") => "", __("Left","ultimate_vc") => "" ), ), array( "type" => "vc_link", "heading" => __("Content Box Link","ultimate_vc"), "param_name" => "link", //"description" => __("", "ultimate_vc"), //"dependency" => array("element" => "img_link_type", "value" => "custom"), ), array( "type" => "number", "heading" => __("Min Height", "ultimate_vc"), "param_name" => "min_height", "suffix"=>"px", "min"=>"0", ), array( "type" => "textfield", "heading" => __("Extra class name", "ultimate_vc"), "param_name" => "el_class", "description" => __("If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.", "ultimate_vc") ),
// Background array( "type" => "dropdown", "heading" => __("Background Image Repeat","ultimate_vc"), "param_name" => "bg_repeat", "value" => array( __("Repeat", "ultimate_vc") => 'repeat', __("Repeat X", "ultimate_vc") => 'repeat-x', __("Repeat Y", "ultimate_vc") => 'repeat-y', __("No Repeat", "ultimate_vc") => 'no-repeat', ), "group" => "Background", "dependency" => Array("element" => "bg_type", "value" => "bg_image" ), ), array( "type" => "dropdown", "heading" => __("Background Image Size","ultimate_vc"), "param_name" => "bg_size", "value" => array( __("Cover - Image to be as large as possible", "ultimate_vc") => 'cover', __("Contain - Image will try to fit inside the container area", "ultimate_vc") => 'contain', __("Initial", "ultimate_vc") => 'initial', ), "group" => "Background", "dependency" => Array("element" => "bg_type", "value" => "bg_image" ), ), array( "type" => "textfield", "heading" => __("Background Image Posiiton", "ultimate_vc"), "param_name" => "bg_position", "description" => __("You can use any number with px, em, %, etc. Example- 100px 100px.", "ultimate_vc"), "group" => "Background", "dependency" => Array("element" => "bg_type", "value" => "bg_image" ), ),
// Hover array( "type" => "colorpicker", //"class" => "", "heading" => __("Background Color","ultimate_vc"), "param_name" => "hover_bg_color", "dependency" => Array("element" => "bg_type", "value" => "bg_color" ), "group" => "Hover", ), array( "type" => "colorpicker", "heading" => __("Border Color","ultimate_vc"), "param_name" => "hover_border_color", "edit_field_class" => "vc_col-sm-12 vc_column border_ultimate_border", // Custom dependency "group" => "Hover", ), array( "type" => "ultimate_boxshadow", "heading" => __("Box Shadow", "ultimate_vc"), "param_name" => "hover_box_shadow", "unit" => "px", // [required] px,em,%,all Default all "positions" => array( __("Horizontal","ultimate_vc") => "", __("Vertical","ultimate_vc") => "", __("Blur","ultimate_vc") => "", __("Spread","ultimate_vc") => "" ), "label_color" => __("Shadow Color","ultimate_vc"), //"enable_color" => false, //"label_style" => __("Style","ultimate_vc"), //"dependency" => Array("element" => "img_box_shadow_type", "value" => "on" ), "group" => "Hover", ), /*array( "type" => "colorpicker", "edit_field_class" => "vc_col-sm-12 vc_column hover_box_shadow_ultimate_box_shadow_color", // color dependency "heading" => __("Shadow Color","ultimate_vc"), "param_name" => "box_hover_shadow_color", "group" => "Hover", ),*/
// Effect array( "type" => "ult_param_heading", "param_name" => "content_transition", "text" => __("Transition Options","ultimate_vc"), 'edit_field_class' => 'ult-param-heading-wrapper vc_column vc_col-sm-12', "group" => "Hover", ), array( "type" => "dropdown", //"class" => "", "heading" => __("Transition Property","ultimate_vc"), "param_name" => "trans_property", "value" => array( __("All", "ultimate_vc") => 'all', __("Background", "ultimate_vc") => 'background', __("Color", "ultimate_vc") => 'color', __("Height", "ultimate_vc") => 'height', __("Width", "ultimate_vc") => 'width', __("Outline", "ultimate_vc") => 'outline', ), "group"=> "Hover", ), array( "type" => "number", //"class" => "", "heading" => __("Duration", "ultimate_vc"), "param_name" => "trans_duration", "suffix"=>"ms", "min"=>"0", "value" => "", "group"=> "Hover", ), array( "type" => "dropdown", //"class" => "", "heading" => __("Transition Effect","ultimate_vc"), "param_name" => "trans_function", "value" => array( __("Ease", "ultimate_vc") => 'ease', __("Linear", "ultimate_vc") => 'linear', __("Ease-In", "ultimate_vc") => 'ease-in', __("Ease-Out", "ultimate_vc") => 'ease-out', __("Ease-In-Out", "ultimate_vc") => 'ease-in-out', ), "group"=> "Hover", ),
// Responsive array( "type" => "ultimate_spacing", "heading" => __("Margin", "ultimate_vc"), "param_name" => "responsive_margin", "mode" => "margin", // margin/padding "unit" => "px", // [required] px,em,%,all Default all "positions" => array( // Also set 'defaults' __("Top","ultimate_vc") => "", __("Right","ultimate_vc") => "", __("Bottom","ultimate_vc") => "", __("Left","ultimate_vc") => "" ), "group" => __( 'Responsive', 'ultimate_vc' ), "description" => __( 'This margin will apply below screen 768px.', 'ultimate_vc' ) ), ), ) ); } } function ult_content_box_scripts() { Ultimate_VC_Addons::ultimate_register_style( 'ult_content_box_css', 'content-box' );
Ultimate_VC_Addons::ultimate_register_script( 'ult_content_box_js', 'content-box', false, array( 'jquery' ) ); } } // Finally initialize code new Ult_Content_Box; if ( class_exists( 'WPBakeryShortCodesContainer' ) && !class_exists( 'WPBakeryShortCode_ult_content_box' ) ) { class WPBakeryShortCode_ult_content_box extends WPBakeryShortCodesContainer { } } }
|