@@ -6,35 +6,35 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
| 8 | 8 | { |
| 9 | - public static $files = array ( |
|
| 9 | + public static $files = array( |
|
| 10 | 10 | 'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php', |
| 11 | 11 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
| 12 | 12 | '42671a413efb740d7040437ff2a982cd' => __DIR__ . '/..' . '/ayecode/wp-super-duper/sd-functions.php', |
| 13 | 13 | ); |
| 14 | 14 | |
| 15 | - public static $prefixLengthsPsr4 = array ( |
|
| 15 | + public static $prefixLengthsPsr4 = array( |
|
| 16 | 16 | 'M' => |
| 17 | - array ( |
|
| 17 | + array( |
|
| 18 | 18 | 'MaxMind\\Db\\' => 11, |
| 19 | 19 | ), |
| 20 | 20 | 'C' => |
| 21 | - array ( |
|
| 21 | + array( |
|
| 22 | 22 | 'Composer\\Installers\\' => 20, |
| 23 | 23 | ), |
| 24 | 24 | ); |
| 25 | 25 | |
| 26 | - public static $prefixDirsPsr4 = array ( |
|
| 26 | + public static $prefixDirsPsr4 = array( |
|
| 27 | 27 | 'MaxMind\\Db\\' => |
| 28 | - array ( |
|
| 28 | + array( |
|
| 29 | 29 | 0 => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db', |
| 30 | 30 | ), |
| 31 | 31 | 'Composer\\Installers\\' => |
| 32 | - array ( |
|
| 32 | + array( |
|
| 33 | 33 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
| 34 | 34 | ), |
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | - public static $classMap = array ( |
|
| 37 | + public static $classMap = array( |
|
| 38 | 38 | 'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php', |
| 39 | 39 | 'AyeCode_Deactivation_Survey' => __DIR__ . '/..' . '/ayecode/wp-deactivation-survey/wp-deactivation-survey.php', |
| 40 | 40 | 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public static function getInitializer(ClassLoader $loader) |
| 45 | 45 | { |
| 46 | - return \Closure::bind(function () use ($loader) { |
|
| 46 | + return \Closure::bind(function() use ($loader) { |
|
| 47 | 47 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
| 48 | 48 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
| 49 | 49 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |
@@ -6,39 +6,39 @@ |
||
| 6 | 6 | /** |
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if (!defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | -add_action('after_setup_theme', function () { |
|
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 16 | +add_action('after_setup_theme', function() { |
|
| 17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
| 18 | 18 | $this_version = "0.1.72"; |
| 19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | - $ayecode_ui_version = $this_version ; |
|
| 21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 19 | + if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) { |
|
| 20 | + $ayecode_ui_version = $this_version; |
|
| 21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
| 22 | 22 | } |
| 23 | 23 | },0); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
| 27 | 27 | */ |
| 28 | -add_action('after_setup_theme', function () { |
|
| 28 | +add_action('after_setup_theme', function() { |
|
| 29 | 29 | global $ayecode_ui_file_key; |
| 30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
| 31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
| 32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
| 33 | 33 | } |
| 34 | 34 | },1); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Add the function that calls the class. |
| 38 | 38 | */ |
| 39 | -if(!function_exists('aui')){ |
|
| 40 | - function aui(){ |
|
| 41 | - if(!class_exists("AUI",false)){ |
|
| 39 | +if (!function_exists('aui')) { |
|
| 40 | + function aui() { |
|
| 41 | + if (!class_exists("AUI", false)) { |
|
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | return AUI::instance(); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return string The rendered component. |
| 20 | 20 | */ |
| 21 | - public static function input( $args = array() ) { |
|
| 21 | + public static function input($args = array()) { |
|
| 22 | 22 | $defaults = array( |
| 23 | 23 | 'type' => 'text', |
| 24 | 24 | 'name' => '', |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * Parse incoming $args into an array and merge it with $defaults |
| 67 | 67 | */ |
| 68 | - $args = wp_parse_args( $args, $defaults ); |
|
| 68 | + $args = wp_parse_args($args, $defaults); |
|
| 69 | 69 | $output = ''; |
| 70 | - if ( ! empty( $args['type'] ) ) { |
|
| 70 | + if (!empty($args['type'])) { |
|
| 71 | 71 | // hidden label option needs to be empty |
| 72 | 72 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
| 73 | 73 | |
| 74 | - $type = sanitize_html_class( $args['type'] ); |
|
| 74 | + $type = sanitize_html_class($args['type']); |
|
| 75 | 75 | |
| 76 | 76 | $help_text = ''; |
| 77 | 77 | $label = ''; |
@@ -85,17 +85,17 @@ discard block |
||
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | // floating labels need label after |
| 88 | - if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) { |
|
| 88 | + if ($args['label_type'] == 'floating' && $type != 'checkbox') { |
|
| 89 | 89 | $label_after = true; |
| 90 | 90 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // size |
| 94 | 94 | $size = ''; |
| 95 | - if ( $args['size'] == 'lg' || $args['size'] == 'large' ) { |
|
| 95 | + if ($args['size'] == 'lg' || $args['size'] == 'large') { |
|
| 96 | 96 | $size = 'lg'; |
| 97 | 97 | $args['class'] .= ' form-control-lg'; |
| 98 | - }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) { |
|
| 98 | + }elseif ($args['size'] == 'sm' || $args['size'] == 'small') { |
|
| 99 | 99 | $size = 'sm'; |
| 100 | 100 | $args['class'] .= ' form-control-sm'; |
| 101 | 101 | } |
@@ -104,20 +104,20 @@ discard block |
||
| 104 | 104 | $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');'; |
| 105 | 105 | |
| 106 | 106 | // Some special sauce for files |
| 107 | - if ( $type == 'file' ) { |
|
| 107 | + if ($type == 'file') { |
|
| 108 | 108 | $label_after = true; // if type file we need the label after |
| 109 | 109 | $args['class'] .= ' custom-file-input '; |
| 110 | - } elseif ( $type == 'checkbox' ) { |
|
| 110 | + } elseif ($type == 'checkbox') { |
|
| 111 | 111 | $label_after = true; // if type file we need the label after |
| 112 | 112 | $args['class'] .= ' custom-control-input '; |
| 113 | - } elseif ( $type == 'datepicker' || $type == 'timepicker' ) { |
|
| 113 | + } elseif ($type == 'datepicker' || $type == 'timepicker') { |
|
| 114 | 114 | $type = 'text'; |
| 115 | 115 | $args['class'] .= ' bg-initial '; // @todo not sure why we have this? |
| 116 | 116 | |
| 117 | 117 | $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
| 118 | 118 | |
| 119 | 119 | // set a way to clear field if empty |
| 120 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) { |
|
| 120 | + if ($args['input_group_right'] === '' && $args['clear_icon'] !== false) { |
|
| 121 | 121 | $args['input_group_right_inside'] = true; |
| 122 | 122 | $args['clear_icon'] = true; |
| 123 | 123 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | // enqueue the script |
| 126 | 126 | $aui_settings = AyeCode_UI_Settings::instance(); |
| 127 | 127 | $aui_settings->enqueue_flatpickr(); |
| 128 | - } elseif ( $type == 'iconpicker' ) { |
|
| 128 | + } elseif ($type == 'iconpicker') { |
|
| 129 | 129 | $type = 'text'; |
| 130 | 130 | //$args['class'] .= ' aui-flatpickr bg-initial '; |
| 131 | 131 | // $args['class'] .= ' bg-initial '; |
@@ -140,103 +140,103 @@ discard block |
||
| 140 | 140 | $aui_settings->enqueue_iconpicker(); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) { |
|
| 144 | - $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />'; |
|
| 143 | + if ($type == 'checkbox' && !empty($args['name']) && strpos($args['name'], '[') === false) { |
|
| 144 | + $output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />'; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // allow clear icon |
| 148 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] ) { |
|
| 149 | - $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' ); |
|
| 148 | + if ($args['input_group_right'] === '' && $args['clear_icon']) { |
|
| 149 | + $font_size = $size == 'sm' ? '1.3' : ($size == 'lg' ? '1.65' : '1.5'); |
|
| 150 | 150 | $args['input_group_right_inside'] = true; |
| 151 | - $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: '.$font_size.'rem" aria-hidden="true" class="close">×</span></span>'; |
|
| 151 | + $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="close">×</span></span>'; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // open/type |
| 155 | 155 | $output .= '<input type="' . $type . '" '; |
| 156 | 156 | |
| 157 | 157 | // name |
| 158 | - if ( ! empty( $args['name'] ) ) { |
|
| 159 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 158 | + if (!empty($args['name'])) { |
|
| 159 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // id |
| 163 | - if ( ! empty( $args['id'] ) ) { |
|
| 164 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 163 | + if (!empty($args['id'])) { |
|
| 164 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // placeholder |
| 168 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 169 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 168 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
| 169 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // title |
| 173 | - if ( ! empty( $args['title'] ) ) { |
|
| 174 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 173 | + if (!empty($args['title'])) { |
|
| 174 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // value |
| 178 | - if ( ! empty( $args['value'] ) ) { |
|
| 179 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 178 | + if (!empty($args['value'])) { |
|
| 179 | + $output .= AUI_Component_Helper::value($args['value']); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // checked, for radio and checkboxes |
| 183 | - if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) { |
|
| 183 | + if (($type == 'checkbox' || $type == 'radio') && $args['checked']) { |
|
| 184 | 184 | $output .= ' checked '; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | // validation text |
| 188 | - if ( ! empty( $args['validation_text'] ) ) { |
|
| 189 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
| 188 | + if (!empty($args['validation_text'])) { |
|
| 189 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
| 190 | 190 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // validation_pattern |
| 194 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 195 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 194 | + if (!empty($args['validation_pattern'])) { |
|
| 195 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // step (for numbers) |
| 199 | - if ( ! empty( $args['step'] ) ) { |
|
| 199 | + if (!empty($args['step'])) { |
|
| 200 | 200 | $output .= ' step="' . $args['step'] . '" '; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // required |
| 204 | - if ( ! empty( $args['required'] ) ) { |
|
| 204 | + if (!empty($args['required'])) { |
|
| 205 | 205 | $output .= ' required '; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // class |
| 209 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 209 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
| 210 | 210 | $output .= ' class="form-control ' . $class . '" '; |
| 211 | 211 | |
| 212 | 212 | // data-attributes |
| 213 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 213 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
| 214 | 214 | |
| 215 | 215 | // extra attributes |
| 216 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 217 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 216 | + if (!empty($args['extra_attributes'])) { |
|
| 217 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | // close |
| 221 | 221 | $output .= ' >'; |
| 222 | 222 | |
| 223 | 223 | // help text |
| 224 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 225 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 224 | + if (!empty($args['help_text'])) { |
|
| 225 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // label |
| 229 | - if ( ! empty( $args['label'] ) ) { |
|
| 229 | + if (!empty($args['label'])) { |
|
| 230 | 230 | $label_base_class = ''; |
| 231 | - if ( $type == 'file' ) { |
|
| 231 | + if ($type == 'file') { |
|
| 232 | 232 | $label_base_class = ' custom-file-label'; |
| 233 | - } elseif ( $type == 'checkbox' ) { |
|
| 234 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
| 235 | - $label_args['title'] = wp_kses_post( $args['help_text'] ); |
|
| 233 | + } elseif ($type == 'checkbox') { |
|
| 234 | + if (!empty($args['label_force_left'])) { |
|
| 235 | + $label_args['title'] = wp_kses_post($args['help_text']); |
|
| 236 | 236 | $help_text = ''; |
| 237 | 237 | //$label_args['class'] .= ' d-inline '; |
| 238 | 238 | $args['wrap_class'] .= ' align-items-center '; |
| 239 | - }else{ |
|
| 239 | + } else { |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | |
@@ -244,45 +244,45 @@ discard block |
||
| 244 | 244 | } |
| 245 | 245 | $label_args['class'] .= $label_base_class; |
| 246 | 246 | $temp_label_args = $label_args; |
| 247 | - if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";} |
|
| 248 | - $label = self::label( $temp_label_args, $type ); |
|
| 247 | + if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; } |
|
| 248 | + $label = self::label($temp_label_args, $type); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | |
| 252 | 252 | |
| 253 | 253 | |
| 254 | 254 | // set help text in the correct position |
| 255 | - if ( $label_after ) { |
|
| 255 | + if ($label_after) { |
|
| 256 | 256 | $output .= $label . $help_text; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // some input types need a separate wrap |
| 260 | - if ( $type == 'file' ) { |
|
| 261 | - $output = self::wrap( array( |
|
| 260 | + if ($type == 'file') { |
|
| 261 | + $output = self::wrap(array( |
|
| 262 | 262 | 'content' => $output, |
| 263 | 263 | 'class' => 'form-group custom-file' |
| 264 | - ) ); |
|
| 265 | - } elseif ( $type == 'checkbox' ) { |
|
| 264 | + )); |
|
| 265 | + } elseif ($type == 'checkbox') { |
|
| 266 | 266 | |
| 267 | 267 | $label_args['title'] = $args['label']; |
| 268 | - $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ); |
|
| 269 | - $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
| 270 | - $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : ''; |
|
| 271 | - $wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox'; |
|
| 272 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
| 268 | + $label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label'); |
|
| 269 | + $label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
| 270 | + $switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : ''; |
|
| 271 | + $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox'; |
|
| 272 | + if (!empty($args['label_force_left'])) { |
|
| 273 | 273 | $wrap_class .= ' d-flex align-content-center'; |
| 274 | - $label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) ); |
|
| 274 | + $label = str_replace("custom-control-label", "", self::label($label_args, 'cb')); |
|
| 275 | 275 | } |
| 276 | - $output = self::wrap( array( |
|
| 276 | + $output = self::wrap(array( |
|
| 277 | 277 | 'content' => $output, |
| 278 | 278 | 'class' => 'custom-control ' . $wrap_class |
| 279 | - ) ); |
|
| 279 | + )); |
|
| 280 | 280 | |
| 281 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 282 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 281 | + if ($args['label_type'] == 'horizontal') { |
|
| 282 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
| 283 | 283 | $output = $label . '<div class="' . $input_col . '">' . $output . '</div>'; |
| 284 | 284 | } |
| 285 | - } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) { |
|
| 285 | + } elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) { |
|
| 286 | 286 | |
| 287 | 287 | |
| 288 | 288 | // allow password field to toggle view |
@@ -296,65 +296,65 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | // input group wraps |
| 299 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 300 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 299 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
| 300 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
| 301 | 301 | $group_size = $size == 'lg' ? ' input-group-lg' : ''; |
| 302 | 302 | $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size; |
| 303 | 303 | |
| 304 | - if ( $args['input_group_left'] ) { |
|
| 305 | - $output = self::wrap( array( |
|
| 304 | + if ($args['input_group_left']) { |
|
| 305 | + $output = self::wrap(array( |
|
| 306 | 306 | 'content' => $output, |
| 307 | 307 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
| 308 | 308 | 'input_group_left' => $args['input_group_left'], |
| 309 | 309 | 'input_group_left_inside' => $args['input_group_left_inside'] |
| 310 | - ) ); |
|
| 310 | + )); |
|
| 311 | 311 | } |
| 312 | - if ( $args['input_group_right'] ) { |
|
| 313 | - $output = self::wrap( array( |
|
| 312 | + if ($args['input_group_right']) { |
|
| 313 | + $output = self::wrap(array( |
|
| 314 | 314 | 'content' => $output, |
| 315 | 315 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
| 316 | 316 | 'input_group_right' => $args['input_group_right'], |
| 317 | 317 | 'input_group_right_inside' => $args['input_group_right_inside'] |
| 318 | - ) ); |
|
| 318 | + )); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if ( ! $label_after ) { |
|
| 323 | + if (!$label_after) { |
|
| 324 | 324 | $output .= $help_text; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | |
| 328 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 329 | - $output = self::wrap( array( |
|
| 328 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
| 329 | + $output = self::wrap(array( |
|
| 330 | 330 | 'content' => $output, |
| 331 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 332 | - ) ); |
|
| 331 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
| 332 | + )); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ( ! $label_after ) { |
|
| 335 | + if (!$label_after) { |
|
| 336 | 336 | $output = $label . $output; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // wrap |
| 340 | - if ( ! $args['no_wrap'] ) { |
|
| 340 | + if (!$args['no_wrap']) { |
|
| 341 | 341 | $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
| 342 | 342 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
| 343 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 344 | - $output = self::wrap( array( |
|
| 343 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 344 | + $output = self::wrap(array( |
|
| 345 | 345 | 'content' => $output, |
| 346 | 346 | 'class' => $wrap_class, |
| 347 | 347 | 'element_require' => $args['element_require'], |
| 348 | 348 | 'argument_id' => $args['id'], |
| 349 | 349 | 'wrap_attributes' => $args['wrap_attributes'], |
| 350 | - ) ); |
|
| 350 | + )); |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | return $output; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - public static function label( $args = array(), $type = '' ) { |
|
| 357 | + public static function label($args = array(), $type = '') { |
|
| 358 | 358 | //<label for="exampleInputEmail1">Email address</label> |
| 359 | 359 | $defaults = array( |
| 360 | 360 | 'title' => 'div', |
@@ -367,33 +367,33 @@ discard block |
||
| 367 | 367 | /** |
| 368 | 368 | * Parse incoming $args into an array and merge it with $defaults |
| 369 | 369 | */ |
| 370 | - $args = wp_parse_args( $args, $defaults ); |
|
| 370 | + $args = wp_parse_args($args, $defaults); |
|
| 371 | 371 | $output = ''; |
| 372 | 372 | |
| 373 | - if ( $args['title'] ) { |
|
| 373 | + if ($args['title']) { |
|
| 374 | 374 | |
| 375 | 375 | // maybe hide labels //@todo set a global option for visibility class |
| 376 | - if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) { |
|
| 376 | + if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) { |
|
| 377 | 377 | $class = $args['class']; |
| 378 | 378 | } else { |
| 379 | 379 | $class = 'sr-only ' . $args['class']; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | // maybe horizontal |
| 383 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 384 | - $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label'; |
|
| 383 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
| 384 | + $class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label'; |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // open |
| 388 | 388 | $output .= '<label '; |
| 389 | 389 | |
| 390 | 390 | // for |
| 391 | - if ( ! empty( $args['for'] ) ) { |
|
| 392 | - $output .= ' for="' . esc_attr( $args['for'] ) . '" '; |
|
| 391 | + if (!empty($args['for'])) { |
|
| 392 | + $output .= ' for="' . esc_attr($args['for']) . '" '; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | // class |
| 396 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
| 396 | + $class = $class ? AUI_Component_Helper::esc_classes($class) : ''; |
|
| 397 | 397 | $output .= ' class="' . $class . '" '; |
| 398 | 398 | |
| 399 | 399 | // close |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | |
| 402 | 402 | |
| 403 | 403 | // title, don't escape fully as can contain html |
| 404 | - if ( ! empty( $args['title'] ) ) { |
|
| 405 | - $output .= wp_kses_post( $args['title'] ); |
|
| 404 | + if (!empty($args['title'])) { |
|
| 405 | + $output .= wp_kses_post($args['title']); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // close wrap |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * |
| 423 | 423 | * @return string |
| 424 | 424 | */ |
| 425 | - public static function wrap( $args = array() ) { |
|
| 425 | + public static function wrap($args = array()) { |
|
| 426 | 426 | $defaults = array( |
| 427 | 427 | 'type' => 'div', |
| 428 | 428 | 'class' => 'form-group', |
@@ -439,31 +439,31 @@ discard block |
||
| 439 | 439 | /** |
| 440 | 440 | * Parse incoming $args into an array and merge it with $defaults |
| 441 | 441 | */ |
| 442 | - $args = wp_parse_args( $args, $defaults ); |
|
| 442 | + $args = wp_parse_args($args, $defaults); |
|
| 443 | 443 | $output = ''; |
| 444 | - if ( $args['type'] ) { |
|
| 444 | + if ($args['type']) { |
|
| 445 | 445 | |
| 446 | 446 | // open |
| 447 | - $output .= '<' . sanitize_html_class( $args['type'] ); |
|
| 447 | + $output .= '<' . sanitize_html_class($args['type']); |
|
| 448 | 448 | |
| 449 | 449 | // element require |
| 450 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 451 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 450 | + if (!empty($args['element_require'])) { |
|
| 451 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
| 452 | 452 | $args['class'] .= " aui-conditional-field"; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | // argument_id |
| 456 | - if ( ! empty( $args['argument_id'] ) ) { |
|
| 457 | - $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"'; |
|
| 456 | + if (!empty($args['argument_id'])) { |
|
| 457 | + $output .= ' data-argument="' . esc_attr($args['argument_id']) . '"'; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | // class |
| 461 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 461 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
| 462 | 462 | $output .= ' class="' . $class . '" '; |
| 463 | 463 | |
| 464 | 464 | // Attributes |
| 465 | - if ( ! empty( $args['wrap_attributes'] ) ) { |
|
| 466 | - $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] ); |
|
| 465 | + if (!empty($args['wrap_attributes'])) { |
|
| 466 | + $output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // close wrap |
@@ -471,9 +471,9 @@ discard block |
||
| 471 | 471 | |
| 472 | 472 | |
| 473 | 473 | // Input group left |
| 474 | - if ( ! empty( $args['input_group_left'] ) ) { |
|
| 475 | - $position_class = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 476 | - $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
| 474 | + if (!empty($args['input_group_left'])) { |
|
| 475 | + $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
| 476 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
| 477 | 477 | $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
| 478 | 478 | } |
| 479 | 479 | |
@@ -481,15 +481,15 @@ discard block |
||
| 481 | 481 | $output .= $args['content']; |
| 482 | 482 | |
| 483 | 483 | // Input group right |
| 484 | - if ( ! empty( $args['input_group_right'] ) ) { |
|
| 485 | - $position_class = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 486 | - $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
| 484 | + if (!empty($args['input_group_right'])) { |
|
| 485 | + $position_class = !empty($args['input_group_right_inside']) ? 'position-absolute h-100' : ''; |
|
| 486 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
| 487 | 487 | $output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
| 491 | 491 | // close wrap |
| 492 | - $output .= '</' . sanitize_html_class( $args['type'] ) . '>'; |
|
| 492 | + $output .= '</' . sanitize_html_class($args['type']) . '>'; |
|
| 493 | 493 | |
| 494 | 494 | |
| 495 | 495 | } else { |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * |
| 507 | 507 | * @return string The rendered component. |
| 508 | 508 | */ |
| 509 | - public static function textarea( $args = array() ) { |
|
| 509 | + public static function textarea($args = array()) { |
|
| 510 | 510 | $defaults = array( |
| 511 | 511 | 'name' => '', |
| 512 | 512 | 'class' => '', |
@@ -543,28 +543,28 @@ discard block |
||
| 543 | 543 | /** |
| 544 | 544 | * Parse incoming $args into an array and merge it with $defaults |
| 545 | 545 | */ |
| 546 | - $args = wp_parse_args( $args, $defaults ); |
|
| 546 | + $args = wp_parse_args($args, $defaults); |
|
| 547 | 547 | $output = ''; |
| 548 | 548 | |
| 549 | 549 | // hidden label option needs to be empty |
| 550 | 550 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
| 551 | 551 | |
| 552 | 552 | // floating labels don't work with wysiwyg so set it as top |
| 553 | - if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) { |
|
| 553 | + if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) { |
|
| 554 | 554 | $args['label_type'] = 'top'; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | $label_after = $args['label_after']; |
| 558 | 558 | |
| 559 | 559 | // floating labels need label after |
| 560 | - if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) { |
|
| 560 | + if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) { |
|
| 561 | 561 | $label_after = true; |
| 562 | 562 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | // label |
| 566 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 567 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 566 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
| 567 | + } elseif (!empty($args['label']) && !$label_after) { |
|
| 568 | 568 | $label_args = array( |
| 569 | 569 | 'title' => $args['label'], |
| 570 | 570 | 'for' => $args['id'], |
@@ -572,34 +572,34 @@ discard block |
||
| 572 | 572 | 'label_type' => $args['label_type'], |
| 573 | 573 | 'label_col' => $args['label_col'] |
| 574 | 574 | ); |
| 575 | - $output .= self::label( $label_args ); |
|
| 575 | + $output .= self::label($label_args); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | // maybe horizontal label |
| 579 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 580 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 579 | + if ($args['label_type'] == 'horizontal') { |
|
| 580 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
| 581 | 581 | $output .= '<div class="' . $input_col . '">'; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - if ( ! empty( $args['wysiwyg'] ) ) { |
|
| 584 | + if (!empty($args['wysiwyg'])) { |
|
| 585 | 585 | ob_start(); |
| 586 | 586 | $content = $args['value']; |
| 587 | - $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor'; |
|
| 587 | + $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
|
| 588 | 588 | $settings = array( |
| 589 | - 'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4, |
|
| 589 | + 'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4, |
|
| 590 | 590 | 'quicktags' => false, |
| 591 | 591 | 'media_buttons' => false, |
| 592 | 592 | 'editor_class' => 'form-control', |
| 593 | - 'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ), |
|
| 593 | + 'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']), |
|
| 594 | 594 | 'teeny' => true, |
| 595 | 595 | ); |
| 596 | 596 | |
| 597 | 597 | // maybe set settings if array |
| 598 | - if ( is_array( $args['wysiwyg'] ) ) { |
|
| 599 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
| 598 | + if (is_array($args['wysiwyg'])) { |
|
| 599 | + $settings = wp_parse_args($args['wysiwyg'], $settings); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - wp_editor( $content, $editor_id, $settings ); |
|
| 602 | + wp_editor($content, $editor_id, $settings); |
|
| 603 | 603 | $output .= ob_get_clean(); |
| 604 | 604 | } else { |
| 605 | 605 | |
@@ -607,65 +607,65 @@ discard block |
||
| 607 | 607 | $output .= '<textarea '; |
| 608 | 608 | |
| 609 | 609 | // name |
| 610 | - if ( ! empty( $args['name'] ) ) { |
|
| 611 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 610 | + if (!empty($args['name'])) { |
|
| 611 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | // id |
| 615 | - if ( ! empty( $args['id'] ) ) { |
|
| 616 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 615 | + if (!empty($args['id'])) { |
|
| 616 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | // placeholder |
| 620 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 621 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 620 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
| 621 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | // title |
| 625 | - if ( ! empty( $args['title'] ) ) { |
|
| 626 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 625 | + if (!empty($args['title'])) { |
|
| 626 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | // validation text |
| 630 | - if ( ! empty( $args['validation_text'] ) ) { |
|
| 631 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
| 630 | + if (!empty($args['validation_text'])) { |
|
| 631 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
| 632 | 632 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | // validation_pattern |
| 636 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 637 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 636 | + if (!empty($args['validation_pattern'])) { |
|
| 637 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | // required |
| 641 | - if ( ! empty( $args['required'] ) ) { |
|
| 641 | + if (!empty($args['required'])) { |
|
| 642 | 642 | $output .= ' required '; |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | // rows |
| 646 | - if ( ! empty( $args['rows'] ) ) { |
|
| 647 | - $output .= ' rows="' . absint( $args['rows'] ) . '" '; |
|
| 646 | + if (!empty($args['rows'])) { |
|
| 647 | + $output .= ' rows="' . absint($args['rows']) . '" '; |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | |
| 651 | 651 | // class |
| 652 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 652 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
| 653 | 653 | $output .= ' class="form-control ' . $class . '" '; |
| 654 | 654 | |
| 655 | 655 | // extra attributes |
| 656 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 657 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 656 | + if (!empty($args['extra_attributes'])) { |
|
| 657 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | // close tag |
| 661 | 661 | $output .= ' >'; |
| 662 | 662 | |
| 663 | 663 | // value |
| 664 | - if ( ! empty( $args['value'] ) ) { |
|
| 665 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
| 666 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
| 664 | + if (!empty($args['value'])) { |
|
| 665 | + if (!empty($args['allow_tags'])) { |
|
| 666 | + $output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML. |
|
| 667 | 667 | } else { |
| 668 | - $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] ); |
|
| 668 | + $output .= AUI_Component_Helper::sanitize_textarea_field($args['value']); |
|
| 669 | 669 | } |
| 670 | 670 | } |
| 671 | 671 | |
@@ -674,23 +674,23 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | |
| 676 | 676 | // input group wraps |
| 677 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 678 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 679 | - if ( $args['input_group_left'] ) { |
|
| 680 | - $output = self::wrap( array( |
|
| 677 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
| 678 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
| 679 | + if ($args['input_group_left']) { |
|
| 680 | + $output = self::wrap(array( |
|
| 681 | 681 | 'content' => $output, |
| 682 | 682 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
| 683 | 683 | 'input_group_left' => $args['input_group_left'], |
| 684 | 684 | 'input_group_left_inside' => $args['input_group_left_inside'] |
| 685 | - ) ); |
|
| 685 | + )); |
|
| 686 | 686 | } |
| 687 | - if ( $args['input_group_right'] ) { |
|
| 688 | - $output = self::wrap( array( |
|
| 687 | + if ($args['input_group_right']) { |
|
| 688 | + $output = self::wrap(array( |
|
| 689 | 689 | 'content' => $output, |
| 690 | 690 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
| 691 | 691 | 'input_group_right' => $args['input_group_right'], |
| 692 | 692 | 'input_group_right_inside' => $args['input_group_right_inside'] |
| 693 | - ) ); |
|
| 693 | + )); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | } |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if ( ! empty( $args['label'] ) && $label_after ) { |
|
| 701 | + if (!empty($args['label']) && $label_after) { |
|
| 702 | 702 | $label_args = array( |
| 703 | 703 | 'title' => $args['label'], |
| 704 | 704 | 'for' => $args['id'], |
@@ -706,32 +706,32 @@ discard block |
||
| 706 | 706 | 'label_type' => $args['label_type'], |
| 707 | 707 | 'label_col' => $args['label_col'] |
| 708 | 708 | ); |
| 709 | - $output .= self::label( $label_args ); |
|
| 709 | + $output .= self::label($label_args); |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | // help text |
| 713 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 714 | - $output .= AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 713 | + if (!empty($args['help_text'])) { |
|
| 714 | + $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | // maybe horizontal label |
| 718 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 718 | + if ($args['label_type'] == 'horizontal') { |
|
| 719 | 719 | $output .= '</div>'; |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | |
| 723 | 723 | // wrap |
| 724 | - if ( ! $args['no_wrap'] ) { |
|
| 724 | + if (!$args['no_wrap']) { |
|
| 725 | 725 | $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group'; |
| 726 | 726 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
| 727 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 728 | - $output = self::wrap( array( |
|
| 727 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 728 | + $output = self::wrap(array( |
|
| 729 | 729 | 'content' => $output, |
| 730 | 730 | 'class' => $wrap_class, |
| 731 | 731 | 'element_require' => $args['element_require'], |
| 732 | 732 | 'argument_id' => $args['id'], |
| 733 | 733 | 'wrap_attributes' => $args['wrap_attributes'], |
| 734 | - ) ); |
|
| 734 | + )); |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | * |
| 746 | 746 | * @return string The rendered component. |
| 747 | 747 | */ |
| 748 | - public static function select( $args = array() ) { |
|
| 748 | + public static function select($args = array()) { |
|
| 749 | 749 | $defaults = array( |
| 750 | 750 | 'class' => '', |
| 751 | 751 | 'wrap_class' => '', |
@@ -782,11 +782,11 @@ discard block |
||
| 782 | 782 | /** |
| 783 | 783 | * Parse incoming $args into an array and merge it with $defaults |
| 784 | 784 | */ |
| 785 | - $args = wp_parse_args( $args, $defaults ); |
|
| 785 | + $args = wp_parse_args($args, $defaults); |
|
| 786 | 786 | $output = ''; |
| 787 | 787 | |
| 788 | 788 | // for now lets hide floating labels |
| 789 | - if ( $args['label_type'] == 'floating' ) { |
|
| 789 | + if ($args['label_type'] == 'floating') { |
|
| 790 | 790 | $args['label_type'] = 'hidden'; |
| 791 | 791 | } |
| 792 | 792 | |
@@ -797,31 +797,31 @@ discard block |
||
| 797 | 797 | $label_after = $args['label_after']; |
| 798 | 798 | |
| 799 | 799 | // floating labels need label after |
| 800 | - if ( $args['label_type'] == 'floating' ) { |
|
| 800 | + if ($args['label_type'] == 'floating') { |
|
| 801 | 801 | $label_after = true; |
| 802 | 802 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | // Maybe setup select2 |
| 806 | 806 | $is_select2 = false; |
| 807 | - if ( ! empty( $args['select2'] ) ) { |
|
| 807 | + if (!empty($args['select2'])) { |
|
| 808 | 808 | $args['class'] .= ' aui-select2'; |
| 809 | 809 | $is_select2 = true; |
| 810 | - } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) { |
|
| 810 | + } elseif (strpos($args['class'], 'aui-select2') !== false) { |
|
| 811 | 811 | $is_select2 = true; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | // select2 tags |
| 815 | - if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason |
|
| 815 | + if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason |
|
| 816 | 816 | $args['data-tags'] = 'true'; |
| 817 | 817 | $args['data-token-separators'] = "[',']"; |
| 818 | 818 | $args['multiple'] = true; |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | // select2 placeholder |
| 822 | - if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) { |
|
| 823 | - $args['data-placeholder'] = esc_attr( $args['placeholder'] ); |
|
| 824 | - $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true; |
|
| 822 | + if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) { |
|
| 823 | + $args['data-placeholder'] = esc_attr($args['placeholder']); |
|
| 824 | + $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | |
@@ -833,61 +833,61 @@ discard block |
||
| 833 | 833 | // } |
| 834 | 834 | |
| 835 | 835 | // Set hidden input to save empty value for multiselect. |
| 836 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
| 837 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>'; |
|
| 836 | + if (!empty($args['multiple']) && !empty($args['name'])) { |
|
| 837 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value=""/>'; |
|
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | // open/type |
| 841 | 841 | $output .= '<select '; |
| 842 | 842 | |
| 843 | 843 | // style |
| 844 | - if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
| 844 | + if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
| 845 | 845 | $output .= " style='width:100%;' "; |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | // element require |
| 849 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 850 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 849 | + if (!empty($args['element_require'])) { |
|
| 850 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
| 851 | 851 | $args['class'] .= " aui-conditional-field"; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | // class |
| 855 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 856 | - $output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class ); |
|
| 855 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
| 856 | + $output .= AUI_Component_Helper::class_attr('custom-select ' . $class); |
|
| 857 | 857 | |
| 858 | 858 | // name |
| 859 | - if ( ! empty( $args['name'] ) ) { |
|
| 860 | - $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] ); |
|
| 859 | + if (!empty($args['name'])) { |
|
| 860 | + $output .= AUI_Component_Helper::name($args['name'], $args['multiple']); |
|
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | // id |
| 864 | - if ( ! empty( $args['id'] ) ) { |
|
| 865 | - $output .= AUI_Component_Helper::id( $args['id'] ); |
|
| 864 | + if (!empty($args['id'])) { |
|
| 865 | + $output .= AUI_Component_Helper::id($args['id']); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | // title |
| 869 | - if ( ! empty( $args['title'] ) ) { |
|
| 870 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 869 | + if (!empty($args['title'])) { |
|
| 870 | + $output .= AUI_Component_Helper::title($args['title']); |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | // data-attributes |
| 874 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 874 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
| 875 | 875 | |
| 876 | 876 | // aria-attributes |
| 877 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 877 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
| 878 | 878 | |
| 879 | 879 | // extra attributes |
| 880 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 881 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 880 | + if (!empty($args['extra_attributes'])) { |
|
| 881 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | // required |
| 885 | - if ( ! empty( $args['required'] ) ) { |
|
| 885 | + if (!empty($args['required'])) { |
|
| 886 | 886 | $output .= ' required '; |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | // multiple |
| 890 | - if ( ! empty( $args['multiple'] ) ) { |
|
| 890 | + if (!empty($args['multiple'])) { |
|
| 891 | 891 | $output .= ' multiple '; |
| 892 | 892 | } |
| 893 | 893 | |
@@ -895,50 +895,50 @@ discard block |
||
| 895 | 895 | $output .= ' >'; |
| 896 | 896 | |
| 897 | 897 | // placeholder |
| 898 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) { |
|
| 899 | - $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>'; |
|
| 900 | - } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) { |
|
| 898 | + if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) { |
|
| 899 | + $output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>'; |
|
| 900 | + } elseif ($is_select2 && !empty($args['placeholder'])) { |
|
| 901 | 901 | $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | // Options |
| 905 | - if ( ! empty( $args['options'] ) ) { |
|
| 905 | + if (!empty($args['options'])) { |
|
| 906 | 906 | |
| 907 | - if ( ! is_array( $args['options'] ) ) { |
|
| 907 | + if (!is_array($args['options'])) { |
|
| 908 | 908 | $output .= $args['options']; // not the preferred way but an option |
| 909 | 909 | } else { |
| 910 | - foreach ( $args['options'] as $val => $name ) { |
|
| 910 | + foreach ($args['options'] as $val => $name) { |
|
| 911 | 911 | $selected = ''; |
| 912 | - if ( is_array( $name ) ) { |
|
| 913 | - if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) { |
|
| 914 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 912 | + if (is_array($name)) { |
|
| 913 | + if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
|
| 914 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
| 915 | 915 | |
| 916 | - $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>'; |
|
| 916 | + $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
| 917 | 917 | } else { |
| 918 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 919 | - $option_value = isset( $name['value'] ) ? $name['value'] : ''; |
|
| 920 | - $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : ''; |
|
| 921 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) { |
|
| 922 | - $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : ""; |
|
| 923 | - } elseif ( ! empty( $args['value'] ) ) { |
|
| 924 | - $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false ); |
|
| 925 | - } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) { |
|
| 926 | - $selected = selected( $option_value, $args['value'], false ); |
|
| 918 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
| 919 | + $option_value = isset($name['value']) ? $name['value'] : ''; |
|
| 920 | + $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : ''; |
|
| 921 | + if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) { |
|
| 922 | + $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
|
| 923 | + } elseif (!empty($args['value'])) { |
|
| 924 | + $selected = selected($option_value, stripslashes_deep($args['value']), false); |
|
| 925 | + } elseif (empty($args['value']) && $args['value'] === $option_value) { |
|
| 926 | + $selected = selected($option_value, $args['value'], false); |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | - $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>'; |
|
| 929 | + $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>'; |
|
| 930 | 930 | } |
| 931 | 931 | } else { |
| 932 | - if ( ! empty( $args['value'] ) ) { |
|
| 933 | - if ( is_array( $args['value'] ) ) { |
|
| 934 | - $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : ''; |
|
| 935 | - } elseif ( ! empty( $args['value'] ) ) { |
|
| 936 | - $selected = selected( $args['value'], $val, false ); |
|
| 932 | + if (!empty($args['value'])) { |
|
| 933 | + if (is_array($args['value'])) { |
|
| 934 | + $selected = in_array($val, $args['value']) ? 'selected="selected"' : ''; |
|
| 935 | + } elseif (!empty($args['value'])) { |
|
| 936 | + $selected = selected($args['value'], $val, false); |
|
| 937 | 937 | } |
| 938 | - } elseif ( $args['value'] === $val ) { |
|
| 939 | - $selected = selected( $args['value'], $val, false ); |
|
| 938 | + } elseif ($args['value'] === $val) { |
|
| 939 | + $selected = selected($args['value'], $val, false); |
|
| 940 | 940 | } |
| 941 | - $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
| 941 | + $output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>'; |
|
| 942 | 942 | } |
| 943 | 943 | } |
| 944 | 944 | } |
@@ -951,8 +951,8 @@ discard block |
||
| 951 | 951 | $label = ''; |
| 952 | 952 | $help_text = ''; |
| 953 | 953 | // label |
| 954 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 955 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 954 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
| 955 | + } elseif (!empty($args['label']) && !$label_after) { |
|
| 956 | 956 | $label_args = array( |
| 957 | 957 | 'title' => $args['label'], |
| 958 | 958 | 'for' => $args['id'], |
@@ -960,49 +960,49 @@ discard block |
||
| 960 | 960 | 'label_type' => $args['label_type'], |
| 961 | 961 | 'label_col' => $args['label_col'] |
| 962 | 962 | ); |
| 963 | - $label = self::label( $label_args ); |
|
| 963 | + $label = self::label($label_args); |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | // help text |
| 967 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 968 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 967 | + if (!empty($args['help_text'])) { |
|
| 968 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | // input group wraps |
| 972 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 973 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 974 | - if ( $args['input_group_left'] ) { |
|
| 975 | - $output = self::wrap( array( |
|
| 972 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
| 973 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
| 974 | + if ($args['input_group_left']) { |
|
| 975 | + $output = self::wrap(array( |
|
| 976 | 976 | 'content' => $output, |
| 977 | 977 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
| 978 | 978 | 'input_group_left' => $args['input_group_left'], |
| 979 | 979 | 'input_group_left_inside' => $args['input_group_left_inside'] |
| 980 | - ) ); |
|
| 980 | + )); |
|
| 981 | 981 | } |
| 982 | - if ( $args['input_group_right'] ) { |
|
| 983 | - $output = self::wrap( array( |
|
| 982 | + if ($args['input_group_right']) { |
|
| 983 | + $output = self::wrap(array( |
|
| 984 | 984 | 'content' => $output, |
| 985 | 985 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
| 986 | 986 | 'input_group_right' => $args['input_group_right'], |
| 987 | 987 | 'input_group_right_inside' => $args['input_group_right_inside'] |
| 988 | - ) ); |
|
| 988 | + )); |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | - if ( ! $label_after ) { |
|
| 993 | + if (!$label_after) { |
|
| 994 | 994 | $output .= $help_text; |
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | |
| 998 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 999 | - $output = self::wrap( array( |
|
| 998 | + if ($args['label_type'] == 'horizontal') { |
|
| 999 | + $output = self::wrap(array( |
|
| 1000 | 1000 | 'content' => $output, |
| 1001 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 1002 | - ) ); |
|
| 1001 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
| 1002 | + )); |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | - if ( ! $label_after ) { |
|
| 1005 | + if (!$label_after) { |
|
| 1006 | 1006 | $output = $label . $output; |
| 1007 | 1007 | } |
| 1008 | 1008 | |
@@ -1013,16 +1013,16 @@ discard block |
||
| 1013 | 1013 | |
| 1014 | 1014 | |
| 1015 | 1015 | // wrap |
| 1016 | - if ( ! $args['no_wrap'] ) { |
|
| 1016 | + if (!$args['no_wrap']) { |
|
| 1017 | 1017 | $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
| 1018 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1019 | - $output = self::wrap( array( |
|
| 1018 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1019 | + $output = self::wrap(array( |
|
| 1020 | 1020 | 'content' => $output, |
| 1021 | 1021 | 'class' => $wrap_class, |
| 1022 | 1022 | 'element_require' => $args['element_require'], |
| 1023 | 1023 | 'argument_id' => $args['id'], |
| 1024 | 1024 | 'wrap_attributes' => $args['wrap_attributes'], |
| 1025 | - ) ); |
|
| 1025 | + )); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | |
@@ -1036,7 +1036,7 @@ discard block |
||
| 1036 | 1036 | * |
| 1037 | 1037 | * @return string The rendered component. |
| 1038 | 1038 | */ |
| 1039 | - public static function radio( $args = array() ) { |
|
| 1039 | + public static function radio($args = array()) { |
|
| 1040 | 1040 | $defaults = array( |
| 1041 | 1041 | 'class' => '', |
| 1042 | 1042 | 'wrap_class' => '', |
@@ -1066,10 +1066,10 @@ discard block |
||
| 1066 | 1066 | /** |
| 1067 | 1067 | * Parse incoming $args into an array and merge it with $defaults |
| 1068 | 1068 | */ |
| 1069 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1069 | + $args = wp_parse_args($args, $defaults); |
|
| 1070 | 1070 | |
| 1071 | 1071 | // for now lets use horizontal for floating |
| 1072 | - if ( $args['label_type'] == 'floating' ) { |
|
| 1072 | + if ($args['label_type'] == 'floating') { |
|
| 1073 | 1073 | $args['label_type'] = 'horizontal'; |
| 1074 | 1074 | } |
| 1075 | 1075 | |
@@ -1084,47 +1084,47 @@ discard block |
||
| 1084 | 1084 | |
| 1085 | 1085 | |
| 1086 | 1086 | // label before |
| 1087 | - if ( ! empty( $args['label'] ) ) { |
|
| 1088 | - $output .= self::label( $label_args, 'radio' ); |
|
| 1087 | + if (!empty($args['label'])) { |
|
| 1088 | + $output .= self::label($label_args, 'radio'); |
|
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | // maybe horizontal label |
| 1092 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 1093 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 1092 | + if ($args['label_type'] == 'horizontal') { |
|
| 1093 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
| 1094 | 1094 | $output .= '<div class="' . $input_col . '">'; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | - if ( ! empty( $args['options'] ) ) { |
|
| 1097 | + if (!empty($args['options'])) { |
|
| 1098 | 1098 | $count = 0; |
| 1099 | - foreach ( $args['options'] as $value => $label ) { |
|
| 1099 | + foreach ($args['options'] as $value => $label) { |
|
| 1100 | 1100 | $option_args = $args; |
| 1101 | 1101 | $option_args['value'] = $value; |
| 1102 | 1102 | $option_args['label'] = $label; |
| 1103 | 1103 | $option_args['checked'] = $value == $args['value'] ? true : false; |
| 1104 | - $output .= self::radio_option( $option_args, $count ); |
|
| 1105 | - $count ++; |
|
| 1104 | + $output .= self::radio_option($option_args, $count); |
|
| 1105 | + $count++; |
|
| 1106 | 1106 | } |
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | // help text |
| 1110 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
| 1110 | + $help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : ''; |
|
| 1111 | 1111 | $output .= $help_text; |
| 1112 | 1112 | |
| 1113 | 1113 | // maybe horizontal label |
| 1114 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 1114 | + if ($args['label_type'] == 'horizontal') { |
|
| 1115 | 1115 | $output .= '</div>'; |
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | // wrap |
| 1119 | 1119 | $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
| 1120 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1121 | - $output = self::wrap( array( |
|
| 1120 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1121 | + $output = self::wrap(array( |
|
| 1122 | 1122 | 'content' => $output, |
| 1123 | 1123 | 'class' => $wrap_class, |
| 1124 | 1124 | 'element_require' => $args['element_require'], |
| 1125 | 1125 | 'argument_id' => $args['id'], |
| 1126 | 1126 | 'wrap_attributes' => $args['wrap_attributes'], |
| 1127 | - ) ); |
|
| 1127 | + )); |
|
| 1128 | 1128 | |
| 1129 | 1129 | |
| 1130 | 1130 | return $output; |
@@ -1137,7 +1137,7 @@ discard block |
||
| 1137 | 1137 | * |
| 1138 | 1138 | * @return string The rendered component. |
| 1139 | 1139 | */ |
| 1140 | - public static function radio_option( $args = array(), $count = '' ) { |
|
| 1140 | + public static function radio_option($args = array(), $count = '') { |
|
| 1141 | 1141 | $defaults = array( |
| 1142 | 1142 | 'class' => '', |
| 1143 | 1143 | 'id' => '', |
@@ -1155,7 +1155,7 @@ discard block |
||
| 1155 | 1155 | /** |
| 1156 | 1156 | * Parse incoming $args into an array and merge it with $defaults |
| 1157 | 1157 | */ |
| 1158 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1158 | + $args = wp_parse_args($args, $defaults); |
|
| 1159 | 1159 | |
| 1160 | 1160 | $output = ''; |
| 1161 | 1161 | |
@@ -1166,43 +1166,43 @@ discard block |
||
| 1166 | 1166 | $output .= ' class="form-check-input" '; |
| 1167 | 1167 | |
| 1168 | 1168 | // name |
| 1169 | - if ( ! empty( $args['name'] ) ) { |
|
| 1170 | - $output .= AUI_Component_Helper::name( $args['name'] ); |
|
| 1169 | + if (!empty($args['name'])) { |
|
| 1170 | + $output .= AUI_Component_Helper::name($args['name']); |
|
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | // id |
| 1174 | - if ( ! empty( $args['id'] ) ) { |
|
| 1175 | - $output .= AUI_Component_Helper::id( $args['id'] . $count ); |
|
| 1174 | + if (!empty($args['id'])) { |
|
| 1175 | + $output .= AUI_Component_Helper::id($args['id'] . $count); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | // title |
| 1179 | - if ( ! empty( $args['title'] ) ) { |
|
| 1180 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 1179 | + if (!empty($args['title'])) { |
|
| 1180 | + $output .= AUI_Component_Helper::title($args['title']); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | // value |
| 1184 | - if ( isset( $args['value'] ) ) { |
|
| 1185 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 1184 | + if (isset($args['value'])) { |
|
| 1185 | + $output .= AUI_Component_Helper::value($args['value']); |
|
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | // checked, for radio and checkboxes |
| 1189 | - if ( $args['checked'] ) { |
|
| 1189 | + if ($args['checked']) { |
|
| 1190 | 1190 | $output .= ' checked '; |
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | 1193 | // data-attributes |
| 1194 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 1194 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
| 1195 | 1195 | |
| 1196 | 1196 | // aria-attributes |
| 1197 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 1197 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
| 1198 | 1198 | |
| 1199 | 1199 | // extra attributes |
| 1200 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 1201 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 1200 | + if (!empty($args['extra_attributes'])) { |
|
| 1201 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | // required |
| 1205 | - if ( ! empty( $args['required'] ) ) { |
|
| 1205 | + if (!empty($args['required'])) { |
|
| 1206 | 1206 | $output .= ' required '; |
| 1207 | 1207 | } |
| 1208 | 1208 | |
@@ -1210,38 +1210,38 @@ discard block |
||
| 1210 | 1210 | $output .= ' >'; |
| 1211 | 1211 | |
| 1212 | 1212 | // label |
| 1213 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 1214 | - } elseif ( ! empty( $args['label'] ) ) { |
|
| 1215 | - $output .= self::label( array( |
|
| 1213 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
| 1214 | + } elseif (!empty($args['label'])) { |
|
| 1215 | + $output .= self::label(array( |
|
| 1216 | 1216 | 'title' => $args['label'], |
| 1217 | 1217 | 'for' => $args['id'] . $count, |
| 1218 | 1218 | 'class' => 'form-check-label' |
| 1219 | - ), 'radio' ); |
|
| 1219 | + ), 'radio'); |
|
| 1220 | 1220 | } |
| 1221 | 1221 | |
| 1222 | 1222 | // wrap |
| 1223 | - if ( ! $args['no_wrap'] ) { |
|
| 1223 | + if (!$args['no_wrap']) { |
|
| 1224 | 1224 | $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
| 1225 | 1225 | |
| 1226 | 1226 | // Unique wrap class |
| 1227 | 1227 | $uniq_class = 'fwrap'; |
| 1228 | - if ( ! empty( $args['name'] ) ) { |
|
| 1228 | + if (!empty($args['name'])) { |
|
| 1229 | 1229 | $uniq_class .= '-' . $args['name']; |
| 1230 | - } else if ( ! empty( $args['id'] ) ) { |
|
| 1230 | + } else if (!empty($args['id'])) { |
|
| 1231 | 1231 | $uniq_class .= '-' . $args['id']; |
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | - if ( isset( $args['value'] ) || $args['value'] !== "" ) { |
|
| 1234 | + if (isset($args['value']) || $args['value'] !== "") { |
|
| 1235 | 1235 | $uniq_class .= '-' . $args['value']; |
| 1236 | 1236 | } else { |
| 1237 | 1237 | $uniq_class .= '-' . $count; |
| 1238 | 1238 | } |
| 1239 | - $wrap_class .= ' ' . sanitize_html_class( $uniq_class ); |
|
| 1239 | + $wrap_class .= ' ' . sanitize_html_class($uniq_class); |
|
| 1240 | 1240 | |
| 1241 | - $output = self::wrap( array( |
|
| 1241 | + $output = self::wrap(array( |
|
| 1242 | 1242 | 'content' => $output, |
| 1243 | 1243 | 'class' => $wrap_class |
| 1244 | - ) ); |
|
| 1244 | + )); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | return $output; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | 17 | // If this file is called directly, abort. |
| 18 | -if ( ! defined( 'WPINC' ) ) { |
|
| 18 | +if (!defined('WPINC')) { |
|
| 19 | 19 | die; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -29,14 +29,14 @@ discard block |
||
| 29 | 29 | public function __construct() { |
| 30 | 30 | |
| 31 | 31 | // load AUI |
| 32 | - require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' ); |
|
| 32 | + require_once(dirname(__FILE__) . '/ayecode-ui-loader.php'); |
|
| 33 | 33 | |
| 34 | 34 | // Maybe show example page |
| 35 | - add_action( 'template_redirect', array( $this,'maybe_show_examples' ) ); |
|
| 35 | + add_action('template_redirect', array($this, 'maybe_show_examples')); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function maybe_show_examples(){ |
|
| 39 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 38 | + public function maybe_show_examples() { |
|
| 39 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
| 40 | 40 | echo "<head>"; |
| 41 | 41 | wp_head(); |
| 42 | 42 | echo "</head>"; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function get_examples(){ |
|
| 51 | + public function get_examples() { |
|
| 52 | 52 | $output = ''; |
| 53 | 53 | |
| 54 | 54 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | 'id' => 'wpinv_discount_start', |
| 62 | 62 | 'size' => 'sm', |
| 63 | 63 | 'name' => 'wpinv_discount_start', |
| 64 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 64 | + 'label' => __('Start Date', 'invoicing'), |
|
| 65 | 65 | 'placeholder' => 'YYYY-MM-DD 00:00', |
| 66 | 66 | 'value' => '', |
| 67 | 67 | 'extra_attributes' => array( |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | 'id' => 'wpinv_discount_start', |
| 79 | 79 | //'size' => 'smx', |
| 80 | 80 | 'name' => 'wpinv_discount_start', |
| 81 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 81 | + 'label' => __('Start Date', 'invoicing'), |
|
| 82 | 82 | 'placeholder' => 'YYYY-MM-DD 00:00', |
| 83 | 83 | 'value' => '', |
| 84 | 84 | 'extra_attributes' => array( |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | 'id' => 'wpinv_discount_start', |
| 95 | 95 | 'size' => 'lg', |
| 96 | 96 | 'name' => 'wpinv_discount_start', |
| 97 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 97 | + 'label' => __('Start Date', 'invoicing'), |
|
| 98 | 98 | 'placeholder' => 'YYYY-MM-DD 00:00', |
| 99 | 99 | 'value' => '', |
| 100 | 100 | 'extra_attributes' => array( |