PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.66
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.66
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
userswp / vendor / ayecode / wp-ayecode-ui / includes / components / class-aui-component-button.php

class-aui-component-button.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.66, at vendor/ayecode/wp-ayecode-ui/includes/components/class-aui-component-button.php

153 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 /**
8 * A component class for rendering a bootstrap button.
9 *
10 * @since 1.0.0
11 */
12 class AUI_Component_Button {
13
14 /**
15 * Build the component.
16 *
17 * @param array $args
18 *
19 * @return string The rendered component.
20 */
21 public static function get($args = array()){
22 $defaults = array(
23 'type' => 'a', // a, button, badge
24 'href' => '#',
25 'new_window' => false,
26 'class' => 'btn btn-primary',
27 'id' => '',
28 'title' => '',
29 'value' => '',
30 'content' => '',
31 'icon' => '',
32 'hover_content' => '',
33 'hover_icon' => '',
34 'new_line_after' => true,
35 'no_wrap' => true,
36 'onclick' => '',
37 'style' => '',
38 'extra_attributes' => array(), // an array of extra attributes
39 'icon_extra_attributes' => array() // an array of icon extra attributes
40 );
41
42 /**
43 * Parse incoming $args into an array and merge it with $defaults
44 */
45 $args = wp_parse_args( $args, $defaults );
46 $output = '';
47 if ( ! empty( $args['type'] ) ) {
48 $type = $args['type'] != 'a' ? esc_attr($args['type']) : 'a';
49
50 // open/type
51 if($type=='a'){
52 $new_window = !empty($args['new_window']) ? ' target="_blank" ' : '';
53 $output .= '<a href="' . $args['href'] . '"'.$new_window;
54 }elseif($type=='badge'){
55 $output .= '<span ';
56 }else{
57 $output .= '<button type="' . $type . '" ';
58 }
59
60 // name
61 if(!empty($args['name'])){
62 $output .= AUI_Component_Helper::name($args['name']);
63 }
64
65 // id
66 if(!empty($args['id'])){
67 $output .= AUI_Component_Helper::id($args['id']);
68 }
69
70 // title
71 if(!empty($args['title'])){
72 $output .= AUI_Component_Helper::title($args['title']);
73 }
74
75 // value
76 if(!empty($args['value'])){
77 $output .= AUI_Component_Helper::value($args['value']);
78 }
79
80 // class
81 $class = !empty($args['class']) ? $args['class'] : '';
82 $output .= AUI_Component_Helper::class_attr($class);
83
84 // data-attributes
85 $output .= AUI_Component_Helper::data_attributes($args);
86
87 // aria-attributes
88 $output .= AUI_Component_Helper::aria_attributes($args);
89
90 // extra attributes
91 if(!empty($args['extra_attributes'])){
92 $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
93 }
94
95 // onclick, we don't escape this
96 if(!empty($args['onclick'])){
97 $output .= ' onclick="'.$args['onclick'].'" ';
98 }
99
100 // style, we don't escape this
101 if(!empty($args['style'])){
102 $output .= ' style="'.$args['style'].'" ';
103 }
104
105 // close opening tag
106 $output .= ' >';
107
108
109 // hover content
110 $hover_content = false;
111 if(!empty($args['hover_content']) || !empty($args['hover_icon'])){
112 $output .= "<span class='hover-content'>".AUI_Component_Helper::icon($args['hover_icon'],$args['hover_content']).$args['hover_content']."</span>";
113 $hover_content = true;
114 }
115
116 // content
117 if($hover_content){$output .= "<span class='hover-content-original'>";}
118 if(!empty($args['content']) || !empty($args['icon'])){
119 $output .= AUI_Component_Helper::icon($args['icon'],$args['content'],$args['icon_extra_attributes']).$args['content'];
120 }
121 if($hover_content){$output .= "</span>";}
122
123
124
125 // close
126 if($type=='a'){
127 $output .= '</a>';
128 }elseif($type=='badge'){
129 $output .= '</span>';
130 }else{
131 $output .= '</button>';
132 }
133
134 // maybe new line after? This adds better spacing between buttons.
135 if(!empty($args['new_line_after'])){
136 $output .= PHP_EOL;
137 }
138
139
140 // wrap
141 if(!$args['no_wrap']){
142 $output = AUI_Component_Input::wrap(array(
143 'content' => $output,
144 ));
145 }
146
147
148 }
149
150 return $output;
151 }
152
153 }