@@ -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,1291 +11,1291 @@ 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 | - global $aui_bs5; |
|
| 23 | - |
|
| 24 | - $defaults = array( |
|
| 25 | - 'type' => 'text', |
|
| 26 | - 'name' => '', |
|
| 27 | - 'class' => '', |
|
| 28 | - 'wrap_class' => '', |
|
| 29 | - 'id' => '', |
|
| 30 | - 'placeholder' => '', |
|
| 31 | - 'title' => '', |
|
| 32 | - 'value' => '', |
|
| 33 | - 'required' => false, |
|
| 34 | - 'size' => '', // sm, lg, small, large |
|
| 35 | - 'clear_icon' => '', // true will show a clear icon, can't be used with input_group_right |
|
| 36 | - 'with_hidden' => false, // Append hidden field for single checkbox. |
|
| 37 | - 'label' => '', |
|
| 38 | - 'label_after' => false, |
|
| 39 | - 'label_class' => '', |
|
| 40 | - 'label_col' => '2', |
|
| 41 | - 'label_type' => '', // top, horizontal, empty = hidden |
|
| 42 | - 'label_force_left' => false, // used to force checkbox label left when using horizontal |
|
| 43 | - // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 44 | - 'help_text' => '', |
|
| 45 | - 'validation_text' => '', |
|
| 46 | - 'validation_pattern' => '', |
|
| 47 | - 'no_wrap' => false, |
|
| 48 | - 'input_group_right' => '', |
|
| 49 | - 'input_group_left' => '', |
|
| 50 | - 'input_group_right_inside' => false, |
|
| 51 | - // forces the input group inside the input |
|
| 52 | - 'input_group_left_inside' => false, |
|
| 53 | - // forces the input group inside the input |
|
| 54 | - 'form_group_class' => '', |
|
| 55 | - 'step' => '', |
|
| 56 | - 'switch' => false, |
|
| 57 | - // to show checkbox as a switch |
|
| 58 | - 'checked' => false, |
|
| 59 | - // set a checkbox or radio as selected |
|
| 60 | - 'password_toggle' => true, |
|
| 61 | - // toggle view/hide password |
|
| 62 | - 'element_require' => '', |
|
| 63 | - // [%element_id%] == "1" |
|
| 64 | - 'extra_attributes' => array(), |
|
| 65 | - // an array of extra attributes |
|
| 66 | - 'wrap_attributes' => array() |
|
| 67 | - ); |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 71 | - */ |
|
| 72 | - $args = wp_parse_args( $args, $defaults ); |
|
| 73 | - $output = ''; |
|
| 74 | - if ( ! empty( $args['type'] ) ) { |
|
| 75 | - // hidden label option needs to be empty |
|
| 76 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 77 | - |
|
| 78 | - $type = sanitize_html_class( $args['type'] ); |
|
| 79 | - |
|
| 80 | - $help_text = ''; |
|
| 81 | - $label = ''; |
|
| 82 | - $label_after = $args['label_after']; |
|
| 83 | - $label_args = array( |
|
| 84 | - 'title' => $args['label'], |
|
| 85 | - 'for' => $args['id'], |
|
| 86 | - 'class' => $args['label_class'] . " ", |
|
| 87 | - 'label_type' => $args['label_type'], |
|
| 88 | - 'label_col' => $args['label_col'] |
|
| 89 | - ); |
|
| 90 | - |
|
| 91 | - // floating labels need label after |
|
| 92 | - if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) { |
|
| 93 | - $label_after = true; |
|
| 94 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - // size |
|
| 98 | - $size = ''; |
|
| 99 | - if ( $args['size'] == 'lg' || $args['size'] == 'large' ) { |
|
| 100 | - $size = 'lg'; |
|
| 101 | - $args['class'] .= ' form-control-lg'; |
|
| 102 | - }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) { |
|
| 103 | - $size = 'sm'; |
|
| 104 | - $args['class'] .= ' form-control-sm'; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // clear function |
|
| 108 | - $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');'; |
|
| 109 | - |
|
| 110 | - // Some special sauce for files |
|
| 111 | - if ( $type == 'file' ) { |
|
| 112 | - $label_after = true; // if type file we need the label after |
|
| 113 | - $args['class'] .= ' custom-file-input '; |
|
| 114 | - } elseif ( $type == 'checkbox' ) { |
|
| 115 | - $label_after = true; // if type file we need the label after |
|
| 116 | - $args['class'] .= $aui_bs5 ? ' form-check-input c-pointer ' : ' custom-control-input c-pointer '; |
|
| 117 | - } elseif ( $type == 'datepicker' || $type == 'timepicker' ) { |
|
| 118 | - $orig_type = $type; |
|
| 119 | - $type = 'text'; |
|
| 120 | - $args['class'] .= ' bg-initial '; // @todo not sure why we have this? |
|
| 121 | - $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');"; |
|
| 122 | - |
|
| 123 | - $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
|
| 124 | - |
|
| 125 | - // Disable native datetime inputs. |
|
| 126 | - $disable_mobile_attr = isset( $args['extra_attributes']['data-disable-mobile'] ) ? $args['extra_attributes']['data-disable-mobile'] : 'true'; |
|
| 127 | - $disable_mobile_attr = apply_filters( 'aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args ); |
|
| 128 | - |
|
| 129 | - $args['extra_attributes']['data-disable-mobile'] = $disable_mobile_attr; |
|
| 130 | - |
|
| 131 | - // set a way to clear field if empty |
|
| 132 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) { |
|
| 133 | - $args['input_group_right_inside'] = true; |
|
| 134 | - $args['clear_icon'] = true; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // enqueue the script |
|
| 138 | - $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 139 | - $aui_settings->enqueue_flatpickr(); |
|
| 140 | - } elseif ( $type == 'iconpicker' ) { |
|
| 141 | - $type = 'text'; |
|
| 142 | - //$args['class'] .= ' aui-flatpickr bg-initial '; |
|
| 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 | + global $aui_bs5; |
|
| 23 | + |
|
| 24 | + $defaults = array( |
|
| 25 | + 'type' => 'text', |
|
| 26 | + 'name' => '', |
|
| 27 | + 'class' => '', |
|
| 28 | + 'wrap_class' => '', |
|
| 29 | + 'id' => '', |
|
| 30 | + 'placeholder' => '', |
|
| 31 | + 'title' => '', |
|
| 32 | + 'value' => '', |
|
| 33 | + 'required' => false, |
|
| 34 | + 'size' => '', // sm, lg, small, large |
|
| 35 | + 'clear_icon' => '', // true will show a clear icon, can't be used with input_group_right |
|
| 36 | + 'with_hidden' => false, // Append hidden field for single checkbox. |
|
| 37 | + 'label' => '', |
|
| 38 | + 'label_after' => false, |
|
| 39 | + 'label_class' => '', |
|
| 40 | + 'label_col' => '2', |
|
| 41 | + 'label_type' => '', // top, horizontal, empty = hidden |
|
| 42 | + 'label_force_left' => false, // used to force checkbox label left when using horizontal |
|
| 43 | + // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 44 | + 'help_text' => '', |
|
| 45 | + 'validation_text' => '', |
|
| 46 | + 'validation_pattern' => '', |
|
| 47 | + 'no_wrap' => false, |
|
| 48 | + 'input_group_right' => '', |
|
| 49 | + 'input_group_left' => '', |
|
| 50 | + 'input_group_right_inside' => false, |
|
| 51 | + // forces the input group inside the input |
|
| 52 | + 'input_group_left_inside' => false, |
|
| 53 | + // forces the input group inside the input |
|
| 54 | + 'form_group_class' => '', |
|
| 55 | + 'step' => '', |
|
| 56 | + 'switch' => false, |
|
| 57 | + // to show checkbox as a switch |
|
| 58 | + 'checked' => false, |
|
| 59 | + // set a checkbox or radio as selected |
|
| 60 | + 'password_toggle' => true, |
|
| 61 | + // toggle view/hide password |
|
| 62 | + 'element_require' => '', |
|
| 63 | + // [%element_id%] == "1" |
|
| 64 | + 'extra_attributes' => array(), |
|
| 65 | + // an array of extra attributes |
|
| 66 | + 'wrap_attributes' => array() |
|
| 67 | + ); |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 71 | + */ |
|
| 72 | + $args = wp_parse_args( $args, $defaults ); |
|
| 73 | + $output = ''; |
|
| 74 | + if ( ! empty( $args['type'] ) ) { |
|
| 75 | + // hidden label option needs to be empty |
|
| 76 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 77 | + |
|
| 78 | + $type = sanitize_html_class( $args['type'] ); |
|
| 79 | + |
|
| 80 | + $help_text = ''; |
|
| 81 | + $label = ''; |
|
| 82 | + $label_after = $args['label_after']; |
|
| 83 | + $label_args = array( |
|
| 84 | + 'title' => $args['label'], |
|
| 85 | + 'for' => $args['id'], |
|
| 86 | + 'class' => $args['label_class'] . " ", |
|
| 87 | + 'label_type' => $args['label_type'], |
|
| 88 | + 'label_col' => $args['label_col'] |
|
| 89 | + ); |
|
| 90 | + |
|
| 91 | + // floating labels need label after |
|
| 92 | + if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) { |
|
| 93 | + $label_after = true; |
|
| 94 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + // size |
|
| 98 | + $size = ''; |
|
| 99 | + if ( $args['size'] == 'lg' || $args['size'] == 'large' ) { |
|
| 100 | + $size = 'lg'; |
|
| 101 | + $args['class'] .= ' form-control-lg'; |
|
| 102 | + }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) { |
|
| 103 | + $size = 'sm'; |
|
| 104 | + $args['class'] .= ' form-control-sm'; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // clear function |
|
| 108 | + $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');'; |
|
| 109 | + |
|
| 110 | + // Some special sauce for files |
|
| 111 | + if ( $type == 'file' ) { |
|
| 112 | + $label_after = true; // if type file we need the label after |
|
| 113 | + $args['class'] .= ' custom-file-input '; |
|
| 114 | + } elseif ( $type == 'checkbox' ) { |
|
| 115 | + $label_after = true; // if type file we need the label after |
|
| 116 | + $args['class'] .= $aui_bs5 ? ' form-check-input c-pointer ' : ' custom-control-input c-pointer '; |
|
| 117 | + } elseif ( $type == 'datepicker' || $type == 'timepicker' ) { |
|
| 118 | + $orig_type = $type; |
|
| 119 | + $type = 'text'; |
|
| 120 | + $args['class'] .= ' bg-initial '; // @todo not sure why we have this? |
|
| 121 | + $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');"; |
|
| 122 | + |
|
| 123 | + $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
|
| 124 | + |
|
| 125 | + // Disable native datetime inputs. |
|
| 126 | + $disable_mobile_attr = isset( $args['extra_attributes']['data-disable-mobile'] ) ? $args['extra_attributes']['data-disable-mobile'] : 'true'; |
|
| 127 | + $disable_mobile_attr = apply_filters( 'aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args ); |
|
| 128 | + |
|
| 129 | + $args['extra_attributes']['data-disable-mobile'] = $disable_mobile_attr; |
|
| 130 | + |
|
| 131 | + // set a way to clear field if empty |
|
| 132 | + if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) { |
|
| 133 | + $args['input_group_right_inside'] = true; |
|
| 134 | + $args['clear_icon'] = true; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // enqueue the script |
|
| 138 | + $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 139 | + $aui_settings->enqueue_flatpickr(); |
|
| 140 | + } elseif ( $type == 'iconpicker' ) { |
|
| 141 | + $type = 'text'; |
|
| 142 | + //$args['class'] .= ' aui-flatpickr bg-initial '; |
|
| 143 | 143 | // $args['class'] .= ' bg-initial '; |
| 144 | 144 | |
| 145 | - $args['extra_attributes']['data-aui-init'] = 'iconpicker'; |
|
| 146 | - $args['extra_attributes']['data-placement'] = 'bottomRight'; |
|
| 145 | + $args['extra_attributes']['data-aui-init'] = 'iconpicker'; |
|
| 146 | + $args['extra_attributes']['data-placement'] = 'bottomRight'; |
|
| 147 | 147 | |
| 148 | - $args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>'; |
|
| 148 | + $args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>'; |
|
| 149 | 149 | // $args['input_group_right_inside'] = true; |
| 150 | - // enqueue the script |
|
| 151 | - $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 152 | - $aui_settings->enqueue_iconpicker(); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - if ( $type == 'checkbox' && ( ( ! empty( $args['name'] ) && strpos( $args['name'], '[' ) === false ) || ! empty( $args['with_hidden'] ) ) ) { |
|
| 156 | - $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />'; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - // allow clear icon |
|
| 160 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] ) { |
|
| 161 | - $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' ); |
|
| 162 | - $args['input_group_right_inside'] = true; |
|
| 163 | - $align_class = $aui_bs5 ? ' h-100 py-0' : ''; |
|
| 164 | - $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ( $aui_bs5 ? 'btn-close' : 'close' ) . '">' . ( $aui_bs5 ? '' : '×' ) . '</span></span>'; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // open/type |
|
| 168 | - $output .= '<input type="' . $type . '" '; |
|
| 169 | - |
|
| 170 | - // name |
|
| 171 | - if ( ! empty( $args['name'] ) ) { |
|
| 172 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - // id |
|
| 176 | - if ( ! empty( $args['id'] ) ) { |
|
| 177 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - // placeholder |
|
| 181 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 182 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - // title |
|
| 186 | - if ( ! empty( $args['title'] ) ) { |
|
| 187 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // value |
|
| 191 | - if ( ! empty( $args['value'] ) ) { |
|
| 192 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - // checked, for radio and checkboxes |
|
| 196 | - if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) { |
|
| 197 | - $output .= ' checked '; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - // validation text |
|
| 201 | - if ( ! empty( $args['validation_text'] ) ) { |
|
| 202 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" '; |
|
| 203 | - $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - // validation_pattern |
|
| 207 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 208 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - // step (for numbers) |
|
| 212 | - if ( ! empty( $args['step'] ) ) { |
|
| 213 | - $output .= ' step="' . $args['step'] . '" '; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - // required |
|
| 217 | - if ( ! empty( $args['required'] ) ) { |
|
| 218 | - $output .= ' required '; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // class |
|
| 222 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 223 | - $output .= $aui_bs5 && $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" '; |
|
| 224 | - |
|
| 225 | - // data-attributes |
|
| 226 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 227 | - |
|
| 228 | - // extra attributes |
|
| 229 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 230 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // close |
|
| 234 | - $output .= ' >'; |
|
| 235 | - |
|
| 236 | - // help text |
|
| 237 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 238 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - // label |
|
| 242 | - if ( ! empty( $args['label'] ) ) { |
|
| 243 | - $label_base_class = ''; |
|
| 244 | - if ( $type == 'file' ) { |
|
| 245 | - $label_base_class = ' custom-file-label'; |
|
| 246 | - } elseif ( $type == 'checkbox' ) { |
|
| 247 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
| 248 | - $label_args['title'] = wp_kses_post( $args['help_text'] ); |
|
| 249 | - $help_text = ''; |
|
| 250 | - //$label_args['class'] .= ' d-inline '; |
|
| 251 | - $args['wrap_class'] .= ' align-items-center '; |
|
| 252 | - }else{ |
|
| 253 | - |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - $label_base_class = $aui_bs5 ? ' form-check-label' : ' custom-control-label'; |
|
| 257 | - } |
|
| 258 | - $label_args['class'] .= $label_base_class; |
|
| 259 | - $temp_label_args = $label_args; |
|
| 260 | - if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";} |
|
| 261 | - $label = self::label( $temp_label_args, $type ); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - // set help text in the correct position |
|
| 268 | - if ( $label_after ) { |
|
| 269 | - $output .= $label . $help_text; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - // some input types need a separate wrap |
|
| 273 | - if ( $type == 'file' ) { |
|
| 274 | - $output = self::wrap( array( |
|
| 275 | - 'content' => $output, |
|
| 276 | - 'class' => $aui_bs5 ? 'mb-3 custom-file' : 'form-group custom-file' |
|
| 277 | - ) ); |
|
| 278 | - } elseif ( $type == 'checkbox' ) { |
|
| 279 | - |
|
| 280 | - $label_args['title'] = $args['label']; |
|
| 281 | - $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ); |
|
| 282 | - $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
| 283 | - $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : ''; |
|
| 284 | - if ( $aui_bs5 ) { |
|
| 285 | - $wrap_class = $args['switch'] ? 'form-check form-switch' . $switch_size_class : 'form-check'; |
|
| 286 | - }else{ |
|
| 287 | - $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox' ; |
|
| 288 | - } |
|
| 289 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
| 290 | - $wrap_class .= $aui_bs5 ? '' : ' d-flex align-content-center'; |
|
| 291 | - $label = str_replace(array("form-check-label","custom-control-label"),"", self::label( $label_args, 'cb' ) ); |
|
| 292 | - } |
|
| 293 | - $output = self::wrap( array( |
|
| 294 | - 'content' => $output, |
|
| 295 | - 'class' => $aui_bs5 ? $wrap_class : 'custom-control ' . $wrap_class |
|
| 296 | - ) ); |
|
| 297 | - |
|
| 298 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 299 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 300 | - $output = $label . '<div class="' . $input_col . '">' . $output . '</div>'; |
|
| 301 | - } |
|
| 302 | - } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) { |
|
| 303 | - |
|
| 304 | - |
|
| 305 | - // allow password field to toggle view |
|
| 306 | - $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" |
|
| 150 | + // enqueue the script |
|
| 151 | + $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 152 | + $aui_settings->enqueue_iconpicker(); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + if ( $type == 'checkbox' && ( ( ! empty( $args['name'] ) && strpos( $args['name'], '[' ) === false ) || ! empty( $args['with_hidden'] ) ) ) { |
|
| 156 | + $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />'; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + // allow clear icon |
|
| 160 | + if ( $args['input_group_right'] === '' && $args['clear_icon'] ) { |
|
| 161 | + $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' ); |
|
| 162 | + $args['input_group_right_inside'] = true; |
|
| 163 | + $align_class = $aui_bs5 ? ' h-100 py-0' : ''; |
|
| 164 | + $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ( $aui_bs5 ? 'btn-close' : 'close' ) . '">' . ( $aui_bs5 ? '' : '×' ) . '</span></span>'; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // open/type |
|
| 168 | + $output .= '<input type="' . $type . '" '; |
|
| 169 | + |
|
| 170 | + // name |
|
| 171 | + if ( ! empty( $args['name'] ) ) { |
|
| 172 | + $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + // id |
|
| 176 | + if ( ! empty( $args['id'] ) ) { |
|
| 177 | + $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + // placeholder |
|
| 181 | + if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 182 | + $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + // title |
|
| 186 | + if ( ! empty( $args['title'] ) ) { |
|
| 187 | + $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // value |
|
| 191 | + if ( ! empty( $args['value'] ) ) { |
|
| 192 | + $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + // checked, for radio and checkboxes |
|
| 196 | + if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) { |
|
| 197 | + $output .= ' checked '; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + // validation text |
|
| 201 | + if ( ! empty( $args['validation_text'] ) ) { |
|
| 202 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" '; |
|
| 203 | + $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + // validation_pattern |
|
| 207 | + if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 208 | + $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + // step (for numbers) |
|
| 212 | + if ( ! empty( $args['step'] ) ) { |
|
| 213 | + $output .= ' step="' . $args['step'] . '" '; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + // required |
|
| 217 | + if ( ! empty( $args['required'] ) ) { |
|
| 218 | + $output .= ' required '; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // class |
|
| 222 | + $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 223 | + $output .= $aui_bs5 && $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" '; |
|
| 224 | + |
|
| 225 | + // data-attributes |
|
| 226 | + $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 227 | + |
|
| 228 | + // extra attributes |
|
| 229 | + if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 230 | + $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // close |
|
| 234 | + $output .= ' >'; |
|
| 235 | + |
|
| 236 | + // help text |
|
| 237 | + if ( ! empty( $args['help_text'] ) ) { |
|
| 238 | + $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + // label |
|
| 242 | + if ( ! empty( $args['label'] ) ) { |
|
| 243 | + $label_base_class = ''; |
|
| 244 | + if ( $type == 'file' ) { |
|
| 245 | + $label_base_class = ' custom-file-label'; |
|
| 246 | + } elseif ( $type == 'checkbox' ) { |
|
| 247 | + if ( ! empty( $args['label_force_left'] ) ) { |
|
| 248 | + $label_args['title'] = wp_kses_post( $args['help_text'] ); |
|
| 249 | + $help_text = ''; |
|
| 250 | + //$label_args['class'] .= ' d-inline '; |
|
| 251 | + $args['wrap_class'] .= ' align-items-center '; |
|
| 252 | + }else{ |
|
| 253 | + |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + $label_base_class = $aui_bs5 ? ' form-check-label' : ' custom-control-label'; |
|
| 257 | + } |
|
| 258 | + $label_args['class'] .= $label_base_class; |
|
| 259 | + $temp_label_args = $label_args; |
|
| 260 | + if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";} |
|
| 261 | + $label = self::label( $temp_label_args, $type ); |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + // set help text in the correct position |
|
| 268 | + if ( $label_after ) { |
|
| 269 | + $output .= $label . $help_text; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + // some input types need a separate wrap |
|
| 273 | + if ( $type == 'file' ) { |
|
| 274 | + $output = self::wrap( array( |
|
| 275 | + 'content' => $output, |
|
| 276 | + 'class' => $aui_bs5 ? 'mb-3 custom-file' : 'form-group custom-file' |
|
| 277 | + ) ); |
|
| 278 | + } elseif ( $type == 'checkbox' ) { |
|
| 279 | + |
|
| 280 | + $label_args['title'] = $args['label']; |
|
| 281 | + $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ); |
|
| 282 | + $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
| 283 | + $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : ''; |
|
| 284 | + if ( $aui_bs5 ) { |
|
| 285 | + $wrap_class = $args['switch'] ? 'form-check form-switch' . $switch_size_class : 'form-check'; |
|
| 286 | + }else{ |
|
| 287 | + $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox' ; |
|
| 288 | + } |
|
| 289 | + if ( ! empty( $args['label_force_left'] ) ) { |
|
| 290 | + $wrap_class .= $aui_bs5 ? '' : ' d-flex align-content-center'; |
|
| 291 | + $label = str_replace(array("form-check-label","custom-control-label"),"", self::label( $label_args, 'cb' ) ); |
|
| 292 | + } |
|
| 293 | + $output = self::wrap( array( |
|
| 294 | + 'content' => $output, |
|
| 295 | + 'class' => $aui_bs5 ? $wrap_class : 'custom-control ' . $wrap_class |
|
| 296 | + ) ); |
|
| 297 | + |
|
| 298 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 299 | + $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 300 | + $output = $label . '<div class="' . $input_col . '">' . $output . '</div>'; |
|
| 301 | + } |
|
| 302 | + } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) { |
|
| 303 | + |
|
| 304 | + |
|
| 305 | + // allow password field to toggle view |
|
| 306 | + $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" |
|
| 307 | 307 | onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\'); |
| 308 | 308 | var $eli = jQuery(this).parent().parent().find(\'input\'); |
| 309 | 309 | if($el.hasClass(\'fa-eye\')) |
| 310 | 310 | {$eli.attr(\'type\',\'text\');} |
| 311 | 311 | else{$eli.attr(\'type\',\'password\');}" |
| 312 | 312 | ><i class="far fa-fw fa-eye-slash"></i></span>'; |
| 313 | - } |
|
| 314 | - |
|
| 315 | - // input group wraps |
|
| 316 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 317 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 318 | - $group_size = $size == 'lg' ? ' input-group-lg' : ''; |
|
| 319 | - $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size; |
|
| 320 | - |
|
| 321 | - if ( $args['input_group_left'] ) { |
|
| 322 | - $output = self::wrap( array( |
|
| 323 | - 'content' => $output, |
|
| 324 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
|
| 325 | - 'input_group_left' => $args['input_group_left'], |
|
| 326 | - 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 327 | - ) ); |
|
| 328 | - } |
|
| 329 | - if ( $args['input_group_right'] ) { |
|
| 330 | - $output = self::wrap( array( |
|
| 331 | - 'content' => $output, |
|
| 332 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
|
| 333 | - 'input_group_right' => $args['input_group_right'], |
|
| 334 | - 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 335 | - ) ); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - if ( ! $label_after ) { |
|
| 341 | - $output .= $help_text; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 346 | - $output = self::wrap( array( |
|
| 347 | - 'content' => $output, |
|
| 348 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 349 | - ) ); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - if ( ! $label_after ) { |
|
| 353 | - $output = $label . $output; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - // wrap |
|
| 357 | - if ( ! $args['no_wrap'] ) { |
|
| 358 | - if ( ! empty( $args['form_group_class'] ) ) { |
|
| 359 | - $fg_class = esc_attr( $args['form_group_class'] ); |
|
| 360 | - }else{ |
|
| 361 | - $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
|
| 362 | - } |
|
| 363 | - $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : $fg_class; |
|
| 364 | - $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 365 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 366 | - $output = self::wrap( array( |
|
| 367 | - 'content' => $output, |
|
| 368 | - 'class' => $wrap_class, |
|
| 369 | - 'element_require' => $args['element_require'], |
|
| 370 | - 'argument_id' => $args['id'], |
|
| 371 | - 'wrap_attributes' => $args['wrap_attributes'], |
|
| 372 | - ) ); |
|
| 373 | - } |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - return $output; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - public static function label( $args = array(), $type = '' ) { |
|
| 380 | - global $aui_bs5; |
|
| 381 | - //<label for="exampleInputEmail1">Email address</label> |
|
| 382 | - $defaults = array( |
|
| 383 | - 'title' => 'div', |
|
| 384 | - 'for' => '', |
|
| 385 | - 'class' => '', |
|
| 386 | - 'label_type' => '', // empty = hidden, top, horizontal |
|
| 387 | - 'label_col' => '', |
|
| 388 | - ); |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 392 | - */ |
|
| 393 | - $args = wp_parse_args( $args, $defaults ); |
|
| 394 | - $output = ''; |
|
| 395 | - |
|
| 396 | - if ( $args['title'] ) { |
|
| 397 | - |
|
| 398 | - // maybe hide labels //@todo set a global option for visibility class |
|
| 399 | - if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) { |
|
| 400 | - $class = $args['class']; |
|
| 401 | - } else { |
|
| 402 | - $class = 'sr-only ' . $args['class']; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - // maybe horizontal |
|
| 406 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 407 | - $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label '.$type; |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - if( $aui_bs5 ){ $class .= ' form-label'; } |
|
| 411 | - |
|
| 412 | - // open |
|
| 413 | - $output .= '<label '; |
|
| 414 | - |
|
| 415 | - // for |
|
| 416 | - if ( ! empty( $args['for'] ) ) { |
|
| 417 | - $output .= ' for="' . esc_attr( $args['for'] ) . '" '; |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - // class |
|
| 421 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
| 422 | - $output .= ' class="' . $class . '" '; |
|
| 423 | - |
|
| 424 | - // close |
|
| 425 | - $output .= '>'; |
|
| 426 | - |
|
| 427 | - |
|
| 428 | - // title, don't escape fully as can contain html |
|
| 429 | - if ( ! empty( $args['title'] ) ) { |
|
| 430 | - $output .= wp_kses_post( $args['title'] ); |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - // close wrap |
|
| 434 | - $output .= '</label>'; |
|
| 435 | - |
|
| 436 | - |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - |
|
| 440 | - return $output; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - /** |
|
| 444 | - * Wrap some content in a HTML wrapper. |
|
| 445 | - * |
|
| 446 | - * @param array $args |
|
| 447 | - * |
|
| 448 | - * @return string |
|
| 449 | - */ |
|
| 450 | - public static function wrap( $args = array() ) { |
|
| 451 | - global $aui_bs5; |
|
| 452 | - $defaults = array( |
|
| 453 | - 'type' => 'div', |
|
| 454 | - 'class' => $aui_bs5 ? 'mb-3' : 'form-group', |
|
| 455 | - 'content' => '', |
|
| 456 | - 'input_group_left' => '', |
|
| 457 | - 'input_group_right' => '', |
|
| 458 | - 'input_group_left_inside' => false, |
|
| 459 | - 'input_group_right_inside' => false, |
|
| 460 | - 'element_require' => '', |
|
| 461 | - 'argument_id' => '', |
|
| 462 | - 'wrap_attributes' => array() |
|
| 463 | - ); |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 467 | - */ |
|
| 468 | - $args = wp_parse_args( $args, $defaults ); |
|
| 469 | - $output = ''; |
|
| 470 | - if ( $args['type'] ) { |
|
| 471 | - |
|
| 472 | - // open |
|
| 473 | - $output .= '<' . sanitize_html_class( $args['type'] ); |
|
| 474 | - |
|
| 475 | - // element require |
|
| 476 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 477 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 478 | - $args['class'] .= " aui-conditional-field"; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - // argument_id |
|
| 482 | - if ( ! empty( $args['argument_id'] ) ) { |
|
| 483 | - $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"'; |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - // class |
|
| 487 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 488 | - $output .= ' class="' . $class . '" '; |
|
| 489 | - |
|
| 490 | - // Attributes |
|
| 491 | - if ( ! empty( $args['wrap_attributes'] ) ) { |
|
| 492 | - $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] ); |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - // close wrap |
|
| 496 | - $output .= ' >'; |
|
| 497 | - |
|
| 498 | - |
|
| 499 | - // Input group left |
|
| 500 | - if ( ! empty( $args['input_group_left'] ) ) { |
|
| 501 | - $position_class = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 502 | - $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
| 503 | - $output .= $aui_bs5 ? $input_group_left : '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + // input group wraps |
|
| 316 | + if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 317 | + $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 318 | + $group_size = $size == 'lg' ? ' input-group-lg' : ''; |
|
| 319 | + $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size; |
|
| 320 | + |
|
| 321 | + if ( $args['input_group_left'] ) { |
|
| 322 | + $output = self::wrap( array( |
|
| 323 | + 'content' => $output, |
|
| 324 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
|
| 325 | + 'input_group_left' => $args['input_group_left'], |
|
| 326 | + 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 327 | + ) ); |
|
| 328 | + } |
|
| 329 | + if ( $args['input_group_right'] ) { |
|
| 330 | + $output = self::wrap( array( |
|
| 331 | + 'content' => $output, |
|
| 332 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
|
| 333 | + 'input_group_right' => $args['input_group_right'], |
|
| 334 | + 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 335 | + ) ); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + if ( ! $label_after ) { |
|
| 341 | + $output .= $help_text; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 346 | + $output = self::wrap( array( |
|
| 347 | + 'content' => $output, |
|
| 348 | + 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 349 | + ) ); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + if ( ! $label_after ) { |
|
| 353 | + $output = $label . $output; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + // wrap |
|
| 357 | + if ( ! $args['no_wrap'] ) { |
|
| 358 | + if ( ! empty( $args['form_group_class'] ) ) { |
|
| 359 | + $fg_class = esc_attr( $args['form_group_class'] ); |
|
| 360 | + }else{ |
|
| 361 | + $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
|
| 362 | + } |
|
| 363 | + $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : $fg_class; |
|
| 364 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 365 | + $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 366 | + $output = self::wrap( array( |
|
| 367 | + 'content' => $output, |
|
| 368 | + 'class' => $wrap_class, |
|
| 369 | + 'element_require' => $args['element_require'], |
|
| 370 | + 'argument_id' => $args['id'], |
|
| 371 | + 'wrap_attributes' => $args['wrap_attributes'], |
|
| 372 | + ) ); |
|
| 373 | + } |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + return $output; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + public static function label( $args = array(), $type = '' ) { |
|
| 380 | + global $aui_bs5; |
|
| 381 | + //<label for="exampleInputEmail1">Email address</label> |
|
| 382 | + $defaults = array( |
|
| 383 | + 'title' => 'div', |
|
| 384 | + 'for' => '', |
|
| 385 | + 'class' => '', |
|
| 386 | + 'label_type' => '', // empty = hidden, top, horizontal |
|
| 387 | + 'label_col' => '', |
|
| 388 | + ); |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 392 | + */ |
|
| 393 | + $args = wp_parse_args( $args, $defaults ); |
|
| 394 | + $output = ''; |
|
| 395 | + |
|
| 396 | + if ( $args['title'] ) { |
|
| 397 | + |
|
| 398 | + // maybe hide labels //@todo set a global option for visibility class |
|
| 399 | + if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) { |
|
| 400 | + $class = $args['class']; |
|
| 401 | + } else { |
|
| 402 | + $class = 'sr-only ' . $args['class']; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + // maybe horizontal |
|
| 406 | + if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 407 | + $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label '.$type; |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + if( $aui_bs5 ){ $class .= ' form-label'; } |
|
| 411 | + |
|
| 412 | + // open |
|
| 413 | + $output .= '<label '; |
|
| 414 | + |
|
| 415 | + // for |
|
| 416 | + if ( ! empty( $args['for'] ) ) { |
|
| 417 | + $output .= ' for="' . esc_attr( $args['for'] ) . '" '; |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + // class |
|
| 421 | + $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
| 422 | + $output .= ' class="' . $class . '" '; |
|
| 423 | + |
|
| 424 | + // close |
|
| 425 | + $output .= '>'; |
|
| 426 | + |
|
| 427 | + |
|
| 428 | + // title, don't escape fully as can contain html |
|
| 429 | + if ( ! empty( $args['title'] ) ) { |
|
| 430 | + $output .= wp_kses_post( $args['title'] ); |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + // close wrap |
|
| 434 | + $output .= '</label>'; |
|
| 435 | + |
|
| 436 | + |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + |
|
| 440 | + return $output; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + /** |
|
| 444 | + * Wrap some content in a HTML wrapper. |
|
| 445 | + * |
|
| 446 | + * @param array $args |
|
| 447 | + * |
|
| 448 | + * @return string |
|
| 449 | + */ |
|
| 450 | + public static function wrap( $args = array() ) { |
|
| 451 | + global $aui_bs5; |
|
| 452 | + $defaults = array( |
|
| 453 | + 'type' => 'div', |
|
| 454 | + 'class' => $aui_bs5 ? 'mb-3' : 'form-group', |
|
| 455 | + 'content' => '', |
|
| 456 | + 'input_group_left' => '', |
|
| 457 | + 'input_group_right' => '', |
|
| 458 | + 'input_group_left_inside' => false, |
|
| 459 | + 'input_group_right_inside' => false, |
|
| 460 | + 'element_require' => '', |
|
| 461 | + 'argument_id' => '', |
|
| 462 | + 'wrap_attributes' => array() |
|
| 463 | + ); |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 467 | + */ |
|
| 468 | + $args = wp_parse_args( $args, $defaults ); |
|
| 469 | + $output = ''; |
|
| 470 | + if ( $args['type'] ) { |
|
| 471 | + |
|
| 472 | + // open |
|
| 473 | + $output .= '<' . sanitize_html_class( $args['type'] ); |
|
| 474 | + |
|
| 475 | + // element require |
|
| 476 | + if ( ! empty( $args['element_require'] ) ) { |
|
| 477 | + $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 478 | + $args['class'] .= " aui-conditional-field"; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + // argument_id |
|
| 482 | + if ( ! empty( $args['argument_id'] ) ) { |
|
| 483 | + $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"'; |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + // class |
|
| 487 | + $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 488 | + $output .= ' class="' . $class . '" '; |
|
| 489 | + |
|
| 490 | + // Attributes |
|
| 491 | + if ( ! empty( $args['wrap_attributes'] ) ) { |
|
| 492 | + $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] ); |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + // close wrap |
|
| 496 | + $output .= ' >'; |
|
| 497 | + |
|
| 498 | + |
|
| 499 | + // Input group left |
|
| 500 | + if ( ! empty( $args['input_group_left'] ) ) { |
|
| 501 | + $position_class = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 502 | + $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
| 503 | + $output .= $aui_bs5 ? $input_group_left : '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
|
| 504 | 504 | // $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
| 505 | - } |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | - // content |
|
| 508 | - $output .= $args['content']; |
|
| 507 | + // content |
|
| 508 | + $output .= $args['content']; |
|
| 509 | 509 | |
| 510 | - // Input group right |
|
| 511 | - if ( ! empty( $args['input_group_right'] ) ) { |
|
| 512 | - $position_class = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 513 | - $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
| 514 | - $output .= $aui_bs5 ? str_replace( 'input-group-text','input-group-text top-0 end-0', $input_group_right ) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
|
| 510 | + // Input group right |
|
| 511 | + if ( ! empty( $args['input_group_right'] ) ) { |
|
| 512 | + $position_class = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 513 | + $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
| 514 | + $output .= $aui_bs5 ? str_replace( 'input-group-text','input-group-text top-0 end-0', $input_group_right ) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
|
| 515 | 515 | // $output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
| 516 | - } |
|
| 517 | - |
|
| 518 | - |
|
| 519 | - // close wrap |
|
| 520 | - $output .= '</' . sanitize_html_class( $args['type'] ) . '>'; |
|
| 521 | - |
|
| 522 | - |
|
| 523 | - } else { |
|
| 524 | - $output = $args['content']; |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - return $output; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - /** |
|
| 531 | - * Build the component. |
|
| 532 | - * |
|
| 533 | - * @param array $args |
|
| 534 | - * |
|
| 535 | - * @return string The rendered component. |
|
| 536 | - */ |
|
| 537 | - public static function textarea( $args = array() ) { |
|
| 538 | - global $aui_bs5; |
|
| 539 | - |
|
| 540 | - $defaults = array( |
|
| 541 | - 'name' => '', |
|
| 542 | - 'class' => '', |
|
| 543 | - 'wrap_class' => '', |
|
| 544 | - 'id' => '', |
|
| 545 | - 'placeholder' => '', |
|
| 546 | - 'title' => '', |
|
| 547 | - 'value' => '', |
|
| 548 | - 'required' => false, |
|
| 549 | - 'label' => '', |
|
| 550 | - 'label_after' => false, |
|
| 551 | - 'label_class' => '', |
|
| 552 | - 'label_type' => '', |
|
| 553 | - 'label_col' => '', |
|
| 554 | - // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 555 | - 'input_group_right' => '', |
|
| 556 | - 'input_group_left' => '', |
|
| 557 | - 'input_group_right_inside' => false, |
|
| 558 | - 'form_group_class' => '', |
|
| 559 | - 'help_text' => '', |
|
| 560 | - 'validation_text' => '', |
|
| 561 | - 'validation_pattern' => '', |
|
| 562 | - 'no_wrap' => false, |
|
| 563 | - 'rows' => '', |
|
| 564 | - 'wysiwyg' => false, |
|
| 565 | - 'allow_tags' => false, |
|
| 566 | - // Allow HTML tags |
|
| 567 | - 'element_require' => '', |
|
| 568 | - // [%element_id%] == "1" |
|
| 569 | - 'extra_attributes' => array(), |
|
| 570 | - // an array of extra attributes |
|
| 571 | - 'wrap_attributes' => array(), |
|
| 572 | - ); |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 576 | - */ |
|
| 577 | - $args = wp_parse_args( $args, $defaults ); |
|
| 578 | - $output = ''; |
|
| 579 | - $label = ''; |
|
| 580 | - |
|
| 581 | - // hidden label option needs to be empty |
|
| 582 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 583 | - |
|
| 584 | - // floating labels don't work with wysiwyg so set it as top |
|
| 585 | - if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) { |
|
| 586 | - $args['label_type'] = 'top'; |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - $label_after = $args['label_after']; |
|
| 590 | - |
|
| 591 | - // floating labels need label after |
|
| 592 | - if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) { |
|
| 593 | - $label_after = true; |
|
| 594 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - // label |
|
| 598 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 599 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 600 | - $label_args = array( |
|
| 601 | - 'title' => $args['label'], |
|
| 602 | - 'for' => $args['id'], |
|
| 603 | - 'class' => $args['label_class'] . " ", |
|
| 604 | - 'label_type' => $args['label_type'], |
|
| 605 | - 'label_col' => $args['label_col'] |
|
| 606 | - ); |
|
| 607 | - $label .= self::label( $label_args ); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - // maybe horizontal label |
|
| 611 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 612 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 613 | - $label .= '<div class="' . $input_col . '">'; |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - if ( ! empty( $args['wysiwyg'] ) ) { |
|
| 617 | - ob_start(); |
|
| 618 | - $content = $args['value']; |
|
| 619 | - $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor'; |
|
| 620 | - $settings = array( |
|
| 621 | - 'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4, |
|
| 622 | - 'quicktags' => false, |
|
| 623 | - 'media_buttons' => false, |
|
| 624 | - 'editor_class' => 'form-control', |
|
| 625 | - 'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ), |
|
| 626 | - 'teeny' => true, |
|
| 627 | - ); |
|
| 628 | - |
|
| 629 | - // maybe set settings if array |
|
| 630 | - if ( is_array( $args['wysiwyg'] ) ) { |
|
| 631 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
| 632 | - } |
|
| 633 | - |
|
| 634 | - wp_editor( $content, $editor_id, $settings ); |
|
| 635 | - $output .= ob_get_clean(); |
|
| 636 | - } else { |
|
| 637 | - |
|
| 638 | - // open |
|
| 639 | - $output .= '<textarea '; |
|
| 640 | - |
|
| 641 | - // name |
|
| 642 | - if ( ! empty( $args['name'] ) ) { |
|
| 643 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - // id |
|
| 647 | - if ( ! empty( $args['id'] ) ) { |
|
| 648 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - // placeholder |
|
| 652 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 653 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - // title |
|
| 657 | - if ( ! empty( $args['title'] ) ) { |
|
| 658 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - // validation text |
|
| 662 | - if ( ! empty( $args['validation_text'] ) ) { |
|
| 663 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" '; |
|
| 664 | - $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 665 | - } |
|
| 666 | - |
|
| 667 | - // validation_pattern |
|
| 668 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 669 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - // required |
|
| 673 | - if ( ! empty( $args['required'] ) ) { |
|
| 674 | - $output .= ' required '; |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - // rows |
|
| 678 | - if ( ! empty( $args['rows'] ) ) { |
|
| 679 | - $output .= ' rows="' . absint( $args['rows'] ) . '" '; |
|
| 680 | - } |
|
| 681 | - |
|
| 682 | - |
|
| 683 | - // class |
|
| 684 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 685 | - $output .= ' class="form-control ' . $class . '" '; |
|
| 686 | - |
|
| 687 | - // extra attributes |
|
| 688 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 689 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 690 | - } |
|
| 691 | - |
|
| 692 | - // close tag |
|
| 693 | - $output .= ' >'; |
|
| 694 | - |
|
| 695 | - // value |
|
| 696 | - if ( ! empty( $args['value'] ) ) { |
|
| 697 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
| 698 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
| 699 | - } else { |
|
| 700 | - $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] ); |
|
| 701 | - } |
|
| 702 | - } |
|
| 703 | - |
|
| 704 | - // closing tag |
|
| 705 | - $output .= '</textarea>'; |
|
| 706 | - |
|
| 707 | - |
|
| 708 | - // input group wraps |
|
| 709 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 710 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 711 | - if ( $args['input_group_left'] ) { |
|
| 712 | - $output = self::wrap( array( |
|
| 713 | - 'content' => $output, |
|
| 714 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 715 | - 'input_group_left' => $args['input_group_left'], |
|
| 716 | - 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 717 | - ) ); |
|
| 718 | - } |
|
| 719 | - if ( $args['input_group_right'] ) { |
|
| 720 | - $output = self::wrap( array( |
|
| 721 | - 'content' => $output, |
|
| 722 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 723 | - 'input_group_right' => $args['input_group_right'], |
|
| 724 | - 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 725 | - ) ); |
|
| 726 | - } |
|
| 727 | - |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - |
|
| 731 | - } |
|
| 732 | - |
|
| 733 | - if ( ! empty( $args['label'] ) && $label_after ) { |
|
| 734 | - $label_args = array( |
|
| 735 | - 'title' => $args['label'], |
|
| 736 | - 'for' => $args['id'], |
|
| 737 | - 'class' => $args['label_class'] . " ", |
|
| 738 | - 'label_type' => $args['label_type'], |
|
| 739 | - 'label_col' => $args['label_col'] |
|
| 740 | - ); |
|
| 741 | - $output .= self::label( $label_args ); |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - // help text |
|
| 745 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 746 | - $output .= AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 747 | - } |
|
| 748 | - |
|
| 749 | - if ( ! $label_after ) { |
|
| 750 | - $output = $label . $output; |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - // maybe horizontal label |
|
| 754 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 755 | - $output .= '</div>'; |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - |
|
| 759 | - // wrap |
|
| 760 | - if ( ! $args['no_wrap'] ) { |
|
| 761 | - if ( ! empty( $args['form_group_class'] ) ) { |
|
| 762 | - $fg_class = esc_attr( $args['form_group_class'] ); |
|
| 763 | - }else{ |
|
| 764 | - $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
|
| 765 | - } |
|
| 766 | - $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : $fg_class; |
|
| 767 | - $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 768 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 769 | - $output = self::wrap( array( |
|
| 770 | - 'content' => $output, |
|
| 771 | - 'class' => $wrap_class, |
|
| 772 | - 'element_require' => $args['element_require'], |
|
| 773 | - 'argument_id' => $args['id'], |
|
| 774 | - 'wrap_attributes' => $args['wrap_attributes'], |
|
| 775 | - ) ); |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - |
|
| 779 | - return $output; |
|
| 780 | - } |
|
| 781 | - |
|
| 782 | - /** |
|
| 783 | - * Build the component. |
|
| 784 | - * |
|
| 785 | - * @param array $args |
|
| 786 | - * |
|
| 787 | - * @return string The rendered component. |
|
| 788 | - */ |
|
| 789 | - public static function select( $args = array() ) { |
|
| 790 | - global $aui_bs5; |
|
| 791 | - $defaults = array( |
|
| 792 | - 'class' => '', |
|
| 793 | - 'wrap_class' => '', |
|
| 794 | - 'id' => '', |
|
| 795 | - 'title' => '', |
|
| 796 | - 'value' => '', |
|
| 797 | - // can be an array or a string |
|
| 798 | - 'required' => false, |
|
| 799 | - 'label' => '', |
|
| 800 | - 'label_after' => false, |
|
| 801 | - 'label_type' => '', |
|
| 802 | - 'label_col' => '', |
|
| 803 | - // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 804 | - 'label_class' => '', |
|
| 805 | - 'help_text' => '', |
|
| 806 | - 'placeholder' => '', |
|
| 807 | - 'options' => array(), |
|
| 808 | - // array or string |
|
| 809 | - 'icon' => '', |
|
| 810 | - 'multiple' => false, |
|
| 811 | - 'select2' => false, |
|
| 812 | - 'no_wrap' => false, |
|
| 813 | - 'input_group_right' => '', |
|
| 814 | - 'input_group_left' => '', |
|
| 815 | - 'input_group_right_inside' => false, // forces the input group inside the input |
|
| 816 | - 'input_group_left_inside' => false, // forces the input group inside the input |
|
| 817 | - 'form_group_class' => '', |
|
| 818 | - 'element_require' => '', |
|
| 819 | - // [%element_id%] == "1" |
|
| 820 | - 'extra_attributes' => array(), |
|
| 821 | - // an array of extra attributes |
|
| 822 | - 'wrap_attributes' => array(), |
|
| 823 | - ); |
|
| 824 | - |
|
| 825 | - /** |
|
| 826 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 827 | - */ |
|
| 828 | - $args = wp_parse_args( $args, $defaults ); |
|
| 829 | - $output = ''; |
|
| 830 | - |
|
| 831 | - // for now lets hide floating labels |
|
| 832 | - if ( $args['label_type'] == 'floating' ) { |
|
| 833 | - $args['label_type'] = 'hidden'; |
|
| 834 | - } |
|
| 835 | - |
|
| 836 | - // hidden label option needs to be empty |
|
| 837 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 838 | - |
|
| 839 | - |
|
| 840 | - $label_after = $args['label_after']; |
|
| 841 | - |
|
| 842 | - // floating labels need label after |
|
| 843 | - if ( $args['label_type'] == 'floating' ) { |
|
| 844 | - $label_after = true; |
|
| 845 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - // Maybe setup select2 |
|
| 849 | - $is_select2 = false; |
|
| 850 | - if ( ! empty( $args['select2'] ) ) { |
|
| 851 | - $args['class'] .= ' aui-select2'; |
|
| 852 | - $is_select2 = true; |
|
| 853 | - } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) { |
|
| 854 | - $is_select2 = true; |
|
| 855 | - } |
|
| 856 | - |
|
| 857 | - // select2 tags |
|
| 858 | - if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason |
|
| 859 | - $args['data-tags'] = 'true'; |
|
| 860 | - $args['data-token-separators'] = "[',']"; |
|
| 861 | - $args['multiple'] = true; |
|
| 862 | - } |
|
| 863 | - |
|
| 864 | - // select2 placeholder |
|
| 865 | - if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) { |
|
| 866 | - $args['data-placeholder'] = esc_attr( $args['placeholder'] ); |
|
| 867 | - $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true; |
|
| 868 | - } |
|
| 869 | - |
|
| 870 | - // Set hidden input to save empty value for multiselect. |
|
| 871 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
| 872 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>'; |
|
| 873 | - } |
|
| 874 | - |
|
| 875 | - // open/type |
|
| 876 | - $output .= '<select '; |
|
| 877 | - |
|
| 878 | - // style |
|
| 879 | - if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
| 880 | - $output .= " style='width:100%;' "; |
|
| 881 | - } |
|
| 882 | - |
|
| 883 | - // element require |
|
| 884 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 885 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 886 | - $args['class'] .= " aui-conditional-field"; |
|
| 887 | - } |
|
| 888 | - |
|
| 889 | - // class |
|
| 890 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 891 | - $select_class = $aui_bs5 ? 'form-select ' : 'custom-select '; |
|
| 892 | - $output .= AUI_Component_Helper::class_attr( $select_class . $class ); |
|
| 893 | - |
|
| 894 | - // name |
|
| 895 | - if ( ! empty( $args['name'] ) ) { |
|
| 896 | - $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] ); |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - // id |
|
| 900 | - if ( ! empty( $args['id'] ) ) { |
|
| 901 | - $output .= AUI_Component_Helper::id( $args['id'] ); |
|
| 902 | - } |
|
| 903 | - |
|
| 904 | - // title |
|
| 905 | - if ( ! empty( $args['title'] ) ) { |
|
| 906 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 907 | - } |
|
| 908 | - |
|
| 909 | - // data-attributes |
|
| 910 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 911 | - |
|
| 912 | - // aria-attributes |
|
| 913 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 914 | - |
|
| 915 | - // extra attributes |
|
| 916 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 917 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 918 | - } |
|
| 919 | - |
|
| 920 | - // required |
|
| 921 | - if ( ! empty( $args['required'] ) ) { |
|
| 922 | - $output .= ' required '; |
|
| 923 | - } |
|
| 924 | - |
|
| 925 | - // multiple |
|
| 926 | - if ( ! empty( $args['multiple'] ) ) { |
|
| 927 | - $output .= ' multiple '; |
|
| 928 | - } |
|
| 929 | - |
|
| 930 | - // close opening tag |
|
| 931 | - $output .= ' >'; |
|
| 932 | - |
|
| 933 | - // placeholder |
|
| 934 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) { |
|
| 935 | - $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>'; |
|
| 936 | - } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) { |
|
| 937 | - $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
|
| 938 | - } |
|
| 939 | - |
|
| 940 | - // Options |
|
| 941 | - if ( ! empty( $args['options'] ) ) { |
|
| 942 | - |
|
| 943 | - if ( ! is_array( $args['options'] ) ) { |
|
| 944 | - $output .= $args['options']; // not the preferred way but an option |
|
| 945 | - } else { |
|
| 946 | - foreach ( $args['options'] as $val => $name ) { |
|
| 947 | - $selected = ''; |
|
| 948 | - if ( is_array( $name ) ) { |
|
| 949 | - if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) { |
|
| 950 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 951 | - |
|
| 952 | - $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>'; |
|
| 953 | - } else { |
|
| 954 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 955 | - $option_value = isset( $name['value'] ) ? $name['value'] : ''; |
|
| 956 | - $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : ''; |
|
| 957 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) { |
|
| 958 | - $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : ""; |
|
| 959 | - } elseif ( ! empty( $args['value'] ) ) { |
|
| 960 | - $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false ); |
|
| 961 | - } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) { |
|
| 962 | - $selected = selected( $option_value, $args['value'], false ); |
|
| 963 | - } |
|
| 964 | - |
|
| 965 | - $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>'; |
|
| 966 | - } |
|
| 967 | - } else { |
|
| 968 | - if ( ! empty( $args['value'] ) ) { |
|
| 969 | - if ( is_array( $args['value'] ) ) { |
|
| 970 | - $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : ''; |
|
| 971 | - } elseif ( ! empty( $args['value'] ) ) { |
|
| 972 | - $selected = selected( $args['value'], $val, false ); |
|
| 973 | - } |
|
| 974 | - } elseif ( $args['value'] === $val ) { |
|
| 975 | - $selected = selected( $args['value'], $val, false ); |
|
| 976 | - } |
|
| 977 | - $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
| 978 | - } |
|
| 979 | - } |
|
| 980 | - } |
|
| 981 | - |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - // closing tag |
|
| 985 | - $output .= '</select>'; |
|
| 986 | - |
|
| 987 | - $label = ''; |
|
| 988 | - $help_text = ''; |
|
| 989 | - // label |
|
| 990 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 991 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 992 | - $label_args = array( |
|
| 993 | - 'title' => $args['label'], |
|
| 994 | - 'for' => $args['id'], |
|
| 995 | - 'class' => $args['label_class'] . " ", |
|
| 996 | - 'label_type' => $args['label_type'], |
|
| 997 | - 'label_col' => $args['label_col'] |
|
| 998 | - ); |
|
| 999 | - $label = self::label( $label_args ); |
|
| 1000 | - } |
|
| 1001 | - |
|
| 1002 | - // help text |
|
| 1003 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 1004 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 1005 | - } |
|
| 1006 | - |
|
| 1007 | - // input group wraps |
|
| 1008 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 1009 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 1010 | - if ( $args['input_group_left'] ) { |
|
| 1011 | - $output = self::wrap( array( |
|
| 1012 | - 'content' => $output, |
|
| 1013 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 1014 | - 'input_group_left' => $args['input_group_left'], |
|
| 1015 | - 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 1016 | - ) ); |
|
| 1017 | - } |
|
| 1018 | - if ( $args['input_group_right'] ) { |
|
| 1019 | - $output = self::wrap( array( |
|
| 1020 | - 'content' => $output, |
|
| 1021 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 1022 | - 'input_group_right' => $args['input_group_right'], |
|
| 1023 | - 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 1024 | - ) ); |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - } |
|
| 1028 | - |
|
| 1029 | - if ( ! $label_after ) { |
|
| 1030 | - $output .= $help_text; |
|
| 1031 | - } |
|
| 1032 | - |
|
| 1033 | - |
|
| 1034 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 1035 | - $output = self::wrap( array( |
|
| 1036 | - 'content' => $output, |
|
| 1037 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 1038 | - ) ); |
|
| 1039 | - } |
|
| 1040 | - |
|
| 1041 | - if ( ! $label_after ) { |
|
| 1042 | - $output = $label . $output; |
|
| 1043 | - } |
|
| 1044 | - |
|
| 1045 | - // maybe horizontal label |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + |
|
| 519 | + // close wrap |
|
| 520 | + $output .= '</' . sanitize_html_class( $args['type'] ) . '>'; |
|
| 521 | + |
|
| 522 | + |
|
| 523 | + } else { |
|
| 524 | + $output = $args['content']; |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + return $output; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + /** |
|
| 531 | + * Build the component. |
|
| 532 | + * |
|
| 533 | + * @param array $args |
|
| 534 | + * |
|
| 535 | + * @return string The rendered component. |
|
| 536 | + */ |
|
| 537 | + public static function textarea( $args = array() ) { |
|
| 538 | + global $aui_bs5; |
|
| 539 | + |
|
| 540 | + $defaults = array( |
|
| 541 | + 'name' => '', |
|
| 542 | + 'class' => '', |
|
| 543 | + 'wrap_class' => '', |
|
| 544 | + 'id' => '', |
|
| 545 | + 'placeholder' => '', |
|
| 546 | + 'title' => '', |
|
| 547 | + 'value' => '', |
|
| 548 | + 'required' => false, |
|
| 549 | + 'label' => '', |
|
| 550 | + 'label_after' => false, |
|
| 551 | + 'label_class' => '', |
|
| 552 | + 'label_type' => '', |
|
| 553 | + 'label_col' => '', |
|
| 554 | + // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 555 | + 'input_group_right' => '', |
|
| 556 | + 'input_group_left' => '', |
|
| 557 | + 'input_group_right_inside' => false, |
|
| 558 | + 'form_group_class' => '', |
|
| 559 | + 'help_text' => '', |
|
| 560 | + 'validation_text' => '', |
|
| 561 | + 'validation_pattern' => '', |
|
| 562 | + 'no_wrap' => false, |
|
| 563 | + 'rows' => '', |
|
| 564 | + 'wysiwyg' => false, |
|
| 565 | + 'allow_tags' => false, |
|
| 566 | + // Allow HTML tags |
|
| 567 | + 'element_require' => '', |
|
| 568 | + // [%element_id%] == "1" |
|
| 569 | + 'extra_attributes' => array(), |
|
| 570 | + // an array of extra attributes |
|
| 571 | + 'wrap_attributes' => array(), |
|
| 572 | + ); |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 576 | + */ |
|
| 577 | + $args = wp_parse_args( $args, $defaults ); |
|
| 578 | + $output = ''; |
|
| 579 | + $label = ''; |
|
| 580 | + |
|
| 581 | + // hidden label option needs to be empty |
|
| 582 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 583 | + |
|
| 584 | + // floating labels don't work with wysiwyg so set it as top |
|
| 585 | + if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) { |
|
| 586 | + $args['label_type'] = 'top'; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + $label_after = $args['label_after']; |
|
| 590 | + |
|
| 591 | + // floating labels need label after |
|
| 592 | + if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) { |
|
| 593 | + $label_after = true; |
|
| 594 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + // label |
|
| 598 | + if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 599 | + } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 600 | + $label_args = array( |
|
| 601 | + 'title' => $args['label'], |
|
| 602 | + 'for' => $args['id'], |
|
| 603 | + 'class' => $args['label_class'] . " ", |
|
| 604 | + 'label_type' => $args['label_type'], |
|
| 605 | + 'label_col' => $args['label_col'] |
|
| 606 | + ); |
|
| 607 | + $label .= self::label( $label_args ); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + // maybe horizontal label |
|
| 611 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 612 | + $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 613 | + $label .= '<div class="' . $input_col . '">'; |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + if ( ! empty( $args['wysiwyg'] ) ) { |
|
| 617 | + ob_start(); |
|
| 618 | + $content = $args['value']; |
|
| 619 | + $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor'; |
|
| 620 | + $settings = array( |
|
| 621 | + 'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4, |
|
| 622 | + 'quicktags' => false, |
|
| 623 | + 'media_buttons' => false, |
|
| 624 | + 'editor_class' => 'form-control', |
|
| 625 | + 'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ), |
|
| 626 | + 'teeny' => true, |
|
| 627 | + ); |
|
| 628 | + |
|
| 629 | + // maybe set settings if array |
|
| 630 | + if ( is_array( $args['wysiwyg'] ) ) { |
|
| 631 | + $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
| 632 | + } |
|
| 633 | + |
|
| 634 | + wp_editor( $content, $editor_id, $settings ); |
|
| 635 | + $output .= ob_get_clean(); |
|
| 636 | + } else { |
|
| 637 | + |
|
| 638 | + // open |
|
| 639 | + $output .= '<textarea '; |
|
| 640 | + |
|
| 641 | + // name |
|
| 642 | + if ( ! empty( $args['name'] ) ) { |
|
| 643 | + $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + // id |
|
| 647 | + if ( ! empty( $args['id'] ) ) { |
|
| 648 | + $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + // placeholder |
|
| 652 | + if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 653 | + $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + // title |
|
| 657 | + if ( ! empty( $args['title'] ) ) { |
|
| 658 | + $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + // validation text |
|
| 662 | + if ( ! empty( $args['validation_text'] ) ) { |
|
| 663 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" '; |
|
| 664 | + $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 665 | + } |
|
| 666 | + |
|
| 667 | + // validation_pattern |
|
| 668 | + if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 669 | + $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + // required |
|
| 673 | + if ( ! empty( $args['required'] ) ) { |
|
| 674 | + $output .= ' required '; |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + // rows |
|
| 678 | + if ( ! empty( $args['rows'] ) ) { |
|
| 679 | + $output .= ' rows="' . absint( $args['rows'] ) . '" '; |
|
| 680 | + } |
|
| 681 | + |
|
| 682 | + |
|
| 683 | + // class |
|
| 684 | + $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 685 | + $output .= ' class="form-control ' . $class . '" '; |
|
| 686 | + |
|
| 687 | + // extra attributes |
|
| 688 | + if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 689 | + $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 690 | + } |
|
| 691 | + |
|
| 692 | + // close tag |
|
| 693 | + $output .= ' >'; |
|
| 694 | + |
|
| 695 | + // value |
|
| 696 | + if ( ! empty( $args['value'] ) ) { |
|
| 697 | + if ( ! empty( $args['allow_tags'] ) ) { |
|
| 698 | + $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
| 699 | + } else { |
|
| 700 | + $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] ); |
|
| 701 | + } |
|
| 702 | + } |
|
| 703 | + |
|
| 704 | + // closing tag |
|
| 705 | + $output .= '</textarea>'; |
|
| 706 | + |
|
| 707 | + |
|
| 708 | + // input group wraps |
|
| 709 | + if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 710 | + $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 711 | + if ( $args['input_group_left'] ) { |
|
| 712 | + $output = self::wrap( array( |
|
| 713 | + 'content' => $output, |
|
| 714 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 715 | + 'input_group_left' => $args['input_group_left'], |
|
| 716 | + 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 717 | + ) ); |
|
| 718 | + } |
|
| 719 | + if ( $args['input_group_right'] ) { |
|
| 720 | + $output = self::wrap( array( |
|
| 721 | + 'content' => $output, |
|
| 722 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 723 | + 'input_group_right' => $args['input_group_right'], |
|
| 724 | + 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 725 | + ) ); |
|
| 726 | + } |
|
| 727 | + |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + |
|
| 731 | + } |
|
| 732 | + |
|
| 733 | + if ( ! empty( $args['label'] ) && $label_after ) { |
|
| 734 | + $label_args = array( |
|
| 735 | + 'title' => $args['label'], |
|
| 736 | + 'for' => $args['id'], |
|
| 737 | + 'class' => $args['label_class'] . " ", |
|
| 738 | + 'label_type' => $args['label_type'], |
|
| 739 | + 'label_col' => $args['label_col'] |
|
| 740 | + ); |
|
| 741 | + $output .= self::label( $label_args ); |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + // help text |
|
| 745 | + if ( ! empty( $args['help_text'] ) ) { |
|
| 746 | + $output .= AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 747 | + } |
|
| 748 | + |
|
| 749 | + if ( ! $label_after ) { |
|
| 750 | + $output = $label . $output; |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + // maybe horizontal label |
|
| 754 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 755 | + $output .= '</div>'; |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + |
|
| 759 | + // wrap |
|
| 760 | + if ( ! $args['no_wrap'] ) { |
|
| 761 | + if ( ! empty( $args['form_group_class'] ) ) { |
|
| 762 | + $fg_class = esc_attr( $args['form_group_class'] ); |
|
| 763 | + }else{ |
|
| 764 | + $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
|
| 765 | + } |
|
| 766 | + $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : $fg_class; |
|
| 767 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 768 | + $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 769 | + $output = self::wrap( array( |
|
| 770 | + 'content' => $output, |
|
| 771 | + 'class' => $wrap_class, |
|
| 772 | + 'element_require' => $args['element_require'], |
|
| 773 | + 'argument_id' => $args['id'], |
|
| 774 | + 'wrap_attributes' => $args['wrap_attributes'], |
|
| 775 | + ) ); |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + |
|
| 779 | + return $output; |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + /** |
|
| 783 | + * Build the component. |
|
| 784 | + * |
|
| 785 | + * @param array $args |
|
| 786 | + * |
|
| 787 | + * @return string The rendered component. |
|
| 788 | + */ |
|
| 789 | + public static function select( $args = array() ) { |
|
| 790 | + global $aui_bs5; |
|
| 791 | + $defaults = array( |
|
| 792 | + 'class' => '', |
|
| 793 | + 'wrap_class' => '', |
|
| 794 | + 'id' => '', |
|
| 795 | + 'title' => '', |
|
| 796 | + 'value' => '', |
|
| 797 | + // can be an array or a string |
|
| 798 | + 'required' => false, |
|
| 799 | + 'label' => '', |
|
| 800 | + 'label_after' => false, |
|
| 801 | + 'label_type' => '', |
|
| 802 | + 'label_col' => '', |
|
| 803 | + // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 804 | + 'label_class' => '', |
|
| 805 | + 'help_text' => '', |
|
| 806 | + 'placeholder' => '', |
|
| 807 | + 'options' => array(), |
|
| 808 | + // array or string |
|
| 809 | + 'icon' => '', |
|
| 810 | + 'multiple' => false, |
|
| 811 | + 'select2' => false, |
|
| 812 | + 'no_wrap' => false, |
|
| 813 | + 'input_group_right' => '', |
|
| 814 | + 'input_group_left' => '', |
|
| 815 | + 'input_group_right_inside' => false, // forces the input group inside the input |
|
| 816 | + 'input_group_left_inside' => false, // forces the input group inside the input |
|
| 817 | + 'form_group_class' => '', |
|
| 818 | + 'element_require' => '', |
|
| 819 | + // [%element_id%] == "1" |
|
| 820 | + 'extra_attributes' => array(), |
|
| 821 | + // an array of extra attributes |
|
| 822 | + 'wrap_attributes' => array(), |
|
| 823 | + ); |
|
| 824 | + |
|
| 825 | + /** |
|
| 826 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 827 | + */ |
|
| 828 | + $args = wp_parse_args( $args, $defaults ); |
|
| 829 | + $output = ''; |
|
| 830 | + |
|
| 831 | + // for now lets hide floating labels |
|
| 832 | + if ( $args['label_type'] == 'floating' ) { |
|
| 833 | + $args['label_type'] = 'hidden'; |
|
| 834 | + } |
|
| 835 | + |
|
| 836 | + // hidden label option needs to be empty |
|
| 837 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 838 | + |
|
| 839 | + |
|
| 840 | + $label_after = $args['label_after']; |
|
| 841 | + |
|
| 842 | + // floating labels need label after |
|
| 843 | + if ( $args['label_type'] == 'floating' ) { |
|
| 844 | + $label_after = true; |
|
| 845 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + // Maybe setup select2 |
|
| 849 | + $is_select2 = false; |
|
| 850 | + if ( ! empty( $args['select2'] ) ) { |
|
| 851 | + $args['class'] .= ' aui-select2'; |
|
| 852 | + $is_select2 = true; |
|
| 853 | + } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) { |
|
| 854 | + $is_select2 = true; |
|
| 855 | + } |
|
| 856 | + |
|
| 857 | + // select2 tags |
|
| 858 | + if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason |
|
| 859 | + $args['data-tags'] = 'true'; |
|
| 860 | + $args['data-token-separators'] = "[',']"; |
|
| 861 | + $args['multiple'] = true; |
|
| 862 | + } |
|
| 863 | + |
|
| 864 | + // select2 placeholder |
|
| 865 | + if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) { |
|
| 866 | + $args['data-placeholder'] = esc_attr( $args['placeholder'] ); |
|
| 867 | + $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true; |
|
| 868 | + } |
|
| 869 | + |
|
| 870 | + // Set hidden input to save empty value for multiselect. |
|
| 871 | + if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
| 872 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>'; |
|
| 873 | + } |
|
| 874 | + |
|
| 875 | + // open/type |
|
| 876 | + $output .= '<select '; |
|
| 877 | + |
|
| 878 | + // style |
|
| 879 | + if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
| 880 | + $output .= " style='width:100%;' "; |
|
| 881 | + } |
|
| 882 | + |
|
| 883 | + // element require |
|
| 884 | + if ( ! empty( $args['element_require'] ) ) { |
|
| 885 | + $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 886 | + $args['class'] .= " aui-conditional-field"; |
|
| 887 | + } |
|
| 888 | + |
|
| 889 | + // class |
|
| 890 | + $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 891 | + $select_class = $aui_bs5 ? 'form-select ' : 'custom-select '; |
|
| 892 | + $output .= AUI_Component_Helper::class_attr( $select_class . $class ); |
|
| 893 | + |
|
| 894 | + // name |
|
| 895 | + if ( ! empty( $args['name'] ) ) { |
|
| 896 | + $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] ); |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + // id |
|
| 900 | + if ( ! empty( $args['id'] ) ) { |
|
| 901 | + $output .= AUI_Component_Helper::id( $args['id'] ); |
|
| 902 | + } |
|
| 903 | + |
|
| 904 | + // title |
|
| 905 | + if ( ! empty( $args['title'] ) ) { |
|
| 906 | + $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 907 | + } |
|
| 908 | + |
|
| 909 | + // data-attributes |
|
| 910 | + $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 911 | + |
|
| 912 | + // aria-attributes |
|
| 913 | + $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 914 | + |
|
| 915 | + // extra attributes |
|
| 916 | + if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 917 | + $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 918 | + } |
|
| 919 | + |
|
| 920 | + // required |
|
| 921 | + if ( ! empty( $args['required'] ) ) { |
|
| 922 | + $output .= ' required '; |
|
| 923 | + } |
|
| 924 | + |
|
| 925 | + // multiple |
|
| 926 | + if ( ! empty( $args['multiple'] ) ) { |
|
| 927 | + $output .= ' multiple '; |
|
| 928 | + } |
|
| 929 | + |
|
| 930 | + // close opening tag |
|
| 931 | + $output .= ' >'; |
|
| 932 | + |
|
| 933 | + // placeholder |
|
| 934 | + if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) { |
|
| 935 | + $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>'; |
|
| 936 | + } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) { |
|
| 937 | + $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
|
| 938 | + } |
|
| 939 | + |
|
| 940 | + // Options |
|
| 941 | + if ( ! empty( $args['options'] ) ) { |
|
| 942 | + |
|
| 943 | + if ( ! is_array( $args['options'] ) ) { |
|
| 944 | + $output .= $args['options']; // not the preferred way but an option |
|
| 945 | + } else { |
|
| 946 | + foreach ( $args['options'] as $val => $name ) { |
|
| 947 | + $selected = ''; |
|
| 948 | + if ( is_array( $name ) ) { |
|
| 949 | + if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) { |
|
| 950 | + $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 951 | + |
|
| 952 | + $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>'; |
|
| 953 | + } else { |
|
| 954 | + $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 955 | + $option_value = isset( $name['value'] ) ? $name['value'] : ''; |
|
| 956 | + $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : ''; |
|
| 957 | + if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) { |
|
| 958 | + $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : ""; |
|
| 959 | + } elseif ( ! empty( $args['value'] ) ) { |
|
| 960 | + $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false ); |
|
| 961 | + } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) { |
|
| 962 | + $selected = selected( $option_value, $args['value'], false ); |
|
| 963 | + } |
|
| 964 | + |
|
| 965 | + $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>'; |
|
| 966 | + } |
|
| 967 | + } else { |
|
| 968 | + if ( ! empty( $args['value'] ) ) { |
|
| 969 | + if ( is_array( $args['value'] ) ) { |
|
| 970 | + $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : ''; |
|
| 971 | + } elseif ( ! empty( $args['value'] ) ) { |
|
| 972 | + $selected = selected( $args['value'], $val, false ); |
|
| 973 | + } |
|
| 974 | + } elseif ( $args['value'] === $val ) { |
|
| 975 | + $selected = selected( $args['value'], $val, false ); |
|
| 976 | + } |
|
| 977 | + $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
| 978 | + } |
|
| 979 | + } |
|
| 980 | + } |
|
| 981 | + |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + // closing tag |
|
| 985 | + $output .= '</select>'; |
|
| 986 | + |
|
| 987 | + $label = ''; |
|
| 988 | + $help_text = ''; |
|
| 989 | + // label |
|
| 990 | + if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 991 | + } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 992 | + $label_args = array( |
|
| 993 | + 'title' => $args['label'], |
|
| 994 | + 'for' => $args['id'], |
|
| 995 | + 'class' => $args['label_class'] . " ", |
|
| 996 | + 'label_type' => $args['label_type'], |
|
| 997 | + 'label_col' => $args['label_col'] |
|
| 998 | + ); |
|
| 999 | + $label = self::label( $label_args ); |
|
| 1000 | + } |
|
| 1001 | + |
|
| 1002 | + // help text |
|
| 1003 | + if ( ! empty( $args['help_text'] ) ) { |
|
| 1004 | + $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 1005 | + } |
|
| 1006 | + |
|
| 1007 | + // input group wraps |
|
| 1008 | + if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 1009 | + $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 1010 | + if ( $args['input_group_left'] ) { |
|
| 1011 | + $output = self::wrap( array( |
|
| 1012 | + 'content' => $output, |
|
| 1013 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 1014 | + 'input_group_left' => $args['input_group_left'], |
|
| 1015 | + 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 1016 | + ) ); |
|
| 1017 | + } |
|
| 1018 | + if ( $args['input_group_right'] ) { |
|
| 1019 | + $output = self::wrap( array( |
|
| 1020 | + 'content' => $output, |
|
| 1021 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 1022 | + 'input_group_right' => $args['input_group_right'], |
|
| 1023 | + 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 1024 | + ) ); |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + } |
|
| 1028 | + |
|
| 1029 | + if ( ! $label_after ) { |
|
| 1030 | + $output .= $help_text; |
|
| 1031 | + } |
|
| 1032 | + |
|
| 1033 | + |
|
| 1034 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 1035 | + $output = self::wrap( array( |
|
| 1036 | + 'content' => $output, |
|
| 1037 | + 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 1038 | + ) ); |
|
| 1039 | + } |
|
| 1040 | + |
|
| 1041 | + if ( ! $label_after ) { |
|
| 1042 | + $output = $label . $output; |
|
| 1043 | + } |
|
| 1044 | + |
|
| 1045 | + // maybe horizontal label |
|
| 1046 | 1046 | // if ( $args['label_type'] == 'horizontal' ) { |
| 1047 | 1047 | // $output .= '</div>'; |
| 1048 | 1048 | // } |
| 1049 | 1049 | |
| 1050 | 1050 | |
| 1051 | - // wrap |
|
| 1052 | - if ( ! $args['no_wrap'] ) { |
|
| 1053 | - if ( ! empty( $args['form_group_class'] ) ) { |
|
| 1054 | - $fg_class = esc_attr( $args['form_group_class'] ); |
|
| 1055 | - }else{ |
|
| 1056 | - $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
|
| 1057 | - } |
|
| 1058 | - $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class; |
|
| 1059 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1060 | - $output = self::wrap( array( |
|
| 1061 | - 'content' => $output, |
|
| 1062 | - 'class' => $wrap_class, |
|
| 1063 | - 'element_require' => $args['element_require'], |
|
| 1064 | - 'argument_id' => $args['id'], |
|
| 1065 | - 'wrap_attributes' => $args['wrap_attributes'], |
|
| 1066 | - ) ); |
|
| 1067 | - } |
|
| 1068 | - |
|
| 1069 | - |
|
| 1070 | - return $output; |
|
| 1071 | - } |
|
| 1072 | - |
|
| 1073 | - /** |
|
| 1074 | - * Build the component. |
|
| 1075 | - * |
|
| 1076 | - * @param array $args |
|
| 1077 | - * |
|
| 1078 | - * @return string The rendered component. |
|
| 1079 | - */ |
|
| 1080 | - public static function radio( $args = array() ) { |
|
| 1081 | - global $aui_bs5; |
|
| 1082 | - |
|
| 1083 | - $defaults = array( |
|
| 1084 | - 'class' => '', |
|
| 1085 | - 'wrap_class' => '', |
|
| 1086 | - 'id' => '', |
|
| 1087 | - 'title' => '', |
|
| 1088 | - 'horizontal' => false, |
|
| 1089 | - // sets the lable horizontal |
|
| 1090 | - 'value' => '', |
|
| 1091 | - 'label' => '', |
|
| 1092 | - 'label_class' => '', |
|
| 1093 | - 'label_type' => '', |
|
| 1094 | - 'label_col' => '', |
|
| 1095 | - // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 1096 | - 'help_text' => '', |
|
| 1097 | - 'inline' => true, |
|
| 1098 | - 'required' => false, |
|
| 1099 | - 'options' => array(), |
|
| 1100 | - 'icon' => '', |
|
| 1101 | - 'no_wrap' => false, |
|
| 1102 | - 'element_require' => '', |
|
| 1103 | - // [%element_id%] == "1" |
|
| 1104 | - 'extra_attributes' => array(), |
|
| 1105 | - // an array of extra attributes |
|
| 1106 | - 'wrap_attributes' => array() |
|
| 1107 | - ); |
|
| 1108 | - |
|
| 1109 | - /** |
|
| 1110 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 1111 | - */ |
|
| 1112 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1113 | - |
|
| 1114 | - // for now lets use horizontal for floating |
|
| 1115 | - if ( $args['label_type'] == 'floating' ) { |
|
| 1116 | - $args['label_type'] = 'horizontal'; |
|
| 1117 | - } |
|
| 1118 | - |
|
| 1119 | - $label_args = array( |
|
| 1120 | - 'title' => $args['label'], |
|
| 1121 | - 'class' => $args['label_class'] . " pt-0 ", |
|
| 1122 | - 'label_type' => $args['label_type'], |
|
| 1123 | - 'label_col' => $args['label_col'] |
|
| 1124 | - ); |
|
| 1125 | - |
|
| 1126 | - if ( $args['label_type'] == 'top' || $args['label_type'] == 'hidden' ) { |
|
| 1127 | - $label_args['class'] .= 'd-block '; |
|
| 1128 | - |
|
| 1129 | - if ( $args['label_type'] == 'hidden' ) { |
|
| 1130 | - $label_args['class'] .= 'sr-only '; |
|
| 1131 | - } |
|
| 1132 | - } |
|
| 1133 | - |
|
| 1134 | - $output = ''; |
|
| 1135 | - |
|
| 1136 | - // label before |
|
| 1137 | - if ( ! empty( $args['label'] ) ) { |
|
| 1138 | - $output .= self::label( $label_args, 'radio' ); |
|
| 1139 | - } |
|
| 1140 | - |
|
| 1141 | - // maybe horizontal label |
|
| 1142 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 1143 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 1144 | - $output .= '<div class="' . $input_col . '">'; |
|
| 1145 | - } |
|
| 1146 | - |
|
| 1147 | - if ( ! empty( $args['options'] ) ) { |
|
| 1148 | - $count = 0; |
|
| 1149 | - foreach ( $args['options'] as $value => $label ) { |
|
| 1150 | - $option_args = $args; |
|
| 1151 | - $option_args['value'] = $value; |
|
| 1152 | - $option_args['label'] = $label; |
|
| 1153 | - $option_args['checked'] = $value == $args['value'] ? true : false; |
|
| 1154 | - $output .= self::radio_option( $option_args, $count ); |
|
| 1155 | - $count ++; |
|
| 1156 | - } |
|
| 1157 | - } |
|
| 1158 | - |
|
| 1159 | - // help text |
|
| 1160 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
| 1161 | - $output .= $help_text; |
|
| 1162 | - |
|
| 1163 | - // maybe horizontal label |
|
| 1164 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 1165 | - $output .= '</div>'; |
|
| 1166 | - } |
|
| 1167 | - |
|
| 1168 | - // wrap |
|
| 1169 | - $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
|
| 1170 | - $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class; |
|
| 1171 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1172 | - $output = self::wrap( array( |
|
| 1173 | - 'content' => $output, |
|
| 1174 | - 'class' => $wrap_class, |
|
| 1175 | - 'element_require' => $args['element_require'], |
|
| 1176 | - 'argument_id' => $args['id'], |
|
| 1177 | - 'wrap_attributes' => $args['wrap_attributes'], |
|
| 1178 | - ) ); |
|
| 1179 | - |
|
| 1180 | - |
|
| 1181 | - return $output; |
|
| 1182 | - } |
|
| 1183 | - |
|
| 1184 | - /** |
|
| 1185 | - * Build the component. |
|
| 1186 | - * |
|
| 1187 | - * @param array $args |
|
| 1188 | - * |
|
| 1189 | - * @return string The rendered component. |
|
| 1190 | - */ |
|
| 1191 | - public static function radio_option( $args = array(), $count = '' ) { |
|
| 1192 | - $defaults = array( |
|
| 1193 | - 'class' => '', |
|
| 1194 | - 'id' => '', |
|
| 1195 | - 'title' => '', |
|
| 1196 | - 'value' => '', |
|
| 1197 | - 'required' => false, |
|
| 1198 | - 'inline' => true, |
|
| 1199 | - 'label' => '', |
|
| 1200 | - 'options' => array(), |
|
| 1201 | - 'icon' => '', |
|
| 1202 | - 'no_wrap' => false, |
|
| 1203 | - 'extra_attributes' => array() // an array of extra attributes |
|
| 1204 | - ); |
|
| 1205 | - |
|
| 1206 | - /** |
|
| 1207 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 1208 | - */ |
|
| 1209 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1210 | - |
|
| 1211 | - $output = ''; |
|
| 1212 | - |
|
| 1213 | - // open/type |
|
| 1214 | - $output .= '<input type="radio"'; |
|
| 1215 | - |
|
| 1216 | - // class |
|
| 1217 | - $output .= ' class="form-check-input" '; |
|
| 1218 | - |
|
| 1219 | - // name |
|
| 1220 | - if ( ! empty( $args['name'] ) ) { |
|
| 1221 | - $output .= AUI_Component_Helper::name( $args['name'] ); |
|
| 1222 | - } |
|
| 1223 | - |
|
| 1224 | - // id |
|
| 1225 | - if ( ! empty( $args['id'] ) ) { |
|
| 1226 | - $output .= AUI_Component_Helper::id( $args['id'] . $count ); |
|
| 1227 | - } |
|
| 1228 | - |
|
| 1229 | - // title |
|
| 1230 | - if ( ! empty( $args['title'] ) ) { |
|
| 1231 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 1232 | - } |
|
| 1233 | - |
|
| 1234 | - // value |
|
| 1235 | - if ( isset( $args['value'] ) ) { |
|
| 1236 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 1237 | - } |
|
| 1238 | - |
|
| 1239 | - // checked, for radio and checkboxes |
|
| 1240 | - if ( $args['checked'] ) { |
|
| 1241 | - $output .= ' checked '; |
|
| 1242 | - } |
|
| 1243 | - |
|
| 1244 | - // data-attributes |
|
| 1245 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 1246 | - |
|
| 1247 | - // aria-attributes |
|
| 1248 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 1249 | - |
|
| 1250 | - // extra attributes |
|
| 1251 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 1252 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 1253 | - } |
|
| 1254 | - |
|
| 1255 | - // required |
|
| 1256 | - if ( ! empty( $args['required'] ) ) { |
|
| 1257 | - $output .= ' required '; |
|
| 1258 | - } |
|
| 1259 | - |
|
| 1260 | - // close opening tag |
|
| 1261 | - $output .= ' >'; |
|
| 1262 | - |
|
| 1263 | - // label |
|
| 1264 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 1265 | - } elseif ( ! empty( $args['label'] ) ) { |
|
| 1266 | - $output .= self::label( array( |
|
| 1267 | - 'title' => $args['label'], |
|
| 1268 | - 'for' => $args['id'] . $count, |
|
| 1269 | - 'class' => 'form-check-label' |
|
| 1270 | - ), 'radio' ); |
|
| 1271 | - } |
|
| 1272 | - |
|
| 1273 | - // wrap |
|
| 1274 | - if ( ! $args['no_wrap'] ) { |
|
| 1275 | - $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
|
| 1276 | - |
|
| 1277 | - // Unique wrap class |
|
| 1278 | - $uniq_class = 'fwrap'; |
|
| 1279 | - if ( ! empty( $args['name'] ) ) { |
|
| 1280 | - $uniq_class .= '-' . $args['name']; |
|
| 1281 | - } else if ( ! empty( $args['id'] ) ) { |
|
| 1282 | - $uniq_class .= '-' . $args['id']; |
|
| 1283 | - } |
|
| 1284 | - |
|
| 1285 | - if ( isset( $args['value'] ) || $args['value'] !== "" ) { |
|
| 1286 | - $uniq_class .= '-' . $args['value']; |
|
| 1287 | - } else { |
|
| 1288 | - $uniq_class .= '-' . $count; |
|
| 1289 | - } |
|
| 1290 | - $wrap_class .= ' ' . sanitize_html_class( $uniq_class ); |
|
| 1291 | - |
|
| 1292 | - $output = self::wrap( array( |
|
| 1293 | - 'content' => $output, |
|
| 1294 | - 'class' => $wrap_class |
|
| 1295 | - ) ); |
|
| 1296 | - } |
|
| 1297 | - |
|
| 1298 | - return $output; |
|
| 1299 | - } |
|
| 1051 | + // wrap |
|
| 1052 | + if ( ! $args['no_wrap'] ) { |
|
| 1053 | + if ( ! empty( $args['form_group_class'] ) ) { |
|
| 1054 | + $fg_class = esc_attr( $args['form_group_class'] ); |
|
| 1055 | + }else{ |
|
| 1056 | + $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
|
| 1057 | + } |
|
| 1058 | + $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class; |
|
| 1059 | + $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1060 | + $output = self::wrap( array( |
|
| 1061 | + 'content' => $output, |
|
| 1062 | + 'class' => $wrap_class, |
|
| 1063 | + 'element_require' => $args['element_require'], |
|
| 1064 | + 'argument_id' => $args['id'], |
|
| 1065 | + 'wrap_attributes' => $args['wrap_attributes'], |
|
| 1066 | + ) ); |
|
| 1067 | + } |
|
| 1068 | + |
|
| 1069 | + |
|
| 1070 | + return $output; |
|
| 1071 | + } |
|
| 1072 | + |
|
| 1073 | + /** |
|
| 1074 | + * Build the component. |
|
| 1075 | + * |
|
| 1076 | + * @param array $args |
|
| 1077 | + * |
|
| 1078 | + * @return string The rendered component. |
|
| 1079 | + */ |
|
| 1080 | + public static function radio( $args = array() ) { |
|
| 1081 | + global $aui_bs5; |
|
| 1082 | + |
|
| 1083 | + $defaults = array( |
|
| 1084 | + 'class' => '', |
|
| 1085 | + 'wrap_class' => '', |
|
| 1086 | + 'id' => '', |
|
| 1087 | + 'title' => '', |
|
| 1088 | + 'horizontal' => false, |
|
| 1089 | + // sets the lable horizontal |
|
| 1090 | + 'value' => '', |
|
| 1091 | + 'label' => '', |
|
| 1092 | + 'label_class' => '', |
|
| 1093 | + 'label_type' => '', |
|
| 1094 | + 'label_col' => '', |
|
| 1095 | + // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 1096 | + 'help_text' => '', |
|
| 1097 | + 'inline' => true, |
|
| 1098 | + 'required' => false, |
|
| 1099 | + 'options' => array(), |
|
| 1100 | + 'icon' => '', |
|
| 1101 | + 'no_wrap' => false, |
|
| 1102 | + 'element_require' => '', |
|
| 1103 | + // [%element_id%] == "1" |
|
| 1104 | + 'extra_attributes' => array(), |
|
| 1105 | + // an array of extra attributes |
|
| 1106 | + 'wrap_attributes' => array() |
|
| 1107 | + ); |
|
| 1108 | + |
|
| 1109 | + /** |
|
| 1110 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 1111 | + */ |
|
| 1112 | + $args = wp_parse_args( $args, $defaults ); |
|
| 1113 | + |
|
| 1114 | + // for now lets use horizontal for floating |
|
| 1115 | + if ( $args['label_type'] == 'floating' ) { |
|
| 1116 | + $args['label_type'] = 'horizontal'; |
|
| 1117 | + } |
|
| 1118 | + |
|
| 1119 | + $label_args = array( |
|
| 1120 | + 'title' => $args['label'], |
|
| 1121 | + 'class' => $args['label_class'] . " pt-0 ", |
|
| 1122 | + 'label_type' => $args['label_type'], |
|
| 1123 | + 'label_col' => $args['label_col'] |
|
| 1124 | + ); |
|
| 1125 | + |
|
| 1126 | + if ( $args['label_type'] == 'top' || $args['label_type'] == 'hidden' ) { |
|
| 1127 | + $label_args['class'] .= 'd-block '; |
|
| 1128 | + |
|
| 1129 | + if ( $args['label_type'] == 'hidden' ) { |
|
| 1130 | + $label_args['class'] .= 'sr-only '; |
|
| 1131 | + } |
|
| 1132 | + } |
|
| 1133 | + |
|
| 1134 | + $output = ''; |
|
| 1135 | + |
|
| 1136 | + // label before |
|
| 1137 | + if ( ! empty( $args['label'] ) ) { |
|
| 1138 | + $output .= self::label( $label_args, 'radio' ); |
|
| 1139 | + } |
|
| 1140 | + |
|
| 1141 | + // maybe horizontal label |
|
| 1142 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 1143 | + $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 1144 | + $output .= '<div class="' . $input_col . '">'; |
|
| 1145 | + } |
|
| 1146 | + |
|
| 1147 | + if ( ! empty( $args['options'] ) ) { |
|
| 1148 | + $count = 0; |
|
| 1149 | + foreach ( $args['options'] as $value => $label ) { |
|
| 1150 | + $option_args = $args; |
|
| 1151 | + $option_args['value'] = $value; |
|
| 1152 | + $option_args['label'] = $label; |
|
| 1153 | + $option_args['checked'] = $value == $args['value'] ? true : false; |
|
| 1154 | + $output .= self::radio_option( $option_args, $count ); |
|
| 1155 | + $count ++; |
|
| 1156 | + } |
|
| 1157 | + } |
|
| 1158 | + |
|
| 1159 | + // help text |
|
| 1160 | + $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
| 1161 | + $output .= $help_text; |
|
| 1162 | + |
|
| 1163 | + // maybe horizontal label |
|
| 1164 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 1165 | + $output .= '</div>'; |
|
| 1166 | + } |
|
| 1167 | + |
|
| 1168 | + // wrap |
|
| 1169 | + $fg_class = $aui_bs5 ? 'mb-3' : 'form-group'; |
|
| 1170 | + $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class; |
|
| 1171 | + $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1172 | + $output = self::wrap( array( |
|
| 1173 | + 'content' => $output, |
|
| 1174 | + 'class' => $wrap_class, |
|
| 1175 | + 'element_require' => $args['element_require'], |
|
| 1176 | + 'argument_id' => $args['id'], |
|
| 1177 | + 'wrap_attributes' => $args['wrap_attributes'], |
|
| 1178 | + ) ); |
|
| 1179 | + |
|
| 1180 | + |
|
| 1181 | + return $output; |
|
| 1182 | + } |
|
| 1183 | + |
|
| 1184 | + /** |
|
| 1185 | + * Build the component. |
|
| 1186 | + * |
|
| 1187 | + * @param array $args |
|
| 1188 | + * |
|
| 1189 | + * @return string The rendered component. |
|
| 1190 | + */ |
|
| 1191 | + public static function radio_option( $args = array(), $count = '' ) { |
|
| 1192 | + $defaults = array( |
|
| 1193 | + 'class' => '', |
|
| 1194 | + 'id' => '', |
|
| 1195 | + 'title' => '', |
|
| 1196 | + 'value' => '', |
|
| 1197 | + 'required' => false, |
|
| 1198 | + 'inline' => true, |
|
| 1199 | + 'label' => '', |
|
| 1200 | + 'options' => array(), |
|
| 1201 | + 'icon' => '', |
|
| 1202 | + 'no_wrap' => false, |
|
| 1203 | + 'extra_attributes' => array() // an array of extra attributes |
|
| 1204 | + ); |
|
| 1205 | + |
|
| 1206 | + /** |
|
| 1207 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 1208 | + */ |
|
| 1209 | + $args = wp_parse_args( $args, $defaults ); |
|
| 1210 | + |
|
| 1211 | + $output = ''; |
|
| 1212 | + |
|
| 1213 | + // open/type |
|
| 1214 | + $output .= '<input type="radio"'; |
|
| 1215 | + |
|
| 1216 | + // class |
|
| 1217 | + $output .= ' class="form-check-input" '; |
|
| 1218 | + |
|
| 1219 | + // name |
|
| 1220 | + if ( ! empty( $args['name'] ) ) { |
|
| 1221 | + $output .= AUI_Component_Helper::name( $args['name'] ); |
|
| 1222 | + } |
|
| 1223 | + |
|
| 1224 | + // id |
|
| 1225 | + if ( ! empty( $args['id'] ) ) { |
|
| 1226 | + $output .= AUI_Component_Helper::id( $args['id'] . $count ); |
|
| 1227 | + } |
|
| 1228 | + |
|
| 1229 | + // title |
|
| 1230 | + if ( ! empty( $args['title'] ) ) { |
|
| 1231 | + $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 1232 | + } |
|
| 1233 | + |
|
| 1234 | + // value |
|
| 1235 | + if ( isset( $args['value'] ) ) { |
|
| 1236 | + $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 1237 | + } |
|
| 1238 | + |
|
| 1239 | + // checked, for radio and checkboxes |
|
| 1240 | + if ( $args['checked'] ) { |
|
| 1241 | + $output .= ' checked '; |
|
| 1242 | + } |
|
| 1243 | + |
|
| 1244 | + // data-attributes |
|
| 1245 | + $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 1246 | + |
|
| 1247 | + // aria-attributes |
|
| 1248 | + $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 1249 | + |
|
| 1250 | + // extra attributes |
|
| 1251 | + if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 1252 | + $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 1253 | + } |
|
| 1254 | + |
|
| 1255 | + // required |
|
| 1256 | + if ( ! empty( $args['required'] ) ) { |
|
| 1257 | + $output .= ' required '; |
|
| 1258 | + } |
|
| 1259 | + |
|
| 1260 | + // close opening tag |
|
| 1261 | + $output .= ' >'; |
|
| 1262 | + |
|
| 1263 | + // label |
|
| 1264 | + if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 1265 | + } elseif ( ! empty( $args['label'] ) ) { |
|
| 1266 | + $output .= self::label( array( |
|
| 1267 | + 'title' => $args['label'], |
|
| 1268 | + 'for' => $args['id'] . $count, |
|
| 1269 | + 'class' => 'form-check-label' |
|
| 1270 | + ), 'radio' ); |
|
| 1271 | + } |
|
| 1272 | + |
|
| 1273 | + // wrap |
|
| 1274 | + if ( ! $args['no_wrap'] ) { |
|
| 1275 | + $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
|
| 1276 | + |
|
| 1277 | + // Unique wrap class |
|
| 1278 | + $uniq_class = 'fwrap'; |
|
| 1279 | + if ( ! empty( $args['name'] ) ) { |
|
| 1280 | + $uniq_class .= '-' . $args['name']; |
|
| 1281 | + } else if ( ! empty( $args['id'] ) ) { |
|
| 1282 | + $uniq_class .= '-' . $args['id']; |
|
| 1283 | + } |
|
| 1284 | + |
|
| 1285 | + if ( isset( $args['value'] ) || $args['value'] !== "" ) { |
|
| 1286 | + $uniq_class .= '-' . $args['value']; |
|
| 1287 | + } else { |
|
| 1288 | + $uniq_class .= '-' . $count; |
|
| 1289 | + } |
|
| 1290 | + $wrap_class .= ' ' . sanitize_html_class( $uniq_class ); |
|
| 1291 | + |
|
| 1292 | + $output = self::wrap( array( |
|
| 1293 | + 'content' => $output, |
|
| 1294 | + 'class' => $wrap_class |
|
| 1295 | + ) ); |
|
| 1296 | + } |
|
| 1297 | + |
|
| 1298 | + return $output; |
|
| 1299 | + } |
|
| 1300 | 1300 | |
| 1301 | 1301 | } |
| 1302 | 1302 | \ No newline at end of file |
@@ -14,75 +14,75 @@ |
||
| 14 | 14 | * @return array|mixed|string|string[] |
| 15 | 15 | */ |
| 16 | 16 | function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) { |
| 17 | - global $aui_bs5; |
|
| 17 | + global $aui_bs5; |
|
| 18 | 18 | |
| 19 | - if ( $aui_bs5 ) { |
|
| 20 | - $convert = array( |
|
| 21 | - '"ml-' => '"ms-', |
|
| 22 | - '"mr-' => '"me-', |
|
| 23 | - '"pl-' => '"ps-', |
|
| 24 | - '"pr-' => '"pe-', |
|
| 25 | - "'ml-" => "'ms-", |
|
| 26 | - "'mr-" => "'me-", |
|
| 27 | - "'pl-" => "'ps-", |
|
| 28 | - "'pr-" => "'pe-", |
|
| 29 | - ' ml-' => ' ms-', |
|
| 30 | - ' mr-' => ' me-', |
|
| 31 | - ' pl-' => ' ps-', |
|
| 32 | - ' pr-' => ' pe-', |
|
| 33 | - '.ml-' => '.ms-', |
|
| 34 | - '.mr-' => '.me-', |
|
| 35 | - '.pl-' => '.ps-', |
|
| 36 | - '.pr-' => '.pe-', |
|
| 37 | - ' form-row' => ' row', |
|
| 38 | - ' embed-responsive-item' => '', |
|
| 39 | - ' embed-responsive' => ' ratio', |
|
| 40 | - '-1by1' => '-1x1', |
|
| 41 | - '-4by3' => '-4x3', |
|
| 42 | - '-16by9' => '-16x9', |
|
| 43 | - '-21by9' => '-21x9', |
|
| 44 | - 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
| 45 | - ' badge-' => ' text-bg-', |
|
| 46 | - 'form-group' => 'mb-3', |
|
| 47 | - 'custom-select' => 'form-select', |
|
| 48 | - 'float-left' => 'float-start', |
|
| 49 | - 'float-right' => 'float-end', |
|
| 50 | - 'text-left' => 'text-start', |
|
| 51 | - 'text-sm-left' => 'text-sm-start', |
|
| 52 | - 'text-md-left' => 'text-md-start', |
|
| 53 | - 'text-lg-left' => 'text-lg-start', |
|
| 54 | - 'text-right' => 'text-end', |
|
| 55 | - 'text-sm-right' => 'text-sm-end', |
|
| 56 | - 'text-md-right' => 'text-md-end', |
|
| 57 | - 'text-lg-right' => 'text-lg-end', |
|
| 58 | - 'border-right' => 'border-end', |
|
| 59 | - 'border-left' => 'border-start', |
|
| 60 | - 'font-weight-' => 'fw-', |
|
| 61 | - 'btn-block' => 'w-100', |
|
| 62 | - 'rounded-left' => 'rounded-start', |
|
| 63 | - 'rounded-right' => 'rounded-end', |
|
| 64 | - 'font-italic' => 'fst-italic', |
|
| 19 | + if ( $aui_bs5 ) { |
|
| 20 | + $convert = array( |
|
| 21 | + '"ml-' => '"ms-', |
|
| 22 | + '"mr-' => '"me-', |
|
| 23 | + '"pl-' => '"ps-', |
|
| 24 | + '"pr-' => '"pe-', |
|
| 25 | + "'ml-" => "'ms-", |
|
| 26 | + "'mr-" => "'me-", |
|
| 27 | + "'pl-" => "'ps-", |
|
| 28 | + "'pr-" => "'pe-", |
|
| 29 | + ' ml-' => ' ms-', |
|
| 30 | + ' mr-' => ' me-', |
|
| 31 | + ' pl-' => ' ps-', |
|
| 32 | + ' pr-' => ' pe-', |
|
| 33 | + '.ml-' => '.ms-', |
|
| 34 | + '.mr-' => '.me-', |
|
| 35 | + '.pl-' => '.ps-', |
|
| 36 | + '.pr-' => '.pe-', |
|
| 37 | + ' form-row' => ' row', |
|
| 38 | + ' embed-responsive-item' => '', |
|
| 39 | + ' embed-responsive' => ' ratio', |
|
| 40 | + '-1by1' => '-1x1', |
|
| 41 | + '-4by3' => '-4x3', |
|
| 42 | + '-16by9' => '-16x9', |
|
| 43 | + '-21by9' => '-21x9', |
|
| 44 | + 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
| 45 | + ' badge-' => ' text-bg-', |
|
| 46 | + 'form-group' => 'mb-3', |
|
| 47 | + 'custom-select' => 'form-select', |
|
| 48 | + 'float-left' => 'float-start', |
|
| 49 | + 'float-right' => 'float-end', |
|
| 50 | + 'text-left' => 'text-start', |
|
| 51 | + 'text-sm-left' => 'text-sm-start', |
|
| 52 | + 'text-md-left' => 'text-md-start', |
|
| 53 | + 'text-lg-left' => 'text-lg-start', |
|
| 54 | + 'text-right' => 'text-end', |
|
| 55 | + 'text-sm-right' => 'text-sm-end', |
|
| 56 | + 'text-md-right' => 'text-md-end', |
|
| 57 | + 'text-lg-right' => 'text-lg-end', |
|
| 58 | + 'border-right' => 'border-end', |
|
| 59 | + 'border-left' => 'border-start', |
|
| 60 | + 'font-weight-' => 'fw-', |
|
| 61 | + 'btn-block' => 'w-100', |
|
| 62 | + 'rounded-left' => 'rounded-start', |
|
| 63 | + 'rounded-right' => 'rounded-end', |
|
| 64 | + 'font-italic' => 'fst-italic', |
|
| 65 | 65 | |
| 66 | 66 | // 'custom-control custom-checkbox' => 'form-check', |
| 67 | - // data |
|
| 68 | - ' data-toggle=' => ' data-bs-toggle=', |
|
| 69 | - 'data-ride=' => 'data-bs-ride=', |
|
| 70 | - 'data-controlnav=' => 'data-bs-controlnav=', |
|
| 71 | - 'data-slide=' => 'data-bs-slide=', |
|
| 72 | - 'data-slide-to=' => 'data-bs-slide-to=', |
|
| 73 | - 'data-target=' => 'data-bs-target=', |
|
| 74 | - 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
| 75 | - 'class="close"' => 'class="btn-close"', |
|
| 76 | - '<span aria-hidden="true">×</span>' => '', |
|
| 77 | - ); |
|
| 78 | - $output = str_replace( |
|
| 79 | - array_keys( $convert ), |
|
| 80 | - array_values( $convert ), |
|
| 81 | - $output |
|
| 82 | - ); |
|
| 83 | - } |
|
| 67 | + // data |
|
| 68 | + ' data-toggle=' => ' data-bs-toggle=', |
|
| 69 | + 'data-ride=' => 'data-bs-ride=', |
|
| 70 | + 'data-controlnav=' => 'data-bs-controlnav=', |
|
| 71 | + 'data-slide=' => 'data-bs-slide=', |
|
| 72 | + 'data-slide-to=' => 'data-bs-slide-to=', |
|
| 73 | + 'data-target=' => 'data-bs-target=', |
|
| 74 | + 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
| 75 | + 'class="close"' => 'class="btn-close"', |
|
| 76 | + '<span aria-hidden="true">×</span>' => '', |
|
| 77 | + ); |
|
| 78 | + $output = str_replace( |
|
| 79 | + array_keys( $convert ), |
|
| 80 | + array_values( $convert ), |
|
| 81 | + $output |
|
| 82 | + ); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - return $output; |
|
| 85 | + return $output; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -21,480 +21,480 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * A Class to be able to change settings for Font Awesome. |
|
| 26 | - * |
|
| 27 | - * Class AyeCode_UI_Settings |
|
| 28 | - * @ver 1.0.0 |
|
| 29 | - * @todo decide how to implement textdomain |
|
| 30 | - */ |
|
| 31 | - class AyeCode_UI_Settings { |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Class version version. |
|
| 35 | - * |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - public $version = '0.2.15'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Class textdomain. |
|
| 42 | - * |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - public $textdomain = 'aui'; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Latest version of Bootstrap at time of publish published. |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - public $latest = "5.2.2"; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Current version of select2 being used. |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - public $select2_version = "4.0.11"; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * The title. |
|
| 63 | - * |
|
| 64 | - * @var string |
|
| 65 | - */ |
|
| 66 | - public $name = 'AyeCode UI'; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * The relative url to the assets. |
|
| 70 | - * |
|
| 71 | - * @var string |
|
| 72 | - */ |
|
| 73 | - public $url = ''; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Holds the settings values. |
|
| 77 | - * |
|
| 78 | - * @var array |
|
| 79 | - */ |
|
| 80 | - private $settings; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * AyeCode_UI_Settings instance. |
|
| 84 | - * |
|
| 85 | - * @access private |
|
| 86 | - * @since 1.0.0 |
|
| 87 | - * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | - */ |
|
| 89 | - private static $instance = null; |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Main AyeCode_UI_Settings Instance. |
|
| 94 | - * |
|
| 95 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 96 | - * |
|
| 97 | - * @since 1.0.0 |
|
| 98 | - * @static |
|
| 99 | - * @return AyeCode_UI_Settings - Main instance. |
|
| 100 | - */ |
|
| 101 | - public static function instance() { |
|
| 102 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 103 | - |
|
| 104 | - self::$instance = new AyeCode_UI_Settings; |
|
| 105 | - |
|
| 106 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 107 | - |
|
| 108 | - if ( is_admin() ) { |
|
| 109 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 110 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 111 | - |
|
| 112 | - // Maybe show example page |
|
| 113 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 114 | - |
|
| 115 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 116 | - add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 ); |
|
| 117 | - } |
|
| 118 | - } |
|
| 24 | + /** |
|
| 25 | + * A Class to be able to change settings for Font Awesome. |
|
| 26 | + * |
|
| 27 | + * Class AyeCode_UI_Settings |
|
| 28 | + * @ver 1.0.0 |
|
| 29 | + * @todo decide how to implement textdomain |
|
| 30 | + */ |
|
| 31 | + class AyeCode_UI_Settings { |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Class version version. |
|
| 35 | + * |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + public $version = '0.2.15'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Class textdomain. |
|
| 42 | + * |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + public $textdomain = 'aui'; |
|
| 119 | 46 | |
| 120 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 47 | + /** |
|
| 48 | + * Latest version of Bootstrap at time of publish published. |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + public $latest = "5.2.2"; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Current version of select2 being used. |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + public $select2_version = "4.0.11"; |
|
| 121 | 60 | |
| 122 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 123 | - } |
|
| 61 | + /** |
|
| 62 | + * The title. |
|
| 63 | + * |
|
| 64 | + * @var string |
|
| 65 | + */ |
|
| 66 | + public $name = 'AyeCode UI'; |
|
| 124 | 67 | |
| 125 | - return self::$instance; |
|
| 126 | - } |
|
| 68 | + /** |
|
| 69 | + * The relative url to the assets. |
|
| 70 | + * |
|
| 71 | + * @var string |
|
| 72 | + */ |
|
| 73 | + public $url = ''; |
|
| 127 | 74 | |
| 128 | - /** |
|
| 129 | - * Add custom colors to the color selector. |
|
| 130 | - * |
|
| 131 | - * @param $theme_colors |
|
| 132 | - * @param $include_outlines |
|
| 133 | - * @param $include_branding |
|
| 134 | - * |
|
| 135 | - * @return mixed |
|
| 136 | - */ |
|
| 137 | - public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){ |
|
| 75 | + /** |
|
| 76 | + * Holds the settings values. |
|
| 77 | + * |
|
| 78 | + * @var array |
|
| 79 | + */ |
|
| 80 | + private $settings; |
|
| 138 | 81 | |
| 82 | + /** |
|
| 83 | + * AyeCode_UI_Settings instance. |
|
| 84 | + * |
|
| 85 | + * @access private |
|
| 86 | + * @since 1.0.0 |
|
| 87 | + * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | + */ |
|
| 89 | + private static $instance = null; |
|
| 139 | 90 | |
| 140 | - $setting = wp_get_global_settings(); |
|
| 141 | 91 | |
| 142 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 143 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 144 | - $theme_colors[$color['slug']] = esc_attr($color['name']); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return $theme_colors; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Setup some constants. |
|
| 153 | - */ |
|
| 154 | - public function constants(){ |
|
| 155 | - define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" ); |
|
| 156 | - define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' ); |
|
| 157 | - define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' ); |
|
| 158 | - define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' ); |
|
| 159 | - define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' ); |
|
| 160 | - define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' ); |
|
| 161 | - define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' ); |
|
| 162 | - define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' ); |
|
| 163 | - define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' ); |
|
| 164 | - define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' ); |
|
| 165 | - define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' ); |
|
| 166 | - define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' ); |
|
| 167 | - define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' ); |
|
| 168 | - define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' ); |
|
| 169 | - define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' ); |
|
| 170 | - define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' ); |
|
| 171 | - |
|
| 172 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 173 | - define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL ); |
|
| 174 | - } |
|
| 175 | - if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) { |
|
| 176 | - define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL ); |
|
| 177 | - } |
|
| 178 | - if ( ! defined( 'AUI_INFO_COLOR' ) ) { |
|
| 179 | - define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL ); |
|
| 180 | - } |
|
| 181 | - if ( ! defined( 'AUI_WARNING_COLOR' ) ) { |
|
| 182 | - define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL ); |
|
| 183 | - } |
|
| 184 | - if ( ! defined( 'AUI_DANGER_COLOR' ) ) { |
|
| 185 | - define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL ); |
|
| 186 | - } |
|
| 187 | - if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) { |
|
| 188 | - define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL ); |
|
| 189 | - } |
|
| 190 | - if ( ! defined( 'AUI_LIGHT_COLOR' ) ) { |
|
| 191 | - define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL ); |
|
| 192 | - } |
|
| 193 | - if ( ! defined( 'AUI_DARK_COLOR' ) ) { |
|
| 194 | - define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL ); |
|
| 195 | - } |
|
| 196 | - if ( ! defined( 'AUI_WHITE_COLOR' ) ) { |
|
| 197 | - define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL ); |
|
| 198 | - } |
|
| 199 | - if ( ! defined( 'AUI_PURPLE_COLOR' ) ) { |
|
| 200 | - define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL ); |
|
| 201 | - } |
|
| 202 | - if ( ! defined( 'AUI_SALMON_COLOR' ) ) { |
|
| 203 | - define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL ); |
|
| 204 | - } |
|
| 205 | - if ( ! defined( 'AUI_CYAN_COLOR' ) ) { |
|
| 206 | - define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL ); |
|
| 207 | - } |
|
| 208 | - if ( ! defined( 'AUI_GRAY_COLOR' ) ) { |
|
| 209 | - define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL ); |
|
| 210 | - } |
|
| 211 | - if ( ! defined( 'AUI_INDIGO_COLOR' ) ) { |
|
| 212 | - define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL ); |
|
| 213 | - } |
|
| 214 | - if ( ! defined( 'AUI_ORANGE_COLOR' ) ) { |
|
| 215 | - define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL ); |
|
| 216 | - } |
|
| 217 | - if ( ! defined( 'AUI_BLACK_COLOR' ) ) { |
|
| 218 | - define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL ); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - public static function get_colors( $original = false){ |
|
| 224 | - |
|
| 225 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 226 | - return array(); |
|
| 227 | - } |
|
| 228 | - if ( $original ) { |
|
| 229 | - return array( |
|
| 230 | - 'primary' => AUI_PRIMARY_COLOR_ORIGINAL, |
|
| 231 | - 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, |
|
| 232 | - 'info' => AUI_INFO_COLOR_ORIGINAL, |
|
| 233 | - 'warning' => AUI_WARNING_COLOR_ORIGINAL, |
|
| 234 | - 'danger' => AUI_DANGER_COLOR_ORIGINAL, |
|
| 235 | - 'success' => AUI_SUCCESS_COLOR_ORIGINAL, |
|
| 236 | - 'light' => AUI_LIGHT_COLOR_ORIGINAL, |
|
| 237 | - 'dark' => AUI_DARK_COLOR_ORIGINAL, |
|
| 238 | - 'white' => AUI_WHITE_COLOR_ORIGINAL, |
|
| 239 | - 'purple' => AUI_PURPLE_COLOR_ORIGINAL, |
|
| 240 | - 'salmon' => AUI_SALMON_COLOR_ORIGINAL, |
|
| 241 | - 'cyan' => AUI_CYAN_COLOR_ORIGINAL, |
|
| 242 | - 'gray' => AUI_GRAY_COLOR_ORIGINAL, |
|
| 243 | - 'indigo' => AUI_INDIGO_COLOR_ORIGINAL, |
|
| 244 | - 'orange' => AUI_ORANGE_COLOR_ORIGINAL, |
|
| 245 | - 'black' => AUI_BLACK_COLOR_ORIGINAL, |
|
| 246 | - ); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - return array( |
|
| 250 | - 'primary' => AUI_PRIMARY_COLOR, |
|
| 251 | - 'secondary' => AUI_SECONDARY_COLOR, |
|
| 252 | - 'info' => AUI_INFO_COLOR, |
|
| 253 | - 'warning' => AUI_WARNING_COLOR, |
|
| 254 | - 'danger' => AUI_DANGER_COLOR, |
|
| 255 | - 'success' => AUI_SUCCESS_COLOR, |
|
| 256 | - 'light' => AUI_LIGHT_COLOR, |
|
| 257 | - 'dark' => AUI_DARK_COLOR, |
|
| 258 | - 'white' => AUI_WHITE_COLOR, |
|
| 259 | - 'purple' => AUI_PURPLE_COLOR, |
|
| 260 | - 'salmon' => AUI_SALMON_COLOR, |
|
| 261 | - 'cyan' => AUI_CYAN_COLOR, |
|
| 262 | - 'gray' => AUI_GRAY_COLOR, |
|
| 263 | - 'indigo' => AUI_INDIGO_COLOR, |
|
| 264 | - 'orange' => AUI_ORANGE_COLOR, |
|
| 265 | - 'black' => AUI_BLACK_COLOR, |
|
| 266 | - ); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Add admin body class to show when BS5 is active. |
|
| 271 | - * |
|
| 272 | - * @param $classes |
|
| 273 | - * |
|
| 274 | - * @return mixed |
|
| 275 | - */ |
|
| 276 | - public function add_bs5_admin_body_class( $classes = '' ) { |
|
| 277 | - $classes .= ' aui_bs5'; |
|
| 278 | - |
|
| 279 | - return $classes; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * Add a body class to show when BS5 is active. |
|
| 284 | - * |
|
| 285 | - * @param $classes |
|
| 286 | - * |
|
| 287 | - * @return mixed |
|
| 288 | - */ |
|
| 289 | - public function add_bs5_body_class( $classes ) { |
|
| 290 | - $classes[] = 'aui_bs5'; |
|
| 291 | - |
|
| 292 | - return $classes; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * Initiate the settings and add the required action hooks. |
|
| 297 | - */ |
|
| 298 | - public function init() { |
|
| 92 | + /** |
|
| 93 | + * Main AyeCode_UI_Settings Instance. |
|
| 94 | + * |
|
| 95 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 96 | + * |
|
| 97 | + * @since 1.0.0 |
|
| 98 | + * @static |
|
| 99 | + * @return AyeCode_UI_Settings - Main instance. |
|
| 100 | + */ |
|
| 101 | + public static function instance() { |
|
| 102 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 103 | + |
|
| 104 | + self::$instance = new AyeCode_UI_Settings; |
|
| 105 | + |
|
| 106 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 107 | + |
|
| 108 | + if ( is_admin() ) { |
|
| 109 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 110 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 111 | + |
|
| 112 | + // Maybe show example page |
|
| 113 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 114 | + |
|
| 115 | + if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 116 | + add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 ); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 121 | + |
|
| 122 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + return self::$instance; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * Add custom colors to the color selector. |
|
| 130 | + * |
|
| 131 | + * @param $theme_colors |
|
| 132 | + * @param $include_outlines |
|
| 133 | + * @param $include_branding |
|
| 134 | + * |
|
| 135 | + * @return mixed |
|
| 136 | + */ |
|
| 137 | + public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){ |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + $setting = wp_get_global_settings(); |
|
| 141 | + |
|
| 142 | + if(!empty($setting['color']['palette']['custom'])){ |
|
| 143 | + foreach($setting['color']['palette']['custom'] as $color){ |
|
| 144 | + $theme_colors[$color['slug']] = esc_attr($color['name']); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return $theme_colors; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Setup some constants. |
|
| 153 | + */ |
|
| 154 | + public function constants(){ |
|
| 155 | + define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" ); |
|
| 156 | + define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' ); |
|
| 157 | + define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' ); |
|
| 158 | + define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' ); |
|
| 159 | + define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' ); |
|
| 160 | + define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' ); |
|
| 161 | + define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' ); |
|
| 162 | + define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' ); |
|
| 163 | + define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' ); |
|
| 164 | + define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' ); |
|
| 165 | + define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' ); |
|
| 166 | + define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' ); |
|
| 167 | + define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' ); |
|
| 168 | + define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' ); |
|
| 169 | + define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' ); |
|
| 170 | + define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' ); |
|
| 171 | + |
|
| 172 | + if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 173 | + define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL ); |
|
| 174 | + } |
|
| 175 | + if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) { |
|
| 176 | + define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL ); |
|
| 177 | + } |
|
| 178 | + if ( ! defined( 'AUI_INFO_COLOR' ) ) { |
|
| 179 | + define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL ); |
|
| 180 | + } |
|
| 181 | + if ( ! defined( 'AUI_WARNING_COLOR' ) ) { |
|
| 182 | + define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL ); |
|
| 183 | + } |
|
| 184 | + if ( ! defined( 'AUI_DANGER_COLOR' ) ) { |
|
| 185 | + define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL ); |
|
| 186 | + } |
|
| 187 | + if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) { |
|
| 188 | + define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL ); |
|
| 189 | + } |
|
| 190 | + if ( ! defined( 'AUI_LIGHT_COLOR' ) ) { |
|
| 191 | + define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL ); |
|
| 192 | + } |
|
| 193 | + if ( ! defined( 'AUI_DARK_COLOR' ) ) { |
|
| 194 | + define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL ); |
|
| 195 | + } |
|
| 196 | + if ( ! defined( 'AUI_WHITE_COLOR' ) ) { |
|
| 197 | + define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL ); |
|
| 198 | + } |
|
| 199 | + if ( ! defined( 'AUI_PURPLE_COLOR' ) ) { |
|
| 200 | + define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL ); |
|
| 201 | + } |
|
| 202 | + if ( ! defined( 'AUI_SALMON_COLOR' ) ) { |
|
| 203 | + define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL ); |
|
| 204 | + } |
|
| 205 | + if ( ! defined( 'AUI_CYAN_COLOR' ) ) { |
|
| 206 | + define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL ); |
|
| 207 | + } |
|
| 208 | + if ( ! defined( 'AUI_GRAY_COLOR' ) ) { |
|
| 209 | + define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL ); |
|
| 210 | + } |
|
| 211 | + if ( ! defined( 'AUI_INDIGO_COLOR' ) ) { |
|
| 212 | + define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL ); |
|
| 213 | + } |
|
| 214 | + if ( ! defined( 'AUI_ORANGE_COLOR' ) ) { |
|
| 215 | + define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL ); |
|
| 216 | + } |
|
| 217 | + if ( ! defined( 'AUI_BLACK_COLOR' ) ) { |
|
| 218 | + define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL ); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + public static function get_colors( $original = false){ |
|
| 224 | + |
|
| 225 | + if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 226 | + return array(); |
|
| 227 | + } |
|
| 228 | + if ( $original ) { |
|
| 229 | + return array( |
|
| 230 | + 'primary' => AUI_PRIMARY_COLOR_ORIGINAL, |
|
| 231 | + 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, |
|
| 232 | + 'info' => AUI_INFO_COLOR_ORIGINAL, |
|
| 233 | + 'warning' => AUI_WARNING_COLOR_ORIGINAL, |
|
| 234 | + 'danger' => AUI_DANGER_COLOR_ORIGINAL, |
|
| 235 | + 'success' => AUI_SUCCESS_COLOR_ORIGINAL, |
|
| 236 | + 'light' => AUI_LIGHT_COLOR_ORIGINAL, |
|
| 237 | + 'dark' => AUI_DARK_COLOR_ORIGINAL, |
|
| 238 | + 'white' => AUI_WHITE_COLOR_ORIGINAL, |
|
| 239 | + 'purple' => AUI_PURPLE_COLOR_ORIGINAL, |
|
| 240 | + 'salmon' => AUI_SALMON_COLOR_ORIGINAL, |
|
| 241 | + 'cyan' => AUI_CYAN_COLOR_ORIGINAL, |
|
| 242 | + 'gray' => AUI_GRAY_COLOR_ORIGINAL, |
|
| 243 | + 'indigo' => AUI_INDIGO_COLOR_ORIGINAL, |
|
| 244 | + 'orange' => AUI_ORANGE_COLOR_ORIGINAL, |
|
| 245 | + 'black' => AUI_BLACK_COLOR_ORIGINAL, |
|
| 246 | + ); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + return array( |
|
| 250 | + 'primary' => AUI_PRIMARY_COLOR, |
|
| 251 | + 'secondary' => AUI_SECONDARY_COLOR, |
|
| 252 | + 'info' => AUI_INFO_COLOR, |
|
| 253 | + 'warning' => AUI_WARNING_COLOR, |
|
| 254 | + 'danger' => AUI_DANGER_COLOR, |
|
| 255 | + 'success' => AUI_SUCCESS_COLOR, |
|
| 256 | + 'light' => AUI_LIGHT_COLOR, |
|
| 257 | + 'dark' => AUI_DARK_COLOR, |
|
| 258 | + 'white' => AUI_WHITE_COLOR, |
|
| 259 | + 'purple' => AUI_PURPLE_COLOR, |
|
| 260 | + 'salmon' => AUI_SALMON_COLOR, |
|
| 261 | + 'cyan' => AUI_CYAN_COLOR, |
|
| 262 | + 'gray' => AUI_GRAY_COLOR, |
|
| 263 | + 'indigo' => AUI_INDIGO_COLOR, |
|
| 264 | + 'orange' => AUI_ORANGE_COLOR, |
|
| 265 | + 'black' => AUI_BLACK_COLOR, |
|
| 266 | + ); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Add admin body class to show when BS5 is active. |
|
| 271 | + * |
|
| 272 | + * @param $classes |
|
| 273 | + * |
|
| 274 | + * @return mixed |
|
| 275 | + */ |
|
| 276 | + public function add_bs5_admin_body_class( $classes = '' ) { |
|
| 277 | + $classes .= ' aui_bs5'; |
|
| 278 | + |
|
| 279 | + return $classes; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * Add a body class to show when BS5 is active. |
|
| 284 | + * |
|
| 285 | + * @param $classes |
|
| 286 | + * |
|
| 287 | + * @return mixed |
|
| 288 | + */ |
|
| 289 | + public function add_bs5_body_class( $classes ) { |
|
| 290 | + $classes[] = 'aui_bs5'; |
|
| 291 | + |
|
| 292 | + return $classes; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * Initiate the settings and add the required action hooks. |
|
| 297 | + */ |
|
| 298 | + public function init() { |
|
| 299 | 299 | global $aui_bs5; |
| 300 | 300 | |
| 301 | - // Maybe fix settings |
|
| 302 | - if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 303 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 304 | - if ( ! empty( $db_settings ) ) { |
|
| 305 | - $db_settings['css_backend'] = 'compatibility'; |
|
| 306 | - $db_settings['js_backend'] = 'core-popper'; |
|
| 307 | - update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 308 | - wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 309 | - } |
|
| 310 | - } |
|
| 301 | + // Maybe fix settings |
|
| 302 | + if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 303 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 304 | + if ( ! empty( $db_settings ) ) { |
|
| 305 | + $db_settings['css_backend'] = 'compatibility'; |
|
| 306 | + $db_settings['js_backend'] = 'core-popper'; |
|
| 307 | + update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 308 | + wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - $this->constants(); |
|
| 313 | - $this->settings = $this->get_settings(); |
|
| 314 | - $this->url = $this->get_url(); |
|
| 312 | + $this->constants(); |
|
| 313 | + $this->settings = $this->get_settings(); |
|
| 314 | + $this->url = $this->get_url(); |
|
| 315 | 315 | |
| 316 | 316 | // define the version |
| 317 | - $aui_bs5 = $this->settings['bs_ver'] === '5'; |
|
| 318 | - |
|
| 319 | - if ( $aui_bs5 ) { |
|
| 320 | - include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' ); |
|
| 321 | - add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 ); |
|
| 322 | - add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) ); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * Maybe load CSS |
|
| 327 | - * |
|
| 328 | - * We load super early in case there is a theme version that might change the colors |
|
| 329 | - */ |
|
| 330 | - if ( $this->settings['css'] ) { |
|
| 331 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 317 | + $aui_bs5 = $this->settings['bs_ver'] === '5'; |
|
| 318 | + |
|
| 319 | + if ( $aui_bs5 ) { |
|
| 320 | + include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' ); |
|
| 321 | + add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 ); |
|
| 322 | + add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) ); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * Maybe load CSS |
|
| 327 | + * |
|
| 328 | + * We load super early in case there is a theme version that might change the colors |
|
| 329 | + */ |
|
| 330 | + if ( $this->settings['css'] ) { |
|
| 331 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 332 | 332 | $priority = $aui_bs5 ? 10 : $priority; |
| 333 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 334 | - } |
|
| 335 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 336 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - // maybe load JS |
|
| 340 | - if ( $this->settings['js'] ) { |
|
| 341 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 342 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 343 | - } |
|
| 344 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 345 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - // Maybe set the HTML font size |
|
| 349 | - if ( $this->settings['html_font_size'] ) { |
|
| 350 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - // Maybe show backend style error |
|
| 354 | - if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 355 | - add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * Show admin notice if backend scripts not loaded. |
|
| 362 | - */ |
|
| 363 | - public function show_admin_style_notice(){ |
|
| 364 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 365 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 366 | - $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 367 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * Check if we should load the admin scripts or not. |
|
| 372 | - * |
|
| 373 | - * @return bool |
|
| 374 | - */ |
|
| 375 | - public function load_admin_scripts(){ |
|
| 376 | - $result = true; |
|
| 377 | - |
|
| 378 | - // check if specifically disabled |
|
| 379 | - if(!empty($this->settings['disable_admin'])){ |
|
| 380 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 381 | - foreach($url_parts as $part){ |
|
| 382 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 383 | - return false; // return early, no point checking further |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - return $result; |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * Add a html font size to the footer. |
|
| 393 | - */ |
|
| 394 | - public function html_font_size(){ |
|
| 395 | - $this->settings = $this->get_settings(); |
|
| 396 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * Check if the current admin screen should load scripts. |
|
| 401 | - * |
|
| 402 | - * @return bool |
|
| 403 | - */ |
|
| 404 | - public function is_aui_screen(){ |
|
| 333 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 334 | + } |
|
| 335 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 336 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + // maybe load JS |
|
| 340 | + if ( $this->settings['js'] ) { |
|
| 341 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 342 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 343 | + } |
|
| 344 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 345 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + // Maybe set the HTML font size |
|
| 349 | + if ( $this->settings['html_font_size'] ) { |
|
| 350 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + // Maybe show backend style error |
|
| 354 | + if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 355 | + add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * Show admin notice if backend scripts not loaded. |
|
| 362 | + */ |
|
| 363 | + public function show_admin_style_notice(){ |
|
| 364 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 365 | + $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 366 | + $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 367 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * Check if we should load the admin scripts or not. |
|
| 372 | + * |
|
| 373 | + * @return bool |
|
| 374 | + */ |
|
| 375 | + public function load_admin_scripts(){ |
|
| 376 | + $result = true; |
|
| 377 | + |
|
| 378 | + // check if specifically disabled |
|
| 379 | + if(!empty($this->settings['disable_admin'])){ |
|
| 380 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 381 | + foreach($url_parts as $part){ |
|
| 382 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 383 | + return false; // return early, no point checking further |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + return $result; |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * Add a html font size to the footer. |
|
| 393 | + */ |
|
| 394 | + public function html_font_size(){ |
|
| 395 | + $this->settings = $this->get_settings(); |
|
| 396 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * Check if the current admin screen should load scripts. |
|
| 401 | + * |
|
| 402 | + * @return bool |
|
| 403 | + */ |
|
| 404 | + public function is_aui_screen(){ |
|
| 405 | 405 | // echo '###';exit; |
| 406 | - $load = false; |
|
| 407 | - // check if we should load or not |
|
| 408 | - if ( is_admin() ) { |
|
| 409 | - // Only enable on set pages |
|
| 410 | - $aui_screens = array( |
|
| 411 | - 'page', |
|
| 406 | + $load = false; |
|
| 407 | + // check if we should load or not |
|
| 408 | + if ( is_admin() ) { |
|
| 409 | + // Only enable on set pages |
|
| 410 | + $aui_screens = array( |
|
| 411 | + 'page', |
|
| 412 | 412 | //'docs', |
| 413 | - 'post', |
|
| 414 | - 'settings_page_ayecode-ui-settings', |
|
| 415 | - 'appearance_page_gutenberg-widgets', |
|
| 416 | - 'widgets', |
|
| 417 | - 'ayecode-ui-settings', |
|
| 418 | - 'site-editor' |
|
| 419 | - ); |
|
| 420 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 413 | + 'post', |
|
| 414 | + 'settings_page_ayecode-ui-settings', |
|
| 415 | + 'appearance_page_gutenberg-widgets', |
|
| 416 | + 'widgets', |
|
| 417 | + 'ayecode-ui-settings', |
|
| 418 | + 'site-editor' |
|
| 419 | + ); |
|
| 420 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 421 | 421 | |
| 422 | - $screen = get_current_screen(); |
|
| 422 | + $screen = get_current_screen(); |
|
| 423 | 423 | |
| 424 | 424 | // echo '###'.$screen->id; |
| 425 | 425 | |
| 426 | - // check if we are on a AUI screen |
|
| 427 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 428 | - $load = true; |
|
| 429 | - } |
|
| 426 | + // check if we are on a AUI screen |
|
| 427 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 428 | + $load = true; |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | - //load for widget previews in WP 5.8 |
|
| 432 | - if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 433 | - $load = true; |
|
| 434 | - } |
|
| 435 | - } |
|
| 431 | + //load for widget previews in WP 5.8 |
|
| 432 | + if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 433 | + $load = true; |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | 436 | |
| 437 | 437 | |
| 438 | 438 | |
| 439 | - return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 440 | - } |
|
| 439 | + return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - /** |
|
| 443 | - * Check if the current theme is a block theme. |
|
| 444 | - * |
|
| 445 | - * @return bool |
|
| 446 | - */ |
|
| 447 | - public static function is_block_theme() { |
|
| 448 | - if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { |
|
| 449 | - return true; |
|
| 450 | - } |
|
| 442 | + /** |
|
| 443 | + * Check if the current theme is a block theme. |
|
| 444 | + * |
|
| 445 | + * @return bool |
|
| 446 | + */ |
|
| 447 | + public static function is_block_theme() { |
|
| 448 | + if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { |
|
| 449 | + return true; |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - return false; |
|
| 453 | - } |
|
| 452 | + return false; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | - /** |
|
| 456 | - * Adds the styles. |
|
| 457 | - */ |
|
| 458 | - public function enqueue_style() { |
|
| 455 | + /** |
|
| 456 | + * Adds the styles. |
|
| 457 | + */ |
|
| 458 | + public function enqueue_style() { |
|
| 459 | 459 | global $aui_bs5; |
| 460 | 460 | |
| 461 | 461 | $load_fse = false; |
| 462 | 462 | |
| 463 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 464 | - // don't add wp-admin scripts if not requested to |
|
| 465 | - }else{ |
|
| 466 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 463 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 464 | + // don't add wp-admin scripts if not requested to |
|
| 465 | + }else{ |
|
| 466 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 467 | 467 | |
| 468 | - $rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : ''; |
|
| 468 | + $rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : ''; |
|
| 469 | 469 | |
| 470 | 470 | $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : ''; |
| 471 | 471 | |
| 472 | - if($this->settings[$css_setting]){ |
|
| 473 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 474 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 472 | + if($this->settings[$css_setting]){ |
|
| 473 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 474 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 475 | 475 | |
| 476 | 476 | |
| 477 | 477 | |
| 478 | - wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 479 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 478 | + wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 479 | + wp_enqueue_style( 'ayecode-ui' ); |
|
| 480 | 480 | |
| 481 | - $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : ''; |
|
| 481 | + $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : ''; |
|
| 482 | 482 | |
| 483 | 483 | // if ( is_admin() && !empty($_REQUEST['postType']) ) { |
| 484 | - if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
| 485 | - $url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css'; |
|
| 486 | - wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version ); |
|
| 487 | - wp_enqueue_style( 'ayecode-ui-fse' ); |
|
| 488 | - $load_fse = true; |
|
| 489 | - } |
|
| 484 | + if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
| 485 | + $url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css'; |
|
| 486 | + wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version ); |
|
| 487 | + wp_enqueue_style( 'ayecode-ui-fse' ); |
|
| 488 | + $load_fse = true; |
|
| 489 | + } |
|
| 490 | 490 | |
| 491 | 491 | |
| 492 | - // flatpickr |
|
| 493 | - wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version ); |
|
| 492 | + // flatpickr |
|
| 493 | + wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version ); |
|
| 494 | 494 | |
| 495 | - // fix some wp-admin issues |
|
| 496 | - if(is_admin()){ |
|
| 497 | - $custom_css = " |
|
| 495 | + // fix some wp-admin issues |
|
| 496 | + if(is_admin()){ |
|
| 497 | + $custom_css = " |
|
| 498 | 498 | body{ |
| 499 | 499 | background-color: #f1f1f1; |
| 500 | 500 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -535,67 +535,67 @@ discard block |
||
| 535 | 535 | } |
| 536 | 536 | "; |
| 537 | 537 | |
| 538 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 539 | - $custom_css .= " |
|
| 538 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 539 | + $custom_css .= " |
|
| 540 | 540 | .edit-post-sidebar input[type=color].components-text-control__input{ |
| 541 | 541 | padding: 0; |
| 542 | 542 | } |
| 543 | 543 | "; |
| 544 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 545 | - } |
|
| 544 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - // custom changes |
|
| 548 | - if ( $load_fse ) { |
|
| 549 | - wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) ); |
|
| 550 | - }else{ |
|
| 551 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 547 | + // custom changes |
|
| 548 | + if ( $load_fse ) { |
|
| 549 | + wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) ); |
|
| 550 | + }else{ |
|
| 551 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 552 | 552 | |
| 553 | - } |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | - } |
|
| 556 | - } |
|
| 555 | + } |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | 558 | |
| 559 | - } |
|
| 559 | + } |
|
| 560 | 560 | |
| 561 | - /** |
|
| 562 | - * Get inline script used if bootstrap enqueued |
|
| 563 | - * |
|
| 564 | - * If this remains small then its best to use this than to add another JS file. |
|
| 565 | - */ |
|
| 566 | - public function inline_script() { |
|
| 561 | + /** |
|
| 562 | + * Get inline script used if bootstrap enqueued |
|
| 563 | + * |
|
| 564 | + * If this remains small then its best to use this than to add another JS file. |
|
| 565 | + */ |
|
| 566 | + public function inline_script() { |
|
| 567 | 567 | global $aui_bs5; |
| 568 | - // Flatpickr calendar locale |
|
| 569 | - $flatpickr_locale = self::flatpickr_locale(); |
|
| 570 | - |
|
| 571 | - ob_start(); |
|
| 572 | - if ( $aui_bs5 ) { |
|
| 573 | - include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' ); |
|
| 574 | - }else{ |
|
| 575 | - include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' ); |
|
| 568 | + // Flatpickr calendar locale |
|
| 569 | + $flatpickr_locale = self::flatpickr_locale(); |
|
| 570 | + |
|
| 571 | + ob_start(); |
|
| 572 | + if ( $aui_bs5 ) { |
|
| 573 | + include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' ); |
|
| 574 | + }else{ |
|
| 575 | + include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' ); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $output = ob_get_clean(); |
|
| 578 | + $output = ob_get_clean(); |
|
| 579 | 579 | |
| 580 | - /* |
|
| 580 | + /* |
|
| 581 | 581 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 582 | 582 | */ |
| 583 | - return str_replace( array( |
|
| 584 | - '<script>', |
|
| 585 | - '</script>' |
|
| 586 | - ), '', self::minify_js($output) ); |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - |
|
| 590 | - /** |
|
| 591 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 592 | - * |
|
| 593 | - * @TODO we may need this when other conflicts arrise. |
|
| 594 | - * @return mixed |
|
| 595 | - */ |
|
| 596 | - public static function bs3_compat_js() { |
|
| 597 | - ob_start(); |
|
| 598 | - ?> |
|
| 583 | + return str_replace( array( |
|
| 584 | + '<script>', |
|
| 585 | + '</script>' |
|
| 586 | + ), '', self::minify_js($output) ); |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + |
|
| 590 | + /** |
|
| 591 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 592 | + * |
|
| 593 | + * @TODO we may need this when other conflicts arrise. |
|
| 594 | + * @return mixed |
|
| 595 | + */ |
|
| 596 | + public static function bs3_compat_js() { |
|
| 597 | + ob_start(); |
|
| 598 | + ?> |
|
| 599 | 599 | <script> |
| 600 | 600 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
| 601 | 601 | /* With Avada builder */ |
@@ -603,20 +603,20 @@ discard block |
||
| 603 | 603 | <?php } ?> |
| 604 | 604 | </script> |
| 605 | 605 | <?php |
| 606 | - return str_replace( array( |
|
| 607 | - '<script>', |
|
| 608 | - '</script>' |
|
| 609 | - ), '', ob_get_clean()); |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - /** |
|
| 613 | - * Get inline script used if bootstrap file browser enqueued. |
|
| 614 | - * |
|
| 615 | - * If this remains small then its best to use this than to add another JS file. |
|
| 616 | - */ |
|
| 617 | - public function inline_script_file_browser(){ |
|
| 618 | - ob_start(); |
|
| 619 | - ?> |
|
| 606 | + return str_replace( array( |
|
| 607 | + '<script>', |
|
| 608 | + '</script>' |
|
| 609 | + ), '', ob_get_clean()); |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * Get inline script used if bootstrap file browser enqueued. |
|
| 614 | + * |
|
| 615 | + * If this remains small then its best to use this than to add another JS file. |
|
| 616 | + */ |
|
| 617 | + public function inline_script_file_browser(){ |
|
| 618 | + ob_start(); |
|
| 619 | + ?> |
|
| 620 | 620 | <script> |
| 621 | 621 | // run on doc ready |
| 622 | 622 | jQuery(document).ready(function () { |
@@ -624,282 +624,282 @@ discard block |
||
| 624 | 624 | }); |
| 625 | 625 | </script> |
| 626 | 626 | <?php |
| 627 | - $output = ob_get_clean(); |
|
| 627 | + $output = ob_get_clean(); |
|
| 628 | 628 | |
| 629 | - /* |
|
| 629 | + /* |
|
| 630 | 630 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 631 | 631 | */ |
| 632 | - return str_replace( array( |
|
| 633 | - '<script>', |
|
| 634 | - '</script>' |
|
| 635 | - ), '', $output ); |
|
| 636 | - } |
|
| 632 | + return str_replace( array( |
|
| 633 | + '<script>', |
|
| 634 | + '</script>' |
|
| 635 | + ), '', $output ); |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | - /** |
|
| 639 | - * Adds the Font Awesome JS. |
|
| 640 | - */ |
|
| 641 | - public function enqueue_scripts() { |
|
| 638 | + /** |
|
| 639 | + * Adds the Font Awesome JS. |
|
| 640 | + */ |
|
| 641 | + public function enqueue_scripts() { |
|
| 642 | 642 | |
| 643 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 644 | - // don't add wp-admin scripts if not requested to |
|
| 645 | - }else { |
|
| 643 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 644 | + // don't add wp-admin scripts if not requested to |
|
| 645 | + }else { |
|
| 646 | 646 | |
| 647 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 647 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 648 | 648 | |
| 649 | - $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : ''; |
|
| 649 | + $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : ''; |
|
| 650 | 650 | |
| 651 | - // select2 |
|
| 652 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 651 | + // select2 |
|
| 652 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 653 | 653 | |
| 654 | - // flatpickr |
|
| 655 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 654 | + // flatpickr |
|
| 655 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 656 | 656 | |
| 657 | - // iconpicker |
|
| 658 | - if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) { |
|
| 659 | - wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version ); |
|
| 660 | - }else{ |
|
| 661 | - wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 662 | - } |
|
| 657 | + // iconpicker |
|
| 658 | + if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) { |
|
| 659 | + wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version ); |
|
| 660 | + }else{ |
|
| 661 | + wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - // Bootstrap file browser |
|
| 665 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 666 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 667 | - |
|
| 668 | - $load_inline = false; |
|
| 669 | - |
|
| 670 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 671 | - // Bootstrap bundle |
|
| 672 | - $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js'; |
|
| 673 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 674 | - 'select2', |
|
| 675 | - 'jquery' |
|
| 676 | - ), $this->version, $this->is_bs3_compat() ); |
|
| 677 | - // if in admin then add to footer for compatibility. |
|
| 678 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 679 | - $script = $this->inline_script(); |
|
| 680 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 681 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 682 | - $url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5 |
|
| 683 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 684 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 685 | - $load_inline = true; |
|
| 686 | - } else { |
|
| 687 | - $load_inline = true; |
|
| 688 | - } |
|
| 664 | + // Bootstrap file browser |
|
| 665 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 666 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 667 | + |
|
| 668 | + $load_inline = false; |
|
| 669 | + |
|
| 670 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 671 | + // Bootstrap bundle |
|
| 672 | + $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js'; |
|
| 673 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 674 | + 'select2', |
|
| 675 | + 'jquery' |
|
| 676 | + ), $this->version, $this->is_bs3_compat() ); |
|
| 677 | + // if in admin then add to footer for compatibility. |
|
| 678 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 679 | + $script = $this->inline_script(); |
|
| 680 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 681 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 682 | + $url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5 |
|
| 683 | + wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 684 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 685 | + $load_inline = true; |
|
| 686 | + } else { |
|
| 687 | + $load_inline = true; |
|
| 688 | + } |
|
| 689 | 689 | |
| 690 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 691 | - if ( $load_inline ) { |
|
| 692 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 693 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 694 | - $script = $this->inline_script(); |
|
| 695 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 696 | - } |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * Enqueue flatpickr if called. |
|
| 703 | - */ |
|
| 704 | - public function enqueue_flatpickr(){ |
|
| 705 | - wp_enqueue_style( 'flatpickr' ); |
|
| 706 | - wp_enqueue_script( 'flatpickr' ); |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - /** |
|
| 710 | - * Enqueue iconpicker if called. |
|
| 711 | - */ |
|
| 712 | - public function enqueue_iconpicker(){ |
|
| 713 | - wp_enqueue_style( 'iconpicker' ); |
|
| 714 | - wp_enqueue_script( 'iconpicker' ); |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - /** |
|
| 718 | - * Get the url path to the current folder. |
|
| 719 | - * |
|
| 720 | - * @return string |
|
| 721 | - */ |
|
| 722 | - public function get_url() { |
|
| 723 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 724 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 725 | - |
|
| 726 | - // Replace http:// to https://. |
|
| 727 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 728 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - // Check if we are inside a plugin |
|
| 732 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 733 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 734 | - |
|
| 735 | - return trailingslashit( $url ); |
|
| 736 | - } |
|
| 737 | - |
|
| 738 | - /** |
|
| 739 | - * Get the url path to the current folder. |
|
| 740 | - * |
|
| 741 | - * @return string |
|
| 742 | - */ |
|
| 743 | - public function get_url_old() { |
|
| 744 | - |
|
| 745 | - $url = ''; |
|
| 746 | - // check if we are inside a plugin |
|
| 747 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 748 | - |
|
| 749 | - // add check in-case user has changed wp-content dir name. |
|
| 750 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 751 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 752 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 753 | - |
|
| 754 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 755 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - return $url; |
|
| 759 | - } |
|
| 760 | - |
|
| 761 | - /** |
|
| 762 | - * Register the database settings with WordPress. |
|
| 763 | - */ |
|
| 764 | - public function register_settings() { |
|
| 765 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 766 | - } |
|
| 767 | - |
|
| 768 | - /** |
|
| 769 | - * Add the WordPress settings menu item. |
|
| 770 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 771 | - */ |
|
| 772 | - public function menu_item() { |
|
| 773 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 774 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 775 | - $this, |
|
| 776 | - 'settings_page' |
|
| 777 | - ) ); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - /** |
|
| 781 | - * Get a list of themes and their default JS settings. |
|
| 782 | - * |
|
| 783 | - * @return array |
|
| 784 | - */ |
|
| 785 | - public function theme_js_settings(){ |
|
| 786 | - return array( |
|
| 787 | - 'ayetheme' => 'popper', |
|
| 788 | - 'listimia' => 'required', |
|
| 789 | - 'listimia_backend' => 'core-popper', |
|
| 790 | - //'avada' => 'required', // removed as we now add compatibility |
|
| 791 | - ); |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - /** |
|
| 690 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 691 | + if ( $load_inline ) { |
|
| 692 | + wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 693 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 694 | + $script = $this->inline_script(); |
|
| 695 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * Enqueue flatpickr if called. |
|
| 703 | + */ |
|
| 704 | + public function enqueue_flatpickr(){ |
|
| 705 | + wp_enqueue_style( 'flatpickr' ); |
|
| 706 | + wp_enqueue_script( 'flatpickr' ); |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + /** |
|
| 710 | + * Enqueue iconpicker if called. |
|
| 711 | + */ |
|
| 712 | + public function enqueue_iconpicker(){ |
|
| 713 | + wp_enqueue_style( 'iconpicker' ); |
|
| 714 | + wp_enqueue_script( 'iconpicker' ); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + /** |
|
| 718 | + * Get the url path to the current folder. |
|
| 719 | + * |
|
| 720 | + * @return string |
|
| 721 | + */ |
|
| 722 | + public function get_url() { |
|
| 723 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 724 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 725 | + |
|
| 726 | + // Replace http:// to https://. |
|
| 727 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 728 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + // Check if we are inside a plugin |
|
| 732 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 733 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 734 | + |
|
| 735 | + return trailingslashit( $url ); |
|
| 736 | + } |
|
| 737 | + |
|
| 738 | + /** |
|
| 739 | + * Get the url path to the current folder. |
|
| 740 | + * |
|
| 741 | + * @return string |
|
| 742 | + */ |
|
| 743 | + public function get_url_old() { |
|
| 744 | + |
|
| 745 | + $url = ''; |
|
| 746 | + // check if we are inside a plugin |
|
| 747 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 748 | + |
|
| 749 | + // add check in-case user has changed wp-content dir name. |
|
| 750 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 751 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 752 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 753 | + |
|
| 754 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 755 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + return $url; |
|
| 759 | + } |
|
| 760 | + |
|
| 761 | + /** |
|
| 762 | + * Register the database settings with WordPress. |
|
| 763 | + */ |
|
| 764 | + public function register_settings() { |
|
| 765 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + /** |
|
| 769 | + * Add the WordPress settings menu item. |
|
| 770 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 771 | + */ |
|
| 772 | + public function menu_item() { |
|
| 773 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 774 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 775 | + $this, |
|
| 776 | + 'settings_page' |
|
| 777 | + ) ); |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + /** |
|
| 781 | + * Get a list of themes and their default JS settings. |
|
| 782 | + * |
|
| 783 | + * @return array |
|
| 784 | + */ |
|
| 785 | + public function theme_js_settings(){ |
|
| 786 | + return array( |
|
| 787 | + 'ayetheme' => 'popper', |
|
| 788 | + 'listimia' => 'required', |
|
| 789 | + 'listimia_backend' => 'core-popper', |
|
| 790 | + //'avada' => 'required', // removed as we now add compatibility |
|
| 791 | + ); |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + /** |
|
| 795 | 795 | * Get the date the site was installed. |
| 796 | 796 | * |
| 797 | - * @return false|string |
|
| 798 | - */ |
|
| 797 | + * @return false|string |
|
| 798 | + */ |
|
| 799 | 799 | public function get_site_install_date() { |
| 800 | - global $wpdb; // This gives you access to the WordPress database object |
|
| 800 | + global $wpdb; // This gives you access to the WordPress database object |
|
| 801 | 801 | |
| 802 | - // Prepare the SQL query to get the oldest registration date |
|
| 803 | - $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}"; |
|
| 802 | + // Prepare the SQL query to get the oldest registration date |
|
| 803 | + $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}"; |
|
| 804 | 804 | |
| 805 | - // Execute the query |
|
| 806 | - $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
| 805 | + // Execute the query |
|
| 806 | + $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
| 807 | 807 | |
| 808 | - return $date ? $date : false; |
|
| 808 | + return $date ? $date : false; |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | - /** |
|
| 812 | - * Show admin notice if backend scripts not loaded. |
|
| 813 | - */ |
|
| 814 | - public function show_admin_version_notice(){ |
|
| 815 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings" ); |
|
| 816 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>'; |
|
| 817 | - $message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button; |
|
| 818 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
| 819 | - } |
|
| 820 | - |
|
| 821 | - /** |
|
| 822 | - * Get the current Font Awesome output settings. |
|
| 823 | - * |
|
| 824 | - * @return array The array of settings. |
|
| 825 | - */ |
|
| 826 | - public function get_settings() { |
|
| 827 | - |
|
| 828 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 811 | + /** |
|
| 812 | + * Show admin notice if backend scripts not loaded. |
|
| 813 | + */ |
|
| 814 | + public function show_admin_version_notice(){ |
|
| 815 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings" ); |
|
| 816 | + $button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>'; |
|
| 817 | + $message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button; |
|
| 818 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
| 819 | + } |
|
| 820 | + |
|
| 821 | + /** |
|
| 822 | + * Get the current Font Awesome output settings. |
|
| 823 | + * |
|
| 824 | + * @return array The array of settings. |
|
| 825 | + */ |
|
| 826 | + public function get_settings() { |
|
| 827 | + |
|
| 828 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 829 | 829 | |
| 830 | 830 | // Maybe show default version notice |
| 831 | - $site_install_date = new DateTime( self::get_site_install_date() ); |
|
| 832 | - $switch_over_date = new DateTime("2024-02-01"); |
|
| 833 | - if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) { |
|
| 834 | - add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) ); |
|
| 835 | - } |
|
| 836 | - |
|
| 837 | - $js_default = 'core-popper'; |
|
| 838 | - $js_default_backend = $js_default; |
|
| 839 | - |
|
| 840 | - // maybe set defaults (if no settings set) |
|
| 841 | - if(empty($db_settings)){ |
|
| 842 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 843 | - $theme_js_settings = self::theme_js_settings(); |
|
| 844 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 845 | - $js_default = $theme_js_settings[$active_theme]; |
|
| 846 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 847 | - } |
|
| 848 | - } |
|
| 831 | + $site_install_date = new DateTime( self::get_site_install_date() ); |
|
| 832 | + $switch_over_date = new DateTime("2024-02-01"); |
|
| 833 | + if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) { |
|
| 834 | + add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) ); |
|
| 835 | + } |
|
| 849 | 836 | |
| 850 | - /** |
|
| 851 | - * Filter the default settings. |
|
| 852 | - */ |
|
| 853 | - $defaults = apply_filters( 'ayecode-ui-default-settings', array( |
|
| 854 | - 'css' => 'compatibility', // core, compatibility |
|
| 855 | - 'js' => $js_default, // js to load, core-popper, popper |
|
| 856 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 857 | - 'css_backend' => 'compatibility', // core, compatibility |
|
| 858 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 859 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 837 | + $js_default = 'core-popper'; |
|
| 838 | + $js_default_backend = $js_default; |
|
| 839 | + |
|
| 840 | + // maybe set defaults (if no settings set) |
|
| 841 | + if(empty($db_settings)){ |
|
| 842 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 843 | + $theme_js_settings = self::theme_js_settings(); |
|
| 844 | + if(isset($theme_js_settings[$active_theme])){ |
|
| 845 | + $js_default = $theme_js_settings[$active_theme]; |
|
| 846 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 847 | + } |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + /** |
|
| 851 | + * Filter the default settings. |
|
| 852 | + */ |
|
| 853 | + $defaults = apply_filters( 'ayecode-ui-default-settings', array( |
|
| 854 | + 'css' => 'compatibility', // core, compatibility |
|
| 855 | + 'js' => $js_default, // js to load, core-popper, popper |
|
| 856 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 857 | + 'css_backend' => 'compatibility', // core, compatibility |
|
| 858 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 859 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 860 | 860 | 'bs_ver' => '5', // The default bootstrap version to sue by default |
| 861 | - ), $db_settings ); |
|
| 861 | + ), $db_settings ); |
|
| 862 | 862 | |
| 863 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 863 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 864 | 864 | |
| 865 | - /** |
|
| 866 | - * Filter the Bootstrap settings. |
|
| 867 | - * |
|
| 868 | - * @todo if we add this filer people might use it and then it defeats the purpose of this class :/ |
|
| 869 | - */ |
|
| 870 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 871 | - } |
|
| 865 | + /** |
|
| 866 | + * Filter the Bootstrap settings. |
|
| 867 | + * |
|
| 868 | + * @todo if we add this filer people might use it and then it defeats the purpose of this class :/ |
|
| 869 | + */ |
|
| 870 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 871 | + } |
|
| 872 | 872 | |
| 873 | 873 | |
| 874 | - /** |
|
| 875 | - * The settings page html output. |
|
| 876 | - */ |
|
| 877 | - public function settings_page() { |
|
| 878 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 879 | - wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) ); |
|
| 880 | - } |
|
| 874 | + /** |
|
| 875 | + * The settings page html output. |
|
| 876 | + */ |
|
| 877 | + public function settings_page() { |
|
| 878 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 879 | + wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) ); |
|
| 880 | + } |
|
| 881 | 881 | $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() ); |
| 882 | 882 | |
| 883 | - ?> |
|
| 883 | + ?> |
|
| 884 | 884 | <div class="wrap"> |
| 885 | 885 | <h1><?php echo esc_attr( $this->name ); ?></h1> |
| 886 | 886 | <p><?php echo esc_html( apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect' ) ) );?></p> |
| 887 | 887 | <form method="post" action="options.php"> |
| 888 | 888 | <?php |
| 889 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 890 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 891 | - ?> |
|
| 889 | + settings_fields( 'ayecode-ui-settings' ); |
|
| 890 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
| 891 | + ?> |
|
| 892 | 892 | |
| 893 | 893 | <h2><?php esc_html_e( 'BootStrap Version', 'ayecode-connect' ); ?></h2> |
| 894 | 894 | <p><?php echo esc_html( apply_filters( 'ayecode-ui-version-settings-message', __("V5 is recommended, however if you have another plugin installed using v4, you may need to use v4 also.", 'ayecode-connect' ) ) );?></p> |
| 895 | 895 | <div class="bsui"><?php |
| 896 | - if ( ! empty( $overrides ) ) { |
|
| 897 | - echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 898 | - 'type'=> 'info', |
|
| 899 | - 'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' ) |
|
| 900 | - )); |
|
| 901 | - } |
|
| 902 | - ?> |
|
| 896 | + if ( ! empty( $overrides ) ) { |
|
| 897 | + echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 898 | + 'type'=> 'info', |
|
| 899 | + 'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' ) |
|
| 900 | + )); |
|
| 901 | + } |
|
| 902 | + ?> |
|
| 903 | 903 | </div> |
| 904 | 904 | <table class="form-table wpbs-table-version-settings"> |
| 905 | 905 | <tr valign="top"> |
@@ -983,77 +983,77 @@ discard block |
||
| 983 | 983 | </table> |
| 984 | 984 | |
| 985 | 985 | <?php |
| 986 | - submit_button(); |
|
| 987 | - ?> |
|
| 986 | + submit_button(); |
|
| 987 | + ?> |
|
| 988 | 988 | </form> |
| 989 | 989 | <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo esc_html( $this->version ); ?></div> |
| 990 | 990 | </div> |
| 991 | 991 | <?php |
| 992 | - } |
|
| 992 | + } |
|
| 993 | 993 | |
| 994 | 994 | public function get_load_source(){ |
| 995 | - $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
| 996 | - $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
| 997 | - |
|
| 998 | - // Find source plugin/theme of SD |
|
| 999 | - $source = array(); |
|
| 1000 | - if ( strpos( $file, $plugins_dir ) !== false ) { |
|
| 1001 | - $source = explode( "/", plugin_basename( $file ) ); |
|
| 1002 | - } else if ( function_exists( 'get_theme_root' ) ) { |
|
| 1003 | - $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
| 1004 | - |
|
| 1005 | - if ( strpos( $file, $themes_dir ) !== false ) { |
|
| 1006 | - $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
| 1007 | - } |
|
| 1008 | - } |
|
| 995 | + $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
| 996 | + $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
| 997 | + |
|
| 998 | + // Find source plugin/theme of SD |
|
| 999 | + $source = array(); |
|
| 1000 | + if ( strpos( $file, $plugins_dir ) !== false ) { |
|
| 1001 | + $source = explode( "/", plugin_basename( $file ) ); |
|
| 1002 | + } else if ( function_exists( 'get_theme_root' ) ) { |
|
| 1003 | + $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
| 1004 | + |
|
| 1005 | + if ( strpos( $file, $themes_dir ) !== false ) { |
|
| 1006 | + $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
| 1007 | + } |
|
| 1008 | + } |
|
| 1009 | 1009 | |
| 1010 | 1010 | return isset($source[0]) ? esc_attr($source[0]) : ''; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - public function customizer_settings($wp_customize){ |
|
| 1014 | - $wp_customize->add_section('aui_settings', array( |
|
| 1015 | - 'title' => __('AyeCode UI', 'ayecode-connect' ), |
|
| 1016 | - 'priority' => 120, |
|
| 1017 | - )); |
|
| 1018 | - |
|
| 1019 | - // ============================= |
|
| 1020 | - // = Color Picker = |
|
| 1021 | - // ============================= |
|
| 1022 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1023 | - 'default' => AUI_PRIMARY_COLOR, |
|
| 1024 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1025 | - 'capability' => 'edit_theme_options', |
|
| 1026 | - 'type' => 'option', |
|
| 1027 | - 'transport' => 'refresh', |
|
| 1028 | - )); |
|
| 1029 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1030 | - 'label' => __('Primary Color', 'ayecode-connect' ), |
|
| 1031 | - 'section' => 'aui_settings', |
|
| 1032 | - 'settings' => 'aui_options[color_primary]', |
|
| 1033 | - ))); |
|
| 1034 | - |
|
| 1035 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1036 | - 'default' => '#6c757d', |
|
| 1037 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1038 | - 'capability' => 'edit_theme_options', |
|
| 1039 | - 'type' => 'option', |
|
| 1040 | - 'transport' => 'refresh', |
|
| 1041 | - )); |
|
| 1042 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1043 | - 'label' => __('Secondary Color', 'ayecode-connect' ), |
|
| 1044 | - 'section' => 'aui_settings', |
|
| 1045 | - 'settings' => 'aui_options[color_secondary]', |
|
| 1046 | - ))); |
|
| 1047 | - } |
|
| 1048 | - |
|
| 1049 | - /** |
|
| 1050 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1051 | - * |
|
| 1052 | - * @return mixed |
|
| 1053 | - */ |
|
| 1054 | - public static function bs3_compat_css() { |
|
| 1055 | - ob_start(); |
|
| 1056 | - ?> |
|
| 1013 | + public function customizer_settings($wp_customize){ |
|
| 1014 | + $wp_customize->add_section('aui_settings', array( |
|
| 1015 | + 'title' => __('AyeCode UI', 'ayecode-connect' ), |
|
| 1016 | + 'priority' => 120, |
|
| 1017 | + )); |
|
| 1018 | + |
|
| 1019 | + // ============================= |
|
| 1020 | + // = Color Picker = |
|
| 1021 | + // ============================= |
|
| 1022 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1023 | + 'default' => AUI_PRIMARY_COLOR, |
|
| 1024 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1025 | + 'capability' => 'edit_theme_options', |
|
| 1026 | + 'type' => 'option', |
|
| 1027 | + 'transport' => 'refresh', |
|
| 1028 | + )); |
|
| 1029 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1030 | + 'label' => __('Primary Color', 'ayecode-connect' ), |
|
| 1031 | + 'section' => 'aui_settings', |
|
| 1032 | + 'settings' => 'aui_options[color_primary]', |
|
| 1033 | + ))); |
|
| 1034 | + |
|
| 1035 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1036 | + 'default' => '#6c757d', |
|
| 1037 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1038 | + 'capability' => 'edit_theme_options', |
|
| 1039 | + 'type' => 'option', |
|
| 1040 | + 'transport' => 'refresh', |
|
| 1041 | + )); |
|
| 1042 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1043 | + 'label' => __('Secondary Color', 'ayecode-connect' ), |
|
| 1044 | + 'section' => 'aui_settings', |
|
| 1045 | + 'settings' => 'aui_options[color_secondary]', |
|
| 1046 | + ))); |
|
| 1047 | + } |
|
| 1048 | + |
|
| 1049 | + /** |
|
| 1050 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1051 | + * |
|
| 1052 | + * @return mixed |
|
| 1053 | + */ |
|
| 1054 | + public static function bs3_compat_css() { |
|
| 1055 | + ob_start(); |
|
| 1056 | + ?> |
|
| 1057 | 1057 | <style> |
| 1058 | 1058 | /* Bootstrap 3 compatibility */ |
| 1059 | 1059 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1082,55 +1082,55 @@ discard block |
||
| 1082 | 1082 | <?php } ?> |
| 1083 | 1083 | </style> |
| 1084 | 1084 | <?php |
| 1085 | - return str_replace( array( |
|
| 1086 | - '<style>', |
|
| 1087 | - '</style>' |
|
| 1088 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1089 | - } |
|
| 1085 | + return str_replace( array( |
|
| 1086 | + '<style>', |
|
| 1087 | + '</style>' |
|
| 1088 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1089 | + } |
|
| 1090 | 1090 | |
| 1091 | 1091 | |
| 1092 | - public static function custom_css($compatibility = true) { |
|
| 1092 | + public static function custom_css($compatibility = true) { |
|
| 1093 | 1093 | global $aui_bs5; |
| 1094 | 1094 | |
| 1095 | - $colors = array(); |
|
| 1096 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 1095 | + $colors = array(); |
|
| 1096 | + if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 1097 | 1097 | |
| 1098 | 1098 | |
| 1099 | - $setting = wp_get_global_settings(); |
|
| 1099 | + $setting = wp_get_global_settings(); |
|
| 1100 | 1100 | |
| 1101 | 1101 | // print_r(wp_get_global_styles());//exit; |
| 1102 | 1102 | // print_r(get_default_block_editor_settings());exit; |
| 1103 | 1103 | |
| 1104 | 1104 | // print_r($setting);echo '###';exit; |
| 1105 | - if(!empty($setting['color']['palette']['theme'])){ |
|
| 1106 | - foreach($setting['color']['palette']['theme'] as $color){ |
|
| 1107 | - $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1108 | - } |
|
| 1109 | - } |
|
| 1105 | + if(!empty($setting['color']['palette']['theme'])){ |
|
| 1106 | + foreach($setting['color']['palette']['theme'] as $color){ |
|
| 1107 | + $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1108 | + } |
|
| 1109 | + } |
|
| 1110 | 1110 | |
| 1111 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 1112 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 1113 | - $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1114 | - } |
|
| 1115 | - } |
|
| 1116 | - }else{ |
|
| 1117 | - $settings = get_option('aui_options'); |
|
| 1118 | - $colors = array( |
|
| 1119 | - 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1120 | - 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1121 | - ); |
|
| 1122 | - } |
|
| 1111 | + if(!empty($setting['color']['palette']['custom'])){ |
|
| 1112 | + foreach($setting['color']['palette']['custom'] as $color){ |
|
| 1113 | + $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1114 | + } |
|
| 1115 | + } |
|
| 1116 | + }else{ |
|
| 1117 | + $settings = get_option('aui_options'); |
|
| 1118 | + $colors = array( |
|
| 1119 | + 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1120 | + 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1121 | + ); |
|
| 1122 | + } |
|
| 1123 | 1123 | |
| 1124 | - ob_start(); |
|
| 1124 | + ob_start(); |
|
| 1125 | 1125 | |
| 1126 | - ?> |
|
| 1126 | + ?> |
|
| 1127 | 1127 | <style> |
| 1128 | 1128 | <?php |
| 1129 | 1129 | |
| 1130 | - // BS v3 compat |
|
| 1131 | - if( self::is_bs3_compat() ){ |
|
| 1132 | - echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 1133 | - } |
|
| 1130 | + // BS v3 compat |
|
| 1131 | + if( self::is_bs3_compat() ){ |
|
| 1132 | + echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 1133 | + } |
|
| 1134 | 1134 | |
| 1135 | 1135 | $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : ''; |
| 1136 | 1136 | $is_fse = false; |
@@ -1138,26 +1138,26 @@ discard block |
||
| 1138 | 1138 | $is_fse = true; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | - if(!empty($colors)){ |
|
| 1142 | - $d_colors = self::get_colors(true); |
|
| 1141 | + if(!empty($colors)){ |
|
| 1142 | + $d_colors = self::get_colors(true); |
|
| 1143 | 1143 | |
| 1144 | 1144 | // $is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'; |
| 1145 | - foreach($colors as $key => $color ){ |
|
| 1146 | - if((empty( $d_colors[$key]) || $d_colors[$key] != $color) || $is_fse ) { |
|
| 1147 | - $var = $is_fse ? "var(--wp--preset--color--$key)" : $color; |
|
| 1148 | - $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility; |
|
| 1149 | - echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 1150 | - } |
|
| 1151 | - } |
|
| 1152 | - // exit; |
|
| 1153 | - } |
|
| 1145 | + foreach($colors as $key => $color ){ |
|
| 1146 | + if((empty( $d_colors[$key]) || $d_colors[$key] != $color) || $is_fse ) { |
|
| 1147 | + $var = $is_fse ? "var(--wp--preset--color--$key)" : $color; |
|
| 1148 | + $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility; |
|
| 1149 | + echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1152 | + // exit; |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | - // Set admin bar z-index lower when modal is open. |
|
| 1156 | - echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1155 | + // Set admin bar z-index lower when modal is open. |
|
| 1156 | + echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1157 | 1157 | |
| 1158 | - if(is_admin()){ |
|
| 1159 | - echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1160 | - } |
|
| 1158 | + if(is_admin()){ |
|
| 1159 | + echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1160 | + } |
|
| 1161 | 1161 | |
| 1162 | 1162 | if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' ) ){ |
| 1163 | 1163 | $css = ''; |
@@ -1177,28 +1177,28 @@ discard block |
||
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | // line height |
| 1180 | - if( !empty( $theme_settings['typography']['lineHeight'] ) ){ |
|
| 1180 | + if( !empty( $theme_settings['typography']['lineHeight'] ) ){ |
|
| 1181 | 1181 | $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';'; |
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | 1184 | |
| 1185 | - // font weight |
|
| 1186 | - if( !empty( $theme_settings['typography']['fontWeight'] ) ){ |
|
| 1185 | + // font weight |
|
| 1186 | + if( !empty( $theme_settings['typography']['fontWeight'] ) ){ |
|
| 1187 | 1187 | $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';'; |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | // Background |
| 1191 | - if( !empty( $theme_settings['color']['background'] ) ){ |
|
| 1191 | + if( !empty( $theme_settings['color']['background'] ) ){ |
|
| 1192 | 1192 | $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';'; |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | - // Background Gradient |
|
| 1196 | - if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
| 1195 | + // Background Gradient |
|
| 1196 | + if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
| 1197 | 1197 | $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';'; |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | - // Background Gradient |
|
| 1201 | - if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
| 1200 | + // Background Gradient |
|
| 1201 | + if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
| 1202 | 1202 | $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';'; |
| 1203 | 1203 | } |
| 1204 | 1204 | |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';'; |
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | - // heading font family |
|
| 1239 | + // heading font family |
|
| 1240 | 1240 | if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){ |
| 1241 | 1241 | $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily'] ) . ';'; |
| 1242 | 1242 | } |
@@ -1249,201 +1249,201 @@ discard block |
||
| 1249 | 1249 | |
| 1250 | 1250 | foreach($hs as $hn){ |
| 1251 | 1251 | $h_css = ''; |
| 1252 | - if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){ |
|
| 1252 | + if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){ |
|
| 1253 | 1253 | $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';'; |
| 1254 | - } |
|
| 1254 | + } |
|
| 1255 | 1255 | |
| 1256 | - if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){ |
|
| 1256 | + if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){ |
|
| 1257 | 1257 | $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize'] ) . ';'; |
| 1258 | - } |
|
| 1258 | + } |
|
| 1259 | 1259 | |
| 1260 | - if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){ |
|
| 1260 | + if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){ |
|
| 1261 | 1261 | $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) . ';'; |
| 1262 | - } |
|
| 1262 | + } |
|
| 1263 | 1263 | |
| 1264 | - if($h_css){ |
|
| 1264 | + if($h_css){ |
|
| 1265 | 1265 | echo esc_attr( $bep . $hn ) . '{'.esc_attr( $h_css ).'}'; |
| 1266 | - } |
|
| 1266 | + } |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | } |
| 1270 | - ?> |
|
| 1270 | + ?> |
|
| 1271 | 1271 | </style> |
| 1272 | 1272 | <?php |
| 1273 | 1273 | |
| 1274 | 1274 | |
| 1275 | - /* |
|
| 1275 | + /* |
|
| 1276 | 1276 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1277 | 1277 | */ |
| 1278 | - return str_replace( array( |
|
| 1279 | - '<style>', |
|
| 1280 | - '</style>' |
|
| 1281 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1282 | - } |
|
| 1283 | - |
|
| 1284 | - |
|
| 1285 | - |
|
| 1286 | - /** |
|
| 1287 | - * Check if we should add booststrap 3 compatibility changes. |
|
| 1288 | - * |
|
| 1289 | - * @return bool |
|
| 1290 | - */ |
|
| 1291 | - public static function is_bs3_compat(){ |
|
| 1292 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1293 | - } |
|
| 1294 | - |
|
| 1295 | - public static function hex_to_rgb( $hex ) { |
|
| 1296 | - // Remove '#' if present |
|
| 1297 | - $hex = str_replace( '#', '', $hex ); |
|
| 1298 | - |
|
| 1299 | - // Check if input is RGB |
|
| 1300 | - if ( strpos( $hex, 'rgba(' ) === 0 || strpos( $hex, 'rgb(' ) === 0 ) { |
|
| 1301 | - $_rgb = explode( ',', str_replace( array( 'rgba(', 'rgb(', ')' ), '', $hex ) ); |
|
| 1302 | - |
|
| 1303 | - $rgb = ( isset( $_rgb[0] ) ? (int) trim( $_rgb[0] ) : '0' ) . ','; |
|
| 1304 | - $rgb .= ( isset( $_rgb[1] ) ? (int) trim( $_rgb[1] ) : '0' ) . ','; |
|
| 1305 | - $rgb .= ( isset( $_rgb[2] ) ? (int) trim( $_rgb[2] ) : '0' ); |
|
| 1306 | - |
|
| 1307 | - return $rgb; |
|
| 1308 | - } |
|
| 1309 | - |
|
| 1310 | - // Convert 3-digit hex to 6-digit hex |
|
| 1311 | - if ( strlen( $hex ) == 3 ) { |
|
| 1312 | - $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 ); |
|
| 1313 | - } |
|
| 1314 | - |
|
| 1315 | - // Convert hex to RGB |
|
| 1316 | - $r = hexdec( substr( $hex, 0, 2 ) ); |
|
| 1317 | - $g = hexdec( substr( $hex, 2, 2 ) ); |
|
| 1318 | - $b = hexdec( substr( $hex, 4, 2 ) ); |
|
| 1319 | - |
|
| 1320 | - // Return RGB values as an array |
|
| 1321 | - return $r . ',' . $g . ',' . $b; |
|
| 1322 | - } |
|
| 1323 | - |
|
| 1324 | - /** |
|
| 1325 | - * Build the CSS to overwrite a bootstrap color variable. |
|
| 1326 | - * |
|
| 1327 | - * @param $type |
|
| 1328 | - * @param $color_code |
|
| 1329 | - * @param $compatibility |
|
| 1330 | - * |
|
| 1331 | - * @return string |
|
| 1332 | - */ |
|
| 1333 | - public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){ |
|
| 1334 | - global $aui_bs5; |
|
| 1335 | - |
|
| 1336 | - $is_var = false; |
|
| 1337 | - $is_custom = strpos($type, 'custom-') !== false ? true : false; |
|
| 1338 | - if(!$color_code){return '';} |
|
| 1339 | - if(strpos($color_code, 'var') !== false){ |
|
| 1340 | - //if(!sanitize_hex_color($color_code)){ |
|
| 1341 | - $color_code = esc_attr($color_code); |
|
| 1342 | - $is_var = true; |
|
| 1278 | + return str_replace( array( |
|
| 1279 | + '<style>', |
|
| 1280 | + '</style>' |
|
| 1281 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1282 | + } |
|
| 1283 | + |
|
| 1284 | + |
|
| 1285 | + |
|
| 1286 | + /** |
|
| 1287 | + * Check if we should add booststrap 3 compatibility changes. |
|
| 1288 | + * |
|
| 1289 | + * @return bool |
|
| 1290 | + */ |
|
| 1291 | + public static function is_bs3_compat(){ |
|
| 1292 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1293 | + } |
|
| 1294 | + |
|
| 1295 | + public static function hex_to_rgb( $hex ) { |
|
| 1296 | + // Remove '#' if present |
|
| 1297 | + $hex = str_replace( '#', '', $hex ); |
|
| 1298 | + |
|
| 1299 | + // Check if input is RGB |
|
| 1300 | + if ( strpos( $hex, 'rgba(' ) === 0 || strpos( $hex, 'rgb(' ) === 0 ) { |
|
| 1301 | + $_rgb = explode( ',', str_replace( array( 'rgba(', 'rgb(', ')' ), '', $hex ) ); |
|
| 1302 | + |
|
| 1303 | + $rgb = ( isset( $_rgb[0] ) ? (int) trim( $_rgb[0] ) : '0' ) . ','; |
|
| 1304 | + $rgb .= ( isset( $_rgb[1] ) ? (int) trim( $_rgb[1] ) : '0' ) . ','; |
|
| 1305 | + $rgb .= ( isset( $_rgb[2] ) ? (int) trim( $_rgb[2] ) : '0' ); |
|
| 1306 | + |
|
| 1307 | + return $rgb; |
|
| 1308 | + } |
|
| 1309 | + |
|
| 1310 | + // Convert 3-digit hex to 6-digit hex |
|
| 1311 | + if ( strlen( $hex ) == 3 ) { |
|
| 1312 | + $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 ); |
|
| 1313 | + } |
|
| 1314 | + |
|
| 1315 | + // Convert hex to RGB |
|
| 1316 | + $r = hexdec( substr( $hex, 0, 2 ) ); |
|
| 1317 | + $g = hexdec( substr( $hex, 2, 2 ) ); |
|
| 1318 | + $b = hexdec( substr( $hex, 4, 2 ) ); |
|
| 1319 | + |
|
| 1320 | + // Return RGB values as an array |
|
| 1321 | + return $r . ',' . $g . ',' . $b; |
|
| 1322 | + } |
|
| 1323 | + |
|
| 1324 | + /** |
|
| 1325 | + * Build the CSS to overwrite a bootstrap color variable. |
|
| 1326 | + * |
|
| 1327 | + * @param $type |
|
| 1328 | + * @param $color_code |
|
| 1329 | + * @param $compatibility |
|
| 1330 | + * |
|
| 1331 | + * @return string |
|
| 1332 | + */ |
|
| 1333 | + public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){ |
|
| 1334 | + global $aui_bs5; |
|
| 1335 | + |
|
| 1336 | + $is_var = false; |
|
| 1337 | + $is_custom = strpos($type, 'custom-') !== false ? true : false; |
|
| 1338 | + if(!$color_code){return '';} |
|
| 1339 | + if(strpos($color_code, 'var') !== false){ |
|
| 1340 | + //if(!sanitize_hex_color($color_code)){ |
|
| 1341 | + $color_code = esc_attr($color_code); |
|
| 1342 | + $is_var = true; |
|
| 1343 | 1343 | // $color_code = "rgba($color_code, 0.5)"; |
| 1344 | 1344 | // echo '###1'.$color_code.'###';//exit; |
| 1345 | - } |
|
| 1345 | + } |
|
| 1346 | 1346 | |
| 1347 | 1347 | // echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
| 1348 | 1348 | |
| 1349 | - if(!$color_code){return '';} |
|
| 1349 | + if(!$color_code){return '';} |
|
| 1350 | 1350 | |
| 1351 | - $rgb = self::hex_to_rgb($hex); |
|
| 1351 | + $rgb = self::hex_to_rgb($hex); |
|
| 1352 | 1352 | |
| 1353 | - if($compatibility===true || $compatibility===1){ |
|
| 1354 | - $compatibility = '.bsui'; |
|
| 1355 | - }elseif(!$compatibility){ |
|
| 1356 | - $compatibility = ''; |
|
| 1357 | - }else{ |
|
| 1358 | - $compatibility = esc_attr($compatibility); |
|
| 1359 | - } |
|
| 1353 | + if($compatibility===true || $compatibility===1){ |
|
| 1354 | + $compatibility = '.bsui'; |
|
| 1355 | + }elseif(!$compatibility){ |
|
| 1356 | + $compatibility = ''; |
|
| 1357 | + }else{ |
|
| 1358 | + $compatibility = esc_attr($compatibility); |
|
| 1359 | + } |
|
| 1360 | 1360 | |
| 1361 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 1361 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 1362 | 1362 | |
| 1363 | 1363 | |
| 1364 | 1364 | $output = ''; |
| 1365 | 1365 | |
| 1366 | 1366 | // echo '####'.$color_code;exit; |
| 1367 | 1367 | |
| 1368 | - $type = sanitize_html_class($type); |
|
| 1368 | + $type = sanitize_html_class($type); |
|
| 1369 | + |
|
| 1370 | + /** |
|
| 1371 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1372 | + */ |
|
| 1373 | + $selectors = array( |
|
| 1374 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
| 1375 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 1376 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 1377 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 1378 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 1379 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 1380 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 1381 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 1382 | + ".badge-{$type}" => array( 'b' ), |
|
| 1383 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
| 1384 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
| 1385 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 1386 | + ".text-{$type}" => array( 'c' ), |
|
| 1387 | + ); |
|
| 1388 | + |
|
| 1389 | + if ( $aui_bs5 ) { |
|
| 1390 | + unset($selectors[".alert-{$type}" ]); |
|
| 1391 | + } |
|
| 1369 | 1392 | |
| 1370 | - /** |
|
| 1371 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1372 | - */ |
|
| 1373 | - $selectors = array( |
|
| 1374 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
| 1375 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 1376 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 1377 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 1378 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 1379 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 1380 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 1381 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 1382 | - ".badge-{$type}" => array( 'b' ), |
|
| 1383 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
| 1384 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
| 1385 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 1386 | - ".text-{$type}" => array( 'c' ), |
|
| 1387 | - ); |
|
| 1388 | - |
|
| 1389 | - if ( $aui_bs5 ) { |
|
| 1390 | - unset($selectors[".alert-{$type}" ]); |
|
| 1391 | - } |
|
| 1392 | - |
|
| 1393 | - if ( $type == 'primary' ) { |
|
| 1394 | - $selectors = $selectors + array( |
|
| 1395 | - 'a' => array( 'c' ), |
|
| 1396 | - '.btn-link' => array( 'c' ), |
|
| 1397 | - '.dropdown-item.active' => array( 'b' ), |
|
| 1398 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 1399 | - 'b', |
|
| 1400 | - 'o' |
|
| 1401 | - ), |
|
| 1402 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 1403 | - 'b', |
|
| 1404 | - 'o' |
|
| 1405 | - ), |
|
| 1406 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 1407 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 1408 | - '.page-link' => array( 'c' ), |
|
| 1409 | - '.page-item.active .page-link' => array( |
|
| 1410 | - 'b', |
|
| 1411 | - 'o' |
|
| 1412 | - ), |
|
| 1413 | - '.progress-bar' => array( 'b' ), |
|
| 1414 | - '.list-group-item.active' => array( |
|
| 1415 | - 'b', |
|
| 1416 | - 'o' |
|
| 1417 | - ), |
|
| 1418 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 1419 | - ); |
|
| 1420 | - } |
|
| 1393 | + if ( $type == 'primary' ) { |
|
| 1394 | + $selectors = $selectors + array( |
|
| 1395 | + 'a' => array( 'c' ), |
|
| 1396 | + '.btn-link' => array( 'c' ), |
|
| 1397 | + '.dropdown-item.active' => array( 'b' ), |
|
| 1398 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 1399 | + 'b', |
|
| 1400 | + 'o' |
|
| 1401 | + ), |
|
| 1402 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 1403 | + 'b', |
|
| 1404 | + 'o' |
|
| 1405 | + ), |
|
| 1406 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 1407 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 1408 | + '.page-link' => array( 'c' ), |
|
| 1409 | + '.page-item.active .page-link' => array( |
|
| 1410 | + 'b', |
|
| 1411 | + 'o' |
|
| 1412 | + ), |
|
| 1413 | + '.progress-bar' => array( 'b' ), |
|
| 1414 | + '.list-group-item.active' => array( |
|
| 1415 | + 'b', |
|
| 1416 | + 'o' |
|
| 1417 | + ), |
|
| 1418 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 1419 | + ); |
|
| 1420 | + } |
|
| 1421 | 1421 | |
| 1422 | 1422 | |
| 1423 | 1423 | |
| 1424 | 1424 | // link |
| 1425 | - if ( $type === 'primary' ) { |
|
| 1426 | - $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }'; |
|
| 1427 | - $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).'; }'; |
|
| 1428 | - $output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }'; |
|
| 1425 | + if ( $type === 'primary' ) { |
|
| 1426 | + $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }'; |
|
| 1427 | + $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).'; }'; |
|
| 1428 | + $output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }'; |
|
| 1429 | 1429 | |
| 1430 | - $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}'; |
|
| 1431 | - $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}'; |
|
| 1430 | + $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}'; |
|
| 1431 | + $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}'; |
|
| 1432 | 1432 | |
| 1433 | 1433 | // dropdown |
| 1434 | - $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}'; |
|
| 1434 | + $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}'; |
|
| 1435 | 1435 | |
| 1436 | 1436 | // pagination |
| 1437 | - $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}'; |
|
| 1437 | + $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}'; |
|
| 1438 | 1438 | |
| 1439 | - } |
|
| 1439 | + } |
|
| 1440 | 1440 | |
| 1441 | - $output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}'; |
|
| 1442 | - $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}'; |
|
| 1441 | + $output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}'; |
|
| 1442 | + $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}'; |
|
| 1443 | 1443 | |
| 1444 | - // buttons |
|
| 1445 | - $output .= $prefix . ' .btn-'.esc_attr($type).'{'; |
|
| 1446 | - $output .= ' |
|
| 1444 | + // buttons |
|
| 1445 | + $output .= $prefix . ' .btn-'.esc_attr($type).'{'; |
|
| 1446 | + $output .= ' |
|
| 1447 | 1447 | --bs-btn-bg: '.esc_attr($color_code).'; |
| 1448 | 1448 | --bs-btn-border-color: '.esc_attr($color_code).'; |
| 1449 | 1449 | --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
@@ -1461,11 +1461,11 @@ discard block |
||
| 1461 | 1461 | // --bs-btn-active-color: #fff; |
| 1462 | 1462 | // --bs-btn-disabled-color: #fff; |
| 1463 | 1463 | // '; |
| 1464 | - $output .= '}'; |
|
| 1464 | + $output .= '}'; |
|
| 1465 | 1465 | |
| 1466 | - // buttons outline |
|
| 1467 | - $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; |
|
| 1468 | - $output .= ' |
|
| 1466 | + // buttons outline |
|
| 1467 | + $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; |
|
| 1468 | + $output .= ' |
|
| 1469 | 1469 | --bs-btn-color: '.esc_attr($color_code).'; |
| 1470 | 1470 | --bs-btn-border-color: '.esc_attr($color_code).'; |
| 1471 | 1471 | --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
@@ -1483,37 +1483,37 @@ discard block |
||
| 1483 | 1483 | // --bs-btn-active-color: #fff; |
| 1484 | 1484 | // --bs-btn-disabled-color: #fff; |
| 1485 | 1485 | // '; |
| 1486 | - $output .= '}'; |
|
| 1486 | + $output .= '}'; |
|
| 1487 | 1487 | |
| 1488 | 1488 | |
| 1489 | 1489 | // button hover |
| 1490 | - $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; |
|
| 1491 | - $output .= ' |
|
| 1490 | + $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; |
|
| 1491 | + $output .= ' |
|
| 1492 | 1492 | box-shadow: 0 0.25rem 0.25rem 0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb), .1), 0 0.375rem 0.75rem -0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb) , .4); |
| 1493 | 1493 | } |
| 1494 | 1494 | '; |
| 1495 | 1495 | |
| 1496 | 1496 | |
| 1497 | - if ( $aui_bs5 ) { |
|
| 1497 | + if ( $aui_bs5 ) { |
|
| 1498 | 1498 | // $output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }'; |
| 1499 | - $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }'; |
|
| 1500 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
| 1501 | - } |
|
| 1499 | + $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }'; |
|
| 1500 | + $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
| 1501 | + } |
|
| 1502 | 1502 | |
| 1503 | 1503 | |
| 1504 | - if ( $is_custom ) { |
|
| 1504 | + if ( $is_custom ) { |
|
| 1505 | 1505 | |
| 1506 | 1506 | // echo '###'.$type;exit; |
| 1507 | 1507 | |
| 1508 | - // build rules into each type |
|
| 1509 | - foreach($selectors as $selector => $types){ |
|
| 1510 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1511 | - $types = array_combine($types,$types); |
|
| 1512 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1513 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1514 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1515 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1516 | - } |
|
| 1508 | + // build rules into each type |
|
| 1509 | + foreach($selectors as $selector => $types){ |
|
| 1510 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1511 | + $types = array_combine($types,$types); |
|
| 1512 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1513 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1514 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1515 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1516 | + } |
|
| 1517 | 1517 | |
| 1518 | 1518 | // // build rules into each type |
| 1519 | 1519 | // foreach($important_selectors as $selector => $types){ |
@@ -1525,67 +1525,67 @@ discard block |
||
| 1525 | 1525 | // if(isset($types['f'])){$fill_i[] = $selector;} |
| 1526 | 1526 | // } |
| 1527 | 1527 | |
| 1528 | - // add any color rules |
|
| 1529 | - if(!empty($color)){ |
|
| 1530 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1531 | - } |
|
| 1532 | - if(!empty($color_i)){ |
|
| 1533 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1534 | - } |
|
| 1528 | + // add any color rules |
|
| 1529 | + if(!empty($color)){ |
|
| 1530 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1531 | + } |
|
| 1532 | + if(!empty($color_i)){ |
|
| 1533 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1534 | + } |
|
| 1535 | 1535 | |
| 1536 | - // add any background color rules |
|
| 1537 | - if(!empty($background)){ |
|
| 1538 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1539 | - } |
|
| 1540 | - if(!empty($background_i)){ |
|
| 1541 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1536 | + // add any background color rules |
|
| 1537 | + if(!empty($background)){ |
|
| 1538 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1539 | + } |
|
| 1540 | + if(!empty($background_i)){ |
|
| 1541 | + $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1542 | 1542 | // $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
| 1543 | - } |
|
| 1543 | + } |
|
| 1544 | 1544 | |
| 1545 | - // add any border color rules |
|
| 1546 | - if(!empty($border)){ |
|
| 1547 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1548 | - } |
|
| 1549 | - if(!empty($border_i)){ |
|
| 1550 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1551 | - } |
|
| 1545 | + // add any border color rules |
|
| 1546 | + if(!empty($border)){ |
|
| 1547 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1548 | + } |
|
| 1549 | + if(!empty($border_i)){ |
|
| 1550 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1551 | + } |
|
| 1552 | 1552 | |
| 1553 | - // add any fill color rules |
|
| 1554 | - if(!empty($fill)){ |
|
| 1555 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1556 | - } |
|
| 1557 | - if(!empty($fill_i)){ |
|
| 1558 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1559 | - } |
|
| 1553 | + // add any fill color rules |
|
| 1554 | + if(!empty($fill)){ |
|
| 1555 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1556 | + } |
|
| 1557 | + if(!empty($fill_i)){ |
|
| 1558 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1559 | + } |
|
| 1560 | 1560 | |
| 1561 | - } |
|
| 1561 | + } |
|
| 1562 | 1562 | |
| 1563 | 1563 | |
| 1564 | 1564 | |
| 1565 | 1565 | |
| 1566 | - $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 1567 | - // darken |
|
| 1568 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1569 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1570 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1571 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
| 1566 | + $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 1567 | + // darken |
|
| 1568 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1569 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1570 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1571 | + $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
| 1572 | 1572 | |
| 1573 | - // lighten |
|
| 1574 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1573 | + // lighten |
|
| 1574 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1575 | 1575 | |
| 1576 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1577 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1576 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1577 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1578 | 1578 | |
| 1579 | 1579 | |
| 1580 | - // button states |
|
| 1581 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 1582 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1580 | + // button states |
|
| 1581 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 1582 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1583 | 1583 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
| 1584 | - $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1585 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1586 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1584 | + $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1585 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1586 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1587 | 1587 | |
| 1588 | - // text |
|
| 1588 | + // text |
|
| 1589 | 1589 | // $output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} "; |
| 1590 | 1590 | |
| 1591 | 1591 | |
@@ -1600,777 +1600,777 @@ discard block |
||
| 1600 | 1600 | // $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
| 1601 | 1601 | // } |
| 1602 | 1602 | |
| 1603 | - // alerts |
|
| 1604 | - if ( $aui_bs5 ) { |
|
| 1603 | + // alerts |
|
| 1604 | + if ( $aui_bs5 ) { |
|
| 1605 | 1605 | // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
| 1606 | - $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} "; |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - return $output; |
|
| 1610 | - } |
|
| 1611 | - |
|
| 1612 | - /** |
|
| 1613 | - * Build the CSS to overwrite a bootstrap color variable. |
|
| 1614 | - * |
|
| 1615 | - * @param $type |
|
| 1616 | - * @param $color_code |
|
| 1617 | - * @param $compatibility |
|
| 1618 | - * |
|
| 1619 | - * @return string |
|
| 1620 | - */ |
|
| 1621 | - public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){ |
|
| 1606 | + $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} "; |
|
| 1607 | + } |
|
| 1608 | + |
|
| 1609 | + return $output; |
|
| 1610 | + } |
|
| 1611 | + |
|
| 1612 | + /** |
|
| 1613 | + * Build the CSS to overwrite a bootstrap color variable. |
|
| 1614 | + * |
|
| 1615 | + * @param $type |
|
| 1616 | + * @param $color_code |
|
| 1617 | + * @param $compatibility |
|
| 1618 | + * |
|
| 1619 | + * @return string |
|
| 1620 | + */ |
|
| 1621 | + public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){ |
|
| 1622 | 1622 | global $aui_bs5; |
| 1623 | 1623 | |
| 1624 | - $is_var = false; |
|
| 1625 | - if(!$color_code){return '';} |
|
| 1626 | - if(strpos($color_code, 'var') !== false){ |
|
| 1627 | - //if(!sanitize_hex_color($color_code)){ |
|
| 1628 | - $color_code = esc_attr($color_code); |
|
| 1629 | - $is_var = true; |
|
| 1624 | + $is_var = false; |
|
| 1625 | + if(!$color_code){return '';} |
|
| 1626 | + if(strpos($color_code, 'var') !== false){ |
|
| 1627 | + //if(!sanitize_hex_color($color_code)){ |
|
| 1628 | + $color_code = esc_attr($color_code); |
|
| 1629 | + $is_var = true; |
|
| 1630 | 1630 | // $color_code = "rgba($color_code, 0.5)"; |
| 1631 | 1631 | // echo '###1'.$color_code.'###';//exit; |
| 1632 | - } |
|
| 1632 | + } |
|
| 1633 | 1633 | |
| 1634 | 1634 | // echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
| 1635 | 1635 | |
| 1636 | - if(!$color_code){return '';} |
|
| 1636 | + if(!$color_code){return '';} |
|
| 1637 | 1637 | |
| 1638 | 1638 | $rgb = self::hex_to_rgb($hex); |
| 1639 | 1639 | |
| 1640 | - if($compatibility===true || $compatibility===1){ |
|
| 1641 | - $compatibility = '.bsui'; |
|
| 1642 | - }elseif(!$compatibility){ |
|
| 1643 | - $compatibility = ''; |
|
| 1644 | - }else{ |
|
| 1645 | - $compatibility = esc_attr($compatibility); |
|
| 1646 | - } |
|
| 1640 | + if($compatibility===true || $compatibility===1){ |
|
| 1641 | + $compatibility = '.bsui'; |
|
| 1642 | + }elseif(!$compatibility){ |
|
| 1643 | + $compatibility = ''; |
|
| 1644 | + }else{ |
|
| 1645 | + $compatibility = esc_attr($compatibility); |
|
| 1646 | + } |
|
| 1647 | 1647 | |
| 1648 | 1648 | |
| 1649 | 1649 | |
| 1650 | 1650 | // echo '####'.$color_code;exit; |
| 1651 | 1651 | |
| 1652 | - $type = sanitize_html_class($type); |
|
| 1653 | - |
|
| 1654 | - /** |
|
| 1655 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1656 | - */ |
|
| 1657 | - $selectors = array( |
|
| 1658 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
| 1659 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 1660 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 1661 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 1662 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 1663 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 1664 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 1665 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 1666 | - ".badge-{$type}" => array( 'b' ), |
|
| 1667 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
| 1668 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
| 1669 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 1670 | - ); |
|
| 1671 | - |
|
| 1672 | - if ( $aui_bs5 ) { |
|
| 1652 | + $type = sanitize_html_class($type); |
|
| 1653 | + |
|
| 1654 | + /** |
|
| 1655 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1656 | + */ |
|
| 1657 | + $selectors = array( |
|
| 1658 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
| 1659 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 1660 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 1661 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 1662 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 1663 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 1664 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 1665 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 1666 | + ".badge-{$type}" => array( 'b' ), |
|
| 1667 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
| 1668 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
| 1669 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 1670 | + ); |
|
| 1671 | + |
|
| 1672 | + if ( $aui_bs5 ) { |
|
| 1673 | 1673 | unset($selectors[".alert-{$type}" ]); |
| 1674 | - } |
|
| 1675 | - |
|
| 1676 | - if ( $type == 'primary' ) { |
|
| 1677 | - $selectors = $selectors + array( |
|
| 1678 | - 'a' => array( 'c' ), |
|
| 1679 | - '.btn-link' => array( 'c' ), |
|
| 1680 | - '.dropdown-item.active' => array( 'b' ), |
|
| 1681 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 1682 | - 'b', |
|
| 1683 | - 'o' |
|
| 1684 | - ), |
|
| 1685 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 1686 | - 'b', |
|
| 1687 | - 'o' |
|
| 1688 | - ), |
|
| 1689 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 1690 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 1691 | - '.page-link' => array( 'c' ), |
|
| 1692 | - '.page-item.active .page-link' => array( |
|
| 1693 | - 'b', |
|
| 1694 | - 'o' |
|
| 1695 | - ), |
|
| 1696 | - '.progress-bar' => array( 'b' ), |
|
| 1697 | - '.list-group-item.active' => array( |
|
| 1698 | - 'b', |
|
| 1699 | - 'o' |
|
| 1700 | - ), |
|
| 1701 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 1674 | + } |
|
| 1675 | + |
|
| 1676 | + if ( $type == 'primary' ) { |
|
| 1677 | + $selectors = $selectors + array( |
|
| 1678 | + 'a' => array( 'c' ), |
|
| 1679 | + '.btn-link' => array( 'c' ), |
|
| 1680 | + '.dropdown-item.active' => array( 'b' ), |
|
| 1681 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 1682 | + 'b', |
|
| 1683 | + 'o' |
|
| 1684 | + ), |
|
| 1685 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 1686 | + 'b', |
|
| 1687 | + 'o' |
|
| 1688 | + ), |
|
| 1689 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 1690 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 1691 | + '.page-link' => array( 'c' ), |
|
| 1692 | + '.page-item.active .page-link' => array( |
|
| 1693 | + 'b', |
|
| 1694 | + 'o' |
|
| 1695 | + ), |
|
| 1696 | + '.progress-bar' => array( 'b' ), |
|
| 1697 | + '.list-group-item.active' => array( |
|
| 1698 | + 'b', |
|
| 1699 | + 'o' |
|
| 1700 | + ), |
|
| 1701 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 1702 | 1702 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1703 | 1703 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1704 | 1704 | // '.custom-range::-ms-thumb' => array('b'), |
| 1705 | - ); |
|
| 1706 | - } |
|
| 1707 | - |
|
| 1708 | - $important_selectors = array( |
|
| 1709 | - ".bg-{$type}" => array('b','f'), |
|
| 1710 | - ".border-{$type}" => array('o'), |
|
| 1711 | - ".text-{$type}" => array('c'), |
|
| 1712 | - ); |
|
| 1713 | - |
|
| 1714 | - $color = array(); |
|
| 1715 | - $color_i = array(); |
|
| 1716 | - $background = array(); |
|
| 1717 | - $background_i = array(); |
|
| 1718 | - $border = array(); |
|
| 1719 | - $border_i = array(); |
|
| 1720 | - $fill = array(); |
|
| 1721 | - $fill_i = array(); |
|
| 1722 | - |
|
| 1723 | - $output = ''; |
|
| 1724 | - |
|
| 1725 | - if ( $aui_bs5 ) { |
|
| 1705 | + ); |
|
| 1706 | + } |
|
| 1707 | + |
|
| 1708 | + $important_selectors = array( |
|
| 1709 | + ".bg-{$type}" => array('b','f'), |
|
| 1710 | + ".border-{$type}" => array('o'), |
|
| 1711 | + ".text-{$type}" => array('c'), |
|
| 1712 | + ); |
|
| 1713 | + |
|
| 1714 | + $color = array(); |
|
| 1715 | + $color_i = array(); |
|
| 1716 | + $background = array(); |
|
| 1717 | + $background_i = array(); |
|
| 1718 | + $border = array(); |
|
| 1719 | + $border_i = array(); |
|
| 1720 | + $fill = array(); |
|
| 1721 | + $fill_i = array(); |
|
| 1722 | + |
|
| 1723 | + $output = ''; |
|
| 1724 | + |
|
| 1725 | + if ( $aui_bs5 ) { |
|
| 1726 | 1726 | // $output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }'; |
| 1727 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
| 1728 | - } |
|
| 1729 | - |
|
| 1730 | - // build rules into each type |
|
| 1731 | - foreach($selectors as $selector => $types){ |
|
| 1732 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1733 | - $types = array_combine($types,$types); |
|
| 1734 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1735 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1736 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1737 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1738 | - } |
|
| 1739 | - |
|
| 1740 | - // build rules into each type |
|
| 1741 | - foreach($important_selectors as $selector => $types){ |
|
| 1742 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1743 | - $types = array_combine($types,$types); |
|
| 1744 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1745 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1746 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1747 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1748 | - } |
|
| 1749 | - |
|
| 1750 | - // add any color rules |
|
| 1751 | - if(!empty($color)){ |
|
| 1752 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1753 | - } |
|
| 1754 | - if(!empty($color_i)){ |
|
| 1755 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1756 | - } |
|
| 1757 | - |
|
| 1758 | - // add any background color rules |
|
| 1759 | - if(!empty($background)){ |
|
| 1760 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1761 | - } |
|
| 1762 | - if(!empty($background_i)){ |
|
| 1763 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1727 | + $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
| 1728 | + } |
|
| 1729 | + |
|
| 1730 | + // build rules into each type |
|
| 1731 | + foreach($selectors as $selector => $types){ |
|
| 1732 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1733 | + $types = array_combine($types,$types); |
|
| 1734 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1735 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1736 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1737 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1738 | + } |
|
| 1739 | + |
|
| 1740 | + // build rules into each type |
|
| 1741 | + foreach($important_selectors as $selector => $types){ |
|
| 1742 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 1743 | + $types = array_combine($types,$types); |
|
| 1744 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1745 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1746 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1747 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1748 | + } |
|
| 1749 | + |
|
| 1750 | + // add any color rules |
|
| 1751 | + if(!empty($color)){ |
|
| 1752 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1753 | + } |
|
| 1754 | + if(!empty($color_i)){ |
|
| 1755 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1756 | + } |
|
| 1757 | + |
|
| 1758 | + // add any background color rules |
|
| 1759 | + if(!empty($background)){ |
|
| 1760 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1761 | + } |
|
| 1762 | + if(!empty($background_i)){ |
|
| 1763 | + $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1764 | 1764 | // $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
| 1765 | - } |
|
| 1765 | + } |
|
| 1766 | 1766 | |
| 1767 | - // add any border color rules |
|
| 1768 | - if(!empty($border)){ |
|
| 1769 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1770 | - } |
|
| 1771 | - if(!empty($border_i)){ |
|
| 1772 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1773 | - } |
|
| 1767 | + // add any border color rules |
|
| 1768 | + if(!empty($border)){ |
|
| 1769 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1770 | + } |
|
| 1771 | + if(!empty($border_i)){ |
|
| 1772 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1773 | + } |
|
| 1774 | 1774 | |
| 1775 | - // add any fill color rules |
|
| 1776 | - if(!empty($fill)){ |
|
| 1777 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1778 | - } |
|
| 1779 | - if(!empty($fill_i)){ |
|
| 1780 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1781 | - } |
|
| 1775 | + // add any fill color rules |
|
| 1776 | + if(!empty($fill)){ |
|
| 1777 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1778 | + } |
|
| 1779 | + if(!empty($fill_i)){ |
|
| 1780 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1781 | + } |
|
| 1782 | 1782 | |
| 1783 | 1783 | |
| 1784 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 1784 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 1785 | 1785 | |
| 1786 | - $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 1787 | - // darken |
|
| 1788 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1789 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1790 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1791 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
| 1786 | + $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 1787 | + // darken |
|
| 1788 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1789 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1790 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1791 | + $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
| 1792 | 1792 | |
| 1793 | - // lighten |
|
| 1794 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1793 | + // lighten |
|
| 1794 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1795 | 1795 | |
| 1796 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1797 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1796 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1797 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1798 | 1798 | |
| 1799 | 1799 | |
| 1800 | - // button states |
|
| 1801 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 1802 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1800 | + // button states |
|
| 1801 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 1802 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1803 | 1803 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
| 1804 | - $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1805 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1806 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1804 | + $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1805 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1806 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1807 | 1807 | |
| 1808 | - if ( $type == 'primary' ) { |
|
| 1809 | - // dropdown's |
|
| 1810 | - $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1808 | + if ( $type == 'primary' ) { |
|
| 1809 | + // dropdown's |
|
| 1810 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1811 | 1811 | |
| 1812 | - // input states |
|
| 1813 | - $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1812 | + // input states |
|
| 1813 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1814 | 1814 | |
| 1815 | - // page link |
|
| 1816 | - $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1817 | - } |
|
| 1815 | + // page link |
|
| 1816 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1817 | + } |
|
| 1818 | 1818 | |
| 1819 | 1819 | // alerts |
| 1820 | - if ( $aui_bs5 ) { |
|
| 1820 | + if ( $aui_bs5 ) { |
|
| 1821 | 1821 | // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
| 1822 | - $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} "; |
|
| 1823 | - } |
|
| 1824 | - |
|
| 1825 | - return $output; |
|
| 1826 | - } |
|
| 1827 | - |
|
| 1828 | - /** |
|
| 1829 | - * |
|
| 1830 | - * @deprecated 0.1.76 Use css_overwrite() |
|
| 1831 | - * |
|
| 1832 | - * @param $color_code |
|
| 1833 | - * @param $compatibility |
|
| 1834 | - * @param $use_variable |
|
| 1835 | - * |
|
| 1836 | - * @return string |
|
| 1837 | - */ |
|
| 1838 | - public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
| 1839 | - |
|
| 1840 | - if(!$use_variable){ |
|
| 1841 | - $color_code = sanitize_hex_color($color_code); |
|
| 1842 | - if(!$color_code){return '';} |
|
| 1843 | - } |
|
| 1844 | - |
|
| 1845 | - /** |
|
| 1846 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1847 | - */ |
|
| 1848 | - $selectors = array( |
|
| 1849 | - 'a' => array('c'), |
|
| 1850 | - '.btn-primary' => array('b','o'), |
|
| 1851 | - '.btn-primary.disabled' => array('b','o'), |
|
| 1852 | - '.btn-primary:disabled' => array('b','o'), |
|
| 1853 | - '.btn-outline-primary' => array('c','o'), |
|
| 1854 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 1855 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1856 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1857 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1858 | - '.btn-link' => array('c'), |
|
| 1859 | - '.dropdown-item.active' => array('b'), |
|
| 1860 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1861 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1822 | + $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} "; |
|
| 1823 | + } |
|
| 1824 | + |
|
| 1825 | + return $output; |
|
| 1826 | + } |
|
| 1827 | + |
|
| 1828 | + /** |
|
| 1829 | + * |
|
| 1830 | + * @deprecated 0.1.76 Use css_overwrite() |
|
| 1831 | + * |
|
| 1832 | + * @param $color_code |
|
| 1833 | + * @param $compatibility |
|
| 1834 | + * @param $use_variable |
|
| 1835 | + * |
|
| 1836 | + * @return string |
|
| 1837 | + */ |
|
| 1838 | + public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
| 1839 | + |
|
| 1840 | + if(!$use_variable){ |
|
| 1841 | + $color_code = sanitize_hex_color($color_code); |
|
| 1842 | + if(!$color_code){return '';} |
|
| 1843 | + } |
|
| 1844 | + |
|
| 1845 | + /** |
|
| 1846 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1847 | + */ |
|
| 1848 | + $selectors = array( |
|
| 1849 | + 'a' => array('c'), |
|
| 1850 | + '.btn-primary' => array('b','o'), |
|
| 1851 | + '.btn-primary.disabled' => array('b','o'), |
|
| 1852 | + '.btn-primary:disabled' => array('b','o'), |
|
| 1853 | + '.btn-outline-primary' => array('c','o'), |
|
| 1854 | + '.btn-outline-primary:hover' => array('b','o'), |
|
| 1855 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1856 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1857 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1858 | + '.btn-link' => array('c'), |
|
| 1859 | + '.dropdown-item.active' => array('b'), |
|
| 1860 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1861 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1862 | 1862 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1863 | 1863 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1864 | 1864 | // '.custom-range::-ms-thumb' => array('b'), |
| 1865 | - '.nav-pills .nav-link.active' => array('b'), |
|
| 1866 | - '.nav-pills .show>.nav-link' => array('b'), |
|
| 1867 | - '.page-link' => array('c'), |
|
| 1868 | - '.page-item.active .page-link' => array('b','o'), |
|
| 1869 | - '.badge-primary' => array('b'), |
|
| 1870 | - '.alert-primary' => array('b','o'), |
|
| 1871 | - '.progress-bar' => array('b'), |
|
| 1872 | - '.list-group-item.active' => array('b','o'), |
|
| 1873 | - '.bg-primary' => array('b','f'), |
|
| 1874 | - '.btn-link.btn-primary' => array('c'), |
|
| 1875 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1876 | - ); |
|
| 1877 | - |
|
| 1878 | - $important_selectors = array( |
|
| 1879 | - '.bg-primary' => array('b','f'), |
|
| 1880 | - '.border-primary' => array('o'), |
|
| 1881 | - '.text-primary' => array('c'), |
|
| 1882 | - ); |
|
| 1883 | - |
|
| 1884 | - $color = array(); |
|
| 1885 | - $color_i = array(); |
|
| 1886 | - $background = array(); |
|
| 1887 | - $background_i = array(); |
|
| 1888 | - $border = array(); |
|
| 1889 | - $border_i = array(); |
|
| 1890 | - $fill = array(); |
|
| 1891 | - $fill_i = array(); |
|
| 1892 | - |
|
| 1893 | - $output = ''; |
|
| 1894 | - |
|
| 1895 | - // build rules into each type |
|
| 1896 | - foreach($selectors as $selector => $types){ |
|
| 1897 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1898 | - $types = array_combine($types,$types); |
|
| 1899 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1900 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1901 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1902 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1903 | - } |
|
| 1904 | - |
|
| 1905 | - // build rules into each type |
|
| 1906 | - foreach($important_selectors as $selector => $types){ |
|
| 1907 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1908 | - $types = array_combine($types,$types); |
|
| 1909 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1910 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1911 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1912 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1913 | - } |
|
| 1914 | - |
|
| 1915 | - // add any color rules |
|
| 1916 | - if(!empty($color)){ |
|
| 1917 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1918 | - } |
|
| 1919 | - if(!empty($color_i)){ |
|
| 1920 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1921 | - } |
|
| 1922 | - |
|
| 1923 | - // add any background color rules |
|
| 1924 | - if(!empty($background)){ |
|
| 1925 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1926 | - } |
|
| 1927 | - if(!empty($background_i)){ |
|
| 1928 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1929 | - } |
|
| 1930 | - |
|
| 1931 | - // add any border color rules |
|
| 1932 | - if(!empty($border)){ |
|
| 1933 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1934 | - } |
|
| 1935 | - if(!empty($border_i)){ |
|
| 1936 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1937 | - } |
|
| 1938 | - |
|
| 1939 | - // add any fill color rules |
|
| 1940 | - if(!empty($fill)){ |
|
| 1941 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1942 | - } |
|
| 1943 | - if(!empty($fill_i)){ |
|
| 1944 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1945 | - } |
|
| 1946 | - |
|
| 1947 | - |
|
| 1948 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 1949 | - |
|
| 1950 | - // darken |
|
| 1951 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1952 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1953 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1954 | - |
|
| 1955 | - // lighten |
|
| 1956 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1957 | - |
|
| 1958 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1959 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1960 | - |
|
| 1961 | - |
|
| 1962 | - // button states |
|
| 1963 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1964 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1965 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1966 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1967 | - |
|
| 1968 | - |
|
| 1969 | - // dropdown's |
|
| 1970 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1971 | - |
|
| 1972 | - |
|
| 1973 | - // input states |
|
| 1974 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1975 | - |
|
| 1976 | - // page link |
|
| 1977 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1978 | - |
|
| 1979 | - return $output; |
|
| 1980 | - } |
|
| 1981 | - |
|
| 1982 | - /** |
|
| 1983 | - * |
|
| 1984 | - * @deprecated 0.1.76 Use css_overwrite() |
|
| 1985 | - * |
|
| 1986 | - * @param $color_code |
|
| 1987 | - * @param $compatibility |
|
| 1988 | - * |
|
| 1989 | - * @return string |
|
| 1990 | - */ |
|
| 1991 | - public static function css_secondary($color_code,$compatibility){; |
|
| 1992 | - $color_code = sanitize_hex_color($color_code); |
|
| 1993 | - if(!$color_code){return '';} |
|
| 1994 | - /** |
|
| 1995 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1996 | - */ |
|
| 1997 | - $selectors = array( |
|
| 1998 | - '.btn-secondary' => array('b','o'), |
|
| 1999 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 2000 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 2001 | - '.btn-outline-secondary' => array('c','o'), |
|
| 2002 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 2003 | - '.btn-outline-secondary.disabled' => array('c'), |
|
| 2004 | - '.btn-outline-secondary:disabled' => array('c'), |
|
| 2005 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2006 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2007 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 2008 | - '.badge-secondary' => array('b'), |
|
| 2009 | - '.alert-secondary' => array('b','o'), |
|
| 2010 | - '.btn-link.btn-secondary' => array('c'), |
|
| 2011 | - ); |
|
| 2012 | - |
|
| 2013 | - $important_selectors = array( |
|
| 2014 | - '.bg-secondary' => array('b','f'), |
|
| 2015 | - '.border-secondary' => array('o'), |
|
| 2016 | - '.text-secondary' => array('c'), |
|
| 2017 | - ); |
|
| 2018 | - |
|
| 2019 | - $color = array(); |
|
| 2020 | - $color_i = array(); |
|
| 2021 | - $background = array(); |
|
| 2022 | - $background_i = array(); |
|
| 2023 | - $border = array(); |
|
| 2024 | - $border_i = array(); |
|
| 2025 | - $fill = array(); |
|
| 2026 | - $fill_i = array(); |
|
| 2027 | - |
|
| 2028 | - $output = ''; |
|
| 2029 | - |
|
| 2030 | - // build rules into each type |
|
| 2031 | - foreach($selectors as $selector => $types){ |
|
| 2032 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2033 | - $types = array_combine($types,$types); |
|
| 2034 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2035 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2036 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2037 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2038 | - } |
|
| 2039 | - |
|
| 2040 | - // build rules into each type |
|
| 2041 | - foreach($important_selectors as $selector => $types){ |
|
| 2042 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2043 | - $types = array_combine($types,$types); |
|
| 2044 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2045 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2046 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2047 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2048 | - } |
|
| 2049 | - |
|
| 2050 | - // add any color rules |
|
| 2051 | - if(!empty($color)){ |
|
| 2052 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2053 | - } |
|
| 2054 | - if(!empty($color_i)){ |
|
| 2055 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2056 | - } |
|
| 2057 | - |
|
| 2058 | - // add any background color rules |
|
| 2059 | - if(!empty($background)){ |
|
| 2060 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2061 | - } |
|
| 2062 | - if(!empty($background_i)){ |
|
| 2063 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2064 | - } |
|
| 2065 | - |
|
| 2066 | - // add any border color rules |
|
| 2067 | - if(!empty($border)){ |
|
| 2068 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2069 | - } |
|
| 2070 | - if(!empty($border_i)){ |
|
| 2071 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2072 | - } |
|
| 2073 | - |
|
| 2074 | - // add any fill color rules |
|
| 2075 | - if(!empty($fill)){ |
|
| 2076 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2077 | - } |
|
| 2078 | - if(!empty($fill_i)){ |
|
| 2079 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2080 | - } |
|
| 2081 | - |
|
| 2082 | - |
|
| 2083 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 2084 | - |
|
| 2085 | - // darken |
|
| 2086 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2087 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2088 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2089 | - |
|
| 2090 | - // lighten |
|
| 2091 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2092 | - |
|
| 2093 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2094 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2095 | - |
|
| 2096 | - |
|
| 2097 | - // button states |
|
| 2098 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2099 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2100 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2101 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2102 | - |
|
| 2103 | - |
|
| 2104 | - return $output; |
|
| 2105 | - } |
|
| 2106 | - |
|
| 2107 | - /** |
|
| 2108 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2109 | - * |
|
| 2110 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2111 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2112 | - * |
|
| 2113 | - * @return string |
|
| 2114 | - */ |
|
| 2115 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2116 | - $hexCode = ltrim($hexCode, '#'); |
|
| 2117 | - |
|
| 2118 | - if ( strpos( $hexCode, 'rgba(' ) !== false || strpos( $hexCode, 'rgb(' ) !== false ) { |
|
| 2119 | - return $hexCode; |
|
| 2120 | - } |
|
| 2121 | - |
|
| 2122 | - if (strlen($hexCode) == 3) { |
|
| 2123 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2124 | - } |
|
| 2125 | - |
|
| 2126 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 2127 | - |
|
| 2128 | - foreach ($hexCode as & $color) { |
|
| 2129 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2130 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 2131 | - |
|
| 2132 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2133 | - } |
|
| 2134 | - |
|
| 2135 | - return '#' . implode($hexCode); |
|
| 2136 | - } |
|
| 2137 | - |
|
| 2138 | - /** |
|
| 2139 | - * Check if we should display examples. |
|
| 2140 | - */ |
|
| 2141 | - public function maybe_show_examples(){ |
|
| 2142 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2143 | - echo "<head>"; |
|
| 2144 | - wp_head(); |
|
| 2145 | - echo "</head>"; |
|
| 2146 | - echo "<body>"; |
|
| 2147 | - echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2148 | - echo "</body>"; |
|
| 2149 | - exit; |
|
| 2150 | - } |
|
| 2151 | - } |
|
| 2152 | - |
|
| 2153 | - /** |
|
| 2154 | - * Get developer examples. |
|
| 2155 | - * |
|
| 2156 | - * @return string |
|
| 2157 | - */ |
|
| 2158 | - public function get_examples(){ |
|
| 2159 | - $output = ''; |
|
| 2160 | - |
|
| 2161 | - |
|
| 2162 | - // open form |
|
| 2163 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2164 | - |
|
| 2165 | - // input example |
|
| 2166 | - $output .= aui()->input(array( |
|
| 2167 | - 'type' => 'text', |
|
| 2168 | - 'id' => 'text-example', |
|
| 2169 | - 'name' => 'text-example', |
|
| 2170 | - 'placeholder' => 'text placeholder', |
|
| 2171 | - 'title' => 'Text input example', |
|
| 2172 | - 'value' => '', |
|
| 2173 | - 'required' => false, |
|
| 2174 | - 'help_text' => 'help text', |
|
| 2175 | - 'label' => 'Text input example label' |
|
| 2176 | - )); |
|
| 2177 | - |
|
| 2178 | - // input example |
|
| 2179 | - $output .= aui()->input(array( |
|
| 2180 | - 'type' => 'url', |
|
| 2181 | - 'id' => 'text-example2', |
|
| 2182 | - 'name' => 'text-example', |
|
| 2183 | - 'placeholder' => 'url placeholder', |
|
| 2184 | - 'title' => 'Text input example', |
|
| 2185 | - 'value' => '', |
|
| 2186 | - 'required' => false, |
|
| 2187 | - 'help_text' => 'help text', |
|
| 2188 | - 'label' => 'Text input example label' |
|
| 2189 | - )); |
|
| 2190 | - |
|
| 2191 | - // checkbox example |
|
| 2192 | - $output .= aui()->input(array( |
|
| 2193 | - 'type' => 'checkbox', |
|
| 2194 | - 'id' => 'checkbox-example', |
|
| 2195 | - 'name' => 'checkbox-example', |
|
| 2196 | - 'placeholder' => 'checkbox-example', |
|
| 2197 | - 'title' => 'Checkbox example', |
|
| 2198 | - 'value' => '1', |
|
| 2199 | - 'checked' => true, |
|
| 2200 | - 'required' => false, |
|
| 2201 | - 'help_text' => 'help text', |
|
| 2202 | - 'label' => 'Checkbox checked' |
|
| 2203 | - )); |
|
| 2204 | - |
|
| 2205 | - // checkbox example |
|
| 2206 | - $output .= aui()->input(array( |
|
| 2207 | - 'type' => 'checkbox', |
|
| 2208 | - 'id' => 'checkbox-example2', |
|
| 2209 | - 'name' => 'checkbox-example2', |
|
| 2210 | - 'placeholder' => 'checkbox-example', |
|
| 2211 | - 'title' => 'Checkbox example', |
|
| 2212 | - 'value' => '1', |
|
| 2213 | - 'checked' => false, |
|
| 2214 | - 'required' => false, |
|
| 2215 | - 'help_text' => 'help text', |
|
| 2216 | - 'label' => 'Checkbox un-checked' |
|
| 2217 | - )); |
|
| 2218 | - |
|
| 2219 | - // switch example |
|
| 2220 | - $output .= aui()->input(array( |
|
| 2221 | - 'type' => 'checkbox', |
|
| 2222 | - 'id' => 'switch-example', |
|
| 2223 | - 'name' => 'switch-example', |
|
| 2224 | - 'placeholder' => 'checkbox-example', |
|
| 2225 | - 'title' => 'Switch example', |
|
| 2226 | - 'value' => '1', |
|
| 2227 | - 'checked' => true, |
|
| 2228 | - 'switch' => true, |
|
| 2229 | - 'required' => false, |
|
| 2230 | - 'help_text' => 'help text', |
|
| 2231 | - 'label' => 'Switch on' |
|
| 2232 | - )); |
|
| 2233 | - |
|
| 2234 | - // switch example |
|
| 2235 | - $output .= aui()->input(array( |
|
| 2236 | - 'type' => 'checkbox', |
|
| 2237 | - 'id' => 'switch-example2', |
|
| 2238 | - 'name' => 'switch-example2', |
|
| 2239 | - 'placeholder' => 'checkbox-example', |
|
| 2240 | - 'title' => 'Switch example', |
|
| 2241 | - 'value' => '1', |
|
| 2242 | - 'checked' => false, |
|
| 2243 | - 'switch' => true, |
|
| 2244 | - 'required' => false, |
|
| 2245 | - 'help_text' => 'help text', |
|
| 2246 | - 'label' => 'Switch off' |
|
| 2247 | - )); |
|
| 2248 | - |
|
| 2249 | - // close form |
|
| 2250 | - $output .= "</form>"; |
|
| 2251 | - |
|
| 2252 | - return $output; |
|
| 2253 | - } |
|
| 2254 | - |
|
| 2255 | - /** |
|
| 2256 | - * Calendar params. |
|
| 2257 | - * |
|
| 2258 | - * @since 0.1.44 |
|
| 2259 | - * |
|
| 2260 | - * @return array Calendar params. |
|
| 2261 | - */ |
|
| 2262 | - public static function calendar_params() { |
|
| 2263 | - $params = array( |
|
| 2264 | - 'month_long_1' => __( 'January', 'ayecode-connect' ), |
|
| 2265 | - 'month_long_2' => __( 'February', 'ayecode-connect' ), |
|
| 2266 | - 'month_long_3' => __( 'March', 'ayecode-connect' ), |
|
| 2267 | - 'month_long_4' => __( 'April', 'ayecode-connect' ), |
|
| 2268 | - 'month_long_5' => __( 'May', 'ayecode-connect' ), |
|
| 2269 | - 'month_long_6' => __( 'June', 'ayecode-connect' ), |
|
| 2270 | - 'month_long_7' => __( 'July', 'ayecode-connect' ), |
|
| 2271 | - 'month_long_8' => __( 'August', 'ayecode-connect' ), |
|
| 2272 | - 'month_long_9' => __( 'September', 'ayecode-connect' ), |
|
| 2273 | - 'month_long_10' => __( 'October', 'ayecode-connect' ), |
|
| 2274 | - 'month_long_11' => __( 'November', 'ayecode-connect' ), |
|
| 2275 | - 'month_long_12' => __( 'December', 'ayecode-connect' ), |
|
| 2276 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ), |
|
| 2277 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ), |
|
| 2278 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ), |
|
| 2279 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ), |
|
| 2280 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ), |
|
| 2281 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ), |
|
| 2282 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ), |
|
| 2283 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ), |
|
| 2284 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ), |
|
| 2285 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ), |
|
| 2286 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ), |
|
| 2287 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ), |
|
| 2288 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ), |
|
| 2289 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ), |
|
| 2290 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ), |
|
| 2291 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ), |
|
| 2292 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ), |
|
| 2293 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ), |
|
| 2294 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ), |
|
| 2295 | - 'day_s2_1' => __( 'Su', 'ayecode-connect' ), |
|
| 2296 | - 'day_s2_2' => __( 'Mo', 'ayecode-connect' ), |
|
| 2297 | - 'day_s2_3' => __( 'Tu', 'ayecode-connect' ), |
|
| 2298 | - 'day_s2_4' => __( 'We', 'ayecode-connect' ), |
|
| 2299 | - 'day_s2_5' => __( 'Th', 'ayecode-connect' ), |
|
| 2300 | - 'day_s2_6' => __( 'Fr', 'ayecode-connect' ), |
|
| 2301 | - 'day_s2_7' => __( 'Sa', 'ayecode-connect' ), |
|
| 2302 | - 'day_s3_1' => __( 'Sun', 'ayecode-connect' ), |
|
| 2303 | - 'day_s3_2' => __( 'Mon', 'ayecode-connect' ), |
|
| 2304 | - 'day_s3_3' => __( 'Tue', 'ayecode-connect' ), |
|
| 2305 | - 'day_s3_4' => __( 'Wed', 'ayecode-connect' ), |
|
| 2306 | - 'day_s3_5' => __( 'Thu', 'ayecode-connect' ), |
|
| 2307 | - 'day_s3_6' => __( 'Fri', 'ayecode-connect' ), |
|
| 2308 | - 'day_s3_7' => __( 'Sat', 'ayecode-connect' ), |
|
| 2309 | - 'day_s5_1' => __( 'Sunday', 'ayecode-connect' ), |
|
| 2310 | - 'day_s5_2' => __( 'Monday', 'ayecode-connect' ), |
|
| 2311 | - 'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ), |
|
| 2312 | - 'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ), |
|
| 2313 | - 'day_s5_5' => __( 'Thursday', 'ayecode-connect' ), |
|
| 2314 | - 'day_s5_6' => __( 'Friday', 'ayecode-connect' ), |
|
| 2315 | - 'day_s5_7' => __( 'Saturday', 'ayecode-connect' ), |
|
| 2316 | - 'am_lower' => __( 'am', 'ayecode-connect' ), |
|
| 2317 | - 'pm_lower' => __( 'pm', 'ayecode-connect' ), |
|
| 2318 | - 'am_upper' => __( 'AM', 'ayecode-connect' ), |
|
| 2319 | - 'pm_upper' => __( 'PM', 'ayecode-connect' ), |
|
| 2320 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2321 | - 'time_24hr' => false, |
|
| 2322 | - 'year' => __( 'Year', 'ayecode-connect' ), |
|
| 2323 | - 'hour' => __( 'Hour', 'ayecode-connect' ), |
|
| 2324 | - 'minute' => __( 'Minute', 'ayecode-connect' ), |
|
| 2325 | - 'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ), |
|
| 2326 | - 'rangeSeparator' => __( ' to ', 'ayecode-connect' ), |
|
| 2327 | - 'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ), |
|
| 2328 | - 'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' ) |
|
| 2329 | - ); |
|
| 2330 | - |
|
| 2331 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2332 | - } |
|
| 2333 | - |
|
| 2334 | - /** |
|
| 2335 | - * Flatpickr calendar localize. |
|
| 2336 | - * |
|
| 2337 | - * @since 0.1.44 |
|
| 2338 | - * |
|
| 2339 | - * @return string Calendar locale. |
|
| 2340 | - */ |
|
| 2341 | - public static function flatpickr_locale() { |
|
| 2342 | - $params = self::calendar_params(); |
|
| 2343 | - |
|
| 2344 | - if ( is_string( $params ) ) { |
|
| 2345 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2346 | - } else { |
|
| 2347 | - foreach ( (array) $params as $key => $value ) { |
|
| 2348 | - if ( ! is_scalar( $value ) ) { |
|
| 2349 | - continue; |
|
| 2350 | - } |
|
| 2351 | - |
|
| 2352 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2353 | - } |
|
| 2354 | - } |
|
| 1865 | + '.nav-pills .nav-link.active' => array('b'), |
|
| 1866 | + '.nav-pills .show>.nav-link' => array('b'), |
|
| 1867 | + '.page-link' => array('c'), |
|
| 1868 | + '.page-item.active .page-link' => array('b','o'), |
|
| 1869 | + '.badge-primary' => array('b'), |
|
| 1870 | + '.alert-primary' => array('b','o'), |
|
| 1871 | + '.progress-bar' => array('b'), |
|
| 1872 | + '.list-group-item.active' => array('b','o'), |
|
| 1873 | + '.bg-primary' => array('b','f'), |
|
| 1874 | + '.btn-link.btn-primary' => array('c'), |
|
| 1875 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1876 | + ); |
|
| 1877 | + |
|
| 1878 | + $important_selectors = array( |
|
| 1879 | + '.bg-primary' => array('b','f'), |
|
| 1880 | + '.border-primary' => array('o'), |
|
| 1881 | + '.text-primary' => array('c'), |
|
| 1882 | + ); |
|
| 1883 | + |
|
| 1884 | + $color = array(); |
|
| 1885 | + $color_i = array(); |
|
| 1886 | + $background = array(); |
|
| 1887 | + $background_i = array(); |
|
| 1888 | + $border = array(); |
|
| 1889 | + $border_i = array(); |
|
| 1890 | + $fill = array(); |
|
| 1891 | + $fill_i = array(); |
|
| 1892 | + |
|
| 1893 | + $output = ''; |
|
| 1894 | + |
|
| 1895 | + // build rules into each type |
|
| 1896 | + foreach($selectors as $selector => $types){ |
|
| 1897 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1898 | + $types = array_combine($types,$types); |
|
| 1899 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1900 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1901 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1902 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1903 | + } |
|
| 1904 | + |
|
| 1905 | + // build rules into each type |
|
| 1906 | + foreach($important_selectors as $selector => $types){ |
|
| 1907 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1908 | + $types = array_combine($types,$types); |
|
| 1909 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1910 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1911 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1912 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1913 | + } |
|
| 1914 | + |
|
| 1915 | + // add any color rules |
|
| 1916 | + if(!empty($color)){ |
|
| 1917 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1918 | + } |
|
| 1919 | + if(!empty($color_i)){ |
|
| 1920 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1921 | + } |
|
| 1922 | + |
|
| 1923 | + // add any background color rules |
|
| 1924 | + if(!empty($background)){ |
|
| 1925 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1926 | + } |
|
| 1927 | + if(!empty($background_i)){ |
|
| 1928 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1929 | + } |
|
| 1930 | + |
|
| 1931 | + // add any border color rules |
|
| 1932 | + if(!empty($border)){ |
|
| 1933 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1934 | + } |
|
| 1935 | + if(!empty($border_i)){ |
|
| 1936 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1937 | + } |
|
| 1938 | + |
|
| 1939 | + // add any fill color rules |
|
| 1940 | + if(!empty($fill)){ |
|
| 1941 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1942 | + } |
|
| 1943 | + if(!empty($fill_i)){ |
|
| 1944 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1945 | + } |
|
| 1946 | + |
|
| 1947 | + |
|
| 1948 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 1949 | + |
|
| 1950 | + // darken |
|
| 1951 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1952 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1953 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1954 | + |
|
| 1955 | + // lighten |
|
| 1956 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1957 | + |
|
| 1958 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1959 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1960 | + |
|
| 1961 | + |
|
| 1962 | + // button states |
|
| 1963 | + $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1964 | + $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1965 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1966 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2355 | 1967 | |
| 2356 | - $day_s3 = array(); |
|
| 2357 | - $day_s5 = array(); |
|
| 2358 | 1968 | |
| 2359 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2360 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2361 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2362 | - } |
|
| 1969 | + // dropdown's |
|
| 1970 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2363 | 1971 | |
| 2364 | - $month_s = array(); |
|
| 2365 | - $month_long = array(); |
|
| 2366 | 1972 | |
| 2367 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2368 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2369 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2370 | - } |
|
| 1973 | + // input states |
|
| 1974 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2371 | 1975 | |
| 2372 | - ob_start(); |
|
| 2373 | - if ( 0 ) { ?><script><?php } ?> |
|
| 1976 | + // page link |
|
| 1977 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1978 | + |
|
| 1979 | + return $output; |
|
| 1980 | + } |
|
| 1981 | + |
|
| 1982 | + /** |
|
| 1983 | + * |
|
| 1984 | + * @deprecated 0.1.76 Use css_overwrite() |
|
| 1985 | + * |
|
| 1986 | + * @param $color_code |
|
| 1987 | + * @param $compatibility |
|
| 1988 | + * |
|
| 1989 | + * @return string |
|
| 1990 | + */ |
|
| 1991 | + public static function css_secondary($color_code,$compatibility){; |
|
| 1992 | + $color_code = sanitize_hex_color($color_code); |
|
| 1993 | + if(!$color_code){return '';} |
|
| 1994 | + /** |
|
| 1995 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1996 | + */ |
|
| 1997 | + $selectors = array( |
|
| 1998 | + '.btn-secondary' => array('b','o'), |
|
| 1999 | + '.btn-secondary.disabled' => array('b','o'), |
|
| 2000 | + '.btn-secondary:disabled' => array('b','o'), |
|
| 2001 | + '.btn-outline-secondary' => array('c','o'), |
|
| 2002 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
| 2003 | + '.btn-outline-secondary.disabled' => array('c'), |
|
| 2004 | + '.btn-outline-secondary:disabled' => array('c'), |
|
| 2005 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2006 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2007 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 2008 | + '.badge-secondary' => array('b'), |
|
| 2009 | + '.alert-secondary' => array('b','o'), |
|
| 2010 | + '.btn-link.btn-secondary' => array('c'), |
|
| 2011 | + ); |
|
| 2012 | + |
|
| 2013 | + $important_selectors = array( |
|
| 2014 | + '.bg-secondary' => array('b','f'), |
|
| 2015 | + '.border-secondary' => array('o'), |
|
| 2016 | + '.text-secondary' => array('c'), |
|
| 2017 | + ); |
|
| 2018 | + |
|
| 2019 | + $color = array(); |
|
| 2020 | + $color_i = array(); |
|
| 2021 | + $background = array(); |
|
| 2022 | + $background_i = array(); |
|
| 2023 | + $border = array(); |
|
| 2024 | + $border_i = array(); |
|
| 2025 | + $fill = array(); |
|
| 2026 | + $fill_i = array(); |
|
| 2027 | + |
|
| 2028 | + $output = ''; |
|
| 2029 | + |
|
| 2030 | + // build rules into each type |
|
| 2031 | + foreach($selectors as $selector => $types){ |
|
| 2032 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2033 | + $types = array_combine($types,$types); |
|
| 2034 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 2035 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 2036 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 2037 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 2038 | + } |
|
| 2039 | + |
|
| 2040 | + // build rules into each type |
|
| 2041 | + foreach($important_selectors as $selector => $types){ |
|
| 2042 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2043 | + $types = array_combine($types,$types); |
|
| 2044 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2045 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2046 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2047 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2048 | + } |
|
| 2049 | + |
|
| 2050 | + // add any color rules |
|
| 2051 | + if(!empty($color)){ |
|
| 2052 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2053 | + } |
|
| 2054 | + if(!empty($color_i)){ |
|
| 2055 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2056 | + } |
|
| 2057 | + |
|
| 2058 | + // add any background color rules |
|
| 2059 | + if(!empty($background)){ |
|
| 2060 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2061 | + } |
|
| 2062 | + if(!empty($background_i)){ |
|
| 2063 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2064 | + } |
|
| 2065 | + |
|
| 2066 | + // add any border color rules |
|
| 2067 | + if(!empty($border)){ |
|
| 2068 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2069 | + } |
|
| 2070 | + if(!empty($border_i)){ |
|
| 2071 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2072 | + } |
|
| 2073 | + |
|
| 2074 | + // add any fill color rules |
|
| 2075 | + if(!empty($fill)){ |
|
| 2076 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2077 | + } |
|
| 2078 | + if(!empty($fill_i)){ |
|
| 2079 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2080 | + } |
|
| 2081 | + |
|
| 2082 | + |
|
| 2083 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 2084 | + |
|
| 2085 | + // darken |
|
| 2086 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2087 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2088 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2089 | + |
|
| 2090 | + // lighten |
|
| 2091 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2092 | + |
|
| 2093 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2094 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2095 | + |
|
| 2096 | + |
|
| 2097 | + // button states |
|
| 2098 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2099 | + $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2100 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2101 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2102 | + |
|
| 2103 | + |
|
| 2104 | + return $output; |
|
| 2105 | + } |
|
| 2106 | + |
|
| 2107 | + /** |
|
| 2108 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2109 | + * |
|
| 2110 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2111 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2112 | + * |
|
| 2113 | + * @return string |
|
| 2114 | + */ |
|
| 2115 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2116 | + $hexCode = ltrim($hexCode, '#'); |
|
| 2117 | + |
|
| 2118 | + if ( strpos( $hexCode, 'rgba(' ) !== false || strpos( $hexCode, 'rgb(' ) !== false ) { |
|
| 2119 | + return $hexCode; |
|
| 2120 | + } |
|
| 2121 | + |
|
| 2122 | + if (strlen($hexCode) == 3) { |
|
| 2123 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2124 | + } |
|
| 2125 | + |
|
| 2126 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 2127 | + |
|
| 2128 | + foreach ($hexCode as & $color) { |
|
| 2129 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2130 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 2131 | + |
|
| 2132 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2133 | + } |
|
| 2134 | + |
|
| 2135 | + return '#' . implode($hexCode); |
|
| 2136 | + } |
|
| 2137 | + |
|
| 2138 | + /** |
|
| 2139 | + * Check if we should display examples. |
|
| 2140 | + */ |
|
| 2141 | + public function maybe_show_examples(){ |
|
| 2142 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2143 | + echo "<head>"; |
|
| 2144 | + wp_head(); |
|
| 2145 | + echo "</head>"; |
|
| 2146 | + echo "<body>"; |
|
| 2147 | + echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2148 | + echo "</body>"; |
|
| 2149 | + exit; |
|
| 2150 | + } |
|
| 2151 | + } |
|
| 2152 | + |
|
| 2153 | + /** |
|
| 2154 | + * Get developer examples. |
|
| 2155 | + * |
|
| 2156 | + * @return string |
|
| 2157 | + */ |
|
| 2158 | + public function get_examples(){ |
|
| 2159 | + $output = ''; |
|
| 2160 | + |
|
| 2161 | + |
|
| 2162 | + // open form |
|
| 2163 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2164 | + |
|
| 2165 | + // input example |
|
| 2166 | + $output .= aui()->input(array( |
|
| 2167 | + 'type' => 'text', |
|
| 2168 | + 'id' => 'text-example', |
|
| 2169 | + 'name' => 'text-example', |
|
| 2170 | + 'placeholder' => 'text placeholder', |
|
| 2171 | + 'title' => 'Text input example', |
|
| 2172 | + 'value' => '', |
|
| 2173 | + 'required' => false, |
|
| 2174 | + 'help_text' => 'help text', |
|
| 2175 | + 'label' => 'Text input example label' |
|
| 2176 | + )); |
|
| 2177 | + |
|
| 2178 | + // input example |
|
| 2179 | + $output .= aui()->input(array( |
|
| 2180 | + 'type' => 'url', |
|
| 2181 | + 'id' => 'text-example2', |
|
| 2182 | + 'name' => 'text-example', |
|
| 2183 | + 'placeholder' => 'url placeholder', |
|
| 2184 | + 'title' => 'Text input example', |
|
| 2185 | + 'value' => '', |
|
| 2186 | + 'required' => false, |
|
| 2187 | + 'help_text' => 'help text', |
|
| 2188 | + 'label' => 'Text input example label' |
|
| 2189 | + )); |
|
| 2190 | + |
|
| 2191 | + // checkbox example |
|
| 2192 | + $output .= aui()->input(array( |
|
| 2193 | + 'type' => 'checkbox', |
|
| 2194 | + 'id' => 'checkbox-example', |
|
| 2195 | + 'name' => 'checkbox-example', |
|
| 2196 | + 'placeholder' => 'checkbox-example', |
|
| 2197 | + 'title' => 'Checkbox example', |
|
| 2198 | + 'value' => '1', |
|
| 2199 | + 'checked' => true, |
|
| 2200 | + 'required' => false, |
|
| 2201 | + 'help_text' => 'help text', |
|
| 2202 | + 'label' => 'Checkbox checked' |
|
| 2203 | + )); |
|
| 2204 | + |
|
| 2205 | + // checkbox example |
|
| 2206 | + $output .= aui()->input(array( |
|
| 2207 | + 'type' => 'checkbox', |
|
| 2208 | + 'id' => 'checkbox-example2', |
|
| 2209 | + 'name' => 'checkbox-example2', |
|
| 2210 | + 'placeholder' => 'checkbox-example', |
|
| 2211 | + 'title' => 'Checkbox example', |
|
| 2212 | + 'value' => '1', |
|
| 2213 | + 'checked' => false, |
|
| 2214 | + 'required' => false, |
|
| 2215 | + 'help_text' => 'help text', |
|
| 2216 | + 'label' => 'Checkbox un-checked' |
|
| 2217 | + )); |
|
| 2218 | + |
|
| 2219 | + // switch example |
|
| 2220 | + $output .= aui()->input(array( |
|
| 2221 | + 'type' => 'checkbox', |
|
| 2222 | + 'id' => 'switch-example', |
|
| 2223 | + 'name' => 'switch-example', |
|
| 2224 | + 'placeholder' => 'checkbox-example', |
|
| 2225 | + 'title' => 'Switch example', |
|
| 2226 | + 'value' => '1', |
|
| 2227 | + 'checked' => true, |
|
| 2228 | + 'switch' => true, |
|
| 2229 | + 'required' => false, |
|
| 2230 | + 'help_text' => 'help text', |
|
| 2231 | + 'label' => 'Switch on' |
|
| 2232 | + )); |
|
| 2233 | + |
|
| 2234 | + // switch example |
|
| 2235 | + $output .= aui()->input(array( |
|
| 2236 | + 'type' => 'checkbox', |
|
| 2237 | + 'id' => 'switch-example2', |
|
| 2238 | + 'name' => 'switch-example2', |
|
| 2239 | + 'placeholder' => 'checkbox-example', |
|
| 2240 | + 'title' => 'Switch example', |
|
| 2241 | + 'value' => '1', |
|
| 2242 | + 'checked' => false, |
|
| 2243 | + 'switch' => true, |
|
| 2244 | + 'required' => false, |
|
| 2245 | + 'help_text' => 'help text', |
|
| 2246 | + 'label' => 'Switch off' |
|
| 2247 | + )); |
|
| 2248 | + |
|
| 2249 | + // close form |
|
| 2250 | + $output .= "</form>"; |
|
| 2251 | + |
|
| 2252 | + return $output; |
|
| 2253 | + } |
|
| 2254 | + |
|
| 2255 | + /** |
|
| 2256 | + * Calendar params. |
|
| 2257 | + * |
|
| 2258 | + * @since 0.1.44 |
|
| 2259 | + * |
|
| 2260 | + * @return array Calendar params. |
|
| 2261 | + */ |
|
| 2262 | + public static function calendar_params() { |
|
| 2263 | + $params = array( |
|
| 2264 | + 'month_long_1' => __( 'January', 'ayecode-connect' ), |
|
| 2265 | + 'month_long_2' => __( 'February', 'ayecode-connect' ), |
|
| 2266 | + 'month_long_3' => __( 'March', 'ayecode-connect' ), |
|
| 2267 | + 'month_long_4' => __( 'April', 'ayecode-connect' ), |
|
| 2268 | + 'month_long_5' => __( 'May', 'ayecode-connect' ), |
|
| 2269 | + 'month_long_6' => __( 'June', 'ayecode-connect' ), |
|
| 2270 | + 'month_long_7' => __( 'July', 'ayecode-connect' ), |
|
| 2271 | + 'month_long_8' => __( 'August', 'ayecode-connect' ), |
|
| 2272 | + 'month_long_9' => __( 'September', 'ayecode-connect' ), |
|
| 2273 | + 'month_long_10' => __( 'October', 'ayecode-connect' ), |
|
| 2274 | + 'month_long_11' => __( 'November', 'ayecode-connect' ), |
|
| 2275 | + 'month_long_12' => __( 'December', 'ayecode-connect' ), |
|
| 2276 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ), |
|
| 2277 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ), |
|
| 2278 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ), |
|
| 2279 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ), |
|
| 2280 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ), |
|
| 2281 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ), |
|
| 2282 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ), |
|
| 2283 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ), |
|
| 2284 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ), |
|
| 2285 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ), |
|
| 2286 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ), |
|
| 2287 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ), |
|
| 2288 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ), |
|
| 2289 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ), |
|
| 2290 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ), |
|
| 2291 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ), |
|
| 2292 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ), |
|
| 2293 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ), |
|
| 2294 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ), |
|
| 2295 | + 'day_s2_1' => __( 'Su', 'ayecode-connect' ), |
|
| 2296 | + 'day_s2_2' => __( 'Mo', 'ayecode-connect' ), |
|
| 2297 | + 'day_s2_3' => __( 'Tu', 'ayecode-connect' ), |
|
| 2298 | + 'day_s2_4' => __( 'We', 'ayecode-connect' ), |
|
| 2299 | + 'day_s2_5' => __( 'Th', 'ayecode-connect' ), |
|
| 2300 | + 'day_s2_6' => __( 'Fr', 'ayecode-connect' ), |
|
| 2301 | + 'day_s2_7' => __( 'Sa', 'ayecode-connect' ), |
|
| 2302 | + 'day_s3_1' => __( 'Sun', 'ayecode-connect' ), |
|
| 2303 | + 'day_s3_2' => __( 'Mon', 'ayecode-connect' ), |
|
| 2304 | + 'day_s3_3' => __( 'Tue', 'ayecode-connect' ), |
|
| 2305 | + 'day_s3_4' => __( 'Wed', 'ayecode-connect' ), |
|
| 2306 | + 'day_s3_5' => __( 'Thu', 'ayecode-connect' ), |
|
| 2307 | + 'day_s3_6' => __( 'Fri', 'ayecode-connect' ), |
|
| 2308 | + 'day_s3_7' => __( 'Sat', 'ayecode-connect' ), |
|
| 2309 | + 'day_s5_1' => __( 'Sunday', 'ayecode-connect' ), |
|
| 2310 | + 'day_s5_2' => __( 'Monday', 'ayecode-connect' ), |
|
| 2311 | + 'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ), |
|
| 2312 | + 'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ), |
|
| 2313 | + 'day_s5_5' => __( 'Thursday', 'ayecode-connect' ), |
|
| 2314 | + 'day_s5_6' => __( 'Friday', 'ayecode-connect' ), |
|
| 2315 | + 'day_s5_7' => __( 'Saturday', 'ayecode-connect' ), |
|
| 2316 | + 'am_lower' => __( 'am', 'ayecode-connect' ), |
|
| 2317 | + 'pm_lower' => __( 'pm', 'ayecode-connect' ), |
|
| 2318 | + 'am_upper' => __( 'AM', 'ayecode-connect' ), |
|
| 2319 | + 'pm_upper' => __( 'PM', 'ayecode-connect' ), |
|
| 2320 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2321 | + 'time_24hr' => false, |
|
| 2322 | + 'year' => __( 'Year', 'ayecode-connect' ), |
|
| 2323 | + 'hour' => __( 'Hour', 'ayecode-connect' ), |
|
| 2324 | + 'minute' => __( 'Minute', 'ayecode-connect' ), |
|
| 2325 | + 'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ), |
|
| 2326 | + 'rangeSeparator' => __( ' to ', 'ayecode-connect' ), |
|
| 2327 | + 'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ), |
|
| 2328 | + 'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' ) |
|
| 2329 | + ); |
|
| 2330 | + |
|
| 2331 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2332 | + } |
|
| 2333 | + |
|
| 2334 | + /** |
|
| 2335 | + * Flatpickr calendar localize. |
|
| 2336 | + * |
|
| 2337 | + * @since 0.1.44 |
|
| 2338 | + * |
|
| 2339 | + * @return string Calendar locale. |
|
| 2340 | + */ |
|
| 2341 | + public static function flatpickr_locale() { |
|
| 2342 | + $params = self::calendar_params(); |
|
| 2343 | + |
|
| 2344 | + if ( is_string( $params ) ) { |
|
| 2345 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2346 | + } else { |
|
| 2347 | + foreach ( (array) $params as $key => $value ) { |
|
| 2348 | + if ( ! is_scalar( $value ) ) { |
|
| 2349 | + continue; |
|
| 2350 | + } |
|
| 2351 | + |
|
| 2352 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2353 | + } |
|
| 2354 | + } |
|
| 2355 | + |
|
| 2356 | + $day_s3 = array(); |
|
| 2357 | + $day_s5 = array(); |
|
| 2358 | + |
|
| 2359 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2360 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2361 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2362 | + } |
|
| 2363 | + |
|
| 2364 | + $month_s = array(); |
|
| 2365 | + $month_long = array(); |
|
| 2366 | + |
|
| 2367 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2368 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2369 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 2370 | + } |
|
| 2371 | + |
|
| 2372 | + ob_start(); |
|
| 2373 | + if ( 0 ) { ?><script><?php } ?> |
|
| 2374 | 2374 | { |
| 2375 | 2375 | weekdays: { |
| 2376 | 2376 | shorthand: ['<?php echo implode( "','", $day_s3 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
@@ -2409,189 +2409,189 @@ discard block |
||
| 2409 | 2409 | } |
| 2410 | 2410 | <?php if ( 0 ) { ?></script><?php } ?> |
| 2411 | 2411 | <?php |
| 2412 | - $locale = ob_get_clean(); |
|
| 2413 | - |
|
| 2414 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2415 | - } |
|
| 2416 | - |
|
| 2417 | - /** |
|
| 2418 | - * Select2 JS params. |
|
| 2419 | - * |
|
| 2420 | - * @since 0.1.44 |
|
| 2421 | - * |
|
| 2422 | - * @return array Select2 JS params. |
|
| 2423 | - */ |
|
| 2424 | - public static function select2_params() { |
|
| 2425 | - $params = array( |
|
| 2426 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'ayecode-connect' ), |
|
| 2427 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ), |
|
| 2428 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ), |
|
| 2429 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2430 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2431 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ), |
|
| 2432 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2433 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ), |
|
| 2434 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ), |
|
| 2435 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'ayecode-connect' ), |
|
| 2436 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'ayecode-connect' ) |
|
| 2437 | - ); |
|
| 2438 | - |
|
| 2439 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2440 | - } |
|
| 2441 | - |
|
| 2442 | - /** |
|
| 2443 | - * Select2 JS localize. |
|
| 2444 | - * |
|
| 2445 | - * @since 0.1.44 |
|
| 2446 | - * |
|
| 2447 | - * @return string Select2 JS locale. |
|
| 2448 | - */ |
|
| 2449 | - public static function select2_locale() { |
|
| 2450 | - $params = self::select2_params(); |
|
| 2451 | - |
|
| 2452 | - foreach ( (array) $params as $key => $value ) { |
|
| 2453 | - if ( ! is_scalar( $value ) ) { |
|
| 2454 | - continue; |
|
| 2455 | - } |
|
| 2412 | + $locale = ob_get_clean(); |
|
| 2456 | 2413 | |
| 2457 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2458 | - } |
|
| 2459 | - |
|
| 2460 | - $locale = json_encode( $params ); |
|
| 2461 | - |
|
| 2462 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2463 | - } |
|
| 2464 | - |
|
| 2465 | - /** |
|
| 2466 | - * Time ago JS localize. |
|
| 2467 | - * |
|
| 2468 | - * @since 0.1.47 |
|
| 2469 | - * |
|
| 2470 | - * @return string Time ago JS locale. |
|
| 2471 | - */ |
|
| 2472 | - public static function timeago_locale() { |
|
| 2473 | - $params = array( |
|
| 2474 | - 'prefix_ago' => '', |
|
| 2475 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ), |
|
| 2476 | - 'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ', |
|
| 2477 | - 'suffix_after' => '', |
|
| 2478 | - 'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ), |
|
| 2479 | - 'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ), |
|
| 2480 | - 'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ), |
|
| 2481 | - 'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ), |
|
| 2482 | - 'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ), |
|
| 2483 | - 'day' => _x( 'a day', 'time ago', 'ayecode-connect' ), |
|
| 2484 | - 'days' => _x( '%d days', 'time ago', 'ayecode-connect' ), |
|
| 2485 | - 'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ), |
|
| 2486 | - 'months' => _x( '%d months', 'time ago', 'ayecode-connect' ), |
|
| 2487 | - 'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ), |
|
| 2488 | - 'years' => _x( '%d years', 'time ago', 'ayecode-connect' ), |
|
| 2489 | - ); |
|
| 2490 | - |
|
| 2491 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2492 | - |
|
| 2493 | - foreach ( (array) $params as $key => $value ) { |
|
| 2494 | - if ( ! is_scalar( $value ) ) { |
|
| 2495 | - continue; |
|
| 2496 | - } |
|
| 2414 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2415 | + } |
|
| 2416 | + |
|
| 2417 | + /** |
|
| 2418 | + * Select2 JS params. |
|
| 2419 | + * |
|
| 2420 | + * @since 0.1.44 |
|
| 2421 | + * |
|
| 2422 | + * @return array Select2 JS params. |
|
| 2423 | + */ |
|
| 2424 | + public static function select2_params() { |
|
| 2425 | + $params = array( |
|
| 2426 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'ayecode-connect' ), |
|
| 2427 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ), |
|
| 2428 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ), |
|
| 2429 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2430 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2431 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ), |
|
| 2432 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ), |
|
| 2433 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ), |
|
| 2434 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ), |
|
| 2435 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'ayecode-connect' ), |
|
| 2436 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'ayecode-connect' ) |
|
| 2437 | + ); |
|
| 2438 | + |
|
| 2439 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2440 | + } |
|
| 2441 | + |
|
| 2442 | + /** |
|
| 2443 | + * Select2 JS localize. |
|
| 2444 | + * |
|
| 2445 | + * @since 0.1.44 |
|
| 2446 | + * |
|
| 2447 | + * @return string Select2 JS locale. |
|
| 2448 | + */ |
|
| 2449 | + public static function select2_locale() { |
|
| 2450 | + $params = self::select2_params(); |
|
| 2451 | + |
|
| 2452 | + foreach ( (array) $params as $key => $value ) { |
|
| 2453 | + if ( ! is_scalar( $value ) ) { |
|
| 2454 | + continue; |
|
| 2455 | + } |
|
| 2456 | + |
|
| 2457 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2458 | + } |
|
| 2459 | + |
|
| 2460 | + $locale = json_encode( $params ); |
|
| 2461 | + |
|
| 2462 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2463 | + } |
|
| 2464 | + |
|
| 2465 | + /** |
|
| 2466 | + * Time ago JS localize. |
|
| 2467 | + * |
|
| 2468 | + * @since 0.1.47 |
|
| 2469 | + * |
|
| 2470 | + * @return string Time ago JS locale. |
|
| 2471 | + */ |
|
| 2472 | + public static function timeago_locale() { |
|
| 2473 | + $params = array( |
|
| 2474 | + 'prefix_ago' => '', |
|
| 2475 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ), |
|
| 2476 | + 'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ', |
|
| 2477 | + 'suffix_after' => '', |
|
| 2478 | + 'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ), |
|
| 2479 | + 'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ), |
|
| 2480 | + 'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ), |
|
| 2481 | + 'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ), |
|
| 2482 | + 'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ), |
|
| 2483 | + 'day' => _x( 'a day', 'time ago', 'ayecode-connect' ), |
|
| 2484 | + 'days' => _x( '%d days', 'time ago', 'ayecode-connect' ), |
|
| 2485 | + 'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ), |
|
| 2486 | + 'months' => _x( '%d months', 'time ago', 'ayecode-connect' ), |
|
| 2487 | + 'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ), |
|
| 2488 | + 'years' => _x( '%d years', 'time ago', 'ayecode-connect' ), |
|
| 2489 | + ); |
|
| 2490 | + |
|
| 2491 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2492 | + |
|
| 2493 | + foreach ( (array) $params as $key => $value ) { |
|
| 2494 | + if ( ! is_scalar( $value ) ) { |
|
| 2495 | + continue; |
|
| 2496 | + } |
|
| 2497 | + |
|
| 2498 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2499 | + } |
|
| 2497 | 2500 | |
| 2498 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2499 | - } |
|
| 2500 | - |
|
| 2501 | - $locale = json_encode( $params ); |
|
| 2502 | - |
|
| 2503 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2504 | - } |
|
| 2505 | - |
|
| 2506 | - /** |
|
| 2507 | - * JavaScript Minifier |
|
| 2508 | - * |
|
| 2509 | - * @param $input |
|
| 2510 | - * |
|
| 2511 | - * @return mixed |
|
| 2512 | - */ |
|
| 2513 | - public static function minify_js($input) { |
|
| 2514 | - if(trim($input) === "") return $input; |
|
| 2515 | - return preg_replace( |
|
| 2516 | - array( |
|
| 2517 | - // Remove comment(s) |
|
| 2518 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2519 | - // Remove white-space(s) outside the string and regex |
|
| 2520 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2521 | - // Remove the last semicolon |
|
| 2522 | - '#;+\}#', |
|
| 2523 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2524 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2525 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2526 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2527 | - ), |
|
| 2528 | - array( |
|
| 2529 | - '$1', |
|
| 2530 | - '$1$2', |
|
| 2531 | - '}', |
|
| 2532 | - '$1$3', |
|
| 2533 | - '$1.$3' |
|
| 2534 | - ), |
|
| 2535 | - $input); |
|
| 2536 | - } |
|
| 2537 | - |
|
| 2538 | - /** |
|
| 2539 | - * Minify CSS |
|
| 2540 | - * |
|
| 2541 | - * @param $input |
|
| 2542 | - * |
|
| 2543 | - * @return mixed |
|
| 2544 | - */ |
|
| 2545 | - public static function minify_css($input) { |
|
| 2546 | - if(trim($input) === "") return $input; |
|
| 2547 | - return preg_replace( |
|
| 2548 | - array( |
|
| 2549 | - // Remove comment(s) |
|
| 2550 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2551 | - // Remove unused white-space(s) |
|
| 2552 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2553 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2554 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2555 | - // Replace `:0 0 0 0` with `:0` |
|
| 2556 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2557 | - // Replace `background-position:0` with `background-position:0 0` |
|
| 2558 | - '#(background-position):0(?=[;\}])#si', |
|
| 2559 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2560 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2561 | - // Minify string value |
|
| 2562 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2563 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2564 | - // Minify HEX color code |
|
| 2565 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2566 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2567 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2568 | - // Remove empty selector(s) |
|
| 2569 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2570 | - ), |
|
| 2571 | - array( |
|
| 2572 | - '$1', |
|
| 2573 | - '$1$2$3$4$5$6$7', |
|
| 2574 | - '$1', |
|
| 2575 | - ':0', |
|
| 2576 | - '$1:0 0', |
|
| 2577 | - '.$1', |
|
| 2578 | - '$1$3', |
|
| 2579 | - '$1$2$4$5', |
|
| 2580 | - '$1$2$3', |
|
| 2581 | - '$1:0', |
|
| 2582 | - '$1$2' |
|
| 2583 | - ), |
|
| 2584 | - $input); |
|
| 2585 | - } |
|
| 2586 | - |
|
| 2587 | - /** |
|
| 2588 | - * Get the conditional fields JavaScript. |
|
| 2589 | - * |
|
| 2590 | - * @return mixed |
|
| 2591 | - */ |
|
| 2592 | - public function conditional_fields_js() { |
|
| 2593 | - ob_start(); |
|
| 2594 | - ?> |
|
| 2501 | + $locale = json_encode( $params ); |
|
| 2502 | + |
|
| 2503 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2504 | + } |
|
| 2505 | + |
|
| 2506 | + /** |
|
| 2507 | + * JavaScript Minifier |
|
| 2508 | + * |
|
| 2509 | + * @param $input |
|
| 2510 | + * |
|
| 2511 | + * @return mixed |
|
| 2512 | + */ |
|
| 2513 | + public static function minify_js($input) { |
|
| 2514 | + if(trim($input) === "") return $input; |
|
| 2515 | + return preg_replace( |
|
| 2516 | + array( |
|
| 2517 | + // Remove comment(s) |
|
| 2518 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2519 | + // Remove white-space(s) outside the string and regex |
|
| 2520 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2521 | + // Remove the last semicolon |
|
| 2522 | + '#;+\}#', |
|
| 2523 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2524 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2525 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2526 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2527 | + ), |
|
| 2528 | + array( |
|
| 2529 | + '$1', |
|
| 2530 | + '$1$2', |
|
| 2531 | + '}', |
|
| 2532 | + '$1$3', |
|
| 2533 | + '$1.$3' |
|
| 2534 | + ), |
|
| 2535 | + $input); |
|
| 2536 | + } |
|
| 2537 | + |
|
| 2538 | + /** |
|
| 2539 | + * Minify CSS |
|
| 2540 | + * |
|
| 2541 | + * @param $input |
|
| 2542 | + * |
|
| 2543 | + * @return mixed |
|
| 2544 | + */ |
|
| 2545 | + public static function minify_css($input) { |
|
| 2546 | + if(trim($input) === "") return $input; |
|
| 2547 | + return preg_replace( |
|
| 2548 | + array( |
|
| 2549 | + // Remove comment(s) |
|
| 2550 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2551 | + // Remove unused white-space(s) |
|
| 2552 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2553 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2554 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2555 | + // Replace `:0 0 0 0` with `:0` |
|
| 2556 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2557 | + // Replace `background-position:0` with `background-position:0 0` |
|
| 2558 | + '#(background-position):0(?=[;\}])#si', |
|
| 2559 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2560 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2561 | + // Minify string value |
|
| 2562 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2563 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2564 | + // Minify HEX color code |
|
| 2565 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2566 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2567 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2568 | + // Remove empty selector(s) |
|
| 2569 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2570 | + ), |
|
| 2571 | + array( |
|
| 2572 | + '$1', |
|
| 2573 | + '$1$2$3$4$5$6$7', |
|
| 2574 | + '$1', |
|
| 2575 | + ':0', |
|
| 2576 | + '$1:0 0', |
|
| 2577 | + '.$1', |
|
| 2578 | + '$1$3', |
|
| 2579 | + '$1$2$4$5', |
|
| 2580 | + '$1$2$3', |
|
| 2581 | + '$1:0', |
|
| 2582 | + '$1$2' |
|
| 2583 | + ), |
|
| 2584 | + $input); |
|
| 2585 | + } |
|
| 2586 | + |
|
| 2587 | + /** |
|
| 2588 | + * Get the conditional fields JavaScript. |
|
| 2589 | + * |
|
| 2590 | + * @return mixed |
|
| 2591 | + */ |
|
| 2592 | + public function conditional_fields_js() { |
|
| 2593 | + ob_start(); |
|
| 2594 | + ?> |
|
| 2595 | 2595 | <script> |
| 2596 | 2596 | /** |
| 2597 | 2597 | * Conditional Fields |
@@ -3112,14 +3112,14 @@ discard block |
||
| 3112 | 3112 | <?php do_action( 'aui_conditional_fields_js', $this ); ?> |
| 3113 | 3113 | </script> |
| 3114 | 3114 | <?php |
| 3115 | - $output = ob_get_clean(); |
|
| 3115 | + $output = ob_get_clean(); |
|
| 3116 | 3116 | |
| 3117 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3118 | - } |
|
| 3119 | - } |
|
| 3117 | + return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3118 | + } |
|
| 3119 | + } |
|
| 3120 | 3120 | |
| 3121 | - /** |
|
| 3122 | - * Run the class if found. |
|
| 3123 | - */ |
|
| 3124 | - AyeCode_UI_Settings::instance(); |
|
| 3121 | + /** |
|
| 3122 | + * Run the class if found. |
|
| 3123 | + */ |
|
| 3124 | + AyeCode_UI_Settings::instance(); |
|
| 3125 | 3125 | } |
| 3126 | 3126 | \ 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.2.15"; |
|
| 19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | - $ayecode_ui_version = $this_version ; |
|
| 21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 22 | - } |
|
| 17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | + $this_version = "0.2.15"; |
|
| 19 | + if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | + $ayecode_ui_version = $this_version ; |
|
| 21 | + $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 22 | + } |
|
| 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 | } |
@@ -3009,7 +3009,7 @@ discard block |
||
| 3009 | 3009 | $close_tab = false; |
| 3010 | 3010 | $close_tabs = false; |
| 3011 | 3011 | |
| 3012 | - if ( ! empty( $block_group_tabs ) ) { |
|
| 3012 | + if ( ! empty( $block_group_tabs ) ) { |
|
| 3013 | 3013 | foreach ( $block_group_tabs as $tab_name => $tab_args ) { |
| 3014 | 3014 | if ( in_array( $key, $tab_args['groups'] ) ) { |
| 3015 | 3015 | $open_tab_groups[] = $key; |
@@ -3098,7 +3098,7 @@ discard block |
||
| 3098 | 3098 | if ( ! empty( $this->options['block-output'] ) ) { |
| 3099 | 3099 | $this->block_element( $this->options['block-output'] ); |
| 3100 | 3100 | }elseif(!empty($this->options['block-edit-return'])){ |
| 3101 | - echo $this->options['block-edit-return']; |
|
| 3101 | + echo $this->options['block-edit-return']; |
|
| 3102 | 3102 | }else{ |
| 3103 | 3103 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 3104 | 3104 | $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div'; |
@@ -3133,12 +3133,12 @@ discard block |
||
| 3133 | 3133 | if(! empty( $this->arguments )){ |
| 3134 | 3134 | |
| 3135 | 3135 | foreach($this->arguments as $key => $args){ |
| 3136 | - // if($args['type']=='tabs'){continue;} |
|
| 3136 | + // if($args['type']=='tabs'){continue;} |
|
| 3137 | 3137 | |
| 3138 | - // don't add metadata arguments |
|
| 3139 | - if (substr($key, 0, 9 ) === 'metadata_') { |
|
| 3140 | - continue; |
|
| 3141 | - } |
|
| 3138 | + // don't add metadata arguments |
|
| 3139 | + if (substr($key, 0, 9 ) === 'metadata_') { |
|
| 3140 | + continue; |
|
| 3141 | + } |
|
| 3142 | 3142 | ?> |
| 3143 | 3143 | if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
| 3144 | 3144 | if ('<?php echo esc_attr( $key );?>' == 'html') { |
@@ -3200,7 +3200,7 @@ discard block |
||
| 3200 | 3200 | // $this->block_element( $this->options['block-output'], true ); |
| 3201 | 3201 | // echo ";"; |
| 3202 | 3202 | |
| 3203 | - ?> |
|
| 3203 | + ?> |
|
| 3204 | 3204 | return el( |
| 3205 | 3205 | '', |
| 3206 | 3206 | {}, |
@@ -3211,7 +3211,7 @@ discard block |
||
| 3211 | 3211 | <?php |
| 3212 | 3212 | |
| 3213 | 3213 | }elseif(!empty($this->options['block-save-return'])){ |
| 3214 | - echo 'return ' . $this->options['block-save-return']; |
|
| 3214 | + echo 'return ' . $this->options['block-save-return']; |
|
| 3215 | 3215 | }elseif(!empty($this->options['nested-block'])){ |
| 3216 | 3216 | ?> |
| 3217 | 3217 | return el( |
@@ -3651,8 +3651,8 @@ discard block |
||
| 3651 | 3651 | {$key}_id: media.id |
| 3652 | 3652 | }); |
| 3653 | 3653 | },"; |
| 3654 | - $extra .= "type: 'image',"; |
|
| 3655 | - $extra .= "render: function (obj) { |
|
| 3654 | + $extra .= "type: 'image',"; |
|
| 3655 | + $extra .= "render: function (obj) { |
|
| 3656 | 3656 | return el( 'div',{}, |
| 3657 | 3657 | ( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, { |
| 3658 | 3658 | className: 'components-button components-circular-option-picker__clear is-primary is-smallx', |
@@ -3977,7 +3977,7 @@ discard block |
||
| 3977 | 3977 | echo "\n el( InnerBlocks, {"; |
| 3978 | 3978 | }elseif($new_args['element']=='innerBlocksProps'){ |
| 3979 | 3979 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3980 | - // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3980 | + // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3981 | 3981 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3982 | 3982 | echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3983 | 3983 | echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; |
@@ -3987,7 +3987,7 @@ discard block |
||
| 3987 | 3987 | echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; |
| 3988 | 3988 | // echo '###'; |
| 3989 | 3989 | |
| 3990 | - // echo '###'; |
|
| 3990 | + // echo '###'; |
|
| 3991 | 3991 | }elseif($new_args['element']=='BlocksProps'){ |
| 3992 | 3992 | |
| 3993 | 3993 | if ( isset($new_args['if_inner_element']) ) { |
@@ -4001,7 +4001,7 @@ discard block |
||
| 4001 | 4001 | echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
| 4002 | 4002 | |
| 4003 | 4003 | |
| 4004 | - // echo "} ),"; |
|
| 4004 | + // echo "} ),"; |
|
| 4005 | 4005 | |
| 4006 | 4006 | }else{ |
| 4007 | 4007 | echo "\n el( '" . $new_args['element'] . "', {"; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if(!empty($this->options['nested-block'])){ |
| 61 | 61 | if(empty($this->options['output_types'])){ |
| 62 | 62 | $this->options['output_types'] = array('shortcode','block'); |
| 63 | - }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { |
|
| 63 | + } elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { |
|
| 64 | 64 | unset($this->options['output_types'][$key]); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | <?php |
| 716 | 716 | if(! empty( $insert_shortcode_function )){ |
| 717 | 717 | echo $insert_shortcode_function; |
| 718 | - }else{ |
|
| 718 | + } else{ |
|
| 719 | 719 | |
| 720 | 720 | /** |
| 721 | 721 | * Function for super duper insert shortcode. |
@@ -2228,7 +2228,7 @@ discard block |
||
| 2228 | 2228 | $p_pl = 'ps-'; |
| 2229 | 2229 | $p_pr = 'pe-'; |
| 2230 | 2230 | <?php |
| 2231 | - }else{ |
|
| 2231 | + } else{ |
|
| 2232 | 2232 | ?> |
| 2233 | 2233 | $aui_bs5 = false; |
| 2234 | 2234 | $p_ml = 'ml-'; |
@@ -2450,7 +2450,7 @@ discard block |
||
| 2450 | 2450 | var InnerBlocks = blockEditor.InnerBlocks; |
| 2451 | 2451 | |
| 2452 | 2452 | var term_query_type = ''; |
| 2453 | - var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>; |
|
| 2453 | + var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";} else{echo "[]";} ?>; |
|
| 2454 | 2454 | const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
| 2455 | 2455 | const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
| 2456 | 2456 | const MediaUpload = wp.blockEditor.MediaUpload; |
@@ -2507,9 +2507,9 @@ discard block |
||
| 2507 | 2507 | $example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : ''; |
| 2508 | 2508 | if( isset( $this->options['example'] ) && $this->options['example'] === false ){ |
| 2509 | 2509 | // no preview if set to false |
| 2510 | - }elseif( !empty( $example_args ) ){ |
|
| 2510 | + } elseif( !empty( $example_args ) ){ |
|
| 2511 | 2511 | echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},"; |
| 2512 | - }elseif( !empty( $this->options['example'] ) ){ |
|
| 2512 | + } elseif( !empty( $this->options['example'] ) ){ |
|
| 2513 | 2513 | unset($this->options['example']['viewportWidth']); |
| 2514 | 2514 | unset($this->options['example']['innerBlocks']); |
| 2515 | 2515 | $example_atts = $this->array_to_attributes( $this->options['example'] ); |
@@ -2526,7 +2526,7 @@ discard block |
||
| 2526 | 2526 | if(!empty($example_parts)){ |
| 2527 | 2527 | echo "example : {".implode(',', $example_parts)."},"; |
| 2528 | 2528 | } |
| 2529 | - }else{ |
|
| 2529 | + } else{ |
|
| 2530 | 2530 | echo 'example : {viewportWidth: 500},'; |
| 2531 | 2531 | } |
| 2532 | 2532 | |
@@ -2596,8 +2596,7 @@ discard block |
||
| 2596 | 2596 | |
| 2597 | 2597 | if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
| 2598 | 2598 | continue; |
| 2599 | - } |
|
| 2600 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2599 | + } elseif ( $args['type'] == 'checkbox' ) { |
|
| 2601 | 2600 | $type = 'boolean'; |
| 2602 | 2601 | $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
| 2603 | 2602 | } elseif ( $args['type'] == 'number' ) { |
@@ -2725,7 +2724,7 @@ discard block |
||
| 2725 | 2724 | <?php |
| 2726 | 2725 | if(!empty($this->options['block-edit-raw'])) { |
| 2727 | 2726 | echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues |
| 2728 | - }else{ |
|
| 2727 | + } else{ |
|
| 2729 | 2728 | ?> |
| 2730 | 2729 | |
| 2731 | 2730 | function hasSelectedInnerBlock(props) { |
@@ -2860,7 +2859,7 @@ discard block |
||
| 2860 | 2859 | $current_screen = function_exists('get_current_screen') ? get_current_screen() : ''; |
| 2861 | 2860 | if(!empty($current_screen->base) && $current_screen->base==='widgets'){ |
| 2862 | 2861 | echo 'const { deviceType } = "";'; |
| 2863 | -}else{ |
|
| 2862 | +} else{ |
|
| 2864 | 2863 | ?> |
| 2865 | 2864 | /** Get device type const. */ |
| 2866 | 2865 | const { deviceType } = wp.data.useSelect != 'undefined' ? wp.data.useSelect(select => { |
@@ -2894,7 +2893,7 @@ discard block |
||
| 2894 | 2893 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
| 2895 | 2894 | 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
| 2896 | 2895 | echo $post->ID; |
| 2897 | - }else{echo '0';}?>, |
|
| 2896 | + } else{echo '0';}?>, |
|
| 2898 | 2897 | '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
| 2899 | 2898 | }; |
| 2900 | 2899 | |
@@ -2914,7 +2913,7 @@ discard block |
||
| 2914 | 2913 | is_fetching = false; |
| 2915 | 2914 | prev_attributes[props.clientId] = props.attributes; |
| 2916 | 2915 | <?php |
| 2917 | - }else{ |
|
| 2916 | + } else{ |
|
| 2918 | 2917 | ?> |
| 2919 | 2918 | props.setAttributes({content: env}); |
| 2920 | 2919 | is_fetching = false; |
@@ -3071,7 +3070,7 @@ discard block |
||
| 3071 | 3070 | // |
| 3072 | 3071 | |
| 3073 | 3072 | } |
| 3074 | - }else { |
|
| 3073 | + } else { |
|
| 3075 | 3074 | ?> |
| 3076 | 3075 | el(wp.components.PanelBody, { |
| 3077 | 3076 | title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>', |
@@ -3097,9 +3096,9 @@ discard block |
||
| 3097 | 3096 | // If the user sets block-output array then build it |
| 3098 | 3097 | if ( ! empty( $this->options['block-output'] ) ) { |
| 3099 | 3098 | $this->block_element( $this->options['block-output'] ); |
| 3100 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
| 3099 | + } elseif(!empty($this->options['block-edit-return'])){ |
|
| 3101 | 3100 | echo $this->options['block-edit-return']; |
| 3102 | - }else{ |
|
| 3101 | + } else{ |
|
| 3103 | 3102 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 3104 | 3103 | $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div'; |
| 3105 | 3104 | ?> |
@@ -3210,9 +3209,9 @@ discard block |
||
| 3210 | 3209 | ); |
| 3211 | 3210 | <?php |
| 3212 | 3211 | |
| 3213 | - }elseif(!empty($this->options['block-save-return'])){ |
|
| 3212 | + } elseif(!empty($this->options['block-save-return'])){ |
|
| 3214 | 3213 | echo 'return ' . $this->options['block-save-return']; |
| 3215 | - }elseif(!empty($this->options['nested-block'])){ |
|
| 3214 | + } elseif(!empty($this->options['nested-block'])){ |
|
| 3216 | 3215 | ?> |
| 3217 | 3216 | return el( |
| 3218 | 3217 | '', |
@@ -3222,13 +3221,13 @@ discard block |
||
| 3222 | 3221 | el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
| 3223 | 3222 | ); |
| 3224 | 3223 | <?php |
| 3225 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 3224 | + } elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 3226 | 3225 | echo "return ". $this->options['block-edit-return'].";"; |
| 3227 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 3226 | + } elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 3228 | 3227 | ?> |
| 3229 | 3228 | return content; |
| 3230 | 3229 | <?php |
| 3231 | - }else{ |
|
| 3230 | + } else{ |
|
| 3232 | 3231 | ?> |
| 3233 | 3232 | var block_wrap = 'div'; |
| 3234 | 3233 | if (attr.hasOwnProperty("block_wrap")) { |
@@ -3279,9 +3278,9 @@ discard block |
||
| 3279 | 3278 | $device_type_icon = ''; |
| 3280 | 3279 | if($device_type=='Desktop'){ |
| 3281 | 3280 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3282 | - }elseif($device_type=='Tablet'){ |
|
| 3281 | + } elseif($device_type=='Tablet'){ |
|
| 3283 | 3282 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3284 | - }elseif($device_type=='Mobile'){ |
|
| 3283 | + } elseif($device_type=='Mobile'){ |
|
| 3285 | 3284 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3286 | 3285 | } |
| 3287 | 3286 | echo $element_require; |
@@ -3326,7 +3325,7 @@ discard block |
||
| 3326 | 3325 | |
| 3327 | 3326 | <?php |
| 3328 | 3327 | if(false){?></script><?php } |
| 3329 | - }elseif(!empty($args['row']['close'])){ |
|
| 3328 | + } elseif(!empty($args['row']['close'])){ |
|
| 3330 | 3329 | if(false){?><script><?php }?> |
| 3331 | 3330 | el( |
| 3332 | 3331 | 'div', |
@@ -3335,7 +3334,7 @@ discard block |
||
| 3335 | 3334 | }, |
| 3336 | 3335 | <?php |
| 3337 | 3336 | if(false){?></script><?php } |
| 3338 | - }else{ |
|
| 3337 | + } else{ |
|
| 3339 | 3338 | if(false){?><script><?php }?> |
| 3340 | 3339 | el( |
| 3341 | 3340 | 'div', |
@@ -3440,9 +3439,9 @@ discard block |
||
| 3440 | 3439 | $device_type_icon = ''; |
| 3441 | 3440 | if($device_type=='Desktop'){ |
| 3442 | 3441 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3443 | - }elseif($device_type=='Tablet'){ |
|
| 3442 | + } elseif($device_type=='Tablet'){ |
|
| 3444 | 3443 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3445 | - }elseif($device_type=='Mobile'){ |
|
| 3444 | + } elseif($device_type=='Mobile'){ |
|
| 3446 | 3445 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3447 | 3446 | } |
| 3448 | 3447 | |
@@ -3505,7 +3504,7 @@ discard block |
||
| 3505 | 3504 | $args['type'] == 'text'; |
| 3506 | 3505 | // Save numbers as numbers and not strings |
| 3507 | 3506 | $value = "props.attributes.$key ? props.attributes.$key : ''"; |
| 3508 | - }else if ( $args['type'] == 'notice' ) { |
|
| 3507 | + } else if ( $args['type'] == 'notice' ) { |
|
| 3509 | 3508 | |
| 3510 | 3509 | $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
| 3511 | 3510 | $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
@@ -3580,7 +3579,7 @@ discard block |
||
| 3580 | 3579 | $key: value |
| 3581 | 3580 | }); |
| 3582 | 3581 | },"; |
| 3583 | - }elseif ( $args['type'] == 'gradient' ) { |
|
| 3582 | + } elseif ( $args['type'] == 'gradient' ) { |
|
| 3584 | 3583 | $type = 'GradientPicker'; |
| 3585 | 3584 | $extra .= "gradients: [{ |
| 3586 | 3585 | name: 'Vivid cyan blue to vivid purple', |
@@ -3619,7 +3618,7 @@ discard block |
||
| 3619 | 3618 | slug: 'cool-to-warm-spectrum', |
| 3620 | 3619 | }],"; |
| 3621 | 3620 | |
| 3622 | - }elseif ( $args['type'] == 'image' ) { |
|
| 3621 | + } elseif ( $args['type'] == 'image' ) { |
|
| 3623 | 3622 | // print_r($args); |
| 3624 | 3623 | |
| 3625 | 3624 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key || props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{ |
@@ -3756,8 +3755,7 @@ discard block |
||
| 3756 | 3755 | $onchange = ""; |
| 3757 | 3756 | |
| 3758 | 3757 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3759 | - } |
|
| 3760 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 3758 | + } elseif ( $args['type'] == 'checkbox' ) { |
|
| 3761 | 3759 | $type = 'CheckboxControl'; |
| 3762 | 3760 | $extra .= "checked: props.attributes.$key,"; |
| 3763 | 3761 | $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
@@ -3769,9 +3767,9 @@ discard block |
||
| 3769 | 3767 | |
| 3770 | 3768 | if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
| 3771 | 3769 | $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
| 3772 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3770 | + } elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3773 | 3771 | $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
| 3774 | - }else { |
|
| 3772 | + } else { |
|
| 3775 | 3773 | |
| 3776 | 3774 | if ( ! empty( $args['options'] ) ) { |
| 3777 | 3775 | $options .= "options: ["; |
@@ -3935,7 +3933,7 @@ discard block |
||
| 3935 | 3933 | foreach ( $custom_attributes as $key => $val ) { |
| 3936 | 3934 | if(is_array($val)){ |
| 3937 | 3935 | $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
| 3938 | - }else{ |
|
| 3936 | + } else{ |
|
| 3939 | 3937 | $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
| 3940 | 3938 | } |
| 3941 | 3939 | } |
@@ -3975,7 +3973,7 @@ discard block |
||
| 3975 | 3973 | |
| 3976 | 3974 | if($new_args['element']=='InnerBlocks'){ |
| 3977 | 3975 | echo "\n el( InnerBlocks, {"; |
| 3978 | - }elseif($new_args['element']=='innerBlocksProps'){ |
|
| 3976 | + } elseif($new_args['element']=='innerBlocksProps'){ |
|
| 3979 | 3977 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3980 | 3978 | // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
| 3981 | 3979 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
@@ -3988,11 +3986,11 @@ discard block |
||
| 3988 | 3986 | // echo '###'; |
| 3989 | 3987 | |
| 3990 | 3988 | // echo '###'; |
| 3991 | - }elseif($new_args['element']=='BlocksProps'){ |
|
| 3989 | + } elseif($new_args['element']=='BlocksProps'){ |
|
| 3992 | 3990 | |
| 3993 | 3991 | if ( isset($new_args['if_inner_element']) ) { |
| 3994 | 3992 | $element = $new_args['if_inner_element']; |
| 3995 | - }else { |
|
| 3993 | + } else { |
|
| 3996 | 3994 | $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
| 3997 | 3995 | } |
| 3998 | 3996 | |
@@ -4003,7 +4001,7 @@ discard block |
||
| 4003 | 4001 | |
| 4004 | 4002 | // echo "} ),"; |
| 4005 | 4003 | |
| 4006 | - }else{ |
|
| 4004 | + } else{ |
|
| 4007 | 4005 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 4008 | 4006 | } |
| 4009 | 4007 | |
@@ -4028,7 +4026,7 @@ discard block |
||
| 4028 | 4026 | |
| 4029 | 4027 | if ( $new_key === 'content' ) { |
| 4030 | 4028 | echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
| 4031 | - }else if ( $new_key === 'if_content' ) { |
|
| 4029 | + } else if ( $new_key === 'if_content' ) { |
|
| 4032 | 4030 | echo $this->block_props_replace( $new_value ); |
| 4033 | 4031 | } |
| 4034 | 4032 | |
@@ -4058,7 +4056,7 @@ discard block |
||
| 4058 | 4056 | |
| 4059 | 4057 | if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
| 4060 | 4058 | echo "))";// end content |
| 4061 | - }else{ |
|
| 4059 | + } else{ |
|
| 4062 | 4060 | echo ")";// end content |
| 4063 | 4061 | } |
| 4064 | 4062 | |
@@ -4384,7 +4382,7 @@ discard block |
||
| 4384 | 4382 | |
| 4385 | 4383 | if(empty($instance['widget_title_tag'])){ |
| 4386 | 4384 | $output = $args['before_title'] . $title . $args['after_title']; |
| 4387 | - }else{ |
|
| 4385 | + } else{ |
|
| 4388 | 4386 | $title_tag = esc_attr( $instance['widget_title_tag'] ); |
| 4389 | 4387 | |
| 4390 | 4388 | // classes |
@@ -4674,11 +4672,11 @@ discard block |
||
| 4674 | 4672 | public function get_widget_icon($icon = 'box-top', $title = ''){ |
| 4675 | 4673 | if($icon=='box-top'){ |
| 4676 | 4674 | return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
| 4677 | - }elseif($icon=='box-right'){ |
|
| 4675 | + } elseif($icon=='box-right'){ |
|
| 4678 | 4676 | return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
| 4679 | - }elseif($icon=='box-bottom'){ |
|
| 4677 | + } elseif($icon=='box-bottom'){ |
|
| 4680 | 4678 | return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
| 4681 | - }elseif($icon=='box-left'){ |
|
| 4679 | + } elseif($icon=='box-left'){ |
|
| 4682 | 4680 | return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
| 4683 | 4681 | } |
| 4684 | 4682 | } |
@@ -11,21 +11,21 @@ discard block |
||
| 11 | 11 | * @return mixed|void |
| 12 | 12 | */ |
| 13 | 13 | function sd_pagenow_exclude() { |
| 14 | - return apply_filters( |
|
| 15 | - 'sd_pagenow_exclude', |
|
| 16 | - array( |
|
| 17 | - 'upload.php', |
|
| 18 | - 'edit-comments.php', |
|
| 19 | - 'edit-tags.php', |
|
| 20 | - 'index.php', |
|
| 21 | - 'media-new.php', |
|
| 22 | - 'options-discussion.php', |
|
| 23 | - 'options-writing.php', |
|
| 24 | - 'edit.php', |
|
| 25 | - 'themes.php', |
|
| 26 | - 'users.php', |
|
| 27 | - ) |
|
| 28 | - ); |
|
| 14 | + return apply_filters( |
|
| 15 | + 'sd_pagenow_exclude', |
|
| 16 | + array( |
|
| 17 | + 'upload.php', |
|
| 18 | + 'edit-comments.php', |
|
| 19 | + 'edit-tags.php', |
|
| 20 | + 'index.php', |
|
| 21 | + 'media-new.php', |
|
| 22 | + 'options-discussion.php', |
|
| 23 | + 'options-writing.php', |
|
| 24 | + 'edit.php', |
|
| 25 | + 'themes.php', |
|
| 26 | + 'users.php', |
|
| 27 | + ) |
|
| 28 | + ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @return mixed|void |
| 38 | 38 | */ |
| 39 | 39 | function sd_widget_exclude() { |
| 40 | - return apply_filters( 'sd_widget_exclude', array() ); |
|
| 40 | + return apply_filters( 'sd_widget_exclude', array() ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
@@ -50,83 +50,83 @@ discard block |
||
| 50 | 50 | * @return array |
| 51 | 51 | */ |
| 52 | 52 | function sd_get_margin_input( $type = 'mt', $overwrite = array(), $include_negatives = true ) { |
| 53 | - global $aui_bs5; |
|
| 54 | - $options = array( |
|
| 55 | - '' => __( 'None', 'ayecode-connect' ), |
|
| 56 | - 'auto' => __( 'auto', 'ayecode-connect' ), |
|
| 57 | - '0' => '0', |
|
| 58 | - '1' => '1', |
|
| 59 | - '2' => '2', |
|
| 60 | - '3' => '3', |
|
| 61 | - '4' => '4', |
|
| 62 | - '5' => '5', |
|
| 63 | - '6' => '6', |
|
| 64 | - '7' => '7', |
|
| 65 | - '8' => '8', |
|
| 66 | - '9' => '9', |
|
| 67 | - '10' => '10', |
|
| 68 | - '11' => '11', |
|
| 69 | - '12' => '12', |
|
| 70 | - ); |
|
| 71 | - |
|
| 72 | - if ( $include_negatives ) { |
|
| 73 | - $options['n1'] = '-1'; |
|
| 74 | - $options['n2'] = '-2'; |
|
| 75 | - $options['n3'] = '-3'; |
|
| 76 | - $options['n4'] = '-4'; |
|
| 77 | - $options['n5'] = '-5'; |
|
| 78 | - $options['n6'] = '-6'; |
|
| 79 | - $options['n7'] = '-7'; |
|
| 80 | - $options['n8'] = '-8'; |
|
| 81 | - $options['n9'] = '-9'; |
|
| 82 | - $options['n10'] = '-10'; |
|
| 83 | - $options['n11'] = '-11'; |
|
| 84 | - $options['n12'] = '-12'; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $defaults = array( |
|
| 88 | - 'type' => 'select', |
|
| 89 | - 'title' => __( 'Margin top', 'ayecode-connect' ), |
|
| 90 | - 'options' => $options, |
|
| 91 | - 'default' => '', |
|
| 92 | - 'desc_tip' => true, |
|
| 93 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 94 | - ); |
|
| 95 | - |
|
| 96 | - // title |
|
| 97 | - if ( $type == 'mt' ) { |
|
| 98 | - $defaults['title'] = __( 'Margin top', 'ayecode-connect' ); |
|
| 99 | - $defaults['icon'] = 'box-top'; |
|
| 100 | - $defaults['row'] = array( |
|
| 101 | - 'title' => __( 'Margins', 'ayecode-connect' ), |
|
| 102 | - 'key' => 'wrapper-margins', |
|
| 103 | - 'open' => true, |
|
| 104 | - 'class' => 'text-center', |
|
| 105 | - ); |
|
| 106 | - } elseif ( $type == 'mr' ) { |
|
| 107 | - $defaults['title'] = __( 'Margin right', 'ayecode-connect' ); |
|
| 108 | - $defaults['icon'] = 'box-right'; |
|
| 109 | - $defaults['row'] = array( |
|
| 110 | - 'key' => 'wrapper-margins', |
|
| 111 | - ); |
|
| 112 | - } elseif ( $type == 'mb' ) { |
|
| 113 | - $defaults['title'] = __( 'Margin bottom', 'ayecode-connect' ); |
|
| 114 | - $defaults['icon'] = 'box-bottom'; |
|
| 115 | - $defaults['row'] = array( |
|
| 116 | - 'key' => 'wrapper-margins', |
|
| 117 | - ); |
|
| 118 | - } elseif ( $type == 'ml' ) { |
|
| 119 | - $defaults['title'] = __( 'Margin left', 'ayecode-connect' ); |
|
| 120 | - $defaults['icon'] = 'box-left'; |
|
| 121 | - $defaults['row'] = array( |
|
| 122 | - 'key' => 'wrapper-margins', |
|
| 123 | - 'close' => true, |
|
| 124 | - ); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 128 | - |
|
| 129 | - return $input; |
|
| 53 | + global $aui_bs5; |
|
| 54 | + $options = array( |
|
| 55 | + '' => __( 'None', 'ayecode-connect' ), |
|
| 56 | + 'auto' => __( 'auto', 'ayecode-connect' ), |
|
| 57 | + '0' => '0', |
|
| 58 | + '1' => '1', |
|
| 59 | + '2' => '2', |
|
| 60 | + '3' => '3', |
|
| 61 | + '4' => '4', |
|
| 62 | + '5' => '5', |
|
| 63 | + '6' => '6', |
|
| 64 | + '7' => '7', |
|
| 65 | + '8' => '8', |
|
| 66 | + '9' => '9', |
|
| 67 | + '10' => '10', |
|
| 68 | + '11' => '11', |
|
| 69 | + '12' => '12', |
|
| 70 | + ); |
|
| 71 | + |
|
| 72 | + if ( $include_negatives ) { |
|
| 73 | + $options['n1'] = '-1'; |
|
| 74 | + $options['n2'] = '-2'; |
|
| 75 | + $options['n3'] = '-3'; |
|
| 76 | + $options['n4'] = '-4'; |
|
| 77 | + $options['n5'] = '-5'; |
|
| 78 | + $options['n6'] = '-6'; |
|
| 79 | + $options['n7'] = '-7'; |
|
| 80 | + $options['n8'] = '-8'; |
|
| 81 | + $options['n9'] = '-9'; |
|
| 82 | + $options['n10'] = '-10'; |
|
| 83 | + $options['n11'] = '-11'; |
|
| 84 | + $options['n12'] = '-12'; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $defaults = array( |
|
| 88 | + 'type' => 'select', |
|
| 89 | + 'title' => __( 'Margin top', 'ayecode-connect' ), |
|
| 90 | + 'options' => $options, |
|
| 91 | + 'default' => '', |
|
| 92 | + 'desc_tip' => true, |
|
| 93 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 94 | + ); |
|
| 95 | + |
|
| 96 | + // title |
|
| 97 | + if ( $type == 'mt' ) { |
|
| 98 | + $defaults['title'] = __( 'Margin top', 'ayecode-connect' ); |
|
| 99 | + $defaults['icon'] = 'box-top'; |
|
| 100 | + $defaults['row'] = array( |
|
| 101 | + 'title' => __( 'Margins', 'ayecode-connect' ), |
|
| 102 | + 'key' => 'wrapper-margins', |
|
| 103 | + 'open' => true, |
|
| 104 | + 'class' => 'text-center', |
|
| 105 | + ); |
|
| 106 | + } elseif ( $type == 'mr' ) { |
|
| 107 | + $defaults['title'] = __( 'Margin right', 'ayecode-connect' ); |
|
| 108 | + $defaults['icon'] = 'box-right'; |
|
| 109 | + $defaults['row'] = array( |
|
| 110 | + 'key' => 'wrapper-margins', |
|
| 111 | + ); |
|
| 112 | + } elseif ( $type == 'mb' ) { |
|
| 113 | + $defaults['title'] = __( 'Margin bottom', 'ayecode-connect' ); |
|
| 114 | + $defaults['icon'] = 'box-bottom'; |
|
| 115 | + $defaults['row'] = array( |
|
| 116 | + 'key' => 'wrapper-margins', |
|
| 117 | + ); |
|
| 118 | + } elseif ( $type == 'ml' ) { |
|
| 119 | + $defaults['title'] = __( 'Margin left', 'ayecode-connect' ); |
|
| 120 | + $defaults['icon'] = 'box-left'; |
|
| 121 | + $defaults['row'] = array( |
|
| 122 | + 'key' => 'wrapper-margins', |
|
| 123 | + 'close' => true, |
|
| 124 | + ); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 128 | + |
|
| 129 | + return $input; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -138,67 +138,67 @@ discard block |
||
| 138 | 138 | * @return array |
| 139 | 139 | */ |
| 140 | 140 | function sd_get_padding_input( $type = 'pt', $overwrite = array() ) { |
| 141 | - $options = array( |
|
| 142 | - '' => __( 'None', 'ayecode-connect' ), |
|
| 143 | - '0' => '0', |
|
| 144 | - '1' => '1', |
|
| 145 | - '2' => '2', |
|
| 146 | - '3' => '3', |
|
| 147 | - '4' => '4', |
|
| 148 | - '5' => '5', |
|
| 149 | - '6' => '6', |
|
| 150 | - '7' => '7', |
|
| 151 | - '8' => '8', |
|
| 152 | - '9' => '9', |
|
| 153 | - '10' => '10', |
|
| 154 | - '11' => '11', |
|
| 155 | - '12' => '12', |
|
| 156 | - ); |
|
| 157 | - |
|
| 158 | - $defaults = array( |
|
| 159 | - 'type' => 'select', |
|
| 160 | - 'title' => __( 'Padding top', 'ayecode-connect' ), |
|
| 161 | - 'options' => $options, |
|
| 162 | - 'default' => '', |
|
| 163 | - 'desc_tip' => true, |
|
| 164 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 165 | - ); |
|
| 166 | - |
|
| 167 | - // title |
|
| 168 | - if ( $type == 'pt' ) { |
|
| 169 | - $defaults['title'] = __( 'Padding top', 'ayecode-connect' ); |
|
| 170 | - $defaults['icon'] = 'box-top'; |
|
| 171 | - $defaults['row'] = array( |
|
| 172 | - 'title' => __( 'Padding', 'ayecode-connect' ), |
|
| 173 | - 'key' => 'wrapper-padding', |
|
| 174 | - 'open' => true, |
|
| 175 | - 'class' => 'text-center', |
|
| 176 | - ); |
|
| 177 | - } elseif ( $type == 'pr' ) { |
|
| 178 | - $defaults['title'] = __( 'Padding right', 'ayecode-connect' ); |
|
| 179 | - $defaults['icon'] = 'box-right'; |
|
| 180 | - $defaults['row'] = array( |
|
| 181 | - 'key' => 'wrapper-padding', |
|
| 182 | - ); |
|
| 183 | - } elseif ( $type == 'pb' ) { |
|
| 184 | - $defaults['title'] = __( 'Padding bottom', 'ayecode-connect' ); |
|
| 185 | - $defaults['icon'] = 'box-bottom'; |
|
| 186 | - $defaults['row'] = array( |
|
| 187 | - 'key' => 'wrapper-padding', |
|
| 188 | - ); |
|
| 189 | - } elseif ( $type == 'pl' ) { |
|
| 190 | - $defaults['title'] = __( 'Padding left', 'ayecode-connect' ); |
|
| 191 | - $defaults['icon'] = 'box-left'; |
|
| 192 | - $defaults['row'] = array( |
|
| 193 | - 'key' => 'wrapper-padding', |
|
| 194 | - 'close' => true, |
|
| 195 | - |
|
| 196 | - ); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 200 | - |
|
| 201 | - return $input; |
|
| 141 | + $options = array( |
|
| 142 | + '' => __( 'None', 'ayecode-connect' ), |
|
| 143 | + '0' => '0', |
|
| 144 | + '1' => '1', |
|
| 145 | + '2' => '2', |
|
| 146 | + '3' => '3', |
|
| 147 | + '4' => '4', |
|
| 148 | + '5' => '5', |
|
| 149 | + '6' => '6', |
|
| 150 | + '7' => '7', |
|
| 151 | + '8' => '8', |
|
| 152 | + '9' => '9', |
|
| 153 | + '10' => '10', |
|
| 154 | + '11' => '11', |
|
| 155 | + '12' => '12', |
|
| 156 | + ); |
|
| 157 | + |
|
| 158 | + $defaults = array( |
|
| 159 | + 'type' => 'select', |
|
| 160 | + 'title' => __( 'Padding top', 'ayecode-connect' ), |
|
| 161 | + 'options' => $options, |
|
| 162 | + 'default' => '', |
|
| 163 | + 'desc_tip' => true, |
|
| 164 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 165 | + ); |
|
| 166 | + |
|
| 167 | + // title |
|
| 168 | + if ( $type == 'pt' ) { |
|
| 169 | + $defaults['title'] = __( 'Padding top', 'ayecode-connect' ); |
|
| 170 | + $defaults['icon'] = 'box-top'; |
|
| 171 | + $defaults['row'] = array( |
|
| 172 | + 'title' => __( 'Padding', 'ayecode-connect' ), |
|
| 173 | + 'key' => 'wrapper-padding', |
|
| 174 | + 'open' => true, |
|
| 175 | + 'class' => 'text-center', |
|
| 176 | + ); |
|
| 177 | + } elseif ( $type == 'pr' ) { |
|
| 178 | + $defaults['title'] = __( 'Padding right', 'ayecode-connect' ); |
|
| 179 | + $defaults['icon'] = 'box-right'; |
|
| 180 | + $defaults['row'] = array( |
|
| 181 | + 'key' => 'wrapper-padding', |
|
| 182 | + ); |
|
| 183 | + } elseif ( $type == 'pb' ) { |
|
| 184 | + $defaults['title'] = __( 'Padding bottom', 'ayecode-connect' ); |
|
| 185 | + $defaults['icon'] = 'box-bottom'; |
|
| 186 | + $defaults['row'] = array( |
|
| 187 | + 'key' => 'wrapper-padding', |
|
| 188 | + ); |
|
| 189 | + } elseif ( $type == 'pl' ) { |
|
| 190 | + $defaults['title'] = __( 'Padding left', 'ayecode-connect' ); |
|
| 191 | + $defaults['icon'] = 'box-left'; |
|
| 192 | + $defaults['row'] = array( |
|
| 193 | + 'key' => 'wrapper-padding', |
|
| 194 | + 'close' => true, |
|
| 195 | + |
|
| 196 | + ); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 200 | + |
|
| 201 | + return $input; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -210,97 +210,97 @@ discard block |
||
| 210 | 210 | * @return array |
| 211 | 211 | */ |
| 212 | 212 | function sd_get_border_input( $type = 'border', $overwrite = array() ) { |
| 213 | - global $aui_bs5; |
|
| 214 | - |
|
| 215 | - $defaults = array( |
|
| 216 | - 'type' => 'select', |
|
| 217 | - 'title' => __( 'Border', 'ayecode-connect' ), |
|
| 218 | - 'options' => array(), |
|
| 219 | - 'default' => '', |
|
| 220 | - 'desc_tip' => true, |
|
| 221 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 222 | - ); |
|
| 223 | - |
|
| 224 | - // title |
|
| 225 | - if ( 'rounded' === $type ) { |
|
| 226 | - $defaults['title'] = __( 'Border radius type', 'ayecode-connect' ); |
|
| 227 | - $defaults['options'] = array( |
|
| 228 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 229 | - 'rounded' => 'rounded', |
|
| 230 | - 'rounded-top' => 'rounded-top', |
|
| 231 | - 'rounded-right' => 'rounded-right', |
|
| 232 | - 'rounded-bottom' => 'rounded-bottom', |
|
| 233 | - 'rounded-left' => 'rounded-left', |
|
| 234 | - ); |
|
| 235 | - $defaults['element_require'] = '[%border%]'; |
|
| 236 | - } elseif ( 'rounded_size' === $type ) { |
|
| 237 | - $defaults['title'] = __( 'Border radius size', 'ayecode-connect' ); |
|
| 238 | - |
|
| 239 | - if ( $aui_bs5 ) { |
|
| 240 | - $defaults['options'] = array( |
|
| 241 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 242 | - '0' => '0', |
|
| 243 | - '1' => '1', |
|
| 244 | - '2' => '2', |
|
| 245 | - '3' => '3', |
|
| 246 | - '4' => '4', |
|
| 247 | - 'circle' => 'circle', |
|
| 248 | - 'pill' => 'pill', |
|
| 249 | - ); |
|
| 250 | - } else { |
|
| 251 | - $defaults['options'] = array( |
|
| 252 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 253 | - 'sm' => __( 'Small', 'ayecode-connect' ), |
|
| 254 | - 'lg' => __( 'Large', 'ayecode-connect' ), |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - $defaults['element_require'] = '[%border%]'; |
|
| 258 | - } elseif ( 'width' === $type ) { // BS% |
|
| 259 | - $defaults['title'] = __( 'Border width', 'ayecode-connect' ); |
|
| 260 | - $defaults['options'] = array( |
|
| 261 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 262 | - 'border-2' => '2', |
|
| 263 | - 'border-3' => '3', |
|
| 264 | - 'border-4' => '4', |
|
| 265 | - 'border-5' => '5', |
|
| 266 | - ); |
|
| 267 | - $defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2'; |
|
| 268 | - } elseif ( 'opacity' === $type ) { // BS% |
|
| 269 | - $defaults['title'] = __( 'Border opacity', 'ayecode-connect' ); |
|
| 270 | - $defaults['options'] = array( |
|
| 271 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 272 | - 'border-opacity-75' => '75%', |
|
| 273 | - 'border-opacity-50' => '50%', |
|
| 274 | - 'border-opacity-25' => '25%', |
|
| 275 | - 'border-opacity-10' => '10%', |
|
| 276 | - ); |
|
| 277 | - $defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2'; |
|
| 278 | - } elseif ( 'type' === $type ) { |
|
| 279 | - $defaults['title'] = __( 'Border show', 'ayecode-connect' ); |
|
| 280 | - $defaults['options'] = array( |
|
| 281 | - 'border' => __( 'Full (set color to show)', 'ayecode-connect' ), |
|
| 282 | - 'border-top' => __( 'Top', 'ayecode-connect' ), |
|
| 283 | - 'border-bottom' => __( 'Bottom', 'ayecode-connect' ), |
|
| 284 | - 'border-left' => __( 'Left', 'ayecode-connect' ), |
|
| 285 | - 'border-right' => __( 'Right', 'ayecode-connect' ), |
|
| 286 | - 'border-top-0' => __( '-Top', 'ayecode-connect' ), |
|
| 287 | - 'border-bottom-0' => __( '-Bottom', 'ayecode-connect' ), |
|
| 288 | - 'border-left-0' => __( '-Left', 'ayecode-connect' ), |
|
| 289 | - 'border-right-0' => __( '-Right', 'ayecode-connect' ), |
|
| 290 | - ); |
|
| 291 | - $defaults['element_require'] = '[%border%]'; |
|
| 292 | - |
|
| 293 | - } else { |
|
| 294 | - $defaults['title'] = __( 'Border color', 'ayecode-connect' ); |
|
| 295 | - $defaults['options'] = array( |
|
| 296 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 297 | - '0' => __( 'None', 'ayecode-connect' ), |
|
| 298 | - ) + sd_aui_colors(); |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 302 | - |
|
| 303 | - return $input; |
|
| 213 | + global $aui_bs5; |
|
| 214 | + |
|
| 215 | + $defaults = array( |
|
| 216 | + 'type' => 'select', |
|
| 217 | + 'title' => __( 'Border', 'ayecode-connect' ), |
|
| 218 | + 'options' => array(), |
|
| 219 | + 'default' => '', |
|
| 220 | + 'desc_tip' => true, |
|
| 221 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 222 | + ); |
|
| 223 | + |
|
| 224 | + // title |
|
| 225 | + if ( 'rounded' === $type ) { |
|
| 226 | + $defaults['title'] = __( 'Border radius type', 'ayecode-connect' ); |
|
| 227 | + $defaults['options'] = array( |
|
| 228 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 229 | + 'rounded' => 'rounded', |
|
| 230 | + 'rounded-top' => 'rounded-top', |
|
| 231 | + 'rounded-right' => 'rounded-right', |
|
| 232 | + 'rounded-bottom' => 'rounded-bottom', |
|
| 233 | + 'rounded-left' => 'rounded-left', |
|
| 234 | + ); |
|
| 235 | + $defaults['element_require'] = '[%border%]'; |
|
| 236 | + } elseif ( 'rounded_size' === $type ) { |
|
| 237 | + $defaults['title'] = __( 'Border radius size', 'ayecode-connect' ); |
|
| 238 | + |
|
| 239 | + if ( $aui_bs5 ) { |
|
| 240 | + $defaults['options'] = array( |
|
| 241 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 242 | + '0' => '0', |
|
| 243 | + '1' => '1', |
|
| 244 | + '2' => '2', |
|
| 245 | + '3' => '3', |
|
| 246 | + '4' => '4', |
|
| 247 | + 'circle' => 'circle', |
|
| 248 | + 'pill' => 'pill', |
|
| 249 | + ); |
|
| 250 | + } else { |
|
| 251 | + $defaults['options'] = array( |
|
| 252 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 253 | + 'sm' => __( 'Small', 'ayecode-connect' ), |
|
| 254 | + 'lg' => __( 'Large', 'ayecode-connect' ), |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + $defaults['element_require'] = '[%border%]'; |
|
| 258 | + } elseif ( 'width' === $type ) { // BS% |
|
| 259 | + $defaults['title'] = __( 'Border width', 'ayecode-connect' ); |
|
| 260 | + $defaults['options'] = array( |
|
| 261 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 262 | + 'border-2' => '2', |
|
| 263 | + 'border-3' => '3', |
|
| 264 | + 'border-4' => '4', |
|
| 265 | + 'border-5' => '5', |
|
| 266 | + ); |
|
| 267 | + $defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2'; |
|
| 268 | + } elseif ( 'opacity' === $type ) { // BS% |
|
| 269 | + $defaults['title'] = __( 'Border opacity', 'ayecode-connect' ); |
|
| 270 | + $defaults['options'] = array( |
|
| 271 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 272 | + 'border-opacity-75' => '75%', |
|
| 273 | + 'border-opacity-50' => '50%', |
|
| 274 | + 'border-opacity-25' => '25%', |
|
| 275 | + 'border-opacity-10' => '10%', |
|
| 276 | + ); |
|
| 277 | + $defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2'; |
|
| 278 | + } elseif ( 'type' === $type ) { |
|
| 279 | + $defaults['title'] = __( 'Border show', 'ayecode-connect' ); |
|
| 280 | + $defaults['options'] = array( |
|
| 281 | + 'border' => __( 'Full (set color to show)', 'ayecode-connect' ), |
|
| 282 | + 'border-top' => __( 'Top', 'ayecode-connect' ), |
|
| 283 | + 'border-bottom' => __( 'Bottom', 'ayecode-connect' ), |
|
| 284 | + 'border-left' => __( 'Left', 'ayecode-connect' ), |
|
| 285 | + 'border-right' => __( 'Right', 'ayecode-connect' ), |
|
| 286 | + 'border-top-0' => __( '-Top', 'ayecode-connect' ), |
|
| 287 | + 'border-bottom-0' => __( '-Bottom', 'ayecode-connect' ), |
|
| 288 | + 'border-left-0' => __( '-Left', 'ayecode-connect' ), |
|
| 289 | + 'border-right-0' => __( '-Right', 'ayecode-connect' ), |
|
| 290 | + ); |
|
| 291 | + $defaults['element_require'] = '[%border%]'; |
|
| 292 | + |
|
| 293 | + } else { |
|
| 294 | + $defaults['title'] = __( 'Border color', 'ayecode-connect' ); |
|
| 295 | + $defaults['options'] = array( |
|
| 296 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 297 | + '0' => __( 'None', 'ayecode-connect' ), |
|
| 298 | + ) + sd_aui_colors(); |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 302 | + |
|
| 303 | + return $input; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -312,25 +312,25 @@ discard block |
||
| 312 | 312 | * @return array |
| 313 | 313 | */ |
| 314 | 314 | function sd_get_shadow_input( $type = 'shadow', $overwrite = array() ) { |
| 315 | - $options = array( |
|
| 316 | - '' => __( 'None', 'ayecode-connect' ), |
|
| 317 | - 'shadow-sm' => __( 'Small', 'ayecode-connect' ), |
|
| 318 | - 'shadow' => __( 'Regular', 'ayecode-connect' ), |
|
| 319 | - 'shadow-lg' => __( 'Large', 'ayecode-connect' ), |
|
| 320 | - ); |
|
| 315 | + $options = array( |
|
| 316 | + '' => __( 'None', 'ayecode-connect' ), |
|
| 317 | + 'shadow-sm' => __( 'Small', 'ayecode-connect' ), |
|
| 318 | + 'shadow' => __( 'Regular', 'ayecode-connect' ), |
|
| 319 | + 'shadow-lg' => __( 'Large', 'ayecode-connect' ), |
|
| 320 | + ); |
|
| 321 | 321 | |
| 322 | - $defaults = array( |
|
| 323 | - 'type' => 'select', |
|
| 324 | - 'title' => __( 'Shadow', 'ayecode-connect' ), |
|
| 325 | - 'options' => $options, |
|
| 326 | - 'default' => '', |
|
| 327 | - 'desc_tip' => true, |
|
| 328 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 329 | - ); |
|
| 322 | + $defaults = array( |
|
| 323 | + 'type' => 'select', |
|
| 324 | + 'title' => __( 'Shadow', 'ayecode-connect' ), |
|
| 325 | + 'options' => $options, |
|
| 326 | + 'default' => '', |
|
| 327 | + 'desc_tip' => true, |
|
| 328 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 329 | + ); |
|
| 330 | 330 | |
| 331 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 331 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 332 | 332 | |
| 333 | - return $input; |
|
| 333 | + return $input; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -342,23 +342,23 @@ discard block |
||
| 342 | 342 | * @return array |
| 343 | 343 | */ |
| 344 | 344 | function sd_get_background_input( $type = 'bg', $overwrite = array() ) { |
| 345 | - $options = array( |
|
| 346 | - '' => __( 'None', 'ayecode-connect' ), |
|
| 347 | - 'transparent' => __( 'Transparent', 'ayecode-connect' ), |
|
| 348 | - ) + sd_aui_colors(); |
|
| 345 | + $options = array( |
|
| 346 | + '' => __( 'None', 'ayecode-connect' ), |
|
| 347 | + 'transparent' => __( 'Transparent', 'ayecode-connect' ), |
|
| 348 | + ) + sd_aui_colors(); |
|
| 349 | 349 | |
| 350 | - $defaults = array( |
|
| 351 | - 'type' => 'select', |
|
| 352 | - 'title' => __( 'Background color', 'ayecode-connect' ), |
|
| 353 | - 'options' => $options, |
|
| 354 | - 'default' => '', |
|
| 355 | - 'desc_tip' => true, |
|
| 356 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 357 | - ); |
|
| 350 | + $defaults = array( |
|
| 351 | + 'type' => 'select', |
|
| 352 | + 'title' => __( 'Background color', 'ayecode-connect' ), |
|
| 353 | + 'options' => $options, |
|
| 354 | + 'default' => '', |
|
| 355 | + 'desc_tip' => true, |
|
| 356 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 357 | + ); |
|
| 358 | 358 | |
| 359 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 359 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 360 | 360 | |
| 361 | - return $input; |
|
| 361 | + return $input; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -370,35 +370,35 @@ discard block |
||
| 370 | 370 | * @return array |
| 371 | 371 | */ |
| 372 | 372 | function sd_get_opacity_input( $type = 'opacity', $overwrite = array() ) { |
| 373 | - $options = array( |
|
| 374 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 375 | - 'opacity-10' => '10%', |
|
| 376 | - 'opacity-15' => '15%', |
|
| 377 | - 'opacity-25' => '25%', |
|
| 378 | - 'opacity-35' => '35%', |
|
| 379 | - 'opacity-40' => '40%', |
|
| 380 | - 'opacity-50' => '50%', |
|
| 381 | - 'opacity-60' => '60%', |
|
| 382 | - 'opacity-65' => '65%', |
|
| 383 | - 'opacity-70' => '70%', |
|
| 384 | - 'opacity-75' => '75%', |
|
| 385 | - 'opacity-80' => '80%', |
|
| 386 | - 'opacity-90' => '90%', |
|
| 387 | - 'opacity-100' => '100%', |
|
| 388 | - ); |
|
| 389 | - |
|
| 390 | - $defaults = array( |
|
| 391 | - 'type' => 'select', |
|
| 392 | - 'title' => __( 'Opacity', 'ayecode-connect' ), |
|
| 393 | - 'options' => $options, |
|
| 394 | - 'default' => '', |
|
| 395 | - 'desc_tip' => true, |
|
| 396 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 397 | - ); |
|
| 398 | - |
|
| 399 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 400 | - |
|
| 401 | - return $input; |
|
| 373 | + $options = array( |
|
| 374 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 375 | + 'opacity-10' => '10%', |
|
| 376 | + 'opacity-15' => '15%', |
|
| 377 | + 'opacity-25' => '25%', |
|
| 378 | + 'opacity-35' => '35%', |
|
| 379 | + 'opacity-40' => '40%', |
|
| 380 | + 'opacity-50' => '50%', |
|
| 381 | + 'opacity-60' => '60%', |
|
| 382 | + 'opacity-65' => '65%', |
|
| 383 | + 'opacity-70' => '70%', |
|
| 384 | + 'opacity-75' => '75%', |
|
| 385 | + 'opacity-80' => '80%', |
|
| 386 | + 'opacity-90' => '90%', |
|
| 387 | + 'opacity-100' => '100%', |
|
| 388 | + ); |
|
| 389 | + |
|
| 390 | + $defaults = array( |
|
| 391 | + 'type' => 'select', |
|
| 392 | + 'title' => __( 'Opacity', 'ayecode-connect' ), |
|
| 393 | + 'options' => $options, |
|
| 394 | + 'default' => '', |
|
| 395 | + 'desc_tip' => true, |
|
| 396 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 397 | + ); |
|
| 398 | + |
|
| 399 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 400 | + |
|
| 401 | + return $input; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -411,124 +411,124 @@ discard block |
||
| 411 | 411 | */ |
| 412 | 412 | function sd_get_background_inputs( $type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array(), $include_button_colors = false ) { |
| 413 | 413 | |
| 414 | - $color_options = $include_button_colors ? sd_aui_colors( false, true, true, true ) : sd_aui_colors(); |
|
| 415 | - |
|
| 416 | - $options = array( |
|
| 417 | - '' => __( 'None', 'ayecode-connect' ), |
|
| 418 | - 'transparent' => __( 'Transparent', 'ayecode-connect' ), |
|
| 419 | - ) + $color_options; |
|
| 420 | - |
|
| 421 | - if ( false !== $overwrite_color ) { |
|
| 422 | - $options['custom-color'] = __( 'Custom Color', 'ayecode-connect' ); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - if ( false !== $overwrite_gradient ) { |
|
| 426 | - $options['custom-gradient'] = __( 'Custom Gradient', 'ayecode-connect' ); |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - $defaults = array( |
|
| 430 | - 'type' => 'select', |
|
| 431 | - 'title' => __( 'Background Color', 'ayecode-connect' ), |
|
| 432 | - 'options' => $options, |
|
| 433 | - 'default' => '', |
|
| 434 | - 'desc_tip' => true, |
|
| 435 | - 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 436 | - ); |
|
| 437 | - |
|
| 438 | - if ( $overwrite !== false ) { |
|
| 439 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - if ( $overwrite_color !== false ) { |
|
| 443 | - $input[ $type . '_color' ] = wp_parse_args( |
|
| 444 | - $overwrite_color, |
|
| 445 | - array( |
|
| 446 | - 'type' => 'color', |
|
| 447 | - 'title' => __( 'Custom color', 'ayecode-connect' ), |
|
| 448 | - 'placeholder' => '', |
|
| 449 | - 'default' => '#0073aa', |
|
| 450 | - 'desc_tip' => true, |
|
| 451 | - 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 452 | - 'element_require' => '[%' . $type . '%]=="custom-color"', |
|
| 453 | - ) |
|
| 454 | - ); |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - if ( $overwrite_gradient !== false ) { |
|
| 458 | - $input[ $type . '_gradient' ] = wp_parse_args( |
|
| 459 | - $overwrite_gradient, |
|
| 460 | - array( |
|
| 461 | - 'type' => 'gradient', |
|
| 462 | - 'title' => __( 'Custom gradient', 'ayecode-connect' ), |
|
| 463 | - 'placeholder' => '', |
|
| 464 | - 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 465 | - 'desc_tip' => true, |
|
| 466 | - 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 467 | - 'element_require' => '[%' . $type . '%]=="custom-gradient"', |
|
| 468 | - ) |
|
| 469 | - ); |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - if ( $overwrite_image !== false ) { |
|
| 473 | - |
|
| 474 | - $input[ $type . '_image_fixed' ] = array( |
|
| 475 | - 'type' => 'checkbox', |
|
| 476 | - 'title' => __( 'Fixed background', 'ayecode-connect' ), |
|
| 477 | - 'default' => '', |
|
| 478 | - 'desc_tip' => true, |
|
| 479 | - 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'ayecode-connect' ), |
|
| 480 | - 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 481 | - |
|
| 482 | - ); |
|
| 483 | - |
|
| 484 | - $input[ $type . '_image_use_featured' ] = array( |
|
| 485 | - 'type' => 'checkbox', |
|
| 486 | - 'title' => __( 'Use featured image', 'ayecode-connect' ), |
|
| 487 | - 'default' => '', |
|
| 488 | - 'desc_tip' => true, |
|
| 489 | - 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'ayecode-connect' ), |
|
| 490 | - 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 491 | - |
|
| 492 | - ); |
|
| 493 | - |
|
| 494 | - $input[ $type . '_image' ] = wp_parse_args( |
|
| 495 | - $overwrite_image, |
|
| 496 | - array( |
|
| 497 | - 'type' => 'image', |
|
| 498 | - 'title' => __( 'Custom image', 'ayecode-connect' ), |
|
| 499 | - 'placeholder' => '', |
|
| 500 | - 'default' => '', |
|
| 501 | - 'desc_tip' => true, |
|
| 502 | - 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 503 | - // 'element_require' => ' ![%' . $type . '_image_use_featured%] ' |
|
| 504 | - ) |
|
| 505 | - ); |
|
| 506 | - |
|
| 507 | - $input[ $type . '_image_id' ] = wp_parse_args( |
|
| 508 | - $overwrite_image, |
|
| 509 | - array( |
|
| 510 | - 'type' => 'hidden', |
|
| 511 | - 'hidden_type' => 'number', |
|
| 512 | - 'title' => '', |
|
| 513 | - 'placeholder' => '', |
|
| 514 | - 'default' => '', |
|
| 515 | - 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 516 | - ) |
|
| 517 | - ); |
|
| 518 | - |
|
| 519 | - $input[ $type . '_image_xy' ] = wp_parse_args( |
|
| 520 | - $overwrite_image, |
|
| 521 | - array( |
|
| 522 | - 'type' => 'image_xy', |
|
| 523 | - 'title' => '', |
|
| 524 | - 'placeholder' => '', |
|
| 525 | - 'default' => '', |
|
| 526 | - 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 527 | - ) |
|
| 528 | - ); |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - return $input; |
|
| 414 | + $color_options = $include_button_colors ? sd_aui_colors( false, true, true, true ) : sd_aui_colors(); |
|
| 415 | + |
|
| 416 | + $options = array( |
|
| 417 | + '' => __( 'None', 'ayecode-connect' ), |
|
| 418 | + 'transparent' => __( 'Transparent', 'ayecode-connect' ), |
|
| 419 | + ) + $color_options; |
|
| 420 | + |
|
| 421 | + if ( false !== $overwrite_color ) { |
|
| 422 | + $options['custom-color'] = __( 'Custom Color', 'ayecode-connect' ); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + if ( false !== $overwrite_gradient ) { |
|
| 426 | + $options['custom-gradient'] = __( 'Custom Gradient', 'ayecode-connect' ); |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + $defaults = array( |
|
| 430 | + 'type' => 'select', |
|
| 431 | + 'title' => __( 'Background Color', 'ayecode-connect' ), |
|
| 432 | + 'options' => $options, |
|
| 433 | + 'default' => '', |
|
| 434 | + 'desc_tip' => true, |
|
| 435 | + 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 436 | + ); |
|
| 437 | + |
|
| 438 | + if ( $overwrite !== false ) { |
|
| 439 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + if ( $overwrite_color !== false ) { |
|
| 443 | + $input[ $type . '_color' ] = wp_parse_args( |
|
| 444 | + $overwrite_color, |
|
| 445 | + array( |
|
| 446 | + 'type' => 'color', |
|
| 447 | + 'title' => __( 'Custom color', 'ayecode-connect' ), |
|
| 448 | + 'placeholder' => '', |
|
| 449 | + 'default' => '#0073aa', |
|
| 450 | + 'desc_tip' => true, |
|
| 451 | + 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 452 | + 'element_require' => '[%' . $type . '%]=="custom-color"', |
|
| 453 | + ) |
|
| 454 | + ); |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + if ( $overwrite_gradient !== false ) { |
|
| 458 | + $input[ $type . '_gradient' ] = wp_parse_args( |
|
| 459 | + $overwrite_gradient, |
|
| 460 | + array( |
|
| 461 | + 'type' => 'gradient', |
|
| 462 | + 'title' => __( 'Custom gradient', 'ayecode-connect' ), |
|
| 463 | + 'placeholder' => '', |
|
| 464 | + 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 465 | + 'desc_tip' => true, |
|
| 466 | + 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 467 | + 'element_require' => '[%' . $type . '%]=="custom-gradient"', |
|
| 468 | + ) |
|
| 469 | + ); |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + if ( $overwrite_image !== false ) { |
|
| 473 | + |
|
| 474 | + $input[ $type . '_image_fixed' ] = array( |
|
| 475 | + 'type' => 'checkbox', |
|
| 476 | + 'title' => __( 'Fixed background', 'ayecode-connect' ), |
|
| 477 | + 'default' => '', |
|
| 478 | + 'desc_tip' => true, |
|
| 479 | + 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'ayecode-connect' ), |
|
| 480 | + 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 481 | + |
|
| 482 | + ); |
|
| 483 | + |
|
| 484 | + $input[ $type . '_image_use_featured' ] = array( |
|
| 485 | + 'type' => 'checkbox', |
|
| 486 | + 'title' => __( 'Use featured image', 'ayecode-connect' ), |
|
| 487 | + 'default' => '', |
|
| 488 | + 'desc_tip' => true, |
|
| 489 | + 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'ayecode-connect' ), |
|
| 490 | + 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 491 | + |
|
| 492 | + ); |
|
| 493 | + |
|
| 494 | + $input[ $type . '_image' ] = wp_parse_args( |
|
| 495 | + $overwrite_image, |
|
| 496 | + array( |
|
| 497 | + 'type' => 'image', |
|
| 498 | + 'title' => __( 'Custom image', 'ayecode-connect' ), |
|
| 499 | + 'placeholder' => '', |
|
| 500 | + 'default' => '', |
|
| 501 | + 'desc_tip' => true, |
|
| 502 | + 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 503 | + // 'element_require' => ' ![%' . $type . '_image_use_featured%] ' |
|
| 504 | + ) |
|
| 505 | + ); |
|
| 506 | + |
|
| 507 | + $input[ $type . '_image_id' ] = wp_parse_args( |
|
| 508 | + $overwrite_image, |
|
| 509 | + array( |
|
| 510 | + 'type' => 'hidden', |
|
| 511 | + 'hidden_type' => 'number', |
|
| 512 | + 'title' => '', |
|
| 513 | + 'placeholder' => '', |
|
| 514 | + 'default' => '', |
|
| 515 | + 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 516 | + ) |
|
| 517 | + ); |
|
| 518 | + |
|
| 519 | + $input[ $type . '_image_xy' ] = wp_parse_args( |
|
| 520 | + $overwrite_image, |
|
| 521 | + array( |
|
| 522 | + 'type' => 'image_xy', |
|
| 523 | + 'title' => '', |
|
| 524 | + 'placeholder' => '', |
|
| 525 | + 'default' => '', |
|
| 526 | + 'group' => __( 'Background', 'ayecode-connect' ), |
|
| 527 | + ) |
|
| 528 | + ); |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + return $input; |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | /** |
@@ -541,175 +541,175 @@ discard block |
||
| 541 | 541 | */ |
| 542 | 542 | function sd_get_shape_divider_inputs( $type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
| 543 | 543 | |
| 544 | - $options = array( |
|
| 545 | - '' => __( 'None', 'ayecode-connect' ), |
|
| 546 | - 'mountains' => __( 'Mountains', 'ayecode-connect' ), |
|
| 547 | - 'drops' => __( 'Drops', 'ayecode-connect' ), |
|
| 548 | - 'clouds' => __( 'Clouds', 'ayecode-connect' ), |
|
| 549 | - 'zigzag' => __( 'Zigzag', 'ayecode-connect' ), |
|
| 550 | - 'pyramids' => __( 'Pyramids', 'ayecode-connect' ), |
|
| 551 | - 'triangle' => __( 'Triangle', 'ayecode-connect' ), |
|
| 552 | - 'triangle-asymmetrical' => __( 'Triangle Asymmetrical', 'ayecode-connect' ), |
|
| 553 | - 'tilt' => __( 'Tilt', 'ayecode-connect' ), |
|
| 554 | - 'opacity-tilt' => __( 'Opacity Tilt', 'ayecode-connect' ), |
|
| 555 | - 'opacity-fan' => __( 'Opacity Fan', 'ayecode-connect' ), |
|
| 556 | - 'curve' => __( 'Curve', 'ayecode-connect' ), |
|
| 557 | - 'curve-asymmetrical' => __( 'Curve Asymmetrical', 'ayecode-connect' ), |
|
| 558 | - 'waves' => __( 'Waves', 'ayecode-connect' ), |
|
| 559 | - 'wave-brush' => __( 'Wave Brush', 'ayecode-connect' ), |
|
| 560 | - 'waves-pattern' => __( 'Waves Pattern', 'ayecode-connect' ), |
|
| 561 | - 'arrow' => __( 'Arrow', 'ayecode-connect' ), |
|
| 562 | - 'split' => __( 'Split', 'ayecode-connect' ), |
|
| 563 | - 'book' => __( 'Book', 'ayecode-connect' ), |
|
| 564 | - ); |
|
| 565 | - |
|
| 566 | - $defaults = array( |
|
| 567 | - 'type' => 'select', |
|
| 568 | - 'title' => __( 'Type', 'ayecode-connect' ), |
|
| 569 | - 'options' => $options, |
|
| 570 | - 'default' => '', |
|
| 571 | - 'desc_tip' => true, |
|
| 572 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 573 | - ); |
|
| 574 | - |
|
| 575 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 576 | - |
|
| 577 | - $input[ $type . '_notice' ] = array( |
|
| 578 | - 'type' => 'notice', |
|
| 579 | - 'desc' => __( 'Parent element must be position `relative`', 'ayecode-connect' ), |
|
| 580 | - 'status' => 'warning', |
|
| 581 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 582 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 583 | - ); |
|
| 584 | - |
|
| 585 | - $input[ $type . '_position' ] = wp_parse_args( |
|
| 586 | - $overwrite_color, |
|
| 587 | - array( |
|
| 588 | - 'type' => 'select', |
|
| 589 | - 'title' => __( 'Position', 'ayecode-connect' ), |
|
| 590 | - 'options' => array( |
|
| 591 | - 'top' => __( 'Top', 'ayecode-connect' ), |
|
| 592 | - 'bottom' => __( 'Bottom', 'ayecode-connect' ), |
|
| 593 | - ), |
|
| 594 | - 'desc_tip' => true, |
|
| 595 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 596 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 597 | - ) |
|
| 598 | - ); |
|
| 599 | - |
|
| 600 | - $options = array( |
|
| 601 | - '' => __( 'None', 'ayecode-connect' ), |
|
| 602 | - 'transparent' => __( 'Transparent', 'ayecode-connect' ), |
|
| 603 | - ) + sd_aui_colors() |
|
| 604 | - + array( |
|
| 605 | - 'custom-color' => __( 'Custom Color', 'ayecode-connect' ), |
|
| 606 | - ); |
|
| 607 | - |
|
| 608 | - $input[ $type . '_color' ] = wp_parse_args( |
|
| 609 | - $overwrite_color, |
|
| 610 | - array( |
|
| 611 | - 'type' => 'select', |
|
| 612 | - 'title' => __( 'Color', 'ayecode-connect' ), |
|
| 613 | - 'options' => $options, |
|
| 614 | - 'desc_tip' => true, |
|
| 615 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 616 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 617 | - ) |
|
| 618 | - ); |
|
| 619 | - |
|
| 620 | - $input[ $type . '_custom_color' ] = wp_parse_args( |
|
| 621 | - $overwrite_color, |
|
| 622 | - array( |
|
| 623 | - 'type' => 'color', |
|
| 624 | - 'title' => __( 'Custom color', 'ayecode-connect' ), |
|
| 625 | - 'placeholder' => '', |
|
| 626 | - 'default' => '#0073aa', |
|
| 627 | - 'desc_tip' => true, |
|
| 628 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 629 | - 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""', |
|
| 630 | - ) |
|
| 631 | - ); |
|
| 632 | - |
|
| 633 | - $input[ $type . '_width' ] = wp_parse_args( |
|
| 634 | - $overwrite_gradient, |
|
| 635 | - array( |
|
| 636 | - 'type' => 'range', |
|
| 637 | - 'title' => __( 'Width', 'ayecode-connect' ), |
|
| 638 | - 'placeholder' => '', |
|
| 639 | - 'default' => '200', |
|
| 640 | - 'desc_tip' => true, |
|
| 641 | - 'custom_attributes' => array( |
|
| 642 | - 'min' => 100, |
|
| 643 | - 'max' => 300, |
|
| 644 | - ), |
|
| 645 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 646 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 647 | - ) |
|
| 648 | - ); |
|
| 649 | - |
|
| 650 | - $input[ $type . '_height' ] = array( |
|
| 651 | - 'type' => 'range', |
|
| 652 | - 'title' => __( 'Height', 'ayecode-connect' ), |
|
| 653 | - 'default' => '100', |
|
| 654 | - 'desc_tip' => true, |
|
| 655 | - 'custom_attributes' => array( |
|
| 656 | - 'min' => 0, |
|
| 657 | - 'max' => 500, |
|
| 658 | - ), |
|
| 659 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 660 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 661 | - ); |
|
| 662 | - |
|
| 663 | - $requires = array( |
|
| 664 | - 'mountains' => array( 'flip' ), |
|
| 665 | - 'drops' => array( 'flip', 'invert' ), |
|
| 666 | - 'clouds' => array( 'flip', 'invert' ), |
|
| 667 | - 'zigzag' => array(), |
|
| 668 | - 'pyramids' => array( 'flip', 'invert' ), |
|
| 669 | - 'triangle' => array( 'invert' ), |
|
| 670 | - 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 671 | - 'tilt' => array( 'flip' ), |
|
| 672 | - 'opacity-tilt' => array( 'flip' ), |
|
| 673 | - 'opacity-fan' => array(), |
|
| 674 | - 'curve' => array( 'invert' ), |
|
| 675 | - 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 676 | - 'waves' => array( 'flip', 'invert' ), |
|
| 677 | - 'wave-brush' => array( 'flip' ), |
|
| 678 | - 'waves-pattern' => array( 'flip' ), |
|
| 679 | - 'arrow' => array( 'invert' ), |
|
| 680 | - 'split' => array( 'invert' ), |
|
| 681 | - 'book' => array( 'invert' ), |
|
| 682 | - ); |
|
| 683 | - |
|
| 684 | - $input[ $type . '_flip' ] = array( |
|
| 685 | - 'type' => 'checkbox', |
|
| 686 | - 'title' => __( 'Flip', 'ayecode-connect' ), |
|
| 687 | - 'default' => '', |
|
| 688 | - 'desc_tip' => true, |
|
| 689 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 690 | - 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ), |
|
| 691 | - ); |
|
| 692 | - |
|
| 693 | - $input[ $type . '_invert' ] = array( |
|
| 694 | - 'type' => 'checkbox', |
|
| 695 | - 'title' => __( 'Invert', 'ayecode-connect' ), |
|
| 696 | - 'default' => '', |
|
| 697 | - 'desc_tip' => true, |
|
| 698 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 699 | - 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ), |
|
| 700 | - ); |
|
| 701 | - |
|
| 702 | - $input[ $type . '_btf' ] = array( |
|
| 703 | - 'type' => 'checkbox', |
|
| 704 | - 'title' => __( 'Bring to front', 'ayecode-connect' ), |
|
| 705 | - 'default' => '', |
|
| 706 | - 'desc_tip' => true, |
|
| 707 | - 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 708 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 709 | - |
|
| 710 | - ); |
|
| 711 | - |
|
| 712 | - return $input; |
|
| 544 | + $options = array( |
|
| 545 | + '' => __( 'None', 'ayecode-connect' ), |
|
| 546 | + 'mountains' => __( 'Mountains', 'ayecode-connect' ), |
|
| 547 | + 'drops' => __( 'Drops', 'ayecode-connect' ), |
|
| 548 | + 'clouds' => __( 'Clouds', 'ayecode-connect' ), |
|
| 549 | + 'zigzag' => __( 'Zigzag', 'ayecode-connect' ), |
|
| 550 | + 'pyramids' => __( 'Pyramids', 'ayecode-connect' ), |
|
| 551 | + 'triangle' => __( 'Triangle', 'ayecode-connect' ), |
|
| 552 | + 'triangle-asymmetrical' => __( 'Triangle Asymmetrical', 'ayecode-connect' ), |
|
| 553 | + 'tilt' => __( 'Tilt', 'ayecode-connect' ), |
|
| 554 | + 'opacity-tilt' => __( 'Opacity Tilt', 'ayecode-connect' ), |
|
| 555 | + 'opacity-fan' => __( 'Opacity Fan', 'ayecode-connect' ), |
|
| 556 | + 'curve' => __( 'Curve', 'ayecode-connect' ), |
|
| 557 | + 'curve-asymmetrical' => __( 'Curve Asymmetrical', 'ayecode-connect' ), |
|
| 558 | + 'waves' => __( 'Waves', 'ayecode-connect' ), |
|
| 559 | + 'wave-brush' => __( 'Wave Brush', 'ayecode-connect' ), |
|
| 560 | + 'waves-pattern' => __( 'Waves Pattern', 'ayecode-connect' ), |
|
| 561 | + 'arrow' => __( 'Arrow', 'ayecode-connect' ), |
|
| 562 | + 'split' => __( 'Split', 'ayecode-connect' ), |
|
| 563 | + 'book' => __( 'Book', 'ayecode-connect' ), |
|
| 564 | + ); |
|
| 565 | + |
|
| 566 | + $defaults = array( |
|
| 567 | + 'type' => 'select', |
|
| 568 | + 'title' => __( 'Type', 'ayecode-connect' ), |
|
| 569 | + 'options' => $options, |
|
| 570 | + 'default' => '', |
|
| 571 | + 'desc_tip' => true, |
|
| 572 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 573 | + ); |
|
| 574 | + |
|
| 575 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 576 | + |
|
| 577 | + $input[ $type . '_notice' ] = array( |
|
| 578 | + 'type' => 'notice', |
|
| 579 | + 'desc' => __( 'Parent element must be position `relative`', 'ayecode-connect' ), |
|
| 580 | + 'status' => 'warning', |
|
| 581 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 582 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 583 | + ); |
|
| 584 | + |
|
| 585 | + $input[ $type . '_position' ] = wp_parse_args( |
|
| 586 | + $overwrite_color, |
|
| 587 | + array( |
|
| 588 | + 'type' => 'select', |
|
| 589 | + 'title' => __( 'Position', 'ayecode-connect' ), |
|
| 590 | + 'options' => array( |
|
| 591 | + 'top' => __( 'Top', 'ayecode-connect' ), |
|
| 592 | + 'bottom' => __( 'Bottom', 'ayecode-connect' ), |
|
| 593 | + ), |
|
| 594 | + 'desc_tip' => true, |
|
| 595 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 596 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 597 | + ) |
|
| 598 | + ); |
|
| 599 | + |
|
| 600 | + $options = array( |
|
| 601 | + '' => __( 'None', 'ayecode-connect' ), |
|
| 602 | + 'transparent' => __( 'Transparent', 'ayecode-connect' ), |
|
| 603 | + ) + sd_aui_colors() |
|
| 604 | + + array( |
|
| 605 | + 'custom-color' => __( 'Custom Color', 'ayecode-connect' ), |
|
| 606 | + ); |
|
| 607 | + |
|
| 608 | + $input[ $type . '_color' ] = wp_parse_args( |
|
| 609 | + $overwrite_color, |
|
| 610 | + array( |
|
| 611 | + 'type' => 'select', |
|
| 612 | + 'title' => __( 'Color', 'ayecode-connect' ), |
|
| 613 | + 'options' => $options, |
|
| 614 | + 'desc_tip' => true, |
|
| 615 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 616 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 617 | + ) |
|
| 618 | + ); |
|
| 619 | + |
|
| 620 | + $input[ $type . '_custom_color' ] = wp_parse_args( |
|
| 621 | + $overwrite_color, |
|
| 622 | + array( |
|
| 623 | + 'type' => 'color', |
|
| 624 | + 'title' => __( 'Custom color', 'ayecode-connect' ), |
|
| 625 | + 'placeholder' => '', |
|
| 626 | + 'default' => '#0073aa', |
|
| 627 | + 'desc_tip' => true, |
|
| 628 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 629 | + 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""', |
|
| 630 | + ) |
|
| 631 | + ); |
|
| 632 | + |
|
| 633 | + $input[ $type . '_width' ] = wp_parse_args( |
|
| 634 | + $overwrite_gradient, |
|
| 635 | + array( |
|
| 636 | + 'type' => 'range', |
|
| 637 | + 'title' => __( 'Width', 'ayecode-connect' ), |
|
| 638 | + 'placeholder' => '', |
|
| 639 | + 'default' => '200', |
|
| 640 | + 'desc_tip' => true, |
|
| 641 | + 'custom_attributes' => array( |
|
| 642 | + 'min' => 100, |
|
| 643 | + 'max' => 300, |
|
| 644 | + ), |
|
| 645 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 646 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 647 | + ) |
|
| 648 | + ); |
|
| 649 | + |
|
| 650 | + $input[ $type . '_height' ] = array( |
|
| 651 | + 'type' => 'range', |
|
| 652 | + 'title' => __( 'Height', 'ayecode-connect' ), |
|
| 653 | + 'default' => '100', |
|
| 654 | + 'desc_tip' => true, |
|
| 655 | + 'custom_attributes' => array( |
|
| 656 | + 'min' => 0, |
|
| 657 | + 'max' => 500, |
|
| 658 | + ), |
|
| 659 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 660 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 661 | + ); |
|
| 662 | + |
|
| 663 | + $requires = array( |
|
| 664 | + 'mountains' => array( 'flip' ), |
|
| 665 | + 'drops' => array( 'flip', 'invert' ), |
|
| 666 | + 'clouds' => array( 'flip', 'invert' ), |
|
| 667 | + 'zigzag' => array(), |
|
| 668 | + 'pyramids' => array( 'flip', 'invert' ), |
|
| 669 | + 'triangle' => array( 'invert' ), |
|
| 670 | + 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 671 | + 'tilt' => array( 'flip' ), |
|
| 672 | + 'opacity-tilt' => array( 'flip' ), |
|
| 673 | + 'opacity-fan' => array(), |
|
| 674 | + 'curve' => array( 'invert' ), |
|
| 675 | + 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 676 | + 'waves' => array( 'flip', 'invert' ), |
|
| 677 | + 'wave-brush' => array( 'flip' ), |
|
| 678 | + 'waves-pattern' => array( 'flip' ), |
|
| 679 | + 'arrow' => array( 'invert' ), |
|
| 680 | + 'split' => array( 'invert' ), |
|
| 681 | + 'book' => array( 'invert' ), |
|
| 682 | + ); |
|
| 683 | + |
|
| 684 | + $input[ $type . '_flip' ] = array( |
|
| 685 | + 'type' => 'checkbox', |
|
| 686 | + 'title' => __( 'Flip', 'ayecode-connect' ), |
|
| 687 | + 'default' => '', |
|
| 688 | + 'desc_tip' => true, |
|
| 689 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 690 | + 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ), |
|
| 691 | + ); |
|
| 692 | + |
|
| 693 | + $input[ $type . '_invert' ] = array( |
|
| 694 | + 'type' => 'checkbox', |
|
| 695 | + 'title' => __( 'Invert', 'ayecode-connect' ), |
|
| 696 | + 'default' => '', |
|
| 697 | + 'desc_tip' => true, |
|
| 698 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 699 | + 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ), |
|
| 700 | + ); |
|
| 701 | + |
|
| 702 | + $input[ $type . '_btf' ] = array( |
|
| 703 | + 'type' => 'checkbox', |
|
| 704 | + 'title' => __( 'Bring to front', 'ayecode-connect' ), |
|
| 705 | + 'default' => '', |
|
| 706 | + 'desc_tip' => true, |
|
| 707 | + 'group' => __( 'Shape Divider', 'ayecode-connect' ), |
|
| 708 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 709 | + |
|
| 710 | + ); |
|
| 711 | + |
|
| 712 | + return $input; |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | /** |
@@ -722,22 +722,22 @@ discard block |
||
| 722 | 722 | * @return string |
| 723 | 723 | */ |
| 724 | 724 | function sd_get_element_require_string( $args, $key, $type ) { |
| 725 | - $output = ''; |
|
| 726 | - $requires = array(); |
|
| 725 | + $output = ''; |
|
| 726 | + $requires = array(); |
|
| 727 | 727 | |
| 728 | - if ( ! empty( $args ) ) { |
|
| 729 | - foreach ( $args as $t => $k ) { |
|
| 730 | - if ( in_array( $key, $k ) ) { |
|
| 731 | - $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 732 | - } |
|
| 733 | - } |
|
| 728 | + if ( ! empty( $args ) ) { |
|
| 729 | + foreach ( $args as $t => $k ) { |
|
| 730 | + if ( in_array( $key, $k ) ) { |
|
| 731 | + $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 732 | + } |
|
| 733 | + } |
|
| 734 | 734 | |
| 735 | - if ( ! empty( $requires ) ) { |
|
| 736 | - $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 737 | - } |
|
| 738 | - } |
|
| 735 | + if ( ! empty( $requires ) ) { |
|
| 736 | + $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 737 | + } |
|
| 738 | + } |
|
| 739 | 739 | |
| 740 | - return $output; |
|
| 740 | + return $output; |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | /** |
@@ -749,41 +749,41 @@ discard block |
||
| 749 | 749 | * @return array |
| 750 | 750 | */ |
| 751 | 751 | function sd_get_text_color_input( $type = 'text_color', $overwrite = array(), $has_custom = false ) { |
| 752 | - $options = array( |
|
| 753 | - '' => __( 'None', 'ayecode-connect' ), |
|
| 754 | - ) + sd_aui_colors(); |
|
| 752 | + $options = array( |
|
| 753 | + '' => __( 'None', 'ayecode-connect' ), |
|
| 754 | + ) + sd_aui_colors(); |
|
| 755 | 755 | |
| 756 | - if ( $has_custom ) { |
|
| 757 | - $options['custom'] = __( 'Custom color', 'ayecode-connect' ); |
|
| 758 | - } |
|
| 756 | + if ( $has_custom ) { |
|
| 757 | + $options['custom'] = __( 'Custom color', 'ayecode-connect' ); |
|
| 758 | + } |
|
| 759 | 759 | |
| 760 | - $defaults = array( |
|
| 761 | - 'type' => 'select', |
|
| 762 | - 'title' => __( 'Text color', 'ayecode-connect' ), |
|
| 763 | - 'options' => $options, |
|
| 764 | - 'default' => '', |
|
| 765 | - 'desc_tip' => true, |
|
| 766 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 767 | - ); |
|
| 760 | + $defaults = array( |
|
| 761 | + 'type' => 'select', |
|
| 762 | + 'title' => __( 'Text color', 'ayecode-connect' ), |
|
| 763 | + 'options' => $options, |
|
| 764 | + 'default' => '', |
|
| 765 | + 'desc_tip' => true, |
|
| 766 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 767 | + ); |
|
| 768 | 768 | |
| 769 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 769 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 770 | 770 | |
| 771 | - return $input; |
|
| 771 | + return $input; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | function sd_get_text_color_input_group( $type = 'text_color', $overwrite = array(), $overwrite_custom = array() ) { |
| 775 | - $inputs = array(); |
|
| 775 | + $inputs = array(); |
|
| 776 | 776 | |
| 777 | - if ( $overwrite !== false ) { |
|
| 778 | - $inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true ); |
|
| 779 | - } |
|
| 777 | + if ( $overwrite !== false ) { |
|
| 778 | + $inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true ); |
|
| 779 | + } |
|
| 780 | 780 | |
| 781 | - if ( $overwrite_custom !== false ) { |
|
| 782 | - $custom = $type . '_custom'; |
|
| 783 | - $inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type ); |
|
| 784 | - } |
|
| 781 | + if ( $overwrite_custom !== false ) { |
|
| 782 | + $custom = $type . '_custom'; |
|
| 783 | + $inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type ); |
|
| 784 | + } |
|
| 785 | 785 | |
| 786 | - return $inputs; |
|
| 786 | + return $inputs; |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | /** |
@@ -796,22 +796,22 @@ discard block |
||
| 796 | 796 | */ |
| 797 | 797 | function sd_get_custom_color_input( $type = 'color_custom', $overwrite = array(), $parent_type = '' ) { |
| 798 | 798 | |
| 799 | - $defaults = array( |
|
| 800 | - 'type' => 'color', |
|
| 801 | - 'title' => __( 'Custom color', 'ayecode-connect' ), |
|
| 802 | - 'default' => '', |
|
| 803 | - 'placeholder' => '', |
|
| 804 | - 'desc_tip' => true, |
|
| 805 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 806 | - ); |
|
| 799 | + $defaults = array( |
|
| 800 | + 'type' => 'color', |
|
| 801 | + 'title' => __( 'Custom color', 'ayecode-connect' ), |
|
| 802 | + 'default' => '', |
|
| 803 | + 'placeholder' => '', |
|
| 804 | + 'desc_tip' => true, |
|
| 805 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 806 | + ); |
|
| 807 | 807 | |
| 808 | - if ( $parent_type ) { |
|
| 809 | - $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 810 | - } |
|
| 808 | + if ( $parent_type ) { |
|
| 809 | + $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 810 | + } |
|
| 811 | 811 | |
| 812 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 812 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 813 | 813 | |
| 814 | - return $input; |
|
| 814 | + return $input; |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | /** |
@@ -824,44 +824,44 @@ discard block |
||
| 824 | 824 | */ |
| 825 | 825 | function sd_get_col_input( $type = 'col', $overwrite = array() ) { |
| 826 | 826 | |
| 827 | - $device_size = ''; |
|
| 828 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 829 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 830 | - $device_size = '-md'; |
|
| 831 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 832 | - $device_size = '-lg'; |
|
| 833 | - } |
|
| 834 | - } |
|
| 835 | - $options = array( |
|
| 836 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 837 | - 'auto' => __( 'auto', 'ayecode-connect' ), |
|
| 838 | - '1' => '1/12', |
|
| 839 | - '2' => '2/12', |
|
| 840 | - '3' => '3/12', |
|
| 841 | - '4' => '4/12', |
|
| 842 | - '5' => '5/12', |
|
| 843 | - '6' => '6/12', |
|
| 844 | - '7' => '7/12', |
|
| 845 | - '8' => '8/12', |
|
| 846 | - '9' => '9/12', |
|
| 847 | - '10' => '10/12', |
|
| 848 | - '11' => '11/12', |
|
| 849 | - '12' => '12/12', |
|
| 850 | - ); |
|
| 851 | - |
|
| 852 | - $defaults = array( |
|
| 853 | - 'type' => 'select', |
|
| 854 | - 'title' => __( 'Column width', 'ayecode-connect' ), |
|
| 855 | - 'options' => $options, |
|
| 856 | - 'default' => '', |
|
| 857 | - 'desc_tip' => true, |
|
| 858 | - 'group' => __( 'Container', 'ayecode-connect' ), |
|
| 859 | - 'element_require' => '[%container%]=="col"', |
|
| 860 | - ); |
|
| 861 | - |
|
| 862 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 863 | - |
|
| 864 | - return $input; |
|
| 827 | + $device_size = ''; |
|
| 828 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 829 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 830 | + $device_size = '-md'; |
|
| 831 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 832 | + $device_size = '-lg'; |
|
| 833 | + } |
|
| 834 | + } |
|
| 835 | + $options = array( |
|
| 836 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 837 | + 'auto' => __( 'auto', 'ayecode-connect' ), |
|
| 838 | + '1' => '1/12', |
|
| 839 | + '2' => '2/12', |
|
| 840 | + '3' => '3/12', |
|
| 841 | + '4' => '4/12', |
|
| 842 | + '5' => '5/12', |
|
| 843 | + '6' => '6/12', |
|
| 844 | + '7' => '7/12', |
|
| 845 | + '8' => '8/12', |
|
| 846 | + '9' => '9/12', |
|
| 847 | + '10' => '10/12', |
|
| 848 | + '11' => '11/12', |
|
| 849 | + '12' => '12/12', |
|
| 850 | + ); |
|
| 851 | + |
|
| 852 | + $defaults = array( |
|
| 853 | + 'type' => 'select', |
|
| 854 | + 'title' => __( 'Column width', 'ayecode-connect' ), |
|
| 855 | + 'options' => $options, |
|
| 856 | + 'default' => '', |
|
| 857 | + 'desc_tip' => true, |
|
| 858 | + 'group' => __( 'Container', 'ayecode-connect' ), |
|
| 859 | + 'element_require' => '[%container%]=="col"', |
|
| 860 | + ); |
|
| 861 | + |
|
| 862 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 863 | + |
|
| 864 | + return $input; |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | /** |
@@ -874,37 +874,37 @@ discard block |
||
| 874 | 874 | */ |
| 875 | 875 | function sd_get_row_cols_input( $type = 'row_cols', $overwrite = array() ) { |
| 876 | 876 | |
| 877 | - $device_size = ''; |
|
| 878 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 879 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 880 | - $device_size = '-md'; |
|
| 881 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 882 | - $device_size = '-lg'; |
|
| 883 | - } |
|
| 884 | - } |
|
| 885 | - $options = array( |
|
| 886 | - '' => __( 'auto', 'ayecode-connect' ), |
|
| 887 | - '1' => '1', |
|
| 888 | - '2' => '2', |
|
| 889 | - '3' => '3', |
|
| 890 | - '4' => '4', |
|
| 891 | - '5' => '5', |
|
| 892 | - '6' => '6', |
|
| 893 | - ); |
|
| 894 | - |
|
| 895 | - $defaults = array( |
|
| 896 | - 'type' => 'select', |
|
| 897 | - 'title' => __( 'Row columns', 'ayecode-connect' ), |
|
| 898 | - 'options' => $options, |
|
| 899 | - 'default' => '', |
|
| 900 | - 'desc_tip' => true, |
|
| 901 | - 'group' => __( 'Container', 'ayecode-connect' ), |
|
| 902 | - 'element_require' => '[%container%]=="row"', |
|
| 903 | - ); |
|
| 904 | - |
|
| 905 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 906 | - |
|
| 907 | - return $input; |
|
| 877 | + $device_size = ''; |
|
| 878 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 879 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 880 | + $device_size = '-md'; |
|
| 881 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 882 | + $device_size = '-lg'; |
|
| 883 | + } |
|
| 884 | + } |
|
| 885 | + $options = array( |
|
| 886 | + '' => __( 'auto', 'ayecode-connect' ), |
|
| 887 | + '1' => '1', |
|
| 888 | + '2' => '2', |
|
| 889 | + '3' => '3', |
|
| 890 | + '4' => '4', |
|
| 891 | + '5' => '5', |
|
| 892 | + '6' => '6', |
|
| 893 | + ); |
|
| 894 | + |
|
| 895 | + $defaults = array( |
|
| 896 | + 'type' => 'select', |
|
| 897 | + 'title' => __( 'Row columns', 'ayecode-connect' ), |
|
| 898 | + 'options' => $options, |
|
| 899 | + 'default' => '', |
|
| 900 | + 'desc_tip' => true, |
|
| 901 | + 'group' => __( 'Container', 'ayecode-connect' ), |
|
| 902 | + 'element_require' => '[%container%]=="row"', |
|
| 903 | + ); |
|
| 904 | + |
|
| 905 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 906 | + |
|
| 907 | + return $input; |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | /** |
@@ -917,33 +917,33 @@ discard block |
||
| 917 | 917 | */ |
| 918 | 918 | function sd_get_text_align_input( $type = 'text_align', $overwrite = array() ) { |
| 919 | 919 | |
| 920 | - $device_size = ''; |
|
| 921 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 922 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 923 | - $device_size = '-md'; |
|
| 924 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 925 | - $device_size = '-lg'; |
|
| 926 | - } |
|
| 927 | - } |
|
| 928 | - $options = array( |
|
| 929 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 930 | - 'text' . $device_size . '-left' => __( 'Left', 'ayecode-connect' ), |
|
| 931 | - 'text' . $device_size . '-right' => __( 'Right', 'ayecode-connect' ), |
|
| 932 | - 'text' . $device_size . '-center' => __( 'Center', 'ayecode-connect' ), |
|
| 933 | - ); |
|
| 934 | - |
|
| 935 | - $defaults = array( |
|
| 936 | - 'type' => 'select', |
|
| 937 | - 'title' => __( 'Text align', 'ayecode-connect' ), |
|
| 938 | - 'options' => $options, |
|
| 939 | - 'default' => '', |
|
| 940 | - 'desc_tip' => true, |
|
| 941 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 942 | - ); |
|
| 943 | - |
|
| 944 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 945 | - |
|
| 946 | - return $input; |
|
| 920 | + $device_size = ''; |
|
| 921 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 922 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 923 | + $device_size = '-md'; |
|
| 924 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 925 | + $device_size = '-lg'; |
|
| 926 | + } |
|
| 927 | + } |
|
| 928 | + $options = array( |
|
| 929 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 930 | + 'text' . $device_size . '-left' => __( 'Left', 'ayecode-connect' ), |
|
| 931 | + 'text' . $device_size . '-right' => __( 'Right', 'ayecode-connect' ), |
|
| 932 | + 'text' . $device_size . '-center' => __( 'Center', 'ayecode-connect' ), |
|
| 933 | + ); |
|
| 934 | + |
|
| 935 | + $defaults = array( |
|
| 936 | + 'type' => 'select', |
|
| 937 | + 'title' => __( 'Text align', 'ayecode-connect' ), |
|
| 938 | + 'options' => $options, |
|
| 939 | + 'default' => '', |
|
| 940 | + 'desc_tip' => true, |
|
| 941 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 942 | + ); |
|
| 943 | + |
|
| 944 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 945 | + |
|
| 946 | + return $input; |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | /** |
@@ -956,39 +956,39 @@ discard block |
||
| 956 | 956 | */ |
| 957 | 957 | function sd_get_display_input( $type = 'display', $overwrite = array() ) { |
| 958 | 958 | |
| 959 | - $device_size = ''; |
|
| 960 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 961 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 962 | - $device_size = '-md'; |
|
| 963 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 964 | - $device_size = '-lg'; |
|
| 965 | - } |
|
| 966 | - } |
|
| 967 | - $options = array( |
|
| 968 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 969 | - 'd' . $device_size . '-none' => 'none', |
|
| 970 | - 'd' . $device_size . '-inline' => 'inline', |
|
| 971 | - 'd' . $device_size . '-inline-block' => 'inline-block', |
|
| 972 | - 'd' . $device_size . '-block' => 'block', |
|
| 973 | - 'd' . $device_size . '-table' => 'table', |
|
| 974 | - 'd' . $device_size . '-table-cell' => 'table-cell', |
|
| 975 | - 'd' . $device_size . '-table-row' => 'table-row', |
|
| 976 | - 'd' . $device_size . '-flex' => 'flex', |
|
| 977 | - 'd' . $device_size . '-inline-flex' => 'inline-flex', |
|
| 978 | - ); |
|
| 979 | - |
|
| 980 | - $defaults = array( |
|
| 981 | - 'type' => 'select', |
|
| 982 | - 'title' => __( 'Display', 'ayecode-connect' ), |
|
| 983 | - 'options' => $options, |
|
| 984 | - 'default' => '', |
|
| 985 | - 'desc_tip' => true, |
|
| 986 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 987 | - ); |
|
| 988 | - |
|
| 989 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 990 | - |
|
| 991 | - return $input; |
|
| 959 | + $device_size = ''; |
|
| 960 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 961 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 962 | + $device_size = '-md'; |
|
| 963 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 964 | + $device_size = '-lg'; |
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | + $options = array( |
|
| 968 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 969 | + 'd' . $device_size . '-none' => 'none', |
|
| 970 | + 'd' . $device_size . '-inline' => 'inline', |
|
| 971 | + 'd' . $device_size . '-inline-block' => 'inline-block', |
|
| 972 | + 'd' . $device_size . '-block' => 'block', |
|
| 973 | + 'd' . $device_size . '-table' => 'table', |
|
| 974 | + 'd' . $device_size . '-table-cell' => 'table-cell', |
|
| 975 | + 'd' . $device_size . '-table-row' => 'table-row', |
|
| 976 | + 'd' . $device_size . '-flex' => 'flex', |
|
| 977 | + 'd' . $device_size . '-inline-flex' => 'inline-flex', |
|
| 978 | + ); |
|
| 979 | + |
|
| 980 | + $defaults = array( |
|
| 981 | + 'type' => 'select', |
|
| 982 | + 'title' => __( 'Display', 'ayecode-connect' ), |
|
| 983 | + 'options' => $options, |
|
| 984 | + 'default' => '', |
|
| 985 | + 'desc_tip' => true, |
|
| 986 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 987 | + ); |
|
| 988 | + |
|
| 989 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 990 | + |
|
| 991 | + return $input; |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | /** |
@@ -1001,17 +1001,17 @@ discard block |
||
| 1001 | 1001 | */ |
| 1002 | 1002 | function sd_get_text_justify_input( $type = 'text_justify', $overwrite = array() ) { |
| 1003 | 1003 | |
| 1004 | - $defaults = array( |
|
| 1005 | - 'type' => 'checkbox', |
|
| 1006 | - 'title' => __( 'Text justify', 'ayecode-connect' ), |
|
| 1007 | - 'default' => '', |
|
| 1008 | - 'desc_tip' => true, |
|
| 1009 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1010 | - ); |
|
| 1004 | + $defaults = array( |
|
| 1005 | + 'type' => 'checkbox', |
|
| 1006 | + 'title' => __( 'Text justify', 'ayecode-connect' ), |
|
| 1007 | + 'default' => '', |
|
| 1008 | + 'desc_tip' => true, |
|
| 1009 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1010 | + ); |
|
| 1011 | 1011 | |
| 1012 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1012 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1013 | 1013 | |
| 1014 | - return $input; |
|
| 1014 | + return $input; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | /** |
@@ -1024,72 +1024,72 @@ discard block |
||
| 1024 | 1024 | * @return array |
| 1025 | 1025 | */ |
| 1026 | 1026 | function sd_aui_colors( $include_branding = false, $include_outlines = false, $outline_button_only_text = false, $include_translucent = false ) { |
| 1027 | - $theme_colors = array(); |
|
| 1028 | - |
|
| 1029 | - $theme_colors['primary'] = __( 'Primary', 'ayecode-connect' ); |
|
| 1030 | - $theme_colors['secondary'] = __( 'Secondary', 'ayecode-connect' ); |
|
| 1031 | - $theme_colors['success'] = __( 'Success', 'ayecode-connect' ); |
|
| 1032 | - $theme_colors['danger'] = __( 'Danger', 'ayecode-connect' ); |
|
| 1033 | - $theme_colors['warning'] = __( 'Warning', 'ayecode-connect' ); |
|
| 1034 | - $theme_colors['info'] = __( 'Info', 'ayecode-connect' ); |
|
| 1035 | - $theme_colors['light'] = __( 'Light', 'ayecode-connect' ); |
|
| 1036 | - $theme_colors['dark'] = __( 'Dark', 'ayecode-connect' ); |
|
| 1037 | - $theme_colors['black'] = __( 'Black', 'ayecode-connect' ); |
|
| 1038 | - $theme_colors['white'] = __( 'White', 'ayecode-connect' ); |
|
| 1039 | - $theme_colors['purple'] = __( 'Purple', 'ayecode-connect' ); |
|
| 1040 | - $theme_colors['salmon'] = __( 'Salmon', 'ayecode-connect' ); |
|
| 1041 | - $theme_colors['cyan'] = __( 'Cyan', 'ayecode-connect' ); |
|
| 1042 | - $theme_colors['gray'] = __( 'Gray', 'ayecode-connect' ); |
|
| 1043 | - $theme_colors['muted'] = __( 'Muted', 'ayecode-connect' ); |
|
| 1044 | - $theme_colors['gray-dark'] = __( 'Gray dark', 'ayecode-connect' ); |
|
| 1045 | - $theme_colors['indigo'] = __( 'Indigo', 'ayecode-connect' ); |
|
| 1046 | - $theme_colors['orange'] = __( 'Orange', 'ayecode-connect' ); |
|
| 1047 | - |
|
| 1048 | - if ( $include_outlines ) { |
|
| 1049 | - $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'ayecode-connect' ) : ''; |
|
| 1050 | - $theme_colors['outline-primary'] = __( 'Primary outline', 'ayecode-connect' ) . $button_only; |
|
| 1051 | - $theme_colors['outline-secondary'] = __( 'Secondary outline', 'ayecode-connect' ) . $button_only; |
|
| 1052 | - $theme_colors['outline-success'] = __( 'Success outline', 'ayecode-connect' ) . $button_only; |
|
| 1053 | - $theme_colors['outline-danger'] = __( 'Danger outline', 'ayecode-connect' ) . $button_only; |
|
| 1054 | - $theme_colors['outline-warning'] = __( 'Warning outline', 'ayecode-connect' ) . $button_only; |
|
| 1055 | - $theme_colors['outline-info'] = __( 'Info outline', 'ayecode-connect' ) . $button_only; |
|
| 1056 | - $theme_colors['outline-light'] = __( 'Light outline', 'ayecode-connect' ) . $button_only; |
|
| 1057 | - $theme_colors['outline-dark'] = __( 'Dark outline', 'ayecode-connect' ) . $button_only; |
|
| 1058 | - $theme_colors['outline-white'] = __( 'White outline', 'ayecode-connect' ) . $button_only; |
|
| 1059 | - $theme_colors['outline-purple'] = __( 'Purple outline', 'ayecode-connect' ) . $button_only; |
|
| 1060 | - $theme_colors['outline-salmon'] = __( 'Salmon outline', 'ayecode-connect' ) . $button_only; |
|
| 1061 | - $theme_colors['outline-cyan'] = __( 'Cyan outline', 'ayecode-connect' ) . $button_only; |
|
| 1062 | - $theme_colors['outline-gray'] = __( 'Gray outline', 'ayecode-connect' ) . $button_only; |
|
| 1063 | - $theme_colors['outline-gray-dark'] = __( 'Gray dark outline', 'ayecode-connect' ) . $button_only; |
|
| 1064 | - $theme_colors['outline-indigo'] = __( 'Indigo outline', 'ayecode-connect' ) . $button_only; |
|
| 1065 | - $theme_colors['outline-orange'] = __( 'Orange outline', 'ayecode-connect' ) . $button_only; |
|
| 1066 | - } |
|
| 1067 | - |
|
| 1068 | - if ( $include_branding ) { |
|
| 1069 | - $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 1070 | - } |
|
| 1071 | - |
|
| 1072 | - if ( $include_translucent ) { |
|
| 1073 | - $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'ayecode-connect' ) : ''; |
|
| 1074 | - $theme_colors['translucent-primary'] = __( 'Primary translucent', 'ayecode-connect' ) . $button_only; |
|
| 1075 | - $theme_colors['translucent-secondary'] = __( 'Secondary translucent', 'ayecode-connect' ) . $button_only; |
|
| 1076 | - $theme_colors['translucent-success'] = __( 'Success translucent', 'ayecode-connect' ) . $button_only; |
|
| 1077 | - $theme_colors['translucent-danger'] = __( 'Danger translucent', 'ayecode-connect' ) . $button_only; |
|
| 1078 | - $theme_colors['translucent-warning'] = __( 'Warning translucent', 'ayecode-connect' ) . $button_only; |
|
| 1079 | - $theme_colors['translucent-info'] = __( 'Info translucent', 'ayecode-connect' ) . $button_only; |
|
| 1080 | - $theme_colors['translucent-light'] = __( 'Light translucent', 'ayecode-connect' ) . $button_only; |
|
| 1081 | - $theme_colors['translucent-dark'] = __( 'Dark translucent', 'ayecode-connect' ) . $button_only; |
|
| 1082 | - $theme_colors['translucent-white'] = __( 'White translucent', 'ayecode-connect' ) . $button_only; |
|
| 1083 | - $theme_colors['translucent-purple'] = __( 'Purple translucent', 'ayecode-connect' ) . $button_only; |
|
| 1084 | - $theme_colors['translucent-salmon'] = __( 'Salmon translucent', 'ayecode-connect' ) . $button_only; |
|
| 1085 | - $theme_colors['translucent-cyan'] = __( 'Cyan translucent', 'ayecode-connect' ) . $button_only; |
|
| 1086 | - $theme_colors['translucent-gray'] = __( 'Gray translucent', 'ayecode-connect' ) . $button_only; |
|
| 1087 | - $theme_colors['translucent-gray-dark'] = __( 'Gray dark translucent', 'ayecode-connect' ) . $button_only; |
|
| 1088 | - $theme_colors['translucent-indigo'] = __( 'Indigo translucent', 'ayecode-connect' ) . $button_only; |
|
| 1089 | - $theme_colors['translucent-orange'] = __( 'Orange translucent', 'ayecode-connect' ) . $button_only; |
|
| 1090 | - } |
|
| 1091 | - |
|
| 1092 | - return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding ); |
|
| 1027 | + $theme_colors = array(); |
|
| 1028 | + |
|
| 1029 | + $theme_colors['primary'] = __( 'Primary', 'ayecode-connect' ); |
|
| 1030 | + $theme_colors['secondary'] = __( 'Secondary', 'ayecode-connect' ); |
|
| 1031 | + $theme_colors['success'] = __( 'Success', 'ayecode-connect' ); |
|
| 1032 | + $theme_colors['danger'] = __( 'Danger', 'ayecode-connect' ); |
|
| 1033 | + $theme_colors['warning'] = __( 'Warning', 'ayecode-connect' ); |
|
| 1034 | + $theme_colors['info'] = __( 'Info', 'ayecode-connect' ); |
|
| 1035 | + $theme_colors['light'] = __( 'Light', 'ayecode-connect' ); |
|
| 1036 | + $theme_colors['dark'] = __( 'Dark', 'ayecode-connect' ); |
|
| 1037 | + $theme_colors['black'] = __( 'Black', 'ayecode-connect' ); |
|
| 1038 | + $theme_colors['white'] = __( 'White', 'ayecode-connect' ); |
|
| 1039 | + $theme_colors['purple'] = __( 'Purple', 'ayecode-connect' ); |
|
| 1040 | + $theme_colors['salmon'] = __( 'Salmon', 'ayecode-connect' ); |
|
| 1041 | + $theme_colors['cyan'] = __( 'Cyan', 'ayecode-connect' ); |
|
| 1042 | + $theme_colors['gray'] = __( 'Gray', 'ayecode-connect' ); |
|
| 1043 | + $theme_colors['muted'] = __( 'Muted', 'ayecode-connect' ); |
|
| 1044 | + $theme_colors['gray-dark'] = __( 'Gray dark', 'ayecode-connect' ); |
|
| 1045 | + $theme_colors['indigo'] = __( 'Indigo', 'ayecode-connect' ); |
|
| 1046 | + $theme_colors['orange'] = __( 'Orange', 'ayecode-connect' ); |
|
| 1047 | + |
|
| 1048 | + if ( $include_outlines ) { |
|
| 1049 | + $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'ayecode-connect' ) : ''; |
|
| 1050 | + $theme_colors['outline-primary'] = __( 'Primary outline', 'ayecode-connect' ) . $button_only; |
|
| 1051 | + $theme_colors['outline-secondary'] = __( 'Secondary outline', 'ayecode-connect' ) . $button_only; |
|
| 1052 | + $theme_colors['outline-success'] = __( 'Success outline', 'ayecode-connect' ) . $button_only; |
|
| 1053 | + $theme_colors['outline-danger'] = __( 'Danger outline', 'ayecode-connect' ) . $button_only; |
|
| 1054 | + $theme_colors['outline-warning'] = __( 'Warning outline', 'ayecode-connect' ) . $button_only; |
|
| 1055 | + $theme_colors['outline-info'] = __( 'Info outline', 'ayecode-connect' ) . $button_only; |
|
| 1056 | + $theme_colors['outline-light'] = __( 'Light outline', 'ayecode-connect' ) . $button_only; |
|
| 1057 | + $theme_colors['outline-dark'] = __( 'Dark outline', 'ayecode-connect' ) . $button_only; |
|
| 1058 | + $theme_colors['outline-white'] = __( 'White outline', 'ayecode-connect' ) . $button_only; |
|
| 1059 | + $theme_colors['outline-purple'] = __( 'Purple outline', 'ayecode-connect' ) . $button_only; |
|
| 1060 | + $theme_colors['outline-salmon'] = __( 'Salmon outline', 'ayecode-connect' ) . $button_only; |
|
| 1061 | + $theme_colors['outline-cyan'] = __( 'Cyan outline', 'ayecode-connect' ) . $button_only; |
|
| 1062 | + $theme_colors['outline-gray'] = __( 'Gray outline', 'ayecode-connect' ) . $button_only; |
|
| 1063 | + $theme_colors['outline-gray-dark'] = __( 'Gray dark outline', 'ayecode-connect' ) . $button_only; |
|
| 1064 | + $theme_colors['outline-indigo'] = __( 'Indigo outline', 'ayecode-connect' ) . $button_only; |
|
| 1065 | + $theme_colors['outline-orange'] = __( 'Orange outline', 'ayecode-connect' ) . $button_only; |
|
| 1066 | + } |
|
| 1067 | + |
|
| 1068 | + if ( $include_branding ) { |
|
| 1069 | + $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 1070 | + } |
|
| 1071 | + |
|
| 1072 | + if ( $include_translucent ) { |
|
| 1073 | + $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'ayecode-connect' ) : ''; |
|
| 1074 | + $theme_colors['translucent-primary'] = __( 'Primary translucent', 'ayecode-connect' ) . $button_only; |
|
| 1075 | + $theme_colors['translucent-secondary'] = __( 'Secondary translucent', 'ayecode-connect' ) . $button_only; |
|
| 1076 | + $theme_colors['translucent-success'] = __( 'Success translucent', 'ayecode-connect' ) . $button_only; |
|
| 1077 | + $theme_colors['translucent-danger'] = __( 'Danger translucent', 'ayecode-connect' ) . $button_only; |
|
| 1078 | + $theme_colors['translucent-warning'] = __( 'Warning translucent', 'ayecode-connect' ) . $button_only; |
|
| 1079 | + $theme_colors['translucent-info'] = __( 'Info translucent', 'ayecode-connect' ) . $button_only; |
|
| 1080 | + $theme_colors['translucent-light'] = __( 'Light translucent', 'ayecode-connect' ) . $button_only; |
|
| 1081 | + $theme_colors['translucent-dark'] = __( 'Dark translucent', 'ayecode-connect' ) . $button_only; |
|
| 1082 | + $theme_colors['translucent-white'] = __( 'White translucent', 'ayecode-connect' ) . $button_only; |
|
| 1083 | + $theme_colors['translucent-purple'] = __( 'Purple translucent', 'ayecode-connect' ) . $button_only; |
|
| 1084 | + $theme_colors['translucent-salmon'] = __( 'Salmon translucent', 'ayecode-connect' ) . $button_only; |
|
| 1085 | + $theme_colors['translucent-cyan'] = __( 'Cyan translucent', 'ayecode-connect' ) . $button_only; |
|
| 1086 | + $theme_colors['translucent-gray'] = __( 'Gray translucent', 'ayecode-connect' ) . $button_only; |
|
| 1087 | + $theme_colors['translucent-gray-dark'] = __( 'Gray dark translucent', 'ayecode-connect' ) . $button_only; |
|
| 1088 | + $theme_colors['translucent-indigo'] = __( 'Indigo translucent', 'ayecode-connect' ) . $button_only; |
|
| 1089 | + $theme_colors['translucent-orange'] = __( 'Orange translucent', 'ayecode-connect' ) . $button_only; |
|
| 1090 | + } |
|
| 1091 | + |
|
| 1092 | + return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding ); |
|
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | 1095 | /** |
@@ -1098,19 +1098,19 @@ discard block |
||
| 1098 | 1098 | * @return array |
| 1099 | 1099 | */ |
| 1100 | 1100 | function sd_aui_branding_colors() { |
| 1101 | - return array( |
|
| 1102 | - 'facebook' => __( 'Facebook', 'ayecode-connect' ), |
|
| 1103 | - 'twitter' => __( 'Twitter', 'ayecode-connect' ), |
|
| 1104 | - 'instagram' => __( 'Instagram', 'ayecode-connect' ), |
|
| 1105 | - 'linkedin' => __( 'Linkedin', 'ayecode-connect' ), |
|
| 1106 | - 'flickr' => __( 'Flickr', 'ayecode-connect' ), |
|
| 1107 | - 'github' => __( 'GitHub', 'ayecode-connect' ), |
|
| 1108 | - 'youtube' => __( 'YouTube', 'ayecode-connect' ), |
|
| 1109 | - 'wordpress' => __( 'WordPress', 'ayecode-connect' ), |
|
| 1110 | - 'google' => __( 'Google', 'ayecode-connect' ), |
|
| 1111 | - 'yahoo' => __( 'Yahoo', 'ayecode-connect' ), |
|
| 1112 | - 'vkontakte' => __( 'Vkontakte', 'ayecode-connect' ), |
|
| 1113 | - ); |
|
| 1101 | + return array( |
|
| 1102 | + 'facebook' => __( 'Facebook', 'ayecode-connect' ), |
|
| 1103 | + 'twitter' => __( 'Twitter', 'ayecode-connect' ), |
|
| 1104 | + 'instagram' => __( 'Instagram', 'ayecode-connect' ), |
|
| 1105 | + 'linkedin' => __( 'Linkedin', 'ayecode-connect' ), |
|
| 1106 | + 'flickr' => __( 'Flickr', 'ayecode-connect' ), |
|
| 1107 | + 'github' => __( 'GitHub', 'ayecode-connect' ), |
|
| 1108 | + 'youtube' => __( 'YouTube', 'ayecode-connect' ), |
|
| 1109 | + 'wordpress' => __( 'WordPress', 'ayecode-connect' ), |
|
| 1110 | + 'google' => __( 'Google', 'ayecode-connect' ), |
|
| 1111 | + 'yahoo' => __( 'Yahoo', 'ayecode-connect' ), |
|
| 1112 | + 'vkontakte' => __( 'Vkontakte', 'ayecode-connect' ), |
|
| 1113 | + ); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | |
@@ -1124,38 +1124,38 @@ discard block |
||
| 1124 | 1124 | */ |
| 1125 | 1125 | function sd_get_container_class_input( $type = 'container', $overwrite = array() ) { |
| 1126 | 1126 | |
| 1127 | - $options = array( |
|
| 1128 | - 'container' => __( 'container (default)', 'ayecode-connect' ), |
|
| 1129 | - 'container-sm' => 'container-sm', |
|
| 1130 | - 'container-md' => 'container-md', |
|
| 1131 | - 'container-lg' => 'container-lg', |
|
| 1132 | - 'container-xl' => 'container-xl', |
|
| 1133 | - 'container-xxl' => 'container-xxl', |
|
| 1134 | - 'container-fluid' => 'container-fluid', |
|
| 1135 | - 'row' => 'row', |
|
| 1136 | - 'col' => 'col', |
|
| 1137 | - 'card' => 'card', |
|
| 1138 | - 'card-header' => 'card-header', |
|
| 1139 | - 'card-img-top' => 'card-img-top', |
|
| 1140 | - 'card-body' => 'card-body', |
|
| 1141 | - 'card-footer' => 'card-footer', |
|
| 1142 | - 'list-group' => 'list-group', |
|
| 1143 | - 'list-group-item' => 'list-group-item', |
|
| 1144 | - '' => __( 'no container class', 'ayecode-connect' ), |
|
| 1145 | - ); |
|
| 1146 | - |
|
| 1147 | - $defaults = array( |
|
| 1148 | - 'type' => 'select', |
|
| 1149 | - 'title' => __( 'Type', 'ayecode-connect' ), |
|
| 1150 | - 'options' => $options, |
|
| 1151 | - 'default' => '', |
|
| 1152 | - 'desc_tip' => true, |
|
| 1153 | - 'group' => __( 'Container', 'ayecode-connect' ), |
|
| 1154 | - ); |
|
| 1155 | - |
|
| 1156 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1157 | - |
|
| 1158 | - return $input; |
|
| 1127 | + $options = array( |
|
| 1128 | + 'container' => __( 'container (default)', 'ayecode-connect' ), |
|
| 1129 | + 'container-sm' => 'container-sm', |
|
| 1130 | + 'container-md' => 'container-md', |
|
| 1131 | + 'container-lg' => 'container-lg', |
|
| 1132 | + 'container-xl' => 'container-xl', |
|
| 1133 | + 'container-xxl' => 'container-xxl', |
|
| 1134 | + 'container-fluid' => 'container-fluid', |
|
| 1135 | + 'row' => 'row', |
|
| 1136 | + 'col' => 'col', |
|
| 1137 | + 'card' => 'card', |
|
| 1138 | + 'card-header' => 'card-header', |
|
| 1139 | + 'card-img-top' => 'card-img-top', |
|
| 1140 | + 'card-body' => 'card-body', |
|
| 1141 | + 'card-footer' => 'card-footer', |
|
| 1142 | + 'list-group' => 'list-group', |
|
| 1143 | + 'list-group-item' => 'list-group-item', |
|
| 1144 | + '' => __( 'no container class', 'ayecode-connect' ), |
|
| 1145 | + ); |
|
| 1146 | + |
|
| 1147 | + $defaults = array( |
|
| 1148 | + 'type' => 'select', |
|
| 1149 | + 'title' => __( 'Type', 'ayecode-connect' ), |
|
| 1150 | + 'options' => $options, |
|
| 1151 | + 'default' => '', |
|
| 1152 | + 'desc_tip' => true, |
|
| 1153 | + 'group' => __( 'Container', 'ayecode-connect' ), |
|
| 1154 | + ); |
|
| 1155 | + |
|
| 1156 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1157 | + |
|
| 1158 | + return $input; |
|
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | 1161 | /** |
@@ -1168,30 +1168,30 @@ discard block |
||
| 1168 | 1168 | */ |
| 1169 | 1169 | function sd_get_position_class_input( $type = 'position', $overwrite = array() ) { |
| 1170 | 1170 | |
| 1171 | - $options = array( |
|
| 1172 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1173 | - 'position-static' => 'static', |
|
| 1174 | - 'position-relative' => 'relative', |
|
| 1175 | - 'position-absolute' => 'absolute', |
|
| 1176 | - 'position-fixed' => 'fixed', |
|
| 1177 | - 'position-sticky' => 'sticky', |
|
| 1178 | - 'fixed-top' => 'fixed-top', |
|
| 1179 | - 'fixed-bottom' => 'fixed-bottom', |
|
| 1180 | - 'sticky-top' => 'sticky-top', |
|
| 1181 | - ); |
|
| 1171 | + $options = array( |
|
| 1172 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1173 | + 'position-static' => 'static', |
|
| 1174 | + 'position-relative' => 'relative', |
|
| 1175 | + 'position-absolute' => 'absolute', |
|
| 1176 | + 'position-fixed' => 'fixed', |
|
| 1177 | + 'position-sticky' => 'sticky', |
|
| 1178 | + 'fixed-top' => 'fixed-top', |
|
| 1179 | + 'fixed-bottom' => 'fixed-bottom', |
|
| 1180 | + 'sticky-top' => 'sticky-top', |
|
| 1181 | + ); |
|
| 1182 | 1182 | |
| 1183 | - $defaults = array( |
|
| 1184 | - 'type' => 'select', |
|
| 1185 | - 'title' => __( 'Position', 'ayecode-connect' ), |
|
| 1186 | - 'options' => $options, |
|
| 1187 | - 'default' => '', |
|
| 1188 | - 'desc_tip' => true, |
|
| 1189 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1190 | - ); |
|
| 1183 | + $defaults = array( |
|
| 1184 | + 'type' => 'select', |
|
| 1185 | + 'title' => __( 'Position', 'ayecode-connect' ), |
|
| 1186 | + 'options' => $options, |
|
| 1187 | + 'default' => '', |
|
| 1188 | + 'desc_tip' => true, |
|
| 1189 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1190 | + ); |
|
| 1191 | 1191 | |
| 1192 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1192 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1193 | 1193 | |
| 1194 | - return $input; |
|
| 1194 | + return $input; |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
@@ -1202,32 +1202,32 @@ discard block |
||
| 1202 | 1202 | */ |
| 1203 | 1203 | function sd_get_absolute_position_input( $type = 'absolute_position', $overwrite = array() ) { |
| 1204 | 1204 | |
| 1205 | - $options = array( |
|
| 1206 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1207 | - 'top-left' => 'top-left', |
|
| 1208 | - 'top-center' => 'top-center', |
|
| 1209 | - 'top-right' => 'top-right', |
|
| 1210 | - 'center-left' => 'middle-left', |
|
| 1211 | - 'center' => 'center', |
|
| 1212 | - 'center-right' => 'middle-right', |
|
| 1213 | - 'bottom-left' => 'bottom-left', |
|
| 1214 | - 'bottom-center' => 'bottom-center', |
|
| 1215 | - 'bottom-right' => 'bottom-right', |
|
| 1216 | - ); |
|
| 1217 | - |
|
| 1218 | - $defaults = array( |
|
| 1219 | - 'type' => 'select', |
|
| 1220 | - 'title' => __( 'Absolute Position', 'ayecode-connect' ), |
|
| 1221 | - 'options' => $options, |
|
| 1222 | - 'default' => '', |
|
| 1223 | - 'desc_tip' => true, |
|
| 1224 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1225 | - 'element_require' => '[%position%]=="position-absolute"', |
|
| 1226 | - ); |
|
| 1227 | - |
|
| 1228 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1229 | - |
|
| 1230 | - return $input; |
|
| 1205 | + $options = array( |
|
| 1206 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1207 | + 'top-left' => 'top-left', |
|
| 1208 | + 'top-center' => 'top-center', |
|
| 1209 | + 'top-right' => 'top-right', |
|
| 1210 | + 'center-left' => 'middle-left', |
|
| 1211 | + 'center' => 'center', |
|
| 1212 | + 'center-right' => 'middle-right', |
|
| 1213 | + 'bottom-left' => 'bottom-left', |
|
| 1214 | + 'bottom-center' => 'bottom-center', |
|
| 1215 | + 'bottom-right' => 'bottom-right', |
|
| 1216 | + ); |
|
| 1217 | + |
|
| 1218 | + $defaults = array( |
|
| 1219 | + 'type' => 'select', |
|
| 1220 | + 'title' => __( 'Absolute Position', 'ayecode-connect' ), |
|
| 1221 | + 'options' => $options, |
|
| 1222 | + 'default' => '', |
|
| 1223 | + 'desc_tip' => true, |
|
| 1224 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1225 | + 'element_require' => '[%position%]=="position-absolute"', |
|
| 1226 | + ); |
|
| 1227 | + |
|
| 1228 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1229 | + |
|
| 1230 | + return $input; |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | /** |
@@ -1240,38 +1240,38 @@ discard block |
||
| 1240 | 1240 | */ |
| 1241 | 1241 | function sd_get_sticky_offset_input( $type = 'top', $overwrite = array() ) { |
| 1242 | 1242 | |
| 1243 | - $defaults = array( |
|
| 1244 | - 'type' => 'number', |
|
| 1245 | - 'title' => __( 'Sticky offset', 'ayecode-connect' ), |
|
| 1246 | - //'desc' => __( 'Sticky offset', 'ayecode-connect' ), |
|
| 1247 | - 'default' => '', |
|
| 1248 | - 'desc_tip' => true, |
|
| 1249 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1250 | - 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"', |
|
| 1251 | - ); |
|
| 1252 | - |
|
| 1253 | - // title |
|
| 1254 | - if ( $type == 'top' ) { |
|
| 1255 | - $defaults['title'] = __( 'Top offset', 'ayecode-connect' ); |
|
| 1256 | - $defaults['icon'] = 'box-top'; |
|
| 1257 | - $defaults['row'] = array( |
|
| 1258 | - 'title' => __( 'Sticky offset', 'ayecode-connect' ), |
|
| 1259 | - 'key' => 'sticky-offset', |
|
| 1260 | - 'open' => true, |
|
| 1261 | - 'class' => 'text-center', |
|
| 1262 | - ); |
|
| 1263 | - } elseif ( $type == 'bottom' ) { |
|
| 1264 | - $defaults['title'] = __( 'Bottom offset', 'ayecode-connect' ); |
|
| 1265 | - $defaults['icon'] = 'box-bottom'; |
|
| 1266 | - $defaults['row'] = array( |
|
| 1267 | - 'key' => 'sticky-offset', |
|
| 1268 | - 'close' => true, |
|
| 1269 | - ); |
|
| 1270 | - } |
|
| 1271 | - |
|
| 1272 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1273 | - |
|
| 1274 | - return $input; |
|
| 1243 | + $defaults = array( |
|
| 1244 | + 'type' => 'number', |
|
| 1245 | + 'title' => __( 'Sticky offset', 'ayecode-connect' ), |
|
| 1246 | + //'desc' => __( 'Sticky offset', 'ayecode-connect' ), |
|
| 1247 | + 'default' => '', |
|
| 1248 | + 'desc_tip' => true, |
|
| 1249 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1250 | + 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"', |
|
| 1251 | + ); |
|
| 1252 | + |
|
| 1253 | + // title |
|
| 1254 | + if ( $type == 'top' ) { |
|
| 1255 | + $defaults['title'] = __( 'Top offset', 'ayecode-connect' ); |
|
| 1256 | + $defaults['icon'] = 'box-top'; |
|
| 1257 | + $defaults['row'] = array( |
|
| 1258 | + 'title' => __( 'Sticky offset', 'ayecode-connect' ), |
|
| 1259 | + 'key' => 'sticky-offset', |
|
| 1260 | + 'open' => true, |
|
| 1261 | + 'class' => 'text-center', |
|
| 1262 | + ); |
|
| 1263 | + } elseif ( $type == 'bottom' ) { |
|
| 1264 | + $defaults['title'] = __( 'Bottom offset', 'ayecode-connect' ); |
|
| 1265 | + $defaults['icon'] = 'box-bottom'; |
|
| 1266 | + $defaults['row'] = array( |
|
| 1267 | + 'key' => 'sticky-offset', |
|
| 1268 | + 'close' => true, |
|
| 1269 | + ); |
|
| 1270 | + } |
|
| 1271 | + |
|
| 1272 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1273 | + |
|
| 1274 | + return $input; |
|
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | 1277 | /** |
@@ -1283,61 +1283,61 @@ discard block |
||
| 1283 | 1283 | * @return array |
| 1284 | 1284 | */ |
| 1285 | 1285 | function sd_get_font_size_input( $type = 'font_size', $overwrite = array(), $has_custom = false ) { |
| 1286 | - global $aui_bs5; |
|
| 1287 | - |
|
| 1288 | - $options[] = __( 'Inherit from parent', 'ayecode-connect' ); |
|
| 1289 | - if ( $aui_bs5 ) { |
|
| 1290 | - // responsive font sizes |
|
| 1291 | - $options['fs-base'] = 'fs-base (body default)'; |
|
| 1292 | - $options['fs-6'] = 'fs-6'; |
|
| 1293 | - $options['fs-5'] = 'fs-5'; |
|
| 1294 | - $options['fs-4'] = 'fs-4'; |
|
| 1295 | - $options['fs-3'] = 'fs-3'; |
|
| 1296 | - $options['fs-2'] = 'fs-2'; |
|
| 1297 | - $options['fs-1'] = 'fs-1'; |
|
| 1298 | - |
|
| 1299 | - // custom |
|
| 1300 | - $options['fs-lg'] = 'fs-lg'; |
|
| 1301 | - $options['fs-sm'] = 'fs-sm'; |
|
| 1302 | - $options['fs-xs'] = 'fs-xs'; |
|
| 1303 | - $options['fs-xxs'] = 'fs-xxs'; |
|
| 1304 | - |
|
| 1305 | - } |
|
| 1306 | - |
|
| 1307 | - $options = $options + array( |
|
| 1308 | - 'h6' => 'h6', |
|
| 1309 | - 'h5' => 'h5', |
|
| 1310 | - 'h4' => 'h4', |
|
| 1311 | - 'h3' => 'h3', |
|
| 1312 | - 'h2' => 'h2', |
|
| 1313 | - 'h1' => 'h1', |
|
| 1314 | - 'display-1' => 'display-1', |
|
| 1315 | - 'display-2' => 'display-2', |
|
| 1316 | - 'display-3' => 'display-3', |
|
| 1317 | - 'display-4' => 'display-4', |
|
| 1318 | - ); |
|
| 1319 | - |
|
| 1320 | - if ( $aui_bs5 ) { |
|
| 1321 | - $options['display-5'] = 'display-5'; |
|
| 1322 | - $options['display-6'] = 'display-6'; |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - if ( $has_custom ) { |
|
| 1326 | - $options['custom'] = __( 'Custom size', 'ayecode-connect' ); |
|
| 1327 | - } |
|
| 1328 | - |
|
| 1329 | - $defaults = array( |
|
| 1330 | - 'type' => 'select', |
|
| 1331 | - 'title' => __( 'Font size', 'ayecode-connect' ), |
|
| 1332 | - 'options' => $options, |
|
| 1333 | - 'default' => '', |
|
| 1334 | - 'desc_tip' => true, |
|
| 1335 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1336 | - ); |
|
| 1337 | - |
|
| 1338 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1339 | - |
|
| 1340 | - return $input; |
|
| 1286 | + global $aui_bs5; |
|
| 1287 | + |
|
| 1288 | + $options[] = __( 'Inherit from parent', 'ayecode-connect' ); |
|
| 1289 | + if ( $aui_bs5 ) { |
|
| 1290 | + // responsive font sizes |
|
| 1291 | + $options['fs-base'] = 'fs-base (body default)'; |
|
| 1292 | + $options['fs-6'] = 'fs-6'; |
|
| 1293 | + $options['fs-5'] = 'fs-5'; |
|
| 1294 | + $options['fs-4'] = 'fs-4'; |
|
| 1295 | + $options['fs-3'] = 'fs-3'; |
|
| 1296 | + $options['fs-2'] = 'fs-2'; |
|
| 1297 | + $options['fs-1'] = 'fs-1'; |
|
| 1298 | + |
|
| 1299 | + // custom |
|
| 1300 | + $options['fs-lg'] = 'fs-lg'; |
|
| 1301 | + $options['fs-sm'] = 'fs-sm'; |
|
| 1302 | + $options['fs-xs'] = 'fs-xs'; |
|
| 1303 | + $options['fs-xxs'] = 'fs-xxs'; |
|
| 1304 | + |
|
| 1305 | + } |
|
| 1306 | + |
|
| 1307 | + $options = $options + array( |
|
| 1308 | + 'h6' => 'h6', |
|
| 1309 | + 'h5' => 'h5', |
|
| 1310 | + 'h4' => 'h4', |
|
| 1311 | + 'h3' => 'h3', |
|
| 1312 | + 'h2' => 'h2', |
|
| 1313 | + 'h1' => 'h1', |
|
| 1314 | + 'display-1' => 'display-1', |
|
| 1315 | + 'display-2' => 'display-2', |
|
| 1316 | + 'display-3' => 'display-3', |
|
| 1317 | + 'display-4' => 'display-4', |
|
| 1318 | + ); |
|
| 1319 | + |
|
| 1320 | + if ( $aui_bs5 ) { |
|
| 1321 | + $options['display-5'] = 'display-5'; |
|
| 1322 | + $options['display-6'] = 'display-6'; |
|
| 1323 | + } |
|
| 1324 | + |
|
| 1325 | + if ( $has_custom ) { |
|
| 1326 | + $options['custom'] = __( 'Custom size', 'ayecode-connect' ); |
|
| 1327 | + } |
|
| 1328 | + |
|
| 1329 | + $defaults = array( |
|
| 1330 | + 'type' => 'select', |
|
| 1331 | + 'title' => __( 'Font size', 'ayecode-connect' ), |
|
| 1332 | + 'options' => $options, |
|
| 1333 | + 'default' => '', |
|
| 1334 | + 'desc_tip' => true, |
|
| 1335 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1336 | + ); |
|
| 1337 | + |
|
| 1338 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1339 | + |
|
| 1340 | + return $input; |
|
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | /** |
@@ -1350,27 +1350,27 @@ discard block |
||
| 1350 | 1350 | */ |
| 1351 | 1351 | function sd_get_font_custom_size_input( $type = 'font_size_custom', $overwrite = array(), $parent_type = '' ) { |
| 1352 | 1352 | |
| 1353 | - $defaults = array( |
|
| 1354 | - 'type' => 'number', |
|
| 1355 | - 'title' => __( 'Font size (rem)', 'ayecode-connect' ), |
|
| 1356 | - 'default' => '', |
|
| 1357 | - 'placeholder' => '1.25', |
|
| 1358 | - 'custom_attributes' => array( |
|
| 1359 | - 'step' => '0.1', |
|
| 1360 | - 'min' => '0', |
|
| 1361 | - 'max' => '100', |
|
| 1362 | - ), |
|
| 1363 | - 'desc_tip' => true, |
|
| 1364 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1365 | - ); |
|
| 1353 | + $defaults = array( |
|
| 1354 | + 'type' => 'number', |
|
| 1355 | + 'title' => __( 'Font size (rem)', 'ayecode-connect' ), |
|
| 1356 | + 'default' => '', |
|
| 1357 | + 'placeholder' => '1.25', |
|
| 1358 | + 'custom_attributes' => array( |
|
| 1359 | + 'step' => '0.1', |
|
| 1360 | + 'min' => '0', |
|
| 1361 | + 'max' => '100', |
|
| 1362 | + ), |
|
| 1363 | + 'desc_tip' => true, |
|
| 1364 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1365 | + ); |
|
| 1366 | 1366 | |
| 1367 | - if ( $parent_type ) { |
|
| 1368 | - $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1369 | - } |
|
| 1367 | + if ( $parent_type ) { |
|
| 1368 | + $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1369 | + } |
|
| 1370 | 1370 | |
| 1371 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1371 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1372 | 1372 | |
| 1373 | - return $input; |
|
| 1373 | + return $input; |
|
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | /** |
@@ -1383,23 +1383,23 @@ discard block |
||
| 1383 | 1383 | */ |
| 1384 | 1384 | function sd_get_font_line_height_input( $type = 'font_line_height', $overwrite = array() ) { |
| 1385 | 1385 | |
| 1386 | - $defaults = array( |
|
| 1387 | - 'type' => 'number', |
|
| 1388 | - 'title' => __( 'Font Line Height', 'ayecode-connect' ), |
|
| 1389 | - 'default' => '', |
|
| 1390 | - 'placeholder' => '1.75', |
|
| 1391 | - 'custom_attributes' => array( |
|
| 1392 | - 'step' => '0.1', |
|
| 1393 | - 'min' => '0', |
|
| 1394 | - 'max' => '100', |
|
| 1395 | - ), |
|
| 1396 | - 'desc_tip' => true, |
|
| 1397 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1398 | - ); |
|
| 1386 | + $defaults = array( |
|
| 1387 | + 'type' => 'number', |
|
| 1388 | + 'title' => __( 'Font Line Height', 'ayecode-connect' ), |
|
| 1389 | + 'default' => '', |
|
| 1390 | + 'placeholder' => '1.75', |
|
| 1391 | + 'custom_attributes' => array( |
|
| 1392 | + 'step' => '0.1', |
|
| 1393 | + 'min' => '0', |
|
| 1394 | + 'max' => '100', |
|
| 1395 | + ), |
|
| 1396 | + 'desc_tip' => true, |
|
| 1397 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1398 | + ); |
|
| 1399 | 1399 | |
| 1400 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1400 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1401 | 1401 | |
| 1402 | - return $input; |
|
| 1402 | + return $input; |
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | /** |
@@ -1412,18 +1412,18 @@ discard block |
||
| 1412 | 1412 | */ |
| 1413 | 1413 | function sd_get_font_size_input_group( $type = 'font_size', $overwrite = array(), $overwrite_custom = array() ) { |
| 1414 | 1414 | |
| 1415 | - $inputs = array(); |
|
| 1415 | + $inputs = array(); |
|
| 1416 | 1416 | |
| 1417 | - if ( $overwrite !== false ) { |
|
| 1418 | - $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1419 | - } |
|
| 1417 | + if ( $overwrite !== false ) { |
|
| 1418 | + $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1419 | + } |
|
| 1420 | 1420 | |
| 1421 | - if ( $overwrite_custom !== false ) { |
|
| 1422 | - $custom = $type . '_custom'; |
|
| 1423 | - $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1424 | - } |
|
| 1421 | + if ( $overwrite_custom !== false ) { |
|
| 1422 | + $custom = $type . '_custom'; |
|
| 1423 | + $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1424 | + } |
|
| 1425 | 1425 | |
| 1426 | - return $inputs; |
|
| 1426 | + return $inputs; |
|
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | 1429 | /** |
@@ -1436,33 +1436,33 @@ discard block |
||
| 1436 | 1436 | */ |
| 1437 | 1437 | function sd_get_font_weight_input( $type = 'font_weight', $overwrite = array() ) { |
| 1438 | 1438 | |
| 1439 | - $options = array( |
|
| 1440 | - '' => __( 'Inherit', 'ayecode-connect' ), |
|
| 1441 | - 'font-weight-bold' => 'bold', |
|
| 1442 | - 'font-weight-bolder' => 'bolder', |
|
| 1443 | - 'font-weight-normal' => 'normal', |
|
| 1444 | - 'font-weight-light' => 'light', |
|
| 1445 | - 'font-weight-lighter' => 'lighter', |
|
| 1446 | - 'font-italic' => 'italic', |
|
| 1447 | - 'font-weight-bold font-italic' => 'bold italic', |
|
| 1448 | - 'font-weight-bolder font-italic' => 'bolder italic', |
|
| 1449 | - 'font-weight-normal font-italic' => 'normal italic', |
|
| 1450 | - 'font-weight-light font-italic' => 'light italic', |
|
| 1451 | - 'font-weight-lighter font-italic' => 'lighter italic', |
|
| 1452 | - ); |
|
| 1453 | - |
|
| 1454 | - $defaults = array( |
|
| 1455 | - 'type' => 'select', |
|
| 1456 | - 'title' => __( 'Appearance', 'ayecode-connect' ), |
|
| 1457 | - 'options' => $options, |
|
| 1458 | - 'default' => '', |
|
| 1459 | - 'desc_tip' => true, |
|
| 1460 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1461 | - ); |
|
| 1462 | - |
|
| 1463 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1464 | - |
|
| 1465 | - return $input; |
|
| 1439 | + $options = array( |
|
| 1440 | + '' => __( 'Inherit', 'ayecode-connect' ), |
|
| 1441 | + 'font-weight-bold' => 'bold', |
|
| 1442 | + 'font-weight-bolder' => 'bolder', |
|
| 1443 | + 'font-weight-normal' => 'normal', |
|
| 1444 | + 'font-weight-light' => 'light', |
|
| 1445 | + 'font-weight-lighter' => 'lighter', |
|
| 1446 | + 'font-italic' => 'italic', |
|
| 1447 | + 'font-weight-bold font-italic' => 'bold italic', |
|
| 1448 | + 'font-weight-bolder font-italic' => 'bolder italic', |
|
| 1449 | + 'font-weight-normal font-italic' => 'normal italic', |
|
| 1450 | + 'font-weight-light font-italic' => 'light italic', |
|
| 1451 | + 'font-weight-lighter font-italic' => 'lighter italic', |
|
| 1452 | + ); |
|
| 1453 | + |
|
| 1454 | + $defaults = array( |
|
| 1455 | + 'type' => 'select', |
|
| 1456 | + 'title' => __( 'Appearance', 'ayecode-connect' ), |
|
| 1457 | + 'options' => $options, |
|
| 1458 | + 'default' => '', |
|
| 1459 | + 'desc_tip' => true, |
|
| 1460 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1461 | + ); |
|
| 1462 | + |
|
| 1463 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1464 | + |
|
| 1465 | + return $input; |
|
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | 1468 | /** |
@@ -1475,25 +1475,25 @@ discard block |
||
| 1475 | 1475 | */ |
| 1476 | 1476 | function sd_get_font_case_input( $type = 'font_weight', $overwrite = array() ) { |
| 1477 | 1477 | |
| 1478 | - $options = array( |
|
| 1479 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1480 | - 'text-lowercase' => __( 'lowercase', 'ayecode-connect' ), |
|
| 1481 | - 'text-uppercase' => __( 'UPPERCASE', 'ayecode-connect' ), |
|
| 1482 | - 'text-capitalize' => __( 'Capitalize', 'ayecode-connect' ), |
|
| 1483 | - ); |
|
| 1478 | + $options = array( |
|
| 1479 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1480 | + 'text-lowercase' => __( 'lowercase', 'ayecode-connect' ), |
|
| 1481 | + 'text-uppercase' => __( 'UPPERCASE', 'ayecode-connect' ), |
|
| 1482 | + 'text-capitalize' => __( 'Capitalize', 'ayecode-connect' ), |
|
| 1483 | + ); |
|
| 1484 | 1484 | |
| 1485 | - $defaults = array( |
|
| 1486 | - 'type' => 'select', |
|
| 1487 | - 'title' => __( 'Letter case', 'ayecode-connect' ), |
|
| 1488 | - 'options' => $options, |
|
| 1489 | - 'default' => '', |
|
| 1490 | - 'desc_tip' => true, |
|
| 1491 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1492 | - ); |
|
| 1485 | + $defaults = array( |
|
| 1486 | + 'type' => 'select', |
|
| 1487 | + 'title' => __( 'Letter case', 'ayecode-connect' ), |
|
| 1488 | + 'options' => $options, |
|
| 1489 | + 'default' => '', |
|
| 1490 | + 'desc_tip' => true, |
|
| 1491 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1492 | + ); |
|
| 1493 | 1493 | |
| 1494 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1494 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1495 | 1495 | |
| 1496 | - return $input; |
|
| 1496 | + return $input; |
|
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | /** |
@@ -1507,23 +1507,23 @@ discard block |
||
| 1507 | 1507 | */ |
| 1508 | 1508 | function sd_get_font_italic_input( $type = 'font_italic', $overwrite = array() ) { |
| 1509 | 1509 | |
| 1510 | - $options = array( |
|
| 1511 | - '' => __( 'No', 'ayecode-connect' ), |
|
| 1512 | - 'font-italic' => __( 'Yes', 'ayecode-connect' ), |
|
| 1513 | - ); |
|
| 1510 | + $options = array( |
|
| 1511 | + '' => __( 'No', 'ayecode-connect' ), |
|
| 1512 | + 'font-italic' => __( 'Yes', 'ayecode-connect' ), |
|
| 1513 | + ); |
|
| 1514 | 1514 | |
| 1515 | - $defaults = array( |
|
| 1516 | - 'type' => 'select', |
|
| 1517 | - 'title' => __( 'Font italic', 'ayecode-connect' ), |
|
| 1518 | - 'options' => $options, |
|
| 1519 | - 'default' => '', |
|
| 1520 | - 'desc_tip' => true, |
|
| 1521 | - 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1522 | - ); |
|
| 1515 | + $defaults = array( |
|
| 1516 | + 'type' => 'select', |
|
| 1517 | + 'title' => __( 'Font italic', 'ayecode-connect' ), |
|
| 1518 | + 'options' => $options, |
|
| 1519 | + 'default' => '', |
|
| 1520 | + 'desc_tip' => true, |
|
| 1521 | + 'group' => __( 'Typography', 'ayecode-connect' ), |
|
| 1522 | + ); |
|
| 1523 | 1523 | |
| 1524 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1524 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1525 | 1525 | |
| 1526 | - return $input; |
|
| 1526 | + return $input; |
|
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | /** |
@@ -1536,18 +1536,18 @@ discard block |
||
| 1536 | 1536 | */ |
| 1537 | 1537 | function sd_get_anchor_input( $type = 'anchor', $overwrite = array() ) { |
| 1538 | 1538 | |
| 1539 | - $defaults = array( |
|
| 1540 | - 'type' => 'text', |
|
| 1541 | - 'title' => __( 'HTML anchor', 'ayecode-connect' ), |
|
| 1542 | - 'desc' => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.', 'ayecode-connect' ), |
|
| 1543 | - 'default' => '', |
|
| 1544 | - 'desc_tip' => true, |
|
| 1545 | - 'group' => __( 'Advanced', 'ayecode-connect' ), |
|
| 1546 | - ); |
|
| 1539 | + $defaults = array( |
|
| 1540 | + 'type' => 'text', |
|
| 1541 | + 'title' => __( 'HTML anchor', 'ayecode-connect' ), |
|
| 1542 | + 'desc' => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.', 'ayecode-connect' ), |
|
| 1543 | + 'default' => '', |
|
| 1544 | + 'desc_tip' => true, |
|
| 1545 | + 'group' => __( 'Advanced', 'ayecode-connect' ), |
|
| 1546 | + ); |
|
| 1547 | 1547 | |
| 1548 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1548 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1549 | 1549 | |
| 1550 | - return $input; |
|
| 1550 | + return $input; |
|
| 1551 | 1551 | } |
| 1552 | 1552 | |
| 1553 | 1553 | /** |
@@ -1560,18 +1560,18 @@ discard block |
||
| 1560 | 1560 | */ |
| 1561 | 1561 | function sd_get_class_input( $type = 'css_class', $overwrite = array() ) { |
| 1562 | 1562 | |
| 1563 | - $defaults = array( |
|
| 1564 | - 'type' => 'text', |
|
| 1565 | - 'title' => __( 'Additional CSS class(es)', 'ayecode-connect' ), |
|
| 1566 | - 'desc' => __( 'Separate multiple classes with spaces.', 'ayecode-connect' ), |
|
| 1567 | - 'default' => '', |
|
| 1568 | - 'desc_tip' => true, |
|
| 1569 | - 'group' => __( 'Advanced', 'ayecode-connect' ), |
|
| 1570 | - ); |
|
| 1563 | + $defaults = array( |
|
| 1564 | + 'type' => 'text', |
|
| 1565 | + 'title' => __( 'Additional CSS class(es)', 'ayecode-connect' ), |
|
| 1566 | + 'desc' => __( 'Separate multiple classes with spaces.', 'ayecode-connect' ), |
|
| 1567 | + 'default' => '', |
|
| 1568 | + 'desc_tip' => true, |
|
| 1569 | + 'group' => __( 'Advanced', 'ayecode-connect' ), |
|
| 1570 | + ); |
|
| 1571 | 1571 | |
| 1572 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1572 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1573 | 1573 | |
| 1574 | - return $input; |
|
| 1574 | + return $input; |
|
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | /** |
@@ -1584,18 +1584,18 @@ discard block |
||
| 1584 | 1584 | */ |
| 1585 | 1585 | function sd_get_custom_name_input( $type = 'metadata_name', $overwrite = array() ) { |
| 1586 | 1586 | |
| 1587 | - $defaults = array( |
|
| 1588 | - 'type' => 'text', |
|
| 1589 | - 'title' => __( 'Block Name', 'ayecode-connect' ), |
|
| 1590 | - 'desc' => __( 'Set a custom name for this block', 'ayecode-connect' ), |
|
| 1591 | - 'default' => '', |
|
| 1592 | - 'desc_tip' => true, |
|
| 1593 | - 'group' => __( 'Advanced', 'ayecode-connect' ), |
|
| 1594 | - ); |
|
| 1587 | + $defaults = array( |
|
| 1588 | + 'type' => 'text', |
|
| 1589 | + 'title' => __( 'Block Name', 'ayecode-connect' ), |
|
| 1590 | + 'desc' => __( 'Set a custom name for this block', 'ayecode-connect' ), |
|
| 1591 | + 'default' => '', |
|
| 1592 | + 'desc_tip' => true, |
|
| 1593 | + 'group' => __( 'Advanced', 'ayecode-connect' ), |
|
| 1594 | + ); |
|
| 1595 | 1595 | |
| 1596 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1596 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1597 | 1597 | |
| 1598 | - return $input; |
|
| 1598 | + return $input; |
|
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | 1601 | /** |
@@ -1608,341 +1608,341 @@ discard block |
||
| 1608 | 1608 | */ |
| 1609 | 1609 | function sd_get_hover_animations_input( $type = 'hover_animations', $overwrite = array() ) { |
| 1610 | 1610 | |
| 1611 | - $options = array( |
|
| 1612 | - '' => __( 'none', 'ayecode-connect' ), |
|
| 1613 | - 'hover-zoom' => __( 'Zoom', 'ayecode-connect' ), |
|
| 1614 | - 'hover-shadow' => __( 'Shadow', 'ayecode-connect' ), |
|
| 1615 | - 'hover-move-up' => __( 'Move up', 'ayecode-connect' ), |
|
| 1616 | - 'hover-move-down' => __( 'Move down', 'ayecode-connect' ), |
|
| 1617 | - 'hover-move-left' => __( 'Move left', 'ayecode-connect' ), |
|
| 1618 | - 'hover-move-right' => __( 'Move right', 'ayecode-connect' ), |
|
| 1619 | - ); |
|
| 1611 | + $options = array( |
|
| 1612 | + '' => __( 'none', 'ayecode-connect' ), |
|
| 1613 | + 'hover-zoom' => __( 'Zoom', 'ayecode-connect' ), |
|
| 1614 | + 'hover-shadow' => __( 'Shadow', 'ayecode-connect' ), |
|
| 1615 | + 'hover-move-up' => __( 'Move up', 'ayecode-connect' ), |
|
| 1616 | + 'hover-move-down' => __( 'Move down', 'ayecode-connect' ), |
|
| 1617 | + 'hover-move-left' => __( 'Move left', 'ayecode-connect' ), |
|
| 1618 | + 'hover-move-right' => __( 'Move right', 'ayecode-connect' ), |
|
| 1619 | + ); |
|
| 1620 | 1620 | |
| 1621 | - $defaults = array( |
|
| 1622 | - 'type' => 'select', |
|
| 1623 | - 'multiple' => true, |
|
| 1624 | - 'title' => __( 'Hover Animations', 'ayecode-connect' ), |
|
| 1625 | - 'options' => $options, |
|
| 1626 | - 'default' => '', |
|
| 1627 | - 'desc_tip' => true, |
|
| 1628 | - 'group' => __( 'Hover Animations', 'ayecode-connect' ), |
|
| 1629 | - ); |
|
| 1621 | + $defaults = array( |
|
| 1622 | + 'type' => 'select', |
|
| 1623 | + 'multiple' => true, |
|
| 1624 | + 'title' => __( 'Hover Animations', 'ayecode-connect' ), |
|
| 1625 | + 'options' => $options, |
|
| 1626 | + 'default' => '', |
|
| 1627 | + 'desc_tip' => true, |
|
| 1628 | + 'group' => __( 'Hover Animations', 'ayecode-connect' ), |
|
| 1629 | + ); |
|
| 1630 | 1630 | |
| 1631 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1631 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1632 | 1632 | |
| 1633 | - return $input; |
|
| 1633 | + return $input; |
|
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 | |
| 1637 | 1637 | function sd_get_flex_align_items_input( $type = 'align-items', $overwrite = array() ) { |
| 1638 | - $device_size = ''; |
|
| 1639 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1640 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1641 | - $device_size = '-md'; |
|
| 1642 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1643 | - $device_size = '-lg'; |
|
| 1644 | - } |
|
| 1645 | - } |
|
| 1646 | - $options = array( |
|
| 1647 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1648 | - 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1649 | - 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1650 | - 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1651 | - 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1652 | - 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1653 | - ); |
|
| 1654 | - |
|
| 1655 | - $defaults = array( |
|
| 1656 | - 'type' => 'select', |
|
| 1657 | - 'title' => __( 'Vertical Align Items', 'ayecode-connect' ), |
|
| 1658 | - 'options' => $options, |
|
| 1659 | - 'default' => '', |
|
| 1660 | - 'desc_tip' => true, |
|
| 1661 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1662 | - 'element_require' => ' ( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1663 | - |
|
| 1664 | - ); |
|
| 1665 | - |
|
| 1666 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1667 | - |
|
| 1668 | - return $input; |
|
| 1638 | + $device_size = ''; |
|
| 1639 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1640 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1641 | + $device_size = '-md'; |
|
| 1642 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1643 | + $device_size = '-lg'; |
|
| 1644 | + } |
|
| 1645 | + } |
|
| 1646 | + $options = array( |
|
| 1647 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1648 | + 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1649 | + 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1650 | + 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1651 | + 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1652 | + 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1653 | + ); |
|
| 1654 | + |
|
| 1655 | + $defaults = array( |
|
| 1656 | + 'type' => 'select', |
|
| 1657 | + 'title' => __( 'Vertical Align Items', 'ayecode-connect' ), |
|
| 1658 | + 'options' => $options, |
|
| 1659 | + 'default' => '', |
|
| 1660 | + 'desc_tip' => true, |
|
| 1661 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1662 | + 'element_require' => ' ( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1663 | + |
|
| 1664 | + ); |
|
| 1665 | + |
|
| 1666 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1667 | + |
|
| 1668 | + return $input; |
|
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | function sd_get_flex_align_items_input_group( $type = 'flex_align_items', $overwrite = array() ) { |
| 1672 | - $inputs = array(); |
|
| 1673 | - $sizes = array( |
|
| 1674 | - '' => 'Mobile', |
|
| 1675 | - '_md' => 'Tablet', |
|
| 1676 | - '_lg' => 'Desktop', |
|
| 1677 | - ); |
|
| 1672 | + $inputs = array(); |
|
| 1673 | + $sizes = array( |
|
| 1674 | + '' => 'Mobile', |
|
| 1675 | + '_md' => 'Tablet', |
|
| 1676 | + '_lg' => 'Desktop', |
|
| 1677 | + ); |
|
| 1678 | 1678 | |
| 1679 | - if ( $overwrite !== false ) { |
|
| 1679 | + if ( $overwrite !== false ) { |
|
| 1680 | 1680 | |
| 1681 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1682 | - $overwrite['device_type'] = $dt; |
|
| 1683 | - $inputs[ $type . $ds ] = sd_get_flex_align_items_input( $type, $overwrite ); |
|
| 1684 | - } |
|
| 1685 | - } |
|
| 1681 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1682 | + $overwrite['device_type'] = $dt; |
|
| 1683 | + $inputs[ $type . $ds ] = sd_get_flex_align_items_input( $type, $overwrite ); |
|
| 1684 | + } |
|
| 1685 | + } |
|
| 1686 | 1686 | |
| 1687 | - return $inputs; |
|
| 1687 | + return $inputs; |
|
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | 1690 | function sd_get_flex_justify_content_input( $type = 'flex_justify_content', $overwrite = array() ) { |
| 1691 | - $device_size = ''; |
|
| 1692 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1693 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1694 | - $device_size = '-md'; |
|
| 1695 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1696 | - $device_size = '-lg'; |
|
| 1697 | - } |
|
| 1698 | - } |
|
| 1699 | - $options = array( |
|
| 1700 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1701 | - 'justify-content' . $device_size . '-start' => 'justify-content-start', |
|
| 1702 | - 'justify-content' . $device_size . '-end' => 'justify-content-end', |
|
| 1703 | - 'justify-content' . $device_size . '-center' => 'justify-content-center', |
|
| 1704 | - 'justify-content' . $device_size . '-between' => 'justify-content-between', |
|
| 1705 | - 'justify-content' . $device_size . '-stretch' => 'justify-content-around', |
|
| 1706 | - ); |
|
| 1707 | - |
|
| 1708 | - $defaults = array( |
|
| 1709 | - 'type' => 'select', |
|
| 1710 | - 'title' => __( 'Justify content', 'ayecode-connect' ), |
|
| 1711 | - 'options' => $options, |
|
| 1712 | - 'default' => '', |
|
| 1713 | - 'desc_tip' => true, |
|
| 1714 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1715 | - 'element_require' => '( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1716 | - |
|
| 1717 | - ); |
|
| 1718 | - |
|
| 1719 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1720 | - |
|
| 1721 | - return $input; |
|
| 1691 | + $device_size = ''; |
|
| 1692 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1693 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1694 | + $device_size = '-md'; |
|
| 1695 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1696 | + $device_size = '-lg'; |
|
| 1697 | + } |
|
| 1698 | + } |
|
| 1699 | + $options = array( |
|
| 1700 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1701 | + 'justify-content' . $device_size . '-start' => 'justify-content-start', |
|
| 1702 | + 'justify-content' . $device_size . '-end' => 'justify-content-end', |
|
| 1703 | + 'justify-content' . $device_size . '-center' => 'justify-content-center', |
|
| 1704 | + 'justify-content' . $device_size . '-between' => 'justify-content-between', |
|
| 1705 | + 'justify-content' . $device_size . '-stretch' => 'justify-content-around', |
|
| 1706 | + ); |
|
| 1707 | + |
|
| 1708 | + $defaults = array( |
|
| 1709 | + 'type' => 'select', |
|
| 1710 | + 'title' => __( 'Justify content', 'ayecode-connect' ), |
|
| 1711 | + 'options' => $options, |
|
| 1712 | + 'default' => '', |
|
| 1713 | + 'desc_tip' => true, |
|
| 1714 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1715 | + 'element_require' => '( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1716 | + |
|
| 1717 | + ); |
|
| 1718 | + |
|
| 1719 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1720 | + |
|
| 1721 | + return $input; |
|
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | 1724 | function sd_get_flex_justify_content_input_group( $type = 'flex_justify_content', $overwrite = array() ) { |
| 1725 | - $inputs = array(); |
|
| 1726 | - $sizes = array( |
|
| 1727 | - '' => 'Mobile', |
|
| 1728 | - '_md' => 'Tablet', |
|
| 1729 | - '_lg' => 'Desktop', |
|
| 1730 | - ); |
|
| 1725 | + $inputs = array(); |
|
| 1726 | + $sizes = array( |
|
| 1727 | + '' => 'Mobile', |
|
| 1728 | + '_md' => 'Tablet', |
|
| 1729 | + '_lg' => 'Desktop', |
|
| 1730 | + ); |
|
| 1731 | 1731 | |
| 1732 | - if ( $overwrite !== false ) { |
|
| 1732 | + if ( $overwrite !== false ) { |
|
| 1733 | 1733 | |
| 1734 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1735 | - $overwrite['device_type'] = $dt; |
|
| 1736 | - $inputs[ $type . $ds ] = sd_get_flex_justify_content_input( $type, $overwrite ); |
|
| 1737 | - } |
|
| 1738 | - } |
|
| 1734 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1735 | + $overwrite['device_type'] = $dt; |
|
| 1736 | + $inputs[ $type . $ds ] = sd_get_flex_justify_content_input( $type, $overwrite ); |
|
| 1737 | + } |
|
| 1738 | + } |
|
| 1739 | 1739 | |
| 1740 | - return $inputs; |
|
| 1740 | + return $inputs; |
|
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | 1743 | |
| 1744 | 1744 | function sd_get_flex_align_self_input( $type = 'flex_align_self', $overwrite = array() ) { |
| 1745 | - $device_size = ''; |
|
| 1746 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1747 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1748 | - $device_size = '-md'; |
|
| 1749 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1750 | - $device_size = '-lg'; |
|
| 1751 | - } |
|
| 1752 | - } |
|
| 1753 | - $options = array( |
|
| 1754 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1755 | - 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1756 | - 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1757 | - 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1758 | - 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1759 | - 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1760 | - ); |
|
| 1761 | - |
|
| 1762 | - $defaults = array( |
|
| 1763 | - 'type' => 'select', |
|
| 1764 | - 'title' => __( 'Align Self', 'ayecode-connect' ), |
|
| 1765 | - 'options' => $options, |
|
| 1766 | - 'default' => '', |
|
| 1767 | - 'desc_tip' => true, |
|
| 1768 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1769 | - 'element_require' => ' [%container%]=="col" ', |
|
| 1770 | - |
|
| 1771 | - ); |
|
| 1772 | - |
|
| 1773 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1774 | - |
|
| 1775 | - return $input; |
|
| 1745 | + $device_size = ''; |
|
| 1746 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1747 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1748 | + $device_size = '-md'; |
|
| 1749 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1750 | + $device_size = '-lg'; |
|
| 1751 | + } |
|
| 1752 | + } |
|
| 1753 | + $options = array( |
|
| 1754 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1755 | + 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1756 | + 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1757 | + 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1758 | + 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1759 | + 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1760 | + ); |
|
| 1761 | + |
|
| 1762 | + $defaults = array( |
|
| 1763 | + 'type' => 'select', |
|
| 1764 | + 'title' => __( 'Align Self', 'ayecode-connect' ), |
|
| 1765 | + 'options' => $options, |
|
| 1766 | + 'default' => '', |
|
| 1767 | + 'desc_tip' => true, |
|
| 1768 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1769 | + 'element_require' => ' [%container%]=="col" ', |
|
| 1770 | + |
|
| 1771 | + ); |
|
| 1772 | + |
|
| 1773 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1774 | + |
|
| 1775 | + return $input; |
|
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | 1778 | function sd_get_flex_align_self_input_group( $type = 'flex_align_self', $overwrite = array() ) { |
| 1779 | - $inputs = array(); |
|
| 1780 | - $sizes = array( |
|
| 1781 | - '' => 'Mobile', |
|
| 1782 | - '_md' => 'Tablet', |
|
| 1783 | - '_lg' => 'Desktop', |
|
| 1784 | - ); |
|
| 1779 | + $inputs = array(); |
|
| 1780 | + $sizes = array( |
|
| 1781 | + '' => 'Mobile', |
|
| 1782 | + '_md' => 'Tablet', |
|
| 1783 | + '_lg' => 'Desktop', |
|
| 1784 | + ); |
|
| 1785 | 1785 | |
| 1786 | - if ( $overwrite !== false ) { |
|
| 1786 | + if ( $overwrite !== false ) { |
|
| 1787 | 1787 | |
| 1788 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1789 | - $overwrite['device_type'] = $dt; |
|
| 1790 | - $inputs[ $type . $ds ] = sd_get_flex_align_self_input( $type, $overwrite ); |
|
| 1791 | - } |
|
| 1792 | - } |
|
| 1788 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1789 | + $overwrite['device_type'] = $dt; |
|
| 1790 | + $inputs[ $type . $ds ] = sd_get_flex_align_self_input( $type, $overwrite ); |
|
| 1791 | + } |
|
| 1792 | + } |
|
| 1793 | 1793 | |
| 1794 | - return $inputs; |
|
| 1794 | + return $inputs; |
|
| 1795 | 1795 | } |
| 1796 | 1796 | |
| 1797 | 1797 | function sd_get_flex_order_input( $type = 'flex_order', $overwrite = array() ) { |
| 1798 | - $device_size = ''; |
|
| 1799 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1800 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1801 | - $device_size = '-md'; |
|
| 1802 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1803 | - $device_size = '-lg'; |
|
| 1804 | - } |
|
| 1805 | - } |
|
| 1806 | - $options = array( |
|
| 1807 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1808 | - ); |
|
| 1809 | - |
|
| 1810 | - $i = 0; |
|
| 1811 | - while ( $i <= 5 ) { |
|
| 1812 | - $options[ 'order' . $device_size . '-' . $i ] = $i; |
|
| 1813 | - $i++; |
|
| 1814 | - } |
|
| 1815 | - |
|
| 1816 | - $defaults = array( |
|
| 1817 | - 'type' => 'select', |
|
| 1818 | - 'title' => __( 'Flex Order', 'ayecode-connect' ), |
|
| 1819 | - 'options' => $options, |
|
| 1820 | - 'default' => '', |
|
| 1821 | - 'desc_tip' => true, |
|
| 1822 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1823 | - 'element_require' => ' [%container%]=="col" ', |
|
| 1824 | - |
|
| 1825 | - ); |
|
| 1826 | - |
|
| 1827 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1828 | - |
|
| 1829 | - return $input; |
|
| 1798 | + $device_size = ''; |
|
| 1799 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1800 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1801 | + $device_size = '-md'; |
|
| 1802 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1803 | + $device_size = '-lg'; |
|
| 1804 | + } |
|
| 1805 | + } |
|
| 1806 | + $options = array( |
|
| 1807 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1808 | + ); |
|
| 1809 | + |
|
| 1810 | + $i = 0; |
|
| 1811 | + while ( $i <= 5 ) { |
|
| 1812 | + $options[ 'order' . $device_size . '-' . $i ] = $i; |
|
| 1813 | + $i++; |
|
| 1814 | + } |
|
| 1815 | + |
|
| 1816 | + $defaults = array( |
|
| 1817 | + 'type' => 'select', |
|
| 1818 | + 'title' => __( 'Flex Order', 'ayecode-connect' ), |
|
| 1819 | + 'options' => $options, |
|
| 1820 | + 'default' => '', |
|
| 1821 | + 'desc_tip' => true, |
|
| 1822 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1823 | + 'element_require' => ' [%container%]=="col" ', |
|
| 1824 | + |
|
| 1825 | + ); |
|
| 1826 | + |
|
| 1827 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1828 | + |
|
| 1829 | + return $input; |
|
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | 1832 | function sd_get_flex_order_input_group( $type = 'flex_order', $overwrite = array() ) { |
| 1833 | - $inputs = array(); |
|
| 1834 | - $sizes = array( |
|
| 1835 | - '' => 'Mobile', |
|
| 1836 | - '_md' => 'Tablet', |
|
| 1837 | - '_lg' => 'Desktop', |
|
| 1838 | - ); |
|
| 1833 | + $inputs = array(); |
|
| 1834 | + $sizes = array( |
|
| 1835 | + '' => 'Mobile', |
|
| 1836 | + '_md' => 'Tablet', |
|
| 1837 | + '_lg' => 'Desktop', |
|
| 1838 | + ); |
|
| 1839 | 1839 | |
| 1840 | - if ( $overwrite !== false ) { |
|
| 1840 | + if ( $overwrite !== false ) { |
|
| 1841 | 1841 | |
| 1842 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1843 | - $overwrite['device_type'] = $dt; |
|
| 1844 | - $inputs[ $type . $ds ] = sd_get_flex_order_input( $type, $overwrite ); |
|
| 1845 | - } |
|
| 1846 | - } |
|
| 1842 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1843 | + $overwrite['device_type'] = $dt; |
|
| 1844 | + $inputs[ $type . $ds ] = sd_get_flex_order_input( $type, $overwrite ); |
|
| 1845 | + } |
|
| 1846 | + } |
|
| 1847 | 1847 | |
| 1848 | - return $inputs; |
|
| 1848 | + return $inputs; |
|
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | 1851 | function sd_get_flex_wrap_group( $type = 'flex_wrap', $overwrite = array() ) { |
| 1852 | - $inputs = array(); |
|
| 1853 | - $sizes = array( |
|
| 1854 | - '' => 'Mobile', |
|
| 1855 | - '_md' => 'Tablet', |
|
| 1856 | - '_lg' => 'Desktop', |
|
| 1857 | - ); |
|
| 1852 | + $inputs = array(); |
|
| 1853 | + $sizes = array( |
|
| 1854 | + '' => 'Mobile', |
|
| 1855 | + '_md' => 'Tablet', |
|
| 1856 | + '_lg' => 'Desktop', |
|
| 1857 | + ); |
|
| 1858 | 1858 | |
| 1859 | - if ( $overwrite !== false ) { |
|
| 1859 | + if ( $overwrite !== false ) { |
|
| 1860 | 1860 | |
| 1861 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1862 | - $overwrite['device_type'] = $dt; |
|
| 1863 | - $inputs[ $type . $ds ] = sd_get_flex_wrap_input( $type, $overwrite ); |
|
| 1864 | - } |
|
| 1865 | - } |
|
| 1861 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1862 | + $overwrite['device_type'] = $dt; |
|
| 1863 | + $inputs[ $type . $ds ] = sd_get_flex_wrap_input( $type, $overwrite ); |
|
| 1864 | + } |
|
| 1865 | + } |
|
| 1866 | 1866 | |
| 1867 | - return $inputs; |
|
| 1867 | + return $inputs; |
|
| 1868 | 1868 | } |
| 1869 | 1869 | |
| 1870 | 1870 | function sd_get_flex_wrap_input( $type = 'flex_wrap', $overwrite = array() ) { |
| 1871 | - $device_size = ''; |
|
| 1872 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1873 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1874 | - $device_size = '-md'; |
|
| 1875 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1876 | - $device_size = '-lg'; |
|
| 1877 | - } |
|
| 1878 | - } |
|
| 1879 | - $options = array( |
|
| 1880 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1881 | - 'flex' . $device_size . '-nowrap' => 'nowrap', |
|
| 1882 | - 'flex' . $device_size . '-wrap' => 'wrap', |
|
| 1883 | - 'flex' . $device_size . '-wrap-reverse' => 'wrap-reverse', |
|
| 1884 | - ); |
|
| 1885 | - |
|
| 1886 | - $defaults = array( |
|
| 1887 | - 'type' => 'select', |
|
| 1888 | - 'title' => __( 'Flex wrap', 'ayecode-connect' ), |
|
| 1889 | - 'options' => $options, |
|
| 1890 | - 'default' => '', |
|
| 1891 | - 'desc_tip' => true, |
|
| 1892 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1893 | - ); |
|
| 1894 | - |
|
| 1895 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1896 | - |
|
| 1897 | - return $input; |
|
| 1871 | + $device_size = ''; |
|
| 1872 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1873 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1874 | + $device_size = '-md'; |
|
| 1875 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1876 | + $device_size = '-lg'; |
|
| 1877 | + } |
|
| 1878 | + } |
|
| 1879 | + $options = array( |
|
| 1880 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1881 | + 'flex' . $device_size . '-nowrap' => 'nowrap', |
|
| 1882 | + 'flex' . $device_size . '-wrap' => 'wrap', |
|
| 1883 | + 'flex' . $device_size . '-wrap-reverse' => 'wrap-reverse', |
|
| 1884 | + ); |
|
| 1885 | + |
|
| 1886 | + $defaults = array( |
|
| 1887 | + 'type' => 'select', |
|
| 1888 | + 'title' => __( 'Flex wrap', 'ayecode-connect' ), |
|
| 1889 | + 'options' => $options, |
|
| 1890 | + 'default' => '', |
|
| 1891 | + 'desc_tip' => true, |
|
| 1892 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1893 | + ); |
|
| 1894 | + |
|
| 1895 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1896 | + |
|
| 1897 | + return $input; |
|
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | 1900 | function sd_get_float_group( $type = 'float', $overwrite = array() ) { |
| 1901 | - $inputs = array(); |
|
| 1902 | - $sizes = array( |
|
| 1903 | - '' => 'Mobile', |
|
| 1904 | - '_md' => 'Tablet', |
|
| 1905 | - '_lg' => 'Desktop', |
|
| 1906 | - ); |
|
| 1901 | + $inputs = array(); |
|
| 1902 | + $sizes = array( |
|
| 1903 | + '' => 'Mobile', |
|
| 1904 | + '_md' => 'Tablet', |
|
| 1905 | + '_lg' => 'Desktop', |
|
| 1906 | + ); |
|
| 1907 | 1907 | |
| 1908 | - if ( $overwrite !== false ) { |
|
| 1908 | + if ( $overwrite !== false ) { |
|
| 1909 | 1909 | |
| 1910 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1911 | - $overwrite['device_type'] = $dt; |
|
| 1912 | - $inputs[ $type . $ds ] = sd_get_float_input( $type, $overwrite ); |
|
| 1913 | - } |
|
| 1914 | - } |
|
| 1910 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1911 | + $overwrite['device_type'] = $dt; |
|
| 1912 | + $inputs[ $type . $ds ] = sd_get_float_input( $type, $overwrite ); |
|
| 1913 | + } |
|
| 1914 | + } |
|
| 1915 | 1915 | |
| 1916 | - return $inputs; |
|
| 1916 | + return $inputs; |
|
| 1917 | 1917 | } |
| 1918 | 1918 | function sd_get_float_input( $type = 'float', $overwrite = array() ) { |
| 1919 | - $device_size = ''; |
|
| 1920 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1921 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1922 | - $device_size = '-md'; |
|
| 1923 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1924 | - $device_size = '-lg'; |
|
| 1925 | - } |
|
| 1926 | - } |
|
| 1927 | - $options = array( |
|
| 1928 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1929 | - 'float' . $device_size . '-start' => 'left', |
|
| 1930 | - 'float' . $device_size . '-end' => 'right', |
|
| 1931 | - 'float' . $device_size . '-none' => 'none', |
|
| 1932 | - ); |
|
| 1933 | - |
|
| 1934 | - $defaults = array( |
|
| 1935 | - 'type' => 'select', |
|
| 1936 | - 'title' => __( 'Float', 'ayecode-connect' ), |
|
| 1937 | - 'options' => $options, |
|
| 1938 | - 'default' => '', |
|
| 1939 | - 'desc_tip' => true, |
|
| 1940 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1941 | - ); |
|
| 1942 | - |
|
| 1943 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1944 | - |
|
| 1945 | - return $input; |
|
| 1919 | + $device_size = ''; |
|
| 1920 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1921 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1922 | + $device_size = '-md'; |
|
| 1923 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1924 | + $device_size = '-lg'; |
|
| 1925 | + } |
|
| 1926 | + } |
|
| 1927 | + $options = array( |
|
| 1928 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1929 | + 'float' . $device_size . '-start' => 'left', |
|
| 1930 | + 'float' . $device_size . '-end' => 'right', |
|
| 1931 | + 'float' . $device_size . '-none' => 'none', |
|
| 1932 | + ); |
|
| 1933 | + |
|
| 1934 | + $defaults = array( |
|
| 1935 | + 'type' => 'select', |
|
| 1936 | + 'title' => __( 'Float', 'ayecode-connect' ), |
|
| 1937 | + 'options' => $options, |
|
| 1938 | + 'default' => '', |
|
| 1939 | + 'desc_tip' => true, |
|
| 1940 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1941 | + ); |
|
| 1942 | + |
|
| 1943 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1944 | + |
|
| 1945 | + return $input; |
|
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | 1948 | /** |
@@ -1953,26 +1953,26 @@ discard block |
||
| 1953 | 1953 | */ |
| 1954 | 1954 | function sd_get_zindex_input( $type = 'zindex', $overwrite = array() ) { |
| 1955 | 1955 | |
| 1956 | - $options = array( |
|
| 1957 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1958 | - 'zindex-0' => '0', |
|
| 1959 | - 'zindex-1' => '1', |
|
| 1960 | - 'zindex-5' => '5', |
|
| 1961 | - 'zindex-10' => '10', |
|
| 1962 | - ); |
|
| 1956 | + $options = array( |
|
| 1957 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1958 | + 'zindex-0' => '0', |
|
| 1959 | + 'zindex-1' => '1', |
|
| 1960 | + 'zindex-5' => '5', |
|
| 1961 | + 'zindex-10' => '10', |
|
| 1962 | + ); |
|
| 1963 | 1963 | |
| 1964 | - $defaults = array( |
|
| 1965 | - 'type' => 'select', |
|
| 1966 | - 'title' => __( 'Z-index', 'ayecode-connect' ), |
|
| 1967 | - 'options' => $options, |
|
| 1968 | - 'default' => '', |
|
| 1969 | - 'desc_tip' => true, |
|
| 1970 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1971 | - ); |
|
| 1964 | + $defaults = array( |
|
| 1965 | + 'type' => 'select', |
|
| 1966 | + 'title' => __( 'Z-index', 'ayecode-connect' ), |
|
| 1967 | + 'options' => $options, |
|
| 1968 | + 'default' => '', |
|
| 1969 | + 'desc_tip' => true, |
|
| 1970 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 1971 | + ); |
|
| 1972 | 1972 | |
| 1973 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1973 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1974 | 1974 | |
| 1975 | - return $input; |
|
| 1975 | + return $input; |
|
| 1976 | 1976 | } |
| 1977 | 1977 | |
| 1978 | 1978 | /** |
@@ -1983,26 +1983,26 @@ discard block |
||
| 1983 | 1983 | */ |
| 1984 | 1984 | function sd_get_overflow_input( $type = 'overflow', $overwrite = array() ) { |
| 1985 | 1985 | |
| 1986 | - $options = array( |
|
| 1987 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 1988 | - 'overflow-auto' => __( 'Auto', 'ayecode-connect' ), |
|
| 1989 | - 'overflow-hidden' => __( 'Hidden', 'ayecode-connect' ), |
|
| 1990 | - 'overflow-visible' => __( 'Visible', 'ayecode-connect' ), |
|
| 1991 | - 'overflow-scroll' => __( 'Scroll', 'ayecode-connect' ), |
|
| 1992 | - ); |
|
| 1986 | + $options = array( |
|
| 1987 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 1988 | + 'overflow-auto' => __( 'Auto', 'ayecode-connect' ), |
|
| 1989 | + 'overflow-hidden' => __( 'Hidden', 'ayecode-connect' ), |
|
| 1990 | + 'overflow-visible' => __( 'Visible', 'ayecode-connect' ), |
|
| 1991 | + 'overflow-scroll' => __( 'Scroll', 'ayecode-connect' ), |
|
| 1992 | + ); |
|
| 1993 | 1993 | |
| 1994 | - $defaults = array( |
|
| 1995 | - 'type' => 'select', |
|
| 1996 | - 'title' => __( 'Overflow', 'ayecode-connect' ), |
|
| 1997 | - 'options' => $options, |
|
| 1998 | - 'default' => '', |
|
| 1999 | - 'desc_tip' => true, |
|
| 2000 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 2001 | - ); |
|
| 1994 | + $defaults = array( |
|
| 1995 | + 'type' => 'select', |
|
| 1996 | + 'title' => __( 'Overflow', 'ayecode-connect' ), |
|
| 1997 | + 'options' => $options, |
|
| 1998 | + 'default' => '', |
|
| 1999 | + 'desc_tip' => true, |
|
| 2000 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 2001 | + ); |
|
| 2002 | 2002 | |
| 2003 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2003 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2004 | 2004 | |
| 2005 | - return $input; |
|
| 2005 | + return $input; |
|
| 2006 | 2006 | } |
| 2007 | 2007 | |
| 2008 | 2008 | /** |
@@ -2013,19 +2013,19 @@ discard block |
||
| 2013 | 2013 | */ |
| 2014 | 2014 | function sd_get_max_height_input( $type = 'max_height', $overwrite = array() ) { |
| 2015 | 2015 | |
| 2016 | - $defaults = array( |
|
| 2017 | - 'type' => 'text', |
|
| 2018 | - 'title' => __( 'Max height', 'ayecode-connect' ), |
|
| 2019 | - 'value' => '', |
|
| 2020 | - 'default' => '', |
|
| 2021 | - 'placeholder' => '', |
|
| 2022 | - 'desc_tip' => true, |
|
| 2023 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 2024 | - ); |
|
| 2016 | + $defaults = array( |
|
| 2017 | + 'type' => 'text', |
|
| 2018 | + 'title' => __( 'Max height', 'ayecode-connect' ), |
|
| 2019 | + 'value' => '', |
|
| 2020 | + 'default' => '', |
|
| 2021 | + 'placeholder' => '', |
|
| 2022 | + 'desc_tip' => true, |
|
| 2023 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 2024 | + ); |
|
| 2025 | 2025 | |
| 2026 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2026 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2027 | 2027 | |
| 2028 | - return $input; |
|
| 2028 | + return $input; |
|
| 2029 | 2029 | } |
| 2030 | 2030 | |
| 2031 | 2031 | /** |
@@ -2036,23 +2036,23 @@ discard block |
||
| 2036 | 2036 | */ |
| 2037 | 2037 | function sd_get_scrollbars_input( $type = 'scrollbars', $overwrite = array() ) { |
| 2038 | 2038 | |
| 2039 | - $options = array( |
|
| 2040 | - '' => __( 'Default', 'ayecode-connect' ), |
|
| 2041 | - 'scrollbars-ios' => __( 'IOS Style', 'ayecode-connect' ), |
|
| 2042 | - ); |
|
| 2039 | + $options = array( |
|
| 2040 | + '' => __( 'Default', 'ayecode-connect' ), |
|
| 2041 | + 'scrollbars-ios' => __( 'IOS Style', 'ayecode-connect' ), |
|
| 2042 | + ); |
|
| 2043 | 2043 | |
| 2044 | - $defaults = array( |
|
| 2045 | - 'type' => 'select', |
|
| 2046 | - 'title' => __( 'Scrollbars', 'ayecode-connect' ), |
|
| 2047 | - 'options' => $options, |
|
| 2048 | - 'default' => '', |
|
| 2049 | - 'desc_tip' => true, |
|
| 2050 | - 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 2051 | - ); |
|
| 2044 | + $defaults = array( |
|
| 2045 | + 'type' => 'select', |
|
| 2046 | + 'title' => __( 'Scrollbars', 'ayecode-connect' ), |
|
| 2047 | + 'options' => $options, |
|
| 2048 | + 'default' => '', |
|
| 2049 | + 'desc_tip' => true, |
|
| 2050 | + 'group' => __( 'Wrapper Styles', 'ayecode-connect' ), |
|
| 2051 | + ); |
|
| 2052 | 2052 | |
| 2053 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2053 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2054 | 2054 | |
| 2055 | - return $input; |
|
| 2055 | + return $input; |
|
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | 2058 | /** |
@@ -2063,17 +2063,17 @@ discard block |
||
| 2063 | 2063 | */ |
| 2064 | 2064 | function sd_get_new_window_input( $type = 'target', $overwrite = array() ) { |
| 2065 | 2065 | |
| 2066 | - $defaults = array( |
|
| 2067 | - 'type' => 'checkbox', |
|
| 2068 | - 'title' => __( 'Open in new window', 'ayecode-connect' ), |
|
| 2069 | - 'default' => '', |
|
| 2070 | - 'desc_tip' => true, |
|
| 2071 | - 'group' => __( 'Link', 'ayecode-connect' ), |
|
| 2072 | - ); |
|
| 2066 | + $defaults = array( |
|
| 2067 | + 'type' => 'checkbox', |
|
| 2068 | + 'title' => __( 'Open in new window', 'ayecode-connect' ), |
|
| 2069 | + 'default' => '', |
|
| 2070 | + 'desc_tip' => true, |
|
| 2071 | + 'group' => __( 'Link', 'ayecode-connect' ), |
|
| 2072 | + ); |
|
| 2073 | 2073 | |
| 2074 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2074 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2075 | 2075 | |
| 2076 | - return $input; |
|
| 2076 | + return $input; |
|
| 2077 | 2077 | } |
| 2078 | 2078 | |
| 2079 | 2079 | /** |
@@ -2084,17 +2084,17 @@ discard block |
||
| 2084 | 2084 | */ |
| 2085 | 2085 | function sd_get_nofollow_input( $type = 'nofollow', $overwrite = array() ) { |
| 2086 | 2086 | |
| 2087 | - $defaults = array( |
|
| 2088 | - 'type' => 'checkbox', |
|
| 2089 | - 'title' => __( 'Add nofollow', 'ayecode-connect' ), |
|
| 2090 | - 'default' => '', |
|
| 2091 | - 'desc_tip' => true, |
|
| 2092 | - 'group' => __( 'Link', 'ayecode-connect' ), |
|
| 2093 | - ); |
|
| 2087 | + $defaults = array( |
|
| 2088 | + 'type' => 'checkbox', |
|
| 2089 | + 'title' => __( 'Add nofollow', 'ayecode-connect' ), |
|
| 2090 | + 'default' => '', |
|
| 2091 | + 'desc_tip' => true, |
|
| 2092 | + 'group' => __( 'Link', 'ayecode-connect' ), |
|
| 2093 | + ); |
|
| 2094 | 2094 | |
| 2095 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2095 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2096 | 2096 | |
| 2097 | - return $input; |
|
| 2097 | + return $input; |
|
| 2098 | 2098 | } |
| 2099 | 2099 | |
| 2100 | 2100 | /** |
@@ -2105,19 +2105,19 @@ discard block |
||
| 2105 | 2105 | */ |
| 2106 | 2106 | function sd_get_attributes_input( $type = 'attributes', $overwrite = array() ) { |
| 2107 | 2107 | |
| 2108 | - $defaults = array( |
|
| 2109 | - 'type' => 'text', |
|
| 2110 | - 'title' => __( 'Custom Attributes', 'ayecode-connect' ), |
|
| 2111 | - 'value' => '', |
|
| 2112 | - 'default' => '', |
|
| 2113 | - 'placeholder' => 'key|value,key2|value2', |
|
| 2114 | - 'desc_tip' => true, |
|
| 2115 | - 'group' => __( 'Link', 'ayecode-connect' ), |
|
| 2116 | - ); |
|
| 2108 | + $defaults = array( |
|
| 2109 | + 'type' => 'text', |
|
| 2110 | + 'title' => __( 'Custom Attributes', 'ayecode-connect' ), |
|
| 2111 | + 'value' => '', |
|
| 2112 | + 'default' => '', |
|
| 2113 | + 'placeholder' => 'key|value,key2|value2', |
|
| 2114 | + 'desc_tip' => true, |
|
| 2115 | + 'group' => __( 'Link', 'ayecode-connect' ), |
|
| 2116 | + ); |
|
| 2117 | 2117 | |
| 2118 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2118 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2119 | 2119 | |
| 2120 | - return $input; |
|
| 2120 | + return $input; |
|
| 2121 | 2121 | } |
| 2122 | 2122 | |
| 2123 | 2123 | /** |
@@ -2126,32 +2126,32 @@ discard block |
||
| 2126 | 2126 | * @return string |
| 2127 | 2127 | */ |
| 2128 | 2128 | function sd_build_attributes_string_escaped( $args ) { |
| 2129 | - global $aui_bs5; |
|
| 2129 | + global $aui_bs5; |
|
| 2130 | 2130 | |
| 2131 | - $attributes = array(); |
|
| 2132 | - $string_escaped = ''; |
|
| 2131 | + $attributes = array(); |
|
| 2132 | + $string_escaped = ''; |
|
| 2133 | 2133 | |
| 2134 | - if ( ! empty( $args['custom'] ) ) { |
|
| 2135 | - $attributes = sd_parse_custom_attributes($args['custom']); |
|
| 2136 | - } |
|
| 2134 | + if ( ! empty( $args['custom'] ) ) { |
|
| 2135 | + $attributes = sd_parse_custom_attributes($args['custom']); |
|
| 2136 | + } |
|
| 2137 | 2137 | |
| 2138 | - // new window |
|
| 2139 | - if ( ! empty( $args['new_window'] ) ) { |
|
| 2140 | - $attributes['target'] = '_blank'; |
|
| 2141 | - } |
|
| 2138 | + // new window |
|
| 2139 | + if ( ! empty( $args['new_window'] ) ) { |
|
| 2140 | + $attributes['target'] = '_blank'; |
|
| 2141 | + } |
|
| 2142 | 2142 | |
| 2143 | - // nofollow |
|
| 2144 | - if ( ! empty( $args['nofollow'] ) ) { |
|
| 2145 | - $attributes['rel'] = isset($attributes['rel']) ? $attributes['rel'] . ' nofollow' : 'nofollow'; |
|
| 2146 | - } |
|
| 2143 | + // nofollow |
|
| 2144 | + if ( ! empty( $args['nofollow'] ) ) { |
|
| 2145 | + $attributes['rel'] = isset($attributes['rel']) ? $attributes['rel'] . ' nofollow' : 'nofollow'; |
|
| 2146 | + } |
|
| 2147 | 2147 | |
| 2148 | - if(!empty($attributes )){ |
|
| 2149 | - foreach ( $attributes as $key => $val ) { |
|
| 2150 | - $string_escaped .= esc_attr($key) . '="' . esc_attr($val) . '" '; |
|
| 2151 | - } |
|
| 2152 | - } |
|
| 2148 | + if(!empty($attributes )){ |
|
| 2149 | + foreach ( $attributes as $key => $val ) { |
|
| 2150 | + $string_escaped .= esc_attr($key) . '="' . esc_attr($val) . '" '; |
|
| 2151 | + } |
|
| 2152 | + } |
|
| 2153 | 2153 | |
| 2154 | - return $string_escaped; |
|
| 2154 | + return $string_escaped; |
|
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | 2157 | /** |
@@ -2163,38 +2163,38 @@ discard block |
||
| 2163 | 2163 | * @return array |
| 2164 | 2164 | */ |
| 2165 | 2165 | function sd_parse_custom_attributes( $attributes_string, $delimiter = ',' ) { |
| 2166 | - $attributes = explode( $delimiter, $attributes_string ); |
|
| 2167 | - $result = []; |
|
| 2166 | + $attributes = explode( $delimiter, $attributes_string ); |
|
| 2167 | + $result = []; |
|
| 2168 | 2168 | |
| 2169 | - foreach ( $attributes as $attribute ) { |
|
| 2170 | - $attr_key_value = explode( '|', $attribute ); |
|
| 2169 | + foreach ( $attributes as $attribute ) { |
|
| 2170 | + $attr_key_value = explode( '|', $attribute ); |
|
| 2171 | 2171 | |
| 2172 | - $attr_key = mb_strtolower( $attr_key_value[0] ); |
|
| 2172 | + $attr_key = mb_strtolower( $attr_key_value[0] ); |
|
| 2173 | 2173 | |
| 2174 | - // Remove any not allowed characters. |
|
| 2175 | - preg_match( '/[-_a-z0-9]+/', $attr_key, $attr_key_matches ); |
|
| 2174 | + // Remove any not allowed characters. |
|
| 2175 | + preg_match( '/[-_a-z0-9]+/', $attr_key, $attr_key_matches ); |
|
| 2176 | 2176 | |
| 2177 | - if ( empty( $attr_key_matches[0] ) ) { |
|
| 2178 | - continue; |
|
| 2179 | - } |
|
| 2177 | + if ( empty( $attr_key_matches[0] ) ) { |
|
| 2178 | + continue; |
|
| 2179 | + } |
|
| 2180 | 2180 | |
| 2181 | - $attr_key = $attr_key_matches[0]; |
|
| 2181 | + $attr_key = $attr_key_matches[0]; |
|
| 2182 | 2182 | |
| 2183 | - // Avoid Javascript events and unescaped href. |
|
| 2184 | - if ( 'href' === $attr_key || 'on' === substr( $attr_key, 0, 2 ) ) { |
|
| 2185 | - continue; |
|
| 2186 | - } |
|
| 2183 | + // Avoid Javascript events and unescaped href. |
|
| 2184 | + if ( 'href' === $attr_key || 'on' === substr( $attr_key, 0, 2 ) ) { |
|
| 2185 | + continue; |
|
| 2186 | + } |
|
| 2187 | 2187 | |
| 2188 | - if ( isset( $attr_key_value[1] ) ) { |
|
| 2189 | - $attr_value = trim( $attr_key_value[1] ); |
|
| 2190 | - } else { |
|
| 2191 | - $attr_value = ''; |
|
| 2192 | - } |
|
| 2188 | + if ( isset( $attr_key_value[1] ) ) { |
|
| 2189 | + $attr_value = trim( $attr_key_value[1] ); |
|
| 2190 | + } else { |
|
| 2191 | + $attr_value = ''; |
|
| 2192 | + } |
|
| 2193 | 2193 | |
| 2194 | - $result[ $attr_key ] = $attr_value; |
|
| 2195 | - } |
|
| 2194 | + $result[ $attr_key ] = $attr_value; |
|
| 2195 | + } |
|
| 2196 | 2196 | |
| 2197 | - return $result; |
|
| 2197 | + return $result; |
|
| 2198 | 2198 | } |
| 2199 | 2199 | |
| 2200 | 2200 | /** |
@@ -2206,419 +2206,419 @@ discard block |
||
| 2206 | 2206 | * @todo find best way to use px- py- or general p- |
| 2207 | 2207 | */ |
| 2208 | 2208 | function sd_build_aui_class( $args ) { |
| 2209 | - global $aui_bs5; |
|
| 2210 | - |
|
| 2211 | - $classes = array(); |
|
| 2212 | - |
|
| 2213 | - if ( $aui_bs5 ) { |
|
| 2214 | - $p_ml = 'ms-'; |
|
| 2215 | - $p_mr = 'me-'; |
|
| 2216 | - |
|
| 2217 | - $p_pl = 'ps-'; |
|
| 2218 | - $p_pr = 'pe-'; |
|
| 2219 | - } else { |
|
| 2220 | - $p_ml = 'ml-'; |
|
| 2221 | - $p_mr = 'mr-'; |
|
| 2222 | - |
|
| 2223 | - $p_pl = 'pl-'; |
|
| 2224 | - $p_pr = 'pr-'; |
|
| 2225 | - } |
|
| 2226 | - |
|
| 2227 | - // margins. |
|
| 2228 | - if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 2229 | - $classes[] = 'mt-' . sanitize_html_class( $args['mt'] ); |
|
| 2230 | - $mt = $args['mt']; |
|
| 2231 | - } else { |
|
| 2232 | - $mt = null; |
|
| 2233 | - } |
|
| 2234 | - if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 2235 | - $classes[] = $p_mr . sanitize_html_class( $args['mr'] ); |
|
| 2236 | - $mr = $args['mr']; |
|
| 2237 | - } else { |
|
| 2238 | - $mr = null; |
|
| 2239 | - } |
|
| 2240 | - if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 2241 | - $classes[] = 'mb-' . sanitize_html_class( $args['mb'] ); |
|
| 2242 | - $mb = $args['mb']; |
|
| 2243 | - } else { |
|
| 2244 | - $mb = null; |
|
| 2245 | - } |
|
| 2246 | - if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 2247 | - $classes[] = $p_ml . sanitize_html_class( $args['ml'] ); |
|
| 2248 | - $ml = $args['ml']; |
|
| 2249 | - } else { |
|
| 2250 | - $ml = null; |
|
| 2251 | - } |
|
| 2252 | - |
|
| 2253 | - // margins tablet. |
|
| 2254 | - if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 2255 | - $classes[] = 'mt-md-' . sanitize_html_class( $args['mt_md'] ); |
|
| 2256 | - $mt_md = $args['mt_md']; |
|
| 2257 | - } else { |
|
| 2258 | - $mt_md = null; |
|
| 2259 | - } |
|
| 2260 | - if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 2261 | - $classes[] = $p_mr . 'md-' . sanitize_html_class( $args['mr_md'] ); |
|
| 2262 | - $mt_md = $args['mr_md']; |
|
| 2263 | - } else { |
|
| 2264 | - $mr_md = null; |
|
| 2265 | - } |
|
| 2266 | - if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 2267 | - $classes[] = 'mb-md-' . sanitize_html_class( $args['mb_md'] ); |
|
| 2268 | - $mt_md = $args['mb_md']; |
|
| 2269 | - } else { |
|
| 2270 | - $mb_md = null; |
|
| 2271 | - } |
|
| 2272 | - if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 2273 | - $classes[] = $p_ml . 'md-' . sanitize_html_class( $args['ml_md'] ); |
|
| 2274 | - $mt_md = $args['ml_md']; |
|
| 2275 | - } else { |
|
| 2276 | - $ml_md = null; |
|
| 2277 | - } |
|
| 2278 | - |
|
| 2279 | - // margins desktop. |
|
| 2280 | - if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 2281 | - if ( $mt == null && $mt_md == null ) { |
|
| 2282 | - $classes[] = 'mt-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 2283 | - } else { |
|
| 2284 | - $classes[] = 'mt-lg-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 2285 | - } |
|
| 2286 | - } |
|
| 2287 | - if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 2288 | - if ( $mr == null && $mr_md == null ) { |
|
| 2289 | - $classes[] = $p_mr . sanitize_html_class( $args['mr_lg'] ); |
|
| 2290 | - } else { |
|
| 2291 | - $classes[] = $p_mr . 'lg-' . sanitize_html_class( $args['mr_lg'] ); |
|
| 2292 | - } |
|
| 2293 | - } |
|
| 2294 | - if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 2295 | - if ( $mb == null && $mb_md == null ) { |
|
| 2296 | - $classes[] = 'mb-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 2297 | - } else { |
|
| 2298 | - $classes[] = 'mb-lg-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 2299 | - } |
|
| 2300 | - } |
|
| 2301 | - if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 2302 | - if ( $ml == null && $ml_md == null ) { |
|
| 2303 | - $classes[] = $p_ml . sanitize_html_class( $args['ml_lg'] ); |
|
| 2304 | - } else { |
|
| 2305 | - $classes[] = $p_ml . 'lg-' . sanitize_html_class( $args['ml_lg'] ); |
|
| 2306 | - } |
|
| 2307 | - } |
|
| 2308 | - |
|
| 2309 | - // padding. |
|
| 2310 | - if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 2311 | - $classes[] = 'pt-' . sanitize_html_class( $args['pt'] ); |
|
| 2312 | - $pt = $args['pt']; |
|
| 2313 | - } else { |
|
| 2314 | - $pt = null; |
|
| 2315 | - } |
|
| 2316 | - if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 2317 | - $classes[] = $p_pr . sanitize_html_class( $args['pr'] ); |
|
| 2318 | - $pr = $args['pr']; |
|
| 2319 | - } else { |
|
| 2320 | - $pr = null; |
|
| 2321 | - } |
|
| 2322 | - if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 2323 | - $classes[] = 'pb-' . sanitize_html_class( $args['pb'] ); |
|
| 2324 | - $pb = $args['pb']; |
|
| 2325 | - } else { |
|
| 2326 | - $pb = null; |
|
| 2327 | - } |
|
| 2328 | - if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 2329 | - $classes[] = $p_pl . sanitize_html_class( $args['pl'] ); |
|
| 2330 | - $pl = $args['pl']; |
|
| 2331 | - } else { |
|
| 2332 | - $pl = null; |
|
| 2333 | - } |
|
| 2334 | - |
|
| 2335 | - // padding tablet. |
|
| 2336 | - if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 2337 | - $classes[] = 'pt-md-' . sanitize_html_class( $args['pt_md'] ); |
|
| 2338 | - $pt_md = $args['pt_md']; |
|
| 2339 | - } else { |
|
| 2340 | - $pt_md = null; |
|
| 2341 | - } |
|
| 2342 | - if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 2343 | - $classes[] = $p_pr . 'md-' . sanitize_html_class( $args['pr_md'] ); |
|
| 2344 | - $pr_md = $args['pr_md']; |
|
| 2345 | - } else { |
|
| 2346 | - $pr_md = null; |
|
| 2347 | - } |
|
| 2348 | - if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 2349 | - $classes[] = 'pb-md-' . sanitize_html_class( $args['pb_md'] ); |
|
| 2350 | - $pb_md = $args['pb_md']; |
|
| 2351 | - } else { |
|
| 2352 | - $pb_md = null; |
|
| 2353 | - } |
|
| 2354 | - if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 2355 | - $classes[] = $p_pl . 'md-' . sanitize_html_class( $args['pl_md'] ); |
|
| 2356 | - $pl_md = $args['pl_md']; |
|
| 2357 | - } else { |
|
| 2358 | - $pl_md = null; |
|
| 2359 | - } |
|
| 2360 | - |
|
| 2361 | - // padding desktop. |
|
| 2362 | - if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 2363 | - if ( $pt == null && $pt_md == null ) { |
|
| 2364 | - $classes[] = 'pt-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 2365 | - } else { |
|
| 2366 | - $classes[] = 'pt-lg-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 2367 | - } |
|
| 2368 | - } |
|
| 2369 | - if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 2370 | - if ( $pr == null && $pr_md == null ) { |
|
| 2371 | - $classes[] = $p_pr . sanitize_html_class( $args['pr_lg'] ); |
|
| 2372 | - } else { |
|
| 2373 | - $classes[] = $p_pr . 'lg-' . sanitize_html_class( $args['pr_lg'] ); |
|
| 2374 | - } |
|
| 2375 | - } |
|
| 2376 | - if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 2377 | - if ( $pb == null && $pb_md == null ) { |
|
| 2378 | - $classes[] = 'pb-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 2379 | - } else { |
|
| 2380 | - $classes[] = 'pb-lg-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 2381 | - } |
|
| 2382 | - } |
|
| 2383 | - if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 2384 | - if ( $pl == null && $pl_md == null ) { |
|
| 2385 | - $classes[] = $p_pl . sanitize_html_class( $args['pl_lg'] ); |
|
| 2386 | - } else { |
|
| 2387 | - $classes[] = $p_pl . 'lg-' . sanitize_html_class( $args['pl_lg'] ); |
|
| 2388 | - } |
|
| 2389 | - } |
|
| 2390 | - |
|
| 2391 | - // row cols, mobile, tablet, desktop |
|
| 2392 | - if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 2393 | - $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols'] ); |
|
| 2394 | - $row_cols = $args['row_cols']; |
|
| 2395 | - } else { |
|
| 2396 | - $row_cols = null; |
|
| 2397 | - } |
|
| 2398 | - if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 2399 | - $classes[] = sanitize_html_class( 'row-cols-md-' . $args['row_cols_md'] ); |
|
| 2400 | - $row_cols_md = $args['row_cols_md']; |
|
| 2401 | - } else { |
|
| 2402 | - $row_cols_md = null; |
|
| 2403 | - } |
|
| 2404 | - if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 2405 | - if ( $row_cols == null && $row_cols_md == null ) { |
|
| 2406 | - $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols_lg'] ); |
|
| 2407 | - } else { |
|
| 2408 | - $classes[] = sanitize_html_class( 'row-cols-lg-' . $args['row_cols_lg'] ); |
|
| 2409 | - } |
|
| 2410 | - } |
|
| 2411 | - |
|
| 2412 | - // columns , mobile, tablet, desktop |
|
| 2413 | - if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 2414 | - $classes[] = sanitize_html_class( 'col-' . $args['col'] ); |
|
| 2415 | - $col = $args['col']; |
|
| 2416 | - } else { |
|
| 2417 | - $col = null; |
|
| 2418 | - } |
|
| 2419 | - if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 2420 | - $classes[] = sanitize_html_class( 'col-md-' . $args['col_md'] ); |
|
| 2421 | - $col_md = $args['col_md']; |
|
| 2422 | - } else { |
|
| 2423 | - $col_md = null; |
|
| 2424 | - } |
|
| 2425 | - if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 2426 | - if ( $col == null && $col_md == null ) { |
|
| 2427 | - $classes[] = sanitize_html_class( 'col-' . $args['col_lg'] ); |
|
| 2428 | - } else { |
|
| 2429 | - $classes[] = sanitize_html_class( 'col-lg-' . $args['col_lg'] ); |
|
| 2430 | - } |
|
| 2431 | - } |
|
| 2432 | - |
|
| 2433 | - // border |
|
| 2434 | - if ( isset( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' || $args['border'] === 0 ) ) { |
|
| 2435 | - $classes[] = 'border-0'; |
|
| 2436 | - } elseif ( ! empty( $args['border'] ) ) { |
|
| 2437 | - $border_class = 'border'; |
|
| 2438 | - if ( ! empty( $args['border_type'] ) && strpos( $args['border_type'], '-0' ) === false ) { |
|
| 2439 | - $border_class = ''; |
|
| 2440 | - } |
|
| 2441 | - $classes[] = $border_class . ' border-' . sanitize_html_class( $args['border'] ); |
|
| 2442 | - } |
|
| 2443 | - |
|
| 2444 | - // border radius type |
|
| 2445 | - if ( ! empty( $args['rounded'] ) ) { |
|
| 2446 | - $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 2447 | - } |
|
| 2448 | - |
|
| 2449 | - // border radius size BS4 |
|
| 2450 | - if ( isset( $args['rounded_size'] ) && in_array( $args['rounded_size'], array( 'sm', 'lg' ) ) ) { |
|
| 2451 | - $classes[] = 'rounded-' . sanitize_html_class( $args['rounded_size'] ); |
|
| 2452 | - // if we set a size then we need to remove "rounded" if set |
|
| 2453 | - if ( ( $key = array_search( 'rounded', $classes ) ) !== false ) { |
|
| 2454 | - unset( $classes[ $key ] ); |
|
| 2455 | - } |
|
| 2456 | - } else { |
|
| 2457 | - |
|
| 2458 | - // border radius size , mobile, tablet, desktop |
|
| 2459 | - if ( isset( $args['rounded_size'] ) && $args['rounded_size'] !== '' ) { |
|
| 2460 | - $classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size'] ); |
|
| 2461 | - $rounded_size = $args['rounded_size']; |
|
| 2462 | - } else { |
|
| 2463 | - $rounded_size = null; |
|
| 2464 | - } |
|
| 2465 | - if ( isset( $args['rounded_size_md'] ) && $args['rounded_size_md'] !== '' ) { |
|
| 2466 | - $classes[] = sanitize_html_class( 'rounded-md-' . $args['rounded_size_md'] ); |
|
| 2467 | - $rounded_size_md = $args['rounded_size_md']; |
|
| 2468 | - } else { |
|
| 2469 | - $rounded_size_md = null; |
|
| 2470 | - } |
|
| 2471 | - if ( isset( $args['rounded_size_lg'] ) && $args['rounded_size_lg'] !== '' ) { |
|
| 2472 | - if ( $rounded_size == null && $rounded_size_md == null ) { |
|
| 2473 | - $classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size_lg'] ); |
|
| 2474 | - } else { |
|
| 2475 | - $classes[] = sanitize_html_class( 'rounded-lg-' . $args['rounded_size_lg'] ); |
|
| 2476 | - } |
|
| 2477 | - } |
|
| 2478 | - } |
|
| 2479 | - |
|
| 2480 | - // shadow |
|
| 2481 | - //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 2482 | - |
|
| 2483 | - // background |
|
| 2484 | - if ( ! empty( $args['bg'] ) ) { |
|
| 2485 | - $classes[] = 'bg-' . sanitize_html_class( $args['bg'] ); |
|
| 2486 | - } |
|
| 2487 | - |
|
| 2488 | - // text_color |
|
| 2489 | - if ( ! empty( $args['text_color'] ) ) { |
|
| 2490 | - $classes[] = 'text-' . sanitize_html_class( $args['text_color'] ); |
|
| 2491 | - } |
|
| 2492 | - |
|
| 2493 | - // text_align |
|
| 2494 | - if ( ! empty( $args['text_justify'] ) ) { |
|
| 2495 | - $classes[] = 'text-justify'; |
|
| 2496 | - } else { |
|
| 2497 | - if ( ! empty( $args['text_align'] ) ) { |
|
| 2498 | - $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 2499 | - $text_align = $args['text_align']; |
|
| 2500 | - } else { |
|
| 2501 | - $text_align = null; |
|
| 2502 | - } |
|
| 2503 | - if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 2504 | - $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 2505 | - $text_align_md = $args['text_align_md']; |
|
| 2506 | - } else { |
|
| 2507 | - $text_align_md = null; |
|
| 2508 | - } |
|
| 2509 | - if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 2510 | - if ( $text_align == null && $text_align_md == null ) { |
|
| 2511 | - $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['text_align_lg'] ) ); |
|
| 2512 | - } else { |
|
| 2513 | - $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 2514 | - } |
|
| 2515 | - } |
|
| 2516 | - } |
|
| 2517 | - |
|
| 2518 | - // display |
|
| 2519 | - if ( ! empty( $args['display'] ) ) { |
|
| 2520 | - $classes[] = sanitize_html_class( $args['display'] ); |
|
| 2521 | - $display = $args['display']; |
|
| 2522 | - } else { |
|
| 2523 | - $display = null; |
|
| 2524 | - } |
|
| 2525 | - if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 2526 | - $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 2527 | - $display_md = $args['display_md']; |
|
| 2528 | - } else { |
|
| 2529 | - $display_md = null; |
|
| 2530 | - } |
|
| 2531 | - if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 2532 | - if ( $display == null && $display_md == null ) { |
|
| 2533 | - $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['display_lg'] ) ); |
|
| 2534 | - } else { |
|
| 2535 | - $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 2536 | - } |
|
| 2537 | - } |
|
| 2538 | - |
|
| 2539 | - // bgtus - background transparent until scroll |
|
| 2540 | - if ( ! empty( $args['bgtus'] ) ) { |
|
| 2541 | - $classes[] = sanitize_html_class( 'bg-transparent-until-scroll' ); |
|
| 2542 | - } |
|
| 2543 | - |
|
| 2544 | - // cscos - change color scheme on scroll |
|
| 2545 | - if ( ! empty( $args['bgtus'] ) && ! empty( $args['cscos'] ) ) { |
|
| 2546 | - $classes[] = sanitize_html_class( 'color-scheme-flip-on-scroll' ); |
|
| 2547 | - } |
|
| 2548 | - |
|
| 2549 | - // hover animations |
|
| 2550 | - if ( ! empty( $args['hover_animations'] ) ) { |
|
| 2551 | - $classes[] = sd_sanitize_html_classes( str_replace( ',', ' ', $args['hover_animations'] ) ); |
|
| 2552 | - } |
|
| 2553 | - |
|
| 2554 | - // absolute_position |
|
| 2555 | - if ( ! empty( $args['absolute_position'] ) ) { |
|
| 2556 | - if ( 'top-left' === $args['absolute_position'] ) { |
|
| 2557 | - $classes[] = 'start-0 top-0'; |
|
| 2558 | - } elseif ( 'top-center' === $args['absolute_position'] ) { |
|
| 2559 | - $classes[] = 'start-50 top-0 translate-middle'; |
|
| 2560 | - } elseif ( 'top-right' === $args['absolute_position'] ) { |
|
| 2561 | - $classes[] = 'end-0 top-0'; |
|
| 2562 | - } elseif ( 'center-left' === $args['absolute_position'] ) { |
|
| 2563 | - $classes[] = 'start-0 top-50'; |
|
| 2564 | - } elseif ( 'center' === $args['absolute_position'] ) { |
|
| 2565 | - $classes[] = 'start-50 top-50 translate-middle'; |
|
| 2566 | - } elseif ( 'center-right' === $args['absolute_position'] ) { |
|
| 2567 | - $classes[] = 'end-0 top-50'; |
|
| 2568 | - } elseif ( 'bottom-left' === $args['absolute_position'] ) { |
|
| 2569 | - $classes[] = 'start-0 bottom-0'; |
|
| 2570 | - } elseif ( 'bottom-center' === $args['absolute_position'] ) { |
|
| 2571 | - $classes[] = 'start-50 bottom-0 translate-middle'; |
|
| 2572 | - } elseif ( 'bottom-right' === $args['absolute_position'] ) { |
|
| 2573 | - $classes[] = 'end-0 bottom-0'; |
|
| 2574 | - } |
|
| 2575 | - } |
|
| 2576 | - |
|
| 2577 | - // build classes from build keys |
|
| 2578 | - $build_keys = sd_get_class_build_keys(); |
|
| 2579 | - if ( ! empty( $build_keys ) ) { |
|
| 2580 | - foreach ( $build_keys as $key ) { |
|
| 2581 | - |
|
| 2582 | - if ( substr( $key, -4 ) == '-MTD' ) { |
|
| 2583 | - |
|
| 2584 | - $k = str_replace( '-MTD', '', $key ); |
|
| 2585 | - |
|
| 2586 | - // Mobile, Tablet, Desktop |
|
| 2587 | - if ( ! empty( $args[ $k ] ) && $args[ $k ] !== '' ) { |
|
| 2588 | - $classes[] = sanitize_html_class( $args[ $k ] ); |
|
| 2589 | - $v = $args[ $k ]; |
|
| 2590 | - } else { |
|
| 2591 | - $v = null; |
|
| 2592 | - } |
|
| 2593 | - if ( ! empty( $args[ $k . '_md' ] ) && $args[ $k . '_md' ] !== '' ) { |
|
| 2594 | - $classes[] = sanitize_html_class( $args[ $k . '_md' ] ); |
|
| 2595 | - $v_md = $args[ $k . '_md' ]; |
|
| 2596 | - } else { |
|
| 2597 | - $v_md = null; |
|
| 2598 | - } |
|
| 2599 | - if ( ! empty( $args[ $k . '_lg' ] ) && $args[ $k . '_lg' ] !== '' ) { |
|
| 2600 | - if ( $v == null && $v_md == null ) { |
|
| 2601 | - $classes[] = sanitize_html_class( str_replace( '-lg', '', $args[ $k . '_lg' ] ) ); |
|
| 2602 | - } else { |
|
| 2603 | - $classes[] = sanitize_html_class( $args[ $k . '_lg' ] ); |
|
| 2604 | - } |
|
| 2605 | - } |
|
| 2606 | - } else { |
|
| 2607 | - if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 2608 | - continue; |
|
| 2609 | - } |
|
| 2610 | - if ( ! empty( $args[ $key ] ) ) { |
|
| 2611 | - $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 2612 | - } |
|
| 2613 | - } |
|
| 2614 | - } |
|
| 2615 | - } |
|
| 2616 | - |
|
| 2617 | - if ( ! empty( $classes ) ) { |
|
| 2618 | - $classes = array_unique( array_filter( array_map( 'trim', $classes ) ) ); |
|
| 2619 | - } |
|
| 2620 | - |
|
| 2621 | - return implode( ' ', $classes ); |
|
| 2209 | + global $aui_bs5; |
|
| 2210 | + |
|
| 2211 | + $classes = array(); |
|
| 2212 | + |
|
| 2213 | + if ( $aui_bs5 ) { |
|
| 2214 | + $p_ml = 'ms-'; |
|
| 2215 | + $p_mr = 'me-'; |
|
| 2216 | + |
|
| 2217 | + $p_pl = 'ps-'; |
|
| 2218 | + $p_pr = 'pe-'; |
|
| 2219 | + } else { |
|
| 2220 | + $p_ml = 'ml-'; |
|
| 2221 | + $p_mr = 'mr-'; |
|
| 2222 | + |
|
| 2223 | + $p_pl = 'pl-'; |
|
| 2224 | + $p_pr = 'pr-'; |
|
| 2225 | + } |
|
| 2226 | + |
|
| 2227 | + // margins. |
|
| 2228 | + if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 2229 | + $classes[] = 'mt-' . sanitize_html_class( $args['mt'] ); |
|
| 2230 | + $mt = $args['mt']; |
|
| 2231 | + } else { |
|
| 2232 | + $mt = null; |
|
| 2233 | + } |
|
| 2234 | + if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 2235 | + $classes[] = $p_mr . sanitize_html_class( $args['mr'] ); |
|
| 2236 | + $mr = $args['mr']; |
|
| 2237 | + } else { |
|
| 2238 | + $mr = null; |
|
| 2239 | + } |
|
| 2240 | + if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 2241 | + $classes[] = 'mb-' . sanitize_html_class( $args['mb'] ); |
|
| 2242 | + $mb = $args['mb']; |
|
| 2243 | + } else { |
|
| 2244 | + $mb = null; |
|
| 2245 | + } |
|
| 2246 | + if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 2247 | + $classes[] = $p_ml . sanitize_html_class( $args['ml'] ); |
|
| 2248 | + $ml = $args['ml']; |
|
| 2249 | + } else { |
|
| 2250 | + $ml = null; |
|
| 2251 | + } |
|
| 2252 | + |
|
| 2253 | + // margins tablet. |
|
| 2254 | + if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 2255 | + $classes[] = 'mt-md-' . sanitize_html_class( $args['mt_md'] ); |
|
| 2256 | + $mt_md = $args['mt_md']; |
|
| 2257 | + } else { |
|
| 2258 | + $mt_md = null; |
|
| 2259 | + } |
|
| 2260 | + if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 2261 | + $classes[] = $p_mr . 'md-' . sanitize_html_class( $args['mr_md'] ); |
|
| 2262 | + $mt_md = $args['mr_md']; |
|
| 2263 | + } else { |
|
| 2264 | + $mr_md = null; |
|
| 2265 | + } |
|
| 2266 | + if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 2267 | + $classes[] = 'mb-md-' . sanitize_html_class( $args['mb_md'] ); |
|
| 2268 | + $mt_md = $args['mb_md']; |
|
| 2269 | + } else { |
|
| 2270 | + $mb_md = null; |
|
| 2271 | + } |
|
| 2272 | + if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 2273 | + $classes[] = $p_ml . 'md-' . sanitize_html_class( $args['ml_md'] ); |
|
| 2274 | + $mt_md = $args['ml_md']; |
|
| 2275 | + } else { |
|
| 2276 | + $ml_md = null; |
|
| 2277 | + } |
|
| 2278 | + |
|
| 2279 | + // margins desktop. |
|
| 2280 | + if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 2281 | + if ( $mt == null && $mt_md == null ) { |
|
| 2282 | + $classes[] = 'mt-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 2283 | + } else { |
|
| 2284 | + $classes[] = 'mt-lg-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 2285 | + } |
|
| 2286 | + } |
|
| 2287 | + if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 2288 | + if ( $mr == null && $mr_md == null ) { |
|
| 2289 | + $classes[] = $p_mr . sanitize_html_class( $args['mr_lg'] ); |
|
| 2290 | + } else { |
|
| 2291 | + $classes[] = $p_mr . 'lg-' . sanitize_html_class( $args['mr_lg'] ); |
|
| 2292 | + } |
|
| 2293 | + } |
|
| 2294 | + if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 2295 | + if ( $mb == null && $mb_md == null ) { |
|
| 2296 | + $classes[] = 'mb-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 2297 | + } else { |
|
| 2298 | + $classes[] = 'mb-lg-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 2299 | + } |
|
| 2300 | + } |
|
| 2301 | + if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 2302 | + if ( $ml == null && $ml_md == null ) { |
|
| 2303 | + $classes[] = $p_ml . sanitize_html_class( $args['ml_lg'] ); |
|
| 2304 | + } else { |
|
| 2305 | + $classes[] = $p_ml . 'lg-' . sanitize_html_class( $args['ml_lg'] ); |
|
| 2306 | + } |
|
| 2307 | + } |
|
| 2308 | + |
|
| 2309 | + // padding. |
|
| 2310 | + if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 2311 | + $classes[] = 'pt-' . sanitize_html_class( $args['pt'] ); |
|
| 2312 | + $pt = $args['pt']; |
|
| 2313 | + } else { |
|
| 2314 | + $pt = null; |
|
| 2315 | + } |
|
| 2316 | + if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 2317 | + $classes[] = $p_pr . sanitize_html_class( $args['pr'] ); |
|
| 2318 | + $pr = $args['pr']; |
|
| 2319 | + } else { |
|
| 2320 | + $pr = null; |
|
| 2321 | + } |
|
| 2322 | + if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 2323 | + $classes[] = 'pb-' . sanitize_html_class( $args['pb'] ); |
|
| 2324 | + $pb = $args['pb']; |
|
| 2325 | + } else { |
|
| 2326 | + $pb = null; |
|
| 2327 | + } |
|
| 2328 | + if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 2329 | + $classes[] = $p_pl . sanitize_html_class( $args['pl'] ); |
|
| 2330 | + $pl = $args['pl']; |
|
| 2331 | + } else { |
|
| 2332 | + $pl = null; |
|
| 2333 | + } |
|
| 2334 | + |
|
| 2335 | + // padding tablet. |
|
| 2336 | + if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 2337 | + $classes[] = 'pt-md-' . sanitize_html_class( $args['pt_md'] ); |
|
| 2338 | + $pt_md = $args['pt_md']; |
|
| 2339 | + } else { |
|
| 2340 | + $pt_md = null; |
|
| 2341 | + } |
|
| 2342 | + if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 2343 | + $classes[] = $p_pr . 'md-' . sanitize_html_class( $args['pr_md'] ); |
|
| 2344 | + $pr_md = $args['pr_md']; |
|
| 2345 | + } else { |
|
| 2346 | + $pr_md = null; |
|
| 2347 | + } |
|
| 2348 | + if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 2349 | + $classes[] = 'pb-md-' . sanitize_html_class( $args['pb_md'] ); |
|
| 2350 | + $pb_md = $args['pb_md']; |
|
| 2351 | + } else { |
|
| 2352 | + $pb_md = null; |
|
| 2353 | + } |
|
| 2354 | + if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 2355 | + $classes[] = $p_pl . 'md-' . sanitize_html_class( $args['pl_md'] ); |
|
| 2356 | + $pl_md = $args['pl_md']; |
|
| 2357 | + } else { |
|
| 2358 | + $pl_md = null; |
|
| 2359 | + } |
|
| 2360 | + |
|
| 2361 | + // padding desktop. |
|
| 2362 | + if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 2363 | + if ( $pt == null && $pt_md == null ) { |
|
| 2364 | + $classes[] = 'pt-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 2365 | + } else { |
|
| 2366 | + $classes[] = 'pt-lg-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 2367 | + } |
|
| 2368 | + } |
|
| 2369 | + if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 2370 | + if ( $pr == null && $pr_md == null ) { |
|
| 2371 | + $classes[] = $p_pr . sanitize_html_class( $args['pr_lg'] ); |
|
| 2372 | + } else { |
|
| 2373 | + $classes[] = $p_pr . 'lg-' . sanitize_html_class( $args['pr_lg'] ); |
|
| 2374 | + } |
|
| 2375 | + } |
|
| 2376 | + if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 2377 | + if ( $pb == null && $pb_md == null ) { |
|
| 2378 | + $classes[] = 'pb-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 2379 | + } else { |
|
| 2380 | + $classes[] = 'pb-lg-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 2381 | + } |
|
| 2382 | + } |
|
| 2383 | + if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 2384 | + if ( $pl == null && $pl_md == null ) { |
|
| 2385 | + $classes[] = $p_pl . sanitize_html_class( $args['pl_lg'] ); |
|
| 2386 | + } else { |
|
| 2387 | + $classes[] = $p_pl . 'lg-' . sanitize_html_class( $args['pl_lg'] ); |
|
| 2388 | + } |
|
| 2389 | + } |
|
| 2390 | + |
|
| 2391 | + // row cols, mobile, tablet, desktop |
|
| 2392 | + if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 2393 | + $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols'] ); |
|
| 2394 | + $row_cols = $args['row_cols']; |
|
| 2395 | + } else { |
|
| 2396 | + $row_cols = null; |
|
| 2397 | + } |
|
| 2398 | + if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 2399 | + $classes[] = sanitize_html_class( 'row-cols-md-' . $args['row_cols_md'] ); |
|
| 2400 | + $row_cols_md = $args['row_cols_md']; |
|
| 2401 | + } else { |
|
| 2402 | + $row_cols_md = null; |
|
| 2403 | + } |
|
| 2404 | + if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 2405 | + if ( $row_cols == null && $row_cols_md == null ) { |
|
| 2406 | + $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols_lg'] ); |
|
| 2407 | + } else { |
|
| 2408 | + $classes[] = sanitize_html_class( 'row-cols-lg-' . $args['row_cols_lg'] ); |
|
| 2409 | + } |
|
| 2410 | + } |
|
| 2411 | + |
|
| 2412 | + // columns , mobile, tablet, desktop |
|
| 2413 | + if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 2414 | + $classes[] = sanitize_html_class( 'col-' . $args['col'] ); |
|
| 2415 | + $col = $args['col']; |
|
| 2416 | + } else { |
|
| 2417 | + $col = null; |
|
| 2418 | + } |
|
| 2419 | + if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 2420 | + $classes[] = sanitize_html_class( 'col-md-' . $args['col_md'] ); |
|
| 2421 | + $col_md = $args['col_md']; |
|
| 2422 | + } else { |
|
| 2423 | + $col_md = null; |
|
| 2424 | + } |
|
| 2425 | + if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 2426 | + if ( $col == null && $col_md == null ) { |
|
| 2427 | + $classes[] = sanitize_html_class( 'col-' . $args['col_lg'] ); |
|
| 2428 | + } else { |
|
| 2429 | + $classes[] = sanitize_html_class( 'col-lg-' . $args['col_lg'] ); |
|
| 2430 | + } |
|
| 2431 | + } |
|
| 2432 | + |
|
| 2433 | + // border |
|
| 2434 | + if ( isset( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' || $args['border'] === 0 ) ) { |
|
| 2435 | + $classes[] = 'border-0'; |
|
| 2436 | + } elseif ( ! empty( $args['border'] ) ) { |
|
| 2437 | + $border_class = 'border'; |
|
| 2438 | + if ( ! empty( $args['border_type'] ) && strpos( $args['border_type'], '-0' ) === false ) { |
|
| 2439 | + $border_class = ''; |
|
| 2440 | + } |
|
| 2441 | + $classes[] = $border_class . ' border-' . sanitize_html_class( $args['border'] ); |
|
| 2442 | + } |
|
| 2443 | + |
|
| 2444 | + // border radius type |
|
| 2445 | + if ( ! empty( $args['rounded'] ) ) { |
|
| 2446 | + $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 2447 | + } |
|
| 2448 | + |
|
| 2449 | + // border radius size BS4 |
|
| 2450 | + if ( isset( $args['rounded_size'] ) && in_array( $args['rounded_size'], array( 'sm', 'lg' ) ) ) { |
|
| 2451 | + $classes[] = 'rounded-' . sanitize_html_class( $args['rounded_size'] ); |
|
| 2452 | + // if we set a size then we need to remove "rounded" if set |
|
| 2453 | + if ( ( $key = array_search( 'rounded', $classes ) ) !== false ) { |
|
| 2454 | + unset( $classes[ $key ] ); |
|
| 2455 | + } |
|
| 2456 | + } else { |
|
| 2457 | + |
|
| 2458 | + // border radius size , mobile, tablet, desktop |
|
| 2459 | + if ( isset( $args['rounded_size'] ) && $args['rounded_size'] !== '' ) { |
|
| 2460 | + $classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size'] ); |
|
| 2461 | + $rounded_size = $args['rounded_size']; |
|
| 2462 | + } else { |
|
| 2463 | + $rounded_size = null; |
|
| 2464 | + } |
|
| 2465 | + if ( isset( $args['rounded_size_md'] ) && $args['rounded_size_md'] !== '' ) { |
|
| 2466 | + $classes[] = sanitize_html_class( 'rounded-md-' . $args['rounded_size_md'] ); |
|
| 2467 | + $rounded_size_md = $args['rounded_size_md']; |
|
| 2468 | + } else { |
|
| 2469 | + $rounded_size_md = null; |
|
| 2470 | + } |
|
| 2471 | + if ( isset( $args['rounded_size_lg'] ) && $args['rounded_size_lg'] !== '' ) { |
|
| 2472 | + if ( $rounded_size == null && $rounded_size_md == null ) { |
|
| 2473 | + $classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size_lg'] ); |
|
| 2474 | + } else { |
|
| 2475 | + $classes[] = sanitize_html_class( 'rounded-lg-' . $args['rounded_size_lg'] ); |
|
| 2476 | + } |
|
| 2477 | + } |
|
| 2478 | + } |
|
| 2479 | + |
|
| 2480 | + // shadow |
|
| 2481 | + //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 2482 | + |
|
| 2483 | + // background |
|
| 2484 | + if ( ! empty( $args['bg'] ) ) { |
|
| 2485 | + $classes[] = 'bg-' . sanitize_html_class( $args['bg'] ); |
|
| 2486 | + } |
|
| 2487 | + |
|
| 2488 | + // text_color |
|
| 2489 | + if ( ! empty( $args['text_color'] ) ) { |
|
| 2490 | + $classes[] = 'text-' . sanitize_html_class( $args['text_color'] ); |
|
| 2491 | + } |
|
| 2492 | + |
|
| 2493 | + // text_align |
|
| 2494 | + if ( ! empty( $args['text_justify'] ) ) { |
|
| 2495 | + $classes[] = 'text-justify'; |
|
| 2496 | + } else { |
|
| 2497 | + if ( ! empty( $args['text_align'] ) ) { |
|
| 2498 | + $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 2499 | + $text_align = $args['text_align']; |
|
| 2500 | + } else { |
|
| 2501 | + $text_align = null; |
|
| 2502 | + } |
|
| 2503 | + if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 2504 | + $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 2505 | + $text_align_md = $args['text_align_md']; |
|
| 2506 | + } else { |
|
| 2507 | + $text_align_md = null; |
|
| 2508 | + } |
|
| 2509 | + if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 2510 | + if ( $text_align == null && $text_align_md == null ) { |
|
| 2511 | + $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['text_align_lg'] ) ); |
|
| 2512 | + } else { |
|
| 2513 | + $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 2514 | + } |
|
| 2515 | + } |
|
| 2516 | + } |
|
| 2517 | + |
|
| 2518 | + // display |
|
| 2519 | + if ( ! empty( $args['display'] ) ) { |
|
| 2520 | + $classes[] = sanitize_html_class( $args['display'] ); |
|
| 2521 | + $display = $args['display']; |
|
| 2522 | + } else { |
|
| 2523 | + $display = null; |
|
| 2524 | + } |
|
| 2525 | + if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 2526 | + $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 2527 | + $display_md = $args['display_md']; |
|
| 2528 | + } else { |
|
| 2529 | + $display_md = null; |
|
| 2530 | + } |
|
| 2531 | + if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 2532 | + if ( $display == null && $display_md == null ) { |
|
| 2533 | + $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['display_lg'] ) ); |
|
| 2534 | + } else { |
|
| 2535 | + $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 2536 | + } |
|
| 2537 | + } |
|
| 2538 | + |
|
| 2539 | + // bgtus - background transparent until scroll |
|
| 2540 | + if ( ! empty( $args['bgtus'] ) ) { |
|
| 2541 | + $classes[] = sanitize_html_class( 'bg-transparent-until-scroll' ); |
|
| 2542 | + } |
|
| 2543 | + |
|
| 2544 | + // cscos - change color scheme on scroll |
|
| 2545 | + if ( ! empty( $args['bgtus'] ) && ! empty( $args['cscos'] ) ) { |
|
| 2546 | + $classes[] = sanitize_html_class( 'color-scheme-flip-on-scroll' ); |
|
| 2547 | + } |
|
| 2548 | + |
|
| 2549 | + // hover animations |
|
| 2550 | + if ( ! empty( $args['hover_animations'] ) ) { |
|
| 2551 | + $classes[] = sd_sanitize_html_classes( str_replace( ',', ' ', $args['hover_animations'] ) ); |
|
| 2552 | + } |
|
| 2553 | + |
|
| 2554 | + // absolute_position |
|
| 2555 | + if ( ! empty( $args['absolute_position'] ) ) { |
|
| 2556 | + if ( 'top-left' === $args['absolute_position'] ) { |
|
| 2557 | + $classes[] = 'start-0 top-0'; |
|
| 2558 | + } elseif ( 'top-center' === $args['absolute_position'] ) { |
|
| 2559 | + $classes[] = 'start-50 top-0 translate-middle'; |
|
| 2560 | + } elseif ( 'top-right' === $args['absolute_position'] ) { |
|
| 2561 | + $classes[] = 'end-0 top-0'; |
|
| 2562 | + } elseif ( 'center-left' === $args['absolute_position'] ) { |
|
| 2563 | + $classes[] = 'start-0 top-50'; |
|
| 2564 | + } elseif ( 'center' === $args['absolute_position'] ) { |
|
| 2565 | + $classes[] = 'start-50 top-50 translate-middle'; |
|
| 2566 | + } elseif ( 'center-right' === $args['absolute_position'] ) { |
|
| 2567 | + $classes[] = 'end-0 top-50'; |
|
| 2568 | + } elseif ( 'bottom-left' === $args['absolute_position'] ) { |
|
| 2569 | + $classes[] = 'start-0 bottom-0'; |
|
| 2570 | + } elseif ( 'bottom-center' === $args['absolute_position'] ) { |
|
| 2571 | + $classes[] = 'start-50 bottom-0 translate-middle'; |
|
| 2572 | + } elseif ( 'bottom-right' === $args['absolute_position'] ) { |
|
| 2573 | + $classes[] = 'end-0 bottom-0'; |
|
| 2574 | + } |
|
| 2575 | + } |
|
| 2576 | + |
|
| 2577 | + // build classes from build keys |
|
| 2578 | + $build_keys = sd_get_class_build_keys(); |
|
| 2579 | + if ( ! empty( $build_keys ) ) { |
|
| 2580 | + foreach ( $build_keys as $key ) { |
|
| 2581 | + |
|
| 2582 | + if ( substr( $key, -4 ) == '-MTD' ) { |
|
| 2583 | + |
|
| 2584 | + $k = str_replace( '-MTD', '', $key ); |
|
| 2585 | + |
|
| 2586 | + // Mobile, Tablet, Desktop |
|
| 2587 | + if ( ! empty( $args[ $k ] ) && $args[ $k ] !== '' ) { |
|
| 2588 | + $classes[] = sanitize_html_class( $args[ $k ] ); |
|
| 2589 | + $v = $args[ $k ]; |
|
| 2590 | + } else { |
|
| 2591 | + $v = null; |
|
| 2592 | + } |
|
| 2593 | + if ( ! empty( $args[ $k . '_md' ] ) && $args[ $k . '_md' ] !== '' ) { |
|
| 2594 | + $classes[] = sanitize_html_class( $args[ $k . '_md' ] ); |
|
| 2595 | + $v_md = $args[ $k . '_md' ]; |
|
| 2596 | + } else { |
|
| 2597 | + $v_md = null; |
|
| 2598 | + } |
|
| 2599 | + if ( ! empty( $args[ $k . '_lg' ] ) && $args[ $k . '_lg' ] !== '' ) { |
|
| 2600 | + if ( $v == null && $v_md == null ) { |
|
| 2601 | + $classes[] = sanitize_html_class( str_replace( '-lg', '', $args[ $k . '_lg' ] ) ); |
|
| 2602 | + } else { |
|
| 2603 | + $classes[] = sanitize_html_class( $args[ $k . '_lg' ] ); |
|
| 2604 | + } |
|
| 2605 | + } |
|
| 2606 | + } else { |
|
| 2607 | + if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 2608 | + continue; |
|
| 2609 | + } |
|
| 2610 | + if ( ! empty( $args[ $key ] ) ) { |
|
| 2611 | + $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 2612 | + } |
|
| 2613 | + } |
|
| 2614 | + } |
|
| 2615 | + } |
|
| 2616 | + |
|
| 2617 | + if ( ! empty( $classes ) ) { |
|
| 2618 | + $classes = array_unique( array_filter( array_map( 'trim', $classes ) ) ); |
|
| 2619 | + } |
|
| 2620 | + |
|
| 2621 | + return implode( ' ', $classes ); |
|
| 2622 | 2622 | } |
| 2623 | 2623 | |
| 2624 | 2624 | /** |
@@ -2630,90 +2630,90 @@ discard block |
||
| 2630 | 2630 | */ |
| 2631 | 2631 | function sd_build_aui_styles( $args ) { |
| 2632 | 2632 | |
| 2633 | - $styles = array(); |
|
| 2634 | - |
|
| 2635 | - // background color |
|
| 2636 | - if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 2637 | - if ( $args['bg'] == 'custom-color' ) { |
|
| 2638 | - $styles['background-color'] = $args['bg_color']; |
|
| 2639 | - } elseif ( $args['bg'] == 'custom-gradient' ) { |
|
| 2640 | - $styles['background-image'] = $args['bg_gradient']; |
|
| 2641 | - |
|
| 2642 | - // use background on text. |
|
| 2643 | - if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 2644 | - $styles['background-clip'] = 'text'; |
|
| 2645 | - $styles['-webkit-background-clip'] = 'text'; |
|
| 2646 | - $styles['text-fill-color'] = 'transparent'; |
|
| 2647 | - $styles['-webkit-text-fill-color'] = 'transparent'; |
|
| 2648 | - } |
|
| 2649 | - } |
|
| 2650 | - } |
|
| 2651 | - |
|
| 2652 | - if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 2653 | - $hasImage = true; |
|
| 2654 | - if ( ! empty( $styles['background-color'] ) && $args['bg'] == 'custom-color' ) { |
|
| 2655 | - $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2656 | - $styles['background-blend-mode'] = 'overlay'; |
|
| 2657 | - } elseif ( ! empty( $styles['background-image'] ) && $args['bg'] == 'custom-gradient' ) { |
|
| 2658 | - $styles['background-image'] .= ',url(' . $args['bg_image'] . ')'; |
|
| 2659 | - } elseif ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 2660 | - // do nothing as we alreay have a preset |
|
| 2661 | - $hasImage = false; |
|
| 2662 | - } else { |
|
| 2663 | - $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2664 | - } |
|
| 2665 | - |
|
| 2666 | - if ( $hasImage ) { |
|
| 2667 | - $styles['background-size'] = 'cover'; |
|
| 2668 | - |
|
| 2669 | - if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 2670 | - $styles['background-attachment'] = 'fixed'; |
|
| 2671 | - } |
|
| 2672 | - } |
|
| 2673 | - |
|
| 2674 | - if ( $hasImage && ! empty( $args['bg_image_xy'] ) && ! empty( $args['bg_image_xy']['x'] ) ) { |
|
| 2675 | - $styles['background-position'] = ( $args['bg_image_xy']['x'] * 100 ) . '% ' . ( $args['bg_image_xy']['y'] * 100 ) . '%'; |
|
| 2676 | - } |
|
| 2677 | - } |
|
| 2678 | - |
|
| 2679 | - // sticky offset top |
|
| 2680 | - if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 2681 | - $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 2682 | - } |
|
| 2683 | - |
|
| 2684 | - // sticky offset bottom |
|
| 2685 | - if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 2686 | - $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 2687 | - } |
|
| 2688 | - |
|
| 2689 | - // font size |
|
| 2690 | - if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 2691 | - $styles['font-size'] = (float) $args['font_size_custom'] . 'rem'; |
|
| 2692 | - } |
|
| 2693 | - |
|
| 2694 | - // font color |
|
| 2695 | - if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
|
| 2696 | - $styles['color'] = esc_attr( $args['text_color_custom'] ); |
|
| 2697 | - } |
|
| 2698 | - |
|
| 2699 | - // font line height |
|
| 2700 | - if ( ! empty( $args['font_line_height'] ) && $args['font_line_height'] !== '' ) { |
|
| 2701 | - $styles['line-height'] = esc_attr( $args['font_line_height'] ); |
|
| 2702 | - } |
|
| 2703 | - |
|
| 2704 | - // max height |
|
| 2705 | - if ( ! empty( $args['max_height'] ) && $args['max_height'] !== '' ) { |
|
| 2706 | - $styles['max-height'] = esc_attr( $args['max_height'] ); |
|
| 2707 | - } |
|
| 2708 | - |
|
| 2709 | - $style_string = ''; |
|
| 2710 | - if ( ! empty( $styles ) ) { |
|
| 2711 | - foreach ( $styles as $key => $val ) { |
|
| 2712 | - $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 2713 | - } |
|
| 2714 | - } |
|
| 2715 | - |
|
| 2716 | - return $style_string; |
|
| 2633 | + $styles = array(); |
|
| 2634 | + |
|
| 2635 | + // background color |
|
| 2636 | + if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 2637 | + if ( $args['bg'] == 'custom-color' ) { |
|
| 2638 | + $styles['background-color'] = $args['bg_color']; |
|
| 2639 | + } elseif ( $args['bg'] == 'custom-gradient' ) { |
|
| 2640 | + $styles['background-image'] = $args['bg_gradient']; |
|
| 2641 | + |
|
| 2642 | + // use background on text. |
|
| 2643 | + if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 2644 | + $styles['background-clip'] = 'text'; |
|
| 2645 | + $styles['-webkit-background-clip'] = 'text'; |
|
| 2646 | + $styles['text-fill-color'] = 'transparent'; |
|
| 2647 | + $styles['-webkit-text-fill-color'] = 'transparent'; |
|
| 2648 | + } |
|
| 2649 | + } |
|
| 2650 | + } |
|
| 2651 | + |
|
| 2652 | + if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 2653 | + $hasImage = true; |
|
| 2654 | + if ( ! empty( $styles['background-color'] ) && $args['bg'] == 'custom-color' ) { |
|
| 2655 | + $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2656 | + $styles['background-blend-mode'] = 'overlay'; |
|
| 2657 | + } elseif ( ! empty( $styles['background-image'] ) && $args['bg'] == 'custom-gradient' ) { |
|
| 2658 | + $styles['background-image'] .= ',url(' . $args['bg_image'] . ')'; |
|
| 2659 | + } elseif ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 2660 | + // do nothing as we alreay have a preset |
|
| 2661 | + $hasImage = false; |
|
| 2662 | + } else { |
|
| 2663 | + $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2664 | + } |
|
| 2665 | + |
|
| 2666 | + if ( $hasImage ) { |
|
| 2667 | + $styles['background-size'] = 'cover'; |
|
| 2668 | + |
|
| 2669 | + if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 2670 | + $styles['background-attachment'] = 'fixed'; |
|
| 2671 | + } |
|
| 2672 | + } |
|
| 2673 | + |
|
| 2674 | + if ( $hasImage && ! empty( $args['bg_image_xy'] ) && ! empty( $args['bg_image_xy']['x'] ) ) { |
|
| 2675 | + $styles['background-position'] = ( $args['bg_image_xy']['x'] * 100 ) . '% ' . ( $args['bg_image_xy']['y'] * 100 ) . '%'; |
|
| 2676 | + } |
|
| 2677 | + } |
|
| 2678 | + |
|
| 2679 | + // sticky offset top |
|
| 2680 | + if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 2681 | + $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 2682 | + } |
|
| 2683 | + |
|
| 2684 | + // sticky offset bottom |
|
| 2685 | + if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 2686 | + $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 2687 | + } |
|
| 2688 | + |
|
| 2689 | + // font size |
|
| 2690 | + if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 2691 | + $styles['font-size'] = (float) $args['font_size_custom'] . 'rem'; |
|
| 2692 | + } |
|
| 2693 | + |
|
| 2694 | + // font color |
|
| 2695 | + if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
|
| 2696 | + $styles['color'] = esc_attr( $args['text_color_custom'] ); |
|
| 2697 | + } |
|
| 2698 | + |
|
| 2699 | + // font line height |
|
| 2700 | + if ( ! empty( $args['font_line_height'] ) && $args['font_line_height'] !== '' ) { |
|
| 2701 | + $styles['line-height'] = esc_attr( $args['font_line_height'] ); |
|
| 2702 | + } |
|
| 2703 | + |
|
| 2704 | + // max height |
|
| 2705 | + if ( ! empty( $args['max_height'] ) && $args['max_height'] !== '' ) { |
|
| 2706 | + $styles['max-height'] = esc_attr( $args['max_height'] ); |
|
| 2707 | + } |
|
| 2708 | + |
|
| 2709 | + $style_string = ''; |
|
| 2710 | + if ( ! empty( $styles ) ) { |
|
| 2711 | + foreach ( $styles as $key => $val ) { |
|
| 2712 | + $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 2713 | + } |
|
| 2714 | + } |
|
| 2715 | + |
|
| 2716 | + return $style_string; |
|
| 2717 | 2717 | |
| 2718 | 2718 | } |
| 2719 | 2719 | |
@@ -2726,34 +2726,34 @@ discard block |
||
| 2726 | 2726 | * @return string |
| 2727 | 2727 | */ |
| 2728 | 2728 | function sd_build_hover_styles( $args, $is_preview = false ) { |
| 2729 | - $rules = ''; |
|
| 2730 | - // text color |
|
| 2731 | - if ( ! empty( $args['styleid'] ) ) { |
|
| 2732 | - $styleid = $is_preview ? 'html .editor-styles-wrapper .' . esc_attr( $args['styleid'] ) : 'html .' . esc_attr( $args['styleid'] ); |
|
| 2733 | - |
|
| 2734 | - // text |
|
| 2735 | - if ( ! empty( $args['text_color_hover'] ) ) { |
|
| 2736 | - $key = 'custom' === $args['text_color_hover'] && ! empty( $args['text_color_hover_custom'] ) ? 'text_color_hover_custom' : 'text_color_hover'; |
|
| 2737 | - $color = sd_get_color_from_var( $args[ $key ] ); |
|
| 2738 | - $rules .= $styleid . ':hover {color: ' . $color . ' !important;} '; |
|
| 2739 | - } |
|
| 2740 | - |
|
| 2741 | - // bg |
|
| 2742 | - if ( ! empty( $args['bg_hover'] ) ) { |
|
| 2743 | - if ( 'custom-gradient' === $args['bg_hover'] ) { |
|
| 2744 | - $color = $args['bg_hover_gradient']; |
|
| 2745 | - $rules .= $styleid . ':hover {background-image: ' . $color . ' !important;} '; |
|
| 2746 | - $rules .= $styleid . '.btn:hover {border-color: transparent !important;} '; |
|
| 2747 | - } else { |
|
| 2748 | - $key = 'custom-color' === $args['bg_hover'] ? 'bg_hover_color' : 'bg_hover'; |
|
| 2749 | - $color = sd_get_color_from_var( $args[ $key ] ); |
|
| 2750 | - $rules .= $styleid . ':hover {background: ' . $color . ' !important;} '; |
|
| 2751 | - $rules .= $styleid . '.btn:hover {border-color: ' . $color . ' !important;} '; |
|
| 2752 | - } |
|
| 2753 | - } |
|
| 2754 | - } |
|
| 2755 | - |
|
| 2756 | - return $rules ? '<style>' . $rules . '</style>' : ''; |
|
| 2729 | + $rules = ''; |
|
| 2730 | + // text color |
|
| 2731 | + if ( ! empty( $args['styleid'] ) ) { |
|
| 2732 | + $styleid = $is_preview ? 'html .editor-styles-wrapper .' . esc_attr( $args['styleid'] ) : 'html .' . esc_attr( $args['styleid'] ); |
|
| 2733 | + |
|
| 2734 | + // text |
|
| 2735 | + if ( ! empty( $args['text_color_hover'] ) ) { |
|
| 2736 | + $key = 'custom' === $args['text_color_hover'] && ! empty( $args['text_color_hover_custom'] ) ? 'text_color_hover_custom' : 'text_color_hover'; |
|
| 2737 | + $color = sd_get_color_from_var( $args[ $key ] ); |
|
| 2738 | + $rules .= $styleid . ':hover {color: ' . $color . ' !important;} '; |
|
| 2739 | + } |
|
| 2740 | + |
|
| 2741 | + // bg |
|
| 2742 | + if ( ! empty( $args['bg_hover'] ) ) { |
|
| 2743 | + if ( 'custom-gradient' === $args['bg_hover'] ) { |
|
| 2744 | + $color = $args['bg_hover_gradient']; |
|
| 2745 | + $rules .= $styleid . ':hover {background-image: ' . $color . ' !important;} '; |
|
| 2746 | + $rules .= $styleid . '.btn:hover {border-color: transparent !important;} '; |
|
| 2747 | + } else { |
|
| 2748 | + $key = 'custom-color' === $args['bg_hover'] ? 'bg_hover_color' : 'bg_hover'; |
|
| 2749 | + $color = sd_get_color_from_var( $args[ $key ] ); |
|
| 2750 | + $rules .= $styleid . ':hover {background: ' . $color . ' !important;} '; |
|
| 2751 | + $rules .= $styleid . '.btn:hover {border-color: ' . $color . ' !important;} '; |
|
| 2752 | + } |
|
| 2753 | + } |
|
| 2754 | + } |
|
| 2755 | + |
|
| 2756 | + return $rules ? '<style>' . $rules . '</style>' : ''; |
|
| 2757 | 2757 | } |
| 2758 | 2758 | |
| 2759 | 2759 | /** |
@@ -2765,12 +2765,12 @@ discard block |
||
| 2765 | 2765 | */ |
| 2766 | 2766 | function sd_get_color_from_var( $var ) { |
| 2767 | 2767 | |
| 2768 | - //sanitize_hex_color() @todo this does not cover transparency |
|
| 2769 | - if ( strpos( $var, '#' ) === false ) { |
|
| 2770 | - $var = defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) ? 'var(--wp--preset--color--' . esc_attr( $var ) . ')' : 'var(--' . esc_attr( $var ) . ')'; |
|
| 2771 | - } |
|
| 2768 | + //sanitize_hex_color() @todo this does not cover transparency |
|
| 2769 | + if ( strpos( $var, '#' ) === false ) { |
|
| 2770 | + $var = defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) ? 'var(--wp--preset--color--' . esc_attr( $var ) . ')' : 'var(--' . esc_attr( $var ) . ')'; |
|
| 2771 | + } |
|
| 2772 | 2772 | |
| 2773 | - return $var; |
|
| 2773 | + return $var; |
|
| 2774 | 2774 | } |
| 2775 | 2775 | |
| 2776 | 2776 | /** |
@@ -2782,19 +2782,19 @@ discard block |
||
| 2782 | 2782 | * @return string |
| 2783 | 2783 | */ |
| 2784 | 2784 | function sd_sanitize_html_classes( $classes, $sep = ' ' ) { |
| 2785 | - $return = ''; |
|
| 2785 | + $return = ''; |
|
| 2786 | 2786 | |
| 2787 | - if ( ! is_array( $classes ) ) { |
|
| 2788 | - $classes = explode( $sep, $classes ); |
|
| 2789 | - } |
|
| 2787 | + if ( ! is_array( $classes ) ) { |
|
| 2788 | + $classes = explode( $sep, $classes ); |
|
| 2789 | + } |
|
| 2790 | 2790 | |
| 2791 | - if ( ! empty( $classes ) ) { |
|
| 2792 | - foreach ( $classes as $class ) { |
|
| 2793 | - $return .= sanitize_html_class( $class ) . ' '; |
|
| 2794 | - } |
|
| 2795 | - } |
|
| 2791 | + if ( ! empty( $classes ) ) { |
|
| 2792 | + foreach ( $classes as $class ) { |
|
| 2793 | + $return .= sanitize_html_class( $class ) . ' '; |
|
| 2794 | + } |
|
| 2795 | + } |
|
| 2796 | 2796 | |
| 2797 | - return $return; |
|
| 2797 | + return $return; |
|
| 2798 | 2798 | } |
| 2799 | 2799 | |
| 2800 | 2800 | |
@@ -2804,38 +2804,38 @@ discard block |
||
| 2804 | 2804 | * @return void |
| 2805 | 2805 | */ |
| 2806 | 2806 | function sd_get_class_build_keys() { |
| 2807 | - $keys = array( |
|
| 2808 | - 'container', |
|
| 2809 | - 'position', |
|
| 2810 | - 'flex_direction', |
|
| 2811 | - 'shadow', |
|
| 2812 | - 'rounded', |
|
| 2813 | - 'nav_style', |
|
| 2814 | - 'horizontal_alignment', |
|
| 2815 | - 'nav_fill', |
|
| 2816 | - 'width', |
|
| 2817 | - 'font_weight', |
|
| 2818 | - 'font_size', |
|
| 2819 | - 'font_case', |
|
| 2820 | - 'css_class', |
|
| 2821 | - 'flex_align_items-MTD', |
|
| 2822 | - 'flex_justify_content-MTD', |
|
| 2823 | - 'flex_align_self-MTD', |
|
| 2824 | - 'flex_order-MTD', |
|
| 2825 | - 'styleid', |
|
| 2826 | - 'border_opacity', |
|
| 2827 | - 'border_width', |
|
| 2828 | - 'border_type', |
|
| 2829 | - 'opacity', |
|
| 2830 | - 'zindex', |
|
| 2831 | - 'flex_wrap-MTD', |
|
| 2832 | - 'h100', |
|
| 2833 | - 'overflow', |
|
| 2834 | - 'scrollbars', |
|
| 2835 | - 'float-MTD' |
|
| 2836 | - ); |
|
| 2837 | - |
|
| 2838 | - return apply_filters( 'sd_class_build_keys', $keys ); |
|
| 2807 | + $keys = array( |
|
| 2808 | + 'container', |
|
| 2809 | + 'position', |
|
| 2810 | + 'flex_direction', |
|
| 2811 | + 'shadow', |
|
| 2812 | + 'rounded', |
|
| 2813 | + 'nav_style', |
|
| 2814 | + 'horizontal_alignment', |
|
| 2815 | + 'nav_fill', |
|
| 2816 | + 'width', |
|
| 2817 | + 'font_weight', |
|
| 2818 | + 'font_size', |
|
| 2819 | + 'font_case', |
|
| 2820 | + 'css_class', |
|
| 2821 | + 'flex_align_items-MTD', |
|
| 2822 | + 'flex_justify_content-MTD', |
|
| 2823 | + 'flex_align_self-MTD', |
|
| 2824 | + 'flex_order-MTD', |
|
| 2825 | + 'styleid', |
|
| 2826 | + 'border_opacity', |
|
| 2827 | + 'border_width', |
|
| 2828 | + 'border_type', |
|
| 2829 | + 'opacity', |
|
| 2830 | + 'zindex', |
|
| 2831 | + 'flex_wrap-MTD', |
|
| 2832 | + 'h100', |
|
| 2833 | + 'overflow', |
|
| 2834 | + 'scrollbars', |
|
| 2835 | + 'float-MTD' |
|
| 2836 | + ); |
|
| 2837 | + |
|
| 2838 | + return apply_filters( 'sd_class_build_keys', $keys ); |
|
| 2839 | 2839 | } |
| 2840 | 2840 | |
| 2841 | 2841 | /** |
@@ -2847,18 +2847,18 @@ discard block |
||
| 2847 | 2847 | * @return array |
| 2848 | 2848 | */ |
| 2849 | 2849 | function sd_get_visibility_conditions_input( $type = 'visibility_conditions', $overwrite = array() ) { |
| 2850 | - $defaults = array( |
|
| 2851 | - 'type' => 'visibility_conditions', |
|
| 2852 | - 'title' => __( 'Block Visibility', 'ayecode-connect' ), |
|
| 2853 | - 'button_title' => __( 'Set Block Visibility', 'ayecode-connect' ), |
|
| 2854 | - 'default' => '', |
|
| 2855 | - 'desc_tip' => true, |
|
| 2856 | - 'group' => __( 'Visibility Conditions', 'ayecode-connect' ), |
|
| 2857 | - ); |
|
| 2850 | + $defaults = array( |
|
| 2851 | + 'type' => 'visibility_conditions', |
|
| 2852 | + 'title' => __( 'Block Visibility', 'ayecode-connect' ), |
|
| 2853 | + 'button_title' => __( 'Set Block Visibility', 'ayecode-connect' ), |
|
| 2854 | + 'default' => '', |
|
| 2855 | + 'desc_tip' => true, |
|
| 2856 | + 'group' => __( 'Visibility Conditions', 'ayecode-connect' ), |
|
| 2857 | + ); |
|
| 2858 | 2858 | |
| 2859 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2859 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2860 | 2860 | |
| 2861 | - return $input; |
|
| 2861 | + return $input; |
|
| 2862 | 2862 | } |
| 2863 | 2863 | |
| 2864 | 2864 | /** |
@@ -2870,21 +2870,21 @@ discard block |
||
| 2870 | 2870 | * @return array An array of roles. |
| 2871 | 2871 | */ |
| 2872 | 2872 | function sd_user_roles_options( $exclude = array() ) { |
| 2873 | - $user_roles = array(); |
|
| 2873 | + $user_roles = array(); |
|
| 2874 | 2874 | |
| 2875 | - if ( !function_exists('get_editable_roles') ) { |
|
| 2876 | - require_once( ABSPATH . '/wp-admin/includes/user.php' ); |
|
| 2877 | - } |
|
| 2875 | + if ( !function_exists('get_editable_roles') ) { |
|
| 2876 | + require_once( ABSPATH . '/wp-admin/includes/user.php' ); |
|
| 2877 | + } |
|
| 2878 | 2878 | |
| 2879 | - $roles = get_editable_roles(); |
|
| 2879 | + $roles = get_editable_roles(); |
|
| 2880 | 2880 | |
| 2881 | - foreach ( $roles as $role => $data ) { |
|
| 2882 | - if ( ! ( ! empty( $exclude ) && in_array( $role, $exclude ) ) ) { |
|
| 2883 | - $user_roles[ esc_attr( $role ) ] = translate_user_role( $data['name'] ); |
|
| 2884 | - } |
|
| 2885 | - } |
|
| 2881 | + foreach ( $roles as $role => $data ) { |
|
| 2882 | + if ( ! ( ! empty( $exclude ) && in_array( $role, $exclude ) ) ) { |
|
| 2883 | + $user_roles[ esc_attr( $role ) ] = translate_user_role( $data['name'] ); |
|
| 2884 | + } |
|
| 2885 | + } |
|
| 2886 | 2886 | |
| 2887 | - return apply_filters( 'sd_user_roles_options', $user_roles ); |
|
| 2887 | + return apply_filters( 'sd_user_roles_options', $user_roles ); |
|
| 2888 | 2888 | } |
| 2889 | 2889 | |
| 2890 | 2890 | /** |
@@ -2895,18 +2895,18 @@ discard block |
||
| 2895 | 2895 | * @return array Rule options. |
| 2896 | 2896 | */ |
| 2897 | 2897 | function sd_visibility_rules_options() { |
| 2898 | - $options = array( |
|
| 2899 | - 'logged_in' => __( 'Logged In', 'ayecode-connect' ), |
|
| 2900 | - 'logged_out' => __( 'Logged Out', 'ayecode-connect' ), |
|
| 2901 | - 'post_author' => __( 'Post Author', 'ayecode-connect' ), |
|
| 2902 | - 'user_roles' => __( 'Specific User Roles', 'ayecode-connect' ) |
|
| 2903 | - ); |
|
| 2898 | + $options = array( |
|
| 2899 | + 'logged_in' => __( 'Logged In', 'ayecode-connect' ), |
|
| 2900 | + 'logged_out' => __( 'Logged Out', 'ayecode-connect' ), |
|
| 2901 | + 'post_author' => __( 'Post Author', 'ayecode-connect' ), |
|
| 2902 | + 'user_roles' => __( 'Specific User Roles', 'ayecode-connect' ) |
|
| 2903 | + ); |
|
| 2904 | 2904 | |
| 2905 | - if ( class_exists( 'GeoDirectory' ) ) { |
|
| 2906 | - $options['gd_field'] = __( 'GD Field', 'ayecode-connect' ); |
|
| 2907 | - } |
|
| 2905 | + if ( class_exists( 'GeoDirectory' ) ) { |
|
| 2906 | + $options['gd_field'] = __( 'GD Field', 'ayecode-connect' ); |
|
| 2907 | + } |
|
| 2908 | 2908 | |
| 2909 | - return apply_filters( 'sd_visibility_rules_options', $options ); |
|
| 2909 | + return apply_filters( 'sd_visibility_rules_options', $options ); |
|
| 2910 | 2910 | } |
| 2911 | 2911 | |
| 2912 | 2912 | /** |
@@ -2915,39 +2915,39 @@ discard block |
||
| 2915 | 2915 | * @return array |
| 2916 | 2916 | */ |
| 2917 | 2917 | function sd_visibility_gd_field_options() { |
| 2918 | - $fields = geodir_post_custom_fields( '', 'all', 'all', 'none' ); |
|
| 2918 | + $fields = geodir_post_custom_fields( '', 'all', 'all', 'none' ); |
|
| 2919 | 2919 | |
| 2920 | - $keys = array(); |
|
| 2921 | - if ( ! empty( $fields ) ) { |
|
| 2922 | - foreach( $fields as $field ) { |
|
| 2923 | - if ( apply_filters( 'geodir_badge_field_skip_key', false, $field ) ) { |
|
| 2924 | - continue; |
|
| 2925 | - } |
|
| 2920 | + $keys = array(); |
|
| 2921 | + if ( ! empty( $fields ) ) { |
|
| 2922 | + foreach( $fields as $field ) { |
|
| 2923 | + if ( apply_filters( 'geodir_badge_field_skip_key', false, $field ) ) { |
|
| 2924 | + continue; |
|
| 2925 | + } |
|
| 2926 | 2926 | |
| 2927 | - $keys[ $field['htmlvar_name'] ] = $field['htmlvar_name'] . ' ( ' . __( $field['admin_title'], 'geodirectory' ) . ' )'; |
|
| 2927 | + $keys[ $field['htmlvar_name'] ] = $field['htmlvar_name'] . ' ( ' . __( $field['admin_title'], 'geodirectory' ) . ' )'; |
|
| 2928 | 2928 | |
| 2929 | - // Extra address fields |
|
| 2930 | - if ( $field['htmlvar_name'] == 'address' && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
| 2931 | - foreach ( $address_fields as $_field => $args ) { |
|
| 2932 | - if ( $_field != 'map_directions' && $_field != 'street' ) { |
|
| 2933 | - $keys[ $_field ] = $_field . ' ( ' . $args['frontend_title'] . ' )'; |
|
| 2934 | - } |
|
| 2935 | - } |
|
| 2936 | - } |
|
| 2937 | - } |
|
| 2938 | - } |
|
| 2929 | + // Extra address fields |
|
| 2930 | + if ( $field['htmlvar_name'] == 'address' && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
| 2931 | + foreach ( $address_fields as $_field => $args ) { |
|
| 2932 | + if ( $_field != 'map_directions' && $_field != 'street' ) { |
|
| 2933 | + $keys[ $_field ] = $_field . ' ( ' . $args['frontend_title'] . ' )'; |
|
| 2934 | + } |
|
| 2935 | + } |
|
| 2936 | + } |
|
| 2937 | + } |
|
| 2938 | + } |
|
| 2939 | 2939 | |
| 2940 | - $standard_fields = sd_visibility_gd_standard_field_options(); |
|
| 2940 | + $standard_fields = sd_visibility_gd_standard_field_options(); |
|
| 2941 | 2941 | |
| 2942 | - if ( ! empty( $standard_fields ) ) { |
|
| 2943 | - foreach ( $standard_fields as $key => $option ) { |
|
| 2944 | - $keys[ $key ] = $option; |
|
| 2945 | - } |
|
| 2946 | - } |
|
| 2942 | + if ( ! empty( $standard_fields ) ) { |
|
| 2943 | + foreach ( $standard_fields as $key => $option ) { |
|
| 2944 | + $keys[ $key ] = $option; |
|
| 2945 | + } |
|
| 2946 | + } |
|
| 2947 | 2947 | |
| 2948 | - $options = apply_filters( 'geodir_badge_field_keys', $keys ); |
|
| 2948 | + $options = apply_filters( 'geodir_badge_field_keys', $keys ); |
|
| 2949 | 2949 | |
| 2950 | - return apply_filters( 'sd_visibility_gd_field_options', $options ); |
|
| 2950 | + return apply_filters( 'sd_visibility_gd_field_options', $options ); |
|
| 2951 | 2951 | } |
| 2952 | 2952 | |
| 2953 | 2953 | /** |
@@ -2956,17 +2956,17 @@ discard block |
||
| 2956 | 2956 | * @return array |
| 2957 | 2957 | */ |
| 2958 | 2958 | function sd_visibility_gd_standard_field_options( $post_type = '' ) { |
| 2959 | - $fields = sd_visibility_gd_standard_fields( $post_type ); |
|
| 2959 | + $fields = sd_visibility_gd_standard_fields( $post_type ); |
|
| 2960 | 2960 | |
| 2961 | - $options = array(); |
|
| 2961 | + $options = array(); |
|
| 2962 | 2962 | |
| 2963 | - foreach ( $fields as $key => $field ) { |
|
| 2964 | - if ( ! empty( $field['frontend_title'] ) ) { |
|
| 2965 | - $options[ $key ] = $key . ' ( ' . $field['frontend_title'] . ' )'; |
|
| 2966 | - } |
|
| 2967 | - } |
|
| 2963 | + foreach ( $fields as $key => $field ) { |
|
| 2964 | + if ( ! empty( $field['frontend_title'] ) ) { |
|
| 2965 | + $options[ $key ] = $key . ' ( ' . $field['frontend_title'] . ' )'; |
|
| 2966 | + } |
|
| 2967 | + } |
|
| 2968 | 2968 | |
| 2969 | - return apply_filters( 'sd_visibility_gd_standard_field_options', $options, $fields ); |
|
| 2969 | + return apply_filters( 'sd_visibility_gd_standard_field_options', $options, $fields ); |
|
| 2970 | 2970 | } |
| 2971 | 2971 | |
| 2972 | 2972 | /** |
@@ -2975,17 +2975,17 @@ discard block |
||
| 2975 | 2975 | * @return array |
| 2976 | 2976 | */ |
| 2977 | 2977 | function sd_visibility_gd_standard_fields( $post_type = '' ) { |
| 2978 | - $standard_fields = geodir_post_meta_standard_fields( $post_type ); |
|
| 2978 | + $standard_fields = geodir_post_meta_standard_fields( $post_type ); |
|
| 2979 | 2979 | |
| 2980 | - $fields = array(); |
|
| 2980 | + $fields = array(); |
|
| 2981 | 2981 | |
| 2982 | - foreach ( $standard_fields as $key => $field ) { |
|
| 2983 | - if ( $key != 'post_link' && strpos( $key, 'event' ) === false && ! empty( $field['frontend_title'] ) ) { |
|
| 2984 | - $fields[ $key ] = $field; |
|
| 2985 | - } |
|
| 2986 | - } |
|
| 2982 | + foreach ( $standard_fields as $key => $field ) { |
|
| 2983 | + if ( $key != 'post_link' && strpos( $key, 'event' ) === false && ! empty( $field['frontend_title'] ) ) { |
|
| 2984 | + $fields[ $key ] = $field; |
|
| 2985 | + } |
|
| 2986 | + } |
|
| 2987 | 2987 | |
| 2988 | - return apply_filters( 'sd_visibility_gd_standard_fields', $fields ); |
|
| 2988 | + return apply_filters( 'sd_visibility_gd_standard_fields', $fields ); |
|
| 2989 | 2989 | } |
| 2990 | 2990 | |
| 2991 | 2991 | /** |
@@ -2994,18 +2994,18 @@ discard block |
||
| 2994 | 2994 | * @return array |
| 2995 | 2995 | */ |
| 2996 | 2996 | function sd_visibility_field_condition_options(){ |
| 2997 | - $options = array( |
|
| 2998 | - 'is_empty' => __( 'is empty', 'ayecode-connect' ), |
|
| 2999 | - 'is_not_empty' => __( 'is not empty', 'ayecode-connect' ), |
|
| 3000 | - 'is_equal' => __( 'is equal', 'ayecode-connect' ), |
|
| 3001 | - 'is_not_equal' => __( 'is not equal', 'ayecode-connect' ), |
|
| 3002 | - 'is_greater_than' => __( 'is greater than', 'ayecode-connect' ), |
|
| 3003 | - 'is_less_than' => __( 'is less than', 'ayecode-connect' ), |
|
| 3004 | - 'is_contains' => __( 'is contains', 'ayecode-connect' ), |
|
| 3005 | - 'is_not_contains' => __( 'is not contains', 'ayecode-connect' ), |
|
| 3006 | - ); |
|
| 2997 | + $options = array( |
|
| 2998 | + 'is_empty' => __( 'is empty', 'ayecode-connect' ), |
|
| 2999 | + 'is_not_empty' => __( 'is not empty', 'ayecode-connect' ), |
|
| 3000 | + 'is_equal' => __( 'is equal', 'ayecode-connect' ), |
|
| 3001 | + 'is_not_equal' => __( 'is not equal', 'ayecode-connect' ), |
|
| 3002 | + 'is_greater_than' => __( 'is greater than', 'ayecode-connect' ), |
|
| 3003 | + 'is_less_than' => __( 'is less than', 'ayecode-connect' ), |
|
| 3004 | + 'is_contains' => __( 'is contains', 'ayecode-connect' ), |
|
| 3005 | + 'is_not_contains' => __( 'is not contains', 'ayecode-connect' ), |
|
| 3006 | + ); |
|
| 3007 | 3007 | |
| 3008 | - return apply_filters( 'sd_visibility_field_condition_options', $options ); |
|
| 3008 | + return apply_filters( 'sd_visibility_field_condition_options', $options ); |
|
| 3009 | 3009 | } |
| 3010 | 3010 | |
| 3011 | 3011 | /** |
@@ -3016,14 +3016,14 @@ discard block |
||
| 3016 | 3016 | * @return array Template type options. |
| 3017 | 3017 | */ |
| 3018 | 3018 | function sd_visibility_output_options() { |
| 3019 | - $options = array( |
|
| 3020 | - 'hide' => __( 'Hide Block', 'ayecode-connect' ), |
|
| 3021 | - 'message' => __( 'Show Custom Message', 'ayecode-connect' ), |
|
| 3022 | - 'page' => __( 'Show Page Content', 'ayecode-connect' ), |
|
| 3023 | - 'template_part' => __( 'Show Template Part', 'ayecode-connect' ), |
|
| 3024 | - ); |
|
| 3019 | + $options = array( |
|
| 3020 | + 'hide' => __( 'Hide Block', 'ayecode-connect' ), |
|
| 3021 | + 'message' => __( 'Show Custom Message', 'ayecode-connect' ), |
|
| 3022 | + 'page' => __( 'Show Page Content', 'ayecode-connect' ), |
|
| 3023 | + 'template_part' => __( 'Show Template Part', 'ayecode-connect' ), |
|
| 3024 | + ); |
|
| 3025 | 3025 | |
| 3026 | - return apply_filters( 'sd_visibility_output_options', $options ); |
|
| 3026 | + return apply_filters( 'sd_visibility_output_options', $options ); |
|
| 3027 | 3027 | } |
| 3028 | 3028 | |
| 3029 | 3029 | /** |
@@ -3035,45 +3035,45 @@ discard block |
||
| 3035 | 3035 | * @return array Template page options. |
| 3036 | 3036 | */ |
| 3037 | 3037 | function sd_template_page_options( $args = array() ) { |
| 3038 | - global $sd_tmpl_page_options; |
|
| 3038 | + global $sd_tmpl_page_options; |
|
| 3039 | 3039 | |
| 3040 | - if ( ! empty( $sd_tmpl_page_options ) ) { |
|
| 3041 | - return $sd_tmpl_page_options; |
|
| 3042 | - } |
|
| 3040 | + if ( ! empty( $sd_tmpl_page_options ) ) { |
|
| 3041 | + return $sd_tmpl_page_options; |
|
| 3042 | + } |
|
| 3043 | 3043 | |
| 3044 | - $args = wp_parse_args( $args, array( |
|
| 3045 | - 'child_of' => 0, |
|
| 3046 | - 'sort_column' => 'post_title', |
|
| 3047 | - 'sort_order' => 'ASC' |
|
| 3048 | - ) ); |
|
| 3044 | + $args = wp_parse_args( $args, array( |
|
| 3045 | + 'child_of' => 0, |
|
| 3046 | + 'sort_column' => 'post_title', |
|
| 3047 | + 'sort_order' => 'ASC' |
|
| 3048 | + ) ); |
|
| 3049 | 3049 | |
| 3050 | - $exclude_pages = array(); |
|
| 3051 | - if ( $page_on_front = get_option( 'page_on_front' ) ) { |
|
| 3052 | - $exclude_pages[] = $page_on_front; |
|
| 3053 | - } |
|
| 3050 | + $exclude_pages = array(); |
|
| 3051 | + if ( $page_on_front = get_option( 'page_on_front' ) ) { |
|
| 3052 | + $exclude_pages[] = $page_on_front; |
|
| 3053 | + } |
|
| 3054 | 3054 | |
| 3055 | - if ( $page_for_posts = get_option( 'page_for_posts' ) ) { |
|
| 3056 | - $exclude_pages[] = $page_for_posts; |
|
| 3057 | - } |
|
| 3055 | + if ( $page_for_posts = get_option( 'page_for_posts' ) ) { |
|
| 3056 | + $exclude_pages[] = $page_for_posts; |
|
| 3057 | + } |
|
| 3058 | 3058 | |
| 3059 | - if ( ! empty( $exclude_pages ) ) { |
|
| 3060 | - $args['exclude'] = $exclude_pages; |
|
| 3061 | - } |
|
| 3059 | + if ( ! empty( $exclude_pages ) ) { |
|
| 3060 | + $args['exclude'] = $exclude_pages; |
|
| 3061 | + } |
|
| 3062 | 3062 | |
| 3063 | - $pages = get_pages( $args ); |
|
| 3063 | + $pages = get_pages( $args ); |
|
| 3064 | 3064 | |
| 3065 | - $options = array( '' => __( 'Select Page...', 'ayecode-connect' ) ); |
|
| 3066 | - if ( ! empty( $pages ) ) { |
|
| 3067 | - foreach ( $pages as $page ) { |
|
| 3068 | - if ( ! empty( $page->ID ) && ! empty( $page->post_title ) ) { |
|
| 3069 | - $options[ $page->ID ] = $page->post_title . ' (#' . $page->ID . ')'; |
|
| 3070 | - } |
|
| 3071 | - } |
|
| 3072 | - } |
|
| 3065 | + $options = array( '' => __( 'Select Page...', 'ayecode-connect' ) ); |
|
| 3066 | + if ( ! empty( $pages ) ) { |
|
| 3067 | + foreach ( $pages as $page ) { |
|
| 3068 | + if ( ! empty( $page->ID ) && ! empty( $page->post_title ) ) { |
|
| 3069 | + $options[ $page->ID ] = $page->post_title . ' (#' . $page->ID . ')'; |
|
| 3070 | + } |
|
| 3071 | + } |
|
| 3072 | + } |
|
| 3073 | 3073 | |
| 3074 | - $sd_tmpl_page_options = $options; |
|
| 3074 | + $sd_tmpl_page_options = $options; |
|
| 3075 | 3075 | |
| 3076 | - return apply_filters( 'sd_template_page_options', $options ); |
|
| 3076 | + return apply_filters( 'sd_template_page_options', $options ); |
|
| 3077 | 3077 | } |
| 3078 | 3078 | |
| 3079 | 3079 | /** |
@@ -3085,25 +3085,25 @@ discard block |
||
| 3085 | 3085 | * @return array Template part options. |
| 3086 | 3086 | */ |
| 3087 | 3087 | function sd_template_part_options( $args = array() ) { |
| 3088 | - global $sd_tmpl_part_options; |
|
| 3088 | + global $sd_tmpl_part_options; |
|
| 3089 | 3089 | |
| 3090 | - if ( ! empty( $sd_tmpl_part_options ) ) { |
|
| 3091 | - return $sd_tmpl_part_options; |
|
| 3092 | - } |
|
| 3090 | + if ( ! empty( $sd_tmpl_part_options ) ) { |
|
| 3091 | + return $sd_tmpl_part_options; |
|
| 3092 | + } |
|
| 3093 | 3093 | |
| 3094 | - $options = array( '' => __( 'Select Template Part...', 'ayecode-connect' ) ); |
|
| 3094 | + $options = array( '' => __( 'Select Template Part...', 'ayecode-connect' ) ); |
|
| 3095 | 3095 | |
| 3096 | - $parts = get_block_templates( array(), 'wp_template_part' ); |
|
| 3096 | + $parts = get_block_templates( array(), 'wp_template_part' ); |
|
| 3097 | 3097 | |
| 3098 | - if ( ! empty( $parts ) ) { |
|
| 3099 | - foreach ( $parts as $part ) { |
|
| 3100 | - $options[ $part->slug ] = $part->title . ' (#' . $part->slug . ')'; |
|
| 3101 | - } |
|
| 3102 | - } |
|
| 3098 | + if ( ! empty( $parts ) ) { |
|
| 3099 | + foreach ( $parts as $part ) { |
|
| 3100 | + $options[ $part->slug ] = $part->title . ' (#' . $part->slug . ')'; |
|
| 3101 | + } |
|
| 3102 | + } |
|
| 3103 | 3103 | |
| 3104 | - $sd_tmpl_part_options = $options; |
|
| 3104 | + $sd_tmpl_part_options = $options; |
|
| 3105 | 3105 | |
| 3106 | - return apply_filters( 'sd_template_part_options', $options, $args ); |
|
| 3106 | + return apply_filters( 'sd_template_part_options', $options, $args ); |
|
| 3107 | 3107 | } |
| 3108 | 3108 | |
| 3109 | 3109 | /** |
@@ -3115,25 +3115,25 @@ discard block |
||
| 3115 | 3115 | * @return array Template part object. |
| 3116 | 3116 | */ |
| 3117 | 3117 | function sd_get_template_part_by_slug( $slug ) { |
| 3118 | - global $bs_tmpl_part_by_slug; |
|
| 3118 | + global $bs_tmpl_part_by_slug; |
|
| 3119 | 3119 | |
| 3120 | - if ( empty( $bs_tmpl_part_by_slug ) ) { |
|
| 3121 | - $bs_tmpl_part_by_slug = array(); |
|
| 3122 | - } |
|
| 3120 | + if ( empty( $bs_tmpl_part_by_slug ) ) { |
|
| 3121 | + $bs_tmpl_part_by_slug = array(); |
|
| 3122 | + } |
|
| 3123 | 3123 | |
| 3124 | - if ( isset( $bs_tmpl_part_by_slug[ $slug ] ) ) { |
|
| 3125 | - return $bs_tmpl_part_by_slug[ $slug ]; |
|
| 3126 | - } |
|
| 3124 | + if ( isset( $bs_tmpl_part_by_slug[ $slug ] ) ) { |
|
| 3125 | + return $bs_tmpl_part_by_slug[ $slug ]; |
|
| 3126 | + } |
|
| 3127 | 3127 | |
| 3128 | - $template_query = get_block_templates( array( 'slug__in' => array( $slug ) ), 'wp_template_part' ); |
|
| 3128 | + $template_query = get_block_templates( array( 'slug__in' => array( $slug ) ), 'wp_template_part' ); |
|
| 3129 | 3129 | |
| 3130 | - $query_post = ! empty( $template_query ) ? $template_query[0] : array(); |
|
| 3130 | + $query_post = ! empty( $template_query ) ? $template_query[0] : array(); |
|
| 3131 | 3131 | |
| 3132 | - $template_part = ! empty( $query_post ) && $query_post->status == 'publish' ? $query_post : array(); |
|
| 3132 | + $template_part = ! empty( $query_post ) && $query_post->status == 'publish' ? $query_post : array(); |
|
| 3133 | 3133 | |
| 3134 | - $bs_tmpl_part_by_slug[ $slug ] = $template_part; |
|
| 3134 | + $bs_tmpl_part_by_slug[ $slug ] = $template_part; |
|
| 3135 | 3135 | |
| 3136 | - return apply_filters( 'sd_get_template_part_by_slug', $template_part, $slug ); |
|
| 3136 | + return apply_filters( 'sd_get_template_part_by_slug', $template_part, $slug ); |
|
| 3137 | 3137 | } |
| 3138 | 3138 | |
| 3139 | 3139 | /** |
@@ -3146,428 +3146,428 @@ discard block |
||
| 3146 | 3146 | * @param WP_Block $instance The block instance. |
| 3147 | 3147 | */ |
| 3148 | 3148 | function sd_render_block( $block_content, $block, $instance = '' ) { |
| 3149 | - // No block visibility conditions set. |
|
| 3150 | - if ( empty( $block['attrs']['visibility_conditions'] ) ) { |
|
| 3151 | - return $block_content; |
|
| 3152 | - } |
|
| 3153 | - |
|
| 3154 | - $attributes = json_decode( $block['attrs']['visibility_conditions'], true ); |
|
| 3155 | - $rules = ! empty( $attributes ) ? sd_block_parse_rules( $attributes ) : array(); |
|
| 3156 | - |
|
| 3157 | - // No rules set. |
|
| 3158 | - if ( empty( $rules ) ) { |
|
| 3159 | - return $block_content; |
|
| 3160 | - } |
|
| 3161 | - |
|
| 3162 | - $_block_content = $block_content; |
|
| 3163 | - |
|
| 3164 | - if ( ! empty( $rules ) && sd_block_check_rules( $rules ) ) { |
|
| 3165 | - if ( ! empty( $attributes['output']['type'] ) ) { |
|
| 3166 | - switch ( $attributes['output']['type'] ) { |
|
| 3167 | - case 'hide': |
|
| 3168 | - $valid_type = true; |
|
| 3169 | - $content = ''; |
|
| 3170 | - |
|
| 3171 | - break; |
|
| 3172 | - case 'message': |
|
| 3173 | - $valid_type = true; |
|
| 3174 | - |
|
| 3175 | - if ( isset( $attributes['output']['message'] ) ) { |
|
| 3176 | - $content = $attributes['output']['message'] != '' ? __( stripslashes( $attributes['output']['message'] ), 'ayecode-connect' ) : $attributes['output']['message']; |
|
| 3177 | - |
|
| 3178 | - if ( ! empty( $attributes['output']['message_type'] ) ) { |
|
| 3179 | - $content = aui()->alert( array( |
|
| 3180 | - 'type'=> $attributes['output']['message_type'], |
|
| 3181 | - 'content'=> $content |
|
| 3182 | - ) |
|
| 3183 | - ); |
|
| 3184 | - } |
|
| 3185 | - } |
|
| 3186 | - |
|
| 3187 | - break; |
|
| 3188 | - case 'page': |
|
| 3189 | - $valid_type = true; |
|
| 3190 | - |
|
| 3191 | - $page_id = ! empty( $attributes['output']['page'] ) ? absint( $attributes['output']['page'] ) : 0; |
|
| 3192 | - $content = sd_get_page_content( $page_id ); |
|
| 3193 | - |
|
| 3194 | - break; |
|
| 3195 | - case 'template_part': |
|
| 3196 | - $valid_type = true; |
|
| 3197 | - |
|
| 3198 | - $template_part = ! empty( $attributes['output']['template_part'] ) ? $attributes['output']['template_part'] : ''; |
|
| 3199 | - $content = sd_get_template_part_content( $template_part ); |
|
| 3200 | - |
|
| 3201 | - break; |
|
| 3202 | - default: |
|
| 3203 | - $valid_type = false; |
|
| 3204 | - break; |
|
| 3205 | - } |
|
| 3206 | - |
|
| 3207 | - if ( $valid_type ) { |
|
| 3208 | - $block_content = '<div class="' . esc_attr( wp_get_block_default_classname( $instance->name ) ) . ' sd-block-has-rule">' . $content . '</div>'; |
|
| 3209 | - } |
|
| 3210 | - } |
|
| 3211 | - } |
|
| 3212 | - |
|
| 3213 | - return apply_filters( 'sd_render_block_visibility_content', $block_content, $_block_content, $attributes, $block, $instance ); |
|
| 3149 | + // No block visibility conditions set. |
|
| 3150 | + if ( empty( $block['attrs']['visibility_conditions'] ) ) { |
|
| 3151 | + return $block_content; |
|
| 3152 | + } |
|
| 3153 | + |
|
| 3154 | + $attributes = json_decode( $block['attrs']['visibility_conditions'], true ); |
|
| 3155 | + $rules = ! empty( $attributes ) ? sd_block_parse_rules( $attributes ) : array(); |
|
| 3156 | + |
|
| 3157 | + // No rules set. |
|
| 3158 | + if ( empty( $rules ) ) { |
|
| 3159 | + return $block_content; |
|
| 3160 | + } |
|
| 3161 | + |
|
| 3162 | + $_block_content = $block_content; |
|
| 3163 | + |
|
| 3164 | + if ( ! empty( $rules ) && sd_block_check_rules( $rules ) ) { |
|
| 3165 | + if ( ! empty( $attributes['output']['type'] ) ) { |
|
| 3166 | + switch ( $attributes['output']['type'] ) { |
|
| 3167 | + case 'hide': |
|
| 3168 | + $valid_type = true; |
|
| 3169 | + $content = ''; |
|
| 3170 | + |
|
| 3171 | + break; |
|
| 3172 | + case 'message': |
|
| 3173 | + $valid_type = true; |
|
| 3174 | + |
|
| 3175 | + if ( isset( $attributes['output']['message'] ) ) { |
|
| 3176 | + $content = $attributes['output']['message'] != '' ? __( stripslashes( $attributes['output']['message'] ), 'ayecode-connect' ) : $attributes['output']['message']; |
|
| 3177 | + |
|
| 3178 | + if ( ! empty( $attributes['output']['message_type'] ) ) { |
|
| 3179 | + $content = aui()->alert( array( |
|
| 3180 | + 'type'=> $attributes['output']['message_type'], |
|
| 3181 | + 'content'=> $content |
|
| 3182 | + ) |
|
| 3183 | + ); |
|
| 3184 | + } |
|
| 3185 | + } |
|
| 3186 | + |
|
| 3187 | + break; |
|
| 3188 | + case 'page': |
|
| 3189 | + $valid_type = true; |
|
| 3190 | + |
|
| 3191 | + $page_id = ! empty( $attributes['output']['page'] ) ? absint( $attributes['output']['page'] ) : 0; |
|
| 3192 | + $content = sd_get_page_content( $page_id ); |
|
| 3193 | + |
|
| 3194 | + break; |
|
| 3195 | + case 'template_part': |
|
| 3196 | + $valid_type = true; |
|
| 3197 | + |
|
| 3198 | + $template_part = ! empty( $attributes['output']['template_part'] ) ? $attributes['output']['template_part'] : ''; |
|
| 3199 | + $content = sd_get_template_part_content( $template_part ); |
|
| 3200 | + |
|
| 3201 | + break; |
|
| 3202 | + default: |
|
| 3203 | + $valid_type = false; |
|
| 3204 | + break; |
|
| 3205 | + } |
|
| 3206 | + |
|
| 3207 | + if ( $valid_type ) { |
|
| 3208 | + $block_content = '<div class="' . esc_attr( wp_get_block_default_classname( $instance->name ) ) . ' sd-block-has-rule">' . $content . '</div>'; |
|
| 3209 | + } |
|
| 3210 | + } |
|
| 3211 | + } |
|
| 3212 | + |
|
| 3213 | + return apply_filters( 'sd_render_block_visibility_content', $block_content, $_block_content, $attributes, $block, $instance ); |
|
| 3214 | 3214 | } |
| 3215 | 3215 | add_filter( 'render_block', 'sd_render_block', 9, 3 ); |
| 3216 | 3216 | |
| 3217 | 3217 | function sd_get_page_content( $page_id ) { |
| 3218 | - $content = $page_id > 0 ? get_post_field( 'post_content', (int) $page_id ) : ''; |
|
| 3218 | + $content = $page_id > 0 ? get_post_field( 'post_content', (int) $page_id ) : ''; |
|
| 3219 | 3219 | |
| 3220 | - // Maybe bypass content |
|
| 3221 | - $bypass_content = apply_filters( 'sd_bypass_page_content', '', $content, $page_id ); |
|
| 3222 | - if ( $bypass_content ) { |
|
| 3223 | - return $bypass_content; |
|
| 3224 | - } |
|
| 3220 | + // Maybe bypass content |
|
| 3221 | + $bypass_content = apply_filters( 'sd_bypass_page_content', '', $content, $page_id ); |
|
| 3222 | + if ( $bypass_content ) { |
|
| 3223 | + return $bypass_content; |
|
| 3224 | + } |
|
| 3225 | 3225 | |
| 3226 | - // Run the shortcodes on the content. |
|
| 3227 | - $content = do_shortcode( $content ); |
|
| 3226 | + // Run the shortcodes on the content. |
|
| 3227 | + $content = do_shortcode( $content ); |
|
| 3228 | 3228 | |
| 3229 | - // Run block content if its available. |
|
| 3230 | - if ( function_exists( 'do_blocks' ) ) { |
|
| 3231 | - $content = do_blocks( $content ); |
|
| 3232 | - } |
|
| 3229 | + // Run block content if its available. |
|
| 3230 | + if ( function_exists( 'do_blocks' ) ) { |
|
| 3231 | + $content = do_blocks( $content ); |
|
| 3232 | + } |
|
| 3233 | 3233 | |
| 3234 | - return apply_filters( 'sd_get_page_content', $content, $page_id ); |
|
| 3234 | + return apply_filters( 'sd_get_page_content', $content, $page_id ); |
|
| 3235 | 3235 | } |
| 3236 | 3236 | |
| 3237 | 3237 | function sd_get_template_part_content( $template_part ) { |
| 3238 | - $template_part_post = $template_part ? sd_get_template_part_by_slug( $template_part ) : array(); |
|
| 3239 | - $content = ! empty( $template_part_post ) ? $template_part_post->content : ''; |
|
| 3238 | + $template_part_post = $template_part ? sd_get_template_part_by_slug( $template_part ) : array(); |
|
| 3239 | + $content = ! empty( $template_part_post ) ? $template_part_post->content : ''; |
|
| 3240 | 3240 | |
| 3241 | - // Maybe bypass content |
|
| 3242 | - $bypass_content = apply_filters( 'sd_bypass_template_part_content', '', $content, $template_part ); |
|
| 3243 | - if ( $bypass_content ) { |
|
| 3244 | - return $bypass_content; |
|
| 3245 | - } |
|
| 3241 | + // Maybe bypass content |
|
| 3242 | + $bypass_content = apply_filters( 'sd_bypass_template_part_content', '', $content, $template_part ); |
|
| 3243 | + if ( $bypass_content ) { |
|
| 3244 | + return $bypass_content; |
|
| 3245 | + } |
|
| 3246 | 3246 | |
| 3247 | - // Run the shortcodes on the content. |
|
| 3248 | - $content = do_shortcode( $content ); |
|
| 3247 | + // Run the shortcodes on the content. |
|
| 3248 | + $content = do_shortcode( $content ); |
|
| 3249 | 3249 | |
| 3250 | - // Run block content if its available. |
|
| 3251 | - if ( function_exists( 'do_blocks' ) ) { |
|
| 3252 | - $content = do_blocks( $content ); |
|
| 3253 | - } |
|
| 3250 | + // Run block content if its available. |
|
| 3251 | + if ( function_exists( 'do_blocks' ) ) { |
|
| 3252 | + $content = do_blocks( $content ); |
|
| 3253 | + } |
|
| 3254 | 3254 | |
| 3255 | - return apply_filters( 'sd_get_template_part_content', $content, $template_part ); |
|
| 3255 | + return apply_filters( 'sd_get_template_part_content', $content, $template_part ); |
|
| 3256 | 3256 | } |
| 3257 | 3257 | |
| 3258 | 3258 | function sd_block_parse_rules( $attrs ) { |
| 3259 | - $rules = array(); |
|
| 3259 | + $rules = array(); |
|
| 3260 | 3260 | |
| 3261 | - if ( ! empty( $attrs ) && is_array( $attrs ) ) { |
|
| 3262 | - $attrs_keys = array_keys( $attrs ); |
|
| 3261 | + if ( ! empty( $attrs ) && is_array( $attrs ) ) { |
|
| 3262 | + $attrs_keys = array_keys( $attrs ); |
|
| 3263 | 3263 | |
| 3264 | - for ( $i = 1; $i <= count( $attrs_keys ); $i++ ) { |
|
| 3265 | - if ( ! empty( $attrs[ 'rule' . $i ] ) && is_array( $attrs[ 'rule' . $i ] ) ) { |
|
| 3266 | - $rules[] = $attrs[ 'rule' . $i ]; |
|
| 3267 | - } |
|
| 3268 | - } |
|
| 3269 | - } |
|
| 3264 | + for ( $i = 1; $i <= count( $attrs_keys ); $i++ ) { |
|
| 3265 | + if ( ! empty( $attrs[ 'rule' . $i ] ) && is_array( $attrs[ 'rule' . $i ] ) ) { |
|
| 3266 | + $rules[] = $attrs[ 'rule' . $i ]; |
|
| 3267 | + } |
|
| 3268 | + } |
|
| 3269 | + } |
|
| 3270 | 3270 | |
| 3271 | - return apply_filters( 'sd_block_parse_rules', $rules, $attrs ); |
|
| 3271 | + return apply_filters( 'sd_block_parse_rules', $rules, $attrs ); |
|
| 3272 | 3272 | } |
| 3273 | 3273 | |
| 3274 | 3274 | function sd_block_check_rules( $rules ) { |
| 3275 | - if ( ! ( is_array( $rules ) && ! empty( $rules ) ) ) { |
|
| 3276 | - return true; |
|
| 3277 | - } |
|
| 3275 | + if ( ! ( is_array( $rules ) && ! empty( $rules ) ) ) { |
|
| 3276 | + return true; |
|
| 3277 | + } |
|
| 3278 | 3278 | |
| 3279 | - foreach ( $rules as $key => $rule ) { |
|
| 3280 | - $match = apply_filters( 'sd_block_check_rule', true, $rule ); |
|
| 3279 | + foreach ( $rules as $key => $rule ) { |
|
| 3280 | + $match = apply_filters( 'sd_block_check_rule', true, $rule ); |
|
| 3281 | 3281 | |
| 3282 | - if ( ! $match ) { |
|
| 3283 | - break; |
|
| 3284 | - } |
|
| 3285 | - } |
|
| 3282 | + if ( ! $match ) { |
|
| 3283 | + break; |
|
| 3284 | + } |
|
| 3285 | + } |
|
| 3286 | 3286 | |
| 3287 | - return apply_filters( 'sd_block_check_rules', $match, $rules ); |
|
| 3287 | + return apply_filters( 'sd_block_check_rules', $match, $rules ); |
|
| 3288 | 3288 | } |
| 3289 | 3289 | |
| 3290 | 3290 | function sd_block_check_rule( $match, $rule ) { |
| 3291 | - global $post; |
|
| 3291 | + global $post; |
|
| 3292 | 3292 | |
| 3293 | - if ( $match && ! empty( $rule['type'] ) ) { |
|
| 3294 | - switch ( $rule['type'] ) { |
|
| 3295 | - case 'logged_in': |
|
| 3296 | - $match = (bool) is_user_logged_in(); |
|
| 3293 | + if ( $match && ! empty( $rule['type'] ) ) { |
|
| 3294 | + switch ( $rule['type'] ) { |
|
| 3295 | + case 'logged_in': |
|
| 3296 | + $match = (bool) is_user_logged_in(); |
|
| 3297 | 3297 | |
| 3298 | - break; |
|
| 3299 | - case 'logged_out': |
|
| 3300 | - $match = ! is_user_logged_in(); |
|
| 3298 | + break; |
|
| 3299 | + case 'logged_out': |
|
| 3300 | + $match = ! is_user_logged_in(); |
|
| 3301 | 3301 | |
| 3302 | - break; |
|
| 3303 | - case 'post_author': |
|
| 3304 | - if ( ! empty( $post ) && $post->post_type != 'page' && ! empty( $post->post_author ) && is_user_logged_in() ) { |
|
| 3305 | - $match = (int) $post->post_author === (int) get_current_user_id() ? true : false; |
|
| 3306 | - } else { |
|
| 3307 | - $match = false; |
|
| 3308 | - } |
|
| 3302 | + break; |
|
| 3303 | + case 'post_author': |
|
| 3304 | + if ( ! empty( $post ) && $post->post_type != 'page' && ! empty( $post->post_author ) && is_user_logged_in() ) { |
|
| 3305 | + $match = (int) $post->post_author === (int) get_current_user_id() ? true : false; |
|
| 3306 | + } else { |
|
| 3307 | + $match = false; |
|
| 3308 | + } |
|
| 3309 | 3309 | |
| 3310 | - break; |
|
| 3311 | - case 'user_roles': |
|
| 3312 | - $match = false; |
|
| 3310 | + break; |
|
| 3311 | + case 'user_roles': |
|
| 3312 | + $match = false; |
|
| 3313 | 3313 | |
| 3314 | - if ( ! empty( $rule['user_roles'] ) ) { |
|
| 3315 | - $user_roles = is_scalar( $rule['user_roles'] ) ? explode( ",", $rule['user_roles'] ) : $rule['user_roles']; |
|
| 3314 | + if ( ! empty( $rule['user_roles'] ) ) { |
|
| 3315 | + $user_roles = is_scalar( $rule['user_roles'] ) ? explode( ",", $rule['user_roles'] ) : $rule['user_roles']; |
|
| 3316 | 3316 | |
| 3317 | - if ( is_array( $user_roles ) ) { |
|
| 3318 | - $user_roles = array_filter( array_map( 'trim', $user_roles ) ); |
|
| 3319 | - } |
|
| 3317 | + if ( is_array( $user_roles ) ) { |
|
| 3318 | + $user_roles = array_filter( array_map( 'trim', $user_roles ) ); |
|
| 3319 | + } |
|
| 3320 | 3320 | |
| 3321 | - if ( ! empty( $user_roles ) && is_array( $user_roles ) && is_user_logged_in() && ( $current_user = wp_get_current_user() ) ) { |
|
| 3322 | - $current_user_roles = $current_user->roles; |
|
| 3321 | + if ( ! empty( $user_roles ) && is_array( $user_roles ) && is_user_logged_in() && ( $current_user = wp_get_current_user() ) ) { |
|
| 3322 | + $current_user_roles = $current_user->roles; |
|
| 3323 | 3323 | |
| 3324 | - foreach ( $user_roles as $role ) { |
|
| 3325 | - if ( in_array( $role, $current_user_roles ) ) { |
|
| 3326 | - $match = true; |
|
| 3327 | - } |
|
| 3328 | - } |
|
| 3329 | - } |
|
| 3330 | - } |
|
| 3324 | + foreach ( $user_roles as $role ) { |
|
| 3325 | + if ( in_array( $role, $current_user_roles ) ) { |
|
| 3326 | + $match = true; |
|
| 3327 | + } |
|
| 3328 | + } |
|
| 3329 | + } |
|
| 3330 | + } |
|
| 3331 | 3331 | |
| 3332 | - break; |
|
| 3333 | - case 'gd_field': |
|
| 3334 | - $match = sd_block_check_rule_gd_field( $rule ); |
|
| 3332 | + break; |
|
| 3333 | + case 'gd_field': |
|
| 3334 | + $match = sd_block_check_rule_gd_field( $rule ); |
|
| 3335 | 3335 | |
| 3336 | - break; |
|
| 3337 | - } |
|
| 3338 | - } |
|
| 3336 | + break; |
|
| 3337 | + } |
|
| 3338 | + } |
|
| 3339 | 3339 | |
| 3340 | - return $match; |
|
| 3340 | + return $match; |
|
| 3341 | 3341 | } |
| 3342 | 3342 | add_filter( 'sd_block_check_rule', 'sd_block_check_rule', 10, 2 ); |
| 3343 | 3343 | |
| 3344 | 3344 | function sd_block_check_rule_gd_field( $rule ) { |
| 3345 | - global $gd_post; |
|
| 3346 | - |
|
| 3347 | - $match_found = false; |
|
| 3348 | - |
|
| 3349 | - if ( class_exists( 'GeoDirectory' ) && ! empty( $gd_post->ID ) && ! empty( $rule['field'] ) && ! empty( $rule['condition'] ) ) { |
|
| 3350 | - $args['block_visibility'] = true; |
|
| 3351 | - $args['key'] = $rule['field']; |
|
| 3352 | - $args['condition'] = $rule['condition']; |
|
| 3353 | - $args['search'] = isset( $rule['search'] ) ? $rule['search'] : ''; |
|
| 3354 | - |
|
| 3355 | - if ( $args['key'] == 'street' ) { |
|
| 3356 | - $args['key'] = 'address'; |
|
| 3357 | - } |
|
| 3358 | - |
|
| 3359 | - $match_field = $_match_field = $args['key']; |
|
| 3360 | - |
|
| 3361 | - if ( $match_field == 'address' ) { |
|
| 3362 | - $match_field = 'street'; |
|
| 3363 | - } elseif ( $match_field == 'post_images' ) { |
|
| 3364 | - $match_field = 'featured_image'; |
|
| 3365 | - } |
|
| 3366 | - |
|
| 3367 | - $find_post = $gd_post; |
|
| 3368 | - $find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
|
| 3369 | - |
|
| 3370 | - if ( ! empty( $find_post->ID ) && ! in_array( 'post_category', $find_post_keys ) ) { |
|
| 3371 | - $find_post = geodir_get_post_info( (int) $find_post->ID ); |
|
| 3372 | - $find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
|
| 3373 | - } |
|
| 3374 | - |
|
| 3375 | - if ( $match_field === '' || ( ! empty( $find_post_keys ) && ( in_array( $match_field, $find_post_keys ) || in_array( $_match_field, $find_post_keys ) ) ) ) { |
|
| 3376 | - $address_fields = array( 'street2', 'neighbourhood', 'city', 'region', 'country', 'zip', 'latitude', 'longitude' ); // Address fields |
|
| 3377 | - $field = array(); |
|
| 3378 | - $empty_field = false; |
|
| 3379 | - |
|
| 3380 | - $standard_fields = sd_visibility_gd_standard_fields(); |
|
| 3381 | - |
|
| 3382 | - if ( $match_field && ! in_array( $match_field, array_keys( $standard_fields ) ) && ! in_array( $match_field, $address_fields ) ) { |
|
| 3383 | - $package_id = geodir_get_post_package_id( $find_post->ID, $find_post->post_type ); |
|
| 3384 | - $fields = geodir_post_custom_fields( $package_id, 'all', $find_post->post_type, 'none' ); |
|
| 3385 | - |
|
| 3386 | - foreach ( $fields as $field_info ) { |
|
| 3387 | - if ( $match_field == $field_info['htmlvar_name'] ) { |
|
| 3388 | - $field = $field_info; |
|
| 3389 | - break; |
|
| 3390 | - } elseif( $_match_field == $field_info['htmlvar_name'] ) { |
|
| 3391 | - $field = $field_info; |
|
| 3392 | - break; |
|
| 3393 | - } |
|
| 3394 | - } |
|
| 3395 | - |
|
| 3396 | - if ( empty( $field ) ) { |
|
| 3397 | - $empty_field = true; |
|
| 3398 | - } |
|
| 3399 | - } |
|
| 3400 | - |
|
| 3401 | - // Address fields. |
|
| 3402 | - if ( in_array( $match_field, $address_fields ) && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
| 3403 | - if ( ! empty( $address_fields[ $match_field ] ) ) { |
|
| 3404 | - $field = $address_fields[ $match_field ]; |
|
| 3405 | - } |
|
| 3406 | - } else if ( in_array( $match_field, array_keys( $standard_fields ) ) ) { |
|
| 3407 | - if ( ! empty( $standard_fields[ $match_field ] ) ) { |
|
| 3408 | - $field = $standard_fields[ $match_field ]; |
|
| 3409 | - } |
|
| 3410 | - } |
|
| 3411 | - |
|
| 3412 | - // Parse search. |
|
| 3413 | - $search = sd_gd_field_rule_search( $args['search'], $find_post->post_type, $rule, $field, $find_post ); |
|
| 3414 | - |
|
| 3415 | - $is_date = ( ! empty( $field['type'] ) && $field['type'] == 'datepicker' ) || in_array( $match_field, array( 'post_date', 'post_modified' ) ) ? true : false; |
|
| 3416 | - $is_date = apply_filters( 'geodir_post_badge_is_date', $is_date, $match_field, $field, $args, $find_post ); |
|
| 3417 | - |
|
| 3418 | - $match_value = isset( $find_post->{$match_field} ) && empty( $empty_field ) ? esc_attr( trim( $find_post->{$match_field} ) ) : ''; |
|
| 3419 | - $match_found = $match_field === '' ? true : false; |
|
| 3420 | - |
|
| 3421 | - if ( ! $match_found ) { |
|
| 3422 | - if ( ( $match_field == 'post_date' || $match_field == 'post_modified' ) && ( empty( $args['condition'] ) || $args['condition'] == 'is_greater_than' || $args['condition'] == 'is_less_than' ) ) { |
|
| 3423 | - if ( strpos( $search, '+' ) === false && strpos( $search, '-' ) === false ) { |
|
| 3424 | - $search = '+' . $search; |
|
| 3425 | - } |
|
| 3426 | - $the_time = $match_field == 'post_modified' ? get_the_modified_date( 'Y-m-d', $find_post ) : get_the_time( 'Y-m-d', $find_post ); |
|
| 3427 | - $until_time = strtotime( $the_time . ' ' . $search . ' days' ); |
|
| 3428 | - $now_time = strtotime( date_i18n( 'Y-m-d', current_time( 'timestamp' ) ) ); |
|
| 3429 | - if ( ( empty( $args['condition'] ) || $args['condition'] == 'is_less_than' ) && $until_time > $now_time ) { |
|
| 3430 | - $match_found = true; |
|
| 3431 | - } elseif ( $args['condition'] == 'is_greater_than' && $until_time < $now_time ) { |
|
| 3432 | - $match_found = true; |
|
| 3433 | - } |
|
| 3434 | - } else { |
|
| 3435 | - switch ( $args['condition'] ) { |
|
| 3436 | - case 'is_equal': |
|
| 3437 | - $match_found = (bool) ( $search != '' && $match_value == $search ); |
|
| 3438 | - break; |
|
| 3439 | - case 'is_not_equal': |
|
| 3440 | - $match_found = (bool) ( $search != '' && $match_value != $search ); |
|
| 3441 | - break; |
|
| 3442 | - case 'is_greater_than': |
|
| 3443 | - $match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value > $search ); |
|
| 3444 | - break; |
|
| 3445 | - case 'is_less_than': |
|
| 3446 | - $match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value < $search ); |
|
| 3447 | - break; |
|
| 3448 | - case 'is_empty': |
|
| 3449 | - $match_found = (bool) ( $match_value === '' || $match_value === false || $match_value === '0' || is_null( $match_value ) ); |
|
| 3450 | - break; |
|
| 3451 | - case 'is_not_empty': |
|
| 3452 | - $match_found = (bool) ( $match_value !== '' && $match_value !== false && $match_value !== '0' && ! is_null( $match_value ) ); |
|
| 3453 | - break; |
|
| 3454 | - case 'is_contains': |
|
| 3455 | - $match_found = (bool) ( $search != '' && stripos( $match_value, $search ) !== false ); |
|
| 3456 | - break; |
|
| 3457 | - case 'is_not_contains': |
|
| 3458 | - $match_found = (bool) ( $search != '' && stripos( $match_value, $search ) === false ); |
|
| 3459 | - break; |
|
| 3460 | - } |
|
| 3461 | - } |
|
| 3462 | - } |
|
| 3463 | - |
|
| 3464 | - $match_found = apply_filters( 'geodir_post_badge_check_match_found', $match_found, $args, $find_post ); |
|
| 3465 | - } else { |
|
| 3466 | - $field = array(); |
|
| 3467 | - |
|
| 3468 | - // Parse search. |
|
| 3469 | - $search = sd_gd_field_rule_search( $args['search'], $find_post->post_type, $rule, $field, $find_post ); |
|
| 3470 | - |
|
| 3471 | - $match_value = ''; |
|
| 3472 | - $match_found = $match_field === '' ? true : false; |
|
| 3473 | - |
|
| 3474 | - if ( ! $match_found ) { |
|
| 3475 | - switch ( $args['condition'] ) { |
|
| 3476 | - case 'is_equal': |
|
| 3477 | - $match_found = (bool) ( $search != '' && $match_value == $search ); |
|
| 3478 | - break; |
|
| 3479 | - case 'is_not_equal': |
|
| 3480 | - $match_found = (bool) ( $search != '' && $match_value != $search ); |
|
| 3481 | - break; |
|
| 3482 | - case 'is_greater_than': |
|
| 3483 | - $match_found = false; |
|
| 3484 | - break; |
|
| 3485 | - case 'is_less_than': |
|
| 3486 | - $match_found = false; |
|
| 3487 | - break; |
|
| 3488 | - case 'is_empty': |
|
| 3489 | - $match_found = true; |
|
| 3490 | - break; |
|
| 3491 | - case 'is_not_empty': |
|
| 3492 | - $match_found = false; |
|
| 3493 | - break; |
|
| 3494 | - case 'is_contains': |
|
| 3495 | - $match_found = false; |
|
| 3496 | - break; |
|
| 3497 | - case 'is_not_contains': |
|
| 3498 | - $match_found = false; |
|
| 3499 | - break; |
|
| 3500 | - } |
|
| 3501 | - } |
|
| 3502 | - |
|
| 3503 | - $match_found = apply_filters( 'geodir_post_badge_check_match_found_empty', $match_found, $args, $find_post ); |
|
| 3504 | - } |
|
| 3505 | - } |
|
| 3506 | - |
|
| 3507 | - return $match_found; |
|
| 3345 | + global $gd_post; |
|
| 3346 | + |
|
| 3347 | + $match_found = false; |
|
| 3348 | + |
|
| 3349 | + if ( class_exists( 'GeoDirectory' ) && ! empty( $gd_post->ID ) && ! empty( $rule['field'] ) && ! empty( $rule['condition'] ) ) { |
|
| 3350 | + $args['block_visibility'] = true; |
|
| 3351 | + $args['key'] = $rule['field']; |
|
| 3352 | + $args['condition'] = $rule['condition']; |
|
| 3353 | + $args['search'] = isset( $rule['search'] ) ? $rule['search'] : ''; |
|
| 3354 | + |
|
| 3355 | + if ( $args['key'] == 'street' ) { |
|
| 3356 | + $args['key'] = 'address'; |
|
| 3357 | + } |
|
| 3358 | + |
|
| 3359 | + $match_field = $_match_field = $args['key']; |
|
| 3360 | + |
|
| 3361 | + if ( $match_field == 'address' ) { |
|
| 3362 | + $match_field = 'street'; |
|
| 3363 | + } elseif ( $match_field == 'post_images' ) { |
|
| 3364 | + $match_field = 'featured_image'; |
|
| 3365 | + } |
|
| 3366 | + |
|
| 3367 | + $find_post = $gd_post; |
|
| 3368 | + $find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
|
| 3369 | + |
|
| 3370 | + if ( ! empty( $find_post->ID ) && ! in_array( 'post_category', $find_post_keys ) ) { |
|
| 3371 | + $find_post = geodir_get_post_info( (int) $find_post->ID ); |
|
| 3372 | + $find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
|
| 3373 | + } |
|
| 3374 | + |
|
| 3375 | + if ( $match_field === '' || ( ! empty( $find_post_keys ) && ( in_array( $match_field, $find_post_keys ) || in_array( $_match_field, $find_post_keys ) ) ) ) { |
|
| 3376 | + $address_fields = array( 'street2', 'neighbourhood', 'city', 'region', 'country', 'zip', 'latitude', 'longitude' ); // Address fields |
|
| 3377 | + $field = array(); |
|
| 3378 | + $empty_field = false; |
|
| 3379 | + |
|
| 3380 | + $standard_fields = sd_visibility_gd_standard_fields(); |
|
| 3381 | + |
|
| 3382 | + if ( $match_field && ! in_array( $match_field, array_keys( $standard_fields ) ) && ! in_array( $match_field, $address_fields ) ) { |
|
| 3383 | + $package_id = geodir_get_post_package_id( $find_post->ID, $find_post->post_type ); |
|
| 3384 | + $fields = geodir_post_custom_fields( $package_id, 'all', $find_post->post_type, 'none' ); |
|
| 3385 | + |
|
| 3386 | + foreach ( $fields as $field_info ) { |
|
| 3387 | + if ( $match_field == $field_info['htmlvar_name'] ) { |
|
| 3388 | + $field = $field_info; |
|
| 3389 | + break; |
|
| 3390 | + } elseif( $_match_field == $field_info['htmlvar_name'] ) { |
|
| 3391 | + $field = $field_info; |
|
| 3392 | + break; |
|
| 3393 | + } |
|
| 3394 | + } |
|
| 3395 | + |
|
| 3396 | + if ( empty( $field ) ) { |
|
| 3397 | + $empty_field = true; |
|
| 3398 | + } |
|
| 3399 | + } |
|
| 3400 | + |
|
| 3401 | + // Address fields. |
|
| 3402 | + if ( in_array( $match_field, $address_fields ) && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
| 3403 | + if ( ! empty( $address_fields[ $match_field ] ) ) { |
|
| 3404 | + $field = $address_fields[ $match_field ]; |
|
| 3405 | + } |
|
| 3406 | + } else if ( in_array( $match_field, array_keys( $standard_fields ) ) ) { |
|
| 3407 | + if ( ! empty( $standard_fields[ $match_field ] ) ) { |
|
| 3408 | + $field = $standard_fields[ $match_field ]; |
|
| 3409 | + } |
|
| 3410 | + } |
|
| 3411 | + |
|
| 3412 | + // Parse search. |
|
| 3413 | + $search = sd_gd_field_rule_search( $args['search'], $find_post->post_type, $rule, $field, $find_post ); |
|
| 3414 | + |
|
| 3415 | + $is_date = ( ! empty( $field['type'] ) && $field['type'] == 'datepicker' ) || in_array( $match_field, array( 'post_date', 'post_modified' ) ) ? true : false; |
|
| 3416 | + $is_date = apply_filters( 'geodir_post_badge_is_date', $is_date, $match_field, $field, $args, $find_post ); |
|
| 3417 | + |
|
| 3418 | + $match_value = isset( $find_post->{$match_field} ) && empty( $empty_field ) ? esc_attr( trim( $find_post->{$match_field} ) ) : ''; |
|
| 3419 | + $match_found = $match_field === '' ? true : false; |
|
| 3420 | + |
|
| 3421 | + if ( ! $match_found ) { |
|
| 3422 | + if ( ( $match_field == 'post_date' || $match_field == 'post_modified' ) && ( empty( $args['condition'] ) || $args['condition'] == 'is_greater_than' || $args['condition'] == 'is_less_than' ) ) { |
|
| 3423 | + if ( strpos( $search, '+' ) === false && strpos( $search, '-' ) === false ) { |
|
| 3424 | + $search = '+' . $search; |
|
| 3425 | + } |
|
| 3426 | + $the_time = $match_field == 'post_modified' ? get_the_modified_date( 'Y-m-d', $find_post ) : get_the_time( 'Y-m-d', $find_post ); |
|
| 3427 | + $until_time = strtotime( $the_time . ' ' . $search . ' days' ); |
|
| 3428 | + $now_time = strtotime( date_i18n( 'Y-m-d', current_time( 'timestamp' ) ) ); |
|
| 3429 | + if ( ( empty( $args['condition'] ) || $args['condition'] == 'is_less_than' ) && $until_time > $now_time ) { |
|
| 3430 | + $match_found = true; |
|
| 3431 | + } elseif ( $args['condition'] == 'is_greater_than' && $until_time < $now_time ) { |
|
| 3432 | + $match_found = true; |
|
| 3433 | + } |
|
| 3434 | + } else { |
|
| 3435 | + switch ( $args['condition'] ) { |
|
| 3436 | + case 'is_equal': |
|
| 3437 | + $match_found = (bool) ( $search != '' && $match_value == $search ); |
|
| 3438 | + break; |
|
| 3439 | + case 'is_not_equal': |
|
| 3440 | + $match_found = (bool) ( $search != '' && $match_value != $search ); |
|
| 3441 | + break; |
|
| 3442 | + case 'is_greater_than': |
|
| 3443 | + $match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value > $search ); |
|
| 3444 | + break; |
|
| 3445 | + case 'is_less_than': |
|
| 3446 | + $match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value < $search ); |
|
| 3447 | + break; |
|
| 3448 | + case 'is_empty': |
|
| 3449 | + $match_found = (bool) ( $match_value === '' || $match_value === false || $match_value === '0' || is_null( $match_value ) ); |
|
| 3450 | + break; |
|
| 3451 | + case 'is_not_empty': |
|
| 3452 | + $match_found = (bool) ( $match_value !== '' && $match_value !== false && $match_value !== '0' && ! is_null( $match_value ) ); |
|
| 3453 | + break; |
|
| 3454 | + case 'is_contains': |
|
| 3455 | + $match_found = (bool) ( $search != '' && stripos( $match_value, $search ) !== false ); |
|
| 3456 | + break; |
|
| 3457 | + case 'is_not_contains': |
|
| 3458 | + $match_found = (bool) ( $search != '' && stripos( $match_value, $search ) === false ); |
|
| 3459 | + break; |
|
| 3460 | + } |
|
| 3461 | + } |
|
| 3462 | + } |
|
| 3463 | + |
|
| 3464 | + $match_found = apply_filters( 'geodir_post_badge_check_match_found', $match_found, $args, $find_post ); |
|
| 3465 | + } else { |
|
| 3466 | + $field = array(); |
|
| 3467 | + |
|
| 3468 | + // Parse search. |
|
| 3469 | + $search = sd_gd_field_rule_search( $args['search'], $find_post->post_type, $rule, $field, $find_post ); |
|
| 3470 | + |
|
| 3471 | + $match_value = ''; |
|
| 3472 | + $match_found = $match_field === '' ? true : false; |
|
| 3473 | + |
|
| 3474 | + if ( ! $match_found ) { |
|
| 3475 | + switch ( $args['condition'] ) { |
|
| 3476 | + case 'is_equal': |
|
| 3477 | + $match_found = (bool) ( $search != '' && $match_value == $search ); |
|
| 3478 | + break; |
|
| 3479 | + case 'is_not_equal': |
|
| 3480 | + $match_found = (bool) ( $search != '' && $match_value != $search ); |
|
| 3481 | + break; |
|
| 3482 | + case 'is_greater_than': |
|
| 3483 | + $match_found = false; |
|
| 3484 | + break; |
|
| 3485 | + case 'is_less_than': |
|
| 3486 | + $match_found = false; |
|
| 3487 | + break; |
|
| 3488 | + case 'is_empty': |
|
| 3489 | + $match_found = true; |
|
| 3490 | + break; |
|
| 3491 | + case 'is_not_empty': |
|
| 3492 | + $match_found = false; |
|
| 3493 | + break; |
|
| 3494 | + case 'is_contains': |
|
| 3495 | + $match_found = false; |
|
| 3496 | + break; |
|
| 3497 | + case 'is_not_contains': |
|
| 3498 | + $match_found = false; |
|
| 3499 | + break; |
|
| 3500 | + } |
|
| 3501 | + } |
|
| 3502 | + |
|
| 3503 | + $match_found = apply_filters( 'geodir_post_badge_check_match_found_empty', $match_found, $args, $find_post ); |
|
| 3504 | + } |
|
| 3505 | + } |
|
| 3506 | + |
|
| 3507 | + return $match_found; |
|
| 3508 | 3508 | } |
| 3509 | 3509 | |
| 3510 | 3510 | function sd_gd_field_rule_search( $search, $post_type, $rule, $field = array(), $gd_post = array() ) { |
| 3511 | - global $post; |
|
| 3512 | - |
|
| 3513 | - if ( ! $search ) { |
|
| 3514 | - return $search; |
|
| 3515 | - } |
|
| 3516 | - |
|
| 3517 | - $orig_search = $search; |
|
| 3518 | - $_search = strtolower( $search ); |
|
| 3519 | - |
|
| 3520 | - if ( ! empty( $rule['field'] ) && $rule['field'] == 'post_author' ) { |
|
| 3521 | - if ( $search == 'current_user' ) { |
|
| 3522 | - $search = is_user_logged_in() ? (int) get_current_user_id() : - 1; |
|
| 3523 | - } else if ( $search == 'current_author' ) { |
|
| 3524 | - $search = ( ! empty( $post ) && $post->post_type != 'page' && isset( $post->post_author ) ) ? absint( $post->post_author ) : - 1; |
|
| 3525 | - } |
|
| 3526 | - } else if ( $_search == 'date_today' ) { |
|
| 3527 | - $search = date( 'Y-m-d' ); |
|
| 3528 | - } else if ( $_search == 'date_tomorrow' ) { |
|
| 3529 | - $search = date( 'Y-m-d', strtotime( "+1 day" ) ); |
|
| 3530 | - } else if ( $_search == 'date_yesterday' ) { |
|
| 3531 | - $search = date( 'Y-m-d', strtotime( "-1 day" ) ); |
|
| 3532 | - } else if ( $_search == 'time_his' ) { |
|
| 3533 | - $search = date( 'H:i:s' ); |
|
| 3534 | - } else if ( $_search == 'time_hi' ) { |
|
| 3535 | - $search = date( 'H:i' ); |
|
| 3536 | - } else if ( $_search == 'datetime_now' ) { |
|
| 3537 | - $search = date( 'Y-m-d H:i:s' ); |
|
| 3538 | - } else if ( strpos( $_search, 'datetime_after_' ) === 0 ) { |
|
| 3539 | - $_searches = explode( 'datetime_after_', $_search, 2 ); |
|
| 3540 | - |
|
| 3541 | - if ( ! empty( $_searches[1] ) ) { |
|
| 3542 | - $search = date( 'Y-m-d H:i:s', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3543 | - } else { |
|
| 3544 | - $search = date( 'Y-m-d H:i:s' ); |
|
| 3545 | - } |
|
| 3546 | - } else if ( strpos( $_search, 'datetime_before_' ) === 0 ) { |
|
| 3547 | - $_searches = explode( 'datetime_before_', $_search, 2 ); |
|
| 3548 | - |
|
| 3549 | - if ( ! empty( $_searches[1] ) ) { |
|
| 3550 | - $search = date( 'Y-m-d H:i:s', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3551 | - } else { |
|
| 3552 | - $search = date( 'Y-m-d H:i:s' ); |
|
| 3553 | - } |
|
| 3554 | - } else if ( strpos( $_search, 'date_after_' ) === 0 ) { |
|
| 3555 | - $_searches = explode( 'date_after_', $_search, 2 ); |
|
| 3556 | - |
|
| 3557 | - if ( ! empty( $_searches[1] ) ) { |
|
| 3558 | - $search = date( 'Y-m-d', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3559 | - } else { |
|
| 3560 | - $search = date( 'Y-m-d' ); |
|
| 3561 | - } |
|
| 3562 | - } else if ( strpos( $_search, 'date_before_' ) === 0 ) { |
|
| 3563 | - $_searches = explode( 'date_before_', $_search, 2 ); |
|
| 3564 | - |
|
| 3565 | - if ( ! empty( $_searches[1] ) ) { |
|
| 3566 | - $search = date( 'Y-m-d', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3567 | - } else { |
|
| 3568 | - $search = date( 'Y-m-d' ); |
|
| 3569 | - } |
|
| 3570 | - } |
|
| 3571 | - |
|
| 3572 | - return apply_filters( 'sd_gd_field_rule_search', $search, $post_type, $rule, $orig_search ); |
|
| 3511 | + global $post; |
|
| 3512 | + |
|
| 3513 | + if ( ! $search ) { |
|
| 3514 | + return $search; |
|
| 3515 | + } |
|
| 3516 | + |
|
| 3517 | + $orig_search = $search; |
|
| 3518 | + $_search = strtolower( $search ); |
|
| 3519 | + |
|
| 3520 | + if ( ! empty( $rule['field'] ) && $rule['field'] == 'post_author' ) { |
|
| 3521 | + if ( $search == 'current_user' ) { |
|
| 3522 | + $search = is_user_logged_in() ? (int) get_current_user_id() : - 1; |
|
| 3523 | + } else if ( $search == 'current_author' ) { |
|
| 3524 | + $search = ( ! empty( $post ) && $post->post_type != 'page' && isset( $post->post_author ) ) ? absint( $post->post_author ) : - 1; |
|
| 3525 | + } |
|
| 3526 | + } else if ( $_search == 'date_today' ) { |
|
| 3527 | + $search = date( 'Y-m-d' ); |
|
| 3528 | + } else if ( $_search == 'date_tomorrow' ) { |
|
| 3529 | + $search = date( 'Y-m-d', strtotime( "+1 day" ) ); |
|
| 3530 | + } else if ( $_search == 'date_yesterday' ) { |
|
| 3531 | + $search = date( 'Y-m-d', strtotime( "-1 day" ) ); |
|
| 3532 | + } else if ( $_search == 'time_his' ) { |
|
| 3533 | + $search = date( 'H:i:s' ); |
|
| 3534 | + } else if ( $_search == 'time_hi' ) { |
|
| 3535 | + $search = date( 'H:i' ); |
|
| 3536 | + } else if ( $_search == 'datetime_now' ) { |
|
| 3537 | + $search = date( 'Y-m-d H:i:s' ); |
|
| 3538 | + } else if ( strpos( $_search, 'datetime_after_' ) === 0 ) { |
|
| 3539 | + $_searches = explode( 'datetime_after_', $_search, 2 ); |
|
| 3540 | + |
|
| 3541 | + if ( ! empty( $_searches[1] ) ) { |
|
| 3542 | + $search = date( 'Y-m-d H:i:s', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3543 | + } else { |
|
| 3544 | + $search = date( 'Y-m-d H:i:s' ); |
|
| 3545 | + } |
|
| 3546 | + } else if ( strpos( $_search, 'datetime_before_' ) === 0 ) { |
|
| 3547 | + $_searches = explode( 'datetime_before_', $_search, 2 ); |
|
| 3548 | + |
|
| 3549 | + if ( ! empty( $_searches[1] ) ) { |
|
| 3550 | + $search = date( 'Y-m-d H:i:s', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3551 | + } else { |
|
| 3552 | + $search = date( 'Y-m-d H:i:s' ); |
|
| 3553 | + } |
|
| 3554 | + } else if ( strpos( $_search, 'date_after_' ) === 0 ) { |
|
| 3555 | + $_searches = explode( 'date_after_', $_search, 2 ); |
|
| 3556 | + |
|
| 3557 | + if ( ! empty( $_searches[1] ) ) { |
|
| 3558 | + $search = date( 'Y-m-d', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3559 | + } else { |
|
| 3560 | + $search = date( 'Y-m-d' ); |
|
| 3561 | + } |
|
| 3562 | + } else if ( strpos( $_search, 'date_before_' ) === 0 ) { |
|
| 3563 | + $_searches = explode( 'date_before_', $_search, 2 ); |
|
| 3564 | + |
|
| 3565 | + if ( ! empty( $_searches[1] ) ) { |
|
| 3566 | + $search = date( 'Y-m-d', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3567 | + } else { |
|
| 3568 | + $search = date( 'Y-m-d' ); |
|
| 3569 | + } |
|
| 3570 | + } |
|
| 3571 | + |
|
| 3572 | + return apply_filters( 'sd_gd_field_rule_search', $search, $post_type, $rule, $orig_search ); |
|
| 3573 | 3573 | } |