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