PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.15.2
Shortcodes and extra features for Phlox theme v2.15.2
2.17.21 2.17.20 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 3 years ago accordion-widget.php 3 years ago accordion.php 3 years ago attachment-url.php 3 years ago audio.php 3 years ago before-after.php 3 years ago button.php 3 years ago code.php 3 years ago contact-box.php 3 years ago contact-form.php 3 years ago custom-list.php 3 years ago divider.php 3 years ago dropcap.php 3 years ago facebook.php 3 years ago flickr.php 3 years ago gallery.php 3 years ago gmap.php 3 years ago highlight.php 3 years ago image.php 3 years ago instagram-feed.php 3 years ago latest-posts-slider.php 3 years ago popular-posts-widget.php 3 years ago products-grid.php 2 years ago quote.php 3 years ago recent-posts-grid-carousel.php 2 years ago recent-posts-land-style.php 2 years ago recent-posts-masonry.php 2 years ago recent-posts-tiles-carousel.php 2 years ago recent-posts-tiles.php 2 years ago recent-posts-timeline.php 2 years ago recent-posts-widget.php 3 years ago recent-products.php 2 years ago related-posts.php 8 years ago sample-element.php 3 years ago search.php 3 years ago socials-list.php 3 years ago staff.php 3 years ago tab-widget.php 3 years ago tabs.php 3 years ago testimonial.php 3 years ago text.php 3 years ago touch-slider.php 3 years ago video.php 3 years ago
button.php
403 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-2023 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 'category' => THEME_NAME,
26 'group' => '',
27 'admin_enqueue_js' => '',
28 'admin_enqueue_css' => '',
29 'front_enqueue_js' => '',
30 'front_enqueue_css' => '',
31 'icon' => 'aux-element aux-pb-icons-button',
32 'custom_markup' => '',
33 'js_view' => '',
34 'html_template' => '',
35 'deprecated' => '',
36 'content_element' => '',
37 'as_parent' => '',
38 'as_child' => '',
39 'params' => array(
40 array(
41 'heading' => __('Button label','auxin-elements' ),
42 'description' => __('The label of button.','auxin-elements' ),
43 'param_name' => 'label',
44 'type' => 'textfield',
45 'value' => __('Button', 'auxin-elements'),
46 'holder' => 'textfield',
47 'class' => 'label',
48 'admin_label' => false,
49 'dependency' => '',
50 'weight' => '',
51 'group' => '' ,
52 'edit_field_class' => ''
53 ),
54 array(
55 'heading' => __('Button size','auxin-elements' ),
56 'description' => '',
57 'param_name' => 'size',
58 'type' => 'dropdown',
59 'def_value' => 'medium',
60 'value' => array(
61 'exlarge' => __('Exlarge', 'auxin-elements' ),
62 'large' => __('Large' , 'auxin-elements' ),
63 'medium' => __('Medium' , 'auxin-elements' ),
64 'small' => __('Small' , 'auxin-elements' ),
65 'tiny' => __('Tiny' , 'auxin-elements' )
66 ),
67 'holder' => '',
68 'class' => 'round',
69 'admin_label' => true,
70 'dependency' => '',
71 'weight' => '',
72 'group' => '' ,
73 'edit_field_class' => ''
74 ),
75 array(
76 'heading' => __('Button shape','auxin-elements' ),
77 'description' => '',
78 'param_name' => 'border',
79 'type' => 'aux_visual_select',
80 'value' => '',
81 'class' => 'border',
82 'admin_label' => false,
83 'dependency' => '',
84 'weight' => '',
85 'group' => __('Appearance', 'auxin-elements'),
86 'edit_field_class' => '',
87 'choices' => array(
88 '' => array(
89 'label' => __('Box', 'auxin-elements' ),
90 'image' => AUXIN_URL . 'images/visual-select/button-normal.svg'
91 ),
92 'round' => array(
93 'label' => __('Round', 'auxin-elements' ),
94 'image' => AUXIN_URL . 'images/visual-select/button-curved.svg'
95 ),
96 'curve' => array(
97 'label' => __('Curve', 'auxin-elements' ),
98 'image' => AUXIN_URL . 'images/visual-select/button-rounded.svg'
99 )
100 )
101 ),
102 array(
103 'heading' => __('Button style','auxin-elements' ),
104 'description' => '',
105 'param_name' => 'style',
106 'type' => 'aux_visual_select',
107 'value' => '',
108 'class' => 'style',
109 'admin_label' => false,
110 'dependency' => '',
111 'weight' => '',
112 'group' => __('Appearance', 'auxin-elements'),
113 'edit_field_class' => '',
114 'choices' => array(
115 '' => array(
116 'label' => __('Normal', 'auxin-elements' ),
117 'image' => AUXIN_URL . 'images/visual-select/button-normal.svg'
118 ),
119 '3d' => array(
120 'label' => __('3D', 'auxin-elements' ),
121 'image' => AUXIN_URL . 'images/visual-select/button-3d.svg'
122 ),
123 'outline' => array(
124 'label' => __('Outline', 'auxin-elements' ),
125 'image' => AUXIN_URL . 'images/visual-select/button-outline.svg'
126 )
127 )
128 ),
129 array(
130 'heading' => __('Uppercase label','auxin-elements' ),
131 'description' => '',
132 'param_name' => 'uppercase',
133 'type' => 'aux_switch',
134 'value' => '1',
135 'class' => 'uppercase',
136 'admin_label' => false,
137 'dependency' => '',
138 'weight' => '',
139 'group' => '' ,
140 'edit_field_class' => ''
141 ),
142 array(
143 'heading' => __('Darken the label','auxin-elements' ),
144 'description' => __('Darken label of button.','auxin-elements' ),
145 'param_name' => 'dark',
146 'type' => 'aux_switch',
147 'value' => '0',
148 'class' => 'dark',
149 'admin_label' => false,
150 'dependency' => '',
151 'weight' => '',
152 'group' => '' ,
153 'edit_field_class' => ''
154 ),
155 array(
156 'heading' => __('Icon for button','auxin-elements' ),
157 'description' => '',
158 'param_name' => 'icon',
159 'type' => 'aux_iconpicker',
160 'value' => '',
161 'class' => 'icon-name',
162 'admin_label' => false,
163 'dependency' => '',
164 'weight' => '',
165 'group' => '' ,
166 'edit_field_class' => ''
167 ),
168 array(
169 'heading' => __('Icon alignment','auxin-elements' ),
170 'description' => '',
171 'param_name' => 'icon_align',
172 'type' => 'aux_visual_select',
173 'def_value' => 'default',
174 'choices' => array(
175 // default template
176 'default' => array(
177 'label' => __('Default' , 'auxin-elements'),
178 'image' => AUXELS_ADMIN_URL . '/assets/images/button.png'
179 ),
180 'left' => array(
181 'label' => __('Left' , 'auxin-elements'),
182 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button2.webm webm'
183 ),
184 'right' => array(
185 'label' => __('Right' , 'auxin-elements'),
186 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button1.webm webm'
187 ),
188 'over' => array(
189 'label' => __('Over', 'auxin-elements'),
190 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button5.webm webm'
191 ),
192 'left-animate' => array(
193 'label' => __('Animate from Left', 'auxin-elements'),
194 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button4.webm webm'
195 ),
196 'right-animate' => array(
197 'label' => __('Animate from Righ', 'auxin-elements'),
198 'video_src' => AUXELS_ADMIN_URL . '/assets/images/preview/Button3.webm webm'
199 ),
200 ),
201 'holder' => '',
202 'class' => 'icon-align',
203 'admin_label' => false,
204 'dependency' => '',
205 'weight' => '',
206 'group' => '' ,
207 'edit_field_class' => ''
208 ),
209 array(
210 'heading' => __('Color of button','auxin-elements' ),
211 'description' => '',
212 'param_name' => 'color_name',
213 'type' => 'aux_visual_select',
214 'value' => 'carmine-pink',
215 'choices' => auxin_get_famous_colors_list(),
216 'holder' => '',
217 'class' => 'color',
218 'admin_label' => false,
219 'dependency' => '',
220 'weight' => '',
221 'group' => __('Appearance', 'auxin-elements'),
222 'edit_field_class' => ''
223 ),
224 array(
225 'heading' => __('Button Link','auxin-elements' ),
226 'description' => '',
227 'param_name' => 'link',
228 'type' => 'textfield',
229 'value' => '',
230 'holder' => '',
231 'class' => 'link',
232 'admin_label' => false,
233 'dependency' => '',
234 'weight' => '',
235 'group' => '' ,
236 'edit_field_class' => ''
237 ),
238 array(
239 'heading' => __('Open link in','auxin-elements' ),
240 'description' => '',
241 'param_name' => 'target',
242 'type' => 'dropdown',
243 'def_value' => '_self',
244 'value' => array(
245 '_self' => __('Current page' , 'auxin-elements' ),
246 '_blank' => __('New page', 'auxin-elements' )
247 ),
248 'holder' => '',
249 'class' => 'target',
250 'admin_label' => false,
251 'dependency' => '',
252 'weight' => '',
253 'group' => '' ,
254 'edit_field_class' => ''
255 ),
256 array(
257 'heading' => __('Extra class name','auxin-elements'),
258 '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'),
259 'param_name' => 'extra_classes',
260 'type' => 'textfield',
261 'value' => '',
262 'holder' => '',
263 'class' => 'extra_classes',
264 'admin_label' => false,
265 'dependency' => '',
266 'weight' => '',
267 'group' => '' ,
268 'edit_field_class' => ''
269 )
270 )
271 );
272
273 return $master_array;
274 }
275
276 add_filter( 'auxin_master_array_shortcodes', 'auxin_get_button_master_array', 10, 1 );
277
278
279 function auxin_widget_button_callback( $atts = array(), $shortcode_content = null ){
280
281 // Defining default attributes
282 $default_atts = array(
283 'label' => '',
284 'size' => 'medium',
285 'border' => '',
286 'style' => '',
287 'uppercase' => '1',
288 'dark' => '0',
289 'icon' => '',
290 'icon_align' => 'default',
291 'color_name' => 'carmine-pink',
292 'link' => '',
293 'target' => '_self',
294 'nofollow' => false,
295 'btn_attrs' => '', // data-attr1{val1};data-attr2{val2}
296 'custom_styles' => array(),
297 'extra_classes' => '', // custom css class names for this element
298 'custom_el_id' => '',
299 'base_class' => 'aux-widget-button',
300 'open_video_in_lightbox' => false,
301 );
302
303 $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content );
304 extract( $result['parsed_atts'] );
305
306
307 // --------------------------------------------
308 $btn_css_classes = array( 'aux-button' );
309 $btn_css_classes[] = 'aux-' . $size; // size
310 $btn_css_classes[] = 'aux-' . $color_name; // appearance
311
312 if( $border ){
313 $btn_css_classes[] = 'aux-' . $border; // border form
314 }
315 if( $style ){
316 $btn_css_classes[] = 'aux-' . $style; // appearance
317 }
318 if( auxin_is_true( $uppercase ) ){
319 $btn_css_classes[] = 'aux-uppercase'; // text form
320 }
321 if( auxin_is_true( $dark ) ){
322 $btn_css_classes[] = 'aux-dark-text'; // text color
323 }
324 if( $icon_align !== "default" ){
325 $btn_css_classes[] = 'aux-icon-' . $icon_align; // icon align
326 }
327
328 // add extra attributes to button element if defined
329 $btn_other_attrs = '';
330
331 if( $btn_attrs = trim( $btn_attrs, ';' ) ){
332 preg_match_all('/([\-|\w]+)(?!{})([\w]+)/s', $btn_attrs, $btn_attr_matches );
333
334 if( ! empty( $btn_attr_matches[0] ) && is_array( $btn_attr_matches[0] ) ){
335 foreach( $btn_attr_matches[0] as $i => $attr_name_value ){
336 if( 0 == $i % 2 ){
337 $btn_other_attrs .= sprintf(' %s', $attr_name_value);
338 } else {
339 $btn_other_attrs .= sprintf('="%s"', esc_attr( trim( $attr_name_value ) ) );
340 }
341 }
342 $btn_other_attrs = trim( $btn_other_attrs );
343 }
344 }
345
346 $extra_styles = '';
347
348 if ( isset( $custom_styles ) && ! empty( $custom_styles ) ) {
349
350 foreach( $custom_styles as $property => $value ) {
351 if ( 'custom' === $property ) {
352 $extra_styles .= $value;
353 } else {
354 $extra_styles .= $property . ':' . $value . ';';
355 }
356 }
357
358 $extra_styles = 'style="' . $extra_styles . '"';
359
360 }
361
362 if( ! empty( $extra_classes ) ) {
363 $btn_css_classes[] = $extra_classes;
364 }
365
366 if ( auxin_is_true( $open_video_in_lightbox ) ) {
367 $btn_css_classes[] = 'aux-open-video';
368 $btn_other_attrs .= ' data-type="video"';
369 }
370
371 // get escaped class attributes
372 $button_class_attr = auxin_make_html_class_attribute( $btn_css_classes );
373
374 $label = empty( $label ) ? $shortcode_content : $label;
375 $label = empty( $label ) ? __( "Button", 'auxin-elements' ) : $label;
376
377 $btn_content = '<span class="aux-overlay"></span>';
378 $btn_label = '<span class="aux-text">'. auxin_do_cleanup_shortcode( $label ) .'</span>';
379 $btn_icon = $icon ? '<span class="aux-icon '. esc_attr($icon) .'"></span>' : '';
380
381 // if icon is aligned on left
382 if( false !== strpos( $icon_align, 'left') ){
383 $btn_content .= $btn_icon . $btn_label;
384 } else {
385 $btn_content .= $btn_label. $btn_icon;
386 }
387
388 $btn_tag = empty( $link ) ? 'button' : 'a';
389 $btn_rel = auxin_is_true ( $nofollow ) ? ' rel="nofollow"' : '';
390 $btn_href = empty( $link ) ? '' : ' href="'. $link .'" target="'. esc_attr( $target ) .'" ' . $btn_rel;
391
392 $output = '';
393
394 // widget custom output -----------------------
395 $output .= "<$btn_tag $btn_href $btn_other_attrs $button_class_attr $extra_styles>";
396 $output .= $btn_content;
397 $output .= "</$btn_tag>";
398
399 if ( auxin_is_true( $open_video_in_lightbox ) ) {
400 $output = '<span class="aux-lightbox-video ">' . $output . '</span>';
401 }
402 return $output;
403 }