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.6.3.1 2.6.3.2 2.7.0.5 2.7.1.1 2.7.2 2.7.2.1 2.7.3 2.7.3.1 2.7.3.2 2.7.4.1 2.7.4.2 2.7.4.3 2.7.4.4 2.7.4.5 2.8.0.4 2.8.0.5 2.8.0.7 2.8.1.1 2.8.1.2 2.8.1.3 2.8.2.2 2.8.3.1 2.8.3.2 2.8.3.4 2.8.3.5 2.8.3.6 2.8.3.7 2.8.3.9 2.8.4.1 2.8.4.2 2.8.4.3 2.8.4.4 2.8.5.3
beaver-builder-lite-version / modules / button / button.php
beaver-builder-lite-version / modules / button Last commit date
includes 5 years ago js 5 years ago button.php 5 years ago
button.php
529 lines
1 <?php
2
3 /**
4 * @class FLButtonModule
5 */
6 class FLButtonModule extends FLBuilderModule {
7
8 /**
9 * @method __construct
10 */
11 public function __construct() {
12 parent::__construct(array(
13 'name' => __( 'Button', 'fl-builder' ),
14 'description' => __( 'A simple call to action button.', 'fl-builder' ),
15 'category' => __( 'Basic', 'fl-builder' ),
16 'partial_refresh' => true,
17 'icon' => 'button.svg',
18 ));
19 }
20
21 /**
22 * Ensure backwards compatibility with old settings.
23 *
24 * @since 2.2
25 * @param object $settings A module settings object.
26 * @param object $helper A settings compatibility helper.
27 * @return object
28 */
29 public function filter_settings( $settings, $helper ) {
30
31 // Handle old responsive button align.
32 if ( isset( $settings->mobile_align ) ) {
33 $settings->align_responsive = $settings->mobile_align;
34 unset( $settings->mobile_align );
35 }
36
37 // Handle old font size setting.
38 if ( isset( $settings->font_size ) ) {
39 $settings->typography = array();
40 $settings->typography['font_size'] = array(
41 'length' => $settings->font_size,
42 'unit' => isset( $settings->font_size_unit ) ? $settings->font_size_unit : 'px',
43 );
44 $settings->typography['line_height'] = array(
45 'length' => $settings->font_size,
46 'unit' => isset( $settings->font_size_unit ) ? $settings->font_size_unit : 'px',
47 );
48 unset( $settings->font_size );
49 unset( $settings->font_size_unit );
50 }
51
52 // Handle old padding setting.
53 if ( isset( $settings->padding ) && is_numeric( $settings->padding ) ) {
54 $settings->padding_top = $settings->padding;
55 $settings->padding_bottom = $settings->padding;
56 $settings->padding_left = $settings->padding * 2;
57 $settings->padding_right = $settings->padding * 2;
58 unset( $settings->padding );
59 }
60
61 // Handle old gradient style setting.
62 if ( isset( $settings->three_d ) && $settings->three_d ) {
63 $settings->style = 'gradient';
64 }
65
66 // Handle old border settings.
67 if ( ! empty( $settings->bg_color ) && ( ! isset( $settings->border ) || empty( $settings->border ) ) ) {
68 $settings->border = array();
69
70 // Border style, color, and width
71 if ( isset( $settings->border_size ) && isset( $settings->style ) && 'transparent' === $settings->style ) {
72 $settings->border['style'] = 'solid';
73 $settings->border['color'] = FLBuilderColor::adjust_brightness( $settings->bg_color, 12, 'darken' );
74 $settings->border['width'] = array(
75 'top' => $settings->border_size,
76 'right' => $settings->border_size,
77 'bottom' => $settings->border_size,
78 'left' => $settings->border_size,
79 );
80 unset( $settings->border_size );
81 if ( ! empty( $settings->bg_hover_color ) ) {
82 $settings->border_hover_color = FLBuilderColor::adjust_brightness( $settings->bg_hover_color, 12, 'darken' );
83 }
84 }
85
86 // Border radius
87 if ( isset( $settings->border_radius ) ) {
88 $settings->border['radius'] = array(
89 'top_left' => $settings->border_radius,
90 'top_right' => $settings->border_radius,
91 'bottom_left' => $settings->border_radius,
92 'bottom_right' => $settings->border_radius,
93 );
94 unset( $settings->border_radius );
95 }
96 }
97
98 // Handle old transparent background style.
99 if ( isset( $settings->style ) && 'transparent' === $settings->style ) {
100 $settings->style = 'flat';
101 $helper->handle_opacity_inputs( $settings, 'bg_opacity', 'bg_color' );
102 $helper->handle_opacity_inputs( $settings, 'bg_hover_opacity', 'bg_hover_color' );
103 }
104
105 // Return the filtered settings.
106 return $settings;
107 }
108
109 /**
110 * @method enqueue_scripts
111 */
112 public function enqueue_scripts() {
113 if ( $this->settings && 'lightbox' == $this->settings->click_action ) {
114 $this->add_js( 'jquery-magnificpopup' );
115 $this->add_css( 'font-awesome-5' );
116 $this->add_css( 'jquery-magnificpopup' );
117 }
118 }
119
120 /**
121 * @method update
122 */
123 public function update( $settings ) {
124 // Remove the old three_d setting.
125 if ( isset( $settings->three_d ) ) {
126 unset( $settings->three_d );
127 }
128
129 return $settings;
130 }
131
132 /**
133 * @method get_classname
134 */
135 public function get_classname() {
136 $classname = 'fl-button-wrap';
137
138 if ( ! empty( $this->settings->width ) ) {
139 $classname .= ' fl-button-width-' . $this->settings->width;
140 }
141 if ( ! empty( $this->settings->align ) ) {
142 $classname .= ' fl-button-' . $this->settings->align;
143 }
144 if ( ! empty( $this->settings->icon ) ) {
145 $classname .= ' fl-button-has-icon';
146 }
147
148 return $classname;
149 }
150
151 /**
152 * Returns button link rel based on settings
153 * @since 1.10.9
154 */
155 public function get_rel() {
156 $rel = array();
157 if ( '_blank' == $this->settings->link_target ) {
158 $rel[] = 'noopener';
159 }
160 if ( isset( $this->settings->link_nofollow ) && 'yes' == $this->settings->link_nofollow ) {
161 $rel[] = 'nofollow';
162 }
163 $rel = implode( ' ', $rel );
164 if ( $rel ) {
165 $rel = ' rel="' . $rel . '" ';
166 }
167 return $rel;
168 }
169
170 }
171
172 /**
173 * Register the module and its form settings.
174 */
175 FLBuilder::register_module('FLButtonModule', array(
176 'general' => array(
177 'title' => __( 'General', 'fl-builder' ),
178 'sections' => array(
179 'general' => array(
180 'title' => '',
181 'fields' => array(
182 'text' => array(
183 'type' => 'text',
184 'label' => __( 'Text', 'fl-builder' ),
185 'default' => __( 'Click Here', 'fl-builder' ),
186 'preview' => array(
187 'type' => 'text',
188 'selector' => '.fl-button-text',
189 ),
190 'connections' => array( 'string' ),
191 ),
192 'icon' => array(
193 'type' => 'icon',
194 'label' => __( 'Icon', 'fl-builder' ),
195 'show_remove' => true,
196 'show' => array(
197 'fields' => array( 'icon_position', 'icon_animation' ),
198 ),
199 'preview' => array(
200 'type' => 'none',
201 ),
202 ),
203 'icon_position' => array(
204 'type' => 'select',
205 'label' => __( 'Icon Position', 'fl-builder' ),
206 'default' => 'before',
207 'options' => array(
208 'before' => __( 'Before Text', 'fl-builder' ),
209 'after' => __( 'After Text', 'fl-builder' ),
210 ),
211 'preview' => array(
212 'type' => 'none',
213 ),
214 ),
215 'icon_animation' => array(
216 'type' => 'select',
217 'label' => __( 'Icon Visibility', 'fl-builder' ),
218 'default' => 'disable',
219 'options' => array(
220 'disable' => __( 'Always Visible', 'fl-builder' ),
221 'enable' => __( 'Fade In On Hover', 'fl-builder' ),
222 ),
223 'preview' => array(
224 'type' => 'none',
225 ),
226 ),
227 'click_action' => array(
228 'type' => 'select',
229 'label' => __( 'Click Action', 'fl-builder' ),
230 'default' => 'link',
231 'options' => array(
232 'link' => __( 'Link', 'fl-builder' ),
233 'lightbox' => __( 'Lightbox', 'fl-builder' ),
234 ),
235 'toggle' => array(
236 'link' => array(
237 'fields' => array( 'link' ),
238 ),
239 'lightbox' => array(
240 'sections' => array( 'lightbox' ),
241 ),
242 ),
243 'preview' => array(
244 'type' => 'none',
245 ),
246 ),
247 'link' => array(
248 'type' => 'link',
249 'label' => __( 'Link', 'fl-builder' ),
250 'placeholder' => __( 'http://www.example.com', 'fl-builder' ),
251 'show_target' => true,
252 'show_nofollow' => true,
253 'show_download' => true,
254 'preview' => array(
255 'type' => 'none',
256 ),
257 'connections' => array( 'url' ),
258 ),
259 ),
260 ),
261 'lightbox' => array(
262 'title' => __( 'Lightbox Content', 'fl-builder' ),
263 'fields' => array(
264 'lightbox_content_type' => array(
265 'type' => 'select',
266 'label' => __( 'Content Type', 'fl-builder' ),
267 'default' => 'html',
268 'options' => array(
269 'html' => __( 'HTML', 'fl-builder' ),
270 'video' => __( 'Video', 'fl-builder' ),
271 ),
272 'preview' => array(
273 'type' => 'none',
274 ),
275 'toggle' => array(
276 'html' => array(
277 'fields' => array( 'lightbox_content_html' ),
278 ),
279 'video' => array(
280 'fields' => array( 'lightbox_video_link' ),
281 ),
282 ),
283 ),
284 'lightbox_content_html' => array(
285 'type' => 'code',
286 'editor' => 'html',
287 'label' => '',
288 'rows' => '19',
289 'preview' => array(
290 'type' => 'none',
291 ),
292 'connections' => array( 'string' ),
293 ),
294 'lightbox_video_link' => array(
295 'type' => 'text',
296 'label' => __( 'Video Link', 'fl-builder' ),
297 'placeholder' => 'https://vimeo.com/122546221',
298 'preview' => array(
299 'type' => 'none',
300 ),
301 'connections' => array( 'custom_field' ),
302 ),
303 ),
304 ),
305 ),
306 ),
307 'style' => array(
308 'title' => __( 'Style', 'fl-builder' ),
309 'sections' => array(
310 'style' => array(
311 'title' => '',
312 'fields' => array(
313 'width' => array(
314 'type' => 'select',
315 'label' => __( 'Width', 'fl-builder' ),
316 'default' => 'auto',
317 'options' => array(
318 'auto' => _x( 'Auto', 'Width.', 'fl-builder' ),
319 'full' => __( 'Full Width', 'fl-builder' ),
320 'custom' => __( 'Custom', 'fl-builder' ),
321 ),
322 'toggle' => array(
323 'auto' => array(
324 'fields' => array( 'align' ),
325 ),
326 'full' => array(),
327 'custom' => array(
328 'fields' => array( 'align', 'custom_width' ),
329 ),
330 ),
331 ),
332 'custom_width' => array(
333 'type' => 'unit',
334 'label' => __( 'Custom Width', 'fl-builder' ),
335 'default' => '200',
336 'slider' => array(
337 'px' => array(
338 'min' => 0,
339 'max' => 1000,
340 'step' => 10,
341 ),
342 ),
343 'units' => array(
344 'px',
345 'vw',
346 '%',
347 ),
348 'preview' => array(
349 'type' => 'css',
350 'selector' => 'a.fl-button',
351 'property' => 'width',
352 ),
353 ),
354 'align' => array(
355 'type' => 'align',
356 'label' => __( 'Align', 'fl-builder' ),
357 'default' => 'left',
358 'responsive' => true,
359 'preview' => array(
360 'type' => 'css',
361 'selector' => '.fl-button-wrap',
362 'property' => 'text-align',
363 ),
364 ),
365 'padding' => array(
366 'type' => 'dimension',
367 'label' => __( 'Padding', 'fl-builder' ),
368 'responsive' => true,
369 'slider' => true,
370 'units' => array( 'px' ),
371 'preview' => array(
372 'type' => 'css',
373 'selector' => 'a.fl-button',
374 'property' => 'padding',
375 ),
376 ),
377 ),
378 ),
379 'text' => array(
380 'title' => __( 'Text', 'fl-builder' ),
381 'fields' => array(
382 'text_color' => array(
383 'type' => 'color',
384 'connections' => array( 'color' ),
385 'label' => __( 'Text Color', 'fl-builder' ),
386 'default' => '',
387 'show_reset' => true,
388 'show_alpha' => true,
389 'preview' => array(
390 'type' => 'css',
391 'selector' => 'a.fl-button, a.fl-button *',
392 'property' => 'color',
393 'important' => true,
394 ),
395 ),
396 'text_hover_color' => array(
397 'type' => 'color',
398 'connections' => array( 'color' ),
399 'label' => __( 'Text Hover Color', 'fl-builder' ),
400 'default' => '',
401 'show_reset' => true,
402 'show_alpha' => true,
403 'preview' => array(
404 'type' => 'css',
405 'selector' => 'a.fl-button:hover, a.fl-button:hover *, a.fl-button:focus, a.fl-button:focus *',
406 'property' => 'color',
407 'important' => true,
408 ),
409 ),
410 'typography' => array(
411 'type' => 'typography',
412 'label' => __( 'Typography', 'fl-builder' ),
413 'responsive' => true,
414 'preview' => array(
415 'type' => 'css',
416 'selector' => 'a.fl-button',
417 ),
418 ),
419 ),
420 ),
421 'icons' => array(
422 'title' => __( 'Icon', 'fl-builder' ),
423 'fields' => array(
424 'duo_color1' => array(
425 'label' => __( 'DuoTone Icon Primary Color', 'fl-builder' ),
426 'type' => 'color',
427 'default' => '',
428 'show_reset' => true,
429 'show_alpha' => true,
430 'preview' => array(
431 'type' => 'css',
432 'selector' => 'i.fl-button-icon.fad:before',
433 'property' => 'color',
434 'important' => true,
435 ),
436 ),
437 'duo_color2' => array(
438 'label' => __( 'DuoTone Icon Secondary Color', 'fl-builder' ),
439 'type' => 'color',
440 'default' => '',
441 'show_reset' => true,
442 'show_alpha' => true,
443 'preview' => array(
444 'type' => 'css',
445 'selector' => 'i.fl-button-icon.fad:after',
446 'property' => 'color',
447 'important' => true,
448 ),
449 ),
450 ),
451 ),
452 'colors' => array(
453 'title' => __( 'Background', 'fl-builder' ),
454 'fields' => array(
455 'bg_color' => array(
456 'type' => 'color',
457 'connections' => array( 'color' ),
458 'label' => __( 'Background Color', 'fl-builder' ),
459 'default' => '',
460 'show_reset' => true,
461 'show_alpha' => true,
462 'preview' => array(
463 'type' => 'none',
464 ),
465 ),
466 'bg_hover_color' => array(
467 'type' => 'color',
468 'connections' => array( 'color' ),
469 'label' => __( 'Background Hover Color', 'fl-builder' ),
470 'default' => '',
471 'show_reset' => true,
472 'show_alpha' => true,
473 'preview' => array(
474 'type' => 'none',
475 ),
476 ),
477 'style' => array(
478 'type' => 'select',
479 'label' => __( 'Background Style', 'fl-builder' ),
480 'default' => 'flat',
481 'options' => array(
482 'flat' => __( 'Flat', 'fl-builder' ),
483 'gradient' => __( 'Gradient', 'fl-builder' ),
484 ),
485 ),
486 'button_transition' => array(
487 'type' => 'select',
488 'label' => __( 'Background Animation', 'fl-builder' ),
489 'default' => 'disable',
490 'options' => array(
491 'disable' => __( 'Disabled', 'fl-builder' ),
492 'enable' => __( 'Enabled', 'fl-builder' ),
493 ),
494 'preview' => array(
495 'type' => 'none',
496 ),
497 ),
498 ),
499 ),
500 'border' => array(
501 'title' => __( 'Border', 'fl-builder' ),
502 'fields' => array(
503 'border' => array(
504 'type' => 'border',
505 'label' => __( 'Border', 'fl-builder' ),
506 'responsive' => true,
507 'preview' => array(
508 'type' => 'css',
509 'selector' => 'a.fl-button',
510 'important' => true,
511 ),
512 ),
513 'border_hover_color' => array(
514 'type' => 'color',
515 'connections' => array( 'color' ),
516 'label' => __( 'Border Hover Color', 'fl-builder' ),
517 'default' => '',
518 'show_reset' => true,
519 'show_alpha' => true,
520 'preview' => array(
521 'type' => 'none',
522 ),
523 ),
524 ),
525 ),
526 ),
527 ),
528 ));
529