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
|
<?php /** * Show button shortcode * * @param array $atts * @param string $content * * @return string */ if ( ! function_exists( 'penci_button_shortcode' ) ) { function penci_button_shortcode( $atts, $content ) { $link = $color = $size = $icon = $icon_position = ''; $id = $nofollow = $background = $text_color = $target = $align = ''; $full = $class = $margin_bottom = $text_hover_color = $hover_bgcolor = '';
$atts = shortcode_atts( array( 'link' => '#', 'color' => '', 'size' => '', 'icon' => '', 'icon_position' => '',
'id' => '', 'nofollow' => '', 'background' => '', 'text_color' => '', 'hover_bgcolor' => '', 'text_hover_color' => '', 'target' => '', 'align' => '', 'full' => '', 'class' => '', 'margin_bottom' => '', ), $atts, 'button' );
extract( $atts );
$unique_id = 'pencisc-button' . '__' . rand( 1000, 100000000 );
$classes = array( 'pencisc-button', 'button', $unique_id );
if ( $full ) $classes[] = 'pencisc-full'; if ( $class ) $classes[] = $class; if ( 'right' == $icon_position ) $classes[] = 'pencisc-icon-right'; if ( $color ) $classes[] = "pencisc-background-$color"; if ( $align ) $classes[] = "pencisc-align-$align"; if ( $size ) $classes[] = "pencisc-$size"; $classes = implode( ' ', $classes ); $style = ''; if ( $background ) $style .= "background-color:$background;"; $style .= "border-color:$background;"; if ( $text_color ) $style .= "color:$text_color;";
if ( $margin_bottom || 0 == $margin_bottom ) { $style .= "margin-bottom:$margin_bottom;"; }
$content = do_shortcode( $content );
$html = "<a href='$link' class='$classes'" . ( $id ? " id='$id'" : '' ) . ( $nofollow ? " rel='nofollow'" : '' ) . ( $target ? " target='$target'" : '' ) . ( $style ? " style='$style'" : '' ) . '>'; if ( $icon ) { $icon = '<i class="' . $icon . '"></i>'; $content = $icon_position == 'right' ? ( $content . $icon ) : ( $icon . $content ); } $html .= $content . '</a>'; if ( $align == 'center' ) $html = '<div style="text-align:center">' . $html . '</div>';
if( $hover_bgcolor || $text_hover_color ) { $html .= '<style>a.button.'. $unique_id . ':hover{ ';
if ( $hover_bgcolor ){ $html .= "background-color:$hover_bgcolor !important;"; $html .= "border-color:$hover_bgcolor !important;"; }
if ( $text_hover_color ) { $html .= "color:$text_hover_color !important;"; }
$html .= '}</style>'; }
return apply_filters( 'pencisc_shortcode_button', $html, $atts, $content ); } }
|