PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.5.2
Shortcodes and extra features for Phlox theme v2.5.2
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / includes / elements / button.php
auxin-elements / includes / elements Last commit date
about-widget.php 6 years ago accordion-widget.php 6 years ago accordion.php 6 years ago attachment-url.php 6 years ago audio.php 6 years ago before-after.php 6 years ago button.php 6 years ago code.php 6 years ago contact-box.php 6 years ago contact-form.php 6 years ago custom-list.php 6 years ago divider.php 6 years ago dropcap.php 6 years ago facebook.php 6 years ago flickr.php 6 years ago gallery.php 6 years ago general-element-fields.php 6 years ago gmap.php 6 years ago highlight.php 6 years ago image.php 6 years ago instagram-feed.php 6 years ago latest-items.php 8 years ago latest-posts-slider.php 6 years ago popular-posts-widget.php 6 years ago quote.php 6 years ago recent-posts-grid-carousel.php 6 years ago recent-posts-land-style.php 6 years ago recent-posts-masonry.php 6 years ago recent-posts-tiles-carousel.php 6 years ago recent-posts-tiles.php 6 years ago recent-posts-timeline.php 6 years ago recent-posts-widget.php 6 years ago recent-products.php 6 years ago related-posts.php 8 years ago sample-element.php 6 years ago search.php 6 years ago socials-list.php 6 years ago staff.php 6 years ago tab-widget.php 6 years ago tabs.php 6 years ago testimonial.php 6 years ago text.php 6 years ago touch-slider.php 6 years ago video.php 6 years ago
button.php
397 lines
1 <?php
2 /**
3 * Button element
4 *
5 *
6 * @package Auxin
7 * @license LICENSE.txt
8 * @author averta
9 * @link http://phlox.pro/
10 * @copyright (c) 2010-2020 averta
11 */
12
13 function auxin_get_button_master_array( $master_array ) {
14
15 $master_array['aux_button'] = array(
16 'name' => __("Button", 'auxin-elements' ),
17 'auxin_output_callback' => 'auxin_widget_button_callback',
18 'base' => 'aux_button',
19 'description' => __('It adds a button element.', 'auxin-elements' ),
20 'class' => 'aux-widget-button',
21 'show_settings_on_create' => true,
22 'weight' => 1,
23 'is_widget' => false,
24 'is_shortcode' => true,
25 'is_so' => true,
26 'is_vc' => true,
27 'category' => THEME_NAME,
28 'group' => '',
29 'admin_enqueue_js' => '',
30 'admin_enqueue_css' => '',
31 'front_enqueue_js' => '',
32 'front_enqueue_css' => '',
33 'icon' => 'aux-element aux-pb-icons-button',
34 'custom_markup' => '',
35 'js_view' => '',
36 'html_template' => '',
37 'deprecated' => '',
38 'content_element' => '',
39 'as_parent' => '',
40 'as_child' => '',
41 'params' => array(
42 array(
43 'heading' => __('Button label','auxin-elements' ),
44 'description' => __('The label of button.','auxin-elements' ),
45 'param_name' => 'label',
46 'type' => 'textfield',
47 'value' => __('Button', 'auxin-elements'),
48 'holder' => 'textfield',
49 'class' => 'label',
50 'admin_label' => false,
51 'dependency' => '',
52 'weight' => '',
53 'group' => '' ,
54 'edit_field_class' => ''
55 ),
56 array(
57 'heading' => __('Button size','auxin-elements' ),
58 'description' => '',
59 'param_name' => 'size',
60 'type' => 'dropdown',
61 'def_value' => 'medium',
62 'value' => array(
63 'exlarge' => __('Exlarge', 'auxin-elements' ),
64 'large' => __('Large' , 'auxin-elements' ),
65 'medium' => __('Medium' , 'auxin-elements' ),
66 'small' => __('Small' , 'auxin-elements' ),
67 'tiny' => __('Tiny' , 'auxin-elements' )
68 ),
69 'holder' => '',
70 'class' => 'round',
71 'admin_label' => true,
72 'dependency' => '',
73 'weight' => '',
74 'group' => '' ,
75 'edit_field_class' => ''
76 ),
77 array(
78 'heading' => __('Button shape','auxin-elements' ),
79 'description' => '',
80 'param_name' => 'border',
81 'type' => 'aux_visual_select',
82 'value' => '',
83 'class' => 'border',
84 'admin_label' => false,
85 'dependency' => '',
86 'weight' => '',
87 'group' => __('Appearance', 'auxin-elements'),
88 'edit_field_class' => '',
89 'choices' => array(
90 '' => array(
91 'label' => __('Box', 'auxin-elements' ),
92 'image' => AUXIN_URL . 'images/visual-select/button-normal.svg'
93 ),
94 'round' => array(
95 'label' => __('Round', 'auxin-elements' ),
96 'image' => AUXIN_URL . 'images/visual-select/button-curved.svg'
97 ),
98 'curve' => array(
99 'label' => __('Curve', 'auxin-elements' ),
100 'image' => AUXIN_URL . 'images/visual-select/button-rounded.svg'
101 )
102 )
103 ),
104 array(
105 'heading' => __('Button style','auxin-elements' ),
106 'description' => '',
107 'param_name' => 'style',
108 'type' => 'aux_visual_select',
109 'value' => '',
110 'class' => 'style',
111 'admin_label' => false,
112 'dependency' => '',
113 'weight' => '',
114 'group' => __('Appearance', 'auxin-elements'),
115 'edit_field_class' => '',
116 'choices' => array(
117 '' => array(
118 'label' => __('Normal', 'auxin-elements' ),
119 'image' => AUXIN_URL . 'images/visual-select/button-normal.svg'
120 ),
121 '3d' => array(
122 'label' => __('3D', 'auxin-elements' ),
123 'image' => AUXIN_URL . 'images/visual-select/button-3d.svg'
124 ),
125 'outline' => array(
126 'label' => __('Outline', 'auxin-elements' ),
127 'image' => AUXIN_URL . 'images/visual-select/button-outline.svg'
128 )
129 )
130 ),
131 array(
132 'heading' => __('Uppercase label','auxin-elements' ),
133 'description' => '',
134 'param_name' => 'uppercase',
135 'type' => 'aux_switch',
136 'value' => '1',
137 'class' => 'uppercase',
138 'admin_label' => false,
139 'dependency' => '',
140 'weight' => '',
141 'group' => '' ,
142 'edit_field_class' => ''
143 ),
144 array(
145 'heading' => __('Darken the label','auxin-elements' ),
146 'description' => __('Darken label of button.','auxin-elements' ),
147 'param_name' => 'dark',
148 'type' => 'aux_switch',
149 'value' => '0',
150 'class' => 'dark',
151 'admin_label' => false,
152 'dependency' => '',
153 'weight' => '',
154 'group' => '' ,
155 'edit_field_class' => ''
156 ),
157 array(
158 'heading' => __('Icon for button','auxin-elements' ),
159 'description' => '',
160 'param_name' => 'icon',
161 'type' => 'aux_iconpicker',
162 'value' => '',
163 'class' => 'icon-name',
164 'admin_label' => false,
165 'dependency' => '',
166 'weight' => '',
167 'group' => '' ,
168 'edit_field_class' => ''
169 ),
170 array(
171 'heading' => __('Icon alignment','auxin-elements' ),
172 'description' => '',
173 'param_name' => 'icon_align',
174 'type' => 'aux_visual_select',
175 'def_value' => 'default',
176 'choices' => array(
177 // default template
178 'default' => array(
179 'label' => __('Default' , 'auxin-elements'),
180 'image' => AUXELS_ADMIN_URL . '/assets/images/button.png'
181 ),
182 'left' => array(
183 'label' => __('Left' , 'auxin-elements'),
184 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button2.webm webm'
185 ),
186 'right' => array(
187 'label' => __('Right' , 'auxin-elements'),
188 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button1.webm webm'
189 ),
190 'over' => array(
191 'label' => __('Over', 'auxin-elements'),
192 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button5.webm webm'
193 ),
194 'left-animate' => array(
195 'label' => __('Animate from Left', 'auxin-elements'),
196 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button4.webm webm'
197 ),
198 'right-animate' => array(
199 'label' => __('Animate from Righ', 'auxin-elements'),
200 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button3.webm webm'
201 ),
202 ),
203 'holder' => '',
204 'class' => 'icon-align',
205 'admin_label' => false,
206 'dependency' => '',
207 'weight' => '',
208 'group' => '' ,
209 'edit_field_class' => ''
210 ),
211 array(
212 'heading' => __('Color of button','auxin-elements' ),
213 'description' => '',
214 'param_name' => 'color_name',
215 'type' => 'aux_visual_select',
216 'value' => 'carmine-pink',
217 'choices' => auxin_get_famous_colors_list(),
218 'holder' => '',
219 'class' => 'color',
220 'admin_label' => false,
221 'dependency' => '',
222 'weight' => '',
223 'group' => __('Appearance', 'auxin-elements'),
224 'edit_field_class' => ''
225 ),
226 array(
227 'heading' => __('Button Link','auxin-elements' ),
228 'description' => '',
229 'param_name' => 'link',
230 'type' => 'textfield',
231 'value' => '',
232 'holder' => '',
233 'class' => 'link',
234 'admin_label' => false,
235 'dependency' => '',
236 'weight' => '',
237 'group' => '' ,
238 'edit_field_class' => ''
239 ),
240 array(
241 'heading' => __('Open link in','auxin-elements' ),
242 'description' => '',
243 'param_name' => 'target',
244 'type' => 'dropdown',
245 'def_value' => '_self',
246 'value' => array(
247 '_self' => __('Current page' , 'auxin-elements' ),
248 '_blank' => __('New page', 'auxin-elements' )
249 ),
250 'holder' => '',
251 'class' => 'target',
252 'admin_label' => false,
253 'dependency' => '',
254 'weight' => '',
255 'group' => '' ,
256 'edit_field_class' => ''
257 ),
258 array(
259 'heading' => __('Extra class name','auxin-elements'),
260 '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.', 'auxin-elements'),
261 'param_name' => 'extra_classes',
262 'type' => 'textfield',
263 'value' => '',
264 'holder' => '',
265 'class' => 'extra_classes',
266 'admin_label' => false,
267 'dependency' => '',
268 'weight' => '',
269 'group' => '' ,
270 'edit_field_class' => ''
271 )
272 )
273 );
274
275 return $master_array;
276 }
277
278 add_filter( 'auxin_master_array_shortcodes', 'auxin_get_button_master_array', 10, 1 );
279
280
281 function auxin_widget_button_callback( $atts = array(), $shortcode_content = null ){
282
283 // Defining default attributes
284 $default_atts = array(
285 'label' => '',
286 'size' => 'medium',
287 'border' => '',
288 'style' => '',
289 'uppercase' => '1',
290 'dark' => '0',
291 'icon' => '',
292 'icon_align' => 'default',
293 'color_name' => 'carmine-pink',
294 'link' => '',
295 'target' => '_self',
296 'nofollow' => false,
297 'btn_attrs' => '', // data-attr1{val1};data-attr2{val2}
298 'custom_styles' => array(),
299 'extra_classes' => '', // custom css class names for this element
300 'custom_el_id' => '',
301 'base_class' => 'aux-widget-button'
302 );
303
304 $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content );
305 extract( $result['parsed_atts'] );
306
307
308 // --------------------------------------------
309 $btn_css_classes = array( 'aux-button' );
310 $btn_css_classes[] = 'aux-' . $size; // size
311 $btn_css_classes[] = 'aux-' . $color_name; // appearance
312
313 if( $border ){
314 $btn_css_classes[] = 'aux-' . $border; // border form
315 }
316 if( $style ){
317 $btn_css_classes[] = 'aux-' . $style; // appearance
318 }
319 if( auxin_is_true( $uppercase ) ){
320 $btn_css_classes[] = 'aux-uppercase'; // text form
321 }
322 if( auxin_is_true( $dark ) ){
323 $btn_css_classes[] = 'aux-dark-text'; // text color
324 }
325 if( $icon_align !== "default" ){
326 $btn_css_classes[] = 'aux-icon-' . $icon_align; // icon align
327 }
328
329 // add extra attributes to button element if defined
330 $btn_other_attrs = '';
331
332 if( $btn_attrs = trim( $btn_attrs, ';' ) ){
333 preg_match_all('/([\-|\w]+)(?!{})([\w]+)/s', $btn_attrs, $btn_attr_matches );
334
335 if( ! empty( $btn_attr_matches[0] ) && is_array( $btn_attr_matches[0] ) ){
336 foreach( $btn_attr_matches[0] as $i => $attr_name_value ){
337 if( 0 == $i % 2 ){
338 $btn_other_attrs .= sprintf(' %s', $attr_name_value);
339 } else {
340 $btn_other_attrs .= sprintf('="%s"', esc_attr( trim( $attr_name_value ) ) );
341 }
342 }
343 $btn_other_attrs = trim( $btn_other_attrs );
344 }
345 }
346
347 $extra_styles = '';
348
349 if ( isset( $custom_styles ) && ! empty( $custom_styles ) ) {
350
351 foreach( $custom_styles as $property => $value ) {
352 if ( 'custom' === $property ) {
353 $extra_styles .= $value;
354 } else {
355 $extra_styles .= $property . ':' . $value . ';';
356 }
357 }
358
359 $extra_styles = 'style="' . $extra_styles . '"';
360
361 }
362
363 if( ! empty( $extra_classes ) ) {
364 $btn_css_classes[] = $extra_classes;
365 }
366
367 // get escaped class attributes
368 $button_class_attr = auxin_make_html_class_attribute( $btn_css_classes );
369
370 $label = empty( $label ) ? $shortcode_content : $label;
371 $label = empty( $label ) ? __( "Button", 'auxin-elements' ) : $label;
372
373 $btn_content = '<span class="aux-overlay"></span>';
374 $btn_label = '<span class="aux-text">'. auxin_do_cleanup_shortcode( $label ) .'</span>';
375 $btn_icon = $icon ? '<span class="aux-icon '. esc_attr($icon) .'"></span>' : '';
376
377 // if icon is aligned on left
378 if( false !== strpos( $icon_align, 'left') ){
379 $btn_content .= $btn_icon . $btn_label;
380 } else {
381 $btn_content .= $btn_label. $btn_icon;
382 }
383
384 $btn_tag = empty( $link ) ? 'button' : 'a';
385 $btn_rel = auxin_is_true ( $nofollow ) ? ' rel="nofollow"' : '';
386 $btn_href = empty( $link ) ? '' : ' href="'. esc_url( $link ) .'" target="'. esc_attr( $target ) .'" ' . $btn_rel;
387
388 $output = '';
389
390 // widget custom output -----------------------
391
392 $output .= "<$btn_tag $btn_href $btn_other_attrs $button_class_attr $extra_styles>";
393 $output .= $btn_content;
394 $output .= "</$btn_tag>";
395
396 return $output;
397 }