-
Notifications
You must be signed in to change notification settings - Fork 4
/
example-plugin.php
237 lines (216 loc) · 5.68 KB
/
example-plugin.php
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?php
/*
Plugin Name: AyeCode UI
Plugin URI: https://ayecode.io/
Description: This is an example plugin to test AyeCode UI Quickly.
Version: 0.2.30
Author: AyeCode Ltd
Author URI: https://userswp.io
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Text Domain: ayecode-ui
Domain Path: /languages
Requires at least: 4.9
Tested up to: 6.7
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class AyeCode_UI_Plugin {
/**
* AUI Plugin constructor.
*
* @since 1.0.0
*/
public function __construct() {
// load AUI
require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' );
// Maybe show example page
add_action( 'template_redirect', array( $this,'maybe_show_examples' ) );
}
public function maybe_show_examples(){
if ( current_user_can( 'manage_options' ) && isset( $_REQUEST['preview-aui'] ) ) {
echo "<head>";
wp_head();
echo "</head>";
echo "<body class='bsui'>";
echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
wp_footer();
echo "</body>";
exit;
}
}
public function get_examples(){
$output = '';
// open form
$output .= "<form class='p-5 m-5 border rounded bg-white'>";
$output .= aui()->input(
array(
'type' => 'datepicker',
'id' => 'date_example_sm',
'size' => 'sm',
'name' => 'date_example_sm',
'label' => 'Date Input Label (small)',
'help_text' => 'help text',
'label_type' => 'top',
'placeholder' => 'YYYY-MM-DD 00:00',
'value' => '',
'extra_attributes' => array(
'data-enable-time' => 'true',
'data-time_24hr' => 'true',
'data-allow-input' => 'true',
),
)
);
$output .= aui()->input(
array(
'type' => 'datepicker',
'id' => 'date_example',
//'size' => 'smx',
'name' => 'date_example',
'label' => 'Date Input Label',
'help_text' => 'help text',
'label_type' => 'top',
'placeholder' => 'YYYY-MM-DD 00:00',
'value' => '',
'extra_attributes' => array(
'data-enable-time' => 'true',
'data-time_24hr' => 'true',
'data-allow-input' => 'true',
),
)
);
$output .= aui()->input(
array(
'type' => 'datepicker',
'id' => 'date_example_lg',
'size' => 'lg',
'name' => 'date_example_lg',
'label' => 'Date Input Label (large)',
'help_text' => 'help text',
'label_type' => 'top',
'placeholder' => 'YYYY-MM-DD 00:00',
'value' => '',
'extra_attributes' => array(
'data-enable-time' => 'true',
'data-time_24hr' => 'true',
//'data-allow-input' => 'true',
),
)
);
// input example
$output .= aui()->input(
array(
'type' => 'text',
'id' => 'text-example',
'size' => 'sm',
//'clear_icon' => true,
'name' => 'text-example',
'placeholder' => 'text placeholder',
'title' => 'Text input example',
'value' => '',
'required' => false,
'help_text' => 'help text',
'label' => 'Text input example label',
'label_type' => 'top'
)
);
$output .= aui()->input(
array(
'type' => 'search',
'id' => 'text-example',
'size' => 'sm',
//'clear_icon' => true,
'name' => 'text-example',
'placeholder' => 'text placeholder',
'title' => 'Text input example',
'value' => '',
'required' => false,
'help_text' => 'help text',
'label' => 'Text input example label',
'label_type' => 'top'
)
);
// input example
$output .= aui()->input(
array(
'type' => 'url',
'id' => 'text-example2',
'name' => 'text-example',
'placeholder' => 'url placeholder',
'title' => 'Text input example',
'value' => '',
'required' => false,
'help_text' => 'help text',
'label' => 'Text input example label'
)
);
// checkbox example
$output .= aui()->input(
array(
'type' => 'checkbox',
'id' => 'checkbox-example',
'name' => 'checkbox-example',
'placeholder' => 'checkbox-example',
'title' => 'Checkbox example',
'value' => '1',
'checked' => true,
'required' => false,
'help_text' => 'help text',
'label' => 'Checkbox checked'
)
);
// checkbox example
$output .= aui()->input(
array(
'type' => 'checkbox',
'id' => 'checkbox-example2',
'name' => 'checkbox-example2',
'placeholder' => 'checkbox-example',
'title' => 'Checkbox example',
'value' => '1',
'checked' => false,
'required' => false,
'help_text' => 'help text',
'label' => 'Checkbox un-checked'
)
);
// switch example
$output .= aui()->input(
array(
'type' => 'checkbox',
'id' => 'switch-example',
'name' => 'switch-example',
'placeholder' => 'checkbox-example',
'title' => 'Switch example',
'value' => '1',
'checked' => true,
'switch' => true,
'required' => false,
'help_text' => 'help text',
'label' => 'Switch on'
)
);
// switch example
$output .= aui()->input(
array(
'type' => 'checkbox',
'id' => 'switch-example2',
'name' => 'switch-example2',
'placeholder' => 'checkbox-example',
'title' => 'Switch example',
'value' => '1',
'checked' => false,
'switch' => true,
'required' => false,
'help_text' => 'help text',
'label' => 'Switch off'
)
);
// close form
$output .= "</form>";
return $output;
}
}
new AyeCode_UI_Plugin();