| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: AyeCode UI |
| 4 |
Plugin URI: https://ayecode.io/ |
| 5 |
Description: This is an example plugin to test AyeCode UI Quickly. |
| 6 |
Version: 0.2.54 |
| 7 |
Author: AyeCode Ltd |
| 8 |
Author URI: https://userswp.io |
| 9 |
License: GPL-2.0+ |
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 11 |
Text Domain: ayecode-ui |
| 12 |
Domain Path: /languages |
| 13 |
Requires at least: 6.0 |
| 14 |
Tested up to: 7.0 |
| 15 |
*/ |
| 16 |
|
| 17 |
// If this file is called directly, abort. |
| 18 |
if ( ! defined( 'WPINC' ) ) { |
| 19 |
die; |
| 20 |
} |
| 21 |
|
| 22 |
class AyeCode_UI_Plugin { |
| 23 |
|
| 24 |
/** |
| 25 |
* AUI Plugin constructor. |
| 26 |
* |
| 27 |
* @since 1.0.0 |
| 28 |
*/ |
| 29 |
public function __construct() { |
| 30 |
|
| 31 |
// load AUI |
| 32 |
require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' ); |
| 33 |
|
| 34 |
// Maybe show example page |
| 35 |
add_action( 'template_redirect', array( $this,'maybe_show_examples' ) ); |
| 36 |
} |
| 37 |
|
| 38 |
public function maybe_show_examples(){ |
| 39 |
if ( current_user_can( 'manage_options' ) && isset( $_REQUEST['preview-aui'] ) ) { |
| 40 |
echo "<head>"; |
| 41 |
wp_head(); |
| 42 |
echo "</head>"; |
| 43 |
echo "<body class='bsui'>"; |
| 44 |
echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 45 |
wp_footer(); |
| 46 |
echo "</body>"; |
| 47 |
exit; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
public function get_examples(){ |
| 52 |
$output = ''; |
| 53 |
|
| 54 |
// open form |
| 55 |
$output .= "<form class='p-5 m-5 border rounded bg-white'>"; |
| 56 |
|
| 57 |
$output .= aui()->input( |
| 58 |
array( |
| 59 |
'type' => 'datepicker', |
| 60 |
'id' => 'date_example_sm', |
| 61 |
'size' => 'sm', |
| 62 |
'name' => 'date_example_sm', |
| 63 |
'label' => 'Date Input Label (small)', |
| 64 |
'help_text' => 'help text', |
| 65 |
'label_type' => 'top', |
| 66 |
'placeholder' => 'YYYY-MM-DD 00:00', |
| 67 |
'value' => '', |
| 68 |
'extra_attributes' => array( |
| 69 |
'data-enable-time' => 'true', |
| 70 |
'data-time_24hr' => 'true', |
| 71 |
'data-allow-input' => 'true', |
| 72 |
), |
| 73 |
) |
| 74 |
); |
| 75 |
|
| 76 |
$output .= aui()->input( |
| 77 |
array( |
| 78 |
'type' => 'datepicker', |
| 79 |
'id' => 'date_example', |
| 80 |
//'size' => 'smx', |
| 81 |
'name' => 'date_example', |
| 82 |
'label' => 'Date Input Label', |
| 83 |
'help_text' => 'help text', |
| 84 |
'label_type' => 'top', |
| 85 |
'placeholder' => 'YYYY-MM-DD 00:00', |
| 86 |
'value' => '', |
| 87 |
'extra_attributes' => array( |
| 88 |
'data-enable-time' => 'true', |
| 89 |
'data-time_24hr' => 'true', |
| 90 |
'data-allow-input' => 'true', |
| 91 |
), |
| 92 |
) |
| 93 |
); |
| 94 |
|
| 95 |
$output .= aui()->input( |
| 96 |
array( |
| 97 |
'type' => 'datepicker', |
| 98 |
'id' => 'date_example_lg', |
| 99 |
'size' => 'lg', |
| 100 |
'name' => 'date_example_lg', |
| 101 |
'label' => 'Date Input Label (large)', |
| 102 |
'help_text' => 'help text', |
| 103 |
'label_type' => 'top', |
| 104 |
'placeholder' => 'YYYY-MM-DD 00:00', |
| 105 |
'value' => '', |
| 106 |
'extra_attributes' => array( |
| 107 |
'data-enable-time' => 'true', |
| 108 |
'data-time_24hr' => 'true', |
| 109 |
//'data-allow-input' => 'true', |
| 110 |
), |
| 111 |
) |
| 112 |
); |
| 113 |
|
| 114 |
// input example |
| 115 |
$output .= aui()->input( |
| 116 |
array( |
| 117 |
'type' => 'text', |
| 118 |
'id' => 'text-example', |
| 119 |
'size' => 'sm', |
| 120 |
//'clear_icon' => true, |
| 121 |
'name' => 'text-example', |
| 122 |
'placeholder' => 'text placeholder', |
| 123 |
'title' => 'Text input example', |
| 124 |
'value' => '', |
| 125 |
'required' => false, |
| 126 |
'help_text' => 'help text', |
| 127 |
'label' => 'Text input example label', |
| 128 |
'label_type' => 'top' |
| 129 |
) |
| 130 |
); |
| 131 |
|
| 132 |
$output .= aui()->input( |
| 133 |
array( |
| 134 |
'type' => 'search', |
| 135 |
'id' => 'text-example', |
| 136 |
'size' => 'sm', |
| 137 |
//'clear_icon' => true, |
| 138 |
'name' => 'text-example', |
| 139 |
'placeholder' => 'text placeholder', |
| 140 |
'title' => 'Text input example', |
| 141 |
'value' => '', |
| 142 |
'required' => false, |
| 143 |
'help_text' => 'help text', |
| 144 |
'label' => 'Text input example label', |
| 145 |
'label_type' => 'top' |
| 146 |
) |
| 147 |
); |
| 148 |
|
| 149 |
// input example |
| 150 |
$output .= aui()->input( |
| 151 |
array( |
| 152 |
'type' => 'url', |
| 153 |
'id' => 'text-example2', |
| 154 |
'name' => 'text-example', |
| 155 |
'placeholder' => 'url placeholder', |
| 156 |
'title' => 'Text input example', |
| 157 |
'value' => '', |
| 158 |
'required' => false, |
| 159 |
'help_text' => 'help text', |
| 160 |
'label' => 'Text input example label' |
| 161 |
) |
| 162 |
); |
| 163 |
|
| 164 |
// checkbox example |
| 165 |
$output .= aui()->input( |
| 166 |
array( |
| 167 |
'type' => 'checkbox', |
| 168 |
'id' => 'checkbox-example', |
| 169 |
'name' => 'checkbox-example', |
| 170 |
'placeholder' => 'checkbox-example', |
| 171 |
'title' => 'Checkbox example', |
| 172 |
'value' => '1', |
| 173 |
'checked' => true, |
| 174 |
'required' => false, |
| 175 |
'help_text' => 'help text', |
| 176 |
'label' => 'Checkbox checked' |
| 177 |
) |
| 178 |
); |
| 179 |
|
| 180 |
// checkbox example |
| 181 |
$output .= aui()->input( |
| 182 |
array( |
| 183 |
'type' => 'checkbox', |
| 184 |
'id' => 'checkbox-example2', |
| 185 |
'name' => 'checkbox-example2', |
| 186 |
'placeholder' => 'checkbox-example', |
| 187 |
'title' => 'Checkbox example', |
| 188 |
'value' => '1', |
| 189 |
'checked' => false, |
| 190 |
'required' => false, |
| 191 |
'help_text' => 'help text', |
| 192 |
'label' => 'Checkbox un-checked' |
| 193 |
) |
| 194 |
); |
| 195 |
|
| 196 |
// switch example |
| 197 |
$output .= aui()->input( |
| 198 |
array( |
| 199 |
'type' => 'checkbox', |
| 200 |
'id' => 'switch-example', |
| 201 |
'name' => 'switch-example', |
| 202 |
'placeholder' => 'checkbox-example', |
| 203 |
'title' => 'Switch example', |
| 204 |
'value' => '1', |
| 205 |
'checked' => true, |
| 206 |
'switch' => true, |
| 207 |
'required' => false, |
| 208 |
'help_text' => 'help text', |
| 209 |
'label' => 'Switch on' |
| 210 |
) |
| 211 |
); |
| 212 |
|
| 213 |
// switch example |
| 214 |
$output .= aui()->input( |
| 215 |
array( |
| 216 |
'type' => 'checkbox', |
| 217 |
'id' => 'switch-example2', |
| 218 |
'name' => 'switch-example2', |
| 219 |
'placeholder' => 'checkbox-example', |
| 220 |
'title' => 'Switch example', |
| 221 |
'value' => '1', |
| 222 |
'checked' => false, |
| 223 |
'switch' => true, |
| 224 |
'required' => false, |
| 225 |
'help_text' => 'help text', |
| 226 |
'label' => 'Switch off' |
| 227 |
) |
| 228 |
); |
| 229 |
|
| 230 |
// close form |
| 231 |
$output .= "</form>"; |
| 232 |
|
| 233 |
return $output; |
| 234 |
} |
| 235 |
} |
| 236 |
|
| 237 |
new AyeCode_UI_Plugin(); |