@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | - exit; // Exit if accessed directly |
|
| 4 | + exit; // Exit if accessed directly |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -11,1012 +11,1012 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | class AUI_Component_Input { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Build the component. |
|
| 16 | - * |
|
| 17 | - * @param array $args |
|
| 18 | - * |
|
| 19 | - * @return string The rendered component. |
|
| 20 | - */ |
|
| 21 | - public static function input($args = array()){ |
|
| 22 | - $defaults = array( |
|
| 23 | - 'type' => 'text', |
|
| 24 | - 'name' => '', |
|
| 25 | - 'class' => '', |
|
| 26 | - 'wrap_class' => '', |
|
| 27 | - 'id' => '', |
|
| 28 | - 'placeholder'=> '', |
|
| 29 | - 'title' => '', |
|
| 30 | - 'value' => '', |
|
| 31 | - 'required' => false, |
|
| 32 | - 'label' => '', |
|
| 33 | - 'label_after'=> false, |
|
| 34 | - 'label_class'=> '', |
|
| 35 | - 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 36 | - 'help_text' => '', |
|
| 37 | - 'validation_text' => '', |
|
| 38 | - 'validation_pattern' => '', |
|
| 39 | - 'no_wrap' => false, |
|
| 40 | - 'input_group_right' => '', |
|
| 41 | - 'input_group_left' => '', |
|
| 42 | - 'input_group_right_inside' => false, // forces the input group inside the input |
|
| 43 | - 'input_group_left_inside' => false, // forces the input group inside the input |
|
| 44 | - 'step' => '', |
|
| 45 | - 'switch' => false, // to show checkbox as a switch |
|
| 46 | - 'checked' => false, // set a checkbox or radio as selected |
|
| 47 | - 'password_toggle' => true, // toggle view/hide password |
|
| 48 | - 'element_require' => '', // [%element_id%] == "1" |
|
| 49 | - 'extra_attributes' => array() // an array of extra attributes |
|
| 50 | - ); |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 54 | - */ |
|
| 55 | - $args = wp_parse_args( $args, $defaults ); |
|
| 56 | - $output = ''; |
|
| 57 | - if ( ! empty( $args['type'] ) ) { |
|
| 58 | - // hidden label option needs to be empty |
|
| 59 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 60 | - |
|
| 61 | - $type = sanitize_html_class( $args['type'] ); |
|
| 62 | - |
|
| 63 | - $help_text = ''; |
|
| 64 | - $label = ''; |
|
| 65 | - $label_after = $args['label_after']; |
|
| 66 | - $label_args = array( |
|
| 67 | - 'title'=> $args['label'], |
|
| 68 | - 'for'=> $args['id'], |
|
| 69 | - 'class' => $args['label_class']." ", |
|
| 70 | - 'label_type' => $args['label_type'] |
|
| 71 | - ); |
|
| 72 | - |
|
| 73 | - // floating labels need label after |
|
| 74 | - if( $args['label_type'] == 'floating' && $type != 'checkbox' ){ |
|
| 75 | - $label_after = true; |
|
| 76 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // Some special sauce for files |
|
| 80 | - if($type=='file' ){ |
|
| 81 | - $label_after = true; // if type file we need the label after |
|
| 82 | - $args['class'] .= ' custom-file-input '; |
|
| 83 | - }elseif($type=='checkbox'){ |
|
| 84 | - $label_after = true; // if type file we need the label after |
|
| 85 | - $args['class'] .= ' custom-control-input '; |
|
| 86 | - }elseif($type=='datepicker' || $type=='timepicker'){ |
|
| 87 | - $type = 'text'; |
|
| 88 | - //$args['class'] .= ' aui-flatpickr bg-initial '; |
|
| 89 | - $args['class'] .= ' bg-initial '; |
|
| 90 | - |
|
| 91 | - $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
|
| 92 | - // enqueue the script |
|
| 93 | - $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 94 | - $aui_settings->enqueue_flatpickr(); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - // open/type |
|
| 99 | - $output .= '<input type="' . $type . '" '; |
|
| 100 | - |
|
| 101 | - // name |
|
| 102 | - if(!empty($args['name'])){ |
|
| 103 | - $output .= ' name="'.esc_attr($args['name']).'" '; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // id |
|
| 107 | - if(!empty($args['id'])){ |
|
| 108 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // placeholder |
|
| 112 | - if(isset($args['placeholder']) && '' != $args['placeholder'] ){ |
|
| 113 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - // title |
|
| 117 | - if(!empty($args['title'])){ |
|
| 118 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // value |
|
| 122 | - if(!empty($args['value'])){ |
|
| 123 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // checked, for radio and checkboxes |
|
| 127 | - if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){ |
|
| 128 | - $output .= ' checked '; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - // validation text |
|
| 132 | - if(!empty($args['validation_text'])){ |
|
| 133 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
| 134 | - $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // validation_pattern |
|
| 138 | - if(!empty($args['validation_pattern'])){ |
|
| 139 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - // step (for numbers) |
|
| 143 | - if(!empty($args['step'])){ |
|
| 144 | - $output .= ' step="'.$args['step'].'" '; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // required |
|
| 148 | - if(!empty($args['required'])){ |
|
| 149 | - $output .= ' required '; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // class |
|
| 153 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 154 | - $output .= ' class="form-control '.$class.'" '; |
|
| 155 | - |
|
| 156 | - // data-attributes |
|
| 157 | - $output .= AUI_Component_Helper::data_attributes($args); |
|
| 158 | - |
|
| 159 | - // extra attributes |
|
| 160 | - if(!empty($args['extra_attributes'])){ |
|
| 161 | - $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - // close |
|
| 165 | - $output .= ' >'; |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - // label |
|
| 169 | - if(!empty($args['label'])){ |
|
| 170 | - if($type == 'file'){$label_args['class'] .= 'custom-file-label';} |
|
| 171 | - elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';} |
|
| 172 | - $label = self::label( $label_args, $type ); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - // help text |
|
| 176 | - if(!empty($args['help_text'])){ |
|
| 177 | - $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - // set help text in the correct possition |
|
| 182 | - if($label_after){ |
|
| 183 | - $output .= $label . $help_text; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - // some input types need a separate wrap |
|
| 187 | - if($type == 'file') { |
|
| 188 | - $output = self::wrap( array( |
|
| 189 | - 'content' => $output, |
|
| 190 | - 'class' => 'form-group custom-file' |
|
| 191 | - ) ); |
|
| 192 | - }elseif($type == 'checkbox'){ |
|
| 193 | - $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox'; |
|
| 194 | - $output = self::wrap( array( |
|
| 195 | - 'content' => $output, |
|
| 196 | - 'class' => 'custom-control '.$wrap_class |
|
| 197 | - ) ); |
|
| 198 | - |
|
| 199 | - if($args['label_type']=='horizontal'){ |
|
| 200 | - $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>'; |
|
| 201 | - } |
|
| 202 | - }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){ |
|
| 203 | - |
|
| 204 | - |
|
| 205 | - // allow password field to toggle view |
|
| 206 | - $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" |
|
| 14 | + /** |
|
| 15 | + * Build the component. |
|
| 16 | + * |
|
| 17 | + * @param array $args |
|
| 18 | + * |
|
| 19 | + * @return string The rendered component. |
|
| 20 | + */ |
|
| 21 | + public static function input($args = array()){ |
|
| 22 | + $defaults = array( |
|
| 23 | + 'type' => 'text', |
|
| 24 | + 'name' => '', |
|
| 25 | + 'class' => '', |
|
| 26 | + 'wrap_class' => '', |
|
| 27 | + 'id' => '', |
|
| 28 | + 'placeholder'=> '', |
|
| 29 | + 'title' => '', |
|
| 30 | + 'value' => '', |
|
| 31 | + 'required' => false, |
|
| 32 | + 'label' => '', |
|
| 33 | + 'label_after'=> false, |
|
| 34 | + 'label_class'=> '', |
|
| 35 | + 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 36 | + 'help_text' => '', |
|
| 37 | + 'validation_text' => '', |
|
| 38 | + 'validation_pattern' => '', |
|
| 39 | + 'no_wrap' => false, |
|
| 40 | + 'input_group_right' => '', |
|
| 41 | + 'input_group_left' => '', |
|
| 42 | + 'input_group_right_inside' => false, // forces the input group inside the input |
|
| 43 | + 'input_group_left_inside' => false, // forces the input group inside the input |
|
| 44 | + 'step' => '', |
|
| 45 | + 'switch' => false, // to show checkbox as a switch |
|
| 46 | + 'checked' => false, // set a checkbox or radio as selected |
|
| 47 | + 'password_toggle' => true, // toggle view/hide password |
|
| 48 | + 'element_require' => '', // [%element_id%] == "1" |
|
| 49 | + 'extra_attributes' => array() // an array of extra attributes |
|
| 50 | + ); |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 54 | + */ |
|
| 55 | + $args = wp_parse_args( $args, $defaults ); |
|
| 56 | + $output = ''; |
|
| 57 | + if ( ! empty( $args['type'] ) ) { |
|
| 58 | + // hidden label option needs to be empty |
|
| 59 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 60 | + |
|
| 61 | + $type = sanitize_html_class( $args['type'] ); |
|
| 62 | + |
|
| 63 | + $help_text = ''; |
|
| 64 | + $label = ''; |
|
| 65 | + $label_after = $args['label_after']; |
|
| 66 | + $label_args = array( |
|
| 67 | + 'title'=> $args['label'], |
|
| 68 | + 'for'=> $args['id'], |
|
| 69 | + 'class' => $args['label_class']." ", |
|
| 70 | + 'label_type' => $args['label_type'] |
|
| 71 | + ); |
|
| 72 | + |
|
| 73 | + // floating labels need label after |
|
| 74 | + if( $args['label_type'] == 'floating' && $type != 'checkbox' ){ |
|
| 75 | + $label_after = true; |
|
| 76 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // Some special sauce for files |
|
| 80 | + if($type=='file' ){ |
|
| 81 | + $label_after = true; // if type file we need the label after |
|
| 82 | + $args['class'] .= ' custom-file-input '; |
|
| 83 | + }elseif($type=='checkbox'){ |
|
| 84 | + $label_after = true; // if type file we need the label after |
|
| 85 | + $args['class'] .= ' custom-control-input '; |
|
| 86 | + }elseif($type=='datepicker' || $type=='timepicker'){ |
|
| 87 | + $type = 'text'; |
|
| 88 | + //$args['class'] .= ' aui-flatpickr bg-initial '; |
|
| 89 | + $args['class'] .= ' bg-initial '; |
|
| 90 | + |
|
| 91 | + $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
|
| 92 | + // enqueue the script |
|
| 93 | + $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 94 | + $aui_settings->enqueue_flatpickr(); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + // open/type |
|
| 99 | + $output .= '<input type="' . $type . '" '; |
|
| 100 | + |
|
| 101 | + // name |
|
| 102 | + if(!empty($args['name'])){ |
|
| 103 | + $output .= ' name="'.esc_attr($args['name']).'" '; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // id |
|
| 107 | + if(!empty($args['id'])){ |
|
| 108 | + $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + // placeholder |
|
| 112 | + if(isset($args['placeholder']) && '' != $args['placeholder'] ){ |
|
| 113 | + $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + // title |
|
| 117 | + if(!empty($args['title'])){ |
|
| 118 | + $output .= ' title="'.esc_attr($args['title']).'" '; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // value |
|
| 122 | + if(!empty($args['value'])){ |
|
| 123 | + $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // checked, for radio and checkboxes |
|
| 127 | + if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){ |
|
| 128 | + $output .= ' checked '; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + // validation text |
|
| 132 | + if(!empty($args['validation_text'])){ |
|
| 133 | + $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
| 134 | + $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // validation_pattern |
|
| 138 | + if(!empty($args['validation_pattern'])){ |
|
| 139 | + $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + // step (for numbers) |
|
| 143 | + if(!empty($args['step'])){ |
|
| 144 | + $output .= ' step="'.$args['step'].'" '; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // required |
|
| 148 | + if(!empty($args['required'])){ |
|
| 149 | + $output .= ' required '; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // class |
|
| 153 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 154 | + $output .= ' class="form-control '.$class.'" '; |
|
| 155 | + |
|
| 156 | + // data-attributes |
|
| 157 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
| 158 | + |
|
| 159 | + // extra attributes |
|
| 160 | + if(!empty($args['extra_attributes'])){ |
|
| 161 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + // close |
|
| 165 | + $output .= ' >'; |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + // label |
|
| 169 | + if(!empty($args['label'])){ |
|
| 170 | + if($type == 'file'){$label_args['class'] .= 'custom-file-label';} |
|
| 171 | + elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';} |
|
| 172 | + $label = self::label( $label_args, $type ); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + // help text |
|
| 176 | + if(!empty($args['help_text'])){ |
|
| 177 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + // set help text in the correct possition |
|
| 182 | + if($label_after){ |
|
| 183 | + $output .= $label . $help_text; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + // some input types need a separate wrap |
|
| 187 | + if($type == 'file') { |
|
| 188 | + $output = self::wrap( array( |
|
| 189 | + 'content' => $output, |
|
| 190 | + 'class' => 'form-group custom-file' |
|
| 191 | + ) ); |
|
| 192 | + }elseif($type == 'checkbox'){ |
|
| 193 | + $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox'; |
|
| 194 | + $output = self::wrap( array( |
|
| 195 | + 'content' => $output, |
|
| 196 | + 'class' => 'custom-control '.$wrap_class |
|
| 197 | + ) ); |
|
| 198 | + |
|
| 199 | + if($args['label_type']=='horizontal'){ |
|
| 200 | + $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>'; |
|
| 201 | + } |
|
| 202 | + }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){ |
|
| 203 | + |
|
| 204 | + |
|
| 205 | + // allow password field to toggle view |
|
| 206 | + $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" |
|
| 207 | 207 | onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\'); |
| 208 | 208 | var $eli = jQuery(this).parent().parent().find(\'input\'); |
| 209 | 209 | if($el.hasClass(\'fa-eye\')) |
| 210 | 210 | {$eli.attr(\'type\',\'text\');} |
| 211 | 211 | else{$eli.attr(\'type\',\'password\');}" |
| 212 | 212 | ><i class="far fa-fw fa-eye-slash"></i></span>'; |
| 213 | - } |
|
| 214 | - |
|
| 215 | - // input group wraps |
|
| 216 | - if($args['input_group_left'] || $args['input_group_right']){ |
|
| 217 | - $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
| 218 | - if($args['input_group_left']){ |
|
| 219 | - $output = self::wrap( array( |
|
| 220 | - 'content' => $output, |
|
| 221 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
| 222 | - 'input_group_left' => $args['input_group_left'], |
|
| 223 | - 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 224 | - ) ); |
|
| 225 | - } |
|
| 226 | - if($args['input_group_right']){ |
|
| 227 | - $output = self::wrap( array( |
|
| 228 | - 'content' => $output, |
|
| 229 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
| 230 | - 'input_group_right' => $args['input_group_right'], |
|
| 231 | - 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 232 | - ) ); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - if(!$label_after){ |
|
| 238 | - $output .= $help_text; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
| 243 | - $output = self::wrap( array( |
|
| 244 | - 'content' => $output, |
|
| 245 | - 'class' => 'col-sm-10', |
|
| 246 | - ) ); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - if(!$label_after){ |
|
| 250 | - $output = $label . $output; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - // wrap |
|
| 254 | - if(!$args['no_wrap']){ |
|
| 255 | - |
|
| 256 | - $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
| 257 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 258 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
| 259 | - $output = self::wrap(array( |
|
| 260 | - 'content' => $output, |
|
| 261 | - 'class' => $wrap_class, |
|
| 262 | - 'element_require' => $args['element_require'], |
|
| 263 | - 'argument_id' => $args['id'] |
|
| 264 | - )); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - return $output; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Build the component. |
|
| 276 | - * |
|
| 277 | - * @param array $args |
|
| 278 | - * |
|
| 279 | - * @return string The rendered component. |
|
| 280 | - */ |
|
| 281 | - public static function textarea($args = array()){ |
|
| 282 | - $defaults = array( |
|
| 283 | - 'name' => '', |
|
| 284 | - 'class' => '', |
|
| 285 | - 'wrap_class' => '', |
|
| 286 | - 'id' => '', |
|
| 287 | - 'placeholder'=> '', |
|
| 288 | - 'title' => '', |
|
| 289 | - 'value' => '', |
|
| 290 | - 'required' => false, |
|
| 291 | - 'label' => '', |
|
| 292 | - 'label_after'=> false, |
|
| 293 | - 'label_class' => '', |
|
| 294 | - 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 295 | - 'help_text' => '', |
|
| 296 | - 'validation_text' => '', |
|
| 297 | - 'validation_pattern' => '', |
|
| 298 | - 'no_wrap' => false, |
|
| 299 | - 'rows' => '', |
|
| 300 | - 'wysiwyg' => false, |
|
| 301 | - 'element_require' => '', // [%element_id%] == "1" |
|
| 302 | - ); |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 306 | - */ |
|
| 307 | - $args = wp_parse_args( $args, $defaults ); |
|
| 308 | - $output = ''; |
|
| 309 | - |
|
| 310 | - // hidden label option needs to be empty |
|
| 311 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 312 | - |
|
| 313 | - // floating labels don't work with wysiwyg so set it as top |
|
| 314 | - if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){ |
|
| 315 | - $args['label_type'] = 'top'; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - $label_after = $args['label_after']; |
|
| 319 | - |
|
| 320 | - // floating labels need label after |
|
| 321 | - if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){ |
|
| 322 | - $label_after = true; |
|
| 323 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - // label |
|
| 327 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
| 328 | - }elseif(!empty($args['label']) && !$label_after){ |
|
| 329 | - $label_args = array( |
|
| 330 | - 'title'=> $args['label'], |
|
| 331 | - 'for'=> $args['id'], |
|
| 332 | - 'class' => $args['label_class']." ", |
|
| 333 | - 'label_type' => $args['label_type'] |
|
| 334 | - ); |
|
| 335 | - $output .= self::label( $label_args ); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - // maybe horizontal label |
|
| 339 | - if($args['label_type']=='horizontal'){ |
|
| 340 | - $output .= '<div class="col-sm-10">'; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - if(!empty($args['wysiwyg'])){ |
|
| 344 | - ob_start(); |
|
| 345 | - $content = $args['value']; |
|
| 346 | - $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
|
| 347 | - $settings = array( |
|
| 348 | - 'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4, |
|
| 349 | - 'quicktags' => false, |
|
| 350 | - 'media_buttons' => false, |
|
| 351 | - 'editor_class' => 'form-control', |
|
| 352 | - 'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']), |
|
| 353 | - 'teeny' => true, |
|
| 354 | - ); |
|
| 355 | - |
|
| 356 | - // maybe set settings if array |
|
| 357 | - if(is_array($args['wysiwyg'])){ |
|
| 358 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - wp_editor( $content, $editor_id, $settings ); |
|
| 362 | - $output .= ob_get_clean(); |
|
| 363 | - }else{ |
|
| 364 | - |
|
| 365 | - // open |
|
| 366 | - $output .= '<textarea '; |
|
| 367 | - |
|
| 368 | - // name |
|
| 369 | - if(!empty($args['name'])){ |
|
| 370 | - $output .= ' name="'.sanitize_html_class($args['name']).'" '; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - // id |
|
| 374 | - if(!empty($args['id'])){ |
|
| 375 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - // placeholder |
|
| 379 | - if(isset($args['placeholder']) && '' != $args['placeholder']){ |
|
| 380 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - // title |
|
| 384 | - if(!empty($args['title'])){ |
|
| 385 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - // validation text |
|
| 389 | - if(!empty($args['validation_text'])){ |
|
| 390 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
| 391 | - $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - // validation_pattern |
|
| 395 | - if(!empty($args['validation_pattern'])){ |
|
| 396 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - // required |
|
| 400 | - if(!empty($args['required'])){ |
|
| 401 | - $output .= ' required '; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - // rows |
|
| 405 | - if(!empty($args['rows'])){ |
|
| 406 | - $output .= ' rows="'.absint($args['rows']).'" '; |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - |
|
| 410 | - // class |
|
| 411 | - $class = !empty($args['class']) ? $args['class'] : ''; |
|
| 412 | - $output .= ' class="form-control '.$class.'" '; |
|
| 413 | - |
|
| 414 | - |
|
| 415 | - // close tag |
|
| 416 | - $output .= ' >'; |
|
| 417 | - |
|
| 418 | - // value |
|
| 419 | - if(!empty($args['value'])){ |
|
| 420 | - $output .= sanitize_textarea_field($args['value']); |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - // closing tag |
|
| 424 | - $output .= '</textarea>'; |
|
| 425 | - |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - if(!empty($args['label']) && $label_after){ |
|
| 429 | - $label_args = array( |
|
| 430 | - 'title'=> $args['label'], |
|
| 431 | - 'for'=> $args['id'], |
|
| 432 | - 'class' => $args['label_class']." ", |
|
| 433 | - 'label_type' => $args['label_type'] |
|
| 434 | - ); |
|
| 435 | - $output .= self::label( $label_args ); |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - // help text |
|
| 439 | - if(!empty($args['help_text'])){ |
|
| 440 | - $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - // maybe horizontal label |
|
| 444 | - if($args['label_type']=='horizontal'){ |
|
| 445 | - $output .= '</div>'; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - |
|
| 449 | - // wrap |
|
| 450 | - if(!$args['no_wrap']){ |
|
| 451 | - $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group'; |
|
| 452 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 453 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
| 454 | - $output = self::wrap(array( |
|
| 455 | - 'content' => $output, |
|
| 456 | - 'class' => $wrap_class, |
|
| 457 | - 'element_require' => $args['element_require'], |
|
| 458 | - 'argument_id' => $args['id'] |
|
| 459 | - )); |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - |
|
| 463 | - return $output; |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - public static function label($args = array(), $type = ''){ |
|
| 467 | - //<label for="exampleInputEmail1">Email address</label> |
|
| 468 | - $defaults = array( |
|
| 469 | - 'title' => 'div', |
|
| 470 | - 'for' => '', |
|
| 471 | - 'class' => '', |
|
| 472 | - 'label_type' => '', // empty = hidden, top, horizontal |
|
| 473 | - ); |
|
| 474 | - |
|
| 475 | - /** |
|
| 476 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 477 | - */ |
|
| 478 | - $args = wp_parse_args( $args, $defaults ); |
|
| 479 | - $output = ''; |
|
| 480 | - |
|
| 481 | - if($args['title']){ |
|
| 482 | - |
|
| 483 | - // maybe hide labels //@todo set a global option for visibility class |
|
| 484 | - if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){ |
|
| 485 | - $class = $args['class']; |
|
| 486 | - }else{ |
|
| 487 | - $class = 'sr-only '.$args['class']; |
|
| 488 | - } |
|
| 489 | - |
|
| 490 | - // maybe horizontal |
|
| 491 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
| 492 | - $class .= ' col-sm-2 col-form-label'; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - // open |
|
| 496 | - $output .= '<label '; |
|
| 497 | - |
|
| 498 | - // for |
|
| 499 | - if(!empty($args['for'])){ |
|
| 500 | - $output .= ' for="'.sanitize_text_field($args['for']).'" '; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - // class |
|
| 504 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
| 505 | - $output .= ' class="'.$class.'" '; |
|
| 506 | - |
|
| 507 | - // close |
|
| 508 | - $output .= '>'; |
|
| 509 | - |
|
| 510 | - |
|
| 511 | - // title, don't escape fully as can contain html |
|
| 512 | - if(!empty($args['title'])){ |
|
| 513 | - $output .= wp_kses_post($args['title']); |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - // close wrap |
|
| 517 | - $output .= '</label>'; |
|
| 518 | - |
|
| 519 | - |
|
| 520 | - } |
|
| 521 | - |
|
| 522 | - |
|
| 523 | - return $output; |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - /** |
|
| 527 | - * Wrap some content in a HTML wrapper. |
|
| 528 | - * |
|
| 529 | - * @param array $args |
|
| 530 | - * |
|
| 531 | - * @return string |
|
| 532 | - */ |
|
| 533 | - public static function wrap($args = array()){ |
|
| 534 | - $defaults = array( |
|
| 535 | - 'type' => 'div', |
|
| 536 | - 'class' => 'form-group', |
|
| 537 | - 'content' => '', |
|
| 538 | - 'input_group_left' => '', |
|
| 539 | - 'input_group_right' => '', |
|
| 540 | - 'input_group_left_inside' => false, |
|
| 541 | - 'input_group_right_inside' => false, |
|
| 542 | - 'element_require' => '', |
|
| 543 | - 'argument_id' => '', |
|
| 544 | - ); |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 548 | - */ |
|
| 549 | - $args = wp_parse_args( $args, $defaults ); |
|
| 550 | - $output = ''; |
|
| 551 | - if($args['type']){ |
|
| 552 | - |
|
| 553 | - // open |
|
| 554 | - $output .= '<'.sanitize_html_class($args['type']); |
|
| 555 | - |
|
| 556 | - // element require |
|
| 557 | - if(!empty($args['element_require'])){ |
|
| 558 | - $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
| 559 | - $args['class'] .= " aui-conditional-field"; |
|
| 560 | - } |
|
| 561 | - |
|
| 562 | - // argument_id |
|
| 563 | - if( !empty($args['argument_id']) ){ |
|
| 564 | - $output .= ' data-argument="'.esc_attr($args['argument_id']).'"'; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - // class |
|
| 568 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 569 | - $output .= ' class="'.$class.'" '; |
|
| 570 | - |
|
| 571 | - // close wrap |
|
| 572 | - $output .= ' >'; |
|
| 573 | - |
|
| 574 | - |
|
| 575 | - // Input group left |
|
| 576 | - if(!empty($args['input_group_left'])){ |
|
| 577 | - $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
| 578 | - $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>'; |
|
| 579 | - $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>'; |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - // content |
|
| 583 | - $output .= $args['content']; |
|
| 584 | - |
|
| 585 | - // Input group right |
|
| 586 | - if(!empty($args['input_group_right'])){ |
|
| 587 | - $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
| 588 | - $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>'; |
|
| 589 | - $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>'; |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - |
|
| 593 | - // close wrap |
|
| 594 | - $output .= '</'.sanitize_html_class($args['type']).'>'; |
|
| 595 | - |
|
| 596 | - |
|
| 597 | - }else{ |
|
| 598 | - $output = $args['content']; |
|
| 599 | - } |
|
| 600 | - |
|
| 601 | - return $output; |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - /** |
|
| 605 | - * Build the component. |
|
| 606 | - * |
|
| 607 | - * @param array $args |
|
| 608 | - * |
|
| 609 | - * @return string The rendered component. |
|
| 610 | - */ |
|
| 611 | - public static function select($args = array()){ |
|
| 612 | - $defaults = array( |
|
| 613 | - 'class' => '', |
|
| 614 | - 'wrap_class' => '', |
|
| 615 | - 'id' => '', |
|
| 616 | - 'title' => '', |
|
| 617 | - 'value' => '', // can be an array or a string |
|
| 618 | - 'required' => false, |
|
| 619 | - 'label' => '', |
|
| 620 | - 'label_after'=> false, |
|
| 621 | - 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 622 | - 'label_class' => '', |
|
| 623 | - 'help_text' => '', |
|
| 624 | - 'placeholder'=> '', |
|
| 625 | - 'options' => array(), // array or string |
|
| 626 | - 'icon' => '', |
|
| 627 | - 'multiple' => false, |
|
| 628 | - 'select2' => false, |
|
| 629 | - 'no_wrap' => false, |
|
| 630 | - 'element_require' => '', // [%element_id%] == "1" |
|
| 631 | - 'extra_attributes' => array(), // an array of extra attributes |
|
| 632 | - ); |
|
| 633 | - |
|
| 634 | - /** |
|
| 635 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 636 | - */ |
|
| 637 | - $args = wp_parse_args( $args, $defaults ); |
|
| 638 | - $output = ''; |
|
| 639 | - |
|
| 640 | - // for now lets hide floating labels |
|
| 641 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';} |
|
| 642 | - |
|
| 643 | - // hidden label option needs to be empty |
|
| 644 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 645 | - |
|
| 646 | - |
|
| 647 | - $label_after = $args['label_after']; |
|
| 648 | - |
|
| 649 | - // floating labels need label after |
|
| 650 | - if( $args['label_type'] == 'floating' ){ |
|
| 651 | - $label_after = true; |
|
| 652 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 653 | - } |
|
| 654 | - |
|
| 655 | - // Maybe setup select2 |
|
| 656 | - $is_select2 = false; |
|
| 657 | - if(!empty($args['select2'])){ |
|
| 658 | - $args['class'] .= ' aui-select2'; |
|
| 659 | - $is_select2 = true; |
|
| 660 | - }elseif( strpos($args['class'], 'aui-select2') !== false){ |
|
| 661 | - $is_select2 = true; |
|
| 662 | - } |
|
| 663 | - |
|
| 664 | - // select2 tags |
|
| 665 | - if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason |
|
| 666 | - $args['data-tags'] = 'true'; |
|
| 667 | - $args['data-token-separators'] = "[',']"; |
|
| 668 | - $args['multiple'] = true; |
|
| 669 | - } |
|
| 670 | - |
|
| 671 | - // select2 placeholder |
|
| 672 | - if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){ |
|
| 673 | - $args['data-placeholder'] = esc_attr($args['placeholder']); |
|
| 674 | - $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - // label |
|
| 678 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
| 679 | - }elseif(!empty($args['label']) && !$label_after){ |
|
| 680 | - $label_args = array( |
|
| 681 | - 'title'=> $args['label'], |
|
| 682 | - 'for'=> $args['id'], |
|
| 683 | - 'class' => $args['label_class']." ", |
|
| 684 | - 'label_type' => $args['label_type'] |
|
| 685 | - ); |
|
| 686 | - $output .= self::label($label_args); |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - // maybe horizontal label |
|
| 690 | - if($args['label_type']=='horizontal'){ |
|
| 691 | - $output .= '<div class="col-sm-10">'; |
|
| 692 | - } |
|
| 693 | - |
|
| 694 | - // open/type |
|
| 695 | - $output .= '<select '; |
|
| 696 | - |
|
| 697 | - // style |
|
| 698 | - if($is_select2){ |
|
| 699 | - $output .= " style='width:100%;' "; |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - // element require |
|
| 703 | - if(!empty($args['element_require'])){ |
|
| 704 | - $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
| 705 | - $args['class'] .= " aui-conditional-field"; |
|
| 706 | - } |
|
| 707 | - |
|
| 708 | - // class |
|
| 709 | - $class = !empty($args['class']) ? $args['class'] : ''; |
|
| 710 | - $output .= AUI_Component_Helper::class_attr('custom-select '.$class); |
|
| 711 | - |
|
| 712 | - // name |
|
| 713 | - if(!empty($args['name'])){ |
|
| 714 | - $output .= AUI_Component_Helper::name($args['name'],$args['multiple']); |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - // id |
|
| 718 | - if(!empty($args['id'])){ |
|
| 719 | - $output .= AUI_Component_Helper::id($args['id']); |
|
| 720 | - } |
|
| 721 | - |
|
| 722 | - // title |
|
| 723 | - if(!empty($args['title'])){ |
|
| 724 | - $output .= AUI_Component_Helper::title($args['title']); |
|
| 725 | - } |
|
| 726 | - |
|
| 727 | - // data-attributes |
|
| 728 | - $output .= AUI_Component_Helper::data_attributes($args); |
|
| 729 | - |
|
| 730 | - // aria-attributes |
|
| 731 | - $output .= AUI_Component_Helper::aria_attributes($args); |
|
| 732 | - |
|
| 733 | - // extra attributes |
|
| 734 | - if(!empty($args['extra_attributes'])){ |
|
| 735 | - $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 736 | - } |
|
| 737 | - |
|
| 738 | - // required |
|
| 739 | - if(!empty($args['required'])){ |
|
| 740 | - $output .= ' required '; |
|
| 741 | - } |
|
| 742 | - |
|
| 743 | - // multiple |
|
| 744 | - if(!empty($args['multiple'])){ |
|
| 745 | - $output .= ' multiple '; |
|
| 746 | - } |
|
| 747 | - |
|
| 748 | - // close opening tag |
|
| 749 | - $output .= ' >'; |
|
| 750 | - |
|
| 751 | - // placeholder |
|
| 752 | - if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){ |
|
| 753 | - $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>'; |
|
| 754 | - }elseif($is_select2 && !empty($args['placeholder'])){ |
|
| 755 | - $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - // Options |
|
| 759 | - if(!empty($args['options'])){ |
|
| 760 | - |
|
| 761 | - if(!is_array($args['options'])){ |
|
| 762 | - $output .= $args['options']; // not the preferred way but an option |
|
| 763 | - }else{ |
|
| 764 | - foreach($args['options'] as $val => $name){ |
|
| 765 | - $selected = ''; |
|
| 766 | - if(is_array($name)){ |
|
| 767 | - if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
|
| 768 | - $option_label = isset($name['label']) ? $name['label'] : ''; |
|
| 769 | - |
|
| 770 | - $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
| 771 | - } else { |
|
| 772 | - $option_label = isset($name['label']) ? $name['label'] : ''; |
|
| 773 | - $option_value = isset($name['value']) ? $name['value'] : ''; |
|
| 774 | - if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){ |
|
| 775 | - $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
|
| 776 | - } elseif(!empty($args['value'])) { |
|
| 777 | - $selected = selected($option_value,stripslashes_deep($args['value']), false); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
|
| 781 | - } |
|
| 782 | - }else{ |
|
| 783 | - if(!empty($args['value'])){ |
|
| 784 | - if(is_array($args['value'])){ |
|
| 785 | - $selected = in_array($val,$args['value']) ? 'selected="selected"' : ''; |
|
| 786 | - } elseif(!empty($args['value'])) { |
|
| 787 | - $selected = selected( $args['value'], $val, false); |
|
| 788 | - } |
|
| 789 | - } |
|
| 790 | - $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
| 791 | - } |
|
| 792 | - } |
|
| 793 | - } |
|
| 794 | - |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - // closing tag |
|
| 798 | - $output .= '</select>'; |
|
| 799 | - |
|
| 800 | - if(!empty($args['label']) && $label_after){ |
|
| 801 | - $label_args = array( |
|
| 802 | - 'title'=> $args['label'], |
|
| 803 | - 'for'=> $args['id'], |
|
| 804 | - 'class' => $args['label_class']." ", |
|
| 805 | - 'label_type' => $args['label_type'] |
|
| 806 | - ); |
|
| 807 | - $output .= self::label($label_args); |
|
| 808 | - } |
|
| 809 | - |
|
| 810 | - // help text |
|
| 811 | - if(!empty($args['help_text'])){ |
|
| 812 | - $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
| 813 | - } |
|
| 814 | - |
|
| 815 | - // maybe horizontal label |
|
| 816 | - if($args['label_type']=='horizontal'){ |
|
| 817 | - $output .= '</div>'; |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - |
|
| 821 | - // wrap |
|
| 822 | - if(!$args['no_wrap']){ |
|
| 823 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
| 824 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
| 825 | - $output = self::wrap(array( |
|
| 826 | - 'content' => $output, |
|
| 827 | - 'class' => $wrap_class, |
|
| 828 | - 'element_require' => $args['element_require'], |
|
| 829 | - 'argument_id' => $args['id'] |
|
| 830 | - )); |
|
| 831 | - } |
|
| 832 | - |
|
| 833 | - |
|
| 834 | - return $output; |
|
| 835 | - } |
|
| 836 | - |
|
| 837 | - /** |
|
| 838 | - * Build the component. |
|
| 839 | - * |
|
| 840 | - * @param array $args |
|
| 841 | - * |
|
| 842 | - * @return string The rendered component. |
|
| 843 | - */ |
|
| 844 | - public static function radio($args = array()){ |
|
| 845 | - $defaults = array( |
|
| 846 | - 'class' => '', |
|
| 847 | - 'wrap_class' => '', |
|
| 848 | - 'id' => '', |
|
| 849 | - 'title' => '', |
|
| 850 | - 'horizontal' => false, // sets the lable horizontal |
|
| 851 | - 'value' => '', |
|
| 852 | - 'label' => '', |
|
| 853 | - 'label_class'=> '', |
|
| 854 | - 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 855 | - 'inline' => true, |
|
| 856 | - 'required' => false, |
|
| 857 | - 'options' => array(), |
|
| 858 | - 'icon' => '', |
|
| 859 | - 'no_wrap' => false, |
|
| 860 | - 'element_require' => '', // [%element_id%] == "1" |
|
| 861 | - 'extra_attributes' => array() // an array of extra attributes |
|
| 862 | - ); |
|
| 863 | - |
|
| 864 | - /** |
|
| 865 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 866 | - */ |
|
| 867 | - $args = wp_parse_args( $args, $defaults ); |
|
| 868 | - |
|
| 869 | - // for now lets use horizontal for floating |
|
| 870 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';} |
|
| 871 | - |
|
| 872 | - $label_args = array( |
|
| 873 | - 'title'=> $args['label'], |
|
| 874 | - 'class' => $args['label_class']." pt-0 ", |
|
| 875 | - 'label_type' => $args['label_type'] |
|
| 876 | - ); |
|
| 877 | - |
|
| 878 | - $output = ''; |
|
| 879 | - |
|
| 880 | - |
|
| 881 | - |
|
| 882 | - // label before |
|
| 883 | - if(!empty($args['label'])){ |
|
| 884 | - $output .= self::label( $label_args, 'radio' ); |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - // maybe horizontal label |
|
| 888 | - if($args['label_type']=='horizontal'){ |
|
| 889 | - $output .= '<div class="col-sm-10">'; |
|
| 890 | - } |
|
| 891 | - |
|
| 892 | - if(!empty($args['options'])){ |
|
| 893 | - $count = 0; |
|
| 894 | - foreach($args['options'] as $value => $label){ |
|
| 895 | - $option_args = $args; |
|
| 896 | - $option_args['value'] = $value; |
|
| 897 | - $option_args['label'] = $label; |
|
| 898 | - $option_args['checked'] = $value == $args['value'] ? true : false; |
|
| 899 | - $output .= self::radio_option($option_args,$count); |
|
| 900 | - $count++; |
|
| 901 | - } |
|
| 902 | - } |
|
| 903 | - |
|
| 904 | - // maybe horizontal label |
|
| 905 | - if($args['label_type']=='horizontal'){ |
|
| 906 | - $output .= '</div>'; |
|
| 907 | - } |
|
| 908 | - |
|
| 909 | - |
|
| 910 | - // wrap |
|
| 911 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
| 912 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
| 913 | - $output = self::wrap(array( |
|
| 914 | - 'content' => $output, |
|
| 915 | - 'class' => $wrap_class, |
|
| 916 | - 'element_require' => $args['element_require'], |
|
| 917 | - 'argument_id' => $args['id'] |
|
| 918 | - )); |
|
| 919 | - |
|
| 920 | - |
|
| 921 | - return $output; |
|
| 922 | - } |
|
| 923 | - |
|
| 924 | - /** |
|
| 925 | - * Build the component. |
|
| 926 | - * |
|
| 927 | - * @param array $args |
|
| 928 | - * |
|
| 929 | - * @return string The rendered component. |
|
| 930 | - */ |
|
| 931 | - public static function radio_option($args = array(),$count = ''){ |
|
| 932 | - $defaults = array( |
|
| 933 | - 'class' => '', |
|
| 934 | - 'id' => '', |
|
| 935 | - 'title' => '', |
|
| 936 | - 'value' => '', |
|
| 937 | - 'required' => false, |
|
| 938 | - 'inline' => true, |
|
| 939 | - 'label' => '', |
|
| 940 | - 'options' => array(), |
|
| 941 | - 'icon' => '', |
|
| 942 | - 'no_wrap' => false, |
|
| 943 | - 'extra_attributes' => array() // an array of extra attributes |
|
| 944 | - ); |
|
| 945 | - |
|
| 946 | - /** |
|
| 947 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 948 | - */ |
|
| 949 | - $args = wp_parse_args( $args, $defaults ); |
|
| 950 | - |
|
| 951 | - $output = ''; |
|
| 952 | - |
|
| 953 | - // open/type |
|
| 954 | - $output .= '<input type="radio"'; |
|
| 955 | - |
|
| 956 | - // class |
|
| 957 | - $output .= ' class="form-check-input" '; |
|
| 958 | - |
|
| 959 | - // name |
|
| 960 | - if(!empty($args['name'])){ |
|
| 961 | - $output .= AUI_Component_Helper::name($args['name']); |
|
| 962 | - } |
|
| 963 | - |
|
| 964 | - // id |
|
| 965 | - if(!empty($args['id'])){ |
|
| 966 | - $output .= AUI_Component_Helper::id($args['id'].$count); |
|
| 967 | - } |
|
| 968 | - |
|
| 969 | - // title |
|
| 970 | - if(!empty($args['title'])){ |
|
| 971 | - $output .= AUI_Component_Helper::title($args['title']); |
|
| 972 | - } |
|
| 973 | - |
|
| 974 | - // value |
|
| 975 | - if(isset($args['value'])){ |
|
| 976 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - // checked, for radio and checkboxes |
|
| 980 | - if( $args['checked'] ){ |
|
| 981 | - $output .= ' checked '; |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - // data-attributes |
|
| 985 | - $output .= AUI_Component_Helper::data_attributes($args); |
|
| 986 | - |
|
| 987 | - // aria-attributes |
|
| 988 | - $output .= AUI_Component_Helper::aria_attributes($args); |
|
| 989 | - |
|
| 990 | - // extra attributes |
|
| 991 | - if(!empty($args['extra_attributes'])){ |
|
| 992 | - $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 993 | - } |
|
| 994 | - |
|
| 995 | - // required |
|
| 996 | - if(!empty($args['required'])){ |
|
| 997 | - $output .= ' required '; |
|
| 998 | - } |
|
| 999 | - |
|
| 1000 | - // close opening tag |
|
| 1001 | - $output .= ' >'; |
|
| 1002 | - |
|
| 1003 | - // label |
|
| 1004 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
| 1005 | - }elseif(!empty($args['label'])){ |
|
| 1006 | - $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio'); |
|
| 1007 | - } |
|
| 1008 | - |
|
| 1009 | - // wrap |
|
| 1010 | - if(!$args['no_wrap']){ |
|
| 1011 | - $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
|
| 1012 | - $output = self::wrap(array( |
|
| 1013 | - 'content' => $output, |
|
| 1014 | - 'class' => $wrap_class |
|
| 1015 | - )); |
|
| 1016 | - } |
|
| 1017 | - |
|
| 1018 | - |
|
| 1019 | - return $output; |
|
| 1020 | - } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + // input group wraps |
|
| 216 | + if($args['input_group_left'] || $args['input_group_right']){ |
|
| 217 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
| 218 | + if($args['input_group_left']){ |
|
| 219 | + $output = self::wrap( array( |
|
| 220 | + 'content' => $output, |
|
| 221 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
| 222 | + 'input_group_left' => $args['input_group_left'], |
|
| 223 | + 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 224 | + ) ); |
|
| 225 | + } |
|
| 226 | + if($args['input_group_right']){ |
|
| 227 | + $output = self::wrap( array( |
|
| 228 | + 'content' => $output, |
|
| 229 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
| 230 | + 'input_group_right' => $args['input_group_right'], |
|
| 231 | + 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 232 | + ) ); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + if(!$label_after){ |
|
| 238 | + $output .= $help_text; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
| 243 | + $output = self::wrap( array( |
|
| 244 | + 'content' => $output, |
|
| 245 | + 'class' => 'col-sm-10', |
|
| 246 | + ) ); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + if(!$label_after){ |
|
| 250 | + $output = $label . $output; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + // wrap |
|
| 254 | + if(!$args['no_wrap']){ |
|
| 255 | + |
|
| 256 | + $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
| 257 | + $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 258 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
| 259 | + $output = self::wrap(array( |
|
| 260 | + 'content' => $output, |
|
| 261 | + 'class' => $wrap_class, |
|
| 262 | + 'element_require' => $args['element_require'], |
|
| 263 | + 'argument_id' => $args['id'] |
|
| 264 | + )); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + return $output; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Build the component. |
|
| 276 | + * |
|
| 277 | + * @param array $args |
|
| 278 | + * |
|
| 279 | + * @return string The rendered component. |
|
| 280 | + */ |
|
| 281 | + public static function textarea($args = array()){ |
|
| 282 | + $defaults = array( |
|
| 283 | + 'name' => '', |
|
| 284 | + 'class' => '', |
|
| 285 | + 'wrap_class' => '', |
|
| 286 | + 'id' => '', |
|
| 287 | + 'placeholder'=> '', |
|
| 288 | + 'title' => '', |
|
| 289 | + 'value' => '', |
|
| 290 | + 'required' => false, |
|
| 291 | + 'label' => '', |
|
| 292 | + 'label_after'=> false, |
|
| 293 | + 'label_class' => '', |
|
| 294 | + 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 295 | + 'help_text' => '', |
|
| 296 | + 'validation_text' => '', |
|
| 297 | + 'validation_pattern' => '', |
|
| 298 | + 'no_wrap' => false, |
|
| 299 | + 'rows' => '', |
|
| 300 | + 'wysiwyg' => false, |
|
| 301 | + 'element_require' => '', // [%element_id%] == "1" |
|
| 302 | + ); |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 306 | + */ |
|
| 307 | + $args = wp_parse_args( $args, $defaults ); |
|
| 308 | + $output = ''; |
|
| 309 | + |
|
| 310 | + // hidden label option needs to be empty |
|
| 311 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 312 | + |
|
| 313 | + // floating labels don't work with wysiwyg so set it as top |
|
| 314 | + if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){ |
|
| 315 | + $args['label_type'] = 'top'; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + $label_after = $args['label_after']; |
|
| 319 | + |
|
| 320 | + // floating labels need label after |
|
| 321 | + if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){ |
|
| 322 | + $label_after = true; |
|
| 323 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + // label |
|
| 327 | + if(!empty($args['label']) && is_array($args['label'])){ |
|
| 328 | + }elseif(!empty($args['label']) && !$label_after){ |
|
| 329 | + $label_args = array( |
|
| 330 | + 'title'=> $args['label'], |
|
| 331 | + 'for'=> $args['id'], |
|
| 332 | + 'class' => $args['label_class']." ", |
|
| 333 | + 'label_type' => $args['label_type'] |
|
| 334 | + ); |
|
| 335 | + $output .= self::label( $label_args ); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + // maybe horizontal label |
|
| 339 | + if($args['label_type']=='horizontal'){ |
|
| 340 | + $output .= '<div class="col-sm-10">'; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + if(!empty($args['wysiwyg'])){ |
|
| 344 | + ob_start(); |
|
| 345 | + $content = $args['value']; |
|
| 346 | + $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
|
| 347 | + $settings = array( |
|
| 348 | + 'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4, |
|
| 349 | + 'quicktags' => false, |
|
| 350 | + 'media_buttons' => false, |
|
| 351 | + 'editor_class' => 'form-control', |
|
| 352 | + 'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']), |
|
| 353 | + 'teeny' => true, |
|
| 354 | + ); |
|
| 355 | + |
|
| 356 | + // maybe set settings if array |
|
| 357 | + if(is_array($args['wysiwyg'])){ |
|
| 358 | + $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + wp_editor( $content, $editor_id, $settings ); |
|
| 362 | + $output .= ob_get_clean(); |
|
| 363 | + }else{ |
|
| 364 | + |
|
| 365 | + // open |
|
| 366 | + $output .= '<textarea '; |
|
| 367 | + |
|
| 368 | + // name |
|
| 369 | + if(!empty($args['name'])){ |
|
| 370 | + $output .= ' name="'.sanitize_html_class($args['name']).'" '; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + // id |
|
| 374 | + if(!empty($args['id'])){ |
|
| 375 | + $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + // placeholder |
|
| 379 | + if(isset($args['placeholder']) && '' != $args['placeholder']){ |
|
| 380 | + $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + // title |
|
| 384 | + if(!empty($args['title'])){ |
|
| 385 | + $output .= ' title="'.esc_attr($args['title']).'" '; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + // validation text |
|
| 389 | + if(!empty($args['validation_text'])){ |
|
| 390 | + $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
| 391 | + $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + // validation_pattern |
|
| 395 | + if(!empty($args['validation_pattern'])){ |
|
| 396 | + $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + // required |
|
| 400 | + if(!empty($args['required'])){ |
|
| 401 | + $output .= ' required '; |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + // rows |
|
| 405 | + if(!empty($args['rows'])){ |
|
| 406 | + $output .= ' rows="'.absint($args['rows']).'" '; |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + |
|
| 410 | + // class |
|
| 411 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
| 412 | + $output .= ' class="form-control '.$class.'" '; |
|
| 413 | + |
|
| 414 | + |
|
| 415 | + // close tag |
|
| 416 | + $output .= ' >'; |
|
| 417 | + |
|
| 418 | + // value |
|
| 419 | + if(!empty($args['value'])){ |
|
| 420 | + $output .= sanitize_textarea_field($args['value']); |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + // closing tag |
|
| 424 | + $output .= '</textarea>'; |
|
| 425 | + |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + if(!empty($args['label']) && $label_after){ |
|
| 429 | + $label_args = array( |
|
| 430 | + 'title'=> $args['label'], |
|
| 431 | + 'for'=> $args['id'], |
|
| 432 | + 'class' => $args['label_class']." ", |
|
| 433 | + 'label_type' => $args['label_type'] |
|
| 434 | + ); |
|
| 435 | + $output .= self::label( $label_args ); |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + // help text |
|
| 439 | + if(!empty($args['help_text'])){ |
|
| 440 | + $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + // maybe horizontal label |
|
| 444 | + if($args['label_type']=='horizontal'){ |
|
| 445 | + $output .= '</div>'; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + |
|
| 449 | + // wrap |
|
| 450 | + if(!$args['no_wrap']){ |
|
| 451 | + $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group'; |
|
| 452 | + $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 453 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
| 454 | + $output = self::wrap(array( |
|
| 455 | + 'content' => $output, |
|
| 456 | + 'class' => $wrap_class, |
|
| 457 | + 'element_require' => $args['element_require'], |
|
| 458 | + 'argument_id' => $args['id'] |
|
| 459 | + )); |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + |
|
| 463 | + return $output; |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + public static function label($args = array(), $type = ''){ |
|
| 467 | + //<label for="exampleInputEmail1">Email address</label> |
|
| 468 | + $defaults = array( |
|
| 469 | + 'title' => 'div', |
|
| 470 | + 'for' => '', |
|
| 471 | + 'class' => '', |
|
| 472 | + 'label_type' => '', // empty = hidden, top, horizontal |
|
| 473 | + ); |
|
| 474 | + |
|
| 475 | + /** |
|
| 476 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 477 | + */ |
|
| 478 | + $args = wp_parse_args( $args, $defaults ); |
|
| 479 | + $output = ''; |
|
| 480 | + |
|
| 481 | + if($args['title']){ |
|
| 482 | + |
|
| 483 | + // maybe hide labels //@todo set a global option for visibility class |
|
| 484 | + if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){ |
|
| 485 | + $class = $args['class']; |
|
| 486 | + }else{ |
|
| 487 | + $class = 'sr-only '.$args['class']; |
|
| 488 | + } |
|
| 489 | + |
|
| 490 | + // maybe horizontal |
|
| 491 | + if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
| 492 | + $class .= ' col-sm-2 col-form-label'; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + // open |
|
| 496 | + $output .= '<label '; |
|
| 497 | + |
|
| 498 | + // for |
|
| 499 | + if(!empty($args['for'])){ |
|
| 500 | + $output .= ' for="'.sanitize_text_field($args['for']).'" '; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + // class |
|
| 504 | + $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
| 505 | + $output .= ' class="'.$class.'" '; |
|
| 506 | + |
|
| 507 | + // close |
|
| 508 | + $output .= '>'; |
|
| 509 | + |
|
| 510 | + |
|
| 511 | + // title, don't escape fully as can contain html |
|
| 512 | + if(!empty($args['title'])){ |
|
| 513 | + $output .= wp_kses_post($args['title']); |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + // close wrap |
|
| 517 | + $output .= '</label>'; |
|
| 518 | + |
|
| 519 | + |
|
| 520 | + } |
|
| 521 | + |
|
| 522 | + |
|
| 523 | + return $output; |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + /** |
|
| 527 | + * Wrap some content in a HTML wrapper. |
|
| 528 | + * |
|
| 529 | + * @param array $args |
|
| 530 | + * |
|
| 531 | + * @return string |
|
| 532 | + */ |
|
| 533 | + public static function wrap($args = array()){ |
|
| 534 | + $defaults = array( |
|
| 535 | + 'type' => 'div', |
|
| 536 | + 'class' => 'form-group', |
|
| 537 | + 'content' => '', |
|
| 538 | + 'input_group_left' => '', |
|
| 539 | + 'input_group_right' => '', |
|
| 540 | + 'input_group_left_inside' => false, |
|
| 541 | + 'input_group_right_inside' => false, |
|
| 542 | + 'element_require' => '', |
|
| 543 | + 'argument_id' => '', |
|
| 544 | + ); |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 548 | + */ |
|
| 549 | + $args = wp_parse_args( $args, $defaults ); |
|
| 550 | + $output = ''; |
|
| 551 | + if($args['type']){ |
|
| 552 | + |
|
| 553 | + // open |
|
| 554 | + $output .= '<'.sanitize_html_class($args['type']); |
|
| 555 | + |
|
| 556 | + // element require |
|
| 557 | + if(!empty($args['element_require'])){ |
|
| 558 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
| 559 | + $args['class'] .= " aui-conditional-field"; |
|
| 560 | + } |
|
| 561 | + |
|
| 562 | + // argument_id |
|
| 563 | + if( !empty($args['argument_id']) ){ |
|
| 564 | + $output .= ' data-argument="'.esc_attr($args['argument_id']).'"'; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + // class |
|
| 568 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 569 | + $output .= ' class="'.$class.'" '; |
|
| 570 | + |
|
| 571 | + // close wrap |
|
| 572 | + $output .= ' >'; |
|
| 573 | + |
|
| 574 | + |
|
| 575 | + // Input group left |
|
| 576 | + if(!empty($args['input_group_left'])){ |
|
| 577 | + $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
| 578 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>'; |
|
| 579 | + $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>'; |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + // content |
|
| 583 | + $output .= $args['content']; |
|
| 584 | + |
|
| 585 | + // Input group right |
|
| 586 | + if(!empty($args['input_group_right'])){ |
|
| 587 | + $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
| 588 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>'; |
|
| 589 | + $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>'; |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + |
|
| 593 | + // close wrap |
|
| 594 | + $output .= '</'.sanitize_html_class($args['type']).'>'; |
|
| 595 | + |
|
| 596 | + |
|
| 597 | + }else{ |
|
| 598 | + $output = $args['content']; |
|
| 599 | + } |
|
| 600 | + |
|
| 601 | + return $output; |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + /** |
|
| 605 | + * Build the component. |
|
| 606 | + * |
|
| 607 | + * @param array $args |
|
| 608 | + * |
|
| 609 | + * @return string The rendered component. |
|
| 610 | + */ |
|
| 611 | + public static function select($args = array()){ |
|
| 612 | + $defaults = array( |
|
| 613 | + 'class' => '', |
|
| 614 | + 'wrap_class' => '', |
|
| 615 | + 'id' => '', |
|
| 616 | + 'title' => '', |
|
| 617 | + 'value' => '', // can be an array or a string |
|
| 618 | + 'required' => false, |
|
| 619 | + 'label' => '', |
|
| 620 | + 'label_after'=> false, |
|
| 621 | + 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 622 | + 'label_class' => '', |
|
| 623 | + 'help_text' => '', |
|
| 624 | + 'placeholder'=> '', |
|
| 625 | + 'options' => array(), // array or string |
|
| 626 | + 'icon' => '', |
|
| 627 | + 'multiple' => false, |
|
| 628 | + 'select2' => false, |
|
| 629 | + 'no_wrap' => false, |
|
| 630 | + 'element_require' => '', // [%element_id%] == "1" |
|
| 631 | + 'extra_attributes' => array(), // an array of extra attributes |
|
| 632 | + ); |
|
| 633 | + |
|
| 634 | + /** |
|
| 635 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 636 | + */ |
|
| 637 | + $args = wp_parse_args( $args, $defaults ); |
|
| 638 | + $output = ''; |
|
| 639 | + |
|
| 640 | + // for now lets hide floating labels |
|
| 641 | + if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';} |
|
| 642 | + |
|
| 643 | + // hidden label option needs to be empty |
|
| 644 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 645 | + |
|
| 646 | + |
|
| 647 | + $label_after = $args['label_after']; |
|
| 648 | + |
|
| 649 | + // floating labels need label after |
|
| 650 | + if( $args['label_type'] == 'floating' ){ |
|
| 651 | + $label_after = true; |
|
| 652 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + // Maybe setup select2 |
|
| 656 | + $is_select2 = false; |
|
| 657 | + if(!empty($args['select2'])){ |
|
| 658 | + $args['class'] .= ' aui-select2'; |
|
| 659 | + $is_select2 = true; |
|
| 660 | + }elseif( strpos($args['class'], 'aui-select2') !== false){ |
|
| 661 | + $is_select2 = true; |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + // select2 tags |
|
| 665 | + if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason |
|
| 666 | + $args['data-tags'] = 'true'; |
|
| 667 | + $args['data-token-separators'] = "[',']"; |
|
| 668 | + $args['multiple'] = true; |
|
| 669 | + } |
|
| 670 | + |
|
| 671 | + // select2 placeholder |
|
| 672 | + if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){ |
|
| 673 | + $args['data-placeholder'] = esc_attr($args['placeholder']); |
|
| 674 | + $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + // label |
|
| 678 | + if(!empty($args['label']) && is_array($args['label'])){ |
|
| 679 | + }elseif(!empty($args['label']) && !$label_after){ |
|
| 680 | + $label_args = array( |
|
| 681 | + 'title'=> $args['label'], |
|
| 682 | + 'for'=> $args['id'], |
|
| 683 | + 'class' => $args['label_class']." ", |
|
| 684 | + 'label_type' => $args['label_type'] |
|
| 685 | + ); |
|
| 686 | + $output .= self::label($label_args); |
|
| 687 | + } |
|
| 688 | + |
|
| 689 | + // maybe horizontal label |
|
| 690 | + if($args['label_type']=='horizontal'){ |
|
| 691 | + $output .= '<div class="col-sm-10">'; |
|
| 692 | + } |
|
| 693 | + |
|
| 694 | + // open/type |
|
| 695 | + $output .= '<select '; |
|
| 696 | + |
|
| 697 | + // style |
|
| 698 | + if($is_select2){ |
|
| 699 | + $output .= " style='width:100%;' "; |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + // element require |
|
| 703 | + if(!empty($args['element_require'])){ |
|
| 704 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
| 705 | + $args['class'] .= " aui-conditional-field"; |
|
| 706 | + } |
|
| 707 | + |
|
| 708 | + // class |
|
| 709 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
| 710 | + $output .= AUI_Component_Helper::class_attr('custom-select '.$class); |
|
| 711 | + |
|
| 712 | + // name |
|
| 713 | + if(!empty($args['name'])){ |
|
| 714 | + $output .= AUI_Component_Helper::name($args['name'],$args['multiple']); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + // id |
|
| 718 | + if(!empty($args['id'])){ |
|
| 719 | + $output .= AUI_Component_Helper::id($args['id']); |
|
| 720 | + } |
|
| 721 | + |
|
| 722 | + // title |
|
| 723 | + if(!empty($args['title'])){ |
|
| 724 | + $output .= AUI_Component_Helper::title($args['title']); |
|
| 725 | + } |
|
| 726 | + |
|
| 727 | + // data-attributes |
|
| 728 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
| 729 | + |
|
| 730 | + // aria-attributes |
|
| 731 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
| 732 | + |
|
| 733 | + // extra attributes |
|
| 734 | + if(!empty($args['extra_attributes'])){ |
|
| 735 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 736 | + } |
|
| 737 | + |
|
| 738 | + // required |
|
| 739 | + if(!empty($args['required'])){ |
|
| 740 | + $output .= ' required '; |
|
| 741 | + } |
|
| 742 | + |
|
| 743 | + // multiple |
|
| 744 | + if(!empty($args['multiple'])){ |
|
| 745 | + $output .= ' multiple '; |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + // close opening tag |
|
| 749 | + $output .= ' >'; |
|
| 750 | + |
|
| 751 | + // placeholder |
|
| 752 | + if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){ |
|
| 753 | + $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>'; |
|
| 754 | + }elseif($is_select2 && !empty($args['placeholder'])){ |
|
| 755 | + $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + // Options |
|
| 759 | + if(!empty($args['options'])){ |
|
| 760 | + |
|
| 761 | + if(!is_array($args['options'])){ |
|
| 762 | + $output .= $args['options']; // not the preferred way but an option |
|
| 763 | + }else{ |
|
| 764 | + foreach($args['options'] as $val => $name){ |
|
| 765 | + $selected = ''; |
|
| 766 | + if(is_array($name)){ |
|
| 767 | + if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
|
| 768 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
| 769 | + |
|
| 770 | + $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
| 771 | + } else { |
|
| 772 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
| 773 | + $option_value = isset($name['value']) ? $name['value'] : ''; |
|
| 774 | + if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){ |
|
| 775 | + $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
|
| 776 | + } elseif(!empty($args['value'])) { |
|
| 777 | + $selected = selected($option_value,stripslashes_deep($args['value']), false); |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
|
| 781 | + } |
|
| 782 | + }else{ |
|
| 783 | + if(!empty($args['value'])){ |
|
| 784 | + if(is_array($args['value'])){ |
|
| 785 | + $selected = in_array($val,$args['value']) ? 'selected="selected"' : ''; |
|
| 786 | + } elseif(!empty($args['value'])) { |
|
| 787 | + $selected = selected( $args['value'], $val, false); |
|
| 788 | + } |
|
| 789 | + } |
|
| 790 | + $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
| 791 | + } |
|
| 792 | + } |
|
| 793 | + } |
|
| 794 | + |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + // closing tag |
|
| 798 | + $output .= '</select>'; |
|
| 799 | + |
|
| 800 | + if(!empty($args['label']) && $label_after){ |
|
| 801 | + $label_args = array( |
|
| 802 | + 'title'=> $args['label'], |
|
| 803 | + 'for'=> $args['id'], |
|
| 804 | + 'class' => $args['label_class']." ", |
|
| 805 | + 'label_type' => $args['label_type'] |
|
| 806 | + ); |
|
| 807 | + $output .= self::label($label_args); |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + // help text |
|
| 811 | + if(!empty($args['help_text'])){ |
|
| 812 | + $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + // maybe horizontal label |
|
| 816 | + if($args['label_type']=='horizontal'){ |
|
| 817 | + $output .= '</div>'; |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + |
|
| 821 | + // wrap |
|
| 822 | + if(!$args['no_wrap']){ |
|
| 823 | + $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
| 824 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
| 825 | + $output = self::wrap(array( |
|
| 826 | + 'content' => $output, |
|
| 827 | + 'class' => $wrap_class, |
|
| 828 | + 'element_require' => $args['element_require'], |
|
| 829 | + 'argument_id' => $args['id'] |
|
| 830 | + )); |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + |
|
| 834 | + return $output; |
|
| 835 | + } |
|
| 836 | + |
|
| 837 | + /** |
|
| 838 | + * Build the component. |
|
| 839 | + * |
|
| 840 | + * @param array $args |
|
| 841 | + * |
|
| 842 | + * @return string The rendered component. |
|
| 843 | + */ |
|
| 844 | + public static function radio($args = array()){ |
|
| 845 | + $defaults = array( |
|
| 846 | + 'class' => '', |
|
| 847 | + 'wrap_class' => '', |
|
| 848 | + 'id' => '', |
|
| 849 | + 'title' => '', |
|
| 850 | + 'horizontal' => false, // sets the lable horizontal |
|
| 851 | + 'value' => '', |
|
| 852 | + 'label' => '', |
|
| 853 | + 'label_class'=> '', |
|
| 854 | + 'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 855 | + 'inline' => true, |
|
| 856 | + 'required' => false, |
|
| 857 | + 'options' => array(), |
|
| 858 | + 'icon' => '', |
|
| 859 | + 'no_wrap' => false, |
|
| 860 | + 'element_require' => '', // [%element_id%] == "1" |
|
| 861 | + 'extra_attributes' => array() // an array of extra attributes |
|
| 862 | + ); |
|
| 863 | + |
|
| 864 | + /** |
|
| 865 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 866 | + */ |
|
| 867 | + $args = wp_parse_args( $args, $defaults ); |
|
| 868 | + |
|
| 869 | + // for now lets use horizontal for floating |
|
| 870 | + if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';} |
|
| 871 | + |
|
| 872 | + $label_args = array( |
|
| 873 | + 'title'=> $args['label'], |
|
| 874 | + 'class' => $args['label_class']." pt-0 ", |
|
| 875 | + 'label_type' => $args['label_type'] |
|
| 876 | + ); |
|
| 877 | + |
|
| 878 | + $output = ''; |
|
| 879 | + |
|
| 880 | + |
|
| 881 | + |
|
| 882 | + // label before |
|
| 883 | + if(!empty($args['label'])){ |
|
| 884 | + $output .= self::label( $label_args, 'radio' ); |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + // maybe horizontal label |
|
| 888 | + if($args['label_type']=='horizontal'){ |
|
| 889 | + $output .= '<div class="col-sm-10">'; |
|
| 890 | + } |
|
| 891 | + |
|
| 892 | + if(!empty($args['options'])){ |
|
| 893 | + $count = 0; |
|
| 894 | + foreach($args['options'] as $value => $label){ |
|
| 895 | + $option_args = $args; |
|
| 896 | + $option_args['value'] = $value; |
|
| 897 | + $option_args['label'] = $label; |
|
| 898 | + $option_args['checked'] = $value == $args['value'] ? true : false; |
|
| 899 | + $output .= self::radio_option($option_args,$count); |
|
| 900 | + $count++; |
|
| 901 | + } |
|
| 902 | + } |
|
| 903 | + |
|
| 904 | + // maybe horizontal label |
|
| 905 | + if($args['label_type']=='horizontal'){ |
|
| 906 | + $output .= '</div>'; |
|
| 907 | + } |
|
| 908 | + |
|
| 909 | + |
|
| 910 | + // wrap |
|
| 911 | + $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
| 912 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
| 913 | + $output = self::wrap(array( |
|
| 914 | + 'content' => $output, |
|
| 915 | + 'class' => $wrap_class, |
|
| 916 | + 'element_require' => $args['element_require'], |
|
| 917 | + 'argument_id' => $args['id'] |
|
| 918 | + )); |
|
| 919 | + |
|
| 920 | + |
|
| 921 | + return $output; |
|
| 922 | + } |
|
| 923 | + |
|
| 924 | + /** |
|
| 925 | + * Build the component. |
|
| 926 | + * |
|
| 927 | + * @param array $args |
|
| 928 | + * |
|
| 929 | + * @return string The rendered component. |
|
| 930 | + */ |
|
| 931 | + public static function radio_option($args = array(),$count = ''){ |
|
| 932 | + $defaults = array( |
|
| 933 | + 'class' => '', |
|
| 934 | + 'id' => '', |
|
| 935 | + 'title' => '', |
|
| 936 | + 'value' => '', |
|
| 937 | + 'required' => false, |
|
| 938 | + 'inline' => true, |
|
| 939 | + 'label' => '', |
|
| 940 | + 'options' => array(), |
|
| 941 | + 'icon' => '', |
|
| 942 | + 'no_wrap' => false, |
|
| 943 | + 'extra_attributes' => array() // an array of extra attributes |
|
| 944 | + ); |
|
| 945 | + |
|
| 946 | + /** |
|
| 947 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 948 | + */ |
|
| 949 | + $args = wp_parse_args( $args, $defaults ); |
|
| 950 | + |
|
| 951 | + $output = ''; |
|
| 952 | + |
|
| 953 | + // open/type |
|
| 954 | + $output .= '<input type="radio"'; |
|
| 955 | + |
|
| 956 | + // class |
|
| 957 | + $output .= ' class="form-check-input" '; |
|
| 958 | + |
|
| 959 | + // name |
|
| 960 | + if(!empty($args['name'])){ |
|
| 961 | + $output .= AUI_Component_Helper::name($args['name']); |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + // id |
|
| 965 | + if(!empty($args['id'])){ |
|
| 966 | + $output .= AUI_Component_Helper::id($args['id'].$count); |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + // title |
|
| 970 | + if(!empty($args['title'])){ |
|
| 971 | + $output .= AUI_Component_Helper::title($args['title']); |
|
| 972 | + } |
|
| 973 | + |
|
| 974 | + // value |
|
| 975 | + if(isset($args['value'])){ |
|
| 976 | + $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + // checked, for radio and checkboxes |
|
| 980 | + if( $args['checked'] ){ |
|
| 981 | + $output .= ' checked '; |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + // data-attributes |
|
| 985 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
| 986 | + |
|
| 987 | + // aria-attributes |
|
| 988 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
| 989 | + |
|
| 990 | + // extra attributes |
|
| 991 | + if(!empty($args['extra_attributes'])){ |
|
| 992 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 993 | + } |
|
| 994 | + |
|
| 995 | + // required |
|
| 996 | + if(!empty($args['required'])){ |
|
| 997 | + $output .= ' required '; |
|
| 998 | + } |
|
| 999 | + |
|
| 1000 | + // close opening tag |
|
| 1001 | + $output .= ' >'; |
|
| 1002 | + |
|
| 1003 | + // label |
|
| 1004 | + if(!empty($args['label']) && is_array($args['label'])){ |
|
| 1005 | + }elseif(!empty($args['label'])){ |
|
| 1006 | + $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio'); |
|
| 1007 | + } |
|
| 1008 | + |
|
| 1009 | + // wrap |
|
| 1010 | + if(!$args['no_wrap']){ |
|
| 1011 | + $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
|
| 1012 | + $output = self::wrap(array( |
|
| 1013 | + 'content' => $output, |
|
| 1014 | + 'class' => $wrap_class |
|
| 1015 | + )); |
|
| 1016 | + } |
|
| 1017 | + |
|
| 1018 | + |
|
| 1019 | + return $output; |
|
| 1020 | + } |
|
| 1021 | 1021 | |
| 1022 | 1022 | } |
| 1023 | 1023 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | - exit; // Exit if accessed directly |
|
| 4 | + exit; // Exit if accessed directly |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -11,250 +11,250 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | class AUI_Component_Helper { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * A component helper for generating a input name. |
|
| 16 | - * |
|
| 17 | - * @param $text |
|
| 18 | - * @param $multiple bool If the name is set to be multiple but no brackets found then we add some. |
|
| 19 | - * |
|
| 20 | - * @return string |
|
| 21 | - */ |
|
| 22 | - public static function name($text,$multiple = false){ |
|
| 23 | - $output = ''; |
|
| 24 | - |
|
| 25 | - if($text){ |
|
| 26 | - $is_multiple = strpos($text, '[') === false && $multiple ? '[]' : ''; |
|
| 27 | - $output = ' name="'.esc_attr($text).$is_multiple.'" '; |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - return $output; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * A component helper for generating a item id. |
|
| 35 | - * |
|
| 36 | - * @param $text string The text to be used as the value. |
|
| 37 | - * |
|
| 38 | - * @return string The sanitized item. |
|
| 39 | - */ |
|
| 40 | - public static function id($text){ |
|
| 41 | - $output = ''; |
|
| 42 | - |
|
| 43 | - if($text){ |
|
| 44 | - $output = ' id="'.sanitize_html_class($text).'" '; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - return $output; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * A component helper for generating a item title. |
|
| 52 | - * |
|
| 53 | - * @param $text string The text to be used as the value. |
|
| 54 | - * |
|
| 55 | - * @return string The sanitized item. |
|
| 56 | - */ |
|
| 57 | - public static function title($text){ |
|
| 58 | - $output = ''; |
|
| 59 | - |
|
| 60 | - if($text){ |
|
| 61 | - $output = ' title="'.esc_attr($text).'" '; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - return $output; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * A component helper for generating a item value. |
|
| 69 | - * |
|
| 70 | - * @param $text string The text to be used as the value. |
|
| 71 | - * |
|
| 72 | - * @return string The sanitized item. |
|
| 73 | - */ |
|
| 74 | - public static function value($text){ |
|
| 75 | - $output = ''; |
|
| 76 | - |
|
| 77 | - if($text){ |
|
| 78 | - $output = ' value="'.sanitize_text_field($text).'" '; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - return $output; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * A component helper for generating a item class attribute. |
|
| 86 | - * |
|
| 87 | - * @param $text string The text to be used as the value. |
|
| 88 | - * |
|
| 89 | - * @return string The sanitized item. |
|
| 90 | - */ |
|
| 91 | - public static function class_attr($text){ |
|
| 92 | - $output = ''; |
|
| 93 | - |
|
| 94 | - if($text){ |
|
| 95 | - $classes = self::esc_classes($text); |
|
| 96 | - if(!empty($classes)){ |
|
| 97 | - $output = ' class="'.$classes.'" '; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $output; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Escape a string of classes. |
|
| 106 | - * |
|
| 107 | - * @param $text |
|
| 108 | - * |
|
| 109 | - * @return string |
|
| 110 | - */ |
|
| 111 | - public static function esc_classes($text){ |
|
| 112 | - $output = ''; |
|
| 113 | - |
|
| 114 | - if($text){ |
|
| 115 | - $classes = explode(" ",$text); |
|
| 116 | - $classes = array_map("trim",$classes); |
|
| 117 | - $classes = array_map("sanitize_html_class",$classes); |
|
| 118 | - if(!empty($classes)){ |
|
| 119 | - $output = implode(" ",$classes); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - return $output; |
|
| 124 | - |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @param $args |
|
| 129 | - * |
|
| 130 | - * @return string |
|
| 131 | - */ |
|
| 132 | - public static function data_attributes($args){ |
|
| 133 | - $output = ''; |
|
| 134 | - |
|
| 135 | - if(!empty($args)){ |
|
| 136 | - |
|
| 137 | - foreach($args as $key => $val){ |
|
| 138 | - if(substr( $key, 0, 5 ) === "data-"){ |
|
| 139 | - $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" '; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - return $output; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @param $args |
|
| 149 | - * |
|
| 150 | - * @return string |
|
| 151 | - */ |
|
| 152 | - public static function aria_attributes($args){ |
|
| 153 | - $output = ''; |
|
| 154 | - |
|
| 155 | - if(!empty($args)){ |
|
| 156 | - |
|
| 157 | - foreach($args as $key => $val){ |
|
| 158 | - if(substr( $key, 0, 5 ) === "aria-"){ |
|
| 159 | - $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" '; |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - return $output; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Build a font awesome icon from a class. |
|
| 169 | - * |
|
| 170 | - * @param $class |
|
| 171 | - * @param bool $space_after |
|
| 172 | - * @param array $extra_attributes An array of extra attributes. |
|
| 173 | - * |
|
| 174 | - * @return string |
|
| 175 | - */ |
|
| 176 | - public static function icon($class,$space_after = false, $extra_attributes = array()){ |
|
| 177 | - $output = ''; |
|
| 178 | - |
|
| 179 | - if($class){ |
|
| 180 | - $classes = self::esc_classes($class); |
|
| 181 | - if(!empty($classes)){ |
|
| 182 | - $output = '<i class="'.$classes.'" '; |
|
| 183 | - // extra attributes |
|
| 184 | - if(!empty($extra_attributes)){ |
|
| 185 | - $output .= AUI_Component_Helper::extra_attributes($extra_attributes); |
|
| 186 | - } |
|
| 187 | - $output .= '></i>'; |
|
| 188 | - if($space_after){ |
|
| 189 | - $output .= " "; |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - return $output; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * @param $args |
|
| 199 | - * |
|
| 200 | - * @return string |
|
| 201 | - */ |
|
| 202 | - public static function extra_attributes($args){ |
|
| 203 | - $output = ''; |
|
| 204 | - |
|
| 205 | - if(!empty($args)){ |
|
| 206 | - |
|
| 207 | - if( is_array($args) ){ |
|
| 208 | - foreach($args as $key => $val){ |
|
| 209 | - $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" '; |
|
| 210 | - } |
|
| 211 | - }else{ |
|
| 212 | - $output .= ' '.$args.' '; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - return $output; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * @param $args |
|
| 222 | - * |
|
| 223 | - * @return string |
|
| 224 | - */ |
|
| 225 | - public static function help_text($text){ |
|
| 226 | - $output = ''; |
|
| 227 | - |
|
| 228 | - if($text){ |
|
| 229 | - $output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>'; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - |
|
| 233 | - return $output; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * Replace element require context with JS. |
|
| 238 | - * |
|
| 239 | - * @param $input |
|
| 240 | - * |
|
| 241 | - * @return string|void |
|
| 242 | - */ |
|
| 243 | - public static function element_require( $input ) { |
|
| 244 | - |
|
| 245 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 246 | - |
|
| 247 | - $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( |
|
| 248 | - "jQuery(form).find('[data-argument=\"", |
|
| 249 | - "\"]').find('input,select,textarea').val()", |
|
| 250 | - "\"]').find('input:checked').val()", |
|
| 251 | - ), $input ) ); |
|
| 252 | - |
|
| 253 | - if($output){ |
|
| 254 | - $output = ' data-element-require="'.$output.'" '; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - return $output; |
|
| 258 | - } |
|
| 14 | + /** |
|
| 15 | + * A component helper for generating a input name. |
|
| 16 | + * |
|
| 17 | + * @param $text |
|
| 18 | + * @param $multiple bool If the name is set to be multiple but no brackets found then we add some. |
|
| 19 | + * |
|
| 20 | + * @return string |
|
| 21 | + */ |
|
| 22 | + public static function name($text,$multiple = false){ |
|
| 23 | + $output = ''; |
|
| 24 | + |
|
| 25 | + if($text){ |
|
| 26 | + $is_multiple = strpos($text, '[') === false && $multiple ? '[]' : ''; |
|
| 27 | + $output = ' name="'.esc_attr($text).$is_multiple.'" '; |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + return $output; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * A component helper for generating a item id. |
|
| 35 | + * |
|
| 36 | + * @param $text string The text to be used as the value. |
|
| 37 | + * |
|
| 38 | + * @return string The sanitized item. |
|
| 39 | + */ |
|
| 40 | + public static function id($text){ |
|
| 41 | + $output = ''; |
|
| 42 | + |
|
| 43 | + if($text){ |
|
| 44 | + $output = ' id="'.sanitize_html_class($text).'" '; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + return $output; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * A component helper for generating a item title. |
|
| 52 | + * |
|
| 53 | + * @param $text string The text to be used as the value. |
|
| 54 | + * |
|
| 55 | + * @return string The sanitized item. |
|
| 56 | + */ |
|
| 57 | + public static function title($text){ |
|
| 58 | + $output = ''; |
|
| 59 | + |
|
| 60 | + if($text){ |
|
| 61 | + $output = ' title="'.esc_attr($text).'" '; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + return $output; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * A component helper for generating a item value. |
|
| 69 | + * |
|
| 70 | + * @param $text string The text to be used as the value. |
|
| 71 | + * |
|
| 72 | + * @return string The sanitized item. |
|
| 73 | + */ |
|
| 74 | + public static function value($text){ |
|
| 75 | + $output = ''; |
|
| 76 | + |
|
| 77 | + if($text){ |
|
| 78 | + $output = ' value="'.sanitize_text_field($text).'" '; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + return $output; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * A component helper for generating a item class attribute. |
|
| 86 | + * |
|
| 87 | + * @param $text string The text to be used as the value. |
|
| 88 | + * |
|
| 89 | + * @return string The sanitized item. |
|
| 90 | + */ |
|
| 91 | + public static function class_attr($text){ |
|
| 92 | + $output = ''; |
|
| 93 | + |
|
| 94 | + if($text){ |
|
| 95 | + $classes = self::esc_classes($text); |
|
| 96 | + if(!empty($classes)){ |
|
| 97 | + $output = ' class="'.$classes.'" '; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + return $output; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Escape a string of classes. |
|
| 106 | + * |
|
| 107 | + * @param $text |
|
| 108 | + * |
|
| 109 | + * @return string |
|
| 110 | + */ |
|
| 111 | + public static function esc_classes($text){ |
|
| 112 | + $output = ''; |
|
| 113 | + |
|
| 114 | + if($text){ |
|
| 115 | + $classes = explode(" ",$text); |
|
| 116 | + $classes = array_map("trim",$classes); |
|
| 117 | + $classes = array_map("sanitize_html_class",$classes); |
|
| 118 | + if(!empty($classes)){ |
|
| 119 | + $output = implode(" ",$classes); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + return $output; |
|
| 124 | + |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @param $args |
|
| 129 | + * |
|
| 130 | + * @return string |
|
| 131 | + */ |
|
| 132 | + public static function data_attributes($args){ |
|
| 133 | + $output = ''; |
|
| 134 | + |
|
| 135 | + if(!empty($args)){ |
|
| 136 | + |
|
| 137 | + foreach($args as $key => $val){ |
|
| 138 | + if(substr( $key, 0, 5 ) === "data-"){ |
|
| 139 | + $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" '; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + return $output; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @param $args |
|
| 149 | + * |
|
| 150 | + * @return string |
|
| 151 | + */ |
|
| 152 | + public static function aria_attributes($args){ |
|
| 153 | + $output = ''; |
|
| 154 | + |
|
| 155 | + if(!empty($args)){ |
|
| 156 | + |
|
| 157 | + foreach($args as $key => $val){ |
|
| 158 | + if(substr( $key, 0, 5 ) === "aria-"){ |
|
| 159 | + $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" '; |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + return $output; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Build a font awesome icon from a class. |
|
| 169 | + * |
|
| 170 | + * @param $class |
|
| 171 | + * @param bool $space_after |
|
| 172 | + * @param array $extra_attributes An array of extra attributes. |
|
| 173 | + * |
|
| 174 | + * @return string |
|
| 175 | + */ |
|
| 176 | + public static function icon($class,$space_after = false, $extra_attributes = array()){ |
|
| 177 | + $output = ''; |
|
| 178 | + |
|
| 179 | + if($class){ |
|
| 180 | + $classes = self::esc_classes($class); |
|
| 181 | + if(!empty($classes)){ |
|
| 182 | + $output = '<i class="'.$classes.'" '; |
|
| 183 | + // extra attributes |
|
| 184 | + if(!empty($extra_attributes)){ |
|
| 185 | + $output .= AUI_Component_Helper::extra_attributes($extra_attributes); |
|
| 186 | + } |
|
| 187 | + $output .= '></i>'; |
|
| 188 | + if($space_after){ |
|
| 189 | + $output .= " "; |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + return $output; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * @param $args |
|
| 199 | + * |
|
| 200 | + * @return string |
|
| 201 | + */ |
|
| 202 | + public static function extra_attributes($args){ |
|
| 203 | + $output = ''; |
|
| 204 | + |
|
| 205 | + if(!empty($args)){ |
|
| 206 | + |
|
| 207 | + if( is_array($args) ){ |
|
| 208 | + foreach($args as $key => $val){ |
|
| 209 | + $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" '; |
|
| 210 | + } |
|
| 211 | + }else{ |
|
| 212 | + $output .= ' '.$args.' '; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + return $output; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @param $args |
|
| 222 | + * |
|
| 223 | + * @return string |
|
| 224 | + */ |
|
| 225 | + public static function help_text($text){ |
|
| 226 | + $output = ''; |
|
| 227 | + |
|
| 228 | + if($text){ |
|
| 229 | + $output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>'; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + |
|
| 233 | + return $output; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * Replace element require context with JS. |
|
| 238 | + * |
|
| 239 | + * @param $input |
|
| 240 | + * |
|
| 241 | + * @return string|void |
|
| 242 | + */ |
|
| 243 | + public static function element_require( $input ) { |
|
| 244 | + |
|
| 245 | + $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 246 | + |
|
| 247 | + $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( |
|
| 248 | + "jQuery(form).find('[data-argument=\"", |
|
| 249 | + "\"]').find('input,select,textarea').val()", |
|
| 250 | + "\"]').find('input:checked').val()", |
|
| 251 | + ), $input ) ); |
|
| 252 | + |
|
| 253 | + if($output){ |
|
| 254 | + $output = ' data-element-require="'.$output.'" '; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + return $output; |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | } |
| 261 | 261 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | - exit; // Exit if accessed directly |
|
| 4 | + exit; // Exit if accessed directly |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -11,231 +11,231 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | class AUI { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Holds the class instance. |
|
| 16 | - * |
|
| 17 | - * @since 1.0.0 |
|
| 18 | - * @var null |
|
| 19 | - */ |
|
| 20 | - private static $instance = null; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Holds the current AUI version number. |
|
| 24 | - * |
|
| 25 | - * @var string $ver The current version number. |
|
| 26 | - */ |
|
| 27 | - public static $ver = '0.1.35'; |
|
| 28 | - |
|
| 29 | - public static $options = null; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * There can be only one. |
|
| 33 | - * |
|
| 34 | - * @since 1.0.0 |
|
| 35 | - * @return AUI|null |
|
| 36 | - */ |
|
| 37 | - public static function instance() { |
|
| 38 | - if ( self::$instance == null ) { |
|
| 39 | - self::$instance = new AUI(); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - return self::$instance; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * AUI constructor. |
|
| 47 | - * |
|
| 48 | - * @since 1.0.0 |
|
| 49 | - */ |
|
| 50 | - private function __construct() { |
|
| 51 | - if ( function_exists( "__autoload" ) ) { |
|
| 52 | - spl_autoload_register( "__autoload" ); |
|
| 53 | - } |
|
| 54 | - spl_autoload_register( array( $this, 'autoload' ) ); |
|
| 55 | - |
|
| 56 | - // load options |
|
| 57 | - self::$options = get_option('aui_options'); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Autoload any components on the fly. |
|
| 62 | - * |
|
| 63 | - * @since 1.0.0 |
|
| 64 | - * |
|
| 65 | - * @param $classname |
|
| 66 | - */ |
|
| 67 | - private function autoload( $classname ) { |
|
| 68 | - $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
| 69 | - $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
| 70 | - if ( $file_path && is_readable( $file_path ) ) { |
|
| 71 | - include_once( $file_path ); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Get the AUI options. |
|
| 77 | - * |
|
| 78 | - * @param $option |
|
| 79 | - * |
|
| 80 | - * @return string|void |
|
| 81 | - */ |
|
| 82 | - public function get_option( $option ){ |
|
| 83 | - $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
| 84 | - |
|
| 85 | - if ( ! $result && $option) { |
|
| 86 | - if( $option == 'color_primary' ){ |
|
| 87 | - $result = AUI_PRIMARY_COLOR; |
|
| 88 | - }elseif( $option == 'color_secondary' ){ |
|
| 89 | - $result = AUI_SECONDARY_COLOR; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - return $result; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function render( $items = array() ) { |
|
| 96 | - $output = ''; |
|
| 97 | - |
|
| 98 | - if ( ! empty( $items ) ) { |
|
| 99 | - foreach ( $items as $args ) { |
|
| 100 | - $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
| 101 | - if ( $render && method_exists( __CLASS__, $render ) ) { |
|
| 102 | - $output .= $this->$render( $args ); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - return $output; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Render and return a bootstrap alert component. |
|
| 112 | - * |
|
| 113 | - * @since 1.0.0 |
|
| 114 | - * |
|
| 115 | - * @param array $args |
|
| 116 | - * |
|
| 117 | - * @return string The rendered component. |
|
| 118 | - */ |
|
| 119 | - public function alert( $args = array() ) { |
|
| 120 | - return AUI_Component_Alert::get( $args ); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Render and return a bootstrap input component. |
|
| 125 | - * |
|
| 126 | - * @since 1.0.0 |
|
| 127 | - * |
|
| 128 | - * @param array $args |
|
| 129 | - * |
|
| 130 | - * @return string The rendered component. |
|
| 131 | - */ |
|
| 132 | - public function input( $args = array() ) { |
|
| 133 | - return AUI_Component_Input::input( $args ); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Render and return a bootstrap textarea component. |
|
| 138 | - * |
|
| 139 | - * @since 1.0.0 |
|
| 140 | - * |
|
| 141 | - * @param array $args |
|
| 142 | - * |
|
| 143 | - * @return string The rendered component. |
|
| 144 | - */ |
|
| 145 | - public function textarea( $args = array() ) { |
|
| 146 | - return AUI_Component_Input::textarea( $args ); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Render and return a bootstrap button component. |
|
| 151 | - * |
|
| 152 | - * @since 1.0.0 |
|
| 153 | - * |
|
| 154 | - * @param array $args |
|
| 155 | - * |
|
| 156 | - * @return string The rendered component. |
|
| 157 | - */ |
|
| 158 | - public function button( $args = array() ) { |
|
| 159 | - return AUI_Component_Button::get( $args ); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * Render and return a bootstrap button component. |
|
| 164 | - * |
|
| 165 | - * @since 1.0.0 |
|
| 166 | - * |
|
| 167 | - * @param array $args |
|
| 168 | - * |
|
| 169 | - * @return string The rendered component. |
|
| 170 | - */ |
|
| 171 | - public function badge( $args = array() ) { |
|
| 172 | - $defaults = array( |
|
| 173 | - 'class' => 'badge badge-primary align-middle', |
|
| 174 | - ); |
|
| 175 | - |
|
| 176 | - // maybe set type |
|
| 177 | - if ( empty( $args['href'] ) ) { |
|
| 178 | - $defaults['type'] = 'badge'; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 183 | - */ |
|
| 184 | - $args = wp_parse_args( $args, $defaults ); |
|
| 185 | - |
|
| 186 | - return AUI_Component_Button::get( $args ); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Render and return a bootstrap dropdown component. |
|
| 191 | - * |
|
| 192 | - * @since 1.0.0 |
|
| 193 | - * |
|
| 194 | - * @param array $args |
|
| 195 | - * |
|
| 196 | - * @return string The rendered component. |
|
| 197 | - */ |
|
| 198 | - public function dropdown( $args = array() ) { |
|
| 199 | - return AUI_Component_Dropdown::get( $args ); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Render and return a bootstrap select component. |
|
| 204 | - * |
|
| 205 | - * @since 1.0.0 |
|
| 206 | - * |
|
| 207 | - * @param array $args |
|
| 208 | - * |
|
| 209 | - * @return string The rendered component. |
|
| 210 | - */ |
|
| 211 | - public function select( $args = array() ) { |
|
| 212 | - return AUI_Component_Input::select( $args ); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Render and return a bootstrap radio component. |
|
| 217 | - * |
|
| 218 | - * @since 1.0.0 |
|
| 219 | - * |
|
| 220 | - * @param array $args |
|
| 221 | - * |
|
| 222 | - * @return string The rendered component. |
|
| 223 | - */ |
|
| 224 | - public function radio( $args = array() ) { |
|
| 225 | - return AUI_Component_Input::radio( $args ); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * Render and return a bootstrap pagination component. |
|
| 230 | - * |
|
| 231 | - * @since 1.0.0 |
|
| 232 | - * |
|
| 233 | - * @param array $args |
|
| 234 | - * |
|
| 235 | - * @return string The rendered component. |
|
| 236 | - */ |
|
| 237 | - public function pagination( $args = array() ) { |
|
| 238 | - return AUI_Component_Pagination::get( $args ); |
|
| 239 | - } |
|
| 14 | + /** |
|
| 15 | + * Holds the class instance. |
|
| 16 | + * |
|
| 17 | + * @since 1.0.0 |
|
| 18 | + * @var null |
|
| 19 | + */ |
|
| 20 | + private static $instance = null; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Holds the current AUI version number. |
|
| 24 | + * |
|
| 25 | + * @var string $ver The current version number. |
|
| 26 | + */ |
|
| 27 | + public static $ver = '0.1.35'; |
|
| 28 | + |
|
| 29 | + public static $options = null; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * There can be only one. |
|
| 33 | + * |
|
| 34 | + * @since 1.0.0 |
|
| 35 | + * @return AUI|null |
|
| 36 | + */ |
|
| 37 | + public static function instance() { |
|
| 38 | + if ( self::$instance == null ) { |
|
| 39 | + self::$instance = new AUI(); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + return self::$instance; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * AUI constructor. |
|
| 47 | + * |
|
| 48 | + * @since 1.0.0 |
|
| 49 | + */ |
|
| 50 | + private function __construct() { |
|
| 51 | + if ( function_exists( "__autoload" ) ) { |
|
| 52 | + spl_autoload_register( "__autoload" ); |
|
| 53 | + } |
|
| 54 | + spl_autoload_register( array( $this, 'autoload' ) ); |
|
| 55 | + |
|
| 56 | + // load options |
|
| 57 | + self::$options = get_option('aui_options'); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Autoload any components on the fly. |
|
| 62 | + * |
|
| 63 | + * @since 1.0.0 |
|
| 64 | + * |
|
| 65 | + * @param $classname |
|
| 66 | + */ |
|
| 67 | + private function autoload( $classname ) { |
|
| 68 | + $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
| 69 | + $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
| 70 | + if ( $file_path && is_readable( $file_path ) ) { |
|
| 71 | + include_once( $file_path ); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Get the AUI options. |
|
| 77 | + * |
|
| 78 | + * @param $option |
|
| 79 | + * |
|
| 80 | + * @return string|void |
|
| 81 | + */ |
|
| 82 | + public function get_option( $option ){ |
|
| 83 | + $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
| 84 | + |
|
| 85 | + if ( ! $result && $option) { |
|
| 86 | + if( $option == 'color_primary' ){ |
|
| 87 | + $result = AUI_PRIMARY_COLOR; |
|
| 88 | + }elseif( $option == 'color_secondary' ){ |
|
| 89 | + $result = AUI_SECONDARY_COLOR; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + return $result; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function render( $items = array() ) { |
|
| 96 | + $output = ''; |
|
| 97 | + |
|
| 98 | + if ( ! empty( $items ) ) { |
|
| 99 | + foreach ( $items as $args ) { |
|
| 100 | + $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
| 101 | + if ( $render && method_exists( __CLASS__, $render ) ) { |
|
| 102 | + $output .= $this->$render( $args ); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + return $output; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Render and return a bootstrap alert component. |
|
| 112 | + * |
|
| 113 | + * @since 1.0.0 |
|
| 114 | + * |
|
| 115 | + * @param array $args |
|
| 116 | + * |
|
| 117 | + * @return string The rendered component. |
|
| 118 | + */ |
|
| 119 | + public function alert( $args = array() ) { |
|
| 120 | + return AUI_Component_Alert::get( $args ); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Render and return a bootstrap input component. |
|
| 125 | + * |
|
| 126 | + * @since 1.0.0 |
|
| 127 | + * |
|
| 128 | + * @param array $args |
|
| 129 | + * |
|
| 130 | + * @return string The rendered component. |
|
| 131 | + */ |
|
| 132 | + public function input( $args = array() ) { |
|
| 133 | + return AUI_Component_Input::input( $args ); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Render and return a bootstrap textarea component. |
|
| 138 | + * |
|
| 139 | + * @since 1.0.0 |
|
| 140 | + * |
|
| 141 | + * @param array $args |
|
| 142 | + * |
|
| 143 | + * @return string The rendered component. |
|
| 144 | + */ |
|
| 145 | + public function textarea( $args = array() ) { |
|
| 146 | + return AUI_Component_Input::textarea( $args ); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Render and return a bootstrap button component. |
|
| 151 | + * |
|
| 152 | + * @since 1.0.0 |
|
| 153 | + * |
|
| 154 | + * @param array $args |
|
| 155 | + * |
|
| 156 | + * @return string The rendered component. |
|
| 157 | + */ |
|
| 158 | + public function button( $args = array() ) { |
|
| 159 | + return AUI_Component_Button::get( $args ); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * Render and return a bootstrap button component. |
|
| 164 | + * |
|
| 165 | + * @since 1.0.0 |
|
| 166 | + * |
|
| 167 | + * @param array $args |
|
| 168 | + * |
|
| 169 | + * @return string The rendered component. |
|
| 170 | + */ |
|
| 171 | + public function badge( $args = array() ) { |
|
| 172 | + $defaults = array( |
|
| 173 | + 'class' => 'badge badge-primary align-middle', |
|
| 174 | + ); |
|
| 175 | + |
|
| 176 | + // maybe set type |
|
| 177 | + if ( empty( $args['href'] ) ) { |
|
| 178 | + $defaults['type'] = 'badge'; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 183 | + */ |
|
| 184 | + $args = wp_parse_args( $args, $defaults ); |
|
| 185 | + |
|
| 186 | + return AUI_Component_Button::get( $args ); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Render and return a bootstrap dropdown component. |
|
| 191 | + * |
|
| 192 | + * @since 1.0.0 |
|
| 193 | + * |
|
| 194 | + * @param array $args |
|
| 195 | + * |
|
| 196 | + * @return string The rendered component. |
|
| 197 | + */ |
|
| 198 | + public function dropdown( $args = array() ) { |
|
| 199 | + return AUI_Component_Dropdown::get( $args ); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Render and return a bootstrap select component. |
|
| 204 | + * |
|
| 205 | + * @since 1.0.0 |
|
| 206 | + * |
|
| 207 | + * @param array $args |
|
| 208 | + * |
|
| 209 | + * @return string The rendered component. |
|
| 210 | + */ |
|
| 211 | + public function select( $args = array() ) { |
|
| 212 | + return AUI_Component_Input::select( $args ); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Render and return a bootstrap radio component. |
|
| 217 | + * |
|
| 218 | + * @since 1.0.0 |
|
| 219 | + * |
|
| 220 | + * @param array $args |
|
| 221 | + * |
|
| 222 | + * @return string The rendered component. |
|
| 223 | + */ |
|
| 224 | + public function radio( $args = array() ) { |
|
| 225 | + return AUI_Component_Input::radio( $args ); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * Render and return a bootstrap pagination component. |
|
| 230 | + * |
|
| 231 | + * @since 1.0.0 |
|
| 232 | + * |
|
| 233 | + * @param array $args |
|
| 234 | + * |
|
| 235 | + * @return string The rendered component. |
|
| 236 | + */ |
|
| 237 | + public function pagination( $args = array() ) { |
|
| 238 | + return AUI_Component_Pagination::get( $args ); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | \ No newline at end of file |
@@ -7,40 +7,40 @@ |
||
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | - exit; |
|
| 10 | + exit; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | 16 | add_action('after_setup_theme', function () { |
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | - $this_version = "0.1.35"; |
|
| 19 | - if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | - $ayecode_ui_version = $this_version ; |
|
| 21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 22 | - } |
|
| 17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | + $this_version = "0.1.35"; |
|
| 19 | + if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | + $ayecode_ui_version = $this_version ; |
|
| 21 | + $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 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 | 28 | add_action('after_setup_theme', function () { |
| 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' ); |
|
| 33 | - } |
|
| 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' ); |
|
| 33 | + } |
|
| 34 | 34 | },1); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Add the function that calls the class. |
| 38 | 38 | */ |
| 39 | 39 | if(!function_exists('aui')){ |
| 40 | - function aui(){ |
|
| 41 | - if(!class_exists("AUI",false)){ |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 44 | - return AUI::instance(); |
|
| 45 | - } |
|
| 40 | + function aui(){ |
|
| 41 | + if(!class_exists("AUI",false)){ |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | + return AUI::instance(); |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | class InstalledVersions |
| 13 | 13 | { |
| 14 | 14 | private static $installed = array ( |
| 15 | - 'root' => |
|
| 16 | - array ( |
|
| 15 | + 'root' => |
|
| 16 | + array ( |
|
| 17 | 17 | 'pretty_version' => 'dev-master', |
| 18 | 18 | 'version' => 'dev-master', |
| 19 | 19 | 'aliases' => |
@@ -21,78 +21,78 @@ discard block |
||
| 21 | 21 | ), |
| 22 | 22 | 'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8', |
| 23 | 23 | 'name' => 'ayecode/invoicing', |
| 24 | - ), |
|
| 25 | - 'versions' => |
|
| 26 | - array ( |
|
| 24 | + ), |
|
| 25 | + 'versions' => |
|
| 26 | + array ( |
|
| 27 | 27 | 'ayecode/ayecode-connect-helper' => |
| 28 | 28 | array ( |
| 29 | - 'pretty_version' => '1.0.3', |
|
| 30 | - 'version' => '1.0.3.0', |
|
| 31 | - 'aliases' => |
|
| 32 | - array ( |
|
| 33 | - ), |
|
| 34 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
| 29 | + 'pretty_version' => '1.0.3', |
|
| 30 | + 'version' => '1.0.3.0', |
|
| 31 | + 'aliases' => |
|
| 32 | + array ( |
|
| 33 | + ), |
|
| 34 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
| 35 | 35 | ), |
| 36 | 36 | 'ayecode/invoicing' => |
| 37 | 37 | array ( |
| 38 | - 'pretty_version' => 'dev-master', |
|
| 39 | - 'version' => 'dev-master', |
|
| 40 | - 'aliases' => |
|
| 41 | - array ( |
|
| 42 | - ), |
|
| 43 | - 'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8', |
|
| 38 | + 'pretty_version' => 'dev-master', |
|
| 39 | + 'version' => 'dev-master', |
|
| 40 | + 'aliases' => |
|
| 41 | + array ( |
|
| 42 | + ), |
|
| 43 | + 'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8', |
|
| 44 | 44 | ), |
| 45 | 45 | 'ayecode/wp-ayecode-ui' => |
| 46 | 46 | array ( |
| 47 | - 'pretty_version' => '0.1.35', |
|
| 48 | - 'version' => '0.1.35.0', |
|
| 49 | - 'aliases' => |
|
| 50 | - array ( |
|
| 51 | - ), |
|
| 52 | - 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
|
| 47 | + 'pretty_version' => '0.1.35', |
|
| 48 | + 'version' => '0.1.35.0', |
|
| 49 | + 'aliases' => |
|
| 50 | + array ( |
|
| 51 | + ), |
|
| 52 | + 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
|
| 53 | 53 | ), |
| 54 | 54 | 'ayecode/wp-font-awesome-settings' => |
| 55 | 55 | array ( |
| 56 | - 'pretty_version' => '1.0.12', |
|
| 57 | - 'version' => '1.0.12.0', |
|
| 58 | - 'aliases' => |
|
| 59 | - array ( |
|
| 60 | - ), |
|
| 61 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
| 56 | + 'pretty_version' => '1.0.12', |
|
| 57 | + 'version' => '1.0.12.0', |
|
| 58 | + 'aliases' => |
|
| 59 | + array ( |
|
| 60 | + ), |
|
| 61 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
| 62 | 62 | ), |
| 63 | 63 | 'ayecode/wp-super-duper' => |
| 64 | 64 | array ( |
| 65 | - 'pretty_version' => '1.0.22', |
|
| 66 | - 'version' => '1.0.22.0', |
|
| 67 | - 'aliases' => |
|
| 68 | - array ( |
|
| 69 | - ), |
|
| 70 | - 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
|
| 65 | + 'pretty_version' => '1.0.22', |
|
| 66 | + 'version' => '1.0.22.0', |
|
| 67 | + 'aliases' => |
|
| 68 | + array ( |
|
| 69 | + ), |
|
| 70 | + 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
|
| 71 | 71 | ), |
| 72 | 72 | 'composer/installers' => |
| 73 | 73 | array ( |
| 74 | - 'pretty_version' => 'v1.9.0', |
|
| 75 | - 'version' => '1.9.0.0', |
|
| 76 | - 'aliases' => |
|
| 77 | - array ( |
|
| 78 | - ), |
|
| 79 | - 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
|
| 74 | + 'pretty_version' => 'v1.9.0', |
|
| 75 | + 'version' => '1.9.0.0', |
|
| 76 | + 'aliases' => |
|
| 77 | + array ( |
|
| 78 | + ), |
|
| 79 | + 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
|
| 80 | 80 | ), |
| 81 | 81 | 'roundcube/plugin-installer' => |
| 82 | 82 | array ( |
| 83 | - 'replaced' => |
|
| 84 | - array ( |
|
| 83 | + 'replaced' => |
|
| 84 | + array ( |
|
| 85 | 85 | 0 => '*', |
| 86 | - ), |
|
| 86 | + ), |
|
| 87 | 87 | ), |
| 88 | 88 | 'shama/baton' => |
| 89 | 89 | array ( |
| 90 | - 'replaced' => |
|
| 91 | - array ( |
|
| 90 | + 'replaced' => |
|
| 91 | + array ( |
|
| 92 | 92 | 0 => '*', |
| 93 | - ), |
|
| 93 | + ), |
|
| 94 | + ), |
|
| 94 | 95 | ), |
| 95 | - ), |
|
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | 98 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php return array ( |
| 2 | - 'root' => |
|
| 3 | - array ( |
|
| 2 | + 'root' => |
|
| 3 | + array ( |
|
| 4 | 4 | 'pretty_version' => 'dev-master', |
| 5 | 5 | 'version' => 'dev-master', |
| 6 | 6 | 'aliases' => |
@@ -8,76 +8,76 @@ discard block |
||
| 8 | 8 | ), |
| 9 | 9 | 'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8', |
| 10 | 10 | 'name' => 'ayecode/invoicing', |
| 11 | - ), |
|
| 12 | - 'versions' => |
|
| 13 | - array ( |
|
| 11 | + ), |
|
| 12 | + 'versions' => |
|
| 13 | + array ( |
|
| 14 | 14 | 'ayecode/ayecode-connect-helper' => |
| 15 | 15 | array ( |
| 16 | - 'pretty_version' => '1.0.3', |
|
| 17 | - 'version' => '1.0.3.0', |
|
| 18 | - 'aliases' => |
|
| 19 | - array ( |
|
| 20 | - ), |
|
| 21 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
| 16 | + 'pretty_version' => '1.0.3', |
|
| 17 | + 'version' => '1.0.3.0', |
|
| 18 | + 'aliases' => |
|
| 19 | + array ( |
|
| 20 | + ), |
|
| 21 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
| 22 | 22 | ), |
| 23 | 23 | 'ayecode/invoicing' => |
| 24 | 24 | array ( |
| 25 | - 'pretty_version' => 'dev-master', |
|
| 26 | - 'version' => 'dev-master', |
|
| 27 | - 'aliases' => |
|
| 28 | - array ( |
|
| 29 | - ), |
|
| 30 | - 'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8', |
|
| 25 | + 'pretty_version' => 'dev-master', |
|
| 26 | + 'version' => 'dev-master', |
|
| 27 | + 'aliases' => |
|
| 28 | + array ( |
|
| 29 | + ), |
|
| 30 | + 'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8', |
|
| 31 | 31 | ), |
| 32 | 32 | 'ayecode/wp-ayecode-ui' => |
| 33 | 33 | array ( |
| 34 | - 'pretty_version' => '0.1.35', |
|
| 35 | - 'version' => '0.1.35.0', |
|
| 36 | - 'aliases' => |
|
| 37 | - array ( |
|
| 38 | - ), |
|
| 39 | - 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
|
| 34 | + 'pretty_version' => '0.1.35', |
|
| 35 | + 'version' => '0.1.35.0', |
|
| 36 | + 'aliases' => |
|
| 37 | + array ( |
|
| 38 | + ), |
|
| 39 | + 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
|
| 40 | 40 | ), |
| 41 | 41 | 'ayecode/wp-font-awesome-settings' => |
| 42 | 42 | array ( |
| 43 | - 'pretty_version' => '1.0.12', |
|
| 44 | - 'version' => '1.0.12.0', |
|
| 45 | - 'aliases' => |
|
| 46 | - array ( |
|
| 47 | - ), |
|
| 48 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
| 43 | + 'pretty_version' => '1.0.12', |
|
| 44 | + 'version' => '1.0.12.0', |
|
| 45 | + 'aliases' => |
|
| 46 | + array ( |
|
| 47 | + ), |
|
| 48 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
| 49 | 49 | ), |
| 50 | 50 | 'ayecode/wp-super-duper' => |
| 51 | 51 | array ( |
| 52 | - 'pretty_version' => '1.0.22', |
|
| 53 | - 'version' => '1.0.22.0', |
|
| 54 | - 'aliases' => |
|
| 55 | - array ( |
|
| 56 | - ), |
|
| 57 | - 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
|
| 52 | + 'pretty_version' => '1.0.22', |
|
| 53 | + 'version' => '1.0.22.0', |
|
| 54 | + 'aliases' => |
|
| 55 | + array ( |
|
| 56 | + ), |
|
| 57 | + 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
|
| 58 | 58 | ), |
| 59 | 59 | 'composer/installers' => |
| 60 | 60 | array ( |
| 61 | - 'pretty_version' => 'v1.9.0', |
|
| 62 | - 'version' => '1.9.0.0', |
|
| 63 | - 'aliases' => |
|
| 64 | - array ( |
|
| 65 | - ), |
|
| 66 | - 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
|
| 61 | + 'pretty_version' => 'v1.9.0', |
|
| 62 | + 'version' => '1.9.0.0', |
|
| 63 | + 'aliases' => |
|
| 64 | + array ( |
|
| 65 | + ), |
|
| 66 | + 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
|
| 67 | 67 | ), |
| 68 | 68 | 'roundcube/plugin-installer' => |
| 69 | 69 | array ( |
| 70 | - 'replaced' => |
|
| 71 | - array ( |
|
| 70 | + 'replaced' => |
|
| 71 | + array ( |
|
| 72 | 72 | 0 => '*', |
| 73 | - ), |
|
| 73 | + ), |
|
| 74 | 74 | ), |
| 75 | 75 | 'shama/baton' => |
| 76 | 76 | array ( |
| 77 | - 'replaced' => |
|
| 78 | - array ( |
|
| 77 | + 'replaced' => |
|
| 78 | + array ( |
|
| 79 | 79 | 0 => '*', |
| 80 | - ), |
|
| 80 | + ), |
|
| 81 | + ), |
|
| 81 | 82 | ), |
| 82 | - ), |
|
| 83 | 83 | ); |