@@ -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,1233 +11,1233 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | class AUI_Component_Input { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Build the component. |
|
| 16 | - * |
|
| 17 | - * @param array $args |
|
| 18 | - * |
|
| 19 | - * @return string The rendered component. |
|
| 20 | - */ |
|
| 21 | - public static function input( $args = array() ) { |
|
| 22 | - $defaults = array( |
|
| 23 | - 'type' => 'text', |
|
| 24 | - 'name' => '', |
|
| 25 | - 'class' => '', |
|
| 26 | - 'wrap_class' => '', |
|
| 27 | - 'id' => '', |
|
| 28 | - 'placeholder' => '', |
|
| 29 | - 'title' => '', |
|
| 30 | - 'value' => '', |
|
| 31 | - 'required' => false, |
|
| 32 | - 'size' => '', // sm, lg, small, large |
|
| 33 | - 'clear_icon' => '', // true will show a clear icon, can't be used with input_group_right |
|
| 34 | - 'label' => '', |
|
| 35 | - 'label_after' => false, |
|
| 36 | - 'label_class' => '', |
|
| 37 | - 'label_col' => '2', |
|
| 38 | - 'label_type' => '', // top, horizontal, empty = hidden |
|
| 39 | - 'label_force_left' => false, // used to force checkbox label left when using horizontal |
|
| 40 | - // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 41 | - 'help_text' => '', |
|
| 42 | - 'validation_text' => '', |
|
| 43 | - 'validation_pattern' => '', |
|
| 44 | - 'no_wrap' => false, |
|
| 45 | - 'input_group_right' => '', |
|
| 46 | - 'input_group_left' => '', |
|
| 47 | - 'input_group_right_inside' => false, |
|
| 48 | - // forces the input group inside the input |
|
| 49 | - 'input_group_left_inside' => false, |
|
| 50 | - // forces the input group inside the input |
|
| 51 | - 'step' => '', |
|
| 52 | - 'switch' => false, |
|
| 53 | - // to show checkbox as a switch |
|
| 54 | - 'checked' => false, |
|
| 55 | - // set a checkbox or radio as selected |
|
| 56 | - 'password_toggle' => true, |
|
| 57 | - // toggle view/hide password |
|
| 58 | - 'element_require' => '', |
|
| 59 | - // [%element_id%] == "1" |
|
| 60 | - 'extra_attributes' => array(), |
|
| 61 | - // an array of extra attributes |
|
| 62 | - 'wrap_attributes' => array() |
|
| 63 | - ); |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 67 | - */ |
|
| 68 | - $args = wp_parse_args( $args, $defaults ); |
|
| 69 | - $output = ''; |
|
| 70 | - if ( ! empty( $args['type'] ) ) { |
|
| 71 | - // hidden label option needs to be empty |
|
| 72 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 73 | - |
|
| 74 | - $type = sanitize_html_class( $args['type'] ); |
|
| 75 | - |
|
| 76 | - $help_text = ''; |
|
| 77 | - $label = ''; |
|
| 78 | - $label_after = $args['label_after']; |
|
| 79 | - $label_args = array( |
|
| 80 | - 'title' => $args['label'], |
|
| 81 | - 'for' => $args['id'], |
|
| 82 | - 'class' => $args['label_class'] . " ", |
|
| 83 | - 'label_type' => $args['label_type'], |
|
| 84 | - 'label_col' => $args['label_col'] |
|
| 85 | - ); |
|
| 86 | - |
|
| 87 | - // floating labels need label after |
|
| 88 | - if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) { |
|
| 89 | - $label_after = true; |
|
| 90 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // size |
|
| 94 | - $size = ''; |
|
| 95 | - if ( $args['size'] == 'lg' || $args['size'] == 'large' ) { |
|
| 96 | - $size = 'lg'; |
|
| 97 | - $args['class'] .= ' form-control-lg'; |
|
| 98 | - }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) { |
|
| 99 | - $size = 'sm'; |
|
| 100 | - $args['class'] .= ' form-control-sm'; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // clear function |
|
| 104 | - $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');'; |
|
| 105 | - |
|
| 106 | - // Some special sauce for files |
|
| 107 | - if ( $type == 'file' ) { |
|
| 108 | - $label_after = true; // if type file we need the label after |
|
| 109 | - $args['class'] .= ' custom-file-input '; |
|
| 110 | - } elseif ( $type == 'checkbox' ) { |
|
| 111 | - $label_after = true; // if type file we need the label after |
|
| 112 | - $args['class'] .= ' custom-control-input '; |
|
| 113 | - } elseif ( $type == 'datepicker' || $type == 'timepicker' ) { |
|
| 114 | - $type = 'text'; |
|
| 115 | - $args['class'] .= ' bg-initial '; // @todo not sure why we have this? |
|
| 116 | - $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');"; |
|
| 117 | - |
|
| 118 | - $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
|
| 119 | - |
|
| 120 | - // set a way to clear field if empty |
|
| 121 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) { |
|
| 122 | - $args['input_group_right_inside'] = true; |
|
| 123 | - $args['clear_icon'] = true; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // enqueue the script |
|
| 127 | - $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 128 | - $aui_settings->enqueue_flatpickr(); |
|
| 129 | - } elseif ( $type == 'iconpicker' ) { |
|
| 130 | - $type = 'text'; |
|
| 131 | - //$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 | + $defaults = array( |
|
| 23 | + 'type' => 'text', |
|
| 24 | + 'name' => '', |
|
| 25 | + 'class' => '', |
|
| 26 | + 'wrap_class' => '', |
|
| 27 | + 'id' => '', |
|
| 28 | + 'placeholder' => '', |
|
| 29 | + 'title' => '', |
|
| 30 | + 'value' => '', |
|
| 31 | + 'required' => false, |
|
| 32 | + 'size' => '', // sm, lg, small, large |
|
| 33 | + 'clear_icon' => '', // true will show a clear icon, can't be used with input_group_right |
|
| 34 | + 'label' => '', |
|
| 35 | + 'label_after' => false, |
|
| 36 | + 'label_class' => '', |
|
| 37 | + 'label_col' => '2', |
|
| 38 | + 'label_type' => '', // top, horizontal, empty = hidden |
|
| 39 | + 'label_force_left' => false, // used to force checkbox label left when using horizontal |
|
| 40 | + // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 41 | + 'help_text' => '', |
|
| 42 | + 'validation_text' => '', |
|
| 43 | + 'validation_pattern' => '', |
|
| 44 | + 'no_wrap' => false, |
|
| 45 | + 'input_group_right' => '', |
|
| 46 | + 'input_group_left' => '', |
|
| 47 | + 'input_group_right_inside' => false, |
|
| 48 | + // forces the input group inside the input |
|
| 49 | + 'input_group_left_inside' => false, |
|
| 50 | + // forces the input group inside the input |
|
| 51 | + 'step' => '', |
|
| 52 | + 'switch' => false, |
|
| 53 | + // to show checkbox as a switch |
|
| 54 | + 'checked' => false, |
|
| 55 | + // set a checkbox or radio as selected |
|
| 56 | + 'password_toggle' => true, |
|
| 57 | + // toggle view/hide password |
|
| 58 | + 'element_require' => '', |
|
| 59 | + // [%element_id%] == "1" |
|
| 60 | + 'extra_attributes' => array(), |
|
| 61 | + // an array of extra attributes |
|
| 62 | + 'wrap_attributes' => array() |
|
| 63 | + ); |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 67 | + */ |
|
| 68 | + $args = wp_parse_args( $args, $defaults ); |
|
| 69 | + $output = ''; |
|
| 70 | + if ( ! empty( $args['type'] ) ) { |
|
| 71 | + // hidden label option needs to be empty |
|
| 72 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 73 | + |
|
| 74 | + $type = sanitize_html_class( $args['type'] ); |
|
| 75 | + |
|
| 76 | + $help_text = ''; |
|
| 77 | + $label = ''; |
|
| 78 | + $label_after = $args['label_after']; |
|
| 79 | + $label_args = array( |
|
| 80 | + 'title' => $args['label'], |
|
| 81 | + 'for' => $args['id'], |
|
| 82 | + 'class' => $args['label_class'] . " ", |
|
| 83 | + 'label_type' => $args['label_type'], |
|
| 84 | + 'label_col' => $args['label_col'] |
|
| 85 | + ); |
|
| 86 | + |
|
| 87 | + // floating labels need label after |
|
| 88 | + if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) { |
|
| 89 | + $label_after = true; |
|
| 90 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // size |
|
| 94 | + $size = ''; |
|
| 95 | + if ( $args['size'] == 'lg' || $args['size'] == 'large' ) { |
|
| 96 | + $size = 'lg'; |
|
| 97 | + $args['class'] .= ' form-control-lg'; |
|
| 98 | + }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) { |
|
| 99 | + $size = 'sm'; |
|
| 100 | + $args['class'] .= ' form-control-sm'; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // clear function |
|
| 104 | + $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');'; |
|
| 105 | + |
|
| 106 | + // Some special sauce for files |
|
| 107 | + if ( $type == 'file' ) { |
|
| 108 | + $label_after = true; // if type file we need the label after |
|
| 109 | + $args['class'] .= ' custom-file-input '; |
|
| 110 | + } elseif ( $type == 'checkbox' ) { |
|
| 111 | + $label_after = true; // if type file we need the label after |
|
| 112 | + $args['class'] .= ' custom-control-input '; |
|
| 113 | + } elseif ( $type == 'datepicker' || $type == 'timepicker' ) { |
|
| 114 | + $type = 'text'; |
|
| 115 | + $args['class'] .= ' bg-initial '; // @todo not sure why we have this? |
|
| 116 | + $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');"; |
|
| 117 | + |
|
| 118 | + $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
|
| 119 | + |
|
| 120 | + // set a way to clear field if empty |
|
| 121 | + if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) { |
|
| 122 | + $args['input_group_right_inside'] = true; |
|
| 123 | + $args['clear_icon'] = true; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // enqueue the script |
|
| 127 | + $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 128 | + $aui_settings->enqueue_flatpickr(); |
|
| 129 | + } elseif ( $type == 'iconpicker' ) { |
|
| 130 | + $type = 'text'; |
|
| 131 | + //$args['class'] .= ' aui-flatpickr bg-initial '; |
|
| 132 | 132 | // $args['class'] .= ' bg-initial '; |
| 133 | 133 | |
| 134 | - $args['extra_attributes']['data-aui-init'] = 'iconpicker'; |
|
| 135 | - $args['extra_attributes']['data-placement'] = 'bottomRight'; |
|
| 134 | + $args['extra_attributes']['data-aui-init'] = 'iconpicker'; |
|
| 135 | + $args['extra_attributes']['data-placement'] = 'bottomRight'; |
|
| 136 | 136 | |
| 137 | - $args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>'; |
|
| 137 | + $args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>'; |
|
| 138 | 138 | // $args['input_group_right_inside'] = true; |
| 139 | - // enqueue the script |
|
| 140 | - $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 141 | - $aui_settings->enqueue_iconpicker(); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) { |
|
| 145 | - $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />'; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - // allow clear icon |
|
| 149 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] ) { |
|
| 150 | - $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' ); |
|
| 151 | - $args['input_group_right_inside'] = true; |
|
| 152 | - $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: '.$font_size.'rem" aria-hidden="true" class="close">×</span></span>'; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - // open/type |
|
| 156 | - $output .= '<input type="' . $type . '" '; |
|
| 157 | - |
|
| 158 | - // name |
|
| 159 | - if ( ! empty( $args['name'] ) ) { |
|
| 160 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // id |
|
| 164 | - if ( ! empty( $args['id'] ) ) { |
|
| 165 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // placeholder |
|
| 169 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 170 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - // title |
|
| 174 | - if ( ! empty( $args['title'] ) ) { |
|
| 175 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // value |
|
| 179 | - if ( ! empty( $args['value'] ) ) { |
|
| 180 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // checked, for radio and checkboxes |
|
| 184 | - if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) { |
|
| 185 | - $output .= ' checked '; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - // validation text |
|
| 189 | - if ( ! empty( $args['validation_text'] ) ) { |
|
| 190 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
| 191 | - $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - // validation_pattern |
|
| 195 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 196 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - // step (for numbers) |
|
| 200 | - if ( ! empty( $args['step'] ) ) { |
|
| 201 | - $output .= ' step="' . $args['step'] . '" '; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - // required |
|
| 205 | - if ( ! empty( $args['required'] ) ) { |
|
| 206 | - $output .= ' required '; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - // class |
|
| 210 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 211 | - $output .= ' class="form-control ' . $class . '" '; |
|
| 212 | - |
|
| 213 | - // data-attributes |
|
| 214 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 215 | - |
|
| 216 | - // extra attributes |
|
| 217 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 218 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // close |
|
| 222 | - $output .= ' >'; |
|
| 223 | - |
|
| 224 | - // help text |
|
| 225 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 226 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - // label |
|
| 230 | - if ( ! empty( $args['label'] ) ) { |
|
| 231 | - $label_base_class = ''; |
|
| 232 | - if ( $type == 'file' ) { |
|
| 233 | - $label_base_class = ' custom-file-label'; |
|
| 234 | - } elseif ( $type == 'checkbox' ) { |
|
| 235 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
| 236 | - $label_args['title'] = wp_kses_post( $args['help_text'] ); |
|
| 237 | - $help_text = ''; |
|
| 238 | - //$label_args['class'] .= ' d-inline '; |
|
| 239 | - $args['wrap_class'] .= ' align-items-center '; |
|
| 240 | - }else{ |
|
| 241 | - |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - $label_base_class = ' custom-control-label'; |
|
| 245 | - } |
|
| 246 | - $label_args['class'] .= $label_base_class; |
|
| 247 | - $temp_label_args = $label_args; |
|
| 248 | - if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";} |
|
| 249 | - $label = self::label( $temp_label_args, $type ); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - // set help text in the correct position |
|
| 256 | - if ( $label_after ) { |
|
| 257 | - $output .= $label . $help_text; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - // some input types need a separate wrap |
|
| 261 | - if ( $type == 'file' ) { |
|
| 262 | - $output = self::wrap( array( |
|
| 263 | - 'content' => $output, |
|
| 264 | - 'class' => 'form-group custom-file' |
|
| 265 | - ) ); |
|
| 266 | - } elseif ( $type == 'checkbox' ) { |
|
| 267 | - |
|
| 268 | - $label_args['title'] = $args['label']; |
|
| 269 | - $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ); |
|
| 270 | - $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
| 271 | - $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : ''; |
|
| 272 | - $wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox'; |
|
| 273 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
| 274 | - $wrap_class .= ' d-flex align-content-center'; |
|
| 275 | - $label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) ); |
|
| 276 | - } |
|
| 277 | - $output = self::wrap( array( |
|
| 278 | - 'content' => $output, |
|
| 279 | - 'class' => 'custom-control ' . $wrap_class |
|
| 280 | - ) ); |
|
| 281 | - |
|
| 282 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 283 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 284 | - $output = $label . '<div class="' . $input_col . '">' . $output . '</div>'; |
|
| 285 | - } |
|
| 286 | - } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) { |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - // allow password field to toggle view |
|
| 290 | - $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" |
|
| 139 | + // enqueue the script |
|
| 140 | + $aui_settings = AyeCode_UI_Settings::instance(); |
|
| 141 | + $aui_settings->enqueue_iconpicker(); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) { |
|
| 145 | + $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />'; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + // allow clear icon |
|
| 149 | + if ( $args['input_group_right'] === '' && $args['clear_icon'] ) { |
|
| 150 | + $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' ); |
|
| 151 | + $args['input_group_right_inside'] = true; |
|
| 152 | + $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: '.$font_size.'rem" aria-hidden="true" class="close">×</span></span>'; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + // open/type |
|
| 156 | + $output .= '<input type="' . $type . '" '; |
|
| 157 | + |
|
| 158 | + // name |
|
| 159 | + if ( ! empty( $args['name'] ) ) { |
|
| 160 | + $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // id |
|
| 164 | + if ( ! empty( $args['id'] ) ) { |
|
| 165 | + $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // placeholder |
|
| 169 | + if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 170 | + $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + // title |
|
| 174 | + if ( ! empty( $args['title'] ) ) { |
|
| 175 | + $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // value |
|
| 179 | + if ( ! empty( $args['value'] ) ) { |
|
| 180 | + $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // checked, for radio and checkboxes |
|
| 184 | + if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) { |
|
| 185 | + $output .= ' checked '; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + // validation text |
|
| 189 | + if ( ! empty( $args['validation_text'] ) ) { |
|
| 190 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
| 191 | + $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + // validation_pattern |
|
| 195 | + if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 196 | + $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + // step (for numbers) |
|
| 200 | + if ( ! empty( $args['step'] ) ) { |
|
| 201 | + $output .= ' step="' . $args['step'] . '" '; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + // required |
|
| 205 | + if ( ! empty( $args['required'] ) ) { |
|
| 206 | + $output .= ' required '; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + // class |
|
| 210 | + $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 211 | + $output .= ' class="form-control ' . $class . '" '; |
|
| 212 | + |
|
| 213 | + // data-attributes |
|
| 214 | + $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 215 | + |
|
| 216 | + // extra attributes |
|
| 217 | + if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 218 | + $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // close |
|
| 222 | + $output .= ' >'; |
|
| 223 | + |
|
| 224 | + // help text |
|
| 225 | + if ( ! empty( $args['help_text'] ) ) { |
|
| 226 | + $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + // label |
|
| 230 | + if ( ! empty( $args['label'] ) ) { |
|
| 231 | + $label_base_class = ''; |
|
| 232 | + if ( $type == 'file' ) { |
|
| 233 | + $label_base_class = ' custom-file-label'; |
|
| 234 | + } elseif ( $type == 'checkbox' ) { |
|
| 235 | + if ( ! empty( $args['label_force_left'] ) ) { |
|
| 236 | + $label_args['title'] = wp_kses_post( $args['help_text'] ); |
|
| 237 | + $help_text = ''; |
|
| 238 | + //$label_args['class'] .= ' d-inline '; |
|
| 239 | + $args['wrap_class'] .= ' align-items-center '; |
|
| 240 | + }else{ |
|
| 241 | + |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + $label_base_class = ' custom-control-label'; |
|
| 245 | + } |
|
| 246 | + $label_args['class'] .= $label_base_class; |
|
| 247 | + $temp_label_args = $label_args; |
|
| 248 | + if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";} |
|
| 249 | + $label = self::label( $temp_label_args, $type ); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + // set help text in the correct position |
|
| 256 | + if ( $label_after ) { |
|
| 257 | + $output .= $label . $help_text; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + // some input types need a separate wrap |
|
| 261 | + if ( $type == 'file' ) { |
|
| 262 | + $output = self::wrap( array( |
|
| 263 | + 'content' => $output, |
|
| 264 | + 'class' => 'form-group custom-file' |
|
| 265 | + ) ); |
|
| 266 | + } elseif ( $type == 'checkbox' ) { |
|
| 267 | + |
|
| 268 | + $label_args['title'] = $args['label']; |
|
| 269 | + $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ); |
|
| 270 | + $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
| 271 | + $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : ''; |
|
| 272 | + $wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox'; |
|
| 273 | + if ( ! empty( $args['label_force_left'] ) ) { |
|
| 274 | + $wrap_class .= ' d-flex align-content-center'; |
|
| 275 | + $label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) ); |
|
| 276 | + } |
|
| 277 | + $output = self::wrap( array( |
|
| 278 | + 'content' => $output, |
|
| 279 | + 'class' => 'custom-control ' . $wrap_class |
|
| 280 | + ) ); |
|
| 281 | + |
|
| 282 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 283 | + $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 284 | + $output = $label . '<div class="' . $input_col . '">' . $output . '</div>'; |
|
| 285 | + } |
|
| 286 | + } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) { |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + // allow password field to toggle view |
|
| 290 | + $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" |
|
| 291 | 291 | onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\'); |
| 292 | 292 | var $eli = jQuery(this).parent().parent().find(\'input\'); |
| 293 | 293 | if($el.hasClass(\'fa-eye\')) |
| 294 | 294 | {$eli.attr(\'type\',\'text\');} |
| 295 | 295 | else{$eli.attr(\'type\',\'password\');}" |
| 296 | 296 | ><i class="far fa-fw fa-eye-slash"></i></span>'; |
| 297 | - } |
|
| 298 | - |
|
| 299 | - // input group wraps |
|
| 300 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 301 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 302 | - $group_size = $size == 'lg' ? ' input-group-lg' : ''; |
|
| 303 | - $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size; |
|
| 304 | - |
|
| 305 | - if ( $args['input_group_left'] ) { |
|
| 306 | - $output = self::wrap( array( |
|
| 307 | - 'content' => $output, |
|
| 308 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
|
| 309 | - 'input_group_left' => $args['input_group_left'], |
|
| 310 | - 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 311 | - ) ); |
|
| 312 | - } |
|
| 313 | - if ( $args['input_group_right'] ) { |
|
| 314 | - $output = self::wrap( array( |
|
| 315 | - 'content' => $output, |
|
| 316 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
|
| 317 | - 'input_group_right' => $args['input_group_right'], |
|
| 318 | - 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 319 | - ) ); |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - if ( ! $label_after ) { |
|
| 325 | - $output .= $help_text; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - |
|
| 329 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 330 | - $output = self::wrap( array( |
|
| 331 | - 'content' => $output, |
|
| 332 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 333 | - ) ); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - if ( ! $label_after ) { |
|
| 337 | - $output = $label . $output; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - // wrap |
|
| 341 | - if ( ! $args['no_wrap'] ) { |
|
| 342 | - $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
| 343 | - $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 344 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 345 | - $output = self::wrap( array( |
|
| 346 | - 'content' => $output, |
|
| 347 | - 'class' => $wrap_class, |
|
| 348 | - 'element_require' => $args['element_require'], |
|
| 349 | - 'argument_id' => $args['id'], |
|
| 350 | - 'wrap_attributes' => $args['wrap_attributes'], |
|
| 351 | - ) ); |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - return $output; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - public static function label( $args = array(), $type = '' ) { |
|
| 359 | - //<label for="exampleInputEmail1">Email address</label> |
|
| 360 | - $defaults = array( |
|
| 361 | - 'title' => 'div', |
|
| 362 | - 'for' => '', |
|
| 363 | - 'class' => '', |
|
| 364 | - 'label_type' => '', // empty = hidden, top, horizontal |
|
| 365 | - 'label_col' => '', |
|
| 366 | - ); |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 370 | - */ |
|
| 371 | - $args = wp_parse_args( $args, $defaults ); |
|
| 372 | - $output = ''; |
|
| 373 | - |
|
| 374 | - if ( $args['title'] ) { |
|
| 375 | - |
|
| 376 | - // maybe hide labels //@todo set a global option for visibility class |
|
| 377 | - if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) { |
|
| 378 | - $class = $args['class']; |
|
| 379 | - } else { |
|
| 380 | - $class = 'sr-only ' . $args['class']; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - // maybe horizontal |
|
| 384 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 385 | - $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label'; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - // open |
|
| 389 | - $output .= '<label '; |
|
| 390 | - |
|
| 391 | - // for |
|
| 392 | - if ( ! empty( $args['for'] ) ) { |
|
| 393 | - $output .= ' for="' . esc_attr( $args['for'] ) . '" '; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - // class |
|
| 397 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
| 398 | - $output .= ' class="' . $class . '" '; |
|
| 399 | - |
|
| 400 | - // close |
|
| 401 | - $output .= '>'; |
|
| 402 | - |
|
| 403 | - |
|
| 404 | - // title, don't escape fully as can contain html |
|
| 405 | - if ( ! empty( $args['title'] ) ) { |
|
| 406 | - $output .= wp_kses_post( $args['title'] ); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - // close wrap |
|
| 410 | - $output .= '</label>'; |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - |
|
| 416 | - return $output; |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - /** |
|
| 420 | - * Wrap some content in a HTML wrapper. |
|
| 421 | - * |
|
| 422 | - * @param array $args |
|
| 423 | - * |
|
| 424 | - * @return string |
|
| 425 | - */ |
|
| 426 | - public static function wrap( $args = array() ) { |
|
| 427 | - $defaults = array( |
|
| 428 | - 'type' => 'div', |
|
| 429 | - 'class' => 'form-group', |
|
| 430 | - 'content' => '', |
|
| 431 | - 'input_group_left' => '', |
|
| 432 | - 'input_group_right' => '', |
|
| 433 | - 'input_group_left_inside' => false, |
|
| 434 | - 'input_group_right_inside' => false, |
|
| 435 | - 'element_require' => '', |
|
| 436 | - 'argument_id' => '', |
|
| 437 | - 'wrap_attributes' => array() |
|
| 438 | - ); |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 442 | - */ |
|
| 443 | - $args = wp_parse_args( $args, $defaults ); |
|
| 444 | - $output = ''; |
|
| 445 | - if ( $args['type'] ) { |
|
| 446 | - |
|
| 447 | - // open |
|
| 448 | - $output .= '<' . sanitize_html_class( $args['type'] ); |
|
| 449 | - |
|
| 450 | - // element require |
|
| 451 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 452 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 453 | - $args['class'] .= " aui-conditional-field"; |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - // argument_id |
|
| 457 | - if ( ! empty( $args['argument_id'] ) ) { |
|
| 458 | - $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"'; |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - // class |
|
| 462 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 463 | - $output .= ' class="' . $class . '" '; |
|
| 464 | - |
|
| 465 | - // Attributes |
|
| 466 | - if ( ! empty( $args['wrap_attributes'] ) ) { |
|
| 467 | - $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] ); |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - // close wrap |
|
| 471 | - $output .= ' >'; |
|
| 472 | - |
|
| 473 | - |
|
| 474 | - // Input group left |
|
| 475 | - if ( ! empty( $args['input_group_left'] ) ) { |
|
| 476 | - $position_class = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 477 | - $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
| 478 | - $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - // content |
|
| 482 | - $output .= $args['content']; |
|
| 483 | - |
|
| 484 | - // Input group right |
|
| 485 | - if ( ! empty( $args['input_group_right'] ) ) { |
|
| 486 | - $position_class = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 487 | - $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
| 488 | - $output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - |
|
| 492 | - // close wrap |
|
| 493 | - $output .= '</' . sanitize_html_class( $args['type'] ) . '>'; |
|
| 494 | - |
|
| 495 | - |
|
| 496 | - } else { |
|
| 497 | - $output = $args['content']; |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - return $output; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * Build the component. |
|
| 505 | - * |
|
| 506 | - * @param array $args |
|
| 507 | - * |
|
| 508 | - * @return string The rendered component. |
|
| 509 | - */ |
|
| 510 | - public static function textarea( $args = array() ) { |
|
| 511 | - $defaults = array( |
|
| 512 | - 'name' => '', |
|
| 513 | - 'class' => '', |
|
| 514 | - 'wrap_class' => '', |
|
| 515 | - 'id' => '', |
|
| 516 | - 'placeholder' => '', |
|
| 517 | - 'title' => '', |
|
| 518 | - 'value' => '', |
|
| 519 | - 'required' => false, |
|
| 520 | - 'label' => '', |
|
| 521 | - 'label_after' => false, |
|
| 522 | - 'label_class' => '', |
|
| 523 | - 'label_type' => '', |
|
| 524 | - 'label_col' => '', |
|
| 525 | - // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 526 | - 'input_group_right' => '', |
|
| 527 | - 'input_group_left' => '', |
|
| 528 | - 'input_group_right_inside' => false, |
|
| 529 | - 'help_text' => '', |
|
| 530 | - 'validation_text' => '', |
|
| 531 | - 'validation_pattern' => '', |
|
| 532 | - 'no_wrap' => false, |
|
| 533 | - 'rows' => '', |
|
| 534 | - 'wysiwyg' => false, |
|
| 535 | - 'allow_tags' => false, |
|
| 536 | - // Allow HTML tags |
|
| 537 | - 'element_require' => '', |
|
| 538 | - // [%element_id%] == "1" |
|
| 539 | - 'extra_attributes' => array(), |
|
| 540 | - // an array of extra attributes |
|
| 541 | - 'wrap_attributes' => array(), |
|
| 542 | - ); |
|
| 543 | - |
|
| 544 | - /** |
|
| 545 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 546 | - */ |
|
| 547 | - $args = wp_parse_args( $args, $defaults ); |
|
| 548 | - $output = ''; |
|
| 549 | - |
|
| 550 | - // hidden label option needs to be empty |
|
| 551 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 552 | - |
|
| 553 | - // floating labels don't work with wysiwyg so set it as top |
|
| 554 | - if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) { |
|
| 555 | - $args['label_type'] = 'top'; |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - $label_after = $args['label_after']; |
|
| 559 | - |
|
| 560 | - // floating labels need label after |
|
| 561 | - if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) { |
|
| 562 | - $label_after = true; |
|
| 563 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - // label |
|
| 567 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 568 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 569 | - $label_args = array( |
|
| 570 | - 'title' => $args['label'], |
|
| 571 | - 'for' => $args['id'], |
|
| 572 | - 'class' => $args['label_class'] . " ", |
|
| 573 | - 'label_type' => $args['label_type'], |
|
| 574 | - 'label_col' => $args['label_col'] |
|
| 575 | - ); |
|
| 576 | - $output .= self::label( $label_args ); |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - // maybe horizontal label |
|
| 580 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 581 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 582 | - $output .= '<div class="' . $input_col . '">'; |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - if ( ! empty( $args['wysiwyg'] ) ) { |
|
| 586 | - ob_start(); |
|
| 587 | - $content = $args['value']; |
|
| 588 | - $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor'; |
|
| 589 | - $settings = array( |
|
| 590 | - 'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4, |
|
| 591 | - 'quicktags' => false, |
|
| 592 | - 'media_buttons' => false, |
|
| 593 | - 'editor_class' => 'form-control', |
|
| 594 | - 'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ), |
|
| 595 | - 'teeny' => true, |
|
| 596 | - ); |
|
| 597 | - |
|
| 598 | - // maybe set settings if array |
|
| 599 | - if ( is_array( $args['wysiwyg'] ) ) { |
|
| 600 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - wp_editor( $content, $editor_id, $settings ); |
|
| 604 | - $output .= ob_get_clean(); |
|
| 605 | - } else { |
|
| 606 | - |
|
| 607 | - // open |
|
| 608 | - $output .= '<textarea '; |
|
| 609 | - |
|
| 610 | - // name |
|
| 611 | - if ( ! empty( $args['name'] ) ) { |
|
| 612 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - // id |
|
| 616 | - if ( ! empty( $args['id'] ) ) { |
|
| 617 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - // placeholder |
|
| 621 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 622 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 623 | - } |
|
| 624 | - |
|
| 625 | - // title |
|
| 626 | - if ( ! empty( $args['title'] ) ) { |
|
| 627 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - // validation text |
|
| 631 | - if ( ! empty( $args['validation_text'] ) ) { |
|
| 632 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
| 633 | - $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - // validation_pattern |
|
| 637 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 638 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - // required |
|
| 642 | - if ( ! empty( $args['required'] ) ) { |
|
| 643 | - $output .= ' required '; |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - // rows |
|
| 647 | - if ( ! empty( $args['rows'] ) ) { |
|
| 648 | - $output .= ' rows="' . absint( $args['rows'] ) . '" '; |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - |
|
| 652 | - // class |
|
| 653 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 654 | - $output .= ' class="form-control ' . $class . '" '; |
|
| 655 | - |
|
| 656 | - // extra attributes |
|
| 657 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 658 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - // close tag |
|
| 662 | - $output .= ' >'; |
|
| 663 | - |
|
| 664 | - // value |
|
| 665 | - if ( ! empty( $args['value'] ) ) { |
|
| 666 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
| 667 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
| 668 | - } else { |
|
| 669 | - $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] ); |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - // closing tag |
|
| 674 | - $output .= '</textarea>'; |
|
| 675 | - |
|
| 676 | - |
|
| 677 | - // input group wraps |
|
| 678 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 679 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 680 | - if ( $args['input_group_left'] ) { |
|
| 681 | - $output = self::wrap( array( |
|
| 682 | - 'content' => $output, |
|
| 683 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 684 | - 'input_group_left' => $args['input_group_left'], |
|
| 685 | - 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 686 | - ) ); |
|
| 687 | - } |
|
| 688 | - if ( $args['input_group_right'] ) { |
|
| 689 | - $output = self::wrap( array( |
|
| 690 | - 'content' => $output, |
|
| 691 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 692 | - 'input_group_right' => $args['input_group_right'], |
|
| 693 | - 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 694 | - ) ); |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - if ( ! empty( $args['label'] ) && $label_after ) { |
|
| 703 | - $label_args = array( |
|
| 704 | - 'title' => $args['label'], |
|
| 705 | - 'for' => $args['id'], |
|
| 706 | - 'class' => $args['label_class'] . " ", |
|
| 707 | - 'label_type' => $args['label_type'], |
|
| 708 | - 'label_col' => $args['label_col'] |
|
| 709 | - ); |
|
| 710 | - $output .= self::label( $label_args ); |
|
| 711 | - } |
|
| 712 | - |
|
| 713 | - // help text |
|
| 714 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 715 | - $output .= AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - // maybe horizontal label |
|
| 719 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 720 | - $output .= '</div>'; |
|
| 721 | - } |
|
| 722 | - |
|
| 723 | - |
|
| 724 | - // wrap |
|
| 725 | - if ( ! $args['no_wrap'] ) { |
|
| 726 | - $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group'; |
|
| 727 | - $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 728 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 729 | - $output = self::wrap( array( |
|
| 730 | - 'content' => $output, |
|
| 731 | - 'class' => $wrap_class, |
|
| 732 | - 'element_require' => $args['element_require'], |
|
| 733 | - 'argument_id' => $args['id'], |
|
| 734 | - 'wrap_attributes' => $args['wrap_attributes'], |
|
| 735 | - ) ); |
|
| 736 | - } |
|
| 737 | - |
|
| 738 | - |
|
| 739 | - return $output; |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - /** |
|
| 743 | - * Build the component. |
|
| 744 | - * |
|
| 745 | - * @param array $args |
|
| 746 | - * |
|
| 747 | - * @return string The rendered component. |
|
| 748 | - */ |
|
| 749 | - public static function select( $args = array() ) { |
|
| 750 | - $defaults = array( |
|
| 751 | - 'class' => '', |
|
| 752 | - 'wrap_class' => '', |
|
| 753 | - 'id' => '', |
|
| 754 | - 'title' => '', |
|
| 755 | - 'value' => '', |
|
| 756 | - // can be an array or a string |
|
| 757 | - 'required' => false, |
|
| 758 | - 'label' => '', |
|
| 759 | - 'label_after' => false, |
|
| 760 | - 'label_type' => '', |
|
| 761 | - 'label_col' => '', |
|
| 762 | - // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 763 | - 'label_class' => '', |
|
| 764 | - 'help_text' => '', |
|
| 765 | - 'placeholder' => '', |
|
| 766 | - 'options' => array(), |
|
| 767 | - // array or string |
|
| 768 | - 'icon' => '', |
|
| 769 | - 'multiple' => false, |
|
| 770 | - 'select2' => false, |
|
| 771 | - 'no_wrap' => false, |
|
| 772 | - 'input_group_right' => '', |
|
| 773 | - 'input_group_left' => '', |
|
| 774 | - 'input_group_right_inside' => false, // forces the input group inside the input |
|
| 775 | - 'input_group_left_inside' => false, // forces the input group inside the input |
|
| 776 | - 'element_require' => '', |
|
| 777 | - // [%element_id%] == "1" |
|
| 778 | - 'extra_attributes' => array(), |
|
| 779 | - // an array of extra attributes |
|
| 780 | - 'wrap_attributes' => array(), |
|
| 781 | - ); |
|
| 782 | - |
|
| 783 | - /** |
|
| 784 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 785 | - */ |
|
| 786 | - $args = wp_parse_args( $args, $defaults ); |
|
| 787 | - $output = ''; |
|
| 788 | - |
|
| 789 | - // for now lets hide floating labels |
|
| 790 | - if ( $args['label_type'] == 'floating' ) { |
|
| 791 | - $args['label_type'] = 'hidden'; |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - // hidden label option needs to be empty |
|
| 795 | - $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 796 | - |
|
| 797 | - |
|
| 798 | - $label_after = $args['label_after']; |
|
| 799 | - |
|
| 800 | - // floating labels need label after |
|
| 801 | - if ( $args['label_type'] == 'floating' ) { |
|
| 802 | - $label_after = true; |
|
| 803 | - $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - // Maybe setup select2 |
|
| 807 | - $is_select2 = false; |
|
| 808 | - if ( ! empty( $args['select2'] ) ) { |
|
| 809 | - $args['class'] .= ' aui-select2'; |
|
| 810 | - $is_select2 = true; |
|
| 811 | - } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) { |
|
| 812 | - $is_select2 = true; |
|
| 813 | - } |
|
| 814 | - |
|
| 815 | - // select2 tags |
|
| 816 | - if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason |
|
| 817 | - $args['data-tags'] = 'true'; |
|
| 818 | - $args['data-token-separators'] = "[',']"; |
|
| 819 | - $args['multiple'] = true; |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - // select2 placeholder |
|
| 823 | - if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) { |
|
| 824 | - $args['data-placeholder'] = esc_attr( $args['placeholder'] ); |
|
| 825 | - $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true; |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - // Set hidden input to save empty value for multiselect. |
|
| 829 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
| 830 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>'; |
|
| 831 | - } |
|
| 832 | - |
|
| 833 | - // open/type |
|
| 834 | - $output .= '<select '; |
|
| 835 | - |
|
| 836 | - // style |
|
| 837 | - if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
| 838 | - $output .= " style='width:100%;' "; |
|
| 839 | - } |
|
| 840 | - |
|
| 841 | - // element require |
|
| 842 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 843 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 844 | - $args['class'] .= " aui-conditional-field"; |
|
| 845 | - } |
|
| 846 | - |
|
| 847 | - // class |
|
| 848 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 849 | - $output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class ); |
|
| 850 | - |
|
| 851 | - // name |
|
| 852 | - if ( ! empty( $args['name'] ) ) { |
|
| 853 | - $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] ); |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - // id |
|
| 857 | - if ( ! empty( $args['id'] ) ) { |
|
| 858 | - $output .= AUI_Component_Helper::id( $args['id'] ); |
|
| 859 | - } |
|
| 860 | - |
|
| 861 | - // title |
|
| 862 | - if ( ! empty( $args['title'] ) ) { |
|
| 863 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 864 | - } |
|
| 865 | - |
|
| 866 | - // data-attributes |
|
| 867 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 868 | - |
|
| 869 | - // aria-attributes |
|
| 870 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 871 | - |
|
| 872 | - // extra attributes |
|
| 873 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 874 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 875 | - } |
|
| 876 | - |
|
| 877 | - // required |
|
| 878 | - if ( ! empty( $args['required'] ) ) { |
|
| 879 | - $output .= ' required '; |
|
| 880 | - } |
|
| 881 | - |
|
| 882 | - // multiple |
|
| 883 | - if ( ! empty( $args['multiple'] ) ) { |
|
| 884 | - $output .= ' multiple '; |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - // close opening tag |
|
| 888 | - $output .= ' >'; |
|
| 889 | - |
|
| 890 | - // placeholder |
|
| 891 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) { |
|
| 892 | - $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>'; |
|
| 893 | - } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) { |
|
| 894 | - $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
|
| 895 | - } |
|
| 896 | - |
|
| 897 | - // Options |
|
| 898 | - if ( ! empty( $args['options'] ) ) { |
|
| 899 | - |
|
| 900 | - if ( ! is_array( $args['options'] ) ) { |
|
| 901 | - $output .= $args['options']; // not the preferred way but an option |
|
| 902 | - } else { |
|
| 903 | - foreach ( $args['options'] as $val => $name ) { |
|
| 904 | - $selected = ''; |
|
| 905 | - if ( is_array( $name ) ) { |
|
| 906 | - if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) { |
|
| 907 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 908 | - |
|
| 909 | - $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>'; |
|
| 910 | - } else { |
|
| 911 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 912 | - $option_value = isset( $name['value'] ) ? $name['value'] : ''; |
|
| 913 | - $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : ''; |
|
| 914 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) { |
|
| 915 | - $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : ""; |
|
| 916 | - } elseif ( ! empty( $args['value'] ) ) { |
|
| 917 | - $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false ); |
|
| 918 | - } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) { |
|
| 919 | - $selected = selected( $option_value, $args['value'], false ); |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>'; |
|
| 923 | - } |
|
| 924 | - } else { |
|
| 925 | - if ( ! empty( $args['value'] ) ) { |
|
| 926 | - if ( is_array( $args['value'] ) ) { |
|
| 927 | - $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : ''; |
|
| 928 | - } elseif ( ! empty( $args['value'] ) ) { |
|
| 929 | - $selected = selected( $args['value'], $val, false ); |
|
| 930 | - } |
|
| 931 | - } elseif ( $args['value'] === $val ) { |
|
| 932 | - $selected = selected( $args['value'], $val, false ); |
|
| 933 | - } |
|
| 934 | - $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
| 935 | - } |
|
| 936 | - } |
|
| 937 | - } |
|
| 938 | - |
|
| 939 | - } |
|
| 940 | - |
|
| 941 | - // closing tag |
|
| 942 | - $output .= '</select>'; |
|
| 943 | - |
|
| 944 | - $label = ''; |
|
| 945 | - $help_text = ''; |
|
| 946 | - // label |
|
| 947 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 948 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 949 | - $label_args = array( |
|
| 950 | - 'title' => $args['label'], |
|
| 951 | - 'for' => $args['id'], |
|
| 952 | - 'class' => $args['label_class'] . " ", |
|
| 953 | - 'label_type' => $args['label_type'], |
|
| 954 | - 'label_col' => $args['label_col'] |
|
| 955 | - ); |
|
| 956 | - $label = self::label( $label_args ); |
|
| 957 | - } |
|
| 958 | - |
|
| 959 | - // help text |
|
| 960 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 961 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 962 | - } |
|
| 963 | - |
|
| 964 | - // input group wraps |
|
| 965 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 966 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 967 | - if ( $args['input_group_left'] ) { |
|
| 968 | - $output = self::wrap( array( |
|
| 969 | - 'content' => $output, |
|
| 970 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 971 | - 'input_group_left' => $args['input_group_left'], |
|
| 972 | - 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 973 | - ) ); |
|
| 974 | - } |
|
| 975 | - if ( $args['input_group_right'] ) { |
|
| 976 | - $output = self::wrap( array( |
|
| 977 | - 'content' => $output, |
|
| 978 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 979 | - 'input_group_right' => $args['input_group_right'], |
|
| 980 | - 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 981 | - ) ); |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - } |
|
| 985 | - |
|
| 986 | - if ( ! $label_after ) { |
|
| 987 | - $output .= $help_text; |
|
| 988 | - } |
|
| 989 | - |
|
| 990 | - |
|
| 991 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 992 | - $output = self::wrap( array( |
|
| 993 | - 'content' => $output, |
|
| 994 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 995 | - ) ); |
|
| 996 | - } |
|
| 997 | - |
|
| 998 | - if ( ! $label_after ) { |
|
| 999 | - $output = $label . $output; |
|
| 1000 | - } |
|
| 1001 | - |
|
| 1002 | - // maybe horizontal label |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + // input group wraps |
|
| 300 | + if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 301 | + $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 302 | + $group_size = $size == 'lg' ? ' input-group-lg' : ''; |
|
| 303 | + $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size; |
|
| 304 | + |
|
| 305 | + if ( $args['input_group_left'] ) { |
|
| 306 | + $output = self::wrap( array( |
|
| 307 | + 'content' => $output, |
|
| 308 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
|
| 309 | + 'input_group_left' => $args['input_group_left'], |
|
| 310 | + 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 311 | + ) ); |
|
| 312 | + } |
|
| 313 | + if ( $args['input_group_right'] ) { |
|
| 314 | + $output = self::wrap( array( |
|
| 315 | + 'content' => $output, |
|
| 316 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
|
| 317 | + 'input_group_right' => $args['input_group_right'], |
|
| 318 | + 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 319 | + ) ); |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + if ( ! $label_after ) { |
|
| 325 | + $output .= $help_text; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + |
|
| 329 | + if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 330 | + $output = self::wrap( array( |
|
| 331 | + 'content' => $output, |
|
| 332 | + 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 333 | + ) ); |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + if ( ! $label_after ) { |
|
| 337 | + $output = $label . $output; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + // wrap |
|
| 341 | + if ( ! $args['no_wrap'] ) { |
|
| 342 | + $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
| 343 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 344 | + $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 345 | + $output = self::wrap( array( |
|
| 346 | + 'content' => $output, |
|
| 347 | + 'class' => $wrap_class, |
|
| 348 | + 'element_require' => $args['element_require'], |
|
| 349 | + 'argument_id' => $args['id'], |
|
| 350 | + 'wrap_attributes' => $args['wrap_attributes'], |
|
| 351 | + ) ); |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + return $output; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + public static function label( $args = array(), $type = '' ) { |
|
| 359 | + //<label for="exampleInputEmail1">Email address</label> |
|
| 360 | + $defaults = array( |
|
| 361 | + 'title' => 'div', |
|
| 362 | + 'for' => '', |
|
| 363 | + 'class' => '', |
|
| 364 | + 'label_type' => '', // empty = hidden, top, horizontal |
|
| 365 | + 'label_col' => '', |
|
| 366 | + ); |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 370 | + */ |
|
| 371 | + $args = wp_parse_args( $args, $defaults ); |
|
| 372 | + $output = ''; |
|
| 373 | + |
|
| 374 | + if ( $args['title'] ) { |
|
| 375 | + |
|
| 376 | + // maybe hide labels //@todo set a global option for visibility class |
|
| 377 | + if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) { |
|
| 378 | + $class = $args['class']; |
|
| 379 | + } else { |
|
| 380 | + $class = 'sr-only ' . $args['class']; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + // maybe horizontal |
|
| 384 | + if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 385 | + $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label'; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + // open |
|
| 389 | + $output .= '<label '; |
|
| 390 | + |
|
| 391 | + // for |
|
| 392 | + if ( ! empty( $args['for'] ) ) { |
|
| 393 | + $output .= ' for="' . esc_attr( $args['for'] ) . '" '; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + // class |
|
| 397 | + $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
| 398 | + $output .= ' class="' . $class . '" '; |
|
| 399 | + |
|
| 400 | + // close |
|
| 401 | + $output .= '>'; |
|
| 402 | + |
|
| 403 | + |
|
| 404 | + // title, don't escape fully as can contain html |
|
| 405 | + if ( ! empty( $args['title'] ) ) { |
|
| 406 | + $output .= wp_kses_post( $args['title'] ); |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + // close wrap |
|
| 410 | + $output .= '</label>'; |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + |
|
| 416 | + return $output; |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + /** |
|
| 420 | + * Wrap some content in a HTML wrapper. |
|
| 421 | + * |
|
| 422 | + * @param array $args |
|
| 423 | + * |
|
| 424 | + * @return string |
|
| 425 | + */ |
|
| 426 | + public static function wrap( $args = array() ) { |
|
| 427 | + $defaults = array( |
|
| 428 | + 'type' => 'div', |
|
| 429 | + 'class' => 'form-group', |
|
| 430 | + 'content' => '', |
|
| 431 | + 'input_group_left' => '', |
|
| 432 | + 'input_group_right' => '', |
|
| 433 | + 'input_group_left_inside' => false, |
|
| 434 | + 'input_group_right_inside' => false, |
|
| 435 | + 'element_require' => '', |
|
| 436 | + 'argument_id' => '', |
|
| 437 | + 'wrap_attributes' => array() |
|
| 438 | + ); |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 442 | + */ |
|
| 443 | + $args = wp_parse_args( $args, $defaults ); |
|
| 444 | + $output = ''; |
|
| 445 | + if ( $args['type'] ) { |
|
| 446 | + |
|
| 447 | + // open |
|
| 448 | + $output .= '<' . sanitize_html_class( $args['type'] ); |
|
| 449 | + |
|
| 450 | + // element require |
|
| 451 | + if ( ! empty( $args['element_require'] ) ) { |
|
| 452 | + $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 453 | + $args['class'] .= " aui-conditional-field"; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + // argument_id |
|
| 457 | + if ( ! empty( $args['argument_id'] ) ) { |
|
| 458 | + $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"'; |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + // class |
|
| 462 | + $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 463 | + $output .= ' class="' . $class . '" '; |
|
| 464 | + |
|
| 465 | + // Attributes |
|
| 466 | + if ( ! empty( $args['wrap_attributes'] ) ) { |
|
| 467 | + $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] ); |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + // close wrap |
|
| 471 | + $output .= ' >'; |
|
| 472 | + |
|
| 473 | + |
|
| 474 | + // Input group left |
|
| 475 | + if ( ! empty( $args['input_group_left'] ) ) { |
|
| 476 | + $position_class = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 477 | + $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
| 478 | + $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + // content |
|
| 482 | + $output .= $args['content']; |
|
| 483 | + |
|
| 484 | + // Input group right |
|
| 485 | + if ( ! empty( $args['input_group_right'] ) ) { |
|
| 486 | + $position_class = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 487 | + $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
| 488 | + $output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + |
|
| 492 | + // close wrap |
|
| 493 | + $output .= '</' . sanitize_html_class( $args['type'] ) . '>'; |
|
| 494 | + |
|
| 495 | + |
|
| 496 | + } else { |
|
| 497 | + $output = $args['content']; |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + return $output; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * Build the component. |
|
| 505 | + * |
|
| 506 | + * @param array $args |
|
| 507 | + * |
|
| 508 | + * @return string The rendered component. |
|
| 509 | + */ |
|
| 510 | + public static function textarea( $args = array() ) { |
|
| 511 | + $defaults = array( |
|
| 512 | + 'name' => '', |
|
| 513 | + 'class' => '', |
|
| 514 | + 'wrap_class' => '', |
|
| 515 | + 'id' => '', |
|
| 516 | + 'placeholder' => '', |
|
| 517 | + 'title' => '', |
|
| 518 | + 'value' => '', |
|
| 519 | + 'required' => false, |
|
| 520 | + 'label' => '', |
|
| 521 | + 'label_after' => false, |
|
| 522 | + 'label_class' => '', |
|
| 523 | + 'label_type' => '', |
|
| 524 | + 'label_col' => '', |
|
| 525 | + // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 526 | + 'input_group_right' => '', |
|
| 527 | + 'input_group_left' => '', |
|
| 528 | + 'input_group_right_inside' => false, |
|
| 529 | + 'help_text' => '', |
|
| 530 | + 'validation_text' => '', |
|
| 531 | + 'validation_pattern' => '', |
|
| 532 | + 'no_wrap' => false, |
|
| 533 | + 'rows' => '', |
|
| 534 | + 'wysiwyg' => false, |
|
| 535 | + 'allow_tags' => false, |
|
| 536 | + // Allow HTML tags |
|
| 537 | + 'element_require' => '', |
|
| 538 | + // [%element_id%] == "1" |
|
| 539 | + 'extra_attributes' => array(), |
|
| 540 | + // an array of extra attributes |
|
| 541 | + 'wrap_attributes' => array(), |
|
| 542 | + ); |
|
| 543 | + |
|
| 544 | + /** |
|
| 545 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 546 | + */ |
|
| 547 | + $args = wp_parse_args( $args, $defaults ); |
|
| 548 | + $output = ''; |
|
| 549 | + |
|
| 550 | + // hidden label option needs to be empty |
|
| 551 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 552 | + |
|
| 553 | + // floating labels don't work with wysiwyg so set it as top |
|
| 554 | + if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) { |
|
| 555 | + $args['label_type'] = 'top'; |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + $label_after = $args['label_after']; |
|
| 559 | + |
|
| 560 | + // floating labels need label after |
|
| 561 | + if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) { |
|
| 562 | + $label_after = true; |
|
| 563 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + // label |
|
| 567 | + if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 568 | + } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 569 | + $label_args = array( |
|
| 570 | + 'title' => $args['label'], |
|
| 571 | + 'for' => $args['id'], |
|
| 572 | + 'class' => $args['label_class'] . " ", |
|
| 573 | + 'label_type' => $args['label_type'], |
|
| 574 | + 'label_col' => $args['label_col'] |
|
| 575 | + ); |
|
| 576 | + $output .= self::label( $label_args ); |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + // maybe horizontal label |
|
| 580 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 581 | + $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 582 | + $output .= '<div class="' . $input_col . '">'; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + if ( ! empty( $args['wysiwyg'] ) ) { |
|
| 586 | + ob_start(); |
|
| 587 | + $content = $args['value']; |
|
| 588 | + $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor'; |
|
| 589 | + $settings = array( |
|
| 590 | + 'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4, |
|
| 591 | + 'quicktags' => false, |
|
| 592 | + 'media_buttons' => false, |
|
| 593 | + 'editor_class' => 'form-control', |
|
| 594 | + 'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ), |
|
| 595 | + 'teeny' => true, |
|
| 596 | + ); |
|
| 597 | + |
|
| 598 | + // maybe set settings if array |
|
| 599 | + if ( is_array( $args['wysiwyg'] ) ) { |
|
| 600 | + $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + wp_editor( $content, $editor_id, $settings ); |
|
| 604 | + $output .= ob_get_clean(); |
|
| 605 | + } else { |
|
| 606 | + |
|
| 607 | + // open |
|
| 608 | + $output .= '<textarea '; |
|
| 609 | + |
|
| 610 | + // name |
|
| 611 | + if ( ! empty( $args['name'] ) ) { |
|
| 612 | + $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + // id |
|
| 616 | + if ( ! empty( $args['id'] ) ) { |
|
| 617 | + $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + // placeholder |
|
| 621 | + if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 622 | + $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 623 | + } |
|
| 624 | + |
|
| 625 | + // title |
|
| 626 | + if ( ! empty( $args['title'] ) ) { |
|
| 627 | + $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + // validation text |
|
| 631 | + if ( ! empty( $args['validation_text'] ) ) { |
|
| 632 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
| 633 | + $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + // validation_pattern |
|
| 637 | + if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 638 | + $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + // required |
|
| 642 | + if ( ! empty( $args['required'] ) ) { |
|
| 643 | + $output .= ' required '; |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + // rows |
|
| 647 | + if ( ! empty( $args['rows'] ) ) { |
|
| 648 | + $output .= ' rows="' . absint( $args['rows'] ) . '" '; |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + |
|
| 652 | + // class |
|
| 653 | + $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 654 | + $output .= ' class="form-control ' . $class . '" '; |
|
| 655 | + |
|
| 656 | + // extra attributes |
|
| 657 | + if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 658 | + $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + // close tag |
|
| 662 | + $output .= ' >'; |
|
| 663 | + |
|
| 664 | + // value |
|
| 665 | + if ( ! empty( $args['value'] ) ) { |
|
| 666 | + if ( ! empty( $args['allow_tags'] ) ) { |
|
| 667 | + $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
| 668 | + } else { |
|
| 669 | + $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] ); |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + // closing tag |
|
| 674 | + $output .= '</textarea>'; |
|
| 675 | + |
|
| 676 | + |
|
| 677 | + // input group wraps |
|
| 678 | + if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 679 | + $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 680 | + if ( $args['input_group_left'] ) { |
|
| 681 | + $output = self::wrap( array( |
|
| 682 | + 'content' => $output, |
|
| 683 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 684 | + 'input_group_left' => $args['input_group_left'], |
|
| 685 | + 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 686 | + ) ); |
|
| 687 | + } |
|
| 688 | + if ( $args['input_group_right'] ) { |
|
| 689 | + $output = self::wrap( array( |
|
| 690 | + 'content' => $output, |
|
| 691 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 692 | + 'input_group_right' => $args['input_group_right'], |
|
| 693 | + 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 694 | + ) ); |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + if ( ! empty( $args['label'] ) && $label_after ) { |
|
| 703 | + $label_args = array( |
|
| 704 | + 'title' => $args['label'], |
|
| 705 | + 'for' => $args['id'], |
|
| 706 | + 'class' => $args['label_class'] . " ", |
|
| 707 | + 'label_type' => $args['label_type'], |
|
| 708 | + 'label_col' => $args['label_col'] |
|
| 709 | + ); |
|
| 710 | + $output .= self::label( $label_args ); |
|
| 711 | + } |
|
| 712 | + |
|
| 713 | + // help text |
|
| 714 | + if ( ! empty( $args['help_text'] ) ) { |
|
| 715 | + $output .= AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 716 | + } |
|
| 717 | + |
|
| 718 | + // maybe horizontal label |
|
| 719 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 720 | + $output .= '</div>'; |
|
| 721 | + } |
|
| 722 | + |
|
| 723 | + |
|
| 724 | + // wrap |
|
| 725 | + if ( ! $args['no_wrap'] ) { |
|
| 726 | + $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group'; |
|
| 727 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
| 728 | + $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 729 | + $output = self::wrap( array( |
|
| 730 | + 'content' => $output, |
|
| 731 | + 'class' => $wrap_class, |
|
| 732 | + 'element_require' => $args['element_require'], |
|
| 733 | + 'argument_id' => $args['id'], |
|
| 734 | + 'wrap_attributes' => $args['wrap_attributes'], |
|
| 735 | + ) ); |
|
| 736 | + } |
|
| 737 | + |
|
| 738 | + |
|
| 739 | + return $output; |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + /** |
|
| 743 | + * Build the component. |
|
| 744 | + * |
|
| 745 | + * @param array $args |
|
| 746 | + * |
|
| 747 | + * @return string The rendered component. |
|
| 748 | + */ |
|
| 749 | + public static function select( $args = array() ) { |
|
| 750 | + $defaults = array( |
|
| 751 | + 'class' => '', |
|
| 752 | + 'wrap_class' => '', |
|
| 753 | + 'id' => '', |
|
| 754 | + 'title' => '', |
|
| 755 | + 'value' => '', |
|
| 756 | + // can be an array or a string |
|
| 757 | + 'required' => false, |
|
| 758 | + 'label' => '', |
|
| 759 | + 'label_after' => false, |
|
| 760 | + 'label_type' => '', |
|
| 761 | + 'label_col' => '', |
|
| 762 | + // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 763 | + 'label_class' => '', |
|
| 764 | + 'help_text' => '', |
|
| 765 | + 'placeholder' => '', |
|
| 766 | + 'options' => array(), |
|
| 767 | + // array or string |
|
| 768 | + 'icon' => '', |
|
| 769 | + 'multiple' => false, |
|
| 770 | + 'select2' => false, |
|
| 771 | + 'no_wrap' => false, |
|
| 772 | + 'input_group_right' => '', |
|
| 773 | + 'input_group_left' => '', |
|
| 774 | + 'input_group_right_inside' => false, // forces the input group inside the input |
|
| 775 | + 'input_group_left_inside' => false, // forces the input group inside the input |
|
| 776 | + 'element_require' => '', |
|
| 777 | + // [%element_id%] == "1" |
|
| 778 | + 'extra_attributes' => array(), |
|
| 779 | + // an array of extra attributes |
|
| 780 | + 'wrap_attributes' => array(), |
|
| 781 | + ); |
|
| 782 | + |
|
| 783 | + /** |
|
| 784 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 785 | + */ |
|
| 786 | + $args = wp_parse_args( $args, $defaults ); |
|
| 787 | + $output = ''; |
|
| 788 | + |
|
| 789 | + // for now lets hide floating labels |
|
| 790 | + if ( $args['label_type'] == 'floating' ) { |
|
| 791 | + $args['label_type'] = 'hidden'; |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + // hidden label option needs to be empty |
|
| 795 | + $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
|
| 796 | + |
|
| 797 | + |
|
| 798 | + $label_after = $args['label_after']; |
|
| 799 | + |
|
| 800 | + // floating labels need label after |
|
| 801 | + if ( $args['label_type'] == 'floating' ) { |
|
| 802 | + $label_after = true; |
|
| 803 | + $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + // Maybe setup select2 |
|
| 807 | + $is_select2 = false; |
|
| 808 | + if ( ! empty( $args['select2'] ) ) { |
|
| 809 | + $args['class'] .= ' aui-select2'; |
|
| 810 | + $is_select2 = true; |
|
| 811 | + } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) { |
|
| 812 | + $is_select2 = true; |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + // select2 tags |
|
| 816 | + if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason |
|
| 817 | + $args['data-tags'] = 'true'; |
|
| 818 | + $args['data-token-separators'] = "[',']"; |
|
| 819 | + $args['multiple'] = true; |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + // select2 placeholder |
|
| 823 | + if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) { |
|
| 824 | + $args['data-placeholder'] = esc_attr( $args['placeholder'] ); |
|
| 825 | + $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true; |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + // Set hidden input to save empty value for multiselect. |
|
| 829 | + if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
| 830 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>'; |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + // open/type |
|
| 834 | + $output .= '<select '; |
|
| 835 | + |
|
| 836 | + // style |
|
| 837 | + if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
| 838 | + $output .= " style='width:100%;' "; |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + // element require |
|
| 842 | + if ( ! empty( $args['element_require'] ) ) { |
|
| 843 | + $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 844 | + $args['class'] .= " aui-conditional-field"; |
|
| 845 | + } |
|
| 846 | + |
|
| 847 | + // class |
|
| 848 | + $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 849 | + $output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class ); |
|
| 850 | + |
|
| 851 | + // name |
|
| 852 | + if ( ! empty( $args['name'] ) ) { |
|
| 853 | + $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] ); |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + // id |
|
| 857 | + if ( ! empty( $args['id'] ) ) { |
|
| 858 | + $output .= AUI_Component_Helper::id( $args['id'] ); |
|
| 859 | + } |
|
| 860 | + |
|
| 861 | + // title |
|
| 862 | + if ( ! empty( $args['title'] ) ) { |
|
| 863 | + $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + // data-attributes |
|
| 867 | + $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 868 | + |
|
| 869 | + // aria-attributes |
|
| 870 | + $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 871 | + |
|
| 872 | + // extra attributes |
|
| 873 | + if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 874 | + $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 875 | + } |
|
| 876 | + |
|
| 877 | + // required |
|
| 878 | + if ( ! empty( $args['required'] ) ) { |
|
| 879 | + $output .= ' required '; |
|
| 880 | + } |
|
| 881 | + |
|
| 882 | + // multiple |
|
| 883 | + if ( ! empty( $args['multiple'] ) ) { |
|
| 884 | + $output .= ' multiple '; |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + // close opening tag |
|
| 888 | + $output .= ' >'; |
|
| 889 | + |
|
| 890 | + // placeholder |
|
| 891 | + if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) { |
|
| 892 | + $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>'; |
|
| 893 | + } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) { |
|
| 894 | + $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
|
| 895 | + } |
|
| 896 | + |
|
| 897 | + // Options |
|
| 898 | + if ( ! empty( $args['options'] ) ) { |
|
| 899 | + |
|
| 900 | + if ( ! is_array( $args['options'] ) ) { |
|
| 901 | + $output .= $args['options']; // not the preferred way but an option |
|
| 902 | + } else { |
|
| 903 | + foreach ( $args['options'] as $val => $name ) { |
|
| 904 | + $selected = ''; |
|
| 905 | + if ( is_array( $name ) ) { |
|
| 906 | + if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) { |
|
| 907 | + $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 908 | + |
|
| 909 | + $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>'; |
|
| 910 | + } else { |
|
| 911 | + $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 912 | + $option_value = isset( $name['value'] ) ? $name['value'] : ''; |
|
| 913 | + $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : ''; |
|
| 914 | + if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) { |
|
| 915 | + $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : ""; |
|
| 916 | + } elseif ( ! empty( $args['value'] ) ) { |
|
| 917 | + $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false ); |
|
| 918 | + } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) { |
|
| 919 | + $selected = selected( $option_value, $args['value'], false ); |
|
| 920 | + } |
|
| 921 | + |
|
| 922 | + $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>'; |
|
| 923 | + } |
|
| 924 | + } else { |
|
| 925 | + if ( ! empty( $args['value'] ) ) { |
|
| 926 | + if ( is_array( $args['value'] ) ) { |
|
| 927 | + $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : ''; |
|
| 928 | + } elseif ( ! empty( $args['value'] ) ) { |
|
| 929 | + $selected = selected( $args['value'], $val, false ); |
|
| 930 | + } |
|
| 931 | + } elseif ( $args['value'] === $val ) { |
|
| 932 | + $selected = selected( $args['value'], $val, false ); |
|
| 933 | + } |
|
| 934 | + $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
| 935 | + } |
|
| 936 | + } |
|
| 937 | + } |
|
| 938 | + |
|
| 939 | + } |
|
| 940 | + |
|
| 941 | + // closing tag |
|
| 942 | + $output .= '</select>'; |
|
| 943 | + |
|
| 944 | + $label = ''; |
|
| 945 | + $help_text = ''; |
|
| 946 | + // label |
|
| 947 | + if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 948 | + } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 949 | + $label_args = array( |
|
| 950 | + 'title' => $args['label'], |
|
| 951 | + 'for' => $args['id'], |
|
| 952 | + 'class' => $args['label_class'] . " ", |
|
| 953 | + 'label_type' => $args['label_type'], |
|
| 954 | + 'label_col' => $args['label_col'] |
|
| 955 | + ); |
|
| 956 | + $label = self::label( $label_args ); |
|
| 957 | + } |
|
| 958 | + |
|
| 959 | + // help text |
|
| 960 | + if ( ! empty( $args['help_text'] ) ) { |
|
| 961 | + $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + // input group wraps |
|
| 965 | + if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 966 | + $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 967 | + if ( $args['input_group_left'] ) { |
|
| 968 | + $output = self::wrap( array( |
|
| 969 | + 'content' => $output, |
|
| 970 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 971 | + 'input_group_left' => $args['input_group_left'], |
|
| 972 | + 'input_group_left_inside' => $args['input_group_left_inside'] |
|
| 973 | + ) ); |
|
| 974 | + } |
|
| 975 | + if ( $args['input_group_right'] ) { |
|
| 976 | + $output = self::wrap( array( |
|
| 977 | + 'content' => $output, |
|
| 978 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
| 979 | + 'input_group_right' => $args['input_group_right'], |
|
| 980 | + 'input_group_right_inside' => $args['input_group_right_inside'] |
|
| 981 | + ) ); |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + } |
|
| 985 | + |
|
| 986 | + if ( ! $label_after ) { |
|
| 987 | + $output .= $help_text; |
|
| 988 | + } |
|
| 989 | + |
|
| 990 | + |
|
| 991 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 992 | + $output = self::wrap( array( |
|
| 993 | + 'content' => $output, |
|
| 994 | + 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 995 | + ) ); |
|
| 996 | + } |
|
| 997 | + |
|
| 998 | + if ( ! $label_after ) { |
|
| 999 | + $output = $label . $output; |
|
| 1000 | + } |
|
| 1001 | + |
|
| 1002 | + // maybe horizontal label |
|
| 1003 | 1003 | // if ( $args['label_type'] == 'horizontal' ) { |
| 1004 | 1004 | // $output .= '</div>'; |
| 1005 | 1005 | // } |
| 1006 | 1006 | |
| 1007 | 1007 | |
| 1008 | - // wrap |
|
| 1009 | - if ( ! $args['no_wrap'] ) { |
|
| 1010 | - $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
| 1011 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1012 | - $output = self::wrap( array( |
|
| 1013 | - 'content' => $output, |
|
| 1014 | - 'class' => $wrap_class, |
|
| 1015 | - 'element_require' => $args['element_require'], |
|
| 1016 | - 'argument_id' => $args['id'], |
|
| 1017 | - 'wrap_attributes' => $args['wrap_attributes'], |
|
| 1018 | - ) ); |
|
| 1019 | - } |
|
| 1020 | - |
|
| 1021 | - |
|
| 1022 | - return $output; |
|
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - /** |
|
| 1026 | - * Build the component. |
|
| 1027 | - * |
|
| 1028 | - * @param array $args |
|
| 1029 | - * |
|
| 1030 | - * @return string The rendered component. |
|
| 1031 | - */ |
|
| 1032 | - public static function radio( $args = array() ) { |
|
| 1033 | - $defaults = array( |
|
| 1034 | - 'class' => '', |
|
| 1035 | - 'wrap_class' => '', |
|
| 1036 | - 'id' => '', |
|
| 1037 | - 'title' => '', |
|
| 1038 | - 'horizontal' => false, |
|
| 1039 | - // sets the lable horizontal |
|
| 1040 | - 'value' => '', |
|
| 1041 | - 'label' => '', |
|
| 1042 | - 'label_class' => '', |
|
| 1043 | - 'label_type' => '', |
|
| 1044 | - 'label_col' => '', |
|
| 1045 | - // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 1046 | - 'help_text' => '', |
|
| 1047 | - 'inline' => true, |
|
| 1048 | - 'required' => false, |
|
| 1049 | - 'options' => array(), |
|
| 1050 | - 'icon' => '', |
|
| 1051 | - 'no_wrap' => false, |
|
| 1052 | - 'element_require' => '', |
|
| 1053 | - // [%element_id%] == "1" |
|
| 1054 | - 'extra_attributes' => array(), |
|
| 1055 | - // an array of extra attributes |
|
| 1056 | - 'wrap_attributes' => array() |
|
| 1057 | - ); |
|
| 1058 | - |
|
| 1059 | - /** |
|
| 1060 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 1061 | - */ |
|
| 1062 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1063 | - |
|
| 1064 | - // for now lets use horizontal for floating |
|
| 1065 | - if ( $args['label_type'] == 'floating' ) { |
|
| 1066 | - $args['label_type'] = 'horizontal'; |
|
| 1067 | - } |
|
| 1068 | - |
|
| 1069 | - $label_args = array( |
|
| 1070 | - 'title' => $args['label'], |
|
| 1071 | - 'class' => $args['label_class'] . " pt-0 ", |
|
| 1072 | - 'label_type' => $args['label_type'], |
|
| 1073 | - 'label_col' => $args['label_col'] |
|
| 1074 | - ); |
|
| 1075 | - |
|
| 1076 | - $output = ''; |
|
| 1077 | - |
|
| 1078 | - |
|
| 1079 | - // label before |
|
| 1080 | - if ( ! empty( $args['label'] ) ) { |
|
| 1081 | - $output .= self::label( $label_args, 'radio' ); |
|
| 1082 | - } |
|
| 1083 | - |
|
| 1084 | - // maybe horizontal label |
|
| 1085 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 1086 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 1087 | - $output .= '<div class="' . $input_col . '">'; |
|
| 1088 | - } |
|
| 1089 | - |
|
| 1090 | - if ( ! empty( $args['options'] ) ) { |
|
| 1091 | - $count = 0; |
|
| 1092 | - foreach ( $args['options'] as $value => $label ) { |
|
| 1093 | - $option_args = $args; |
|
| 1094 | - $option_args['value'] = $value; |
|
| 1095 | - $option_args['label'] = $label; |
|
| 1096 | - $option_args['checked'] = $value == $args['value'] ? true : false; |
|
| 1097 | - $output .= self::radio_option( $option_args, $count ); |
|
| 1098 | - $count ++; |
|
| 1099 | - } |
|
| 1100 | - } |
|
| 1101 | - |
|
| 1102 | - // help text |
|
| 1103 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
| 1104 | - $output .= $help_text; |
|
| 1105 | - |
|
| 1106 | - // maybe horizontal label |
|
| 1107 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 1108 | - $output .= '</div>'; |
|
| 1109 | - } |
|
| 1110 | - |
|
| 1111 | - // wrap |
|
| 1112 | - $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
| 1113 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1114 | - $output = self::wrap( array( |
|
| 1115 | - 'content' => $output, |
|
| 1116 | - 'class' => $wrap_class, |
|
| 1117 | - 'element_require' => $args['element_require'], |
|
| 1118 | - 'argument_id' => $args['id'], |
|
| 1119 | - 'wrap_attributes' => $args['wrap_attributes'], |
|
| 1120 | - ) ); |
|
| 1121 | - |
|
| 1122 | - |
|
| 1123 | - return $output; |
|
| 1124 | - } |
|
| 1125 | - |
|
| 1126 | - /** |
|
| 1127 | - * Build the component. |
|
| 1128 | - * |
|
| 1129 | - * @param array $args |
|
| 1130 | - * |
|
| 1131 | - * @return string The rendered component. |
|
| 1132 | - */ |
|
| 1133 | - public static function radio_option( $args = array(), $count = '' ) { |
|
| 1134 | - $defaults = array( |
|
| 1135 | - 'class' => '', |
|
| 1136 | - 'id' => '', |
|
| 1137 | - 'title' => '', |
|
| 1138 | - 'value' => '', |
|
| 1139 | - 'required' => false, |
|
| 1140 | - 'inline' => true, |
|
| 1141 | - 'label' => '', |
|
| 1142 | - 'options' => array(), |
|
| 1143 | - 'icon' => '', |
|
| 1144 | - 'no_wrap' => false, |
|
| 1145 | - 'extra_attributes' => array() // an array of extra attributes |
|
| 1146 | - ); |
|
| 1147 | - |
|
| 1148 | - /** |
|
| 1149 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 1150 | - */ |
|
| 1151 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1152 | - |
|
| 1153 | - $output = ''; |
|
| 1154 | - |
|
| 1155 | - // open/type |
|
| 1156 | - $output .= '<input type="radio"'; |
|
| 1157 | - |
|
| 1158 | - // class |
|
| 1159 | - $output .= ' class="form-check-input" '; |
|
| 1160 | - |
|
| 1161 | - // name |
|
| 1162 | - if ( ! empty( $args['name'] ) ) { |
|
| 1163 | - $output .= AUI_Component_Helper::name( $args['name'] ); |
|
| 1164 | - } |
|
| 1165 | - |
|
| 1166 | - // id |
|
| 1167 | - if ( ! empty( $args['id'] ) ) { |
|
| 1168 | - $output .= AUI_Component_Helper::id( $args['id'] . $count ); |
|
| 1169 | - } |
|
| 1170 | - |
|
| 1171 | - // title |
|
| 1172 | - if ( ! empty( $args['title'] ) ) { |
|
| 1173 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 1174 | - } |
|
| 1175 | - |
|
| 1176 | - // value |
|
| 1177 | - if ( isset( $args['value'] ) ) { |
|
| 1178 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 1179 | - } |
|
| 1180 | - |
|
| 1181 | - // checked, for radio and checkboxes |
|
| 1182 | - if ( $args['checked'] ) { |
|
| 1183 | - $output .= ' checked '; |
|
| 1184 | - } |
|
| 1185 | - |
|
| 1186 | - // data-attributes |
|
| 1187 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 1188 | - |
|
| 1189 | - // aria-attributes |
|
| 1190 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 1191 | - |
|
| 1192 | - // extra attributes |
|
| 1193 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 1194 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 1195 | - } |
|
| 1196 | - |
|
| 1197 | - // required |
|
| 1198 | - if ( ! empty( $args['required'] ) ) { |
|
| 1199 | - $output .= ' required '; |
|
| 1200 | - } |
|
| 1201 | - |
|
| 1202 | - // close opening tag |
|
| 1203 | - $output .= ' >'; |
|
| 1204 | - |
|
| 1205 | - // label |
|
| 1206 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 1207 | - } elseif ( ! empty( $args['label'] ) ) { |
|
| 1208 | - $output .= self::label( array( |
|
| 1209 | - 'title' => $args['label'], |
|
| 1210 | - 'for' => $args['id'] . $count, |
|
| 1211 | - 'class' => 'form-check-label' |
|
| 1212 | - ), 'radio' ); |
|
| 1213 | - } |
|
| 1214 | - |
|
| 1215 | - // wrap |
|
| 1216 | - if ( ! $args['no_wrap'] ) { |
|
| 1217 | - $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
|
| 1218 | - |
|
| 1219 | - // Unique wrap class |
|
| 1220 | - $uniq_class = 'fwrap'; |
|
| 1221 | - if ( ! empty( $args['name'] ) ) { |
|
| 1222 | - $uniq_class .= '-' . $args['name']; |
|
| 1223 | - } else if ( ! empty( $args['id'] ) ) { |
|
| 1224 | - $uniq_class .= '-' . $args['id']; |
|
| 1225 | - } |
|
| 1226 | - |
|
| 1227 | - if ( isset( $args['value'] ) || $args['value'] !== "" ) { |
|
| 1228 | - $uniq_class .= '-' . $args['value']; |
|
| 1229 | - } else { |
|
| 1230 | - $uniq_class .= '-' . $count; |
|
| 1231 | - } |
|
| 1232 | - $wrap_class .= ' ' . sanitize_html_class( $uniq_class ); |
|
| 1233 | - |
|
| 1234 | - $output = self::wrap( array( |
|
| 1235 | - 'content' => $output, |
|
| 1236 | - 'class' => $wrap_class |
|
| 1237 | - ) ); |
|
| 1238 | - } |
|
| 1239 | - |
|
| 1240 | - return $output; |
|
| 1241 | - } |
|
| 1008 | + // wrap |
|
| 1009 | + if ( ! $args['no_wrap'] ) { |
|
| 1010 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
| 1011 | + $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1012 | + $output = self::wrap( array( |
|
| 1013 | + 'content' => $output, |
|
| 1014 | + 'class' => $wrap_class, |
|
| 1015 | + 'element_require' => $args['element_require'], |
|
| 1016 | + 'argument_id' => $args['id'], |
|
| 1017 | + 'wrap_attributes' => $args['wrap_attributes'], |
|
| 1018 | + ) ); |
|
| 1019 | + } |
|
| 1020 | + |
|
| 1021 | + |
|
| 1022 | + return $output; |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * Build the component. |
|
| 1027 | + * |
|
| 1028 | + * @param array $args |
|
| 1029 | + * |
|
| 1030 | + * @return string The rendered component. |
|
| 1031 | + */ |
|
| 1032 | + public static function radio( $args = array() ) { |
|
| 1033 | + $defaults = array( |
|
| 1034 | + 'class' => '', |
|
| 1035 | + 'wrap_class' => '', |
|
| 1036 | + 'id' => '', |
|
| 1037 | + 'title' => '', |
|
| 1038 | + 'horizontal' => false, |
|
| 1039 | + // sets the lable horizontal |
|
| 1040 | + 'value' => '', |
|
| 1041 | + 'label' => '', |
|
| 1042 | + 'label_class' => '', |
|
| 1043 | + 'label_type' => '', |
|
| 1044 | + 'label_col' => '', |
|
| 1045 | + // sets the label type, default: hidden. Options: hidden, top, horizontal, floating |
|
| 1046 | + 'help_text' => '', |
|
| 1047 | + 'inline' => true, |
|
| 1048 | + 'required' => false, |
|
| 1049 | + 'options' => array(), |
|
| 1050 | + 'icon' => '', |
|
| 1051 | + 'no_wrap' => false, |
|
| 1052 | + 'element_require' => '', |
|
| 1053 | + // [%element_id%] == "1" |
|
| 1054 | + 'extra_attributes' => array(), |
|
| 1055 | + // an array of extra attributes |
|
| 1056 | + 'wrap_attributes' => array() |
|
| 1057 | + ); |
|
| 1058 | + |
|
| 1059 | + /** |
|
| 1060 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 1061 | + */ |
|
| 1062 | + $args = wp_parse_args( $args, $defaults ); |
|
| 1063 | + |
|
| 1064 | + // for now lets use horizontal for floating |
|
| 1065 | + if ( $args['label_type'] == 'floating' ) { |
|
| 1066 | + $args['label_type'] = 'horizontal'; |
|
| 1067 | + } |
|
| 1068 | + |
|
| 1069 | + $label_args = array( |
|
| 1070 | + 'title' => $args['label'], |
|
| 1071 | + 'class' => $args['label_class'] . " pt-0 ", |
|
| 1072 | + 'label_type' => $args['label_type'], |
|
| 1073 | + 'label_col' => $args['label_col'] |
|
| 1074 | + ); |
|
| 1075 | + |
|
| 1076 | + $output = ''; |
|
| 1077 | + |
|
| 1078 | + |
|
| 1079 | + // label before |
|
| 1080 | + if ( ! empty( $args['label'] ) ) { |
|
| 1081 | + $output .= self::label( $label_args, 'radio' ); |
|
| 1082 | + } |
|
| 1083 | + |
|
| 1084 | + // maybe horizontal label |
|
| 1085 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 1086 | + $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 1087 | + $output .= '<div class="' . $input_col . '">'; |
|
| 1088 | + } |
|
| 1089 | + |
|
| 1090 | + if ( ! empty( $args['options'] ) ) { |
|
| 1091 | + $count = 0; |
|
| 1092 | + foreach ( $args['options'] as $value => $label ) { |
|
| 1093 | + $option_args = $args; |
|
| 1094 | + $option_args['value'] = $value; |
|
| 1095 | + $option_args['label'] = $label; |
|
| 1096 | + $option_args['checked'] = $value == $args['value'] ? true : false; |
|
| 1097 | + $output .= self::radio_option( $option_args, $count ); |
|
| 1098 | + $count ++; |
|
| 1099 | + } |
|
| 1100 | + } |
|
| 1101 | + |
|
| 1102 | + // help text |
|
| 1103 | + $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
| 1104 | + $output .= $help_text; |
|
| 1105 | + |
|
| 1106 | + // maybe horizontal label |
|
| 1107 | + if ( $args['label_type'] == 'horizontal' ) { |
|
| 1108 | + $output .= '</div>'; |
|
| 1109 | + } |
|
| 1110 | + |
|
| 1111 | + // wrap |
|
| 1112 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
| 1113 | + $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1114 | + $output = self::wrap( array( |
|
| 1115 | + 'content' => $output, |
|
| 1116 | + 'class' => $wrap_class, |
|
| 1117 | + 'element_require' => $args['element_require'], |
|
| 1118 | + 'argument_id' => $args['id'], |
|
| 1119 | + 'wrap_attributes' => $args['wrap_attributes'], |
|
| 1120 | + ) ); |
|
| 1121 | + |
|
| 1122 | + |
|
| 1123 | + return $output; |
|
| 1124 | + } |
|
| 1125 | + |
|
| 1126 | + /** |
|
| 1127 | + * Build the component. |
|
| 1128 | + * |
|
| 1129 | + * @param array $args |
|
| 1130 | + * |
|
| 1131 | + * @return string The rendered component. |
|
| 1132 | + */ |
|
| 1133 | + public static function radio_option( $args = array(), $count = '' ) { |
|
| 1134 | + $defaults = array( |
|
| 1135 | + 'class' => '', |
|
| 1136 | + 'id' => '', |
|
| 1137 | + 'title' => '', |
|
| 1138 | + 'value' => '', |
|
| 1139 | + 'required' => false, |
|
| 1140 | + 'inline' => true, |
|
| 1141 | + 'label' => '', |
|
| 1142 | + 'options' => array(), |
|
| 1143 | + 'icon' => '', |
|
| 1144 | + 'no_wrap' => false, |
|
| 1145 | + 'extra_attributes' => array() // an array of extra attributes |
|
| 1146 | + ); |
|
| 1147 | + |
|
| 1148 | + /** |
|
| 1149 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 1150 | + */ |
|
| 1151 | + $args = wp_parse_args( $args, $defaults ); |
|
| 1152 | + |
|
| 1153 | + $output = ''; |
|
| 1154 | + |
|
| 1155 | + // open/type |
|
| 1156 | + $output .= '<input type="radio"'; |
|
| 1157 | + |
|
| 1158 | + // class |
|
| 1159 | + $output .= ' class="form-check-input" '; |
|
| 1160 | + |
|
| 1161 | + // name |
|
| 1162 | + if ( ! empty( $args['name'] ) ) { |
|
| 1163 | + $output .= AUI_Component_Helper::name( $args['name'] ); |
|
| 1164 | + } |
|
| 1165 | + |
|
| 1166 | + // id |
|
| 1167 | + if ( ! empty( $args['id'] ) ) { |
|
| 1168 | + $output .= AUI_Component_Helper::id( $args['id'] . $count ); |
|
| 1169 | + } |
|
| 1170 | + |
|
| 1171 | + // title |
|
| 1172 | + if ( ! empty( $args['title'] ) ) { |
|
| 1173 | + $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 1174 | + } |
|
| 1175 | + |
|
| 1176 | + // value |
|
| 1177 | + if ( isset( $args['value'] ) ) { |
|
| 1178 | + $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 1179 | + } |
|
| 1180 | + |
|
| 1181 | + // checked, for radio and checkboxes |
|
| 1182 | + if ( $args['checked'] ) { |
|
| 1183 | + $output .= ' checked '; |
|
| 1184 | + } |
|
| 1185 | + |
|
| 1186 | + // data-attributes |
|
| 1187 | + $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 1188 | + |
|
| 1189 | + // aria-attributes |
|
| 1190 | + $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 1191 | + |
|
| 1192 | + // extra attributes |
|
| 1193 | + if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 1194 | + $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 1195 | + } |
|
| 1196 | + |
|
| 1197 | + // required |
|
| 1198 | + if ( ! empty( $args['required'] ) ) { |
|
| 1199 | + $output .= ' required '; |
|
| 1200 | + } |
|
| 1201 | + |
|
| 1202 | + // close opening tag |
|
| 1203 | + $output .= ' >'; |
|
| 1204 | + |
|
| 1205 | + // label |
|
| 1206 | + if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 1207 | + } elseif ( ! empty( $args['label'] ) ) { |
|
| 1208 | + $output .= self::label( array( |
|
| 1209 | + 'title' => $args['label'], |
|
| 1210 | + 'for' => $args['id'] . $count, |
|
| 1211 | + 'class' => 'form-check-label' |
|
| 1212 | + ), 'radio' ); |
|
| 1213 | + } |
|
| 1214 | + |
|
| 1215 | + // wrap |
|
| 1216 | + if ( ! $args['no_wrap'] ) { |
|
| 1217 | + $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
|
| 1218 | + |
|
| 1219 | + // Unique wrap class |
|
| 1220 | + $uniq_class = 'fwrap'; |
|
| 1221 | + if ( ! empty( $args['name'] ) ) { |
|
| 1222 | + $uniq_class .= '-' . $args['name']; |
|
| 1223 | + } else if ( ! empty( $args['id'] ) ) { |
|
| 1224 | + $uniq_class .= '-' . $args['id']; |
|
| 1225 | + } |
|
| 1226 | + |
|
| 1227 | + if ( isset( $args['value'] ) || $args['value'] !== "" ) { |
|
| 1228 | + $uniq_class .= '-' . $args['value']; |
|
| 1229 | + } else { |
|
| 1230 | + $uniq_class .= '-' . $count; |
|
| 1231 | + } |
|
| 1232 | + $wrap_class .= ' ' . sanitize_html_class( $uniq_class ); |
|
| 1233 | + |
|
| 1234 | + $output = self::wrap( array( |
|
| 1235 | + 'content' => $output, |
|
| 1236 | + 'class' => $wrap_class |
|
| 1237 | + ) ); |
|
| 1238 | + } |
|
| 1239 | + |
|
| 1240 | + return $output; |
|
| 1241 | + } |
|
| 1242 | 1242 | |
| 1243 | 1243 | } |
| 1244 | 1244 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return string The rendered component. |
| 20 | 20 | */ |
| 21 | - public static function input( $args = array() ) { |
|
| 21 | + public static function input($args = array()) { |
|
| 22 | 22 | $defaults = array( |
| 23 | 23 | 'type' => 'text', |
| 24 | 24 | 'name' => '', |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * Parse incoming $args into an array and merge it with $defaults |
| 67 | 67 | */ |
| 68 | - $args = wp_parse_args( $args, $defaults ); |
|
| 68 | + $args = wp_parse_args($args, $defaults); |
|
| 69 | 69 | $output = ''; |
| 70 | - if ( ! empty( $args['type'] ) ) { |
|
| 70 | + if (!empty($args['type'])) { |
|
| 71 | 71 | // hidden label option needs to be empty |
| 72 | 72 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
| 73 | 73 | |
| 74 | - $type = sanitize_html_class( $args['type'] ); |
|
| 74 | + $type = sanitize_html_class($args['type']); |
|
| 75 | 75 | |
| 76 | 76 | $help_text = ''; |
| 77 | 77 | $label = ''; |
@@ -85,17 +85,17 @@ discard block |
||
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | // floating labels need label after |
| 88 | - if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) { |
|
| 88 | + if ($args['label_type'] == 'floating' && $type != 'checkbox') { |
|
| 89 | 89 | $label_after = true; |
| 90 | 90 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // size |
| 94 | 94 | $size = ''; |
| 95 | - if ( $args['size'] == 'lg' || $args['size'] == 'large' ) { |
|
| 95 | + if ($args['size'] == 'lg' || $args['size'] == 'large') { |
|
| 96 | 96 | $size = 'lg'; |
| 97 | 97 | $args['class'] .= ' form-control-lg'; |
| 98 | - }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) { |
|
| 98 | + }elseif ($args['size'] == 'sm' || $args['size'] == 'small') { |
|
| 99 | 99 | $size = 'sm'; |
| 100 | 100 | $args['class'] .= ' form-control-sm'; |
| 101 | 101 | } |
@@ -104,21 +104,21 @@ discard block |
||
| 104 | 104 | $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');'; |
| 105 | 105 | |
| 106 | 106 | // Some special sauce for files |
| 107 | - if ( $type == 'file' ) { |
|
| 107 | + if ($type == 'file') { |
|
| 108 | 108 | $label_after = true; // if type file we need the label after |
| 109 | 109 | $args['class'] .= ' custom-file-input '; |
| 110 | - } elseif ( $type == 'checkbox' ) { |
|
| 110 | + } elseif ($type == 'checkbox') { |
|
| 111 | 111 | $label_after = true; // if type file we need the label after |
| 112 | 112 | $args['class'] .= ' custom-control-input '; |
| 113 | - } elseif ( $type == 'datepicker' || $type == 'timepicker' ) { |
|
| 113 | + } elseif ($type == 'datepicker' || $type == 'timepicker') { |
|
| 114 | 114 | $type = 'text'; |
| 115 | 115 | $args['class'] .= ' bg-initial '; // @todo not sure why we have this? |
| 116 | - $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');"; |
|
| 116 | + $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr($args['name']) . "\']').trigger('change');"; |
|
| 117 | 117 | |
| 118 | 118 | $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
| 119 | 119 | |
| 120 | 120 | // set a way to clear field if empty |
| 121 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) { |
|
| 121 | + if ($args['input_group_right'] === '' && $args['clear_icon'] !== false) { |
|
| 122 | 122 | $args['input_group_right_inside'] = true; |
| 123 | 123 | $args['clear_icon'] = true; |
| 124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | // enqueue the script |
| 127 | 127 | $aui_settings = AyeCode_UI_Settings::instance(); |
| 128 | 128 | $aui_settings->enqueue_flatpickr(); |
| 129 | - } elseif ( $type == 'iconpicker' ) { |
|
| 129 | + } elseif ($type == 'iconpicker') { |
|
| 130 | 130 | $type = 'text'; |
| 131 | 131 | //$args['class'] .= ' aui-flatpickr bg-initial '; |
| 132 | 132 | // $args['class'] .= ' bg-initial '; |
@@ -141,103 +141,103 @@ discard block |
||
| 141 | 141 | $aui_settings->enqueue_iconpicker(); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) { |
|
| 145 | - $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />'; |
|
| 144 | + if ($type == 'checkbox' && !empty($args['name']) && strpos($args['name'], '[') === false) { |
|
| 145 | + $output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />'; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // allow clear icon |
| 149 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] ) { |
|
| 150 | - $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' ); |
|
| 149 | + if ($args['input_group_right'] === '' && $args['clear_icon']) { |
|
| 150 | + $font_size = $size == 'sm' ? '1.3' : ($size == 'lg' ? '1.65' : '1.5'); |
|
| 151 | 151 | $args['input_group_right_inside'] = true; |
| 152 | - $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: '.$font_size.'rem" aria-hidden="true" class="close">×</span></span>'; |
|
| 152 | + $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="close">×</span></span>'; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // open/type |
| 156 | 156 | $output .= '<input type="' . $type . '" '; |
| 157 | 157 | |
| 158 | 158 | // name |
| 159 | - if ( ! empty( $args['name'] ) ) { |
|
| 160 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 159 | + if (!empty($args['name'])) { |
|
| 160 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // id |
| 164 | - if ( ! empty( $args['id'] ) ) { |
|
| 165 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 164 | + if (!empty($args['id'])) { |
|
| 165 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // placeholder |
| 169 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 170 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 169 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
| 170 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // title |
| 174 | - if ( ! empty( $args['title'] ) ) { |
|
| 175 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 174 | + if (!empty($args['title'])) { |
|
| 175 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // value |
| 179 | - if ( ! empty( $args['value'] ) ) { |
|
| 180 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 179 | + if (!empty($args['value'])) { |
|
| 180 | + $output .= AUI_Component_Helper::value($args['value']); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // checked, for radio and checkboxes |
| 184 | - if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) { |
|
| 184 | + if (($type == 'checkbox' || $type == 'radio') && $args['checked']) { |
|
| 185 | 185 | $output .= ' checked '; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // validation text |
| 189 | - if ( ! empty( $args['validation_text'] ) ) { |
|
| 190 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
| 189 | + if (!empty($args['validation_text'])) { |
|
| 190 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
| 191 | 191 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // validation_pattern |
| 195 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 196 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 195 | + if (!empty($args['validation_pattern'])) { |
|
| 196 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // step (for numbers) |
| 200 | - if ( ! empty( $args['step'] ) ) { |
|
| 200 | + if (!empty($args['step'])) { |
|
| 201 | 201 | $output .= ' step="' . $args['step'] . '" '; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // required |
| 205 | - if ( ! empty( $args['required'] ) ) { |
|
| 205 | + if (!empty($args['required'])) { |
|
| 206 | 206 | $output .= ' required '; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // class |
| 210 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 210 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
| 211 | 211 | $output .= ' class="form-control ' . $class . '" '; |
| 212 | 212 | |
| 213 | 213 | // data-attributes |
| 214 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 214 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
| 215 | 215 | |
| 216 | 216 | // extra attributes |
| 217 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 218 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 217 | + if (!empty($args['extra_attributes'])) { |
|
| 218 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // close |
| 222 | 222 | $output .= ' >'; |
| 223 | 223 | |
| 224 | 224 | // help text |
| 225 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 226 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 225 | + if (!empty($args['help_text'])) { |
|
| 226 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // label |
| 230 | - if ( ! empty( $args['label'] ) ) { |
|
| 230 | + if (!empty($args['label'])) { |
|
| 231 | 231 | $label_base_class = ''; |
| 232 | - if ( $type == 'file' ) { |
|
| 232 | + if ($type == 'file') { |
|
| 233 | 233 | $label_base_class = ' custom-file-label'; |
| 234 | - } elseif ( $type == 'checkbox' ) { |
|
| 235 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
| 236 | - $label_args['title'] = wp_kses_post( $args['help_text'] ); |
|
| 234 | + } elseif ($type == 'checkbox') { |
|
| 235 | + if (!empty($args['label_force_left'])) { |
|
| 236 | + $label_args['title'] = wp_kses_post($args['help_text']); |
|
| 237 | 237 | $help_text = ''; |
| 238 | 238 | //$label_args['class'] .= ' d-inline '; |
| 239 | 239 | $args['wrap_class'] .= ' align-items-center '; |
| 240 | - }else{ |
|
| 240 | + } else { |
|
| 241 | 241 | |
| 242 | 242 | } |
| 243 | 243 | |
@@ -245,45 +245,45 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | $label_args['class'] .= $label_base_class; |
| 247 | 247 | $temp_label_args = $label_args; |
| 248 | - if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";} |
|
| 249 | - $label = self::label( $temp_label_args, $type ); |
|
| 248 | + if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; } |
|
| 249 | + $label = self::label($temp_label_args, $type); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
| 253 | 253 | |
| 254 | 254 | |
| 255 | 255 | // set help text in the correct position |
| 256 | - if ( $label_after ) { |
|
| 256 | + if ($label_after) { |
|
| 257 | 257 | $output .= $label . $help_text; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // some input types need a separate wrap |
| 261 | - if ( $type == 'file' ) { |
|
| 262 | - $output = self::wrap( array( |
|
| 261 | + if ($type == 'file') { |
|
| 262 | + $output = self::wrap(array( |
|
| 263 | 263 | 'content' => $output, |
| 264 | 264 | 'class' => 'form-group custom-file' |
| 265 | - ) ); |
|
| 266 | - } elseif ( $type == 'checkbox' ) { |
|
| 265 | + )); |
|
| 266 | + } elseif ($type == 'checkbox') { |
|
| 267 | 267 | |
| 268 | 268 | $label_args['title'] = $args['label']; |
| 269 | - $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ); |
|
| 270 | - $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
| 271 | - $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : ''; |
|
| 272 | - $wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox'; |
|
| 273 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
| 269 | + $label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label'); |
|
| 270 | + $label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
| 271 | + $switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : ''; |
|
| 272 | + $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox'; |
|
| 273 | + if (!empty($args['label_force_left'])) { |
|
| 274 | 274 | $wrap_class .= ' d-flex align-content-center'; |
| 275 | - $label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) ); |
|
| 275 | + $label = str_replace("custom-control-label", "", self::label($label_args, 'cb')); |
|
| 276 | 276 | } |
| 277 | - $output = self::wrap( array( |
|
| 277 | + $output = self::wrap(array( |
|
| 278 | 278 | 'content' => $output, |
| 279 | 279 | 'class' => 'custom-control ' . $wrap_class |
| 280 | - ) ); |
|
| 280 | + )); |
|
| 281 | 281 | |
| 282 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 283 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 282 | + if ($args['label_type'] == 'horizontal') { |
|
| 283 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
| 284 | 284 | $output = $label . '<div class="' . $input_col . '">' . $output . '</div>'; |
| 285 | 285 | } |
| 286 | - } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) { |
|
| 286 | + } elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) { |
|
| 287 | 287 | |
| 288 | 288 | |
| 289 | 289 | // allow password field to toggle view |
@@ -297,65 +297,65 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // input group wraps |
| 300 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 301 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 300 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
| 301 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
| 302 | 302 | $group_size = $size == 'lg' ? ' input-group-lg' : ''; |
| 303 | 303 | $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size; |
| 304 | 304 | |
| 305 | - if ( $args['input_group_left'] ) { |
|
| 306 | - $output = self::wrap( array( |
|
| 305 | + if ($args['input_group_left']) { |
|
| 306 | + $output = self::wrap(array( |
|
| 307 | 307 | 'content' => $output, |
| 308 | 308 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
| 309 | 309 | 'input_group_left' => $args['input_group_left'], |
| 310 | 310 | 'input_group_left_inside' => $args['input_group_left_inside'] |
| 311 | - ) ); |
|
| 311 | + )); |
|
| 312 | 312 | } |
| 313 | - if ( $args['input_group_right'] ) { |
|
| 314 | - $output = self::wrap( array( |
|
| 313 | + if ($args['input_group_right']) { |
|
| 314 | + $output = self::wrap(array( |
|
| 315 | 315 | 'content' => $output, |
| 316 | 316 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
| 317 | 317 | 'input_group_right' => $args['input_group_right'], |
| 318 | 318 | 'input_group_right_inside' => $args['input_group_right_inside'] |
| 319 | - ) ); |
|
| 319 | + )); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if ( ! $label_after ) { |
|
| 324 | + if (!$label_after) { |
|
| 325 | 325 | $output .= $help_text; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | |
| 329 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 330 | - $output = self::wrap( array( |
|
| 329 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
| 330 | + $output = self::wrap(array( |
|
| 331 | 331 | 'content' => $output, |
| 332 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 333 | - ) ); |
|
| 332 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
| 333 | + )); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if ( ! $label_after ) { |
|
| 336 | + if (!$label_after) { |
|
| 337 | 337 | $output = $label . $output; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // wrap |
| 341 | - if ( ! $args['no_wrap'] ) { |
|
| 341 | + if (!$args['no_wrap']) { |
|
| 342 | 342 | $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
| 343 | 343 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
| 344 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 345 | - $output = self::wrap( array( |
|
| 344 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 345 | + $output = self::wrap(array( |
|
| 346 | 346 | 'content' => $output, |
| 347 | 347 | 'class' => $wrap_class, |
| 348 | 348 | 'element_require' => $args['element_require'], |
| 349 | 349 | 'argument_id' => $args['id'], |
| 350 | 350 | 'wrap_attributes' => $args['wrap_attributes'], |
| 351 | - ) ); |
|
| 351 | + )); |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | return $output; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - public static function label( $args = array(), $type = '' ) { |
|
| 358 | + public static function label($args = array(), $type = '') { |
|
| 359 | 359 | //<label for="exampleInputEmail1">Email address</label> |
| 360 | 360 | $defaults = array( |
| 361 | 361 | 'title' => 'div', |
@@ -368,33 +368,33 @@ discard block |
||
| 368 | 368 | /** |
| 369 | 369 | * Parse incoming $args into an array and merge it with $defaults |
| 370 | 370 | */ |
| 371 | - $args = wp_parse_args( $args, $defaults ); |
|
| 371 | + $args = wp_parse_args($args, $defaults); |
|
| 372 | 372 | $output = ''; |
| 373 | 373 | |
| 374 | - if ( $args['title'] ) { |
|
| 374 | + if ($args['title']) { |
|
| 375 | 375 | |
| 376 | 376 | // maybe hide labels //@todo set a global option for visibility class |
| 377 | - if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) { |
|
| 377 | + if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) { |
|
| 378 | 378 | $class = $args['class']; |
| 379 | 379 | } else { |
| 380 | 380 | $class = 'sr-only ' . $args['class']; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | // maybe horizontal |
| 384 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
| 385 | - $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label'; |
|
| 384 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
| 385 | + $class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label'; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | // open |
| 389 | 389 | $output .= '<label '; |
| 390 | 390 | |
| 391 | 391 | // for |
| 392 | - if ( ! empty( $args['for'] ) ) { |
|
| 393 | - $output .= ' for="' . esc_attr( $args['for'] ) . '" '; |
|
| 392 | + if (!empty($args['for'])) { |
|
| 393 | + $output .= ' for="' . esc_attr($args['for']) . '" '; |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | // class |
| 397 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
| 397 | + $class = $class ? AUI_Component_Helper::esc_classes($class) : ''; |
|
| 398 | 398 | $output .= ' class="' . $class . '" '; |
| 399 | 399 | |
| 400 | 400 | // close |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | // title, don't escape fully as can contain html |
| 405 | - if ( ! empty( $args['title'] ) ) { |
|
| 406 | - $output .= wp_kses_post( $args['title'] ); |
|
| 405 | + if (!empty($args['title'])) { |
|
| 406 | + $output .= wp_kses_post($args['title']); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | // close wrap |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | * |
| 424 | 424 | * @return string |
| 425 | 425 | */ |
| 426 | - public static function wrap( $args = array() ) { |
|
| 426 | + public static function wrap($args = array()) { |
|
| 427 | 427 | $defaults = array( |
| 428 | 428 | 'type' => 'div', |
| 429 | 429 | 'class' => 'form-group', |
@@ -440,31 +440,31 @@ discard block |
||
| 440 | 440 | /** |
| 441 | 441 | * Parse incoming $args into an array and merge it with $defaults |
| 442 | 442 | */ |
| 443 | - $args = wp_parse_args( $args, $defaults ); |
|
| 443 | + $args = wp_parse_args($args, $defaults); |
|
| 444 | 444 | $output = ''; |
| 445 | - if ( $args['type'] ) { |
|
| 445 | + if ($args['type']) { |
|
| 446 | 446 | |
| 447 | 447 | // open |
| 448 | - $output .= '<' . sanitize_html_class( $args['type'] ); |
|
| 448 | + $output .= '<' . sanitize_html_class($args['type']); |
|
| 449 | 449 | |
| 450 | 450 | // element require |
| 451 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 452 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 451 | + if (!empty($args['element_require'])) { |
|
| 452 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
| 453 | 453 | $args['class'] .= " aui-conditional-field"; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | // argument_id |
| 457 | - if ( ! empty( $args['argument_id'] ) ) { |
|
| 458 | - $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"'; |
|
| 457 | + if (!empty($args['argument_id'])) { |
|
| 458 | + $output .= ' data-argument="' . esc_attr($args['argument_id']) . '"'; |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // class |
| 462 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
| 462 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
| 463 | 463 | $output .= ' class="' . $class . '" '; |
| 464 | 464 | |
| 465 | 465 | // Attributes |
| 466 | - if ( ! empty( $args['wrap_attributes'] ) ) { |
|
| 467 | - $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] ); |
|
| 466 | + if (!empty($args['wrap_attributes'])) { |
|
| 467 | + $output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // close wrap |
@@ -472,9 +472,9 @@ discard block |
||
| 472 | 472 | |
| 473 | 473 | |
| 474 | 474 | // Input group left |
| 475 | - if ( ! empty( $args['input_group_left'] ) ) { |
|
| 476 | - $position_class = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 477 | - $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
| 475 | + if (!empty($args['input_group_left'])) { |
|
| 476 | + $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
| 477 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
| 478 | 478 | $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
| 479 | 479 | } |
| 480 | 480 | |
@@ -482,15 +482,15 @@ discard block |
||
| 482 | 482 | $output .= $args['content']; |
| 483 | 483 | |
| 484 | 484 | // Input group right |
| 485 | - if ( ! empty( $args['input_group_right'] ) ) { |
|
| 486 | - $position_class = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : ''; |
|
| 487 | - $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
| 485 | + if (!empty($args['input_group_right'])) { |
|
| 486 | + $position_class = !empty($args['input_group_right_inside']) ? 'position-absolute h-100' : ''; |
|
| 487 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
| 488 | 488 | $output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
| 492 | 492 | // close wrap |
| 493 | - $output .= '</' . sanitize_html_class( $args['type'] ) . '>'; |
|
| 493 | + $output .= '</' . sanitize_html_class($args['type']) . '>'; |
|
| 494 | 494 | |
| 495 | 495 | |
| 496 | 496 | } else { |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * |
| 508 | 508 | * @return string The rendered component. |
| 509 | 509 | */ |
| 510 | - public static function textarea( $args = array() ) { |
|
| 510 | + public static function textarea($args = array()) { |
|
| 511 | 511 | $defaults = array( |
| 512 | 512 | 'name' => '', |
| 513 | 513 | 'class' => '', |
@@ -544,28 +544,28 @@ discard block |
||
| 544 | 544 | /** |
| 545 | 545 | * Parse incoming $args into an array and merge it with $defaults |
| 546 | 546 | */ |
| 547 | - $args = wp_parse_args( $args, $defaults ); |
|
| 547 | + $args = wp_parse_args($args, $defaults); |
|
| 548 | 548 | $output = ''; |
| 549 | 549 | |
| 550 | 550 | // hidden label option needs to be empty |
| 551 | 551 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
| 552 | 552 | |
| 553 | 553 | // floating labels don't work with wysiwyg so set it as top |
| 554 | - if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) { |
|
| 554 | + if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) { |
|
| 555 | 555 | $args['label_type'] = 'top'; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | $label_after = $args['label_after']; |
| 559 | 559 | |
| 560 | 560 | // floating labels need label after |
| 561 | - if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) { |
|
| 561 | + if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) { |
|
| 562 | 562 | $label_after = true; |
| 563 | 563 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | // label |
| 567 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 568 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 567 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
| 568 | + } elseif (!empty($args['label']) && !$label_after) { |
|
| 569 | 569 | $label_args = array( |
| 570 | 570 | 'title' => $args['label'], |
| 571 | 571 | 'for' => $args['id'], |
@@ -573,34 +573,34 @@ discard block |
||
| 573 | 573 | 'label_type' => $args['label_type'], |
| 574 | 574 | 'label_col' => $args['label_col'] |
| 575 | 575 | ); |
| 576 | - $output .= self::label( $label_args ); |
|
| 576 | + $output .= self::label($label_args); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | // maybe horizontal label |
| 580 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 581 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 580 | + if ($args['label_type'] == 'horizontal') { |
|
| 581 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
| 582 | 582 | $output .= '<div class="' . $input_col . '">'; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - if ( ! empty( $args['wysiwyg'] ) ) { |
|
| 585 | + if (!empty($args['wysiwyg'])) { |
|
| 586 | 586 | ob_start(); |
| 587 | 587 | $content = $args['value']; |
| 588 | - $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor'; |
|
| 588 | + $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
|
| 589 | 589 | $settings = array( |
| 590 | - 'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4, |
|
| 590 | + 'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4, |
|
| 591 | 591 | 'quicktags' => false, |
| 592 | 592 | 'media_buttons' => false, |
| 593 | 593 | 'editor_class' => 'form-control', |
| 594 | - 'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ), |
|
| 594 | + 'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']), |
|
| 595 | 595 | 'teeny' => true, |
| 596 | 596 | ); |
| 597 | 597 | |
| 598 | 598 | // maybe set settings if array |
| 599 | - if ( is_array( $args['wysiwyg'] ) ) { |
|
| 600 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
| 599 | + if (is_array($args['wysiwyg'])) { |
|
| 600 | + $settings = wp_parse_args($args['wysiwyg'], $settings); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - wp_editor( $content, $editor_id, $settings ); |
|
| 603 | + wp_editor($content, $editor_id, $settings); |
|
| 604 | 604 | $output .= ob_get_clean(); |
| 605 | 605 | } else { |
| 606 | 606 | |
@@ -608,65 +608,65 @@ discard block |
||
| 608 | 608 | $output .= '<textarea '; |
| 609 | 609 | |
| 610 | 610 | // name |
| 611 | - if ( ! empty( $args['name'] ) ) { |
|
| 612 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
| 611 | + if (!empty($args['name'])) { |
|
| 612 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | // id |
| 616 | - if ( ! empty( $args['id'] ) ) { |
|
| 617 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
| 616 | + if (!empty($args['id'])) { |
|
| 617 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | // placeholder |
| 621 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
| 622 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
| 621 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
| 622 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | // title |
| 626 | - if ( ! empty( $args['title'] ) ) { |
|
| 627 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
| 626 | + if (!empty($args['title'])) { |
|
| 627 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | // validation text |
| 631 | - if ( ! empty( $args['validation_text'] ) ) { |
|
| 632 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
| 631 | + if (!empty($args['validation_text'])) { |
|
| 632 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
| 633 | 633 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | // validation_pattern |
| 637 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
| 638 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
| 637 | + if (!empty($args['validation_pattern'])) { |
|
| 638 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | // required |
| 642 | - if ( ! empty( $args['required'] ) ) { |
|
| 642 | + if (!empty($args['required'])) { |
|
| 643 | 643 | $output .= ' required '; |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | // rows |
| 647 | - if ( ! empty( $args['rows'] ) ) { |
|
| 648 | - $output .= ' rows="' . absint( $args['rows'] ) . '" '; |
|
| 647 | + if (!empty($args['rows'])) { |
|
| 648 | + $output .= ' rows="' . absint($args['rows']) . '" '; |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | |
| 652 | 652 | // class |
| 653 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 653 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
| 654 | 654 | $output .= ' class="form-control ' . $class . '" '; |
| 655 | 655 | |
| 656 | 656 | // extra attributes |
| 657 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 658 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 657 | + if (!empty($args['extra_attributes'])) { |
|
| 658 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | // close tag |
| 662 | 662 | $output .= ' >'; |
| 663 | 663 | |
| 664 | 664 | // value |
| 665 | - if ( ! empty( $args['value'] ) ) { |
|
| 666 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
| 667 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
| 665 | + if (!empty($args['value'])) { |
|
| 666 | + if (!empty($args['allow_tags'])) { |
|
| 667 | + $output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML. |
|
| 668 | 668 | } else { |
| 669 | - $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] ); |
|
| 669 | + $output .= AUI_Component_Helper::sanitize_textarea_field($args['value']); |
|
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | |
@@ -675,23 +675,23 @@ discard block |
||
| 675 | 675 | |
| 676 | 676 | |
| 677 | 677 | // input group wraps |
| 678 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 679 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 680 | - if ( $args['input_group_left'] ) { |
|
| 681 | - $output = self::wrap( array( |
|
| 678 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
| 679 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
| 680 | + if ($args['input_group_left']) { |
|
| 681 | + $output = self::wrap(array( |
|
| 682 | 682 | 'content' => $output, |
| 683 | 683 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
| 684 | 684 | 'input_group_left' => $args['input_group_left'], |
| 685 | 685 | 'input_group_left_inside' => $args['input_group_left_inside'] |
| 686 | - ) ); |
|
| 686 | + )); |
|
| 687 | 687 | } |
| 688 | - if ( $args['input_group_right'] ) { |
|
| 689 | - $output = self::wrap( array( |
|
| 688 | + if ($args['input_group_right']) { |
|
| 689 | + $output = self::wrap(array( |
|
| 690 | 690 | 'content' => $output, |
| 691 | 691 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
| 692 | 692 | 'input_group_right' => $args['input_group_right'], |
| 693 | 693 | 'input_group_right_inside' => $args['input_group_right_inside'] |
| 694 | - ) ); |
|
| 694 | + )); |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | } |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - if ( ! empty( $args['label'] ) && $label_after ) { |
|
| 702 | + if (!empty($args['label']) && $label_after) { |
|
| 703 | 703 | $label_args = array( |
| 704 | 704 | 'title' => $args['label'], |
| 705 | 705 | 'for' => $args['id'], |
@@ -707,32 +707,32 @@ discard block |
||
| 707 | 707 | 'label_type' => $args['label_type'], |
| 708 | 708 | 'label_col' => $args['label_col'] |
| 709 | 709 | ); |
| 710 | - $output .= self::label( $label_args ); |
|
| 710 | + $output .= self::label($label_args); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | // help text |
| 714 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 715 | - $output .= AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 714 | + if (!empty($args['help_text'])) { |
|
| 715 | + $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | // maybe horizontal label |
| 719 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 719 | + if ($args['label_type'] == 'horizontal') { |
|
| 720 | 720 | $output .= '</div>'; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | |
| 724 | 724 | // wrap |
| 725 | - if ( ! $args['no_wrap'] ) { |
|
| 725 | + if (!$args['no_wrap']) { |
|
| 726 | 726 | $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group'; |
| 727 | 727 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
| 728 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 729 | - $output = self::wrap( array( |
|
| 728 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 729 | + $output = self::wrap(array( |
|
| 730 | 730 | 'content' => $output, |
| 731 | 731 | 'class' => $wrap_class, |
| 732 | 732 | 'element_require' => $args['element_require'], |
| 733 | 733 | 'argument_id' => $args['id'], |
| 734 | 734 | 'wrap_attributes' => $args['wrap_attributes'], |
| 735 | - ) ); |
|
| 735 | + )); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | * |
| 747 | 747 | * @return string The rendered component. |
| 748 | 748 | */ |
| 749 | - public static function select( $args = array() ) { |
|
| 749 | + public static function select($args = array()) { |
|
| 750 | 750 | $defaults = array( |
| 751 | 751 | 'class' => '', |
| 752 | 752 | 'wrap_class' => '', |
@@ -783,11 +783,11 @@ discard block |
||
| 783 | 783 | /** |
| 784 | 784 | * Parse incoming $args into an array and merge it with $defaults |
| 785 | 785 | */ |
| 786 | - $args = wp_parse_args( $args, $defaults ); |
|
| 786 | + $args = wp_parse_args($args, $defaults); |
|
| 787 | 787 | $output = ''; |
| 788 | 788 | |
| 789 | 789 | // for now lets hide floating labels |
| 790 | - if ( $args['label_type'] == 'floating' ) { |
|
| 790 | + if ($args['label_type'] == 'floating') { |
|
| 791 | 791 | $args['label_type'] = 'hidden'; |
| 792 | 792 | } |
| 793 | 793 | |
@@ -798,89 +798,89 @@ discard block |
||
| 798 | 798 | $label_after = $args['label_after']; |
| 799 | 799 | |
| 800 | 800 | // floating labels need label after |
| 801 | - if ( $args['label_type'] == 'floating' ) { |
|
| 801 | + if ($args['label_type'] == 'floating') { |
|
| 802 | 802 | $label_after = true; |
| 803 | 803 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | // Maybe setup select2 |
| 807 | 807 | $is_select2 = false; |
| 808 | - if ( ! empty( $args['select2'] ) ) { |
|
| 808 | + if (!empty($args['select2'])) { |
|
| 809 | 809 | $args['class'] .= ' aui-select2'; |
| 810 | 810 | $is_select2 = true; |
| 811 | - } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) { |
|
| 811 | + } elseif (strpos($args['class'], 'aui-select2') !== false) { |
|
| 812 | 812 | $is_select2 = true; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | // select2 tags |
| 816 | - if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason |
|
| 816 | + if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason |
|
| 817 | 817 | $args['data-tags'] = 'true'; |
| 818 | 818 | $args['data-token-separators'] = "[',']"; |
| 819 | 819 | $args['multiple'] = true; |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | // select2 placeholder |
| 823 | - if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) { |
|
| 824 | - $args['data-placeholder'] = esc_attr( $args['placeholder'] ); |
|
| 825 | - $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true; |
|
| 823 | + if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) { |
|
| 824 | + $args['data-placeholder'] = esc_attr($args['placeholder']); |
|
| 825 | + $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | // Set hidden input to save empty value for multiselect. |
| 829 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
| 830 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>'; |
|
| 829 | + if (!empty($args['multiple']) && !empty($args['name'])) { |
|
| 830 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value="" data-ignore-rule/>'; |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | // open/type |
| 834 | 834 | $output .= '<select '; |
| 835 | 835 | |
| 836 | 836 | // style |
| 837 | - if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
| 837 | + if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
| 838 | 838 | $output .= " style='width:100%;' "; |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | // element require |
| 842 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 843 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
| 842 | + if (!empty($args['element_require'])) { |
|
| 843 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
| 844 | 844 | $args['class'] .= " aui-conditional-field"; |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | // class |
| 848 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
| 849 | - $output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class ); |
|
| 848 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
| 849 | + $output .= AUI_Component_Helper::class_attr('custom-select ' . $class); |
|
| 850 | 850 | |
| 851 | 851 | // name |
| 852 | - if ( ! empty( $args['name'] ) ) { |
|
| 853 | - $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] ); |
|
| 852 | + if (!empty($args['name'])) { |
|
| 853 | + $output .= AUI_Component_Helper::name($args['name'], $args['multiple']); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | // id |
| 857 | - if ( ! empty( $args['id'] ) ) { |
|
| 858 | - $output .= AUI_Component_Helper::id( $args['id'] ); |
|
| 857 | + if (!empty($args['id'])) { |
|
| 858 | + $output .= AUI_Component_Helper::id($args['id']); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | // title |
| 862 | - if ( ! empty( $args['title'] ) ) { |
|
| 863 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 862 | + if (!empty($args['title'])) { |
|
| 863 | + $output .= AUI_Component_Helper::title($args['title']); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | // data-attributes |
| 867 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 867 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
| 868 | 868 | |
| 869 | 869 | // aria-attributes |
| 870 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 870 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
| 871 | 871 | |
| 872 | 872 | // extra attributes |
| 873 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 874 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 873 | + if (!empty($args['extra_attributes'])) { |
|
| 874 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | // required |
| 878 | - if ( ! empty( $args['required'] ) ) { |
|
| 878 | + if (!empty($args['required'])) { |
|
| 879 | 879 | $output .= ' required '; |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | // multiple |
| 883 | - if ( ! empty( $args['multiple'] ) ) { |
|
| 883 | + if (!empty($args['multiple'])) { |
|
| 884 | 884 | $output .= ' multiple '; |
| 885 | 885 | } |
| 886 | 886 | |
@@ -888,50 +888,50 @@ discard block |
||
| 888 | 888 | $output .= ' >'; |
| 889 | 889 | |
| 890 | 890 | // placeholder |
| 891 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) { |
|
| 892 | - $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>'; |
|
| 893 | - } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) { |
|
| 891 | + if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) { |
|
| 892 | + $output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>'; |
|
| 893 | + } elseif ($is_select2 && !empty($args['placeholder'])) { |
|
| 894 | 894 | $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | // Options |
| 898 | - if ( ! empty( $args['options'] ) ) { |
|
| 898 | + if (!empty($args['options'])) { |
|
| 899 | 899 | |
| 900 | - if ( ! is_array( $args['options'] ) ) { |
|
| 900 | + if (!is_array($args['options'])) { |
|
| 901 | 901 | $output .= $args['options']; // not the preferred way but an option |
| 902 | 902 | } else { |
| 903 | - foreach ( $args['options'] as $val => $name ) { |
|
| 903 | + foreach ($args['options'] as $val => $name) { |
|
| 904 | 904 | $selected = ''; |
| 905 | - if ( is_array( $name ) ) { |
|
| 906 | - if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) { |
|
| 907 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 905 | + if (is_array($name)) { |
|
| 906 | + if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
|
| 907 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
| 908 | 908 | |
| 909 | - $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>'; |
|
| 909 | + $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
| 910 | 910 | } else { |
| 911 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
| 912 | - $option_value = isset( $name['value'] ) ? $name['value'] : ''; |
|
| 913 | - $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : ''; |
|
| 914 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) { |
|
| 915 | - $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : ""; |
|
| 916 | - } elseif ( ! empty( $args['value'] ) ) { |
|
| 917 | - $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false ); |
|
| 918 | - } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) { |
|
| 919 | - $selected = selected( $option_value, $args['value'], false ); |
|
| 911 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
| 912 | + $option_value = isset($name['value']) ? $name['value'] : ''; |
|
| 913 | + $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : ''; |
|
| 914 | + if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) { |
|
| 915 | + $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
|
| 916 | + } elseif (!empty($args['value'])) { |
|
| 917 | + $selected = selected($option_value, stripslashes_deep($args['value']), false); |
|
| 918 | + } elseif (empty($args['value']) && $args['value'] === $option_value) { |
|
| 919 | + $selected = selected($option_value, $args['value'], false); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | - $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>'; |
|
| 922 | + $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>'; |
|
| 923 | 923 | } |
| 924 | 924 | } else { |
| 925 | - if ( ! empty( $args['value'] ) ) { |
|
| 926 | - if ( is_array( $args['value'] ) ) { |
|
| 927 | - $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : ''; |
|
| 928 | - } elseif ( ! empty( $args['value'] ) ) { |
|
| 929 | - $selected = selected( $args['value'], $val, false ); |
|
| 925 | + if (!empty($args['value'])) { |
|
| 926 | + if (is_array($args['value'])) { |
|
| 927 | + $selected = in_array($val, $args['value']) ? 'selected="selected"' : ''; |
|
| 928 | + } elseif (!empty($args['value'])) { |
|
| 929 | + $selected = selected($args['value'], $val, false); |
|
| 930 | 930 | } |
| 931 | - } elseif ( $args['value'] === $val ) { |
|
| 932 | - $selected = selected( $args['value'], $val, false ); |
|
| 931 | + } elseif ($args['value'] === $val) { |
|
| 932 | + $selected = selected($args['value'], $val, false); |
|
| 933 | 933 | } |
| 934 | - $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
| 934 | + $output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>'; |
|
| 935 | 935 | } |
| 936 | 936 | } |
| 937 | 937 | } |
@@ -944,8 +944,8 @@ discard block |
||
| 944 | 944 | $label = ''; |
| 945 | 945 | $help_text = ''; |
| 946 | 946 | // label |
| 947 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 948 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
| 947 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
| 948 | + } elseif (!empty($args['label']) && !$label_after) { |
|
| 949 | 949 | $label_args = array( |
| 950 | 950 | 'title' => $args['label'], |
| 951 | 951 | 'for' => $args['id'], |
@@ -953,49 +953,49 @@ discard block |
||
| 953 | 953 | 'label_type' => $args['label_type'], |
| 954 | 954 | 'label_col' => $args['label_col'] |
| 955 | 955 | ); |
| 956 | - $label = self::label( $label_args ); |
|
| 956 | + $label = self::label($label_args); |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | // help text |
| 960 | - if ( ! empty( $args['help_text'] ) ) { |
|
| 961 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
| 960 | + if (!empty($args['help_text'])) { |
|
| 961 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | // input group wraps |
| 965 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
| 966 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
| 967 | - if ( $args['input_group_left'] ) { |
|
| 968 | - $output = self::wrap( array( |
|
| 965 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
| 966 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
| 967 | + if ($args['input_group_left']) { |
|
| 968 | + $output = self::wrap(array( |
|
| 969 | 969 | 'content' => $output, |
| 970 | 970 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
| 971 | 971 | 'input_group_left' => $args['input_group_left'], |
| 972 | 972 | 'input_group_left_inside' => $args['input_group_left_inside'] |
| 973 | - ) ); |
|
| 973 | + )); |
|
| 974 | 974 | } |
| 975 | - if ( $args['input_group_right'] ) { |
|
| 976 | - $output = self::wrap( array( |
|
| 975 | + if ($args['input_group_right']) { |
|
| 976 | + $output = self::wrap(array( |
|
| 977 | 977 | 'content' => $output, |
| 978 | 978 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
| 979 | 979 | 'input_group_right' => $args['input_group_right'], |
| 980 | 980 | 'input_group_right_inside' => $args['input_group_right_inside'] |
| 981 | - ) ); |
|
| 981 | + )); |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - if ( ! $label_after ) { |
|
| 986 | + if (!$label_after) { |
|
| 987 | 987 | $output .= $help_text; |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | |
| 991 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 992 | - $output = self::wrap( array( |
|
| 991 | + if ($args['label_type'] == 'horizontal') { |
|
| 992 | + $output = self::wrap(array( |
|
| 993 | 993 | 'content' => $output, |
| 994 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
| 995 | - ) ); |
|
| 994 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
| 995 | + )); |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | - if ( ! $label_after ) { |
|
| 998 | + if (!$label_after) { |
|
| 999 | 999 | $output = $label . $output; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
@@ -1006,16 +1006,16 @@ discard block |
||
| 1006 | 1006 | |
| 1007 | 1007 | |
| 1008 | 1008 | // wrap |
| 1009 | - if ( ! $args['no_wrap'] ) { |
|
| 1009 | + if (!$args['no_wrap']) { |
|
| 1010 | 1010 | $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
| 1011 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1012 | - $output = self::wrap( array( |
|
| 1011 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1012 | + $output = self::wrap(array( |
|
| 1013 | 1013 | 'content' => $output, |
| 1014 | 1014 | 'class' => $wrap_class, |
| 1015 | 1015 | 'element_require' => $args['element_require'], |
| 1016 | 1016 | 'argument_id' => $args['id'], |
| 1017 | 1017 | 'wrap_attributes' => $args['wrap_attributes'], |
| 1018 | - ) ); |
|
| 1018 | + )); |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | * |
| 1030 | 1030 | * @return string The rendered component. |
| 1031 | 1031 | */ |
| 1032 | - public static function radio( $args = array() ) { |
|
| 1032 | + public static function radio($args = array()) { |
|
| 1033 | 1033 | $defaults = array( |
| 1034 | 1034 | 'class' => '', |
| 1035 | 1035 | 'wrap_class' => '', |
@@ -1059,10 +1059,10 @@ discard block |
||
| 1059 | 1059 | /** |
| 1060 | 1060 | * Parse incoming $args into an array and merge it with $defaults |
| 1061 | 1061 | */ |
| 1062 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1062 | + $args = wp_parse_args($args, $defaults); |
|
| 1063 | 1063 | |
| 1064 | 1064 | // for now lets use horizontal for floating |
| 1065 | - if ( $args['label_type'] == 'floating' ) { |
|
| 1065 | + if ($args['label_type'] == 'floating') { |
|
| 1066 | 1066 | $args['label_type'] = 'horizontal'; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
@@ -1077,47 +1077,47 @@ discard block |
||
| 1077 | 1077 | |
| 1078 | 1078 | |
| 1079 | 1079 | // label before |
| 1080 | - if ( ! empty( $args['label'] ) ) { |
|
| 1081 | - $output .= self::label( $label_args, 'radio' ); |
|
| 1080 | + if (!empty($args['label'])) { |
|
| 1081 | + $output .= self::label($label_args, 'radio'); |
|
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | // maybe horizontal label |
| 1085 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 1086 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
| 1085 | + if ($args['label_type'] == 'horizontal') { |
|
| 1086 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
| 1087 | 1087 | $output .= '<div class="' . $input_col . '">'; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - if ( ! empty( $args['options'] ) ) { |
|
| 1090 | + if (!empty($args['options'])) { |
|
| 1091 | 1091 | $count = 0; |
| 1092 | - foreach ( $args['options'] as $value => $label ) { |
|
| 1092 | + foreach ($args['options'] as $value => $label) { |
|
| 1093 | 1093 | $option_args = $args; |
| 1094 | 1094 | $option_args['value'] = $value; |
| 1095 | 1095 | $option_args['label'] = $label; |
| 1096 | 1096 | $option_args['checked'] = $value == $args['value'] ? true : false; |
| 1097 | - $output .= self::radio_option( $option_args, $count ); |
|
| 1098 | - $count ++; |
|
| 1097 | + $output .= self::radio_option($option_args, $count); |
|
| 1098 | + $count++; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | // help text |
| 1103 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
| 1103 | + $help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : ''; |
|
| 1104 | 1104 | $output .= $help_text; |
| 1105 | 1105 | |
| 1106 | 1106 | // maybe horizontal label |
| 1107 | - if ( $args['label_type'] == 'horizontal' ) { |
|
| 1107 | + if ($args['label_type'] == 'horizontal') { |
|
| 1108 | 1108 | $output .= '</div>'; |
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | // wrap |
| 1112 | 1112 | $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
| 1113 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1114 | - $output = self::wrap( array( |
|
| 1113 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
| 1114 | + $output = self::wrap(array( |
|
| 1115 | 1115 | 'content' => $output, |
| 1116 | 1116 | 'class' => $wrap_class, |
| 1117 | 1117 | 'element_require' => $args['element_require'], |
| 1118 | 1118 | 'argument_id' => $args['id'], |
| 1119 | 1119 | 'wrap_attributes' => $args['wrap_attributes'], |
| 1120 | - ) ); |
|
| 1120 | + )); |
|
| 1121 | 1121 | |
| 1122 | 1122 | |
| 1123 | 1123 | return $output; |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | * |
| 1131 | 1131 | * @return string The rendered component. |
| 1132 | 1132 | */ |
| 1133 | - public static function radio_option( $args = array(), $count = '' ) { |
|
| 1133 | + public static function radio_option($args = array(), $count = '') { |
|
| 1134 | 1134 | $defaults = array( |
| 1135 | 1135 | 'class' => '', |
| 1136 | 1136 | 'id' => '', |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | /** |
| 1149 | 1149 | * Parse incoming $args into an array and merge it with $defaults |
| 1150 | 1150 | */ |
| 1151 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1151 | + $args = wp_parse_args($args, $defaults); |
|
| 1152 | 1152 | |
| 1153 | 1153 | $output = ''; |
| 1154 | 1154 | |
@@ -1159,43 +1159,43 @@ discard block |
||
| 1159 | 1159 | $output .= ' class="form-check-input" '; |
| 1160 | 1160 | |
| 1161 | 1161 | // name |
| 1162 | - if ( ! empty( $args['name'] ) ) { |
|
| 1163 | - $output .= AUI_Component_Helper::name( $args['name'] ); |
|
| 1162 | + if (!empty($args['name'])) { |
|
| 1163 | + $output .= AUI_Component_Helper::name($args['name']); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | // id |
| 1167 | - if ( ! empty( $args['id'] ) ) { |
|
| 1168 | - $output .= AUI_Component_Helper::id( $args['id'] . $count ); |
|
| 1167 | + if (!empty($args['id'])) { |
|
| 1168 | + $output .= AUI_Component_Helper::id($args['id'] . $count); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | // title |
| 1172 | - if ( ! empty( $args['title'] ) ) { |
|
| 1173 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
| 1172 | + if (!empty($args['title'])) { |
|
| 1173 | + $output .= AUI_Component_Helper::title($args['title']); |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | // value |
| 1177 | - if ( isset( $args['value'] ) ) { |
|
| 1178 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
| 1177 | + if (isset($args['value'])) { |
|
| 1178 | + $output .= AUI_Component_Helper::value($args['value']); |
|
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | // checked, for radio and checkboxes |
| 1182 | - if ( $args['checked'] ) { |
|
| 1182 | + if ($args['checked']) { |
|
| 1183 | 1183 | $output .= ' checked '; |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | // data-attributes |
| 1187 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
| 1187 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
| 1188 | 1188 | |
| 1189 | 1189 | // aria-attributes |
| 1190 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
| 1190 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
| 1191 | 1191 | |
| 1192 | 1192 | // extra attributes |
| 1193 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
| 1194 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
| 1193 | + if (!empty($args['extra_attributes'])) { |
|
| 1194 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | // required |
| 1198 | - if ( ! empty( $args['required'] ) ) { |
|
| 1198 | + if (!empty($args['required'])) { |
|
| 1199 | 1199 | $output .= ' required '; |
| 1200 | 1200 | } |
| 1201 | 1201 | |
@@ -1203,38 +1203,38 @@ discard block |
||
| 1203 | 1203 | $output .= ' >'; |
| 1204 | 1204 | |
| 1205 | 1205 | // label |
| 1206 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
| 1207 | - } elseif ( ! empty( $args['label'] ) ) { |
|
| 1208 | - $output .= self::label( array( |
|
| 1206 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
| 1207 | + } elseif (!empty($args['label'])) { |
|
| 1208 | + $output .= self::label(array( |
|
| 1209 | 1209 | 'title' => $args['label'], |
| 1210 | 1210 | 'for' => $args['id'] . $count, |
| 1211 | 1211 | 'class' => 'form-check-label' |
| 1212 | - ), 'radio' ); |
|
| 1212 | + ), 'radio'); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | // wrap |
| 1216 | - if ( ! $args['no_wrap'] ) { |
|
| 1216 | + if (!$args['no_wrap']) { |
|
| 1217 | 1217 | $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
| 1218 | 1218 | |
| 1219 | 1219 | // Unique wrap class |
| 1220 | 1220 | $uniq_class = 'fwrap'; |
| 1221 | - if ( ! empty( $args['name'] ) ) { |
|
| 1221 | + if (!empty($args['name'])) { |
|
| 1222 | 1222 | $uniq_class .= '-' . $args['name']; |
| 1223 | - } else if ( ! empty( $args['id'] ) ) { |
|
| 1223 | + } else if (!empty($args['id'])) { |
|
| 1224 | 1224 | $uniq_class .= '-' . $args['id']; |
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | - if ( isset( $args['value'] ) || $args['value'] !== "" ) { |
|
| 1227 | + if (isset($args['value']) || $args['value'] !== "") { |
|
| 1228 | 1228 | $uniq_class .= '-' . $args['value']; |
| 1229 | 1229 | } else { |
| 1230 | 1230 | $uniq_class .= '-' . $count; |
| 1231 | 1231 | } |
| 1232 | - $wrap_class .= ' ' . sanitize_html_class( $uniq_class ); |
|
| 1232 | + $wrap_class .= ' ' . sanitize_html_class($uniq_class); |
|
| 1233 | 1233 | |
| 1234 | - $output = self::wrap( array( |
|
| 1234 | + $output = self::wrap(array( |
|
| 1235 | 1235 | 'content' => $output, |
| 1236 | 1236 | 'class' => $wrap_class |
| 1237 | - ) ); |
|
| 1237 | + )); |
|
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | 1240 | return $output; |
@@ -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,273 +21,273 @@ 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.1.75'; |
|
| 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 = "4.5.3"; |
|
| 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 | - * Main AyeCode_UI_Settings Instance. |
|
| 93 | - * |
|
| 94 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 95 | - * |
|
| 96 | - * @since 1.0.0 |
|
| 97 | - * @static |
|
| 98 | - * @return AyeCode_UI_Settings - Main instance. |
|
| 99 | - */ |
|
| 100 | - public static function instance() { |
|
| 101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 102 | - |
|
| 103 | - self::$instance = new AyeCode_UI_Settings; |
|
| 104 | - |
|
| 105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 106 | - |
|
| 107 | - if ( is_admin() ) { |
|
| 108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 110 | - |
|
| 111 | - // Maybe show example page |
|
| 112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 113 | - } |
|
| 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.1.75'; |
|
| 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 = "4.5.3"; |
|
| 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 | + * Main AyeCode_UI_Settings Instance. |
|
| 93 | + * |
|
| 94 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 95 | + * |
|
| 96 | + * @since 1.0.0 |
|
| 97 | + * @static |
|
| 98 | + * @return AyeCode_UI_Settings - Main instance. |
|
| 99 | + */ |
|
| 100 | + public static function instance() { |
|
| 101 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 102 | + |
|
| 103 | + self::$instance = new AyeCode_UI_Settings; |
|
| 104 | + |
|
| 105 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 106 | + |
|
| 107 | + if ( is_admin() ) { |
|
| 108 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 109 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 110 | + |
|
| 111 | + // Maybe show example page |
|
| 112 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 115 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 116 | 116 | |
| 117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 118 | - } |
|
| 117 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - return self::$instance; |
|
| 121 | - } |
|
| 120 | + return self::$instance; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Setup some constants. |
|
| 125 | - */ |
|
| 126 | - public function constants(){ |
|
| 127 | - define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
| 128 | - define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
| 129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
| 130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
| 131 | - } |
|
| 123 | + /** |
|
| 124 | + * Setup some constants. |
|
| 125 | + */ |
|
| 126 | + public function constants(){ |
|
| 127 | + define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
| 128 | + define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
| 129 | + if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
| 130 | + if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Initiate the settings and add the required action hooks. |
|
| 135 | - */ |
|
| 136 | - public function init() { |
|
| 137 | - |
|
| 138 | - // Maybe fix settings |
|
| 139 | - if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 140 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 141 | - if ( ! empty( $db_settings ) ) { |
|
| 142 | - $db_settings['css_backend'] = 'compatibility'; |
|
| 143 | - $db_settings['js_backend'] = 'core-popper'; |
|
| 144 | - update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 145 | - wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 146 | - } |
|
| 147 | - } |
|
| 133 | + /** |
|
| 134 | + * Initiate the settings and add the required action hooks. |
|
| 135 | + */ |
|
| 136 | + public function init() { |
|
| 137 | + |
|
| 138 | + // Maybe fix settings |
|
| 139 | + if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 140 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 141 | + if ( ! empty( $db_settings ) ) { |
|
| 142 | + $db_settings['css_backend'] = 'compatibility'; |
|
| 143 | + $db_settings['js_backend'] = 'core-popper'; |
|
| 144 | + update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 145 | + wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - $this->constants(); |
|
| 150 | - $this->settings = $this->get_settings(); |
|
| 151 | - $this->url = $this->get_url(); |
|
| 149 | + $this->constants(); |
|
| 150 | + $this->settings = $this->get_settings(); |
|
| 151 | + $this->url = $this->get_url(); |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Maybe load CSS |
|
| 155 | + * |
|
| 156 | + * We load super early in case there is a theme version that might change the colors |
|
| 157 | + */ |
|
| 158 | + if ( $this->settings['css'] ) { |
|
| 159 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 160 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 161 | + } |
|
| 162 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 163 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 164 | + } |
|
| 152 | 165 | |
| 153 | - /** |
|
| 154 | - * Maybe load CSS |
|
| 155 | - * |
|
| 156 | - * We load super early in case there is a theme version that might change the colors |
|
| 157 | - */ |
|
| 158 | - if ( $this->settings['css'] ) { |
|
| 159 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 160 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 161 | - } |
|
| 162 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 163 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - // maybe load JS |
|
| 167 | - if ( $this->settings['js'] ) { |
|
| 168 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 169 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 170 | - } |
|
| 171 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 172 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - // Maybe set the HTML font size |
|
| 176 | - if ( $this->settings['html_font_size'] ) { |
|
| 177 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - // Maybe show backend style error |
|
| 181 | - if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 182 | - add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 183 | - } |
|
| 166 | + // maybe load JS |
|
| 167 | + if ( $this->settings['js'] ) { |
|
| 168 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 169 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 170 | + } |
|
| 171 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 172 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 173 | + } |
|
| 184 | 174 | |
| 185 | - } |
|
| 175 | + // Maybe set the HTML font size |
|
| 176 | + if ( $this->settings['html_font_size'] ) { |
|
| 177 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 178 | + } |
|
| 186 | 179 | |
| 187 | - /** |
|
| 188 | - * Show admin notice if backend scripts not loaded. |
|
| 189 | - */ |
|
| 190 | - public function show_admin_style_notice(){ |
|
| 191 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 192 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 193 | - $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 194 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>'; |
|
| 195 | - } |
|
| 180 | + // Maybe show backend style error |
|
| 181 | + if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 182 | + add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 183 | + } |
|
| 196 | 184 | |
| 197 | - /** |
|
| 198 | - * Check if we should load the admin scripts or not. |
|
| 199 | - * |
|
| 200 | - * @return bool |
|
| 201 | - */ |
|
| 202 | - public function load_admin_scripts(){ |
|
| 203 | - $result = true; |
|
| 204 | - |
|
| 205 | - // check if specifically disabled |
|
| 206 | - if(!empty($this->settings['disable_admin'])){ |
|
| 207 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 208 | - foreach($url_parts as $part){ |
|
| 209 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 210 | - return false; // return early, no point checking further |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 185 | + } |
|
| 214 | 186 | |
| 215 | - return $result; |
|
| 216 | - } |
|
| 187 | + /** |
|
| 188 | + * Show admin notice if backend scripts not loaded. |
|
| 189 | + */ |
|
| 190 | + public function show_admin_style_notice(){ |
|
| 191 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 192 | + $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 193 | + $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 194 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>'; |
|
| 195 | + } |
|
| 217 | 196 | |
| 218 | - /** |
|
| 219 | - * Add a html font size to the footer. |
|
| 220 | - */ |
|
| 221 | - public function html_font_size(){ |
|
| 222 | - $this->settings = $this->get_settings(); |
|
| 223 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 224 | - } |
|
| 197 | + /** |
|
| 198 | + * Check if we should load the admin scripts or not. |
|
| 199 | + * |
|
| 200 | + * @return bool |
|
| 201 | + */ |
|
| 202 | + public function load_admin_scripts(){ |
|
| 203 | + $result = true; |
|
| 204 | + |
|
| 205 | + // check if specifically disabled |
|
| 206 | + if(!empty($this->settings['disable_admin'])){ |
|
| 207 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 208 | + foreach($url_parts as $part){ |
|
| 209 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 210 | + return false; // return early, no point checking further |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + return $result; |
|
| 216 | + } |
|
| 225 | 217 | |
| 226 | - /** |
|
| 227 | - * Check if the current admin screen should load scripts. |
|
| 228 | - * |
|
| 229 | - * @return bool |
|
| 230 | - */ |
|
| 231 | - public function is_aui_screen(){ |
|
| 218 | + /** |
|
| 219 | + * Add a html font size to the footer. |
|
| 220 | + */ |
|
| 221 | + public function html_font_size(){ |
|
| 222 | + $this->settings = $this->get_settings(); |
|
| 223 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Check if the current admin screen should load scripts. |
|
| 228 | + * |
|
| 229 | + * @return bool |
|
| 230 | + */ |
|
| 231 | + public function is_aui_screen(){ |
|
| 232 | 232 | // echo '###';exit; |
| 233 | - $load = false; |
|
| 234 | - // check if we should load or not |
|
| 235 | - if ( is_admin() ) { |
|
| 236 | - // Only enable on set pages |
|
| 237 | - $aui_screens = array( |
|
| 238 | - 'page', |
|
| 239 | - 'post', |
|
| 240 | - 'settings_page_ayecode-ui-settings', |
|
| 241 | - 'appearance_page_gutenberg-widgets', |
|
| 242 | - 'widgets', |
|
| 243 | - 'ayecode-ui-settings', |
|
| 244 | - 'site-editor' |
|
| 245 | - ); |
|
| 246 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 247 | - |
|
| 248 | - $screen = get_current_screen(); |
|
| 233 | + $load = false; |
|
| 234 | + // check if we should load or not |
|
| 235 | + if ( is_admin() ) { |
|
| 236 | + // Only enable on set pages |
|
| 237 | + $aui_screens = array( |
|
| 238 | + 'page', |
|
| 239 | + 'post', |
|
| 240 | + 'settings_page_ayecode-ui-settings', |
|
| 241 | + 'appearance_page_gutenberg-widgets', |
|
| 242 | + 'widgets', |
|
| 243 | + 'ayecode-ui-settings', |
|
| 244 | + 'site-editor' |
|
| 245 | + ); |
|
| 246 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 247 | + |
|
| 248 | + $screen = get_current_screen(); |
|
| 249 | 249 | |
| 250 | 250 | // echo '###'.$screen->id; |
| 251 | 251 | |
| 252 | - // check if we are on a AUI screen |
|
| 253 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 254 | - $load = true; |
|
| 255 | - } |
|
| 252 | + // check if we are on a AUI screen |
|
| 253 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 254 | + $load = true; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - //load for widget previews in WP 5.8 |
|
| 258 | - if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 259 | - $load = true; |
|
| 260 | - } |
|
| 261 | - } |
|
| 257 | + //load for widget previews in WP 5.8 |
|
| 258 | + if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 259 | + $load = true; |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 264 | - } |
|
| 263 | + return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - /** |
|
| 267 | - * Adds the styles. |
|
| 268 | - */ |
|
| 269 | - public function enqueue_style() { |
|
| 266 | + /** |
|
| 267 | + * Adds the styles. |
|
| 268 | + */ |
|
| 269 | + public function enqueue_style() { |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 273 | - // don't add wp-admin scripts if not requested to |
|
| 274 | - }else{ |
|
| 275 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 272 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 273 | + // don't add wp-admin scripts if not requested to |
|
| 274 | + }else{ |
|
| 275 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 276 | 276 | |
| 277 | - $rtl = is_rtl() ? '-rtl' : ''; |
|
| 277 | + $rtl = is_rtl() ? '-rtl' : ''; |
|
| 278 | 278 | |
| 279 | - if($this->settings[$css_setting]){ |
|
| 280 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 281 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 282 | - wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 283 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 279 | + if($this->settings[$css_setting]){ |
|
| 280 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 281 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 282 | + wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 283 | + wp_enqueue_style( 'ayecode-ui' ); |
|
| 284 | 284 | |
| 285 | - // flatpickr |
|
| 286 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version ); |
|
| 285 | + // flatpickr |
|
| 286 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version ); |
|
| 287 | 287 | |
| 288 | - // fix some wp-admin issues |
|
| 289 | - if(is_admin()){ |
|
| 290 | - $custom_css = " |
|
| 288 | + // fix some wp-admin issues |
|
| 289 | + if(is_admin()){ |
|
| 290 | + $custom_css = " |
|
| 291 | 291 | body{ |
| 292 | 292 | background-color: #f1f1f1; |
| 293 | 293 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -333,35 +333,35 @@ discard block |
||
| 333 | 333 | } |
| 334 | 334 | "; |
| 335 | 335 | |
| 336 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 337 | - $custom_css .= " |
|
| 336 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 337 | + $custom_css .= " |
|
| 338 | 338 | .edit-post-sidebar input[type=color].components-text-control__input{ |
| 339 | 339 | padding: 0; |
| 340 | 340 | } |
| 341 | 341 | "; |
| 342 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 343 | - } |
|
| 342 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - // custom changes |
|
| 346 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 345 | + // custom changes |
|
| 346 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 347 | 347 | |
| 348 | - } |
|
| 349 | - } |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | 351 | |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - /** |
|
| 355 | - * Get inline script used if bootstrap enqueued |
|
| 356 | - * |
|
| 357 | - * If this remains small then its best to use this than to add another JS file. |
|
| 358 | - */ |
|
| 359 | - public function inline_script() { |
|
| 360 | - // Flatpickr calendar locale |
|
| 361 | - $flatpickr_locale = self::flatpickr_locale(); |
|
| 362 | - |
|
| 363 | - ob_start(); |
|
| 364 | - ?> |
|
| 354 | + /** |
|
| 355 | + * Get inline script used if bootstrap enqueued |
|
| 356 | + * |
|
| 357 | + * If this remains small then its best to use this than to add another JS file. |
|
| 358 | + */ |
|
| 359 | + public function inline_script() { |
|
| 360 | + // Flatpickr calendar locale |
|
| 361 | + $flatpickr_locale = self::flatpickr_locale(); |
|
| 362 | + |
|
| 363 | + ob_start(); |
|
| 364 | + ?> |
|
| 365 | 365 | <script> |
| 366 | 366 | /** |
| 367 | 367 | * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ). |
@@ -1266,29 +1266,29 @@ discard block |
||
| 1266 | 1266 | aui_set_data_scroll(); |
| 1267 | 1267 | </script> |
| 1268 | 1268 | <?php |
| 1269 | - $output = ob_get_clean(); |
|
| 1269 | + $output = ob_get_clean(); |
|
| 1270 | 1270 | |
| 1271 | 1271 | |
| 1272 | 1272 | |
| 1273 | - /* |
|
| 1273 | + /* |
|
| 1274 | 1274 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1275 | 1275 | */ |
| 1276 | - return str_replace( array( |
|
| 1277 | - '<script>', |
|
| 1278 | - '</script>' |
|
| 1279 | - ), '', self::minify_js($output) ); |
|
| 1280 | - } |
|
| 1276 | + return str_replace( array( |
|
| 1277 | + '<script>', |
|
| 1278 | + '</script>' |
|
| 1279 | + ), '', self::minify_js($output) ); |
|
| 1280 | + } |
|
| 1281 | 1281 | |
| 1282 | 1282 | |
| 1283 | - /** |
|
| 1284 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1285 | - * |
|
| 1286 | - * @TODO we may need this when other conflicts arrise. |
|
| 1287 | - * @return mixed |
|
| 1288 | - */ |
|
| 1289 | - public static function bs3_compat_js() { |
|
| 1290 | - ob_start(); |
|
| 1291 | - ?> |
|
| 1283 | + /** |
|
| 1284 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1285 | + * |
|
| 1286 | + * @TODO we may need this when other conflicts arrise. |
|
| 1287 | + * @return mixed |
|
| 1288 | + */ |
|
| 1289 | + public static function bs3_compat_js() { |
|
| 1290 | + ob_start(); |
|
| 1291 | + ?> |
|
| 1292 | 1292 | <script> |
| 1293 | 1293 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
| 1294 | 1294 | /* With Avada builder */ |
@@ -1296,20 +1296,20 @@ discard block |
||
| 1296 | 1296 | <?php } ?> |
| 1297 | 1297 | </script> |
| 1298 | 1298 | <?php |
| 1299 | - return str_replace( array( |
|
| 1300 | - '<script>', |
|
| 1301 | - '</script>' |
|
| 1302 | - ), '', ob_get_clean()); |
|
| 1303 | - } |
|
| 1299 | + return str_replace( array( |
|
| 1300 | + '<script>', |
|
| 1301 | + '</script>' |
|
| 1302 | + ), '', ob_get_clean()); |
|
| 1303 | + } |
|
| 1304 | 1304 | |
| 1305 | - /** |
|
| 1306 | - * Get inline script used if bootstrap file browser enqueued. |
|
| 1307 | - * |
|
| 1308 | - * If this remains small then its best to use this than to add another JS file. |
|
| 1309 | - */ |
|
| 1310 | - public function inline_script_file_browser(){ |
|
| 1311 | - ob_start(); |
|
| 1312 | - ?> |
|
| 1305 | + /** |
|
| 1306 | + * Get inline script used if bootstrap file browser enqueued. |
|
| 1307 | + * |
|
| 1308 | + * If this remains small then its best to use this than to add another JS file. |
|
| 1309 | + */ |
|
| 1310 | + public function inline_script_file_browser(){ |
|
| 1311 | + ob_start(); |
|
| 1312 | + ?> |
|
| 1313 | 1313 | <script> |
| 1314 | 1314 | // run on doc ready |
| 1315 | 1315 | jQuery(document).ready(function () { |
@@ -1317,224 +1317,224 @@ discard block |
||
| 1317 | 1317 | }); |
| 1318 | 1318 | </script> |
| 1319 | 1319 | <?php |
| 1320 | - $output = ob_get_clean(); |
|
| 1320 | + $output = ob_get_clean(); |
|
| 1321 | 1321 | |
| 1322 | - /* |
|
| 1322 | + /* |
|
| 1323 | 1323 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1324 | 1324 | */ |
| 1325 | - return str_replace( array( |
|
| 1326 | - '<script>', |
|
| 1327 | - '</script>' |
|
| 1328 | - ), '', $output ); |
|
| 1329 | - } |
|
| 1325 | + return str_replace( array( |
|
| 1326 | + '<script>', |
|
| 1327 | + '</script>' |
|
| 1328 | + ), '', $output ); |
|
| 1329 | + } |
|
| 1330 | 1330 | |
| 1331 | - /** |
|
| 1332 | - * Adds the Font Awesome JS. |
|
| 1333 | - */ |
|
| 1334 | - public function enqueue_scripts() { |
|
| 1331 | + /** |
|
| 1332 | + * Adds the Font Awesome JS. |
|
| 1333 | + */ |
|
| 1334 | + public function enqueue_scripts() { |
|
| 1335 | 1335 | |
| 1336 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 1337 | - // don't add wp-admin scripts if not requested to |
|
| 1338 | - }else { |
|
| 1336 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 1337 | + // don't add wp-admin scripts if not requested to |
|
| 1338 | + }else { |
|
| 1339 | 1339 | |
| 1340 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 1340 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 1341 | 1341 | |
| 1342 | - // select2 |
|
| 1343 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1342 | + // select2 |
|
| 1343 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1344 | 1344 | |
| 1345 | - // flatpickr |
|
| 1346 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 1345 | + // flatpickr |
|
| 1346 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 1347 | 1347 | |
| 1348 | - // flatpickr |
|
| 1349 | - wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 1348 | + // flatpickr |
|
| 1349 | + wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 1350 | 1350 | |
| 1351 | - // Bootstrap file browser |
|
| 1352 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1353 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1354 | - |
|
| 1355 | - $load_inline = false; |
|
| 1356 | - |
|
| 1357 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1358 | - // Bootstrap bundle |
|
| 1359 | - $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 1360 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1361 | - 'select2', |
|
| 1362 | - 'jquery' |
|
| 1363 | - ), $this->version, $this->is_bs3_compat() ); |
|
| 1364 | - // if in admin then add to footer for compatibility. |
|
| 1365 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1366 | - $script = $this->inline_script(); |
|
| 1367 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1368 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1369 | - $url = $this->url . 'assets/js/popper.min.js'; |
|
| 1370 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 1371 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1372 | - $load_inline = true; |
|
| 1373 | - } else { |
|
| 1374 | - $load_inline = true; |
|
| 1375 | - } |
|
| 1351 | + // Bootstrap file browser |
|
| 1352 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1353 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1354 | + |
|
| 1355 | + $load_inline = false; |
|
| 1356 | + |
|
| 1357 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1358 | + // Bootstrap bundle |
|
| 1359 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 1360 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1361 | + 'select2', |
|
| 1362 | + 'jquery' |
|
| 1363 | + ), $this->version, $this->is_bs3_compat() ); |
|
| 1364 | + // if in admin then add to footer for compatibility. |
|
| 1365 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1366 | + $script = $this->inline_script(); |
|
| 1367 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1368 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1369 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
| 1370 | + wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 1371 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1372 | + $load_inline = true; |
|
| 1373 | + } else { |
|
| 1374 | + $load_inline = true; |
|
| 1375 | + } |
|
| 1376 | 1376 | |
| 1377 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 1378 | - if ( $load_inline ) { |
|
| 1379 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1380 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1381 | - $script = $this->inline_script(); |
|
| 1382 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1383 | - } |
|
| 1384 | - } |
|
| 1377 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 1378 | + if ( $load_inline ) { |
|
| 1379 | + wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1380 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1381 | + $script = $this->inline_script(); |
|
| 1382 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1383 | + } |
|
| 1384 | + } |
|
| 1385 | 1385 | |
| 1386 | - } |
|
| 1386 | + } |
|
| 1387 | 1387 | |
| 1388 | - /** |
|
| 1389 | - * Enqueue flatpickr if called. |
|
| 1390 | - */ |
|
| 1391 | - public function enqueue_flatpickr(){ |
|
| 1392 | - wp_enqueue_style( 'flatpickr' ); |
|
| 1393 | - wp_enqueue_script( 'flatpickr' ); |
|
| 1394 | - } |
|
| 1388 | + /** |
|
| 1389 | + * Enqueue flatpickr if called. |
|
| 1390 | + */ |
|
| 1391 | + public function enqueue_flatpickr(){ |
|
| 1392 | + wp_enqueue_style( 'flatpickr' ); |
|
| 1393 | + wp_enqueue_script( 'flatpickr' ); |
|
| 1394 | + } |
|
| 1395 | 1395 | |
| 1396 | - /** |
|
| 1397 | - * Enqueue iconpicker if called. |
|
| 1398 | - */ |
|
| 1399 | - public function enqueue_iconpicker(){ |
|
| 1400 | - wp_enqueue_style( 'iconpicker' ); |
|
| 1401 | - wp_enqueue_script( 'iconpicker' ); |
|
| 1402 | - } |
|
| 1396 | + /** |
|
| 1397 | + * Enqueue iconpicker if called. |
|
| 1398 | + */ |
|
| 1399 | + public function enqueue_iconpicker(){ |
|
| 1400 | + wp_enqueue_style( 'iconpicker' ); |
|
| 1401 | + wp_enqueue_script( 'iconpicker' ); |
|
| 1402 | + } |
|
| 1403 | 1403 | |
| 1404 | - /** |
|
| 1405 | - * Get the url path to the current folder. |
|
| 1406 | - * |
|
| 1407 | - * @return string |
|
| 1408 | - */ |
|
| 1409 | - public function get_url() { |
|
| 1410 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1411 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1412 | - |
|
| 1413 | - // Replace http:// to https://. |
|
| 1414 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1415 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1416 | - } |
|
| 1417 | - |
|
| 1418 | - // Check if we are inside a plugin |
|
| 1419 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1420 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1421 | - |
|
| 1422 | - return trailingslashit( $url ); |
|
| 1423 | - } |
|
| 1404 | + /** |
|
| 1405 | + * Get the url path to the current folder. |
|
| 1406 | + * |
|
| 1407 | + * @return string |
|
| 1408 | + */ |
|
| 1409 | + public function get_url() { |
|
| 1410 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1411 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1412 | + |
|
| 1413 | + // Replace http:// to https://. |
|
| 1414 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1415 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1416 | + } |
|
| 1424 | 1417 | |
| 1425 | - /** |
|
| 1426 | - * Get the url path to the current folder. |
|
| 1427 | - * |
|
| 1428 | - * @return string |
|
| 1429 | - */ |
|
| 1430 | - public function get_url_old() { |
|
| 1418 | + // Check if we are inside a plugin |
|
| 1419 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1420 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1431 | 1421 | |
| 1432 | - $url = ''; |
|
| 1433 | - // check if we are inside a plugin |
|
| 1434 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1422 | + return trailingslashit( $url ); |
|
| 1423 | + } |
|
| 1435 | 1424 | |
| 1436 | - // add check in-case user has changed wp-content dir name. |
|
| 1437 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 1438 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1439 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1425 | + /** |
|
| 1426 | + * Get the url path to the current folder. |
|
| 1427 | + * |
|
| 1428 | + * @return string |
|
| 1429 | + */ |
|
| 1430 | + public function get_url_old() { |
|
| 1440 | 1431 | |
| 1441 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1442 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1443 | - } |
|
| 1432 | + $url = ''; |
|
| 1433 | + // check if we are inside a plugin |
|
| 1434 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1444 | 1435 | |
| 1445 | - return $url; |
|
| 1446 | - } |
|
| 1436 | + // add check in-case user has changed wp-content dir name. |
|
| 1437 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 1438 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1439 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1447 | 1440 | |
| 1448 | - /** |
|
| 1449 | - * Register the database settings with WordPress. |
|
| 1450 | - */ |
|
| 1451 | - public function register_settings() { |
|
| 1452 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1453 | - } |
|
| 1441 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1442 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1443 | + } |
|
| 1454 | 1444 | |
| 1455 | - /** |
|
| 1456 | - * Add the WordPress settings menu item. |
|
| 1457 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 1458 | - */ |
|
| 1459 | - public function menu_item() { |
|
| 1460 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 1461 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1462 | - $this, |
|
| 1463 | - 'settings_page' |
|
| 1464 | - ) ); |
|
| 1465 | - } |
|
| 1445 | + return $url; |
|
| 1446 | + } |
|
| 1466 | 1447 | |
| 1467 | - /** |
|
| 1468 | - * Get a list of themes and their default JS settings. |
|
| 1469 | - * |
|
| 1470 | - * @return array |
|
| 1471 | - */ |
|
| 1472 | - public function theme_js_settings(){ |
|
| 1473 | - return array( |
|
| 1474 | - 'ayetheme' => 'popper', |
|
| 1475 | - 'listimia' => 'required', |
|
| 1476 | - 'listimia_backend' => 'core-popper', |
|
| 1477 | - //'avada' => 'required', // removed as we now add compatibility |
|
| 1478 | - ); |
|
| 1479 | - } |
|
| 1448 | + /** |
|
| 1449 | + * Register the database settings with WordPress. |
|
| 1450 | + */ |
|
| 1451 | + public function register_settings() { |
|
| 1452 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1453 | + } |
|
| 1480 | 1454 | |
| 1481 | - /** |
|
| 1482 | - * Get the current Font Awesome output settings. |
|
| 1483 | - * |
|
| 1484 | - * @return array The array of settings. |
|
| 1485 | - */ |
|
| 1486 | - public function get_settings() { |
|
| 1487 | - |
|
| 1488 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1489 | - $js_default = 'core-popper'; |
|
| 1490 | - $js_default_backend = $js_default; |
|
| 1491 | - |
|
| 1492 | - // maybe set defaults (if no settings set) |
|
| 1493 | - if(empty($db_settings)){ |
|
| 1494 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1495 | - $theme_js_settings = self::theme_js_settings(); |
|
| 1496 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 1497 | - $js_default = $theme_js_settings[$active_theme]; |
|
| 1498 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1499 | - } |
|
| 1500 | - } |
|
| 1501 | - |
|
| 1502 | - $defaults = array( |
|
| 1503 | - 'css' => 'compatibility', // core, compatibility |
|
| 1504 | - 'js' => $js_default, // js to load, core-popper, popper |
|
| 1505 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 1506 | - 'css_backend' => 'compatibility', // core, compatibility |
|
| 1507 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 1508 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 1509 | - ); |
|
| 1510 | - |
|
| 1511 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1512 | - |
|
| 1513 | - /** |
|
| 1514 | - * Filter the Bootstrap settings. |
|
| 1515 | - * |
|
| 1516 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 1517 | - */ |
|
| 1518 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1519 | - } |
|
| 1455 | + /** |
|
| 1456 | + * Add the WordPress settings menu item. |
|
| 1457 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 1458 | + */ |
|
| 1459 | + public function menu_item() { |
|
| 1460 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 1461 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1462 | + $this, |
|
| 1463 | + 'settings_page' |
|
| 1464 | + ) ); |
|
| 1465 | + } |
|
| 1520 | 1466 | |
| 1467 | + /** |
|
| 1468 | + * Get a list of themes and their default JS settings. |
|
| 1469 | + * |
|
| 1470 | + * @return array |
|
| 1471 | + */ |
|
| 1472 | + public function theme_js_settings(){ |
|
| 1473 | + return array( |
|
| 1474 | + 'ayetheme' => 'popper', |
|
| 1475 | + 'listimia' => 'required', |
|
| 1476 | + 'listimia_backend' => 'core-popper', |
|
| 1477 | + //'avada' => 'required', // removed as we now add compatibility |
|
| 1478 | + ); |
|
| 1479 | + } |
|
| 1521 | 1480 | |
| 1522 | - /** |
|
| 1523 | - * The settings page html output. |
|
| 1524 | - */ |
|
| 1525 | - public function settings_page() { |
|
| 1526 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1527 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1528 | - } |
|
| 1529 | - ?> |
|
| 1481 | + /** |
|
| 1482 | + * Get the current Font Awesome output settings. |
|
| 1483 | + * |
|
| 1484 | + * @return array The array of settings. |
|
| 1485 | + */ |
|
| 1486 | + public function get_settings() { |
|
| 1487 | + |
|
| 1488 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1489 | + $js_default = 'core-popper'; |
|
| 1490 | + $js_default_backend = $js_default; |
|
| 1491 | + |
|
| 1492 | + // maybe set defaults (if no settings set) |
|
| 1493 | + if(empty($db_settings)){ |
|
| 1494 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1495 | + $theme_js_settings = self::theme_js_settings(); |
|
| 1496 | + if(isset($theme_js_settings[$active_theme])){ |
|
| 1497 | + $js_default = $theme_js_settings[$active_theme]; |
|
| 1498 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1499 | + } |
|
| 1500 | + } |
|
| 1501 | + |
|
| 1502 | + $defaults = array( |
|
| 1503 | + 'css' => 'compatibility', // core, compatibility |
|
| 1504 | + 'js' => $js_default, // js to load, core-popper, popper |
|
| 1505 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 1506 | + 'css_backend' => 'compatibility', // core, compatibility |
|
| 1507 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 1508 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 1509 | + ); |
|
| 1510 | + |
|
| 1511 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1512 | + |
|
| 1513 | + /** |
|
| 1514 | + * Filter the Bootstrap settings. |
|
| 1515 | + * |
|
| 1516 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 1517 | + */ |
|
| 1518 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1519 | + } |
|
| 1520 | + |
|
| 1521 | + |
|
| 1522 | + /** |
|
| 1523 | + * The settings page html output. |
|
| 1524 | + */ |
|
| 1525 | + public function settings_page() { |
|
| 1526 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1527 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1528 | + } |
|
| 1529 | + ?> |
|
| 1530 | 1530 | <div class="wrap"> |
| 1531 | 1531 | <h1><?php echo $this->name; ?></h1> |
| 1532 | 1532 | <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
| 1533 | 1533 | <form method="post" action="options.php"> |
| 1534 | 1534 | <?php |
| 1535 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 1536 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1537 | - ?> |
|
| 1535 | + settings_fields( 'ayecode-ui-settings' ); |
|
| 1536 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1537 | + ?> |
|
| 1538 | 1538 | |
| 1539 | 1539 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
| 1540 | 1540 | <table class="form-table wpbs-table-settings"> |
@@ -1614,60 +1614,60 @@ discard block |
||
| 1614 | 1614 | </table> |
| 1615 | 1615 | |
| 1616 | 1616 | <?php |
| 1617 | - submit_button(); |
|
| 1618 | - ?> |
|
| 1617 | + submit_button(); |
|
| 1618 | + ?> |
|
| 1619 | 1619 | </form> |
| 1620 | 1620 | |
| 1621 | 1621 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
| 1622 | 1622 | </div> |
| 1623 | 1623 | |
| 1624 | 1624 | <?php |
| 1625 | - } |
|
| 1625 | + } |
|
| 1626 | 1626 | |
| 1627 | - public function customizer_settings($wp_customize){ |
|
| 1628 | - $wp_customize->add_section('aui_settings', array( |
|
| 1629 | - 'title' => __('AyeCode UI','aui'), |
|
| 1630 | - 'priority' => 120, |
|
| 1631 | - )); |
|
| 1632 | - |
|
| 1633 | - // ============================= |
|
| 1634 | - // = Color Picker = |
|
| 1635 | - // ============================= |
|
| 1636 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1637 | - 'default' => AUI_PRIMARY_COLOR, |
|
| 1638 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1639 | - 'capability' => 'edit_theme_options', |
|
| 1640 | - 'type' => 'option', |
|
| 1641 | - 'transport' => 'refresh', |
|
| 1642 | - )); |
|
| 1643 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1644 | - 'label' => __('Primary Color','aui'), |
|
| 1645 | - 'section' => 'aui_settings', |
|
| 1646 | - 'settings' => 'aui_options[color_primary]', |
|
| 1647 | - ))); |
|
| 1648 | - |
|
| 1649 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1650 | - 'default' => '#6c757d', |
|
| 1651 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1652 | - 'capability' => 'edit_theme_options', |
|
| 1653 | - 'type' => 'option', |
|
| 1654 | - 'transport' => 'refresh', |
|
| 1655 | - )); |
|
| 1656 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1657 | - 'label' => __('Secondary Color','aui'), |
|
| 1658 | - 'section' => 'aui_settings', |
|
| 1659 | - 'settings' => 'aui_options[color_secondary]', |
|
| 1660 | - ))); |
|
| 1661 | - } |
|
| 1627 | + public function customizer_settings($wp_customize){ |
|
| 1628 | + $wp_customize->add_section('aui_settings', array( |
|
| 1629 | + 'title' => __('AyeCode UI','aui'), |
|
| 1630 | + 'priority' => 120, |
|
| 1631 | + )); |
|
| 1632 | + |
|
| 1633 | + // ============================= |
|
| 1634 | + // = Color Picker = |
|
| 1635 | + // ============================= |
|
| 1636 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1637 | + 'default' => AUI_PRIMARY_COLOR, |
|
| 1638 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1639 | + 'capability' => 'edit_theme_options', |
|
| 1640 | + 'type' => 'option', |
|
| 1641 | + 'transport' => 'refresh', |
|
| 1642 | + )); |
|
| 1643 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1644 | + 'label' => __('Primary Color','aui'), |
|
| 1645 | + 'section' => 'aui_settings', |
|
| 1646 | + 'settings' => 'aui_options[color_primary]', |
|
| 1647 | + ))); |
|
| 1648 | + |
|
| 1649 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1650 | + 'default' => '#6c757d', |
|
| 1651 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1652 | + 'capability' => 'edit_theme_options', |
|
| 1653 | + 'type' => 'option', |
|
| 1654 | + 'transport' => 'refresh', |
|
| 1655 | + )); |
|
| 1656 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1657 | + 'label' => __('Secondary Color','aui'), |
|
| 1658 | + 'section' => 'aui_settings', |
|
| 1659 | + 'settings' => 'aui_options[color_secondary]', |
|
| 1660 | + ))); |
|
| 1661 | + } |
|
| 1662 | 1662 | |
| 1663 | - /** |
|
| 1664 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1665 | - * |
|
| 1666 | - * @return mixed |
|
| 1667 | - */ |
|
| 1668 | - public static function bs3_compat_css() { |
|
| 1669 | - ob_start(); |
|
| 1670 | - ?> |
|
| 1663 | + /** |
|
| 1664 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1665 | + * |
|
| 1666 | + * @return mixed |
|
| 1667 | + */ |
|
| 1668 | + public static function bs3_compat_css() { |
|
| 1669 | + ob_start(); |
|
| 1670 | + ?> |
|
| 1671 | 1671 | <style> |
| 1672 | 1672 | /* Bootstrap 3 compatibility */ |
| 1673 | 1673 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1696,583 +1696,583 @@ discard block |
||
| 1696 | 1696 | <?php } ?> |
| 1697 | 1697 | </style> |
| 1698 | 1698 | <?php |
| 1699 | - return str_replace( array( |
|
| 1700 | - '<style>', |
|
| 1701 | - '</style>' |
|
| 1702 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1703 | - } |
|
| 1699 | + return str_replace( array( |
|
| 1700 | + '<style>', |
|
| 1701 | + '</style>' |
|
| 1702 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1703 | + } |
|
| 1704 | 1704 | |
| 1705 | 1705 | |
| 1706 | - public static function custom_css($compatibility = true) { |
|
| 1707 | - $settings = get_option('aui_options'); |
|
| 1706 | + public static function custom_css($compatibility = true) { |
|
| 1707 | + $settings = get_option('aui_options'); |
|
| 1708 | 1708 | |
| 1709 | - ob_start(); |
|
| 1709 | + ob_start(); |
|
| 1710 | 1710 | |
| 1711 | - $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
| 1712 | - $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
| 1713 | - //AUI_PRIMARY_COLOR_ORIGINAL |
|
| 1714 | - ?> |
|
| 1711 | + $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
| 1712 | + $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
| 1713 | + //AUI_PRIMARY_COLOR_ORIGINAL |
|
| 1714 | + ?> |
|
| 1715 | 1715 | <style> |
| 1716 | 1716 | <?php |
| 1717 | 1717 | |
| 1718 | - // BS v3 compat |
|
| 1719 | - if( self::is_bs3_compat() ){ |
|
| 1720 | - echo self::bs3_compat_css(); |
|
| 1721 | - } |
|
| 1718 | + // BS v3 compat |
|
| 1719 | + if( self::is_bs3_compat() ){ |
|
| 1720 | + echo self::bs3_compat_css(); |
|
| 1721 | + } |
|
| 1722 | 1722 | |
| 1723 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
| 1724 | - echo self::css_primary($primary_color,$compatibility); |
|
| 1725 | - } |
|
| 1723 | + if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
| 1724 | + echo self::css_primary($primary_color,$compatibility); |
|
| 1725 | + } |
|
| 1726 | 1726 | |
| 1727 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
| 1728 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 1729 | - } |
|
| 1727 | + if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
| 1728 | + echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 1729 | + } |
|
| 1730 | 1730 | |
| 1731 | - // Set admin bar z-index lower when modal is open. |
|
| 1732 | - echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1731 | + // Set admin bar z-index lower when modal is open. |
|
| 1732 | + echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1733 | 1733 | |
| 1734 | - if(is_admin()){ |
|
| 1735 | - echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1736 | - } |
|
| 1734 | + if(is_admin()){ |
|
| 1735 | + echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1736 | + } |
|
| 1737 | 1737 | ?> |
| 1738 | 1738 | </style> |
| 1739 | 1739 | <?php |
| 1740 | 1740 | |
| 1741 | 1741 | |
| 1742 | - /* |
|
| 1742 | + /* |
|
| 1743 | 1743 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1744 | 1744 | */ |
| 1745 | - return str_replace( array( |
|
| 1746 | - '<style>', |
|
| 1747 | - '</style>' |
|
| 1748 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1749 | - } |
|
| 1745 | + return str_replace( array( |
|
| 1746 | + '<style>', |
|
| 1747 | + '</style>' |
|
| 1748 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1749 | + } |
|
| 1750 | 1750 | |
| 1751 | - /** |
|
| 1752 | - * Check if we should add booststrap 3 compatibility changes. |
|
| 1753 | - * |
|
| 1754 | - * @return bool |
|
| 1755 | - */ |
|
| 1756 | - public static function is_bs3_compat(){ |
|
| 1757 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1758 | - } |
|
| 1751 | + /** |
|
| 1752 | + * Check if we should add booststrap 3 compatibility changes. |
|
| 1753 | + * |
|
| 1754 | + * @return bool |
|
| 1755 | + */ |
|
| 1756 | + public static function is_bs3_compat(){ |
|
| 1757 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1758 | + } |
|
| 1759 | 1759 | |
| 1760 | - public static function css_primary($color_code,$compatibility){; |
|
| 1761 | - $color_code = sanitize_hex_color($color_code); |
|
| 1762 | - if(!$color_code){return '';} |
|
| 1763 | - /** |
|
| 1764 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1765 | - */ |
|
| 1766 | - $selectors = array( |
|
| 1767 | - 'a' => array('c'), |
|
| 1768 | - '.btn-primary' => array('b','o'), |
|
| 1769 | - '.btn-primary.disabled' => array('b','o'), |
|
| 1770 | - '.btn-primary:disabled' => array('b','o'), |
|
| 1771 | - '.btn-outline-primary' => array('c','o'), |
|
| 1772 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 1773 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1774 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1775 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1776 | - '.btn-link' => array('c'), |
|
| 1777 | - '.dropdown-item.active' => array('b'), |
|
| 1778 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1779 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1760 | + public static function css_primary($color_code,$compatibility){; |
|
| 1761 | + $color_code = sanitize_hex_color($color_code); |
|
| 1762 | + if(!$color_code){return '';} |
|
| 1763 | + /** |
|
| 1764 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1765 | + */ |
|
| 1766 | + $selectors = array( |
|
| 1767 | + 'a' => array('c'), |
|
| 1768 | + '.btn-primary' => array('b','o'), |
|
| 1769 | + '.btn-primary.disabled' => array('b','o'), |
|
| 1770 | + '.btn-primary:disabled' => array('b','o'), |
|
| 1771 | + '.btn-outline-primary' => array('c','o'), |
|
| 1772 | + '.btn-outline-primary:hover' => array('b','o'), |
|
| 1773 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1774 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1775 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1776 | + '.btn-link' => array('c'), |
|
| 1777 | + '.dropdown-item.active' => array('b'), |
|
| 1778 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1779 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1780 | 1780 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1781 | 1781 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1782 | 1782 | // '.custom-range::-ms-thumb' => array('b'), |
| 1783 | - '.nav-pills .nav-link.active' => array('b'), |
|
| 1784 | - '.nav-pills .show>.nav-link' => array('b'), |
|
| 1785 | - '.page-link' => array('c'), |
|
| 1786 | - '.page-item.active .page-link' => array('b','o'), |
|
| 1787 | - '.badge-primary' => array('b'), |
|
| 1788 | - '.alert-primary' => array('b','o'), |
|
| 1789 | - '.progress-bar' => array('b'), |
|
| 1790 | - '.list-group-item.active' => array('b','o'), |
|
| 1791 | - '.bg-primary' => array('b','f'), |
|
| 1792 | - '.btn-link.btn-primary' => array('c'), |
|
| 1793 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1794 | - ); |
|
| 1795 | - |
|
| 1796 | - $important_selectors = array( |
|
| 1797 | - '.bg-primary' => array('b','f'), |
|
| 1798 | - '.border-primary' => array('o'), |
|
| 1799 | - '.text-primary' => array('c'), |
|
| 1800 | - ); |
|
| 1801 | - |
|
| 1802 | - $color = array(); |
|
| 1803 | - $color_i = array(); |
|
| 1804 | - $background = array(); |
|
| 1805 | - $background_i = array(); |
|
| 1806 | - $border = array(); |
|
| 1807 | - $border_i = array(); |
|
| 1808 | - $fill = array(); |
|
| 1809 | - $fill_i = array(); |
|
| 1810 | - |
|
| 1811 | - $output = ''; |
|
| 1812 | - |
|
| 1813 | - // build rules into each type |
|
| 1814 | - foreach($selectors as $selector => $types){ |
|
| 1815 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1816 | - $types = array_combine($types,$types); |
|
| 1817 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1818 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1819 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1820 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1821 | - } |
|
| 1822 | - |
|
| 1823 | - // build rules into each type |
|
| 1824 | - foreach($important_selectors as $selector => $types){ |
|
| 1825 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1826 | - $types = array_combine($types,$types); |
|
| 1827 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1828 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1829 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1830 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1831 | - } |
|
| 1832 | - |
|
| 1833 | - // add any color rules |
|
| 1834 | - if(!empty($color)){ |
|
| 1835 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1836 | - } |
|
| 1837 | - if(!empty($color_i)){ |
|
| 1838 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1839 | - } |
|
| 1840 | - |
|
| 1841 | - // add any background color rules |
|
| 1842 | - if(!empty($background)){ |
|
| 1843 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1844 | - } |
|
| 1845 | - if(!empty($background_i)){ |
|
| 1846 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1847 | - } |
|
| 1848 | - |
|
| 1849 | - // add any border color rules |
|
| 1850 | - if(!empty($border)){ |
|
| 1851 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1852 | - } |
|
| 1853 | - if(!empty($border_i)){ |
|
| 1854 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1855 | - } |
|
| 1856 | - |
|
| 1857 | - // add any fill color rules |
|
| 1858 | - if(!empty($fill)){ |
|
| 1859 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1860 | - } |
|
| 1861 | - if(!empty($fill_i)){ |
|
| 1862 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1863 | - } |
|
| 1864 | - |
|
| 1865 | - |
|
| 1866 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 1867 | - |
|
| 1868 | - // darken |
|
| 1869 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1870 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1871 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1872 | - |
|
| 1873 | - // lighten |
|
| 1874 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1875 | - |
|
| 1876 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1877 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1878 | - |
|
| 1879 | - |
|
| 1880 | - // button states |
|
| 1881 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1882 | - $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;} "; |
|
| 1883 | - $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.";} "; |
|
| 1884 | - $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;} "; |
|
| 1885 | - |
|
| 1886 | - |
|
| 1887 | - // dropdown's |
|
| 1888 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1889 | - |
|
| 1890 | - |
|
| 1891 | - // input states |
|
| 1892 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1893 | - |
|
| 1894 | - // page link |
|
| 1895 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1896 | - |
|
| 1897 | - return $output; |
|
| 1898 | - } |
|
| 1783 | + '.nav-pills .nav-link.active' => array('b'), |
|
| 1784 | + '.nav-pills .show>.nav-link' => array('b'), |
|
| 1785 | + '.page-link' => array('c'), |
|
| 1786 | + '.page-item.active .page-link' => array('b','o'), |
|
| 1787 | + '.badge-primary' => array('b'), |
|
| 1788 | + '.alert-primary' => array('b','o'), |
|
| 1789 | + '.progress-bar' => array('b'), |
|
| 1790 | + '.list-group-item.active' => array('b','o'), |
|
| 1791 | + '.bg-primary' => array('b','f'), |
|
| 1792 | + '.btn-link.btn-primary' => array('c'), |
|
| 1793 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1794 | + ); |
|
| 1795 | + |
|
| 1796 | + $important_selectors = array( |
|
| 1797 | + '.bg-primary' => array('b','f'), |
|
| 1798 | + '.border-primary' => array('o'), |
|
| 1799 | + '.text-primary' => array('c'), |
|
| 1800 | + ); |
|
| 1801 | + |
|
| 1802 | + $color = array(); |
|
| 1803 | + $color_i = array(); |
|
| 1804 | + $background = array(); |
|
| 1805 | + $background_i = array(); |
|
| 1806 | + $border = array(); |
|
| 1807 | + $border_i = array(); |
|
| 1808 | + $fill = array(); |
|
| 1809 | + $fill_i = array(); |
|
| 1810 | + |
|
| 1811 | + $output = ''; |
|
| 1812 | + |
|
| 1813 | + // build rules into each type |
|
| 1814 | + foreach($selectors as $selector => $types){ |
|
| 1815 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1816 | + $types = array_combine($types,$types); |
|
| 1817 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1818 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1819 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1820 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1821 | + } |
|
| 1899 | 1822 | |
| 1900 | - public static function css_secondary($color_code,$compatibility){; |
|
| 1901 | - $color_code = sanitize_hex_color($color_code); |
|
| 1902 | - if(!$color_code){return '';} |
|
| 1903 | - /** |
|
| 1904 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1905 | - */ |
|
| 1906 | - $selectors = array( |
|
| 1907 | - '.btn-secondary' => array('b','o'), |
|
| 1908 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 1909 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 1910 | - '.btn-outline-secondary' => array('c','o'), |
|
| 1911 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1912 | - '.btn-outline-secondary.disabled' => array('c'), |
|
| 1913 | - '.btn-outline-secondary:disabled' => array('c'), |
|
| 1914 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1915 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1916 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1917 | - '.badge-secondary' => array('b'), |
|
| 1918 | - '.alert-secondary' => array('b','o'), |
|
| 1919 | - '.btn-link.btn-secondary' => array('c'), |
|
| 1920 | - ); |
|
| 1921 | - |
|
| 1922 | - $important_selectors = array( |
|
| 1923 | - '.bg-secondary' => array('b','f'), |
|
| 1924 | - '.border-secondary' => array('o'), |
|
| 1925 | - '.text-secondary' => array('c'), |
|
| 1926 | - ); |
|
| 1927 | - |
|
| 1928 | - $color = array(); |
|
| 1929 | - $color_i = array(); |
|
| 1930 | - $background = array(); |
|
| 1931 | - $background_i = array(); |
|
| 1932 | - $border = array(); |
|
| 1933 | - $border_i = array(); |
|
| 1934 | - $fill = array(); |
|
| 1935 | - $fill_i = array(); |
|
| 1936 | - |
|
| 1937 | - $output = ''; |
|
| 1938 | - |
|
| 1939 | - // build rules into each type |
|
| 1940 | - foreach($selectors as $selector => $types){ |
|
| 1941 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1942 | - $types = array_combine($types,$types); |
|
| 1943 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1944 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1945 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1946 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1947 | - } |
|
| 1948 | - |
|
| 1949 | - // build rules into each type |
|
| 1950 | - foreach($important_selectors as $selector => $types){ |
|
| 1951 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1952 | - $types = array_combine($types,$types); |
|
| 1953 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1954 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1955 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1956 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1957 | - } |
|
| 1958 | - |
|
| 1959 | - // add any color rules |
|
| 1960 | - if(!empty($color)){ |
|
| 1961 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1962 | - } |
|
| 1963 | - if(!empty($color_i)){ |
|
| 1964 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1965 | - } |
|
| 1966 | - |
|
| 1967 | - // add any background color rules |
|
| 1968 | - if(!empty($background)){ |
|
| 1969 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1970 | - } |
|
| 1971 | - if(!empty($background_i)){ |
|
| 1972 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1973 | - } |
|
| 1974 | - |
|
| 1975 | - // add any border color rules |
|
| 1976 | - if(!empty($border)){ |
|
| 1977 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1978 | - } |
|
| 1979 | - if(!empty($border_i)){ |
|
| 1980 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1981 | - } |
|
| 1982 | - |
|
| 1983 | - // add any fill color rules |
|
| 1984 | - if(!empty($fill)){ |
|
| 1985 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1986 | - } |
|
| 1987 | - if(!empty($fill_i)){ |
|
| 1988 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1989 | - } |
|
| 1990 | - |
|
| 1991 | - |
|
| 1992 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 1993 | - |
|
| 1994 | - // darken |
|
| 1995 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1996 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1997 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1998 | - |
|
| 1999 | - // lighten |
|
| 2000 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2001 | - |
|
| 2002 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2003 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2004 | - |
|
| 2005 | - |
|
| 2006 | - // button states |
|
| 2007 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2008 | - $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;} "; |
|
| 2009 | - $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.";} "; |
|
| 2010 | - $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;} "; |
|
| 2011 | - |
|
| 2012 | - |
|
| 2013 | - return $output; |
|
| 2014 | - } |
|
| 1823 | + // build rules into each type |
|
| 1824 | + foreach($important_selectors as $selector => $types){ |
|
| 1825 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1826 | + $types = array_combine($types,$types); |
|
| 1827 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1828 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1829 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1830 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1831 | + } |
|
| 2015 | 1832 | |
| 2016 | - /** |
|
| 2017 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2018 | - * |
|
| 2019 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2020 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2021 | - * |
|
| 2022 | - * @return string |
|
| 2023 | - */ |
|
| 2024 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2025 | - $hexCode = ltrim($hexCode, '#'); |
|
| 1833 | + // add any color rules |
|
| 1834 | + if(!empty($color)){ |
|
| 1835 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1836 | + } |
|
| 1837 | + if(!empty($color_i)){ |
|
| 1838 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1839 | + } |
|
| 2026 | 1840 | |
| 2027 | - if (strlen($hexCode) == 3) { |
|
| 2028 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2029 | - } |
|
| 1841 | + // add any background color rules |
|
| 1842 | + if(!empty($background)){ |
|
| 1843 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1844 | + } |
|
| 1845 | + if(!empty($background_i)){ |
|
| 1846 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1847 | + } |
|
| 2030 | 1848 | |
| 2031 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 1849 | + // add any border color rules |
|
| 1850 | + if(!empty($border)){ |
|
| 1851 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1852 | + } |
|
| 1853 | + if(!empty($border_i)){ |
|
| 1854 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1855 | + } |
|
| 2032 | 1856 | |
| 2033 | - foreach ($hexCode as & $color) { |
|
| 2034 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2035 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 1857 | + // add any fill color rules |
|
| 1858 | + if(!empty($fill)){ |
|
| 1859 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1860 | + } |
|
| 1861 | + if(!empty($fill_i)){ |
|
| 1862 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1863 | + } |
|
| 2036 | 1864 | |
| 2037 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2038 | - } |
|
| 2039 | 1865 | |
| 2040 | - return '#' . implode($hexCode); |
|
| 2041 | - } |
|
| 1866 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 2042 | 1867 | |
| 2043 | - /** |
|
| 2044 | - * Check if we should display examples. |
|
| 2045 | - */ |
|
| 2046 | - public function maybe_show_examples(){ |
|
| 2047 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2048 | - echo "<head>"; |
|
| 2049 | - wp_head(); |
|
| 2050 | - echo "</head>"; |
|
| 2051 | - echo "<body>"; |
|
| 2052 | - echo $this->get_examples(); |
|
| 2053 | - echo "</body>"; |
|
| 2054 | - exit; |
|
| 2055 | - } |
|
| 2056 | - } |
|
| 1868 | + // darken |
|
| 1869 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1870 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1871 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2057 | 1872 | |
| 2058 | - /** |
|
| 2059 | - * Get developer examples. |
|
| 2060 | - * |
|
| 2061 | - * @return string |
|
| 2062 | - */ |
|
| 2063 | - public function get_examples(){ |
|
| 2064 | - $output = ''; |
|
| 2065 | - |
|
| 2066 | - |
|
| 2067 | - // open form |
|
| 2068 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2069 | - |
|
| 2070 | - // input example |
|
| 2071 | - $output .= aui()->input(array( |
|
| 2072 | - 'type' => 'text', |
|
| 2073 | - 'id' => 'text-example', |
|
| 2074 | - 'name' => 'text-example', |
|
| 2075 | - 'placeholder' => 'text placeholder', |
|
| 2076 | - 'title' => 'Text input example', |
|
| 2077 | - 'value' => '', |
|
| 2078 | - 'required' => false, |
|
| 2079 | - 'help_text' => 'help text', |
|
| 2080 | - 'label' => 'Text input example label' |
|
| 2081 | - )); |
|
| 2082 | - |
|
| 2083 | - // input example |
|
| 2084 | - $output .= aui()->input(array( |
|
| 2085 | - 'type' => 'url', |
|
| 2086 | - 'id' => 'text-example2', |
|
| 2087 | - 'name' => 'text-example', |
|
| 2088 | - 'placeholder' => 'url placeholder', |
|
| 2089 | - 'title' => 'Text input example', |
|
| 2090 | - 'value' => '', |
|
| 2091 | - 'required' => false, |
|
| 2092 | - 'help_text' => 'help text', |
|
| 2093 | - 'label' => 'Text input example label' |
|
| 2094 | - )); |
|
| 2095 | - |
|
| 2096 | - // checkbox example |
|
| 2097 | - $output .= aui()->input(array( |
|
| 2098 | - 'type' => 'checkbox', |
|
| 2099 | - 'id' => 'checkbox-example', |
|
| 2100 | - 'name' => 'checkbox-example', |
|
| 2101 | - 'placeholder' => 'checkbox-example', |
|
| 2102 | - 'title' => 'Checkbox example', |
|
| 2103 | - 'value' => '1', |
|
| 2104 | - 'checked' => true, |
|
| 2105 | - 'required' => false, |
|
| 2106 | - 'help_text' => 'help text', |
|
| 2107 | - 'label' => 'Checkbox checked' |
|
| 2108 | - )); |
|
| 2109 | - |
|
| 2110 | - // checkbox example |
|
| 2111 | - $output .= aui()->input(array( |
|
| 2112 | - 'type' => 'checkbox', |
|
| 2113 | - 'id' => 'checkbox-example2', |
|
| 2114 | - 'name' => 'checkbox-example2', |
|
| 2115 | - 'placeholder' => 'checkbox-example', |
|
| 2116 | - 'title' => 'Checkbox example', |
|
| 2117 | - 'value' => '1', |
|
| 2118 | - 'checked' => false, |
|
| 2119 | - 'required' => false, |
|
| 2120 | - 'help_text' => 'help text', |
|
| 2121 | - 'label' => 'Checkbox un-checked' |
|
| 2122 | - )); |
|
| 2123 | - |
|
| 2124 | - // switch example |
|
| 2125 | - $output .= aui()->input(array( |
|
| 2126 | - 'type' => 'checkbox', |
|
| 2127 | - 'id' => 'switch-example', |
|
| 2128 | - 'name' => 'switch-example', |
|
| 2129 | - 'placeholder' => 'checkbox-example', |
|
| 2130 | - 'title' => 'Switch example', |
|
| 2131 | - 'value' => '1', |
|
| 2132 | - 'checked' => true, |
|
| 2133 | - 'switch' => true, |
|
| 2134 | - 'required' => false, |
|
| 2135 | - 'help_text' => 'help text', |
|
| 2136 | - 'label' => 'Switch on' |
|
| 2137 | - )); |
|
| 2138 | - |
|
| 2139 | - // switch example |
|
| 2140 | - $output .= aui()->input(array( |
|
| 2141 | - 'type' => 'checkbox', |
|
| 2142 | - 'id' => 'switch-example2', |
|
| 2143 | - 'name' => 'switch-example2', |
|
| 2144 | - 'placeholder' => 'checkbox-example', |
|
| 2145 | - 'title' => 'Switch example', |
|
| 2146 | - 'value' => '1', |
|
| 2147 | - 'checked' => false, |
|
| 2148 | - 'switch' => true, |
|
| 2149 | - 'required' => false, |
|
| 2150 | - 'help_text' => 'help text', |
|
| 2151 | - 'label' => 'Switch off' |
|
| 2152 | - )); |
|
| 2153 | - |
|
| 2154 | - // close form |
|
| 2155 | - $output .= "</form>"; |
|
| 2156 | - |
|
| 2157 | - return $output; |
|
| 2158 | - } |
|
| 1873 | + // lighten |
|
| 1874 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2159 | 1875 | |
| 2160 | - /** |
|
| 2161 | - * Calendar params. |
|
| 2162 | - * |
|
| 2163 | - * @since 0.1.44 |
|
| 2164 | - * |
|
| 2165 | - * @return array Calendar params. |
|
| 2166 | - */ |
|
| 2167 | - public static function calendar_params() { |
|
| 2168 | - $params = array( |
|
| 2169 | - 'month_long_1' => __( 'January', 'aui' ), |
|
| 2170 | - 'month_long_2' => __( 'February', 'aui' ), |
|
| 2171 | - 'month_long_3' => __( 'March', 'aui' ), |
|
| 2172 | - 'month_long_4' => __( 'April', 'aui' ), |
|
| 2173 | - 'month_long_5' => __( 'May', 'aui' ), |
|
| 2174 | - 'month_long_6' => __( 'June', 'aui' ), |
|
| 2175 | - 'month_long_7' => __( 'July', 'aui' ), |
|
| 2176 | - 'month_long_8' => __( 'August', 'aui' ), |
|
| 2177 | - 'month_long_9' => __( 'September', 'aui' ), |
|
| 2178 | - 'month_long_10' => __( 'October', 'aui' ), |
|
| 2179 | - 'month_long_11' => __( 'November', 'aui' ), |
|
| 2180 | - 'month_long_12' => __( 'December', 'aui' ), |
|
| 2181 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 2182 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 2183 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 2184 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 2185 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 2186 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 2187 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 2188 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 2189 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 2190 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 2191 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 2192 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 2193 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 2194 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 2195 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 2196 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 2197 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 2198 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 2199 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 2200 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 2201 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 2202 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 2203 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
| 2204 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 2205 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 2206 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 2207 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 2208 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 2209 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 2210 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 2211 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 2212 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 2213 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 2214 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 2215 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 2216 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 2217 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 2218 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 2219 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 2220 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 2221 | - 'am_lower' => __( 'am', 'aui' ), |
|
| 2222 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
| 2223 | - 'am_upper' => __( 'AM', 'aui' ), |
|
| 2224 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
| 2225 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2226 | - 'time_24hr' => false, |
|
| 2227 | - 'year' => __( 'Year', 'aui' ), |
|
| 2228 | - 'hour' => __( 'Hour', 'aui' ), |
|
| 2229 | - 'minute' => __( 'Minute', 'aui' ), |
|
| 2230 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 2231 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 2232 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 2233 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 2234 | - ); |
|
| 2235 | - |
|
| 2236 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2237 | - } |
|
| 1876 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1877 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2238 | 1878 | |
| 2239 | - /** |
|
| 2240 | - * Flatpickr calendar localize. |
|
| 2241 | - * |
|
| 2242 | - * @since 0.1.44 |
|
| 2243 | - * |
|
| 2244 | - * @return string Calendar locale. |
|
| 2245 | - */ |
|
| 2246 | - public static function flatpickr_locale() { |
|
| 2247 | - $params = self::calendar_params(); |
|
| 2248 | - |
|
| 2249 | - if ( is_string( $params ) ) { |
|
| 2250 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2251 | - } else { |
|
| 2252 | - foreach ( (array) $params as $key => $value ) { |
|
| 2253 | - if ( ! is_scalar( $value ) ) { |
|
| 2254 | - continue; |
|
| 2255 | - } |
|
| 2256 | 1879 | |
| 2257 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2258 | - } |
|
| 2259 | - } |
|
| 1880 | + // button states |
|
| 1881 | + $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1882 | + $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;} "; |
|
| 1883 | + $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.";} "; |
|
| 1884 | + $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;} "; |
|
| 1885 | + |
|
| 1886 | + |
|
| 1887 | + // dropdown's |
|
| 1888 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1889 | + |
|
| 1890 | + |
|
| 1891 | + // input states |
|
| 1892 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1893 | + |
|
| 1894 | + // page link |
|
| 1895 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1896 | + |
|
| 1897 | + return $output; |
|
| 1898 | + } |
|
| 1899 | + |
|
| 1900 | + public static function css_secondary($color_code,$compatibility){; |
|
| 1901 | + $color_code = sanitize_hex_color($color_code); |
|
| 1902 | + if(!$color_code){return '';} |
|
| 1903 | + /** |
|
| 1904 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1905 | + */ |
|
| 1906 | + $selectors = array( |
|
| 1907 | + '.btn-secondary' => array('b','o'), |
|
| 1908 | + '.btn-secondary.disabled' => array('b','o'), |
|
| 1909 | + '.btn-secondary:disabled' => array('b','o'), |
|
| 1910 | + '.btn-outline-secondary' => array('c','o'), |
|
| 1911 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1912 | + '.btn-outline-secondary.disabled' => array('c'), |
|
| 1913 | + '.btn-outline-secondary:disabled' => array('c'), |
|
| 1914 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1915 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1916 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1917 | + '.badge-secondary' => array('b'), |
|
| 1918 | + '.alert-secondary' => array('b','o'), |
|
| 1919 | + '.btn-link.btn-secondary' => array('c'), |
|
| 1920 | + ); |
|
| 1921 | + |
|
| 1922 | + $important_selectors = array( |
|
| 1923 | + '.bg-secondary' => array('b','f'), |
|
| 1924 | + '.border-secondary' => array('o'), |
|
| 1925 | + '.text-secondary' => array('c'), |
|
| 1926 | + ); |
|
| 1927 | + |
|
| 1928 | + $color = array(); |
|
| 1929 | + $color_i = array(); |
|
| 1930 | + $background = array(); |
|
| 1931 | + $background_i = array(); |
|
| 1932 | + $border = array(); |
|
| 1933 | + $border_i = array(); |
|
| 1934 | + $fill = array(); |
|
| 1935 | + $fill_i = array(); |
|
| 1936 | + |
|
| 1937 | + $output = ''; |
|
| 1938 | + |
|
| 1939 | + // build rules into each type |
|
| 1940 | + foreach($selectors as $selector => $types){ |
|
| 1941 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1942 | + $types = array_combine($types,$types); |
|
| 1943 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1944 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1945 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1946 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1947 | + } |
|
| 1948 | + |
|
| 1949 | + // build rules into each type |
|
| 1950 | + foreach($important_selectors as $selector => $types){ |
|
| 1951 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1952 | + $types = array_combine($types,$types); |
|
| 1953 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1954 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1955 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1956 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1957 | + } |
|
| 1958 | + |
|
| 1959 | + // add any color rules |
|
| 1960 | + if(!empty($color)){ |
|
| 1961 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1962 | + } |
|
| 1963 | + if(!empty($color_i)){ |
|
| 1964 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1965 | + } |
|
| 1966 | + |
|
| 1967 | + // add any background color rules |
|
| 1968 | + if(!empty($background)){ |
|
| 1969 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1970 | + } |
|
| 1971 | + if(!empty($background_i)){ |
|
| 1972 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1973 | + } |
|
| 1974 | + |
|
| 1975 | + // add any border color rules |
|
| 1976 | + if(!empty($border)){ |
|
| 1977 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1978 | + } |
|
| 1979 | + if(!empty($border_i)){ |
|
| 1980 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1981 | + } |
|
| 1982 | + |
|
| 1983 | + // add any fill color rules |
|
| 1984 | + if(!empty($fill)){ |
|
| 1985 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1986 | + } |
|
| 1987 | + if(!empty($fill_i)){ |
|
| 1988 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1989 | + } |
|
| 1990 | + |
|
| 1991 | + |
|
| 1992 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 1993 | + |
|
| 1994 | + // darken |
|
| 1995 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1996 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1997 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1998 | + |
|
| 1999 | + // lighten |
|
| 2000 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2260 | 2001 | |
| 2261 | - $day_s3 = array(); |
|
| 2262 | - $day_s5 = array(); |
|
| 2002 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2003 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2263 | 2004 | |
| 2264 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2265 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2266 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2267 | - } |
|
| 2268 | 2005 | |
| 2269 | - $month_s = array(); |
|
| 2270 | - $month_long = array(); |
|
| 2006 | + // button states |
|
| 2007 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2008 | + $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;} "; |
|
| 2009 | + $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.";} "; |
|
| 2010 | + $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;} "; |
|
| 2271 | 2011 | |
| 2272 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2273 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 2274 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 2275 | - } |
|
| 2012 | + |
|
| 2013 | + return $output; |
|
| 2014 | + } |
|
| 2015 | + |
|
| 2016 | + /** |
|
| 2017 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2018 | + * |
|
| 2019 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2020 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2021 | + * |
|
| 2022 | + * @return string |
|
| 2023 | + */ |
|
| 2024 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2025 | + $hexCode = ltrim($hexCode, '#'); |
|
| 2026 | + |
|
| 2027 | + if (strlen($hexCode) == 3) { |
|
| 2028 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2029 | + } |
|
| 2030 | + |
|
| 2031 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 2032 | + |
|
| 2033 | + foreach ($hexCode as & $color) { |
|
| 2034 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2035 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 2036 | + |
|
| 2037 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2038 | + } |
|
| 2039 | + |
|
| 2040 | + return '#' . implode($hexCode); |
|
| 2041 | + } |
|
| 2042 | + |
|
| 2043 | + /** |
|
| 2044 | + * Check if we should display examples. |
|
| 2045 | + */ |
|
| 2046 | + public function maybe_show_examples(){ |
|
| 2047 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2048 | + echo "<head>"; |
|
| 2049 | + wp_head(); |
|
| 2050 | + echo "</head>"; |
|
| 2051 | + echo "<body>"; |
|
| 2052 | + echo $this->get_examples(); |
|
| 2053 | + echo "</body>"; |
|
| 2054 | + exit; |
|
| 2055 | + } |
|
| 2056 | + } |
|
| 2057 | + |
|
| 2058 | + /** |
|
| 2059 | + * Get developer examples. |
|
| 2060 | + * |
|
| 2061 | + * @return string |
|
| 2062 | + */ |
|
| 2063 | + public function get_examples(){ |
|
| 2064 | + $output = ''; |
|
| 2065 | + |
|
| 2066 | + |
|
| 2067 | + // open form |
|
| 2068 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2069 | + |
|
| 2070 | + // input example |
|
| 2071 | + $output .= aui()->input(array( |
|
| 2072 | + 'type' => 'text', |
|
| 2073 | + 'id' => 'text-example', |
|
| 2074 | + 'name' => 'text-example', |
|
| 2075 | + 'placeholder' => 'text placeholder', |
|
| 2076 | + 'title' => 'Text input example', |
|
| 2077 | + 'value' => '', |
|
| 2078 | + 'required' => false, |
|
| 2079 | + 'help_text' => 'help text', |
|
| 2080 | + 'label' => 'Text input example label' |
|
| 2081 | + )); |
|
| 2082 | + |
|
| 2083 | + // input example |
|
| 2084 | + $output .= aui()->input(array( |
|
| 2085 | + 'type' => 'url', |
|
| 2086 | + 'id' => 'text-example2', |
|
| 2087 | + 'name' => 'text-example', |
|
| 2088 | + 'placeholder' => 'url placeholder', |
|
| 2089 | + 'title' => 'Text input example', |
|
| 2090 | + 'value' => '', |
|
| 2091 | + 'required' => false, |
|
| 2092 | + 'help_text' => 'help text', |
|
| 2093 | + 'label' => 'Text input example label' |
|
| 2094 | + )); |
|
| 2095 | + |
|
| 2096 | + // checkbox example |
|
| 2097 | + $output .= aui()->input(array( |
|
| 2098 | + 'type' => 'checkbox', |
|
| 2099 | + 'id' => 'checkbox-example', |
|
| 2100 | + 'name' => 'checkbox-example', |
|
| 2101 | + 'placeholder' => 'checkbox-example', |
|
| 2102 | + 'title' => 'Checkbox example', |
|
| 2103 | + 'value' => '1', |
|
| 2104 | + 'checked' => true, |
|
| 2105 | + 'required' => false, |
|
| 2106 | + 'help_text' => 'help text', |
|
| 2107 | + 'label' => 'Checkbox checked' |
|
| 2108 | + )); |
|
| 2109 | + |
|
| 2110 | + // checkbox example |
|
| 2111 | + $output .= aui()->input(array( |
|
| 2112 | + 'type' => 'checkbox', |
|
| 2113 | + 'id' => 'checkbox-example2', |
|
| 2114 | + 'name' => 'checkbox-example2', |
|
| 2115 | + 'placeholder' => 'checkbox-example', |
|
| 2116 | + 'title' => 'Checkbox example', |
|
| 2117 | + 'value' => '1', |
|
| 2118 | + 'checked' => false, |
|
| 2119 | + 'required' => false, |
|
| 2120 | + 'help_text' => 'help text', |
|
| 2121 | + 'label' => 'Checkbox un-checked' |
|
| 2122 | + )); |
|
| 2123 | + |
|
| 2124 | + // switch example |
|
| 2125 | + $output .= aui()->input(array( |
|
| 2126 | + 'type' => 'checkbox', |
|
| 2127 | + 'id' => 'switch-example', |
|
| 2128 | + 'name' => 'switch-example', |
|
| 2129 | + 'placeholder' => 'checkbox-example', |
|
| 2130 | + 'title' => 'Switch example', |
|
| 2131 | + 'value' => '1', |
|
| 2132 | + 'checked' => true, |
|
| 2133 | + 'switch' => true, |
|
| 2134 | + 'required' => false, |
|
| 2135 | + 'help_text' => 'help text', |
|
| 2136 | + 'label' => 'Switch on' |
|
| 2137 | + )); |
|
| 2138 | + |
|
| 2139 | + // switch example |
|
| 2140 | + $output .= aui()->input(array( |
|
| 2141 | + 'type' => 'checkbox', |
|
| 2142 | + 'id' => 'switch-example2', |
|
| 2143 | + 'name' => 'switch-example2', |
|
| 2144 | + 'placeholder' => 'checkbox-example', |
|
| 2145 | + 'title' => 'Switch example', |
|
| 2146 | + 'value' => '1', |
|
| 2147 | + 'checked' => false, |
|
| 2148 | + 'switch' => true, |
|
| 2149 | + 'required' => false, |
|
| 2150 | + 'help_text' => 'help text', |
|
| 2151 | + 'label' => 'Switch off' |
|
| 2152 | + )); |
|
| 2153 | + |
|
| 2154 | + // close form |
|
| 2155 | + $output .= "</form>"; |
|
| 2156 | + |
|
| 2157 | + return $output; |
|
| 2158 | + } |
|
| 2159 | + |
|
| 2160 | + /** |
|
| 2161 | + * Calendar params. |
|
| 2162 | + * |
|
| 2163 | + * @since 0.1.44 |
|
| 2164 | + * |
|
| 2165 | + * @return array Calendar params. |
|
| 2166 | + */ |
|
| 2167 | + public static function calendar_params() { |
|
| 2168 | + $params = array( |
|
| 2169 | + 'month_long_1' => __( 'January', 'aui' ), |
|
| 2170 | + 'month_long_2' => __( 'February', 'aui' ), |
|
| 2171 | + 'month_long_3' => __( 'March', 'aui' ), |
|
| 2172 | + 'month_long_4' => __( 'April', 'aui' ), |
|
| 2173 | + 'month_long_5' => __( 'May', 'aui' ), |
|
| 2174 | + 'month_long_6' => __( 'June', 'aui' ), |
|
| 2175 | + 'month_long_7' => __( 'July', 'aui' ), |
|
| 2176 | + 'month_long_8' => __( 'August', 'aui' ), |
|
| 2177 | + 'month_long_9' => __( 'September', 'aui' ), |
|
| 2178 | + 'month_long_10' => __( 'October', 'aui' ), |
|
| 2179 | + 'month_long_11' => __( 'November', 'aui' ), |
|
| 2180 | + 'month_long_12' => __( 'December', 'aui' ), |
|
| 2181 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 2182 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 2183 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 2184 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 2185 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 2186 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 2187 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 2188 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 2189 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 2190 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 2191 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 2192 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 2193 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 2194 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 2195 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 2196 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 2197 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 2198 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 2199 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 2200 | + 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 2201 | + 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 2202 | + 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 2203 | + 'day_s2_4' => __( 'We', 'aui' ), |
|
| 2204 | + 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 2205 | + 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 2206 | + 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 2207 | + 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 2208 | + 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 2209 | + 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 2210 | + 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 2211 | + 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 2212 | + 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 2213 | + 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 2214 | + 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 2215 | + 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 2216 | + 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 2217 | + 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 2218 | + 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 2219 | + 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 2220 | + 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 2221 | + 'am_lower' => __( 'am', 'aui' ), |
|
| 2222 | + 'pm_lower' => __( 'pm', 'aui' ), |
|
| 2223 | + 'am_upper' => __( 'AM', 'aui' ), |
|
| 2224 | + 'pm_upper' => __( 'PM', 'aui' ), |
|
| 2225 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2226 | + 'time_24hr' => false, |
|
| 2227 | + 'year' => __( 'Year', 'aui' ), |
|
| 2228 | + 'hour' => __( 'Hour', 'aui' ), |
|
| 2229 | + 'minute' => __( 'Minute', 'aui' ), |
|
| 2230 | + 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 2231 | + 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 2232 | + 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 2233 | + 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 2234 | + ); |
|
| 2235 | + |
|
| 2236 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2237 | + } |
|
| 2238 | + |
|
| 2239 | + /** |
|
| 2240 | + * Flatpickr calendar localize. |
|
| 2241 | + * |
|
| 2242 | + * @since 0.1.44 |
|
| 2243 | + * |
|
| 2244 | + * @return string Calendar locale. |
|
| 2245 | + */ |
|
| 2246 | + public static function flatpickr_locale() { |
|
| 2247 | + $params = self::calendar_params(); |
|
| 2248 | + |
|
| 2249 | + if ( is_string( $params ) ) { |
|
| 2250 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2251 | + } else { |
|
| 2252 | + foreach ( (array) $params as $key => $value ) { |
|
| 2253 | + if ( ! is_scalar( $value ) ) { |
|
| 2254 | + continue; |
|
| 2255 | + } |
|
| 2256 | + |
|
| 2257 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2258 | + } |
|
| 2259 | + } |
|
| 2260 | + |
|
| 2261 | + $day_s3 = array(); |
|
| 2262 | + $day_s5 = array(); |
|
| 2263 | + |
|
| 2264 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2265 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2266 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2267 | + } |
|
| 2268 | + |
|
| 2269 | + $month_s = array(); |
|
| 2270 | + $month_long = array(); |
|
| 2271 | + |
|
| 2272 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2273 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 2274 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 2275 | + } |
|
| 2276 | 2276 | |
| 2277 | 2277 | ob_start(); |
| 2278 | 2278 | if ( 0 ) { ?><script><?php } ?> |
@@ -2314,189 +2314,189 @@ discard block |
||
| 2314 | 2314 | } |
| 2315 | 2315 | <?php if ( 0 ) { ?></script><?php } ?> |
| 2316 | 2316 | <?php |
| 2317 | - $locale = ob_get_clean(); |
|
| 2317 | + $locale = ob_get_clean(); |
|
| 2318 | 2318 | |
| 2319 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2320 | - } |
|
| 2319 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2320 | + } |
|
| 2321 | 2321 | |
| 2322 | - /** |
|
| 2323 | - * Select2 JS params. |
|
| 2324 | - * |
|
| 2325 | - * @since 0.1.44 |
|
| 2326 | - * |
|
| 2327 | - * @return array Select2 JS params. |
|
| 2328 | - */ |
|
| 2329 | - public static function select2_params() { |
|
| 2330 | - $params = array( |
|
| 2331 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2332 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2333 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2334 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2335 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2336 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2337 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2338 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2339 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2340 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2341 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2342 | - ); |
|
| 2343 | - |
|
| 2344 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2345 | - } |
|
| 2322 | + /** |
|
| 2323 | + * Select2 JS params. |
|
| 2324 | + * |
|
| 2325 | + * @since 0.1.44 |
|
| 2326 | + * |
|
| 2327 | + * @return array Select2 JS params. |
|
| 2328 | + */ |
|
| 2329 | + public static function select2_params() { |
|
| 2330 | + $params = array( |
|
| 2331 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2332 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2333 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2334 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2335 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2336 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2337 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2338 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2339 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2340 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2341 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2342 | + ); |
|
| 2343 | + |
|
| 2344 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2345 | + } |
|
| 2346 | 2346 | |
| 2347 | - /** |
|
| 2348 | - * Select2 JS localize. |
|
| 2349 | - * |
|
| 2350 | - * @since 0.1.44 |
|
| 2351 | - * |
|
| 2352 | - * @return string Select2 JS locale. |
|
| 2353 | - */ |
|
| 2354 | - public static function select2_locale() { |
|
| 2355 | - $params = self::select2_params(); |
|
| 2356 | - |
|
| 2357 | - foreach ( (array) $params as $key => $value ) { |
|
| 2358 | - if ( ! is_scalar( $value ) ) { |
|
| 2359 | - continue; |
|
| 2360 | - } |
|
| 2347 | + /** |
|
| 2348 | + * Select2 JS localize. |
|
| 2349 | + * |
|
| 2350 | + * @since 0.1.44 |
|
| 2351 | + * |
|
| 2352 | + * @return string Select2 JS locale. |
|
| 2353 | + */ |
|
| 2354 | + public static function select2_locale() { |
|
| 2355 | + $params = self::select2_params(); |
|
| 2356 | + |
|
| 2357 | + foreach ( (array) $params as $key => $value ) { |
|
| 2358 | + if ( ! is_scalar( $value ) ) { |
|
| 2359 | + continue; |
|
| 2360 | + } |
|
| 2361 | 2361 | |
| 2362 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2363 | - } |
|
| 2362 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2363 | + } |
|
| 2364 | 2364 | |
| 2365 | - $locale = json_encode( $params ); |
|
| 2365 | + $locale = json_encode( $params ); |
|
| 2366 | 2366 | |
| 2367 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2368 | - } |
|
| 2367 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2368 | + } |
|
| 2369 | 2369 | |
| 2370 | - /** |
|
| 2371 | - * Time ago JS localize. |
|
| 2372 | - * |
|
| 2373 | - * @since 0.1.47 |
|
| 2374 | - * |
|
| 2375 | - * @return string Time ago JS locale. |
|
| 2376 | - */ |
|
| 2377 | - public static function timeago_locale() { |
|
| 2378 | - $params = array( |
|
| 2379 | - 'prefix_ago' => '', |
|
| 2380 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2381 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2382 | - 'suffix_after' => '', |
|
| 2383 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2384 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2385 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2386 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2387 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2388 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2389 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2390 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2391 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2392 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2393 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2394 | - ); |
|
| 2395 | - |
|
| 2396 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2397 | - |
|
| 2398 | - foreach ( (array) $params as $key => $value ) { |
|
| 2399 | - if ( ! is_scalar( $value ) ) { |
|
| 2400 | - continue; |
|
| 2401 | - } |
|
| 2370 | + /** |
|
| 2371 | + * Time ago JS localize. |
|
| 2372 | + * |
|
| 2373 | + * @since 0.1.47 |
|
| 2374 | + * |
|
| 2375 | + * @return string Time ago JS locale. |
|
| 2376 | + */ |
|
| 2377 | + public static function timeago_locale() { |
|
| 2378 | + $params = array( |
|
| 2379 | + 'prefix_ago' => '', |
|
| 2380 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2381 | + 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2382 | + 'suffix_after' => '', |
|
| 2383 | + 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2384 | + 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2385 | + 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2386 | + 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2387 | + 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2388 | + 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2389 | + 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2390 | + 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2391 | + 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2392 | + 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2393 | + 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2394 | + ); |
|
| 2395 | + |
|
| 2396 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2397 | + |
|
| 2398 | + foreach ( (array) $params as $key => $value ) { |
|
| 2399 | + if ( ! is_scalar( $value ) ) { |
|
| 2400 | + continue; |
|
| 2401 | + } |
|
| 2402 | 2402 | |
| 2403 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2404 | - } |
|
| 2403 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2404 | + } |
|
| 2405 | 2405 | |
| 2406 | - $locale = json_encode( $params ); |
|
| 2406 | + $locale = json_encode( $params ); |
|
| 2407 | 2407 | |
| 2408 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2409 | - } |
|
| 2408 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2409 | + } |
|
| 2410 | 2410 | |
| 2411 | - /** |
|
| 2412 | - * JavaScript Minifier |
|
| 2413 | - * |
|
| 2414 | - * @param $input |
|
| 2415 | - * |
|
| 2416 | - * @return mixed |
|
| 2417 | - */ |
|
| 2418 | - public static function minify_js($input) { |
|
| 2419 | - if(trim($input) === "") return $input; |
|
| 2420 | - return preg_replace( |
|
| 2421 | - array( |
|
| 2422 | - // Remove comment(s) |
|
| 2423 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2424 | - // Remove white-space(s) outside the string and regex |
|
| 2425 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2426 | - // Remove the last semicolon |
|
| 2427 | - '#;+\}#', |
|
| 2428 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2429 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2430 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2431 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2432 | - ), |
|
| 2433 | - array( |
|
| 2434 | - '$1', |
|
| 2435 | - '$1$2', |
|
| 2436 | - '}', |
|
| 2437 | - '$1$3', |
|
| 2438 | - '$1.$3' |
|
| 2439 | - ), |
|
| 2440 | - $input); |
|
| 2441 | - } |
|
| 2411 | + /** |
|
| 2412 | + * JavaScript Minifier |
|
| 2413 | + * |
|
| 2414 | + * @param $input |
|
| 2415 | + * |
|
| 2416 | + * @return mixed |
|
| 2417 | + */ |
|
| 2418 | + public static function minify_js($input) { |
|
| 2419 | + if(trim($input) === "") return $input; |
|
| 2420 | + return preg_replace( |
|
| 2421 | + array( |
|
| 2422 | + // Remove comment(s) |
|
| 2423 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2424 | + // Remove white-space(s) outside the string and regex |
|
| 2425 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2426 | + // Remove the last semicolon |
|
| 2427 | + '#;+\}#', |
|
| 2428 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2429 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2430 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2431 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2432 | + ), |
|
| 2433 | + array( |
|
| 2434 | + '$1', |
|
| 2435 | + '$1$2', |
|
| 2436 | + '}', |
|
| 2437 | + '$1$3', |
|
| 2438 | + '$1.$3' |
|
| 2439 | + ), |
|
| 2440 | + $input); |
|
| 2441 | + } |
|
| 2442 | 2442 | |
| 2443 | - /** |
|
| 2444 | - * Minify CSS |
|
| 2445 | - * |
|
| 2446 | - * @param $input |
|
| 2447 | - * |
|
| 2448 | - * @return mixed |
|
| 2449 | - */ |
|
| 2450 | - public static function minify_css($input) { |
|
| 2451 | - if(trim($input) === "") return $input; |
|
| 2452 | - return preg_replace( |
|
| 2453 | - array( |
|
| 2454 | - // Remove comment(s) |
|
| 2455 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2456 | - // Remove unused white-space(s) |
|
| 2457 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2458 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2459 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2460 | - // Replace `:0 0 0 0` with `:0` |
|
| 2461 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2462 | - // Replace `background-position:0` with `background-position:0 0` |
|
| 2463 | - '#(background-position):0(?=[;\}])#si', |
|
| 2464 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2465 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2466 | - // Minify string value |
|
| 2467 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2468 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2469 | - // Minify HEX color code |
|
| 2470 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2471 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2472 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2473 | - // Remove empty selector(s) |
|
| 2474 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2475 | - ), |
|
| 2476 | - array( |
|
| 2477 | - '$1', |
|
| 2478 | - '$1$2$3$4$5$6$7', |
|
| 2479 | - '$1', |
|
| 2480 | - ':0', |
|
| 2481 | - '$1:0 0', |
|
| 2482 | - '.$1', |
|
| 2483 | - '$1$3', |
|
| 2484 | - '$1$2$4$5', |
|
| 2485 | - '$1$2$3', |
|
| 2486 | - '$1:0', |
|
| 2487 | - '$1$2' |
|
| 2488 | - ), |
|
| 2489 | - $input); |
|
| 2490 | - } |
|
| 2443 | + /** |
|
| 2444 | + * Minify CSS |
|
| 2445 | + * |
|
| 2446 | + * @param $input |
|
| 2447 | + * |
|
| 2448 | + * @return mixed |
|
| 2449 | + */ |
|
| 2450 | + public static function minify_css($input) { |
|
| 2451 | + if(trim($input) === "") return $input; |
|
| 2452 | + return preg_replace( |
|
| 2453 | + array( |
|
| 2454 | + // Remove comment(s) |
|
| 2455 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2456 | + // Remove unused white-space(s) |
|
| 2457 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2458 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2459 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2460 | + // Replace `:0 0 0 0` with `:0` |
|
| 2461 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2462 | + // Replace `background-position:0` with `background-position:0 0` |
|
| 2463 | + '#(background-position):0(?=[;\}])#si', |
|
| 2464 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2465 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2466 | + // Minify string value |
|
| 2467 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2468 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2469 | + // Minify HEX color code |
|
| 2470 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2471 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2472 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2473 | + // Remove empty selector(s) |
|
| 2474 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2475 | + ), |
|
| 2476 | + array( |
|
| 2477 | + '$1', |
|
| 2478 | + '$1$2$3$4$5$6$7', |
|
| 2479 | + '$1', |
|
| 2480 | + ':0', |
|
| 2481 | + '$1:0 0', |
|
| 2482 | + '.$1', |
|
| 2483 | + '$1$3', |
|
| 2484 | + '$1$2$4$5', |
|
| 2485 | + '$1$2$3', |
|
| 2486 | + '$1:0', |
|
| 2487 | + '$1$2' |
|
| 2488 | + ), |
|
| 2489 | + $input); |
|
| 2490 | + } |
|
| 2491 | 2491 | |
| 2492 | - /** |
|
| 2493 | - * Get the conditional fields JavaScript. |
|
| 2494 | - * |
|
| 2495 | - * @return mixed |
|
| 2496 | - */ |
|
| 2497 | - public function conditional_fields_js() { |
|
| 2498 | - ob_start(); |
|
| 2499 | - ?> |
|
| 2492 | + /** |
|
| 2493 | + * Get the conditional fields JavaScript. |
|
| 2494 | + * |
|
| 2495 | + * @return mixed |
|
| 2496 | + */ |
|
| 2497 | + public function conditional_fields_js() { |
|
| 2498 | + ob_start(); |
|
| 2499 | + ?> |
|
| 2500 | 2500 | <script> |
| 2501 | 2501 | /** |
| 2502 | 2502 | * Conditional Fields |
@@ -2999,14 +2999,14 @@ discard block |
||
| 2999 | 2999 | <?php do_action( 'aui_conditional_fields_js', $this ); ?> |
| 3000 | 3000 | </script> |
| 3001 | 3001 | <?php |
| 3002 | - $output = ob_get_clean(); |
|
| 3002 | + $output = ob_get_clean(); |
|
| 3003 | 3003 | |
| 3004 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3005 | - } |
|
| 3006 | - } |
|
| 3004 | + return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3005 | + } |
|
| 3006 | + } |
|
| 3007 | 3007 | |
| 3008 | - /** |
|
| 3009 | - * Run the class if found. |
|
| 3010 | - */ |
|
| 3011 | - AyeCode_UI_Settings::instance(); |
|
| 3008 | + /** |
|
| 3009 | + * Run the class if found. |
|
| 3010 | + */ |
|
| 3011 | + AyeCode_UI_Settings::instance(); |
|
| 3012 | 3012 | } |
| 3013 | 3013 | \ No newline at end of file |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if (!defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Only add if the class does not already exist. |
| 21 | 21 | */ |
| 22 | -if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
|
| 22 | +if (!class_exists('AyeCode_UI_Settings')) { |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -98,23 +98,23 @@ discard block |
||
| 98 | 98 | * @return AyeCode_UI_Settings - Main instance. |
| 99 | 99 | */ |
| 100 | 100 | public static function instance() { |
| 101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 101 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
| 102 | 102 | |
| 103 | 103 | self::$instance = new AyeCode_UI_Settings; |
| 104 | 104 | |
| 105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 105 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
| 106 | 106 | |
| 107 | - if ( is_admin() ) { |
|
| 108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 107 | + if (is_admin()) { |
|
| 108 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
| 109 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
| 110 | 110 | |
| 111 | 111 | // Maybe show example page |
| 112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 112 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 115 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
| 116 | 116 | |
| 117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 117 | + do_action('ayecode_ui_settings_loaded'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return self::$instance; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | /** |
| 124 | 124 | * Setup some constants. |
| 125 | 125 | */ |
| 126 | - public function constants(){ |
|
| 126 | + public function constants() { |
|
| 127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
| 128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
| 129 | 129 | if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | public function init() { |
| 137 | 137 | |
| 138 | 138 | // Maybe fix settings |
| 139 | - if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 140 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 141 | - if ( ! empty( $db_settings ) ) { |
|
| 139 | + if (!empty($_REQUEST['aui-fix-admin']) && !empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], "aui-fix-admin")) { |
|
| 140 | + $db_settings = get_option('ayecode-ui-settings'); |
|
| 141 | + if (!empty($db_settings)) { |
|
| 142 | 142 | $db_settings['css_backend'] = 'compatibility'; |
| 143 | 143 | $db_settings['js_backend'] = 'core-popper'; |
| 144 | - update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 144 | + update_option('ayecode-ui-settings', $db_settings); |
|
| 145 | 145 | wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -155,31 +155,31 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * We load super early in case there is a theme version that might change the colors |
| 157 | 157 | */ |
| 158 | - if ( $this->settings['css'] ) { |
|
| 158 | + if ($this->settings['css']) { |
|
| 159 | 159 | $priority = $this->is_bs3_compat() ? 100 : 1; |
| 160 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 160 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), $priority); |
|
| 161 | 161 | } |
| 162 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 163 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 162 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
| 163 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // maybe load JS |
| 167 | - if ( $this->settings['js'] ) { |
|
| 167 | + if ($this->settings['js']) { |
|
| 168 | 168 | $priority = $this->is_bs3_compat() ? 100 : 1; |
| 169 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 169 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority); |
|
| 170 | 170 | } |
| 171 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 172 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 171 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
| 172 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | // Maybe set the HTML font size |
| 176 | - if ( $this->settings['html_font_size'] ) { |
|
| 177 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 176 | + if ($this->settings['html_font_size']) { |
|
| 177 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // Maybe show backend style error |
| 181 | - if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 182 | - add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 181 | + if ($this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper') { |
|
| 182 | + add_action('admin_notices', array($this, 'show_admin_style_notice')); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | } |
@@ -187,11 +187,11 @@ discard block |
||
| 187 | 187 | /** |
| 188 | 188 | * Show admin notice if backend scripts not loaded. |
| 189 | 189 | */ |
| 190 | - public function show_admin_style_notice(){ |
|
| 191 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 192 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 193 | - $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 194 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>'; |
|
| 190 | + public function show_admin_style_notice() { |
|
| 191 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=" . wp_create_nonce('aui-fix-admin')); |
|
| 192 | + $button = '<a href="' . esc_url($fix_url) . '" class="button-primary">Fix Now</a>'; |
|
| 193 | + $message = __('<b>Style Issue:</b> AyeCode UI is disable or set wrong.') . " " . $button; |
|
| 194 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>' . $message . '</p></div>'; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -199,14 +199,14 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return bool |
| 201 | 201 | */ |
| 202 | - public function load_admin_scripts(){ |
|
| 202 | + public function load_admin_scripts() { |
|
| 203 | 203 | $result = true; |
| 204 | 204 | |
| 205 | 205 | // check if specifically disabled |
| 206 | - if(!empty($this->settings['disable_admin'])){ |
|
| 207 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 208 | - foreach($url_parts as $part){ |
|
| 209 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 206 | + if (!empty($this->settings['disable_admin'])) { |
|
| 207 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
| 208 | + foreach ($url_parts as $part) { |
|
| 209 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
| 210 | 210 | return false; // return early, no point checking further |
| 211 | 211 | } |
| 212 | 212 | } |
@@ -218,9 +218,9 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * Add a html font size to the footer. |
| 220 | 220 | */ |
| 221 | - public function html_font_size(){ |
|
| 221 | + public function html_font_size() { |
|
| 222 | 222 | $this->settings = $this->get_settings(); |
| 223 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 223 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -228,11 +228,11 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return bool |
| 230 | 230 | */ |
| 231 | - public function is_aui_screen(){ |
|
| 231 | + public function is_aui_screen() { |
|
| 232 | 232 | // echo '###';exit; |
| 233 | 233 | $load = false; |
| 234 | 234 | // check if we should load or not |
| 235 | - if ( is_admin() ) { |
|
| 235 | + if (is_admin()) { |
|
| 236 | 236 | // Only enable on set pages |
| 237 | 237 | $aui_screens = array( |
| 238 | 238 | 'page', |
@@ -243,24 +243,24 @@ discard block |
||
| 243 | 243 | 'ayecode-ui-settings', |
| 244 | 244 | 'site-editor' |
| 245 | 245 | ); |
| 246 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 246 | + $screen_ids = apply_filters('aui_screen_ids', $aui_screens); |
|
| 247 | 247 | |
| 248 | 248 | $screen = get_current_screen(); |
| 249 | 249 | |
| 250 | 250 | // echo '###'.$screen->id; |
| 251 | 251 | |
| 252 | 252 | // check if we are on a AUI screen |
| 253 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 253 | + if ($screen && in_array($screen->id, $screen_ids)) { |
|
| 254 | 254 | $load = true; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | //load for widget previews in WP 5.8 |
| 258 | - if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 258 | + if (!empty($_REQUEST['legacy-widget-preview'])) { |
|
| 259 | 259 | $load = true; |
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 263 | + return apply_filters('aui_load_on_admin', $load); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -269,24 +269,24 @@ discard block |
||
| 269 | 269 | public function enqueue_style() { |
| 270 | 270 | |
| 271 | 271 | |
| 272 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 272 | + if (is_admin() && !$this->is_aui_screen()) { |
|
| 273 | 273 | // don't add wp-admin scripts if not requested to |
| 274 | - }else{ |
|
| 274 | + } else { |
|
| 275 | 275 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
| 276 | 276 | |
| 277 | 277 | $rtl = is_rtl() ? '-rtl' : ''; |
| 278 | 278 | |
| 279 | - if($this->settings[$css_setting]){ |
|
| 280 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 281 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 282 | - wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 283 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 279 | + if ($this->settings[$css_setting]) { |
|
| 280 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
| 281 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css'; |
|
| 282 | + wp_register_style('ayecode-ui', $url, array(), $this->version); |
|
| 283 | + wp_enqueue_style('ayecode-ui'); |
|
| 284 | 284 | |
| 285 | 285 | // flatpickr |
| 286 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version ); |
|
| 286 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->version); |
|
| 287 | 287 | |
| 288 | 288 | // fix some wp-admin issues |
| 289 | - if(is_admin()){ |
|
| 289 | + if (is_admin()) { |
|
| 290 | 290 | $custom_css = " |
| 291 | 291 | body{ |
| 292 | 292 | background-color: #f1f1f1; |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | padding: 0; |
| 340 | 340 | } |
| 341 | 341 | "; |
| 342 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 342 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | // custom changes |
| 346 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 346 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
| 347 | 347 | |
| 348 | 348 | } |
| 349 | 349 | } |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | function aui_init_flatpickr(){ |
| 607 | 607 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
| 608 | 608 | $aui_doing_init_flatpickr = true; |
| 609 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
| 609 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
| 610 | 610 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
| 611 | 611 | } |
| 612 | 612 | $aui_doing_init_flatpickr = false; |
@@ -1273,10 +1273,10 @@ discard block |
||
| 1273 | 1273 | /* |
| 1274 | 1274 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1275 | 1275 | */ |
| 1276 | - return str_replace( array( |
|
| 1276 | + return str_replace(array( |
|
| 1277 | 1277 | '<script>', |
| 1278 | 1278 | '</script>' |
| 1279 | - ), '', self::minify_js($output) ); |
|
| 1279 | + ), '', self::minify_js($output)); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | |
@@ -1290,13 +1290,13 @@ discard block |
||
| 1290 | 1290 | ob_start(); |
| 1291 | 1291 | ?> |
| 1292 | 1292 | <script> |
| 1293 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
| 1293 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
| 1294 | 1294 | /* With Avada builder */ |
| 1295 | 1295 | |
| 1296 | 1296 | <?php } ?> |
| 1297 | 1297 | </script> |
| 1298 | 1298 | <?php |
| 1299 | - return str_replace( array( |
|
| 1299 | + return str_replace(array( |
|
| 1300 | 1300 | '<script>', |
| 1301 | 1301 | '</script>' |
| 1302 | 1302 | ), '', ob_get_clean()); |
@@ -1307,7 +1307,7 @@ discard block |
||
| 1307 | 1307 | * |
| 1308 | 1308 | * If this remains small then its best to use this than to add another JS file. |
| 1309 | 1309 | */ |
| 1310 | - public function inline_script_file_browser(){ |
|
| 1310 | + public function inline_script_file_browser() { |
|
| 1311 | 1311 | ob_start(); |
| 1312 | 1312 | ?> |
| 1313 | 1313 | <script> |
@@ -1322,10 +1322,10 @@ discard block |
||
| 1322 | 1322 | /* |
| 1323 | 1323 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1324 | 1324 | */ |
| 1325 | - return str_replace( array( |
|
| 1325 | + return str_replace(array( |
|
| 1326 | 1326 | '<script>', |
| 1327 | 1327 | '</script>' |
| 1328 | - ), '', $output ); |
|
| 1328 | + ), '', $output); |
|
| 1329 | 1329 | } |
| 1330 | 1330 | |
| 1331 | 1331 | /** |
@@ -1333,53 +1333,53 @@ discard block |
||
| 1333 | 1333 | */ |
| 1334 | 1334 | public function enqueue_scripts() { |
| 1335 | 1335 | |
| 1336 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 1336 | + if (is_admin() && !$this->is_aui_screen()) { |
|
| 1337 | 1337 | // don't add wp-admin scripts if not requested to |
| 1338 | - }else { |
|
| 1338 | + } else { |
|
| 1339 | 1339 | |
| 1340 | 1340 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
| 1341 | 1341 | |
| 1342 | 1342 | // select2 |
| 1343 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1343 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
| 1344 | 1344 | |
| 1345 | 1345 | // flatpickr |
| 1346 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 1346 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version); |
|
| 1347 | 1347 | |
| 1348 | 1348 | // flatpickr |
| 1349 | - wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 1349 | + wp_register_script('iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version); |
|
| 1350 | 1350 | |
| 1351 | 1351 | // Bootstrap file browser |
| 1352 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1353 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1352 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
| 1353 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
| 1354 | 1354 | |
| 1355 | 1355 | $load_inline = false; |
| 1356 | 1356 | |
| 1357 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1357 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
| 1358 | 1358 | // Bootstrap bundle |
| 1359 | 1359 | $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
| 1360 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1360 | + wp_register_script('bootstrap-js-bundle', $url, array( |
|
| 1361 | 1361 | 'select2', |
| 1362 | 1362 | 'jquery' |
| 1363 | - ), $this->version, $this->is_bs3_compat() ); |
|
| 1363 | + ), $this->version, $this->is_bs3_compat()); |
|
| 1364 | 1364 | // if in admin then add to footer for compatibility. |
| 1365 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1365 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
| 1366 | 1366 | $script = $this->inline_script(); |
| 1367 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1368 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1367 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
| 1368 | + } elseif ($this->settings[$js_setting] == 'popper') { |
|
| 1369 | 1369 | $url = $this->url . 'assets/js/popper.min.js'; |
| 1370 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 1371 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1370 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->version); |
|
| 1371 | + wp_enqueue_script('bootstrap-js-popper'); |
|
| 1372 | 1372 | $load_inline = true; |
| 1373 | 1373 | } else { |
| 1374 | 1374 | $load_inline = true; |
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | 1377 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
| 1378 | - if ( $load_inline ) { |
|
| 1379 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1380 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1378 | + if ($load_inline) { |
|
| 1379 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
| 1380 | + wp_enqueue_script('bootstrap-dummy'); |
|
| 1381 | 1381 | $script = $this->inline_script(); |
| 1382 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1382 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
| 1383 | 1383 | } |
| 1384 | 1384 | } |
| 1385 | 1385 | |
@@ -1388,17 +1388,17 @@ discard block |
||
| 1388 | 1388 | /** |
| 1389 | 1389 | * Enqueue flatpickr if called. |
| 1390 | 1390 | */ |
| 1391 | - public function enqueue_flatpickr(){ |
|
| 1392 | - wp_enqueue_style( 'flatpickr' ); |
|
| 1393 | - wp_enqueue_script( 'flatpickr' ); |
|
| 1391 | + public function enqueue_flatpickr() { |
|
| 1392 | + wp_enqueue_style('flatpickr'); |
|
| 1393 | + wp_enqueue_script('flatpickr'); |
|
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | 1396 | /** |
| 1397 | 1397 | * Enqueue iconpicker if called. |
| 1398 | 1398 | */ |
| 1399 | - public function enqueue_iconpicker(){ |
|
| 1400 | - wp_enqueue_style( 'iconpicker' ); |
|
| 1401 | - wp_enqueue_script( 'iconpicker' ); |
|
| 1399 | + public function enqueue_iconpicker() { |
|
| 1400 | + wp_enqueue_style('iconpicker'); |
|
| 1401 | + wp_enqueue_script('iconpicker'); |
|
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | 1404 | /** |
@@ -1407,19 +1407,19 @@ discard block |
||
| 1407 | 1407 | * @return string |
| 1408 | 1408 | */ |
| 1409 | 1409 | public function get_url() { |
| 1410 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1411 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1410 | + $content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR)); |
|
| 1411 | + $content_url = untrailingslashit(WP_CONTENT_URL); |
|
| 1412 | 1412 | |
| 1413 | 1413 | // Replace http:// to https://. |
| 1414 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1415 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1414 | + if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) { |
|
| 1415 | + $content_url = str_replace('http://', 'https://', $content_url); |
|
| 1416 | 1416 | } |
| 1417 | 1417 | |
| 1418 | 1418 | // Check if we are inside a plugin |
| 1419 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1420 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1419 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
| 1420 | + $url = str_replace($content_dir, $content_url, $file_dir); |
|
| 1421 | 1421 | |
| 1422 | - return trailingslashit( $url ); |
|
| 1422 | + return trailingslashit($url); |
|
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | /** |
@@ -1431,15 +1431,15 @@ discard block |
||
| 1431 | 1431 | |
| 1432 | 1432 | $url = ''; |
| 1433 | 1433 | // check if we are inside a plugin |
| 1434 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1434 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
| 1435 | 1435 | |
| 1436 | 1436 | // add check in-case user has changed wp-content dir name. |
| 1437 | 1437 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
| 1438 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1439 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1438 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
| 1439 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
| 1440 | 1440 | |
| 1441 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1442 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1441 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
| 1442 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | return $url; |
@@ -1449,7 +1449,7 @@ discard block |
||
| 1449 | 1449 | * Register the database settings with WordPress. |
| 1450 | 1450 | */ |
| 1451 | 1451 | public function register_settings() { |
| 1452 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1452 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | 1455 | /** |
@@ -1458,10 +1458,10 @@ discard block |
||
| 1458 | 1458 | */ |
| 1459 | 1459 | public function menu_item() { |
| 1460 | 1460 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
| 1461 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1461 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1462 | 1462 | $this, |
| 1463 | 1463 | 'settings_page' |
| 1464 | - ) ); |
|
| 1464 | + )); |
|
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | /** |
@@ -1469,7 +1469,7 @@ discard block |
||
| 1469 | 1469 | * |
| 1470 | 1470 | * @return array |
| 1471 | 1471 | */ |
| 1472 | - public function theme_js_settings(){ |
|
| 1472 | + public function theme_js_settings() { |
|
| 1473 | 1473 | return array( |
| 1474 | 1474 | 'ayetheme' => 'popper', |
| 1475 | 1475 | 'listimia' => 'required', |
@@ -1485,17 +1485,17 @@ discard block |
||
| 1485 | 1485 | */ |
| 1486 | 1486 | public function get_settings() { |
| 1487 | 1487 | |
| 1488 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1488 | + $db_settings = get_option('ayecode-ui-settings'); |
|
| 1489 | 1489 | $js_default = 'core-popper'; |
| 1490 | 1490 | $js_default_backend = $js_default; |
| 1491 | 1491 | |
| 1492 | 1492 | // maybe set defaults (if no settings set) |
| 1493 | - if(empty($db_settings)){ |
|
| 1494 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1493 | + if (empty($db_settings)) { |
|
| 1494 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
| 1495 | 1495 | $theme_js_settings = self::theme_js_settings(); |
| 1496 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 1496 | + if (isset($theme_js_settings[$active_theme])) { |
|
| 1497 | 1497 | $js_default = $theme_js_settings[$active_theme]; |
| 1498 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1498 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
| 1499 | 1499 | } |
| 1500 | 1500 | } |
| 1501 | 1501 | |
@@ -1508,14 +1508,14 @@ discard block |
||
| 1508 | 1508 | 'disable_admin' => '', // URL snippets to disable loading on admin |
| 1509 | 1509 | ); |
| 1510 | 1510 | |
| 1511 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1511 | + $settings = wp_parse_args($db_settings, $defaults); |
|
| 1512 | 1512 | |
| 1513 | 1513 | /** |
| 1514 | 1514 | * Filter the Bootstrap settings. |
| 1515 | 1515 | * |
| 1516 | 1516 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
| 1517 | 1517 | */ |
| 1518 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1518 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | 1521 | |
@@ -1523,90 +1523,90 @@ discard block |
||
| 1523 | 1523 | * The settings page html output. |
| 1524 | 1524 | */ |
| 1525 | 1525 | public function settings_page() { |
| 1526 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1527 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1526 | + if (!current_user_can('manage_options')) { |
|
| 1527 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
| 1528 | 1528 | } |
| 1529 | 1529 | ?> |
| 1530 | 1530 | <div class="wrap"> |
| 1531 | 1531 | <h1><?php echo $this->name; ?></h1> |
| 1532 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
|
| 1532 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", 'aui'); ?></p> |
|
| 1533 | 1533 | <form method="post" action="options.php"> |
| 1534 | 1534 | <?php |
| 1535 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 1536 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1535 | + settings_fields('ayecode-ui-settings'); |
|
| 1536 | + do_settings_sections('ayecode-ui-settings'); |
|
| 1537 | 1537 | ?> |
| 1538 | 1538 | |
| 1539 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
| 1539 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
| 1540 | 1540 | <table class="form-table wpbs-table-settings"> |
| 1541 | 1541 | <tr valign="top"> |
| 1542 | 1542 | <th scope="row"><label |
| 1543 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 1543 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 1544 | 1544 | <td> |
| 1545 | 1545 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
| 1546 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
| 1547 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
| 1548 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 1546 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
| 1547 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
| 1548 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 1549 | 1549 | </select> |
| 1550 | 1550 | </td> |
| 1551 | 1551 | </tr> |
| 1552 | 1552 | |
| 1553 | 1553 | <tr valign="top"> |
| 1554 | 1554 | <th scope="row"><label |
| 1555 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 1555 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 1556 | 1556 | <td> |
| 1557 | 1557 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
| 1558 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 1559 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 1560 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 1561 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 1558 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 1559 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 1560 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 1561 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 1562 | 1562 | </select> |
| 1563 | 1563 | </td> |
| 1564 | 1564 | </tr> |
| 1565 | 1565 | |
| 1566 | 1566 | <tr valign="top"> |
| 1567 | 1567 | <th scope="row"><label |
| 1568 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
| 1568 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
| 1569 | 1569 | <td> |
| 1570 | - <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
|
| 1571 | - <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p> |
|
| 1570 | + <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" /> |
|
| 1571 | + <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'aui'); ?></p> |
|
| 1572 | 1572 | </td> |
| 1573 | 1573 | </tr> |
| 1574 | 1574 | |
| 1575 | 1575 | </table> |
| 1576 | 1576 | |
| 1577 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
| 1577 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
| 1578 | 1578 | <table class="form-table wpbs-table-settings"> |
| 1579 | 1579 | <tr valign="top"> |
| 1580 | 1580 | <th scope="row"><label |
| 1581 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 1581 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 1582 | 1582 | <td> |
| 1583 | 1583 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
| 1584 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
| 1585 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
|
| 1586 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 1584 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
| 1585 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option> |
|
| 1586 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 1587 | 1587 | </select> |
| 1588 | 1588 | </td> |
| 1589 | 1589 | </tr> |
| 1590 | 1590 | |
| 1591 | 1591 | <tr valign="top"> |
| 1592 | 1592 | <th scope="row"><label |
| 1593 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 1593 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 1594 | 1594 | <td> |
| 1595 | 1595 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
| 1596 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 1597 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 1598 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 1599 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 1596 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 1597 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 1598 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 1599 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 1600 | 1600 | </select> |
| 1601 | 1601 | </td> |
| 1602 | 1602 | </tr> |
| 1603 | 1603 | |
| 1604 | 1604 | <tr valign="top"> |
| 1605 | 1605 | <th scope="row"><label |
| 1606 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
| 1606 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
| 1607 | 1607 | <td> |
| 1608 | - <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
|
| 1609 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
| 1608 | + <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p> |
|
| 1609 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
| 1610 | 1610 | |
| 1611 | 1611 | </td> |
| 1612 | 1612 | </tr> |
@@ -1624,9 +1624,9 @@ discard block |
||
| 1624 | 1624 | <?php |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | - public function customizer_settings($wp_customize){ |
|
| 1627 | + public function customizer_settings($wp_customize) { |
|
| 1628 | 1628 | $wp_customize->add_section('aui_settings', array( |
| 1629 | - 'title' => __('AyeCode UI','aui'), |
|
| 1629 | + 'title' => __('AyeCode UI', 'aui'), |
|
| 1630 | 1630 | 'priority' => 120, |
| 1631 | 1631 | )); |
| 1632 | 1632 | |
@@ -1640,8 +1640,8 @@ discard block |
||
| 1640 | 1640 | 'type' => 'option', |
| 1641 | 1641 | 'transport' => 'refresh', |
| 1642 | 1642 | )); |
| 1643 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1644 | - 'label' => __('Primary Color','aui'), |
|
| 1643 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1644 | + 'label' => __('Primary Color', 'aui'), |
|
| 1645 | 1645 | 'section' => 'aui_settings', |
| 1646 | 1646 | 'settings' => 'aui_options[color_primary]', |
| 1647 | 1647 | ))); |
@@ -1653,8 +1653,8 @@ discard block |
||
| 1653 | 1653 | 'type' => 'option', |
| 1654 | 1654 | 'transport' => 'refresh', |
| 1655 | 1655 | )); |
| 1656 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1657 | - 'label' => __('Secondary Color','aui'), |
|
| 1656 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1657 | + 'label' => __('Secondary Color', 'aui'), |
|
| 1658 | 1658 | 'section' => 'aui_settings', |
| 1659 | 1659 | 'settings' => 'aui_options[color_secondary]', |
| 1660 | 1660 | ))); |
@@ -1680,12 +1680,12 @@ discard block |
||
| 1680 | 1680 | .collapse.show:not(.in){display: inherit;} |
| 1681 | 1681 | .fade.show{opacity: 1;} |
| 1682 | 1682 | |
| 1683 | - <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?> |
|
| 1683 | + <?php if (defined('SVQ_THEME_VERSION')) { ?> |
|
| 1684 | 1684 | /* KLEO theme specific */ |
| 1685 | 1685 | .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;} |
| 1686 | 1686 | <?php } ?> |
| 1687 | 1687 | |
| 1688 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
| 1688 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
| 1689 | 1689 | /* With Avada builder */ |
| 1690 | 1690 | body.modal-open .modal.in {opacity:1;z-index: 99999} |
| 1691 | 1691 | body.modal-open .modal.bsui.in .modal-content {box-shadow: none;} |
@@ -1696,10 +1696,10 @@ discard block |
||
| 1696 | 1696 | <?php } ?> |
| 1697 | 1697 | </style> |
| 1698 | 1698 | <?php |
| 1699 | - return str_replace( array( |
|
| 1699 | + return str_replace(array( |
|
| 1700 | 1700 | '<style>', |
| 1701 | 1701 | '</style>' |
| 1702 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1702 | + ), '', self::minify_css(ob_get_clean())); |
|
| 1703 | 1703 | } |
| 1704 | 1704 | |
| 1705 | 1705 | |
@@ -1716,22 +1716,22 @@ discard block |
||
| 1716 | 1716 | <?php |
| 1717 | 1717 | |
| 1718 | 1718 | // BS v3 compat |
| 1719 | - if( self::is_bs3_compat() ){ |
|
| 1719 | + if (self::is_bs3_compat()) { |
|
| 1720 | 1720 | echo self::bs3_compat_css(); |
| 1721 | 1721 | } |
| 1722 | 1722 | |
| 1723 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
| 1724 | - echo self::css_primary($primary_color,$compatibility); |
|
| 1723 | + if (!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL) { |
|
| 1724 | + echo self::css_primary($primary_color, $compatibility); |
|
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
| 1728 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 1727 | + if (!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL) { |
|
| 1728 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | 1731 | // Set admin bar z-index lower when modal is open. |
| 1732 | 1732 | echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
| 1733 | 1733 | |
| 1734 | - if(is_admin()){ |
|
| 1734 | + if (is_admin()) { |
|
| 1735 | 1735 | echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
| 1736 | 1736 | } |
| 1737 | 1737 | ?> |
@@ -1742,10 +1742,10 @@ discard block |
||
| 1742 | 1742 | /* |
| 1743 | 1743 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1744 | 1744 | */ |
| 1745 | - return str_replace( array( |
|
| 1745 | + return str_replace(array( |
|
| 1746 | 1746 | '<style>', |
| 1747 | 1747 | '</style>' |
| 1748 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1748 | + ), '', self::minify_css(ob_get_clean())); |
|
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | 1751 | /** |
@@ -1753,48 +1753,48 @@ discard block |
||
| 1753 | 1753 | * |
| 1754 | 1754 | * @return bool |
| 1755 | 1755 | */ |
| 1756 | - public static function is_bs3_compat(){ |
|
| 1756 | + public static function is_bs3_compat() { |
|
| 1757 | 1757 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
| 1758 | 1758 | } |
| 1759 | 1759 | |
| 1760 | - public static function css_primary($color_code,$compatibility){; |
|
| 1760 | + public static function css_primary($color_code, $compatibility) {; |
|
| 1761 | 1761 | $color_code = sanitize_hex_color($color_code); |
| 1762 | - if(!$color_code){return '';} |
|
| 1762 | + if (!$color_code) {return ''; } |
|
| 1763 | 1763 | /** |
| 1764 | 1764 | * c = color, b = background color, o = border-color, f = fill |
| 1765 | 1765 | */ |
| 1766 | 1766 | $selectors = array( |
| 1767 | 1767 | 'a' => array('c'), |
| 1768 | - '.btn-primary' => array('b','o'), |
|
| 1769 | - '.btn-primary.disabled' => array('b','o'), |
|
| 1770 | - '.btn-primary:disabled' => array('b','o'), |
|
| 1771 | - '.btn-outline-primary' => array('c','o'), |
|
| 1772 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 1773 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1774 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1775 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1768 | + '.btn-primary' => array('b', 'o'), |
|
| 1769 | + '.btn-primary.disabled' => array('b', 'o'), |
|
| 1770 | + '.btn-primary:disabled' => array('b', 'o'), |
|
| 1771 | + '.btn-outline-primary' => array('c', 'o'), |
|
| 1772 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
| 1773 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 1774 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 1775 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
| 1776 | 1776 | '.btn-link' => array('c'), |
| 1777 | 1777 | '.dropdown-item.active' => array('b'), |
| 1778 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1779 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1778 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
| 1779 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
| 1780 | 1780 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1781 | 1781 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1782 | 1782 | // '.custom-range::-ms-thumb' => array('b'), |
| 1783 | 1783 | '.nav-pills .nav-link.active' => array('b'), |
| 1784 | 1784 | '.nav-pills .show>.nav-link' => array('b'), |
| 1785 | 1785 | '.page-link' => array('c'), |
| 1786 | - '.page-item.active .page-link' => array('b','o'), |
|
| 1786 | + '.page-item.active .page-link' => array('b', 'o'), |
|
| 1787 | 1787 | '.badge-primary' => array('b'), |
| 1788 | - '.alert-primary' => array('b','o'), |
|
| 1788 | + '.alert-primary' => array('b', 'o'), |
|
| 1789 | 1789 | '.progress-bar' => array('b'), |
| 1790 | - '.list-group-item.active' => array('b','o'), |
|
| 1791 | - '.bg-primary' => array('b','f'), |
|
| 1790 | + '.list-group-item.active' => array('b', 'o'), |
|
| 1791 | + '.bg-primary' => array('b', 'f'), |
|
| 1792 | 1792 | '.btn-link.btn-primary' => array('c'), |
| 1793 | 1793 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
| 1794 | 1794 | ); |
| 1795 | 1795 | |
| 1796 | 1796 | $important_selectors = array( |
| 1797 | - '.bg-primary' => array('b','f'), |
|
| 1797 | + '.bg-primary' => array('b', 'f'), |
|
| 1798 | 1798 | '.border-primary' => array('o'), |
| 1799 | 1799 | '.text-primary' => array('c'), |
| 1800 | 1800 | ); |
@@ -1811,116 +1811,116 @@ discard block |
||
| 1811 | 1811 | $output = ''; |
| 1812 | 1812 | |
| 1813 | 1813 | // build rules into each type |
| 1814 | - foreach($selectors as $selector => $types){ |
|
| 1815 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1816 | - $types = array_combine($types,$types); |
|
| 1817 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1818 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1819 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1820 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1814 | + foreach ($selectors as $selector => $types) { |
|
| 1815 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1816 | + $types = array_combine($types, $types); |
|
| 1817 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 1818 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 1819 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 1820 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 1821 | 1821 | } |
| 1822 | 1822 | |
| 1823 | 1823 | // build rules into each type |
| 1824 | - foreach($important_selectors as $selector => $types){ |
|
| 1825 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1826 | - $types = array_combine($types,$types); |
|
| 1827 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1828 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1829 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1830 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1824 | + foreach ($important_selectors as $selector => $types) { |
|
| 1825 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1826 | + $types = array_combine($types, $types); |
|
| 1827 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 1828 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 1829 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 1830 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 1831 | 1831 | } |
| 1832 | 1832 | |
| 1833 | 1833 | // add any color rules |
| 1834 | - if(!empty($color)){ |
|
| 1835 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1834 | + if (!empty($color)) { |
|
| 1835 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 1836 | 1836 | } |
| 1837 | - if(!empty($color_i)){ |
|
| 1838 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1837 | + if (!empty($color_i)) { |
|
| 1838 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 1839 | 1839 | } |
| 1840 | 1840 | |
| 1841 | 1841 | // add any background color rules |
| 1842 | - if(!empty($background)){ |
|
| 1843 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1842 | + if (!empty($background)) { |
|
| 1843 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 1844 | 1844 | } |
| 1845 | - if(!empty($background_i)){ |
|
| 1846 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1845 | + if (!empty($background_i)) { |
|
| 1846 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 1847 | 1847 | } |
| 1848 | 1848 | |
| 1849 | 1849 | // add any border color rules |
| 1850 | - if(!empty($border)){ |
|
| 1851 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1850 | + if (!empty($border)) { |
|
| 1851 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 1852 | 1852 | } |
| 1853 | - if(!empty($border_i)){ |
|
| 1854 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1853 | + if (!empty($border_i)) { |
|
| 1854 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | 1857 | // add any fill color rules |
| 1858 | - if(!empty($fill)){ |
|
| 1859 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1858 | + if (!empty($fill)) { |
|
| 1859 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 1860 | 1860 | } |
| 1861 | - if(!empty($fill_i)){ |
|
| 1862 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1861 | + if (!empty($fill_i)) { |
|
| 1862 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 1863 | 1863 | } |
| 1864 | 1864 | |
| 1865 | 1865 | |
| 1866 | 1866 | $prefix = $compatibility ? ".bsui " : ""; |
| 1867 | 1867 | |
| 1868 | 1868 | // darken |
| 1869 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1870 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1871 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1869 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 1870 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 1871 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 1872 | 1872 | |
| 1873 | 1873 | // lighten |
| 1874 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1874 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 1875 | 1875 | |
| 1876 | 1876 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 1877 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1877 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 1878 | 1878 | |
| 1879 | 1879 | |
| 1880 | 1880 | // button states |
| 1881 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1882 | - $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;} "; |
|
| 1883 | - $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.";} "; |
|
| 1884 | - $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;} "; |
|
| 1881 | + $output .= $prefix . " .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 1882 | + $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;} "; |
|
| 1883 | + $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 . ";} "; |
|
| 1884 | + $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;} "; |
|
| 1885 | 1885 | |
| 1886 | 1886 | |
| 1887 | 1887 | // dropdown's |
| 1888 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1888 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1889 | 1889 | |
| 1890 | 1890 | |
| 1891 | 1891 | // input states |
| 1892 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1892 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1893 | 1893 | |
| 1894 | 1894 | // page link |
| 1895 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1895 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1896 | 1896 | |
| 1897 | 1897 | return $output; |
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | - public static function css_secondary($color_code,$compatibility){; |
|
| 1900 | + public static function css_secondary($color_code, $compatibility) {; |
|
| 1901 | 1901 | $color_code = sanitize_hex_color($color_code); |
| 1902 | - if(!$color_code){return '';} |
|
| 1902 | + if (!$color_code) {return ''; } |
|
| 1903 | 1903 | /** |
| 1904 | 1904 | * c = color, b = background color, o = border-color, f = fill |
| 1905 | 1905 | */ |
| 1906 | 1906 | $selectors = array( |
| 1907 | - '.btn-secondary' => array('b','o'), |
|
| 1908 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 1909 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 1910 | - '.btn-outline-secondary' => array('c','o'), |
|
| 1911 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1907 | + '.btn-secondary' => array('b', 'o'), |
|
| 1908 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
| 1909 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
| 1910 | + '.btn-outline-secondary' => array('c', 'o'), |
|
| 1911 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
| 1912 | 1912 | '.btn-outline-secondary.disabled' => array('c'), |
| 1913 | 1913 | '.btn-outline-secondary:disabled' => array('c'), |
| 1914 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1915 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1916 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1914 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 1915 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 1916 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
| 1917 | 1917 | '.badge-secondary' => array('b'), |
| 1918 | - '.alert-secondary' => array('b','o'), |
|
| 1918 | + '.alert-secondary' => array('b', 'o'), |
|
| 1919 | 1919 | '.btn-link.btn-secondary' => array('c'), |
| 1920 | 1920 | ); |
| 1921 | 1921 | |
| 1922 | 1922 | $important_selectors = array( |
| 1923 | - '.bg-secondary' => array('b','f'), |
|
| 1923 | + '.bg-secondary' => array('b', 'f'), |
|
| 1924 | 1924 | '.border-secondary' => array('o'), |
| 1925 | 1925 | '.text-secondary' => array('c'), |
| 1926 | 1926 | ); |
@@ -1937,77 +1937,77 @@ discard block |
||
| 1937 | 1937 | $output = ''; |
| 1938 | 1938 | |
| 1939 | 1939 | // build rules into each type |
| 1940 | - foreach($selectors as $selector => $types){ |
|
| 1941 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1942 | - $types = array_combine($types,$types); |
|
| 1943 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1944 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1945 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1946 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1940 | + foreach ($selectors as $selector => $types) { |
|
| 1941 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1942 | + $types = array_combine($types, $types); |
|
| 1943 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 1944 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 1945 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 1946 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 1947 | 1947 | } |
| 1948 | 1948 | |
| 1949 | 1949 | // build rules into each type |
| 1950 | - foreach($important_selectors as $selector => $types){ |
|
| 1951 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1952 | - $types = array_combine($types,$types); |
|
| 1953 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1954 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1955 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1956 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1950 | + foreach ($important_selectors as $selector => $types) { |
|
| 1951 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1952 | + $types = array_combine($types, $types); |
|
| 1953 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 1954 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 1955 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 1956 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | 1959 | // add any color rules |
| 1960 | - if(!empty($color)){ |
|
| 1961 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1960 | + if (!empty($color)) { |
|
| 1961 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 1962 | 1962 | } |
| 1963 | - if(!empty($color_i)){ |
|
| 1964 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1963 | + if (!empty($color_i)) { |
|
| 1964 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | 1967 | // add any background color rules |
| 1968 | - if(!empty($background)){ |
|
| 1969 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1968 | + if (!empty($background)) { |
|
| 1969 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 1970 | 1970 | } |
| 1971 | - if(!empty($background_i)){ |
|
| 1972 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1971 | + if (!empty($background_i)) { |
|
| 1972 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | 1975 | // add any border color rules |
| 1976 | - if(!empty($border)){ |
|
| 1977 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1976 | + if (!empty($border)) { |
|
| 1977 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 1978 | 1978 | } |
| 1979 | - if(!empty($border_i)){ |
|
| 1980 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1979 | + if (!empty($border_i)) { |
|
| 1980 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | 1983 | // add any fill color rules |
| 1984 | - if(!empty($fill)){ |
|
| 1985 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1984 | + if (!empty($fill)) { |
|
| 1985 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 1986 | 1986 | } |
| 1987 | - if(!empty($fill_i)){ |
|
| 1988 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1987 | + if (!empty($fill_i)) { |
|
| 1988 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | 1991 | |
| 1992 | 1992 | $prefix = $compatibility ? ".bsui " : ""; |
| 1993 | 1993 | |
| 1994 | 1994 | // darken |
| 1995 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1996 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1997 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1995 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 1996 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 1997 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 1998 | 1998 | |
| 1999 | 1999 | // lighten |
| 2000 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2000 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 2001 | 2001 | |
| 2002 | 2002 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 2003 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2003 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 2004 | 2004 | |
| 2005 | 2005 | |
| 2006 | 2006 | // button states |
| 2007 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2008 | - $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;} "; |
|
| 2009 | - $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.";} "; |
|
| 2010 | - $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;} "; |
|
| 2007 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 2008 | + $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;} "; |
|
| 2009 | + $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 . ";} "; |
|
| 2010 | + $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;} "; |
|
| 2011 | 2011 | |
| 2012 | 2012 | |
| 2013 | 2013 | return $output; |
@@ -2043,8 +2043,8 @@ discard block |
||
| 2043 | 2043 | /** |
| 2044 | 2044 | * Check if we should display examples. |
| 2045 | 2045 | */ |
| 2046 | - public function maybe_show_examples(){ |
|
| 2047 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2046 | + public function maybe_show_examples() { |
|
| 2047 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
| 2048 | 2048 | echo "<head>"; |
| 2049 | 2049 | wp_head(); |
| 2050 | 2050 | echo "</head>"; |
@@ -2060,7 +2060,7 @@ discard block |
||
| 2060 | 2060 | * |
| 2061 | 2061 | * @return string |
| 2062 | 2062 | */ |
| 2063 | - public function get_examples(){ |
|
| 2063 | + public function get_examples() { |
|
| 2064 | 2064 | $output = ''; |
| 2065 | 2065 | |
| 2066 | 2066 | |
@@ -2166,74 +2166,74 @@ discard block |
||
| 2166 | 2166 | */ |
| 2167 | 2167 | public static function calendar_params() { |
| 2168 | 2168 | $params = array( |
| 2169 | - 'month_long_1' => __( 'January', 'aui' ), |
|
| 2170 | - 'month_long_2' => __( 'February', 'aui' ), |
|
| 2171 | - 'month_long_3' => __( 'March', 'aui' ), |
|
| 2172 | - 'month_long_4' => __( 'April', 'aui' ), |
|
| 2173 | - 'month_long_5' => __( 'May', 'aui' ), |
|
| 2174 | - 'month_long_6' => __( 'June', 'aui' ), |
|
| 2175 | - 'month_long_7' => __( 'July', 'aui' ), |
|
| 2176 | - 'month_long_8' => __( 'August', 'aui' ), |
|
| 2177 | - 'month_long_9' => __( 'September', 'aui' ), |
|
| 2178 | - 'month_long_10' => __( 'October', 'aui' ), |
|
| 2179 | - 'month_long_11' => __( 'November', 'aui' ), |
|
| 2180 | - 'month_long_12' => __( 'December', 'aui' ), |
|
| 2181 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 2182 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 2183 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 2184 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 2185 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 2186 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 2187 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 2188 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 2189 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 2190 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 2191 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 2192 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 2193 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 2194 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 2195 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 2196 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 2197 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 2198 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 2199 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 2200 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 2201 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 2202 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 2203 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
| 2204 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 2205 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 2206 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 2207 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 2208 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 2209 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 2210 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 2211 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 2212 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 2213 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 2214 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 2215 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 2216 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 2217 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 2218 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 2219 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 2220 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 2221 | - 'am_lower' => __( 'am', 'aui' ), |
|
| 2222 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
| 2223 | - 'am_upper' => __( 'AM', 'aui' ), |
|
| 2224 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
| 2225 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2169 | + 'month_long_1' => __('January', 'aui'), |
|
| 2170 | + 'month_long_2' => __('February', 'aui'), |
|
| 2171 | + 'month_long_3' => __('March', 'aui'), |
|
| 2172 | + 'month_long_4' => __('April', 'aui'), |
|
| 2173 | + 'month_long_5' => __('May', 'aui'), |
|
| 2174 | + 'month_long_6' => __('June', 'aui'), |
|
| 2175 | + 'month_long_7' => __('July', 'aui'), |
|
| 2176 | + 'month_long_8' => __('August', 'aui'), |
|
| 2177 | + 'month_long_9' => __('September', 'aui'), |
|
| 2178 | + 'month_long_10' => __('October', 'aui'), |
|
| 2179 | + 'month_long_11' => __('November', 'aui'), |
|
| 2180 | + 'month_long_12' => __('December', 'aui'), |
|
| 2181 | + 'month_s_1' => _x('Jan', 'January abbreviation', 'aui'), |
|
| 2182 | + 'month_s_2' => _x('Feb', 'February abbreviation', 'aui'), |
|
| 2183 | + 'month_s_3' => _x('Mar', 'March abbreviation', 'aui'), |
|
| 2184 | + 'month_s_4' => _x('Apr', 'April abbreviation', 'aui'), |
|
| 2185 | + 'month_s_5' => _x('May', 'May abbreviation', 'aui'), |
|
| 2186 | + 'month_s_6' => _x('Jun', 'June abbreviation', 'aui'), |
|
| 2187 | + 'month_s_7' => _x('Jul', 'July abbreviation', 'aui'), |
|
| 2188 | + 'month_s_8' => _x('Aug', 'August abbreviation', 'aui'), |
|
| 2189 | + 'month_s_9' => _x('Sep', 'September abbreviation', 'aui'), |
|
| 2190 | + 'month_s_10' => _x('Oct', 'October abbreviation', 'aui'), |
|
| 2191 | + 'month_s_11' => _x('Nov', 'November abbreviation', 'aui'), |
|
| 2192 | + 'month_s_12' => _x('Dec', 'December abbreviation', 'aui'), |
|
| 2193 | + 'day_s1_1' => _x('S', 'Sunday initial', 'aui'), |
|
| 2194 | + 'day_s1_2' => _x('M', 'Monday initial', 'aui'), |
|
| 2195 | + 'day_s1_3' => _x('T', 'Tuesday initial', 'aui'), |
|
| 2196 | + 'day_s1_4' => _x('W', 'Wednesday initial', 'aui'), |
|
| 2197 | + 'day_s1_5' => _x('T', 'Friday initial', 'aui'), |
|
| 2198 | + 'day_s1_6' => _x('F', 'Thursday initial', 'aui'), |
|
| 2199 | + 'day_s1_7' => _x('S', 'Saturday initial', 'aui'), |
|
| 2200 | + 'day_s2_1' => __('Su', 'aui'), |
|
| 2201 | + 'day_s2_2' => __('Mo', 'aui'), |
|
| 2202 | + 'day_s2_3' => __('Tu', 'aui'), |
|
| 2203 | + 'day_s2_4' => __('We', 'aui'), |
|
| 2204 | + 'day_s2_5' => __('Th', 'aui'), |
|
| 2205 | + 'day_s2_6' => __('Fr', 'aui'), |
|
| 2206 | + 'day_s2_7' => __('Sa', 'aui'), |
|
| 2207 | + 'day_s3_1' => __('Sun', 'aui'), |
|
| 2208 | + 'day_s3_2' => __('Mon', 'aui'), |
|
| 2209 | + 'day_s3_3' => __('Tue', 'aui'), |
|
| 2210 | + 'day_s3_4' => __('Wed', 'aui'), |
|
| 2211 | + 'day_s3_5' => __('Thu', 'aui'), |
|
| 2212 | + 'day_s3_6' => __('Fri', 'aui'), |
|
| 2213 | + 'day_s3_7' => __('Sat', 'aui'), |
|
| 2214 | + 'day_s5_1' => __('Sunday', 'aui'), |
|
| 2215 | + 'day_s5_2' => __('Monday', 'aui'), |
|
| 2216 | + 'day_s5_3' => __('Tuesday', 'aui'), |
|
| 2217 | + 'day_s5_4' => __('Wednesday', 'aui'), |
|
| 2218 | + 'day_s5_5' => __('Thursday', 'aui'), |
|
| 2219 | + 'day_s5_6' => __('Friday', 'aui'), |
|
| 2220 | + 'day_s5_7' => __('Saturday', 'aui'), |
|
| 2221 | + 'am_lower' => __('am', 'aui'), |
|
| 2222 | + 'pm_lower' => __('pm', 'aui'), |
|
| 2223 | + 'am_upper' => __('AM', 'aui'), |
|
| 2224 | + 'pm_upper' => __('PM', 'aui'), |
|
| 2225 | + 'firstDayOfWeek' => (int) get_option('start_of_week'), |
|
| 2226 | 2226 | 'time_24hr' => false, |
| 2227 | - 'year' => __( 'Year', 'aui' ), |
|
| 2228 | - 'hour' => __( 'Hour', 'aui' ), |
|
| 2229 | - 'minute' => __( 'Minute', 'aui' ), |
|
| 2230 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 2231 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 2232 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 2233 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 2227 | + 'year' => __('Year', 'aui'), |
|
| 2228 | + 'hour' => __('Hour', 'aui'), |
|
| 2229 | + 'minute' => __('Minute', 'aui'), |
|
| 2230 | + 'weekAbbreviation' => __('Wk', 'aui'), |
|
| 2231 | + 'rangeSeparator' => __(' to ', 'aui'), |
|
| 2232 | + 'scrollTitle' => __('Scroll to increment', 'aui'), |
|
| 2233 | + 'toggleTitle' => __('Click to toggle', 'aui') |
|
| 2234 | 2234 | ); |
| 2235 | 2235 | |
| 2236 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2236 | + return apply_filters('ayecode_ui_calendar_params', $params); |
|
| 2237 | 2237 | } |
| 2238 | 2238 | |
| 2239 | 2239 | /** |
@@ -2246,47 +2246,47 @@ discard block |
||
| 2246 | 2246 | public static function flatpickr_locale() { |
| 2247 | 2247 | $params = self::calendar_params(); |
| 2248 | 2248 | |
| 2249 | - if ( is_string( $params ) ) { |
|
| 2250 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2249 | + if (is_string($params)) { |
|
| 2250 | + $params = html_entity_decode($params, ENT_QUOTES, 'UTF-8'); |
|
| 2251 | 2251 | } else { |
| 2252 | - foreach ( (array) $params as $key => $value ) { |
|
| 2253 | - if ( ! is_scalar( $value ) ) { |
|
| 2252 | + foreach ((array) $params as $key => $value) { |
|
| 2253 | + if (!is_scalar($value)) { |
|
| 2254 | 2254 | continue; |
| 2255 | 2255 | } |
| 2256 | 2256 | |
| 2257 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2257 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 2258 | 2258 | } |
| 2259 | 2259 | } |
| 2260 | 2260 | |
| 2261 | 2261 | $day_s3 = array(); |
| 2262 | 2262 | $day_s5 = array(); |
| 2263 | 2263 | |
| 2264 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2265 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2266 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2264 | + for ($i = 1; $i <= 7; $i++) { |
|
| 2265 | + $day_s3[] = addslashes($params['day_s3_' . $i]); |
|
| 2266 | + $day_s5[] = addslashes($params['day_s3_' . $i]); |
|
| 2267 | 2267 | } |
| 2268 | 2268 | |
| 2269 | 2269 | $month_s = array(); |
| 2270 | 2270 | $month_long = array(); |
| 2271 | 2271 | |
| 2272 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2273 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 2274 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 2272 | + for ($i = 1; $i <= 12; $i++) { |
|
| 2273 | + $month_s[] = addslashes($params['month_s_' . $i]); |
|
| 2274 | + $month_long[] = addslashes($params['month_long_' . $i]); |
|
| 2275 | 2275 | } |
| 2276 | 2276 | |
| 2277 | 2277 | ob_start(); |
| 2278 | -if ( 0 ) { ?><script><?php } ?> |
|
| 2278 | +if (0) { ?><script><?php } ?> |
|
| 2279 | 2279 | { |
| 2280 | 2280 | weekdays: { |
| 2281 | - shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'], |
|
| 2282 | - longhand: ['<?php echo implode( "','", $day_s5 ); ?>'], |
|
| 2281 | + shorthand: ['<?php echo implode("','", $day_s3); ?>'], |
|
| 2282 | + longhand: ['<?php echo implode("','", $day_s5); ?>'], |
|
| 2283 | 2283 | }, |
| 2284 | 2284 | months: { |
| 2285 | - shorthand: ['<?php echo implode( "','", $month_s ); ?>'], |
|
| 2286 | - longhand: ['<?php echo implode( "','", $month_long ); ?>'], |
|
| 2285 | + shorthand: ['<?php echo implode("','", $month_s); ?>'], |
|
| 2286 | + longhand: ['<?php echo implode("','", $month_long); ?>'], |
|
| 2287 | 2287 | }, |
| 2288 | 2288 | daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31], |
| 2289 | - firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>, |
|
| 2289 | + firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>, |
|
| 2290 | 2290 | ordinal: function (nth) { |
| 2291 | 2291 | var s = nth % 100; |
| 2292 | 2292 | if (s > 3 && s < 21) |
@@ -2302,21 +2302,21 @@ discard block |
||
| 2302 | 2302 | return "th"; |
| 2303 | 2303 | } |
| 2304 | 2304 | }, |
| 2305 | - rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>', |
|
| 2306 | - weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>', |
|
| 2307 | - scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>', |
|
| 2308 | - toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>', |
|
| 2309 | - amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'], |
|
| 2310 | - yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>', |
|
| 2311 | - hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>', |
|
| 2312 | - minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>', |
|
| 2313 | - time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?> |
|
| 2305 | + rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>', |
|
| 2306 | + weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>', |
|
| 2307 | + scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>', |
|
| 2308 | + toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>', |
|
| 2309 | + amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'], |
|
| 2310 | + yearAriaLabel: '<?php echo addslashes($params['year']); ?>', |
|
| 2311 | + hourAriaLabel: '<?php echo addslashes($params['hour']); ?>', |
|
| 2312 | + minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>', |
|
| 2313 | + time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?> |
|
| 2314 | 2314 | } |
| 2315 | -<?php if ( 0 ) { ?></script><?php } ?> |
|
| 2315 | +<?php if (0) { ?></script><?php } ?> |
|
| 2316 | 2316 | <?php |
| 2317 | 2317 | $locale = ob_get_clean(); |
| 2318 | 2318 | |
| 2319 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2319 | + return apply_filters('ayecode_ui_flatpickr_locale', trim($locale)); |
|
| 2320 | 2320 | } |
| 2321 | 2321 | |
| 2322 | 2322 | /** |
@@ -2328,20 +2328,20 @@ discard block |
||
| 2328 | 2328 | */ |
| 2329 | 2329 | public static function select2_params() { |
| 2330 | 2330 | $params = array( |
| 2331 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2332 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2333 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2334 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2335 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2336 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2337 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2338 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2339 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2340 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2341 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2331 | + 'i18n_select_state_text' => esc_attr__('Select an option…', 'aui'), |
|
| 2332 | + 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'aui'), |
|
| 2333 | + 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'aui'), |
|
| 2334 | + 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'aui'), |
|
| 2335 | + 'i18n_input_too_short_n' => _x('Please enter %item% or more characters', 'enhanced select', 'aui'), |
|
| 2336 | + 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'aui'), |
|
| 2337 | + 'i18n_input_too_long_n' => _x('Please delete %item% characters', 'enhanced select', 'aui'), |
|
| 2338 | + 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'aui'), |
|
| 2339 | + 'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'aui'), |
|
| 2340 | + 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'aui'), |
|
| 2341 | + 'i18n_searching' => _x('Searching…', 'enhanced select', 'aui') |
|
| 2342 | 2342 | ); |
| 2343 | 2343 | |
| 2344 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2344 | + return apply_filters('ayecode_ui_select2_params', $params); |
|
| 2345 | 2345 | } |
| 2346 | 2346 | |
| 2347 | 2347 | /** |
@@ -2354,17 +2354,17 @@ discard block |
||
| 2354 | 2354 | public static function select2_locale() { |
| 2355 | 2355 | $params = self::select2_params(); |
| 2356 | 2356 | |
| 2357 | - foreach ( (array) $params as $key => $value ) { |
|
| 2358 | - if ( ! is_scalar( $value ) ) { |
|
| 2357 | + foreach ((array) $params as $key => $value) { |
|
| 2358 | + if (!is_scalar($value)) { |
|
| 2359 | 2359 | continue; |
| 2360 | 2360 | } |
| 2361 | 2361 | |
| 2362 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2362 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 2363 | 2363 | } |
| 2364 | 2364 | |
| 2365 | - $locale = json_encode( $params ); |
|
| 2365 | + $locale = json_encode($params); |
|
| 2366 | 2366 | |
| 2367 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2367 | + return apply_filters('ayecode_ui_select2_locale', trim($locale)); |
|
| 2368 | 2368 | } |
| 2369 | 2369 | |
| 2370 | 2370 | /** |
@@ -2377,35 +2377,35 @@ discard block |
||
| 2377 | 2377 | public static function timeago_locale() { |
| 2378 | 2378 | $params = array( |
| 2379 | 2379 | 'prefix_ago' => '', |
| 2380 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2381 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2380 | + 'suffix_ago' => ' ' . _x('ago', 'time ago', 'aui'), |
|
| 2381 | + 'prefix_after' => _x('after', 'time ago', 'aui') . ' ', |
|
| 2382 | 2382 | 'suffix_after' => '', |
| 2383 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2384 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2385 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2386 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2387 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2388 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2389 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2390 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2391 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2392 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2393 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2383 | + 'seconds' => _x('less than a minute', 'time ago', 'aui'), |
|
| 2384 | + 'minute' => _x('about a minute', 'time ago', 'aui'), |
|
| 2385 | + 'minutes' => _x('%d minutes', 'time ago', 'aui'), |
|
| 2386 | + 'hour' => _x('about an hour', 'time ago', 'aui'), |
|
| 2387 | + 'hours' => _x('about %d hours', 'time ago', 'aui'), |
|
| 2388 | + 'day' => _x('a day', 'time ago', 'aui'), |
|
| 2389 | + 'days' => _x('%d days', 'time ago', 'aui'), |
|
| 2390 | + 'month' => _x('about a month', 'time ago', 'aui'), |
|
| 2391 | + 'months' => _x('%d months', 'time ago', 'aui'), |
|
| 2392 | + 'year' => _x('about a year', 'time ago', 'aui'), |
|
| 2393 | + 'years' => _x('%d years', 'time ago', 'aui'), |
|
| 2394 | 2394 | ); |
| 2395 | 2395 | |
| 2396 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2396 | + $params = apply_filters('ayecode_ui_timeago_params', $params); |
|
| 2397 | 2397 | |
| 2398 | - foreach ( (array) $params as $key => $value ) { |
|
| 2399 | - if ( ! is_scalar( $value ) ) { |
|
| 2398 | + foreach ((array) $params as $key => $value) { |
|
| 2399 | + if (!is_scalar($value)) { |
|
| 2400 | 2400 | continue; |
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2403 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 2404 | 2404 | } |
| 2405 | 2405 | |
| 2406 | - $locale = json_encode( $params ); |
|
| 2406 | + $locale = json_encode($params); |
|
| 2407 | 2407 | |
| 2408 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2408 | + return apply_filters('ayecode_ui_timeago_locale', trim($locale)); |
|
| 2409 | 2409 | } |
| 2410 | 2410 | |
| 2411 | 2411 | /** |
@@ -2416,7 +2416,7 @@ discard block |
||
| 2416 | 2416 | * @return mixed |
| 2417 | 2417 | */ |
| 2418 | 2418 | public static function minify_js($input) { |
| 2419 | - if(trim($input) === "") return $input; |
|
| 2419 | + if (trim($input) === "") return $input; |
|
| 2420 | 2420 | return preg_replace( |
| 2421 | 2421 | array( |
| 2422 | 2422 | // Remove comment(s) |
@@ -2448,7 +2448,7 @@ discard block |
||
| 2448 | 2448 | * @return mixed |
| 2449 | 2449 | */ |
| 2450 | 2450 | public static function minify_css($input) { |
| 2451 | - if(trim($input) === "") return $input; |
|
| 2451 | + if (trim($input) === "") return $input; |
|
| 2452 | 2452 | return preg_replace( |
| 2453 | 2453 | array( |
| 2454 | 2454 | // Remove comment(s) |
@@ -2996,12 +2996,12 @@ discard block |
||
| 2996 | 2996 | }); |
| 2997 | 2997 | } |
| 2998 | 2998 | } |
| 2999 | -<?php do_action( 'aui_conditional_fields_js', $this ); ?> |
|
| 2999 | +<?php do_action('aui_conditional_fields_js', $this); ?> |
|
| 3000 | 3000 | </script> |
| 3001 | 3001 | <?php |
| 3002 | 3002 | $output = ob_get_clean(); |
| 3003 | 3003 | |
| 3004 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3004 | + return str_replace(array('<script>', '</script>'), '', self::minify_js($output)); |
|
| 3005 | 3005 | } |
| 3006 | 3006 | } |
| 3007 | 3007 | |
@@ -7,40 +7,40 @@ |
||
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | - exit; |
|
| 10 | + exit; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | 16 | add_action('after_setup_theme', function () { |
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | - $this_version = "0.1.75"; |
|
| 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.1.75"; |
|
| 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 | } |
@@ -6,39 +6,39 @@ |
||
| 6 | 6 | /** |
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if (!defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | -add_action('after_setup_theme', function () { |
|
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 16 | +add_action('after_setup_theme', function() { |
|
| 17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
| 18 | 18 | $this_version = "0.1.75"; |
| 19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | - $ayecode_ui_version = $this_version ; |
|
| 21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 19 | + if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) { |
|
| 20 | + $ayecode_ui_version = $this_version; |
|
| 21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
| 22 | 22 | } |
| 23 | 23 | },0); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
| 27 | 27 | */ |
| 28 | -add_action('after_setup_theme', function () { |
|
| 28 | +add_action('after_setup_theme', function() { |
|
| 29 | 29 | global $ayecode_ui_file_key; |
| 30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
| 31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
| 32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
| 33 | 33 | } |
| 34 | 34 | },1); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Add the function that calls the class. |
| 38 | 38 | */ |
| 39 | -if(!function_exists('aui')){ |
|
| 40 | - function aui(){ |
|
| 41 | - if(!class_exists("AUI",false)){ |
|
| 39 | +if (!function_exists('aui')) { |
|
| 40 | + function aui() { |
|
| 41 | + if (!class_exists("AUI", false)) { |
|
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | return AUI::instance(); |
@@ -1,59 +1,59 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 11 | - * |
|
| 12 | - * Should not be called direct but extended instead. |
|
| 13 | - * |
|
| 14 | - * Class WP_Super_Duper |
|
| 15 | - * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 16 | - * @ver 1.1.1 |
|
| 17 | - */ |
|
| 18 | - class WP_Super_Duper extends WP_Widget { |
|
| 19 | - |
|
| 20 | - public $version = "1.1.1"; |
|
| 21 | - public $font_awesome_icon_version = "5.11.2"; |
|
| 22 | - public $block_code; |
|
| 23 | - public $options; |
|
| 24 | - public $base_id; |
|
| 25 | - public $settings_hash; |
|
| 26 | - public $arguments = array(); |
|
| 27 | - public $instance = array(); |
|
| 28 | - private $class_name; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * The relative url to the current folder. |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - public $url = ''; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Take the array options and use them to build. |
|
| 39 | - */ |
|
| 40 | - public function __construct( $options ) { |
|
| 41 | - global $sd_widgets; |
|
| 42 | - |
|
| 43 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 44 | - 'name' => $options['name'], |
|
| 45 | - 'class_name' => $options['class_name'], |
|
| 46 | - 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
|
| 47 | - ); |
|
| 48 | - $this->base_id = $options['base_id']; |
|
| 49 | - // lets filter the options before we do anything |
|
| 50 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 51 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 52 | - $options = $this->add_name_from_key( $options ); |
|
| 53 | - $this->options = $options; |
|
| 54 | - |
|
| 55 | - $this->base_id = $options['base_id']; |
|
| 56 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 9 | + /** |
|
| 10 | + * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 11 | + * |
|
| 12 | + * Should not be called direct but extended instead. |
|
| 13 | + * |
|
| 14 | + * Class WP_Super_Duper |
|
| 15 | + * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 16 | + * @ver 1.1.1 |
|
| 17 | + */ |
|
| 18 | + class WP_Super_Duper extends WP_Widget { |
|
| 19 | + |
|
| 20 | + public $version = "1.1.1"; |
|
| 21 | + public $font_awesome_icon_version = "5.11.2"; |
|
| 22 | + public $block_code; |
|
| 23 | + public $options; |
|
| 24 | + public $base_id; |
|
| 25 | + public $settings_hash; |
|
| 26 | + public $arguments = array(); |
|
| 27 | + public $instance = array(); |
|
| 28 | + private $class_name; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * The relative url to the current folder. |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + public $url = ''; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Take the array options and use them to build. |
|
| 39 | + */ |
|
| 40 | + public function __construct( $options ) { |
|
| 41 | + global $sd_widgets; |
|
| 42 | + |
|
| 43 | + $sd_widgets[ $options['base_id'] ] = array( |
|
| 44 | + 'name' => $options['name'], |
|
| 45 | + 'class_name' => $options['class_name'], |
|
| 46 | + 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
|
| 47 | + ); |
|
| 48 | + $this->base_id = $options['base_id']; |
|
| 49 | + // lets filter the options before we do anything |
|
| 50 | + $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 51 | + $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 52 | + $options = $this->add_name_from_key( $options ); |
|
| 53 | + $this->options = $options; |
|
| 54 | + |
|
| 55 | + $this->base_id = $options['base_id']; |
|
| 56 | + $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 57 | 57 | |
| 58 | 58 | // nested blocks can't work as a widget |
| 59 | 59 | if(!empty($this->options['nested-block'])){ |
@@ -64,234 +64,234 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - // init parent |
|
| 68 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 67 | + // init parent |
|
| 68 | + if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 69 | 69 | parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
| 70 | - } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - if ( isset( $options['class_name'] ) ) { |
|
| 74 | - // register widget |
|
| 75 | - $this->class_name = $options['class_name']; |
|
| 73 | + if ( isset( $options['class_name'] ) ) { |
|
| 74 | + // register widget |
|
| 75 | + $this->class_name = $options['class_name']; |
|
| 76 | 76 | |
| 77 | - // register shortcode, this needs to be done even for blocks and widgets |
|
| 77 | + // register shortcode, this needs to be done even for blocks and widgets |
|
| 78 | 78 | $this->register_shortcode(); |
| 79 | 79 | |
| 80 | 80 | |
| 81 | - // Fusion Builder (avada) support |
|
| 82 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 83 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 84 | - } |
|
| 81 | + // Fusion Builder (avada) support |
|
| 82 | + if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 83 | + add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - // register block |
|
| 87 | - if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 88 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 86 | + // register block |
|
| 87 | + if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 88 | + add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 89 | 89 | } |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - // add the CSS and JS we need ONCE |
|
| 93 | - global $sd_widget_scripts; |
|
| 92 | + // add the CSS and JS we need ONCE |
|
| 93 | + global $sd_widget_scripts; |
|
| 94 | 94 | |
| 95 | - if ( ! $sd_widget_scripts ) { |
|
| 96 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 97 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 98 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 95 | + if ( ! $sd_widget_scripts ) { |
|
| 96 | + wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 97 | + wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 98 | + wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 99 | 99 | |
| 100 | - // maybe add elementor editor styles |
|
| 101 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 100 | + // maybe add elementor editor styles |
|
| 101 | + add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 102 | 102 | |
| 103 | - $sd_widget_scripts = true; |
|
| 103 | + $sd_widget_scripts = true; |
|
| 104 | 104 | |
| 105 | - // add shortcode insert button once |
|
| 106 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 107 | - // generatepress theme sections compatibility |
|
| 108 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 109 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 110 | - } |
|
| 111 | - /* Load script on Divi theme builder page */ |
|
| 112 | - if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 113 | - add_thickbox(); |
|
| 114 | - add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 115 | - } |
|
| 105 | + // add shortcode insert button once |
|
| 106 | + add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 107 | + // generatepress theme sections compatibility |
|
| 108 | + if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 109 | + add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 110 | + } |
|
| 111 | + /* Load script on Divi theme builder page */ |
|
| 112 | + if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 113 | + add_thickbox(); |
|
| 114 | + add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - if ( $this->is_preview() ) { |
|
| 118 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 119 | - // this makes the insert button work for elementor |
|
| 120 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 121 | - $this, |
|
| 122 | - 'shortcode_insert_button_script' |
|
| 123 | - ) ); // for elementor |
|
| 124 | - } |
|
| 125 | - // this makes the insert button work for cornerstone |
|
| 126 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 117 | + if ( $this->is_preview() ) { |
|
| 118 | + add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 119 | + // this makes the insert button work for elementor |
|
| 120 | + add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 121 | + $this, |
|
| 122 | + 'shortcode_insert_button_script' |
|
| 123 | + ) ); // for elementor |
|
| 124 | + } |
|
| 125 | + // this makes the insert button work for cornerstone |
|
| 126 | + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 127 | 127 | |
| 128 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 129 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 128 | + add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 129 | + add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 130 | 130 | |
| 131 | - // add generator text to admin head |
|
| 132 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 133 | - } |
|
| 131 | + // add generator text to admin head |
|
| 132 | + add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 136 | - } |
|
| 135 | + do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * The register widget function |
| 140 | 140 | * @return void |
| 141 | 141 | */ |
| 142 | - public function _register() { |
|
| 142 | + public function _register() { |
|
| 143 | 143 | if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
| 144 | 144 | parent::_register(); |
| 145 | - } |
|
| 146 | - } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Add our widget CSS to elementor editor. |
|
| 150 | - */ |
|
| 151 | - public function elementor_editor_styles() { |
|
| 152 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 153 | - } |
|
| 148 | + /** |
|
| 149 | + * Add our widget CSS to elementor editor. |
|
| 150 | + */ |
|
| 151 | + public function elementor_editor_styles() { |
|
| 152 | + wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - public function register_fusion_element() { |
|
| 155 | + public function register_fusion_element() { |
|
| 156 | 156 | |
| 157 | - $options = $this->options; |
|
| 157 | + $options = $this->options; |
|
| 158 | 158 | |
| 159 | - if ( $this->base_id ) { |
|
| 159 | + if ( $this->base_id ) { |
|
| 160 | 160 | |
| 161 | - $params = $this->get_fusion_params(); |
|
| 161 | + $params = $this->get_fusion_params(); |
|
| 162 | 162 | |
| 163 | - $args = array( |
|
| 164 | - 'name' => $options['name'], |
|
| 165 | - 'shortcode' => $this->base_id, |
|
| 166 | - 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 167 | - 'allow_generator' => true, |
|
| 168 | - ); |
|
| 163 | + $args = array( |
|
| 164 | + 'name' => $options['name'], |
|
| 165 | + 'shortcode' => $this->base_id, |
|
| 166 | + 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 167 | + 'allow_generator' => true, |
|
| 168 | + ); |
|
| 169 | 169 | |
| 170 | - if ( ! empty( $params ) ) { |
|
| 171 | - $args['params'] = $params; |
|
| 172 | - } |
|
| 170 | + if ( ! empty( $params ) ) { |
|
| 171 | + $args['params'] = $params; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - fusion_builder_map( $args ); |
|
| 175 | - } |
|
| 174 | + fusion_builder_map( $args ); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - public function get_fusion_params() { |
|
| 180 | - $params = array(); |
|
| 181 | - $arguments = $this->get_arguments(); |
|
| 182 | - |
|
| 183 | - if ( ! empty( $arguments ) ) { |
|
| 184 | - foreach ( $arguments as $key => $val ) { |
|
| 185 | - $param = array(); |
|
| 186 | - // type |
|
| 187 | - $param['type'] = str_replace( |
|
| 188 | - array( |
|
| 189 | - "text", |
|
| 190 | - "number", |
|
| 191 | - "email", |
|
| 192 | - "color", |
|
| 193 | - "checkbox" |
|
| 194 | - ), |
|
| 195 | - array( |
|
| 196 | - "textfield", |
|
| 197 | - "textfield", |
|
| 198 | - "textfield", |
|
| 199 | - "colorpicker", |
|
| 200 | - "select", |
|
| 201 | - |
|
| 202 | - ), |
|
| 203 | - $val['type'] ); |
|
| 204 | - |
|
| 205 | - // multiselect |
|
| 206 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 207 | - $param['type'] = 'multiple_select'; |
|
| 208 | - $param['multiple'] = true; |
|
| 209 | - } |
|
| 179 | + public function get_fusion_params() { |
|
| 180 | + $params = array(); |
|
| 181 | + $arguments = $this->get_arguments(); |
|
| 182 | + |
|
| 183 | + if ( ! empty( $arguments ) ) { |
|
| 184 | + foreach ( $arguments as $key => $val ) { |
|
| 185 | + $param = array(); |
|
| 186 | + // type |
|
| 187 | + $param['type'] = str_replace( |
|
| 188 | + array( |
|
| 189 | + "text", |
|
| 190 | + "number", |
|
| 191 | + "email", |
|
| 192 | + "color", |
|
| 193 | + "checkbox" |
|
| 194 | + ), |
|
| 195 | + array( |
|
| 196 | + "textfield", |
|
| 197 | + "textfield", |
|
| 198 | + "textfield", |
|
| 199 | + "colorpicker", |
|
| 200 | + "select", |
|
| 210 | 201 | |
| 211 | - // heading |
|
| 212 | - $param['heading'] = $val['title']; |
|
| 202 | + ), |
|
| 203 | + $val['type'] ); |
|
| 213 | 204 | |
| 214 | - // description |
|
| 215 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 205 | + // multiselect |
|
| 206 | + if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 207 | + $param['type'] = 'multiple_select'; |
|
| 208 | + $param['multiple'] = true; |
|
| 209 | + } |
|
| 216 | 210 | |
| 217 | - // param_name |
|
| 218 | - $param['param_name'] = $key; |
|
| 211 | + // heading |
|
| 212 | + $param['heading'] = $val['title']; |
|
| 219 | 213 | |
| 220 | - // Default |
|
| 221 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 214 | + // description |
|
| 215 | + $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 222 | 216 | |
| 223 | - // Group |
|
| 224 | - if ( isset( $val['group'] ) ) { |
|
| 225 | - $param['group'] = $val['group']; |
|
| 226 | - } |
|
| 217 | + // param_name |
|
| 218 | + $param['param_name'] = $key; |
|
| 227 | 219 | |
| 228 | - // value |
|
| 229 | - if ( $val['type'] == 'checkbox' ) { |
|
| 230 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 231 | - unset( $param['default'] ); |
|
| 232 | - } |
|
| 233 | - $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 234 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 235 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 236 | - } else { |
|
| 237 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 238 | - } |
|
| 220 | + // Default |
|
| 221 | + $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 239 | 222 | |
| 240 | - // setup the param |
|
| 241 | - $params[] = $param; |
|
| 223 | + // Group |
|
| 224 | + if ( isset( $val['group'] ) ) { |
|
| 225 | + $param['group'] = $val['group']; |
|
| 226 | + } |
|
| 242 | 227 | |
| 243 | - } |
|
| 244 | - } |
|
| 228 | + // value |
|
| 229 | + if ( $val['type'] == 'checkbox' ) { |
|
| 230 | + if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 231 | + unset( $param['default'] ); |
|
| 232 | + } |
|
| 233 | + $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 234 | + } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 235 | + $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 236 | + } else { |
|
| 237 | + $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 238 | + } |
|
| 245 | 239 | |
| 240 | + // setup the param |
|
| 241 | + $params[] = $param; |
|
| 246 | 242 | |
| 247 | - return $params; |
|
| 248 | - } |
|
| 243 | + } |
|
| 244 | + } |
|
| 249 | 245 | |
| 250 | - /** |
|
| 251 | - * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 252 | - */ |
|
| 253 | - public static function maybe_cornerstone_builder() { |
|
| 254 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 255 | - self::shortcode_insert_button_script(); |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | 246 | |
| 259 | - /** |
|
| 260 | - * A function to ge the shortcode builder picker html. |
|
| 261 | - * |
|
| 262 | - * @param string $editor_id |
|
| 263 | - * |
|
| 264 | - * @return string |
|
| 265 | - */ |
|
| 266 | - public static function get_picker( $editor_id = '' ) { |
|
| 267 | - |
|
| 268 | - ob_start(); |
|
| 269 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 270 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 271 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 272 | - $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 273 | - } |
|
| 247 | + return $params; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 252 | + */ |
|
| 253 | + public static function maybe_cornerstone_builder() { |
|
| 254 | + if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 255 | + self::shortcode_insert_button_script(); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * A function to ge the shortcode builder picker html. |
|
| 261 | + * |
|
| 262 | + * @param string $editor_id |
|
| 263 | + * |
|
| 264 | + * @return string |
|
| 265 | + */ |
|
| 266 | + public static function get_picker( $editor_id = '' ) { |
|
| 267 | + |
|
| 268 | + ob_start(); |
|
| 269 | + if ( isset( $_POST['editor_id'] ) ) { |
|
| 270 | + $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 271 | + } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 272 | + $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - global $sd_widgets; |
|
| 275 | + global $sd_widgets; |
|
| 276 | 276 | |
| 277 | 277 | // print_r($sd_widgets);exit; |
| 278 | - ?> |
|
| 278 | + ?> |
|
| 279 | 279 | |
| 280 | 280 | <div class="sd-shortcode-left-wrap"> |
| 281 | 281 | <?php |
| 282 | - ksort( $sd_widgets ); |
|
| 283 | - // print_r($sd_widgets);exit; |
|
| 284 | - if ( ! empty( $sd_widgets ) ) { |
|
| 285 | - echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 286 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 287 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 288 | - if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 289 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 290 | - } |
|
| 291 | - echo "</select>"; |
|
| 282 | + ksort( $sd_widgets ); |
|
| 283 | + // print_r($sd_widgets);exit; |
|
| 284 | + if ( ! empty( $sd_widgets ) ) { |
|
| 285 | + echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 286 | + echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 287 | + foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 288 | + if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 289 | + echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 290 | + } |
|
| 291 | + echo "</select>"; |
|
| 292 | 292 | |
| 293 | - } |
|
| 294 | - ?> |
|
| 293 | + } |
|
| 294 | + ?> |
|
| 295 | 295 | <div class="sd-shortcode-settings"></div> |
| 296 | 296 | |
| 297 | 297 | </div> |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | <?php if ( $editor_id != '' ) { ?> |
| 303 | 303 | <button class="button sd-insert-shortcode-button" |
| 304 | 304 | onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
| 305 | - echo "'" . $editor_id . "'"; |
|
| 306 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 305 | + echo "'" . $editor_id . "'"; |
|
| 306 | + } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 307 | 307 | <?php } ?> |
| 308 | 308 | <button class="button" |
| 309 | 309 | onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
@@ -311,135 +311,135 @@ discard block |
||
| 311 | 311 | </div> |
| 312 | 312 | <?php |
| 313 | 313 | |
| 314 | - $html = ob_get_clean(); |
|
| 314 | + $html = ob_get_clean(); |
|
| 315 | 315 | |
| 316 | - if ( wp_doing_ajax() ) { |
|
| 317 | - echo $html; |
|
| 318 | - $should_die = true; |
|
| 316 | + if ( wp_doing_ajax() ) { |
|
| 317 | + echo $html; |
|
| 318 | + $should_die = true; |
|
| 319 | 319 | |
| 320 | - // some builder get the editor via ajax so we should not die on those occasions |
|
| 321 | - $dont_die = array( |
|
| 322 | - 'parent_tag',// WP Bakery |
|
| 323 | - 'avia_request' // enfold |
|
| 324 | - ); |
|
| 320 | + // some builder get the editor via ajax so we should not die on those occasions |
|
| 321 | + $dont_die = array( |
|
| 322 | + 'parent_tag',// WP Bakery |
|
| 323 | + 'avia_request' // enfold |
|
| 324 | + ); |
|
| 325 | 325 | |
| 326 | - foreach ( $dont_die as $request ) { |
|
| 327 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 328 | - $should_die = false; |
|
| 329 | - } |
|
| 330 | - } |
|
| 326 | + foreach ( $dont_die as $request ) { |
|
| 327 | + if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 328 | + $should_die = false; |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - if ( $should_die ) { |
|
| 333 | - wp_die(); |
|
| 334 | - } |
|
| 332 | + if ( $should_die ) { |
|
| 333 | + wp_die(); |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - } else { |
|
| 337 | - return $html; |
|
| 338 | - } |
|
| 336 | + } else { |
|
| 337 | + return $html; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - return ''; |
|
| 340 | + return ''; |
|
| 341 | 341 | |
| 342 | - } |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - /** |
|
| 345 | - * Output the version in the admin header. |
|
| 346 | - */ |
|
| 347 | - public function generator() { |
|
| 348 | - echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 349 | - } |
|
| 344 | + /** |
|
| 345 | + * Output the version in the admin header. |
|
| 346 | + */ |
|
| 347 | + public function generator() { |
|
| 348 | + echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - /** |
|
| 352 | - * Get widget settings. |
|
| 353 | - * |
|
| 354 | - * @since 1.0.0 |
|
| 355 | - */ |
|
| 356 | - public static function get_widget_settings() { |
|
| 357 | - global $sd_widgets; |
|
| 358 | - |
|
| 359 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 360 | - if ( ! $shortcode ) { |
|
| 361 | - wp_die(); |
|
| 362 | - } |
|
| 363 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 364 | - if ( ! $widget_args ) { |
|
| 365 | - wp_die(); |
|
| 366 | - } |
|
| 367 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 368 | - if ( ! $class_name ) { |
|
| 369 | - wp_die(); |
|
| 370 | - } |
|
| 351 | + /** |
|
| 352 | + * Get widget settings. |
|
| 353 | + * |
|
| 354 | + * @since 1.0.0 |
|
| 355 | + */ |
|
| 356 | + public static function get_widget_settings() { |
|
| 357 | + global $sd_widgets; |
|
| 358 | + |
|
| 359 | + $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 360 | + if ( ! $shortcode ) { |
|
| 361 | + wp_die(); |
|
| 362 | + } |
|
| 363 | + $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 364 | + if ( ! $widget_args ) { |
|
| 365 | + wp_die(); |
|
| 366 | + } |
|
| 367 | + $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 368 | + if ( ! $class_name ) { |
|
| 369 | + wp_die(); |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - // invoke an instance method |
|
| 373 | - $widget = new $class_name; |
|
| 372 | + // invoke an instance method |
|
| 373 | + $widget = new $class_name; |
|
| 374 | 374 | |
| 375 | - ob_start(); |
|
| 376 | - $widget->form( array() ); |
|
| 377 | - $form = ob_get_clean(); |
|
| 378 | - echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 379 | - echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 380 | - echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 381 | - ?> |
|
| 375 | + ob_start(); |
|
| 376 | + $widget->form( array() ); |
|
| 377 | + $form = ob_get_clean(); |
|
| 378 | + echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 379 | + echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 380 | + echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 381 | + ?> |
|
| 382 | 382 | <?php |
| 383 | - wp_die(); |
|
| 384 | - } |
|
| 383 | + wp_die(); |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - /** |
|
| 387 | - * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 388 | - * |
|
| 389 | - * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 390 | - * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null. |
|
| 391 | - * |
|
| 392 | - *@since 1.0.0 |
|
| 393 | - * |
|
| 394 | - */ |
|
| 395 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 396 | - global $sd_widgets, $shortcode_insert_button_once; |
|
| 397 | - if ( $shortcode_insert_button_once ) { |
|
| 398 | - return; |
|
| 399 | - } |
|
| 400 | - add_thickbox(); |
|
| 386 | + /** |
|
| 387 | + * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 388 | + * |
|
| 389 | + * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 390 | + * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null. |
|
| 391 | + * |
|
| 392 | + *@since 1.0.0 |
|
| 393 | + * |
|
| 394 | + */ |
|
| 395 | + public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 396 | + global $sd_widgets, $shortcode_insert_button_once; |
|
| 397 | + if ( $shortcode_insert_button_once ) { |
|
| 398 | + return; |
|
| 399 | + } |
|
| 400 | + add_thickbox(); |
|
| 401 | 401 | |
| 402 | 402 | |
| 403 | - /** |
|
| 404 | - * Cornerstone makes us play dirty tricks :/ |
|
| 405 | - * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 406 | - */ |
|
| 407 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 408 | - echo '<span id="insert-media-button">'; |
|
| 409 | - } |
|
| 403 | + /** |
|
| 404 | + * Cornerstone makes us play dirty tricks :/ |
|
| 405 | + * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 406 | + */ |
|
| 407 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 408 | + echo '<span id="insert-media-button">'; |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 411 | + echo self::shortcode_button( 'this', 'true' ); |
|
| 412 | 412 | |
| 413 | - // see opening note |
|
| 414 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 415 | - echo '</span>'; // end #insert-media-button |
|
| 416 | - } |
|
| 413 | + // see opening note |
|
| 414 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 415 | + echo '</span>'; // end #insert-media-button |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - // Add separate script for generatepress theme sections |
|
| 419 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 420 | - } else { |
|
| 421 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 422 | - } |
|
| 418 | + // Add separate script for generatepress theme sections |
|
| 419 | + if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 420 | + } else { |
|
| 421 | + self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | - $shortcode_insert_button_once = true; |
|
| 425 | - } |
|
| 424 | + $shortcode_insert_button_once = true; |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | - /** |
|
| 428 | - * Gets the shortcode insert button html. |
|
| 429 | - * |
|
| 430 | - * @param string $id |
|
| 431 | - * @param string $search_for_id |
|
| 432 | - * |
|
| 433 | - * @return mixed |
|
| 434 | - */ |
|
| 435 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 436 | - ob_start(); |
|
| 437 | - ?> |
|
| 427 | + /** |
|
| 428 | + * Gets the shortcode insert button html. |
|
| 429 | + * |
|
| 430 | + * @param string $id |
|
| 431 | + * @param string $search_for_id |
|
| 432 | + * |
|
| 433 | + * @return mixed |
|
| 434 | + */ |
|
| 435 | + public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 436 | + ob_start(); |
|
| 437 | + ?> |
|
| 438 | 438 | <span class="sd-lable-shortcode-inserter"> |
| 439 | 439 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 440 | - if ( $search_for_id ) { |
|
| 441 | - echo "," . $search_for_id; |
|
| 442 | - } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 440 | + if ( $search_for_id ) { |
|
| 441 | + echo "," . $search_for_id; |
|
| 442 | + } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 443 | 443 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
| 444 | 444 | <span style="vertical-align: middle;line-height: 18px;font-size: 20px;" |
| 445 | 445 | class="dashicons dashicons-screenoptions"></span> |
@@ -450,21 +450,21 @@ discard block |
||
| 450 | 450 | </span> |
| 451 | 451 | |
| 452 | 452 | <?php |
| 453 | - $html = ob_get_clean(); |
|
| 453 | + $html = ob_get_clean(); |
|
| 454 | 454 | |
| 455 | - // remove line breaks so we can use it in js |
|
| 456 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 457 | - } |
|
| 455 | + // remove line breaks so we can use it in js |
|
| 456 | + return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 457 | + } |
|
| 458 | 458 | |
| 459 | - /** |
|
| 460 | - * Makes SD work with the siteOrigin page builder. |
|
| 461 | - * |
|
| 462 | - * @return mixed |
|
| 463 | - *@since 1.0.6 |
|
| 464 | - */ |
|
| 465 | - public static function siteorigin_js() { |
|
| 466 | - ob_start(); |
|
| 467 | - ?> |
|
| 459 | + /** |
|
| 460 | + * Makes SD work with the siteOrigin page builder. |
|
| 461 | + * |
|
| 462 | + * @return mixed |
|
| 463 | + *@since 1.0.6 |
|
| 464 | + */ |
|
| 465 | + public static function siteorigin_js() { |
|
| 466 | + ob_start(); |
|
| 467 | + ?> |
|
| 468 | 468 | <script> |
| 469 | 469 | /** |
| 470 | 470 | * Check a form to see what items should be shown or hidden. |
@@ -540,29 +540,29 @@ discard block |
||
| 540 | 540 | }); |
| 541 | 541 | </script> |
| 542 | 542 | <?php |
| 543 | - $output = ob_get_clean(); |
|
| 543 | + $output = ob_get_clean(); |
|
| 544 | 544 | |
| 545 | - /* |
|
| 545 | + /* |
|
| 546 | 546 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 547 | 547 | */ |
| 548 | 548 | |
| 549 | - return str_replace( array( |
|
| 550 | - '<script>', |
|
| 551 | - '</script>' |
|
| 552 | - ), '', $output ); |
|
| 553 | - } |
|
| 549 | + return str_replace( array( |
|
| 550 | + '<script>', |
|
| 551 | + '</script>' |
|
| 552 | + ), '', $output ); |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | - /** |
|
| 556 | - * Output the JS and CSS for the shortcode insert button. |
|
| 557 | - * |
|
| 558 | - * @param string $editor_id |
|
| 559 | - * @param string $insert_shortcode_function |
|
| 560 | - * |
|
| 561 | - *@since 1.0.6 |
|
| 562 | - * |
|
| 563 | - */ |
|
| 564 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 565 | - ?> |
|
| 555 | + /** |
|
| 556 | + * Output the JS and CSS for the shortcode insert button. |
|
| 557 | + * |
|
| 558 | + * @param string $editor_id |
|
| 559 | + * @param string $insert_shortcode_function |
|
| 560 | + * |
|
| 561 | + *@since 1.0.6 |
|
| 562 | + * |
|
| 563 | + */ |
|
| 564 | + public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 565 | + ?> |
|
| 566 | 566 | <style> |
| 567 | 567 | .sd-shortcode-left-wrap { |
| 568 | 568 | float: left; |
@@ -690,35 +690,35 @@ discard block |
||
| 690 | 690 | <?php } ?> |
| 691 | 691 | </style> |
| 692 | 692 | <?php |
| 693 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 694 | - echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 695 | - } |
|
| 696 | - ?> |
|
| 693 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 694 | + echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 695 | + } |
|
| 696 | + ?> |
|
| 697 | 697 | <script> |
| 698 | 698 | <?php |
| 699 | - if(! empty( $insert_shortcode_function )){ |
|
| 700 | - echo $insert_shortcode_function; |
|
| 701 | - }else{ |
|
| 702 | - |
|
| 703 | - /** |
|
| 704 | - * Function for super duper insert shortcode. |
|
| 705 | - * |
|
| 706 | - * @since 1.0.0 |
|
| 707 | - */ |
|
| 708 | - ?> |
|
| 699 | + if(! empty( $insert_shortcode_function )){ |
|
| 700 | + echo $insert_shortcode_function; |
|
| 701 | + }else{ |
|
| 702 | + |
|
| 703 | + /** |
|
| 704 | + * Function for super duper insert shortcode. |
|
| 705 | + * |
|
| 706 | + * @since 1.0.0 |
|
| 707 | + */ |
|
| 708 | + ?> |
|
| 709 | 709 | function sd_insert_shortcode($editor_id) { |
| 710 | 710 | $shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val(); |
| 711 | 711 | if ($shortcode) { |
| 712 | 712 | if (!$editor_id) { |
| 713 | 713 | <?php |
| 714 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 715 | - echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 716 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 717 | - echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 718 | - } else { |
|
| 719 | - echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 720 | - } |
|
| 721 | - ?> |
|
| 714 | + if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 715 | + echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 716 | + } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 717 | + echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 718 | + } else { |
|
| 719 | + echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 720 | + } |
|
| 721 | + ?> |
|
| 722 | 722 | } else { |
| 723 | 723 | $editor_id = '#' + $editor_id; |
| 724 | 724 | } |
@@ -1045,18 +1045,18 @@ discard block |
||
| 1045 | 1045 | |
| 1046 | 1046 | </script> |
| 1047 | 1047 | <?php |
| 1048 | - } |
|
| 1048 | + } |
|
| 1049 | 1049 | |
| 1050 | - /** |
|
| 1051 | - * Gets some CSS for the widgets screen. |
|
| 1052 | - * |
|
| 1053 | - * @param bool $advanced If we should include advanced CSS. |
|
| 1054 | - * |
|
| 1055 | - * @return mixed |
|
| 1056 | - */ |
|
| 1057 | - public function widget_css( $advanced = true ) { |
|
| 1058 | - ob_start(); |
|
| 1059 | - ?> |
|
| 1050 | + /** |
|
| 1051 | + * Gets some CSS for the widgets screen. |
|
| 1052 | + * |
|
| 1053 | + * @param bool $advanced If we should include advanced CSS. |
|
| 1054 | + * |
|
| 1055 | + * @return mixed |
|
| 1056 | + */ |
|
| 1057 | + public function widget_css( $advanced = true ) { |
|
| 1058 | + ob_start(); |
|
| 1059 | + ?> |
|
| 1060 | 1060 | <style> |
| 1061 | 1061 | <?php if( $advanced ){ ?> |
| 1062 | 1062 | .sd-advanced-setting { |
@@ -1094,26 +1094,26 @@ discard block |
||
| 1094 | 1094 | } |
| 1095 | 1095 | </style> |
| 1096 | 1096 | <?php |
| 1097 | - $output = ob_get_clean(); |
|
| 1097 | + $output = ob_get_clean(); |
|
| 1098 | 1098 | |
| 1099 | - /* |
|
| 1099 | + /* |
|
| 1100 | 1100 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1101 | 1101 | */ |
| 1102 | 1102 | |
| 1103 | - return str_replace( array( |
|
| 1104 | - '<style>', |
|
| 1105 | - '</style>' |
|
| 1106 | - ), '', $output ); |
|
| 1107 | - } |
|
| 1103 | + return str_replace( array( |
|
| 1104 | + '<style>', |
|
| 1105 | + '</style>' |
|
| 1106 | + ), '', $output ); |
|
| 1107 | + } |
|
| 1108 | 1108 | |
| 1109 | - /** |
|
| 1110 | - * Gets some JS for the widgets screen. |
|
| 1111 | - * |
|
| 1112 | - * @return mixed |
|
| 1113 | - */ |
|
| 1114 | - public function widget_js() { |
|
| 1115 | - ob_start(); |
|
| 1116 | - ?> |
|
| 1109 | + /** |
|
| 1110 | + * Gets some JS for the widgets screen. |
|
| 1111 | + * |
|
| 1112 | + * @return mixed |
|
| 1113 | + */ |
|
| 1114 | + public function widget_js() { |
|
| 1115 | + ob_start(); |
|
| 1116 | + ?> |
|
| 1117 | 1117 | <script> |
| 1118 | 1118 | |
| 1119 | 1119 | /** |
@@ -1268,471 +1268,471 @@ discard block |
||
| 1268 | 1268 | <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
| 1269 | 1269 | </script> |
| 1270 | 1270 | <?php |
| 1271 | - $output = ob_get_clean(); |
|
| 1271 | + $output = ob_get_clean(); |
|
| 1272 | 1272 | |
| 1273 | - /* |
|
| 1273 | + /* |
|
| 1274 | 1274 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1275 | 1275 | */ |
| 1276 | 1276 | |
| 1277 | - return str_replace( array( |
|
| 1278 | - '<script>', |
|
| 1279 | - '</script>' |
|
| 1280 | - ), '', $output ); |
|
| 1281 | - } |
|
| 1277 | + return str_replace( array( |
|
| 1278 | + '<script>', |
|
| 1279 | + '</script>' |
|
| 1280 | + ), '', $output ); |
|
| 1281 | + } |
|
| 1282 | 1282 | |
| 1283 | 1283 | |
| 1284 | - /** |
|
| 1285 | - * Set the name from the argument key. |
|
| 1286 | - * |
|
| 1287 | - * @param $options |
|
| 1288 | - * |
|
| 1289 | - * @return mixed |
|
| 1290 | - */ |
|
| 1291 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1292 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1293 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1294 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1295 | - } |
|
| 1296 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1297 | - foreach ( $options as $key => $val ) { |
|
| 1298 | - $options[ $key ]['name'] = $key; |
|
| 1299 | - } |
|
| 1300 | - } |
|
| 1284 | + /** |
|
| 1285 | + * Set the name from the argument key. |
|
| 1286 | + * |
|
| 1287 | + * @param $options |
|
| 1288 | + * |
|
| 1289 | + * @return mixed |
|
| 1290 | + */ |
|
| 1291 | + private function add_name_from_key( $options, $arguments = false ) { |
|
| 1292 | + if ( ! empty( $options['arguments'] ) ) { |
|
| 1293 | + foreach ( $options['arguments'] as $key => $val ) { |
|
| 1294 | + $options['arguments'][ $key ]['name'] = $key; |
|
| 1295 | + } |
|
| 1296 | + } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1297 | + foreach ( $options as $key => $val ) { |
|
| 1298 | + $options[ $key ]['name'] = $key; |
|
| 1299 | + } |
|
| 1300 | + } |
|
| 1301 | 1301 | |
| 1302 | - return $options; |
|
| 1303 | - } |
|
| 1302 | + return $options; |
|
| 1303 | + } |
|
| 1304 | 1304 | |
| 1305 | - /** |
|
| 1306 | - * Register the parent shortcode. |
|
| 1307 | - * |
|
| 1308 | - * @since 1.0.0 |
|
| 1309 | - */ |
|
| 1310 | - public function register_shortcode() { |
|
| 1311 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1312 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1313 | - } |
|
| 1305 | + /** |
|
| 1306 | + * Register the parent shortcode. |
|
| 1307 | + * |
|
| 1308 | + * @since 1.0.0 |
|
| 1309 | + */ |
|
| 1310 | + public function register_shortcode() { |
|
| 1311 | + add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1312 | + add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1313 | + } |
|
| 1314 | 1314 | |
| 1315 | - /** |
|
| 1316 | - * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1317 | - * |
|
| 1318 | - * @since 1.0.0 |
|
| 1319 | - */ |
|
| 1320 | - public function render_shortcode() { |
|
| 1321 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1322 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1323 | - wp_die(); |
|
| 1324 | - } |
|
| 1315 | + /** |
|
| 1316 | + * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1317 | + * |
|
| 1318 | + * @since 1.0.0 |
|
| 1319 | + */ |
|
| 1320 | + public function render_shortcode() { |
|
| 1321 | + check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1322 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1323 | + wp_die(); |
|
| 1324 | + } |
|
| 1325 | 1325 | |
| 1326 | - // we might need the $post value here so lets set it. |
|
| 1327 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1328 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1329 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1330 | - global $post; |
|
| 1331 | - $post = $post_obj; |
|
| 1332 | - } |
|
| 1333 | - } |
|
| 1326 | + // we might need the $post value here so lets set it. |
|
| 1327 | + if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1328 | + $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1329 | + if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1330 | + global $post; |
|
| 1331 | + $post = $post_obj; |
|
| 1332 | + } |
|
| 1333 | + } |
|
| 1334 | 1334 | |
| 1335 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1336 | - $is_preview = $this->is_preview(); |
|
| 1337 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1338 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1339 | - $attributes = ''; |
|
| 1340 | - if ( ! empty( $attributes_array ) ) { |
|
| 1341 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1342 | - if ( is_array( $value ) ) { |
|
| 1343 | - $value = implode( ",", $value ); |
|
| 1344 | - } |
|
| 1335 | + if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1336 | + $is_preview = $this->is_preview(); |
|
| 1337 | + $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1338 | + $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1339 | + $attributes = ''; |
|
| 1340 | + if ( ! empty( $attributes_array ) ) { |
|
| 1341 | + foreach ( $attributes_array as $key => $value ) { |
|
| 1342 | + if ( is_array( $value ) ) { |
|
| 1343 | + $value = implode( ",", $value ); |
|
| 1344 | + } |
|
| 1345 | 1345 | |
| 1346 | - if ( ! empty( $value ) ) { |
|
| 1347 | - $value = wp_unslash( $value ); |
|
| 1346 | + if ( ! empty( $value ) ) { |
|
| 1347 | + $value = wp_unslash( $value ); |
|
| 1348 | 1348 | |
| 1349 | - // Encode [ and ]. |
|
| 1350 | - if ( $is_preview ) { |
|
| 1351 | - $value = $this->encode_shortcodes( $value ); |
|
| 1352 | - } |
|
| 1353 | - } |
|
| 1354 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1355 | - } |
|
| 1356 | - } |
|
| 1349 | + // Encode [ and ]. |
|
| 1350 | + if ( $is_preview ) { |
|
| 1351 | + $value = $this->encode_shortcodes( $value ); |
|
| 1352 | + } |
|
| 1353 | + } |
|
| 1354 | + $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1355 | + } |
|
| 1356 | + } |
|
| 1357 | 1357 | |
| 1358 | - $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1358 | + $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1359 | 1359 | |
| 1360 | - $content = do_shortcode( $shortcode ); |
|
| 1360 | + $content = do_shortcode( $shortcode ); |
|
| 1361 | 1361 | |
| 1362 | - // Decode [ and ]. |
|
| 1363 | - if ( ! empty( $content ) && $is_preview ) { |
|
| 1364 | - $content = $this->decode_shortcodes( $content ); |
|
| 1365 | - } |
|
| 1362 | + // Decode [ and ]. |
|
| 1363 | + if ( ! empty( $content ) && $is_preview ) { |
|
| 1364 | + $content = $this->decode_shortcodes( $content ); |
|
| 1365 | + } |
|
| 1366 | 1366 | |
| 1367 | - echo $content; |
|
| 1368 | - } |
|
| 1369 | - wp_die(); |
|
| 1370 | - } |
|
| 1367 | + echo $content; |
|
| 1368 | + } |
|
| 1369 | + wp_die(); |
|
| 1370 | + } |
|
| 1371 | 1371 | |
| 1372 | - /** |
|
| 1373 | - * Output the shortcode. |
|
| 1374 | - * |
|
| 1375 | - * @param array $args |
|
| 1376 | - * @param string $content |
|
| 1377 | - * |
|
| 1378 | - * @return string |
|
| 1379 | - */ |
|
| 1380 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1381 | - $_instance = $args; |
|
| 1382 | - |
|
| 1383 | - $args = $this->argument_values( $args ); |
|
| 1384 | - |
|
| 1385 | - // add extra argument so we know its a output to gutenberg |
|
| 1386 | - //$args |
|
| 1387 | - $args = $this->string_to_bool( $args ); |
|
| 1388 | - |
|
| 1389 | - // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1390 | - if ( ! empty( $content ) ) { |
|
| 1391 | - $args['html'] = $content; |
|
| 1392 | - } |
|
| 1372 | + /** |
|
| 1373 | + * Output the shortcode. |
|
| 1374 | + * |
|
| 1375 | + * @param array $args |
|
| 1376 | + * @param string $content |
|
| 1377 | + * |
|
| 1378 | + * @return string |
|
| 1379 | + */ |
|
| 1380 | + public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1381 | + $_instance = $args; |
|
| 1393 | 1382 | |
| 1394 | - if ( ! $this->is_preview() ) { |
|
| 1395 | - /** |
|
| 1396 | - * Filters the settings for a particular widget args. |
|
| 1397 | - * |
|
| 1398 | - * @param array $args The current widget instance's settings. |
|
| 1399 | - * @param WP_Super_Duper $widget The current widget settings. |
|
| 1400 | - * @param array $_instance An array of default widget arguments. |
|
| 1401 | - * |
|
| 1402 | - *@since 1.0.28 |
|
| 1403 | - * |
|
| 1404 | - */ |
|
| 1405 | - $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1383 | + $args = $this->argument_values( $args ); |
|
| 1406 | 1384 | |
| 1407 | - if ( ! is_array( $args ) ) { |
|
| 1408 | - return $args; |
|
| 1409 | - } |
|
| 1410 | - } |
|
| 1385 | + // add extra argument so we know its a output to gutenberg |
|
| 1386 | + //$args |
|
| 1387 | + $args = $this->string_to_bool( $args ); |
|
| 1411 | 1388 | |
| 1412 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1413 | - $class .= " sdel-".$this->get_instance_hash(); |
|
| 1389 | + // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1390 | + if ( ! empty( $content ) ) { |
|
| 1391 | + $args['html'] = $content; |
|
| 1392 | + } |
|
| 1414 | 1393 | |
| 1415 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1416 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1394 | + if ( ! $this->is_preview() ) { |
|
| 1395 | + /** |
|
| 1396 | + * Filters the settings for a particular widget args. |
|
| 1397 | + * |
|
| 1398 | + * @param array $args The current widget instance's settings. |
|
| 1399 | + * @param WP_Super_Duper $widget The current widget settings. |
|
| 1400 | + * @param array $_instance An array of default widget arguments. |
|
| 1401 | + * |
|
| 1402 | + *@since 1.0.28 |
|
| 1403 | + * |
|
| 1404 | + */ |
|
| 1405 | + $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1406 | + |
|
| 1407 | + if ( ! is_array( $args ) ) { |
|
| 1408 | + return $args; |
|
| 1409 | + } |
|
| 1410 | + } |
|
| 1417 | 1411 | |
| 1418 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1419 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1412 | + $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1413 | + $class .= " sdel-".$this->get_instance_hash(); |
|
| 1420 | 1414 | |
| 1421 | - $shortcode_args = array(); |
|
| 1422 | - $output = ''; |
|
| 1423 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1424 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1425 | - $no_wrap = true; |
|
| 1426 | - } |
|
| 1427 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1428 | - if ( $main_content && ! $no_wrap ) { |
|
| 1429 | - // wrap the shortcode in a div with the same class as the widget |
|
| 1430 | - $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1431 | - if ( ! empty( $args['title'] ) ) { |
|
| 1432 | - // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1433 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1434 | - if ( empty( $instance ) ) { |
|
| 1435 | - global $wp_registered_sidebars; |
|
| 1436 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1437 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1438 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1439 | - $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1440 | - $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1441 | - break; |
|
| 1442 | - } |
|
| 1443 | - } |
|
| 1444 | - } |
|
| 1445 | - } |
|
| 1446 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1447 | - } |
|
| 1448 | - $output .= $main_content; |
|
| 1449 | - $output .= '</div>'; |
|
| 1450 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1451 | - $output .= $main_content; |
|
| 1452 | - } |
|
| 1415 | + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1416 | + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1453 | 1417 | |
| 1454 | - // if preview show a placeholder if empty |
|
| 1455 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1456 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1457 | - } |
|
| 1418 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1419 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1458 | 1420 | |
| 1459 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1460 | - } |
|
| 1421 | + $shortcode_args = array(); |
|
| 1422 | + $output = ''; |
|
| 1423 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1424 | + if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1425 | + $no_wrap = true; |
|
| 1426 | + } |
|
| 1427 | + $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1428 | + if ( $main_content && ! $no_wrap ) { |
|
| 1429 | + // wrap the shortcode in a div with the same class as the widget |
|
| 1430 | + $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1431 | + if ( ! empty( $args['title'] ) ) { |
|
| 1432 | + // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1433 | + $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1434 | + if ( empty( $instance ) ) { |
|
| 1435 | + global $wp_registered_sidebars; |
|
| 1436 | + if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1437 | + foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1438 | + if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1439 | + $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1440 | + $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1441 | + break; |
|
| 1442 | + } |
|
| 1443 | + } |
|
| 1444 | + } |
|
| 1445 | + } |
|
| 1446 | + $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1447 | + } |
|
| 1448 | + $output .= $main_content; |
|
| 1449 | + $output .= '</div>'; |
|
| 1450 | + } elseif ( $main_content && $no_wrap ) { |
|
| 1451 | + $output .= $main_content; |
|
| 1452 | + } |
|
| 1461 | 1453 | |
| 1462 | - /** |
|
| 1463 | - * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1464 | - * |
|
| 1465 | - * @param string $name |
|
| 1466 | - * |
|
| 1467 | - * @return string |
|
| 1468 | - */ |
|
| 1469 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1470 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1471 | - } |
|
| 1454 | + // if preview show a placeholder if empty |
|
| 1455 | + if ( $this->is_preview() && $output == '' ) { |
|
| 1456 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1457 | + } |
|
| 1472 | 1458 | |
| 1473 | - /** |
|
| 1474 | - * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1475 | - * |
|
| 1476 | - * @param $options |
|
| 1477 | - * |
|
| 1478 | - * @return mixed |
|
| 1479 | - */ |
|
| 1480 | - public function string_to_bool( $options ) { |
|
| 1481 | - // convert bool strings to booleans |
|
| 1482 | - foreach ( $options as $key => $val ) { |
|
| 1483 | - if ( $val == 'false' ) { |
|
| 1484 | - $options[ $key ] = false; |
|
| 1485 | - } elseif ( $val == 'true' ) { |
|
| 1486 | - $options[ $key ] = true; |
|
| 1487 | - } |
|
| 1488 | - } |
|
| 1459 | + return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1460 | + } |
|
| 1489 | 1461 | |
| 1490 | - return $options; |
|
| 1491 | - } |
|
| 1462 | + /** |
|
| 1463 | + * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1464 | + * |
|
| 1465 | + * @param string $name |
|
| 1466 | + * |
|
| 1467 | + * @return string |
|
| 1468 | + */ |
|
| 1469 | + public function preview_placeholder_text( $name = '' ) { |
|
| 1470 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1471 | + } |
|
| 1492 | 1472 | |
| 1493 | - /** |
|
| 1494 | - * Get the argument values that are also filterable. |
|
| 1495 | - * |
|
| 1496 | - * @param $instance |
|
| 1497 | - * |
|
| 1498 | - * @return array |
|
| 1499 | - *@since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1500 | - * |
|
| 1501 | - */ |
|
| 1502 | - public function argument_values( $instance ) { |
|
| 1503 | - $argument_values = array(); |
|
| 1504 | - |
|
| 1505 | - // set widget instance |
|
| 1506 | - $this->instance = $instance; |
|
| 1507 | - |
|
| 1508 | - if ( empty( $this->arguments ) ) { |
|
| 1509 | - $this->arguments = $this->get_arguments(); |
|
| 1510 | - } |
|
| 1473 | + /** |
|
| 1474 | + * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1475 | + * |
|
| 1476 | + * @param $options |
|
| 1477 | + * |
|
| 1478 | + * @return mixed |
|
| 1479 | + */ |
|
| 1480 | + public function string_to_bool( $options ) { |
|
| 1481 | + // convert bool strings to booleans |
|
| 1482 | + foreach ( $options as $key => $val ) { |
|
| 1483 | + if ( $val == 'false' ) { |
|
| 1484 | + $options[ $key ] = false; |
|
| 1485 | + } elseif ( $val == 'true' ) { |
|
| 1486 | + $options[ $key ] = true; |
|
| 1487 | + } |
|
| 1488 | + } |
|
| 1511 | 1489 | |
| 1512 | - if ( ! empty( $this->arguments ) ) { |
|
| 1513 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1514 | - // set the input name from the key |
|
| 1515 | - $args['name'] = $key; |
|
| 1516 | - // |
|
| 1517 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1518 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1519 | - // don't set default for an empty checkbox |
|
| 1520 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1521 | - $argument_values[ $key ] = $args['default']; |
|
| 1522 | - } |
|
| 1523 | - } |
|
| 1524 | - } |
|
| 1490 | + return $options; |
|
| 1491 | + } |
|
| 1525 | 1492 | |
| 1526 | - return $argument_values; |
|
| 1527 | - } |
|
| 1493 | + /** |
|
| 1494 | + * Get the argument values that are also filterable. |
|
| 1495 | + * |
|
| 1496 | + * @param $instance |
|
| 1497 | + * |
|
| 1498 | + * @return array |
|
| 1499 | + *@since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1500 | + * |
|
| 1501 | + */ |
|
| 1502 | + public function argument_values( $instance ) { |
|
| 1503 | + $argument_values = array(); |
|
| 1528 | 1504 | |
| 1529 | - /** |
|
| 1530 | - * Set arguments in super duper. |
|
| 1531 | - * |
|
| 1532 | - * @return array Set arguments. |
|
| 1533 | - *@since 1.0.0 |
|
| 1534 | - * |
|
| 1535 | - */ |
|
| 1536 | - public function set_arguments() { |
|
| 1537 | - return $this->arguments; |
|
| 1538 | - } |
|
| 1505 | + // set widget instance |
|
| 1506 | + $this->instance = $instance; |
|
| 1539 | 1507 | |
| 1540 | - /** |
|
| 1541 | - * Get arguments in super duper. |
|
| 1542 | - * |
|
| 1543 | - * @return array Get arguments. |
|
| 1544 | - *@since 1.0.0 |
|
| 1545 | - * |
|
| 1546 | - */ |
|
| 1547 | - public function get_arguments() { |
|
| 1548 | - if ( empty( $this->arguments ) ) { |
|
| 1549 | - $this->arguments = $this->set_arguments(); |
|
| 1550 | - } |
|
| 1508 | + if ( empty( $this->arguments ) ) { |
|
| 1509 | + $this->arguments = $this->get_arguments(); |
|
| 1510 | + } |
|
| 1551 | 1511 | |
| 1552 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1553 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1512 | + if ( ! empty( $this->arguments ) ) { |
|
| 1513 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1514 | + // set the input name from the key |
|
| 1515 | + $args['name'] = $key; |
|
| 1516 | + // |
|
| 1517 | + $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1518 | + if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1519 | + // don't set default for an empty checkbox |
|
| 1520 | + } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1521 | + $argument_values[ $key ] = $args['default']; |
|
| 1522 | + } |
|
| 1523 | + } |
|
| 1524 | + } |
|
| 1554 | 1525 | |
| 1555 | - return $this->arguments; |
|
| 1556 | - } |
|
| 1526 | + return $argument_values; |
|
| 1527 | + } |
|
| 1557 | 1528 | |
| 1558 | - /** |
|
| 1559 | - * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1560 | - * |
|
| 1561 | - * @param array $args |
|
| 1562 | - * @param array $widget_args |
|
| 1563 | - * @param string $content |
|
| 1564 | - */ |
|
| 1565 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1529 | + /** |
|
| 1530 | + * Set arguments in super duper. |
|
| 1531 | + * |
|
| 1532 | + * @return array Set arguments. |
|
| 1533 | + *@since 1.0.0 |
|
| 1534 | + * |
|
| 1535 | + */ |
|
| 1536 | + public function set_arguments() { |
|
| 1537 | + return $this->arguments; |
|
| 1538 | + } |
|
| 1566 | 1539 | |
| 1567 | - } |
|
| 1540 | + /** |
|
| 1541 | + * Get arguments in super duper. |
|
| 1542 | + * |
|
| 1543 | + * @return array Get arguments. |
|
| 1544 | + *@since 1.0.0 |
|
| 1545 | + * |
|
| 1546 | + */ |
|
| 1547 | + public function get_arguments() { |
|
| 1548 | + if ( empty( $this->arguments ) ) { |
|
| 1549 | + $this->arguments = $this->set_arguments(); |
|
| 1550 | + } |
|
| 1568 | 1551 | |
| 1569 | - /** |
|
| 1570 | - * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1571 | - */ |
|
| 1572 | - public function register_block() { |
|
| 1573 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1574 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1575 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1576 | - } |
|
| 1577 | - } |
|
| 1552 | + $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1553 | + $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1578 | 1554 | |
| 1579 | - /** |
|
| 1580 | - * Check if we need to show advanced options. |
|
| 1581 | - * |
|
| 1582 | - * @return bool |
|
| 1583 | - */ |
|
| 1584 | - public function block_show_advanced() { |
|
| 1585 | - |
|
| 1586 | - $show = false; |
|
| 1587 | - $arguments = $this->get_arguments(); |
|
| 1588 | - |
|
| 1589 | - if ( ! empty( $arguments ) ) { |
|
| 1590 | - foreach ( $arguments as $argument ) { |
|
| 1591 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1592 | - $show = true; |
|
| 1593 | - break; // no need to continue if we know we have it |
|
| 1594 | - } |
|
| 1595 | - } |
|
| 1596 | - } |
|
| 1555 | + return $this->arguments; |
|
| 1556 | + } |
|
| 1597 | 1557 | |
| 1598 | - return $show; |
|
| 1599 | - } |
|
| 1558 | + /** |
|
| 1559 | + * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1560 | + * |
|
| 1561 | + * @param array $args |
|
| 1562 | + * @param array $widget_args |
|
| 1563 | + * @param string $content |
|
| 1564 | + */ |
|
| 1565 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1600 | 1566 | |
| 1601 | - /** |
|
| 1602 | - * Get the url path to the current folder. |
|
| 1603 | - * |
|
| 1604 | - * @return string |
|
| 1605 | - */ |
|
| 1606 | - public function get_url() { |
|
| 1607 | - $url = $this->url; |
|
| 1608 | - |
|
| 1609 | - if ( ! $url ) { |
|
| 1610 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1611 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1612 | - |
|
| 1613 | - // Replace http:// to https://. |
|
| 1614 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1615 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1616 | - } |
|
| 1567 | + } |
|
| 1617 | 1568 | |
| 1618 | - // Check if we are inside a plugin |
|
| 1619 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1620 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1621 | - $url = trailingslashit( $url ); |
|
| 1622 | - $this->url = $url; |
|
| 1623 | - } |
|
| 1569 | + /** |
|
| 1570 | + * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1571 | + */ |
|
| 1572 | + public function register_block() { |
|
| 1573 | + wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1574 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1575 | + wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1576 | + } |
|
| 1577 | + } |
|
| 1624 | 1578 | |
| 1625 | - return $url; |
|
| 1626 | - } |
|
| 1579 | + /** |
|
| 1580 | + * Check if we need to show advanced options. |
|
| 1581 | + * |
|
| 1582 | + * @return bool |
|
| 1583 | + */ |
|
| 1584 | + public function block_show_advanced() { |
|
| 1627 | 1585 | |
| 1628 | - /** |
|
| 1629 | - * Get the url path to the current folder. |
|
| 1630 | - * |
|
| 1631 | - * @return string |
|
| 1632 | - */ |
|
| 1633 | - public function get_url_old() { |
|
| 1586 | + $show = false; |
|
| 1587 | + $arguments = $this->get_arguments(); |
|
| 1634 | 1588 | |
| 1635 | - $url = $this->url; |
|
| 1589 | + if ( ! empty( $arguments ) ) { |
|
| 1590 | + foreach ( $arguments as $argument ) { |
|
| 1591 | + if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1592 | + $show = true; |
|
| 1593 | + break; // no need to continue if we know we have it |
|
| 1594 | + } |
|
| 1595 | + } |
|
| 1596 | + } |
|
| 1636 | 1597 | |
| 1637 | - if ( ! $url ) { |
|
| 1638 | - // check if we are inside a plugin |
|
| 1639 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1598 | + return $show; |
|
| 1599 | + } |
|
| 1640 | 1600 | |
| 1641 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1642 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1601 | + /** |
|
| 1602 | + * Get the url path to the current folder. |
|
| 1603 | + * |
|
| 1604 | + * @return string |
|
| 1605 | + */ |
|
| 1606 | + public function get_url() { |
|
| 1607 | + $url = $this->url; |
|
| 1643 | 1608 | |
| 1644 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1645 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1646 | - $this->url = $url; |
|
| 1647 | - } |
|
| 1648 | - } |
|
| 1609 | + if ( ! $url ) { |
|
| 1610 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1611 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1649 | 1612 | |
| 1613 | + // Replace http:// to https://. |
|
| 1614 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1615 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1616 | + } |
|
| 1650 | 1617 | |
| 1651 | - return $url; |
|
| 1652 | - } |
|
| 1618 | + // Check if we are inside a plugin |
|
| 1619 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1620 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1621 | + $url = trailingslashit( $url ); |
|
| 1622 | + $this->url = $url; |
|
| 1623 | + } |
|
| 1653 | 1624 | |
| 1654 | - /** |
|
| 1655 | - * Generate the block icon. |
|
| 1656 | - * |
|
| 1657 | - * Enables the use of Font Awesome icons. |
|
| 1658 | - * |
|
| 1659 | - * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1660 | - * |
|
| 1661 | - * @param $icon |
|
| 1662 | - * |
|
| 1663 | - * @return string |
|
| 1664 | - *@since 1.1.0 |
|
| 1665 | - */ |
|
| 1666 | - public function get_block_icon( $icon ) { |
|
| 1667 | - |
|
| 1668 | - // check if we have a Font Awesome icon |
|
| 1669 | - $fa_type = ''; |
|
| 1670 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1671 | - $fa_type = 'solid'; |
|
| 1672 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1673 | - $fa_type = 'regular'; |
|
| 1674 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1675 | - $fa_type = 'brands'; |
|
| 1676 | - } else { |
|
| 1677 | - $icon = "'" . $icon . "'"; |
|
| 1678 | - } |
|
| 1625 | + return $url; |
|
| 1626 | + } |
|
| 1679 | 1627 | |
| 1680 | - // set the icon if we found one |
|
| 1681 | - if ( $fa_type ) { |
|
| 1682 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1683 | - $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1684 | - } |
|
| 1628 | + /** |
|
| 1629 | + * Get the url path to the current folder. |
|
| 1630 | + * |
|
| 1631 | + * @return string |
|
| 1632 | + */ |
|
| 1633 | + public function get_url_old() { |
|
| 1685 | 1634 | |
| 1686 | - return $icon; |
|
| 1687 | - } |
|
| 1635 | + $url = $this->url; |
|
| 1636 | + |
|
| 1637 | + if ( ! $url ) { |
|
| 1638 | + // check if we are inside a plugin |
|
| 1639 | + $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1640 | + |
|
| 1641 | + $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1642 | + $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1643 | + |
|
| 1644 | + if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1645 | + $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1646 | + $this->url = $url; |
|
| 1647 | + } |
|
| 1648 | + } |
|
| 1649 | + |
|
| 1650 | + |
|
| 1651 | + return $url; |
|
| 1652 | + } |
|
| 1653 | + |
|
| 1654 | + /** |
|
| 1655 | + * Generate the block icon. |
|
| 1656 | + * |
|
| 1657 | + * Enables the use of Font Awesome icons. |
|
| 1658 | + * |
|
| 1659 | + * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1660 | + * |
|
| 1661 | + * @param $icon |
|
| 1662 | + * |
|
| 1663 | + * @return string |
|
| 1664 | + *@since 1.1.0 |
|
| 1665 | + */ |
|
| 1666 | + public function get_block_icon( $icon ) { |
|
| 1667 | + |
|
| 1668 | + // check if we have a Font Awesome icon |
|
| 1669 | + $fa_type = ''; |
|
| 1670 | + if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1671 | + $fa_type = 'solid'; |
|
| 1672 | + } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1673 | + $fa_type = 'regular'; |
|
| 1674 | + } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1675 | + $fa_type = 'brands'; |
|
| 1676 | + } else { |
|
| 1677 | + $icon = "'" . $icon . "'"; |
|
| 1678 | + } |
|
| 1688 | 1679 | |
| 1689 | - public function group_arguments( $arguments ) { |
|
| 1680 | + // set the icon if we found one |
|
| 1681 | + if ( $fa_type ) { |
|
| 1682 | + $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1683 | + $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1684 | + } |
|
| 1685 | + |
|
| 1686 | + return $icon; |
|
| 1687 | + } |
|
| 1688 | + |
|
| 1689 | + public function group_arguments( $arguments ) { |
|
| 1690 | 1690 | // echo '###';print_r($arguments); |
| 1691 | - if ( ! empty( $arguments ) ) { |
|
| 1692 | - $temp_arguments = array(); |
|
| 1693 | - $general = __( "General" ); |
|
| 1694 | - $add_sections = false; |
|
| 1695 | - foreach ( $arguments as $key => $args ) { |
|
| 1696 | - if ( isset( $args['group'] ) ) { |
|
| 1697 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1698 | - $add_sections = true; |
|
| 1699 | - } else { |
|
| 1700 | - $temp_arguments[ $general ][ $key ] = $args; |
|
| 1701 | - } |
|
| 1702 | - } |
|
| 1691 | + if ( ! empty( $arguments ) ) { |
|
| 1692 | + $temp_arguments = array(); |
|
| 1693 | + $general = __( "General" ); |
|
| 1694 | + $add_sections = false; |
|
| 1695 | + foreach ( $arguments as $key => $args ) { |
|
| 1696 | + if ( isset( $args['group'] ) ) { |
|
| 1697 | + $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1698 | + $add_sections = true; |
|
| 1699 | + } else { |
|
| 1700 | + $temp_arguments[ $general ][ $key ] = $args; |
|
| 1701 | + } |
|
| 1702 | + } |
|
| 1703 | 1703 | |
| 1704 | - // only add sections if more than one |
|
| 1705 | - if ( $add_sections ) { |
|
| 1706 | - $arguments = $temp_arguments; |
|
| 1707 | - } |
|
| 1708 | - } |
|
| 1704 | + // only add sections if more than one |
|
| 1705 | + if ( $add_sections ) { |
|
| 1706 | + $arguments = $temp_arguments; |
|
| 1707 | + } |
|
| 1708 | + } |
|
| 1709 | 1709 | |
| 1710 | 1710 | // echo '###';print_r($arguments); |
| 1711 | - return $arguments; |
|
| 1712 | - } |
|
| 1711 | + return $arguments; |
|
| 1712 | + } |
|
| 1713 | 1713 | |
| 1714 | 1714 | |
| 1715 | - /** |
|
| 1716 | - * Output the JS for building the dynamic Guntenberg block. |
|
| 1717 | - * |
|
| 1718 | - * @return mixed |
|
| 1719 | - *@since 1.0.9 Save numbers as numbers and not strings. |
|
| 1720 | - * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1721 | - * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1722 | - */ |
|
| 1723 | - public function block() { |
|
| 1715 | + /** |
|
| 1716 | + * Output the JS for building the dynamic Guntenberg block. |
|
| 1717 | + * |
|
| 1718 | + * @return mixed |
|
| 1719 | + *@since 1.0.9 Save numbers as numbers and not strings. |
|
| 1720 | + * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1721 | + * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1722 | + */ |
|
| 1723 | + public function block() { |
|
| 1724 | 1724 | global $sd_is_js_functions_loaded; |
| 1725 | 1725 | |
| 1726 | - ob_start(); |
|
| 1726 | + ob_start(); |
|
| 1727 | 1727 | |
| 1728 | - $show_advanced = $this->block_show_advanced(); |
|
| 1728 | + $show_advanced = $this->block_show_advanced(); |
|
| 1729 | 1729 | |
| 1730 | 1730 | |
| 1731 | - ?> |
|
| 1731 | + ?> |
|
| 1732 | 1732 | <script> |
| 1733 | 1733 | |
| 1734 | 1734 | <?php |
| 1735 | - if(!$sd_is_js_functions_loaded){ |
|
| 1735 | + if(!$sd_is_js_functions_loaded){ |
|
| 1736 | 1736 | $sd_is_js_functions_loaded = true; |
| 1737 | 1737 | ?> |
| 1738 | 1738 | |
@@ -2041,10 +2041,10 @@ discard block |
||
| 2041 | 2041 | |
| 2042 | 2042 | } |
| 2043 | 2043 | |
| 2044 | - if(method_exists($this,'block_global_js')){ |
|
| 2045 | - echo $this->block_global_js(); |
|
| 2046 | - } |
|
| 2047 | - ?> |
|
| 2044 | + if(method_exists($this,'block_global_js')){ |
|
| 2045 | + echo $this->block_global_js(); |
|
| 2046 | + } |
|
| 2047 | + ?> |
|
| 2048 | 2048 | |
| 2049 | 2049 | jQuery(function() { |
| 2050 | 2050 | |
@@ -2094,14 +2094,14 @@ discard block |
||
| 2094 | 2094 | icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
| 2095 | 2095 | supports: { |
| 2096 | 2096 | <?php |
| 2097 | - if ( isset( $this->options['block-supports'] ) ) { |
|
| 2098 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2099 | - } |
|
| 2100 | - ?> |
|
| 2097 | + if ( isset( $this->options['block-supports'] ) ) { |
|
| 2098 | + echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2099 | + } |
|
| 2100 | + ?> |
|
| 2101 | 2101 | }, |
| 2102 | 2102 | <?php |
| 2103 | - if ( isset( $this->options['block-label'] ) ) { |
|
| 2104 | - ?> |
|
| 2103 | + if ( isset( $this->options['block-label'] ) ) { |
|
| 2104 | + ?> |
|
| 2105 | 2105 | __experimentalLabel( attributes, { context } ) { |
| 2106 | 2106 | return <?php echo $this->options['block-label']; ?>; |
| 2107 | 2107 | }, |
@@ -2110,7 +2110,7 @@ discard block |
||
| 2110 | 2110 | ?> |
| 2111 | 2111 | category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
| 2112 | 2112 | <?php if ( isset( $this->options['block-keywords'] ) ) { |
| 2113 | - echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 2113 | + echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 2114 | 2114 | |
| 2115 | 2115 | // // block hover preview. |
| 2116 | 2116 | // $example_args = array(); |
@@ -2135,83 +2135,83 @@ discard block |
||
| 2135 | 2135 | |
| 2136 | 2136 | } |
| 2137 | 2137 | |
| 2138 | - // maybe set no_wrap |
|
| 2139 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2140 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2141 | - $no_wrap = true; |
|
| 2142 | - } |
|
| 2143 | - if ( $no_wrap ) { |
|
| 2144 | - $this->options['block-wrap'] = ''; |
|
| 2145 | - } |
|
| 2138 | + // maybe set no_wrap |
|
| 2139 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2140 | + if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2141 | + $no_wrap = true; |
|
| 2142 | + } |
|
| 2143 | + if ( $no_wrap ) { |
|
| 2144 | + $this->options['block-wrap'] = ''; |
|
| 2145 | + } |
|
| 2146 | 2146 | |
| 2147 | - // maybe load the drag/drop functions. |
|
| 2148 | - $img_drag_drop = false; |
|
| 2147 | + // maybe load the drag/drop functions. |
|
| 2148 | + $img_drag_drop = false; |
|
| 2149 | 2149 | |
| 2150 | - $show_alignment = false; |
|
| 2151 | - // align feature |
|
| 2152 | - /*echo "supports: {"; |
|
| 2150 | + $show_alignment = false; |
|
| 2151 | + // align feature |
|
| 2152 | + /*echo "supports: {"; |
|
| 2153 | 2153 | echo " align: true,"; |
| 2154 | 2154 | echo " html: false"; |
| 2155 | 2155 | echo "},";*/ |
| 2156 | 2156 | |
| 2157 | - if ( ! empty( $this->arguments ) ) { |
|
| 2158 | - echo "attributes : {"; |
|
| 2157 | + if ( ! empty( $this->arguments ) ) { |
|
| 2158 | + echo "attributes : {"; |
|
| 2159 | 2159 | |
| 2160 | - if ( $show_advanced ) { |
|
| 2161 | - echo "show_advanced: {"; |
|
| 2162 | - echo " type: 'boolean',"; |
|
| 2163 | - echo " default: false,"; |
|
| 2164 | - echo "},"; |
|
| 2165 | - } |
|
| 2160 | + if ( $show_advanced ) { |
|
| 2161 | + echo "show_advanced: {"; |
|
| 2162 | + echo " type: 'boolean',"; |
|
| 2163 | + echo " default: false,"; |
|
| 2164 | + echo "},"; |
|
| 2165 | + } |
|
| 2166 | 2166 | |
| 2167 | - // block wrap element |
|
| 2168 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2169 | - echo "block_wrap: {"; |
|
| 2170 | - echo " type: 'string',"; |
|
| 2171 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2172 | - echo "},"; |
|
| 2173 | - } |
|
| 2167 | + // block wrap element |
|
| 2168 | + if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2169 | + echo "block_wrap: {"; |
|
| 2170 | + echo " type: 'string',"; |
|
| 2171 | + echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2172 | + echo "},"; |
|
| 2173 | + } |
|
| 2174 | 2174 | |
| 2175 | 2175 | |
| 2176 | 2176 | |
| 2177 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2177 | + foreach ( $this->arguments as $key => $args ) { |
|
| 2178 | 2178 | |
| 2179 | - if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2180 | - $img_drag_drop = true; |
|
| 2181 | - } |
|
| 2179 | + if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2180 | + $img_drag_drop = true; |
|
| 2181 | + } |
|
| 2182 | 2182 | |
| 2183 | - // set if we should show alignment |
|
| 2184 | - if ( $key == 'alignment' ) { |
|
| 2185 | - $show_alignment = true; |
|
| 2186 | - } |
|
| 2183 | + // set if we should show alignment |
|
| 2184 | + if ( $key == 'alignment' ) { |
|
| 2185 | + $show_alignment = true; |
|
| 2186 | + } |
|
| 2187 | 2187 | |
| 2188 | - $extra = ''; |
|
| 2188 | + $extra = ''; |
|
| 2189 | 2189 | |
| 2190 | - if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2191 | - continue; |
|
| 2192 | - } |
|
| 2193 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2194 | - $type = 'boolean'; |
|
| 2195 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2196 | - } elseif ( $args['type'] == 'number' ) { |
|
| 2197 | - $type = 'number'; |
|
| 2198 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2199 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2200 | - $type = 'array'; |
|
| 2201 | - if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2202 | - $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2203 | - } else { |
|
| 2204 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2205 | - } |
|
| 2206 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2207 | - $type = 'array'; |
|
| 2208 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2209 | - } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2210 | - $type = 'object'; |
|
| 2211 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2212 | - } elseif ( $args['type'] == 'image' ) { |
|
| 2213 | - $type = 'string'; |
|
| 2214 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2190 | + if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2191 | + continue; |
|
| 2192 | + } |
|
| 2193 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 2194 | + $type = 'boolean'; |
|
| 2195 | + $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2196 | + } elseif ( $args['type'] == 'number' ) { |
|
| 2197 | + $type = 'number'; |
|
| 2198 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2199 | + } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2200 | + $type = 'array'; |
|
| 2201 | + if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2202 | + $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2203 | + } else { |
|
| 2204 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2205 | + } |
|
| 2206 | + } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2207 | + $type = 'array'; |
|
| 2208 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2209 | + } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2210 | + $type = 'object'; |
|
| 2211 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2212 | + } elseif ( $args['type'] == 'image' ) { |
|
| 2213 | + $type = 'string'; |
|
| 2214 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2215 | 2215 | |
| 2216 | 2216 | // add a field for ID |
| 2217 | 2217 | // echo $key . "_id : {"; |
@@ -2221,25 +2221,25 @@ discard block |
||
| 2221 | 2221 | // echo "type : 'object',"; |
| 2222 | 2222 | // echo "},"; |
| 2223 | 2223 | |
| 2224 | - } else { |
|
| 2225 | - $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
|
| 2226 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2224 | + } else { |
|
| 2225 | + $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
|
| 2226 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2227 | 2227 | |
| 2228 | - } |
|
| 2229 | - echo $key . " : {"; |
|
| 2230 | - echo "type : '$type',"; |
|
| 2231 | - echo "default : $default,"; |
|
| 2232 | - echo "},"; |
|
| 2233 | - } |
|
| 2228 | + } |
|
| 2229 | + echo $key . " : {"; |
|
| 2230 | + echo "type : '$type',"; |
|
| 2231 | + echo "default : $default,"; |
|
| 2232 | + echo "},"; |
|
| 2233 | + } |
|
| 2234 | 2234 | |
| 2235 | - echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 2236 | - echo "className: { type: 'string', default: '' },"; |
|
| 2235 | + echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 2236 | + echo "className: { type: 'string', default: '' },"; |
|
| 2237 | 2237 | |
| 2238 | - echo "},"; |
|
| 2238 | + echo "},"; |
|
| 2239 | 2239 | |
| 2240 | - } |
|
| 2240 | + } |
|
| 2241 | 2241 | |
| 2242 | - ?> |
|
| 2242 | + ?> |
|
| 2243 | 2243 | |
| 2244 | 2244 | // The "edit" property must be a valid function. |
| 2245 | 2245 | edit: function (props) { |
@@ -2339,9 +2339,9 @@ discard block |
||
| 2339 | 2339 | |
| 2340 | 2340 | var $value = ''; |
| 2341 | 2341 | <?php |
| 2342 | - // if we have a post_type and a category then link them |
|
| 2343 | - if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2344 | - ?> |
|
| 2342 | + // if we have a post_type and a category then link them |
|
| 2343 | + if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2344 | + ?> |
|
| 2345 | 2345 | if(typeof(prev_attributes[props.clientId]) != 'undefined' ){ |
| 2346 | 2346 | $pt = props.attributes.post_type; |
| 2347 | 2347 | if(post_type_rest_slugs.length){ |
@@ -2432,8 +2432,8 @@ discard block |
||
| 2432 | 2432 | 'attributes': props.attributes, |
| 2433 | 2433 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
| 2434 | 2434 | 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
| 2435 | - echo $post->ID; |
|
| 2436 | - }else{echo '0';}?>, |
|
| 2435 | + echo $post->ID; |
|
| 2436 | + }else{echo '0';}?>, |
|
| 2437 | 2437 | '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
| 2438 | 2438 | }; |
| 2439 | 2439 | |
@@ -2510,10 +2510,10 @@ discard block |
||
| 2510 | 2510 | |
| 2511 | 2511 | <?php |
| 2512 | 2512 | |
| 2513 | - if(! empty( $this->arguments )){ |
|
| 2513 | + if(! empty( $this->arguments )){ |
|
| 2514 | 2514 | |
| 2515 | - if ( $show_advanced ) { |
|
| 2516 | - ?> |
|
| 2515 | + if ( $show_advanced ) { |
|
| 2516 | + ?> |
|
| 2517 | 2517 | el('div', { |
| 2518 | 2518 | style: {'padding-left': '16px','padding-right': '16px'} |
| 2519 | 2519 | }, |
@@ -2531,146 +2531,146 @@ discard block |
||
| 2531 | 2531 | , |
| 2532 | 2532 | <?php |
| 2533 | 2533 | |
| 2534 | - } |
|
| 2534 | + } |
|
| 2535 | 2535 | |
| 2536 | - // print_r( $this->arguments); |
|
| 2536 | + // print_r( $this->arguments); |
|
| 2537 | 2537 | |
| 2538 | - //echo '####'; |
|
| 2538 | + //echo '####'; |
|
| 2539 | 2539 | |
| 2540 | - $arguments = $this->group_arguments( $this->arguments ); |
|
| 2540 | + $arguments = $this->group_arguments( $this->arguments ); |
|
| 2541 | 2541 | //print_r($arguments ); exit; |
| 2542 | - // Do we have sections? |
|
| 2543 | - $has_sections = $arguments == $this->arguments ? false : true; |
|
| 2542 | + // Do we have sections? |
|
| 2543 | + $has_sections = $arguments == $this->arguments ? false : true; |
|
| 2544 | 2544 | |
| 2545 | 2545 | |
| 2546 | - if($has_sections){ |
|
| 2547 | - $panel_count = 0; |
|
| 2548 | - $open_tab = ''; |
|
| 2546 | + if($has_sections){ |
|
| 2547 | + $panel_count = 0; |
|
| 2548 | + $open_tab = ''; |
|
| 2549 | 2549 | |
| 2550 | - $open_tab_groups = array(); |
|
| 2551 | - $used_tabs = array(); |
|
| 2552 | - foreach($arguments as $key => $args){ |
|
| 2550 | + $open_tab_groups = array(); |
|
| 2551 | + $used_tabs = array(); |
|
| 2552 | + foreach($arguments as $key => $args){ |
|
| 2553 | 2553 | |
| 2554 | - $close_tab = false; |
|
| 2555 | - $close_tabs = false; |
|
| 2554 | + $close_tab = false; |
|
| 2555 | + $close_tabs = false; |
|
| 2556 | 2556 | |
| 2557 | - if(!empty($this->options['block_group_tabs'])) { |
|
| 2558 | - foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){ |
|
| 2559 | - if(in_array($key,$tab_args['groups'])){ |
|
| 2557 | + if(!empty($this->options['block_group_tabs'])) { |
|
| 2558 | + foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){ |
|
| 2559 | + if(in_array($key,$tab_args['groups'])){ |
|
| 2560 | 2560 | |
| 2561 | - $open_tab_groups[] = $key; |
|
| 2561 | + $open_tab_groups[] = $key; |
|
| 2562 | 2562 | |
| 2563 | - if($open_tab != $tab_name){ |
|
| 2564 | - $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
|
| 2565 | - $tab_args['tab']['open'] = true; |
|
| 2563 | + if($open_tab != $tab_name){ |
|
| 2564 | + $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
|
| 2565 | + $tab_args['tab']['open'] = true; |
|
| 2566 | 2566 | |
| 2567 | - $this->block_tab_start( '', $tab_args ); |
|
| 2567 | + $this->block_tab_start( '', $tab_args ); |
|
| 2568 | 2568 | // echo '###open'.$tab_name;print_r($tab_args); |
| 2569 | - $open_tab = $tab_name; |
|
| 2570 | - $used_tabs[] = $tab_name; |
|
| 2571 | - } |
|
| 2569 | + $open_tab = $tab_name; |
|
| 2570 | + $used_tabs[] = $tab_name; |
|
| 2571 | + } |
|
| 2572 | 2572 | |
| 2573 | - if($open_tab_groups == $tab_args['groups']){ |
|
| 2574 | - //$open_tab = ''; |
|
| 2575 | - $close_tab = true; |
|
| 2576 | - $open_tab_groups = array(); |
|
| 2573 | + if($open_tab_groups == $tab_args['groups']){ |
|
| 2574 | + //$open_tab = ''; |
|
| 2575 | + $close_tab = true; |
|
| 2576 | + $open_tab_groups = array(); |
|
| 2577 | 2577 | |
| 2578 | 2578 | // print_r(array_keys($this->options['block_group_tabs']));echo '####';print_r($used_tabs); |
| 2579 | - if($used_tabs == array_keys($this->options['block_group_tabs'])){ |
|
| 2579 | + if($used_tabs == array_keys($this->options['block_group_tabs'])){ |
|
| 2580 | 2580 | // echo '@@@'; |
| 2581 | - $close_tabs = true; |
|
| 2582 | - } |
|
| 2583 | - } |
|
| 2581 | + $close_tabs = true; |
|
| 2582 | + } |
|
| 2583 | + } |
|
| 2584 | 2584 | |
| 2585 | - } |
|
| 2586 | - } |
|
| 2587 | - } |
|
| 2585 | + } |
|
| 2586 | + } |
|
| 2587 | + } |
|
| 2588 | 2588 | |
| 2589 | 2589 | // |
| 2590 | 2590 | |
| 2591 | - // print_r($arguments);exit; |
|
| 2591 | + // print_r($arguments);exit; |
|
| 2592 | 2592 | |
| 2593 | - ?> |
|
| 2593 | + ?> |
|
| 2594 | 2594 | el(wp.components.PanelBody, { |
| 2595 | 2595 | title: '<?php esc_attr_e( $key ); ?>', |
| 2596 | 2596 | initialOpen: <?php if ( $panel_count ) { |
| 2597 | - echo "false"; |
|
| 2598 | - } else { |
|
| 2599 | - echo "true"; |
|
| 2600 | - }?> |
|
| 2597 | + echo "false"; |
|
| 2598 | + } else { |
|
| 2599 | + echo "true"; |
|
| 2600 | + }?> |
|
| 2601 | 2601 | }, |
| 2602 | 2602 | <?php |
| 2603 | 2603 | |
| 2604 | 2604 | |
| 2605 | 2605 | |
| 2606 | - foreach ( $args as $k => $a ) { |
|
| 2606 | + foreach ( $args as $k => $a ) { |
|
| 2607 | 2607 | |
| 2608 | - $this->block_tab_start( $k, $a ); |
|
| 2609 | - $this->block_row_start( $k, $a ); |
|
| 2610 | - $this->build_block_arguments( $k, $a ); |
|
| 2611 | - $this->block_row_end( $k, $a ); |
|
| 2612 | - $this->block_tab_end( $k, $a ); |
|
| 2613 | - } |
|
| 2614 | - ?> |
|
| 2608 | + $this->block_tab_start( $k, $a ); |
|
| 2609 | + $this->block_row_start( $k, $a ); |
|
| 2610 | + $this->build_block_arguments( $k, $a ); |
|
| 2611 | + $this->block_row_end( $k, $a ); |
|
| 2612 | + $this->block_tab_end( $k, $a ); |
|
| 2613 | + } |
|
| 2614 | + ?> |
|
| 2615 | 2615 | ), |
| 2616 | 2616 | <?php |
| 2617 | - $panel_count ++; |
|
| 2617 | + $panel_count ++; |
|
| 2618 | 2618 | |
| 2619 | 2619 | |
| 2620 | - if($close_tab || $close_tabs){ |
|
| 2621 | - $tab_args = array( |
|
| 2622 | - 'tab' => array( |
|
| 2623 | - 'tabs_close' => $close_tabs, |
|
| 2624 | - 'close' => true, |
|
| 2625 | - ) |
|
| 2620 | + if($close_tab || $close_tabs){ |
|
| 2621 | + $tab_args = array( |
|
| 2622 | + 'tab' => array( |
|
| 2623 | + 'tabs_close' => $close_tabs, |
|
| 2624 | + 'close' => true, |
|
| 2625 | + ) |
|
| 2626 | 2626 | |
| 2627 | - ); |
|
| 2628 | - $this->block_tab_end( '', $tab_args ); |
|
| 2627 | + ); |
|
| 2628 | + $this->block_tab_end( '', $tab_args ); |
|
| 2629 | 2629 | // echo '###close'; print_r($tab_args); |
| 2630 | - $panel_count = 0; |
|
| 2631 | - } |
|
| 2630 | + $panel_count = 0; |
|
| 2631 | + } |
|
| 2632 | 2632 | // |
| 2633 | 2633 | |
| 2634 | - } |
|
| 2635 | - }else { |
|
| 2636 | - ?> |
|
| 2634 | + } |
|
| 2635 | + }else { |
|
| 2636 | + ?> |
|
| 2637 | 2637 | el(wp.components.PanelBody, { |
| 2638 | 2638 | title: '<?php esc_attr_e( "Settings" ); ?>', |
| 2639 | 2639 | initialOpen: true |
| 2640 | 2640 | }, |
| 2641 | 2641 | <?php |
| 2642 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2643 | - $this->block_row_start( $key, $args ); |
|
| 2644 | - $this->build_block_arguments( $key, $args ); |
|
| 2645 | - $this->block_row_end( $key, $args ); |
|
| 2646 | - } |
|
| 2647 | - ?> |
|
| 2642 | + foreach ( $this->arguments as $key => $args ) { |
|
| 2643 | + $this->block_row_start( $key, $args ); |
|
| 2644 | + $this->build_block_arguments( $key, $args ); |
|
| 2645 | + $this->block_row_end( $key, $args ); |
|
| 2646 | + } |
|
| 2647 | + ?> |
|
| 2648 | 2648 | ), |
| 2649 | 2649 | <?php |
| 2650 | - } |
|
| 2650 | + } |
|
| 2651 | 2651 | |
| 2652 | - } |
|
| 2653 | - ?> |
|
| 2652 | + } |
|
| 2653 | + ?> |
|
| 2654 | 2654 | |
| 2655 | 2655 | ), |
| 2656 | 2656 | |
| 2657 | 2657 | <?php |
| 2658 | - // If the user sets block-output array then build it |
|
| 2659 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 2660 | - $this->block_element( $this->options['block-output'] ); |
|
| 2661 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2662 | - echo $this->options['block-edit-return']; |
|
| 2663 | - }else{ |
|
| 2664 | - // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 2665 | - ?> |
|
| 2658 | + // If the user sets block-output array then build it |
|
| 2659 | + if ( ! empty( $this->options['block-output'] ) ) { |
|
| 2660 | + $this->block_element( $this->options['block-output'] ); |
|
| 2661 | + }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2662 | + echo $this->options['block-edit-return']; |
|
| 2663 | + }else{ |
|
| 2664 | + // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 2665 | + ?> |
|
| 2666 | 2666 | el('div', wp.blockEditor.useBlockProps({ |
| 2667 | 2667 | dangerouslySetInnerHTML: {__html: onChangeContent()}, |
| 2668 | 2668 | className: props.className, |
| 2669 | 2669 | style: {'minHeight': '30px'} |
| 2670 | 2670 | })) |
| 2671 | 2671 | <?php |
| 2672 | - } |
|
| 2673 | - ?> |
|
| 2672 | + } |
|
| 2673 | + ?> |
|
| 2674 | 2674 | ]; // end return |
| 2675 | 2675 | |
| 2676 | 2676 | <?php |
@@ -2689,11 +2689,11 @@ discard block |
||
| 2689 | 2689 | $html = ''; |
| 2690 | 2690 | <?php |
| 2691 | 2691 | |
| 2692 | - if(! empty( $this->arguments )){ |
|
| 2692 | + if(! empty( $this->arguments )){ |
|
| 2693 | 2693 | |
| 2694 | - foreach($this->arguments as $key => $args){ |
|
| 2695 | - // if($args['type']=='tabs'){continue;} |
|
| 2696 | - ?> |
|
| 2694 | + foreach($this->arguments as $key => $args){ |
|
| 2695 | + // if($args['type']=='tabs'){continue;} |
|
| 2696 | + ?> |
|
| 2697 | 2697 | if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
| 2698 | 2698 | if ('<?php echo esc_attr( $key );?>' == 'html') { |
| 2699 | 2699 | $html = attr.<?php echo esc_attr( $key );?>; |
@@ -2704,10 +2704,10 @@ discard block |
||
| 2704 | 2704 | } |
| 2705 | 2705 | } |
| 2706 | 2706 | <?php |
| 2707 | - } |
|
| 2708 | - } |
|
| 2707 | + } |
|
| 2708 | + } |
|
| 2709 | 2709 | |
| 2710 | - ?> |
|
| 2710 | + ?> |
|
| 2711 | 2711 | content += "]"; |
| 2712 | 2712 | |
| 2713 | 2713 | <?php |
@@ -2754,7 +2754,7 @@ discard block |
||
| 2754 | 2754 | // $this->block_element( $this->options['block-output'], true ); |
| 2755 | 2755 | // echo ";"; |
| 2756 | 2756 | |
| 2757 | - ?> |
|
| 2757 | + ?> |
|
| 2758 | 2758 | return el( |
| 2759 | 2759 | '', |
| 2760 | 2760 | {}, |
@@ -2764,9 +2764,9 @@ discard block |
||
| 2764 | 2764 | ); |
| 2765 | 2765 | <?php |
| 2766 | 2766 | |
| 2767 | - }elseif(!empty($this->options['block-save-return'])){ |
|
| 2768 | - echo 'return ' . $this->options['block-save-return']; |
|
| 2769 | - }elseif(!empty($this->options['nested-block'])){ |
|
| 2767 | + }elseif(!empty($this->options['block-save-return'])){ |
|
| 2768 | + echo 'return ' . $this->options['block-save-return']; |
|
| 2769 | + }elseif(!empty($this->options['nested-block'])){ |
|
| 2770 | 2770 | ?> |
| 2771 | 2771 | return el( |
| 2772 | 2772 | '', |
@@ -2776,22 +2776,22 @@ discard block |
||
| 2776 | 2776 | el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
| 2777 | 2777 | ); |
| 2778 | 2778 | <?php |
| 2779 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2779 | + }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2780 | 2780 | echo "return ". $this->options['block-edit-return'].";"; |
| 2781 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2782 | - ?> |
|
| 2781 | + }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2782 | + ?> |
|
| 2783 | 2783 | return content; |
| 2784 | 2784 | <?php |
| 2785 | - }else{ |
|
| 2786 | - ?> |
|
| 2785 | + }else{ |
|
| 2786 | + ?> |
|
| 2787 | 2787 | var block_wrap = 'div'; |
| 2788 | 2788 | if (attr.hasOwnProperty("block_wrap")) { |
| 2789 | 2789 | block_wrap = attr.block_wrap; |
| 2790 | 2790 | } |
| 2791 | 2791 | return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} )); |
| 2792 | 2792 | <?php |
| 2793 | - } |
|
| 2794 | - ?> |
|
| 2793 | + } |
|
| 2794 | + ?> |
|
| 2795 | 2795 | |
| 2796 | 2796 | |
| 2797 | 2797 | } |
@@ -2805,29 +2805,29 @@ discard block |
||
| 2805 | 2805 | }); |
| 2806 | 2806 | </script> |
| 2807 | 2807 | <?php |
| 2808 | - $output = ob_get_clean(); |
|
| 2808 | + $output = ob_get_clean(); |
|
| 2809 | 2809 | |
| 2810 | - /* |
|
| 2810 | + /* |
|
| 2811 | 2811 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 2812 | 2812 | */ |
| 2813 | 2813 | |
| 2814 | - return str_replace( array( |
|
| 2815 | - '<script>', |
|
| 2816 | - '</script>' |
|
| 2817 | - ), '', $output ); |
|
| 2818 | - } |
|
| 2814 | + return str_replace( array( |
|
| 2815 | + '<script>', |
|
| 2816 | + '</script>' |
|
| 2817 | + ), '', $output ); |
|
| 2818 | + } |
|
| 2819 | 2819 | |
| 2820 | 2820 | |
| 2821 | 2821 | |
| 2822 | - public function block_row_start($key, $args){ |
|
| 2822 | + public function block_row_start($key, $args){ |
|
| 2823 | 2823 | |
| 2824 | - // check for row |
|
| 2825 | - if(!empty($args['row'])){ |
|
| 2824 | + // check for row |
|
| 2825 | + if(!empty($args['row'])){ |
|
| 2826 | 2826 | |
| 2827 | - if(!empty($args['row']['open'])){ |
|
| 2827 | + if(!empty($args['row']['open'])){ |
|
| 2828 | 2828 | |
| 2829 | - // element require |
|
| 2830 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 2829 | + // element require |
|
| 2830 | + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 2831 | 2831 | $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
| 2832 | 2832 | $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
| 2833 | 2833 | $device_type_icon = ''; |
@@ -2838,10 +2838,10 @@ discard block |
||
| 2838 | 2838 | }elseif($device_type=='Mobile'){ |
| 2839 | 2839 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;"></span>'; |
| 2840 | 2840 | } |
| 2841 | - echo $element_require; |
|
| 2841 | + echo $element_require; |
|
| 2842 | 2842 | echo $device_type_require; |
| 2843 | 2843 | |
| 2844 | - if(false){?><script><?php }?> |
|
| 2844 | + if(false){?><script><?php }?> |
|
| 2845 | 2845 | el('div', { |
| 2846 | 2846 | className: 'bsui components-base-control', |
| 2847 | 2847 | }, |
@@ -2879,51 +2879,51 @@ discard block |
||
| 2879 | 2879 | }, |
| 2880 | 2880 | |
| 2881 | 2881 | <?php |
| 2882 | - if(false){?></script><?php } |
|
| 2883 | - }elseif(!empty($args['row']['close'])){ |
|
| 2884 | - if(false){?><script><?php }?> |
|
| 2882 | + if(false){?></script><?php } |
|
| 2883 | + }elseif(!empty($args['row']['close'])){ |
|
| 2884 | + if(false){?><script><?php }?> |
|
| 2885 | 2885 | el( |
| 2886 | 2886 | 'div', |
| 2887 | 2887 | { |
| 2888 | 2888 | className: 'col pl-0', |
| 2889 | 2889 | }, |
| 2890 | 2890 | <?php |
| 2891 | - if(false){?></script><?php } |
|
| 2892 | - }else{ |
|
| 2893 | - if(false){?><script><?php }?> |
|
| 2891 | + if(false){?></script><?php } |
|
| 2892 | + }else{ |
|
| 2893 | + if(false){?><script><?php }?> |
|
| 2894 | 2894 | el( |
| 2895 | 2895 | 'div', |
| 2896 | 2896 | { |
| 2897 | 2897 | className: 'col pl-0 pr-2', |
| 2898 | 2898 | }, |
| 2899 | 2899 | <?php |
| 2900 | - if(false){?></script><?php } |
|
| 2901 | - } |
|
| 2900 | + if(false){?></script><?php } |
|
| 2901 | + } |
|
| 2902 | 2902 | |
| 2903 | - } |
|
| 2903 | + } |
|
| 2904 | 2904 | |
| 2905 | - } |
|
| 2905 | + } |
|
| 2906 | 2906 | |
| 2907 | - public function block_row_end($key, $args){ |
|
| 2907 | + public function block_row_end($key, $args){ |
|
| 2908 | 2908 | |
| 2909 | - if(!empty($args['row'])){ |
|
| 2910 | - // maybe close |
|
| 2911 | - if(!empty($args['row']['close'])){ |
|
| 2912 | - echo "))"; |
|
| 2913 | - } |
|
| 2909 | + if(!empty($args['row'])){ |
|
| 2910 | + // maybe close |
|
| 2911 | + if(!empty($args['row']['close'])){ |
|
| 2912 | + echo "))"; |
|
| 2913 | + } |
|
| 2914 | 2914 | |
| 2915 | - echo "),"; |
|
| 2916 | - } |
|
| 2917 | - } |
|
| 2915 | + echo "),"; |
|
| 2916 | + } |
|
| 2917 | + } |
|
| 2918 | 2918 | |
| 2919 | - public function block_tab_start($key, $args){ |
|
| 2919 | + public function block_tab_start($key, $args){ |
|
| 2920 | 2920 | |
| 2921 | - // check for row |
|
| 2922 | - if(!empty($args['tab'])){ |
|
| 2921 | + // check for row |
|
| 2922 | + if(!empty($args['tab'])){ |
|
| 2923 | 2923 | |
| 2924 | - if(!empty($args['tab']['tabs_open'])){ |
|
| 2924 | + if(!empty($args['tab']['tabs_open'])){ |
|
| 2925 | 2925 | |
| 2926 | - if(false){?><script><?php }?> |
|
| 2926 | + if(false){?><script><?php }?> |
|
| 2927 | 2927 | |
| 2928 | 2928 | el('div',{className: 'bsui'}, |
| 2929 | 2929 | |
@@ -2936,12 +2936,12 @@ discard block |
||
| 2936 | 2936 | tabs: [ |
| 2937 | 2937 | |
| 2938 | 2938 | <?php |
| 2939 | - if(false){?></script><?php } |
|
| 2940 | - } |
|
| 2939 | + if(false){?></script><?php } |
|
| 2940 | + } |
|
| 2941 | 2941 | |
| 2942 | - if(!empty($args['tab']['open'])){ |
|
| 2942 | + if(!empty($args['tab']['open'])){ |
|
| 2943 | 2943 | |
| 2944 | - if(false){?><script><?php }?> |
|
| 2944 | + if(false){?><script><?php }?> |
|
| 2945 | 2945 | { |
| 2946 | 2946 | name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
| 2947 | 2947 | title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}), |
@@ -2950,23 +2950,23 @@ discard block |
||
| 2950 | 2950 | className: 'components-base-control__help mb-0', |
| 2951 | 2951 | dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'} |
| 2952 | 2952 | }),<?php } |
| 2953 | - if(false){?></script><?php } |
|
| 2954 | - } |
|
| 2953 | + if(false){?></script><?php } |
|
| 2954 | + } |
|
| 2955 | 2955 | |
| 2956 | - } |
|
| 2956 | + } |
|
| 2957 | 2957 | |
| 2958 | - } |
|
| 2958 | + } |
|
| 2959 | 2959 | |
| 2960 | - public function block_tab_end($key, $args){ |
|
| 2960 | + public function block_tab_end($key, $args){ |
|
| 2961 | 2961 | |
| 2962 | - if(!empty($args['tab'])){ |
|
| 2963 | - // maybe close |
|
| 2964 | - if(!empty($args['tab']['close'])){ |
|
| 2965 | - echo ")}, /* tab close */"; |
|
| 2966 | - } |
|
| 2962 | + if(!empty($args['tab'])){ |
|
| 2963 | + // maybe close |
|
| 2964 | + if(!empty($args['tab']['close'])){ |
|
| 2965 | + echo ")}, /* tab close */"; |
|
| 2966 | + } |
|
| 2967 | 2967 | |
| 2968 | - if(!empty($args['tab']['tabs_close'])){ |
|
| 2969 | - if(false){?><script><?php }?> |
|
| 2968 | + if(!empty($args['tab']['tabs_close'])){ |
|
| 2969 | + if(false){?><script><?php }?> |
|
| 2970 | 2970 | ], |
| 2971 | 2971 | }, |
| 2972 | 2972 | ( tab ) => { |
@@ -2976,21 +2976,21 @@ discard block |
||
| 2976 | 2976 | } |
| 2977 | 2977 | )), /* tabs close */ |
| 2978 | 2978 | <?php if(false){ ?></script><?php } |
| 2979 | - } |
|
| 2980 | - } |
|
| 2981 | - } |
|
| 2979 | + } |
|
| 2980 | + } |
|
| 2981 | + } |
|
| 2982 | 2982 | |
| 2983 | - public function build_block_arguments( $key, $args ) { |
|
| 2984 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 2985 | - $options = ''; |
|
| 2986 | - $extra = ''; |
|
| 2987 | - $require = ''; |
|
| 2983 | + public function build_block_arguments( $key, $args ) { |
|
| 2984 | + $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 2985 | + $options = ''; |
|
| 2986 | + $extra = ''; |
|
| 2987 | + $require = ''; |
|
| 2988 | 2988 | $inside_elements = ''; |
| 2989 | 2989 | |
| 2990 | - // `content` is a protected and special argument |
|
| 2991 | - if ( $key == 'content' ) { |
|
| 2992 | - return; |
|
| 2993 | - } |
|
| 2990 | + // `content` is a protected and special argument |
|
| 2991 | + if ( $key == 'content' ) { |
|
| 2992 | + return; |
|
| 2993 | + } |
|
| 2994 | 2994 | |
| 2995 | 2995 | $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
| 2996 | 2996 | $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
@@ -3003,51 +3003,51 @@ discard block |
||
| 3003 | 3003 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;"></span>'; |
| 3004 | 3004 | } |
| 3005 | 3005 | |
| 3006 | - // icon |
|
| 3007 | - $icon = ''; |
|
| 3008 | - if( !empty( $args['icon'] ) ){ |
|
| 3009 | - $icon .= "el('div', {"; |
|
| 3010 | - $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3011 | - $icon .= "className: 'text-center',"; |
|
| 3012 | - $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3013 | - $icon .= "}),"; |
|
| 3014 | - |
|
| 3015 | - // blank title as its added to the icon. |
|
| 3016 | - $args['title'] = ''; |
|
| 3017 | - } |
|
| 3006 | + // icon |
|
| 3007 | + $icon = ''; |
|
| 3008 | + if( !empty( $args['icon'] ) ){ |
|
| 3009 | + $icon .= "el('div', {"; |
|
| 3010 | + $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3011 | + $icon .= "className: 'text-center',"; |
|
| 3012 | + $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3013 | + $icon .= "}),"; |
|
| 3014 | + |
|
| 3015 | + // blank title as its added to the icon. |
|
| 3016 | + $args['title'] = ''; |
|
| 3017 | + } |
|
| 3018 | 3018 | |
| 3019 | - // require advanced |
|
| 3020 | - $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3019 | + // require advanced |
|
| 3020 | + $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3021 | 3021 | |
| 3022 | - // element require |
|
| 3023 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3022 | + // element require |
|
| 3023 | + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3024 | 3024 | |
| 3025 | 3025 | |
| 3026 | - $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 3027 | - $onchangecomplete = ""; |
|
| 3028 | - $value = "props.attributes.$key"; |
|
| 3029 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3030 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 3031 | - $type = 'TextControl'; |
|
| 3032 | - // Save numbers as numbers and not strings |
|
| 3033 | - if ( $args['type'] == 'number' ) { |
|
| 3034 | - $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
|
| 3035 | - } |
|
| 3036 | - }else if ( $args['type'] == 'styleid' ) { |
|
| 3037 | - $type = 'TextControl'; |
|
| 3038 | - $args['type'] == 'text'; |
|
| 3039 | - // Save numbers as numbers and not strings |
|
| 3040 | - $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3041 | - }else if ( $args['type'] == 'notice' ) { |
|
| 3042 | - |
|
| 3043 | - $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
|
| 3044 | - $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
|
| 3045 | - |
|
| 3046 | - $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; |
|
| 3047 | - echo $notice_message ? $element_require . $notice : ''; |
|
| 3048 | - return; |
|
| 3049 | - } |
|
| 3050 | - /* |
|
| 3026 | + $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 3027 | + $onchangecomplete = ""; |
|
| 3028 | + $value = "props.attributes.$key"; |
|
| 3029 | + $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3030 | + if ( in_array( $args['type'], $text_type ) ) { |
|
| 3031 | + $type = 'TextControl'; |
|
| 3032 | + // Save numbers as numbers and not strings |
|
| 3033 | + if ( $args['type'] == 'number' ) { |
|
| 3034 | + $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
|
| 3035 | + } |
|
| 3036 | + }else if ( $args['type'] == 'styleid' ) { |
|
| 3037 | + $type = 'TextControl'; |
|
| 3038 | + $args['type'] == 'text'; |
|
| 3039 | + // Save numbers as numbers and not strings |
|
| 3040 | + $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3041 | + }else if ( $args['type'] == 'notice' ) { |
|
| 3042 | + |
|
| 3043 | + $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
|
| 3044 | + $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
|
| 3045 | + |
|
| 3046 | + $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; |
|
| 3047 | + echo $notice_message ? $element_require . $notice : ''; |
|
| 3048 | + return; |
|
| 3049 | + } |
|
| 3050 | + /* |
|
| 3051 | 3051 | * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout |
| 3052 | 3052 | elseif($args['type']=='tabs'){ |
| 3053 | 3053 | ?> |
@@ -3100,23 +3100,23 @@ discard block |
||
| 3100 | 3100 | return; |
| 3101 | 3101 | } |
| 3102 | 3102 | */ |
| 3103 | - elseif ( $args['type'] == 'color' ) { |
|
| 3104 | - $type = 'ColorPicker'; |
|
| 3105 | - $onchange = ""; |
|
| 3106 | - $extra = "color: $value,"; |
|
| 3107 | - if(!empty($args['disable_alpha'])){ |
|
| 3108 | - $extra .= "disableAlpha: true,"; |
|
| 3109 | - } |
|
| 3110 | - $onchangecomplete = "onChangeComplete: function($key) { |
|
| 3103 | + elseif ( $args['type'] == 'color' ) { |
|
| 3104 | + $type = 'ColorPicker'; |
|
| 3105 | + $onchange = ""; |
|
| 3106 | + $extra = "color: $value,"; |
|
| 3107 | + if(!empty($args['disable_alpha'])){ |
|
| 3108 | + $extra .= "disableAlpha: true,"; |
|
| 3109 | + } |
|
| 3110 | + $onchangecomplete = "onChangeComplete: function($key) { |
|
| 3111 | 3111 | value = $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex; |
| 3112 | 3112 | props.setAttributes({ |
| 3113 | 3113 | $key: value |
| 3114 | 3114 | }); |
| 3115 | 3115 | },"; |
| 3116 | - }elseif ( $args['type'] == 'gradient' ) { |
|
| 3117 | - $type = 'GradientPicker'; |
|
| 3116 | + }elseif ( $args['type'] == 'gradient' ) { |
|
| 3117 | + $type = 'GradientPicker'; |
|
| 3118 | 3118 | |
| 3119 | - }elseif ( $args['type'] == 'image' ) { |
|
| 3119 | + }elseif ( $args['type'] == 'image' ) { |
|
| 3120 | 3120 | // print_r($args); |
| 3121 | 3121 | |
| 3122 | 3122 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? "props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " props.attributes.$key && el(wp.components.FocalPointPicker,{ |
@@ -3139,15 +3139,15 @@ discard block |
||
| 3139 | 3139 | |
| 3140 | 3140 | |
| 3141 | 3141 | $value = '""'; |
| 3142 | - $type = 'MediaUpload'; |
|
| 3142 | + $type = 'MediaUpload'; |
|
| 3143 | 3143 | $extra .= "onSelect: function(media){ |
| 3144 | 3144 | return props.setAttributes({ |
| 3145 | 3145 | $key: media.url, |
| 3146 | 3146 | {$key}_id: media.id |
| 3147 | 3147 | }); |
| 3148 | 3148 | },"; |
| 3149 | - $extra .= "type: 'image',"; |
|
| 3150 | - $extra .= "render: function (obj) { |
|
| 3149 | + $extra .= "type: 'image',"; |
|
| 3150 | + $extra .= "render: function (obj) { |
|
| 3151 | 3151 | return el( 'div',{}, |
| 3152 | 3152 | !props.attributes.$key && el( wp.components.Button, { |
| 3153 | 3153 | className: 'components-button components-circular-option-picker__clear is-primary is-smallx', |
@@ -3176,8 +3176,8 @@ discard block |
||
| 3176 | 3176 | $onchange = ""; |
| 3177 | 3177 | |
| 3178 | 3178 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3179 | - }elseif ( $args['type'] == 'images' ) { |
|
| 3180 | - // print_r($args); |
|
| 3179 | + }elseif ( $args['type'] == 'images' ) { |
|
| 3180 | + // print_r($args); |
|
| 3181 | 3181 | |
| 3182 | 3182 | $img_preview = "props.attributes.$key && (function() { |
| 3183 | 3183 | |
@@ -3206,7 +3206,7 @@ discard block |
||
| 3206 | 3206 | |
| 3207 | 3207 | |
| 3208 | 3208 | $value = '""'; |
| 3209 | - $type = 'MediaUpload'; |
|
| 3209 | + $type = 'MediaUpload'; |
|
| 3210 | 3210 | $extra .= "onSelect: function(media){ |
| 3211 | 3211 | |
| 3212 | 3212 | let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : []; |
@@ -3220,9 +3220,9 @@ discard block |
||
| 3220 | 3220 | $key: JSON.stringify(slim_images).replace('[','').replace(']',''), |
| 3221 | 3221 | }); |
| 3222 | 3222 | },"; |
| 3223 | - $extra .= "type: 'image',"; |
|
| 3224 | - $extra .= "multiple: true,"; |
|
| 3225 | - $extra .= "render: function (obj) { |
|
| 3223 | + $extra .= "type: 'image',"; |
|
| 3224 | + $extra .= "multiple: true,"; |
|
| 3225 | + $extra .= "render: function (obj) { |
|
| 3226 | 3226 | |
| 3227 | 3227 | // init the sort |
| 3228 | 3228 | enableDragSort('sd-sortable'); |
@@ -3261,66 +3261,66 @@ discard block |
||
| 3261 | 3261 | $onchange = ""; |
| 3262 | 3262 | |
| 3263 | 3263 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3264 | - } |
|
| 3265 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 3266 | - $type = 'CheckboxControl'; |
|
| 3267 | - $extra .= "checked: props.attributes.$key,"; |
|
| 3268 | - $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 3269 | - } elseif ( $args['type'] == 'textarea' ) { |
|
| 3270 | - $type = 'TextareaControl'; |
|
| 3271 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3272 | - $type = 'SelectControl'; |
|
| 3273 | - |
|
| 3274 | - if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3275 | - $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3276 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3277 | - $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3278 | - }else { |
|
| 3279 | - |
|
| 3280 | - if ( ! empty( $args['options'] ) ) { |
|
| 3281 | - $options .= "options: ["; |
|
| 3282 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3283 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 3284 | - } |
|
| 3285 | - $options .= "],"; |
|
| 3286 | - } |
|
| 3287 | - } |
|
| 3288 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3289 | - $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px"}, '; |
|
| 3290 | - } |
|
| 3291 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 3292 | - $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 3293 | - }elseif ( $args['type'] == 'margins' ) { |
|
| 3264 | + } |
|
| 3265 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 3266 | + $type = 'CheckboxControl'; |
|
| 3267 | + $extra .= "checked: props.attributes.$key,"; |
|
| 3268 | + $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 3269 | + } elseif ( $args['type'] == 'textarea' ) { |
|
| 3270 | + $type = 'TextareaControl'; |
|
| 3271 | + } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3272 | + $type = 'SelectControl'; |
|
| 3273 | + |
|
| 3274 | + if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3275 | + $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3276 | + }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3277 | + $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3278 | + }else { |
|
| 3279 | + |
|
| 3280 | + if ( ! empty( $args['options'] ) ) { |
|
| 3281 | + $options .= "options: ["; |
|
| 3282 | + foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3283 | + $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 3284 | + } |
|
| 3285 | + $options .= "],"; |
|
| 3286 | + } |
|
| 3287 | + } |
|
| 3288 | + if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3289 | + $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px"}, '; |
|
| 3290 | + } |
|
| 3291 | + } elseif ( $args['type'] == 'alignment' ) { |
|
| 3292 | + $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 3293 | + }elseif ( $args['type'] == 'margins' ) { |
|
| 3294 | 3294 | |
| 3295 | - } else { |
|
| 3296 | - return;// if we have not implemented the control then don't break the JS. |
|
| 3297 | - } |
|
| 3295 | + } else { |
|
| 3296 | + return;// if we have not implemented the control then don't break the JS. |
|
| 3297 | + } |
|
| 3298 | 3298 | |
| 3299 | 3299 | |
| 3300 | 3300 | |
| 3301 | - // color input does not show the labels so we add them |
|
| 3302 | - if($args['type']=='color'){ |
|
| 3303 | - // add show only if advanced |
|
| 3304 | - echo $require_advanced; |
|
| 3305 | - // add setting require if defined |
|
| 3306 | - echo $element_require; |
|
| 3307 | - echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3308 | - } |
|
| 3301 | + // color input does not show the labels so we add them |
|
| 3302 | + if($args['type']=='color'){ |
|
| 3303 | + // add show only if advanced |
|
| 3304 | + echo $require_advanced; |
|
| 3305 | + // add setting require if defined |
|
| 3306 | + echo $element_require; |
|
| 3307 | + echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3308 | + } |
|
| 3309 | 3309 | |
| 3310 | - // add show only if advanced |
|
| 3311 | - echo $require_advanced; |
|
| 3312 | - // add setting require if defined |
|
| 3313 | - echo $element_require; |
|
| 3310 | + // add show only if advanced |
|
| 3311 | + echo $require_advanced; |
|
| 3312 | + // add setting require if defined |
|
| 3313 | + echo $element_require; |
|
| 3314 | 3314 | echo $device_type_require; |
| 3315 | 3315 | |
| 3316 | - // icon |
|
| 3317 | - echo $icon; |
|
| 3318 | - ?> |
|
| 3316 | + // icon |
|
| 3317 | + echo $icon; |
|
| 3318 | + ?> |
|
| 3319 | 3319 | el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components.".$type; ?>, { |
| 3320 | 3320 | label: <?php |
| 3321 | - if(empty($args['title'])){ |
|
| 3321 | + if(empty($args['title'])){ |
|
| 3322 | 3322 | echo "''"; |
| 3323 | - }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3323 | + }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3324 | 3324 | ?>el('label', { |
| 3325 | 3325 | className: 'components-base-control__label', |
| 3326 | 3326 | style: {width:"100%"} |
@@ -3335,22 +3335,22 @@ discard block |
||
| 3335 | 3335 | |
| 3336 | 3336 | )<?php |
| 3337 | 3337 | |
| 3338 | - }else{ |
|
| 3339 | - ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
|
| 3338 | + }else{ |
|
| 3339 | + ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
|
| 3340 | 3340 | |
| 3341 | - } |
|
| 3341 | + } |
|
| 3342 | 3342 | |
| 3343 | - ?>, |
|
| 3343 | + ?>, |
|
| 3344 | 3344 | help: <?php if ( isset( $args['desc'] ) ) { |
| 3345 | - echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
|
| 3346 | - }else{ echo "''"; } ?>, |
|
| 3345 | + echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
|
| 3346 | + }else{ echo "''"; } ?>, |
|
| 3347 | 3347 | value: <?php echo $value; ?>, |
| 3348 | 3348 | <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
| 3349 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3350 | - } ?> |
|
| 3349 | + echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3350 | + } ?> |
|
| 3351 | 3351 | <?php if ( ! empty( $args['placeholder'] ) ) { |
| 3352 | - echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 3353 | - } ?> |
|
| 3352 | + echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 3353 | + } ?> |
|
| 3354 | 3354 | <?php echo $options; ?> |
| 3355 | 3355 | <?php echo $extra; ?> |
| 3356 | 3356 | <?php echo $custom_attributes; ?> |
@@ -3365,67 +3365,67 @@ discard block |
||
| 3365 | 3365 | <?php |
| 3366 | 3366 | |
| 3367 | 3367 | |
| 3368 | - } |
|
| 3368 | + } |
|
| 3369 | 3369 | |
| 3370 | - /** |
|
| 3371 | - * Convert an array of attributes to block string. |
|
| 3372 | - * |
|
| 3373 | - * @param $custom_attributes |
|
| 3374 | - * |
|
| 3375 | - * @return string |
|
| 3376 | - *@todo there is prob a faster way to do this, also we could add some validation here. |
|
| 3377 | - * |
|
| 3378 | - */ |
|
| 3379 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3380 | - $attributes = ''; |
|
| 3381 | - if ( ! empty( $custom_attributes ) ) { |
|
| 3382 | - |
|
| 3383 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 3384 | - if(is_array($val)){ |
|
| 3385 | - $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3386 | - }else{ |
|
| 3387 | - $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3388 | - } |
|
| 3389 | - } |
|
| 3370 | + /** |
|
| 3371 | + * Convert an array of attributes to block string. |
|
| 3372 | + * |
|
| 3373 | + * @param $custom_attributes |
|
| 3374 | + * |
|
| 3375 | + * @return string |
|
| 3376 | + *@todo there is prob a faster way to do this, also we could add some validation here. |
|
| 3377 | + * |
|
| 3378 | + */ |
|
| 3379 | + public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3380 | + $attributes = ''; |
|
| 3381 | + if ( ! empty( $custom_attributes ) ) { |
|
| 3390 | 3382 | |
| 3391 | - } |
|
| 3383 | + foreach ( $custom_attributes as $key => $val ) { |
|
| 3384 | + if(is_array($val)){ |
|
| 3385 | + $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3386 | + }else{ |
|
| 3387 | + $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3388 | + } |
|
| 3389 | + } |
|
| 3392 | 3390 | |
| 3393 | - return $attributes; |
|
| 3394 | - } |
|
| 3391 | + } |
|
| 3392 | + |
|
| 3393 | + return $attributes; |
|
| 3394 | + } |
|
| 3395 | 3395 | |
| 3396 | 3396 | |
| 3397 | 3397 | |
| 3398 | - /** |
|
| 3399 | - * A self looping function to create the output for JS block elements. |
|
| 3400 | - * |
|
| 3401 | - * This is what is output in the WP Editor visual view. |
|
| 3402 | - * |
|
| 3403 | - * @param $args |
|
| 3404 | - */ |
|
| 3405 | - public function block_element( $args, $save = false ) { |
|
| 3398 | + /** |
|
| 3399 | + * A self looping function to create the output for JS block elements. |
|
| 3400 | + * |
|
| 3401 | + * This is what is output in the WP Editor visual view. |
|
| 3402 | + * |
|
| 3403 | + * @param $args |
|
| 3404 | + */ |
|
| 3405 | + public function block_element( $args, $save = false ) { |
|
| 3406 | 3406 | |
| 3407 | 3407 | |
| 3408 | - if ( ! empty( $args ) ) { |
|
| 3409 | - foreach ( $args as $element => $new_args ) { |
|
| 3408 | + if ( ! empty( $args ) ) { |
|
| 3409 | + foreach ( $args as $element => $new_args ) { |
|
| 3410 | 3410 | |
| 3411 | - if ( is_array( $new_args ) ) { // its an element |
|
| 3411 | + if ( is_array( $new_args ) ) { // its an element |
|
| 3412 | 3412 | |
| 3413 | 3413 | |
| 3414 | - if ( isset( $new_args['element'] ) ) { |
|
| 3414 | + if ( isset( $new_args['element'] ) ) { |
|
| 3415 | 3415 | |
| 3416 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 3417 | - echo str_replace( array( |
|
| 3418 | - "'+", |
|
| 3419 | - "+'" |
|
| 3420 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3421 | - unset( $new_args['element_require'] ); |
|
| 3422 | - } |
|
| 3416 | + if ( isset( $new_args['element_require'] ) ) { |
|
| 3417 | + echo str_replace( array( |
|
| 3418 | + "'+", |
|
| 3419 | + "+'" |
|
| 3420 | + ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3421 | + unset( $new_args['element_require'] ); |
|
| 3422 | + } |
|
| 3423 | 3423 | |
| 3424 | 3424 | if($new_args['element']=='InnerBlocks'){ |
| 3425 | 3425 | echo "\n el( InnerBlocks, {"; |
| 3426 | 3426 | }elseif($new_args['element']=='innerBlocksProps'){ |
| 3427 | 3427 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3428 | - // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3428 | + // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3429 | 3429 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3430 | 3430 | echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3431 | 3431 | echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; |
@@ -3435,74 +3435,74 @@ discard block |
||
| 3435 | 3435 | echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; |
| 3436 | 3436 | // echo '###'; |
| 3437 | 3437 | |
| 3438 | - // echo '###'; |
|
| 3438 | + // echo '###'; |
|
| 3439 | 3439 | }elseif($new_args['element']=='BlocksProps'){ |
| 3440 | 3440 | |
| 3441 | - if ( isset($new_args['if_inner_element']) ) { |
|
| 3442 | - $element = $new_args['if_inner_element']; |
|
| 3443 | - }else { |
|
| 3444 | - $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3445 | - } |
|
| 3441 | + if ( isset($new_args['if_inner_element']) ) { |
|
| 3442 | + $element = $new_args['if_inner_element']; |
|
| 3443 | + }else { |
|
| 3444 | + $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3445 | + } |
|
| 3446 | 3446 | |
| 3447 | - unset($new_args['inner_element']); |
|
| 3447 | + unset($new_args['inner_element']); |
|
| 3448 | 3448 | echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {"; |
| 3449 | 3449 | echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
| 3450 | 3450 | |
| 3451 | 3451 | |
| 3452 | - // echo "} ),"; |
|
| 3452 | + // echo "} ),"; |
|
| 3453 | 3453 | |
| 3454 | 3454 | }else{ |
| 3455 | 3455 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 3456 | 3456 | } |
| 3457 | 3457 | |
| 3458 | 3458 | |
| 3459 | - // get the attributes |
|
| 3460 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3459 | + // get the attributes |
|
| 3460 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 3461 | 3461 | |
| 3462 | 3462 | |
| 3463 | - if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3464 | - // do nothing |
|
| 3465 | - } else { |
|
| 3466 | - echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3467 | - } |
|
| 3468 | - } |
|
| 3463 | + if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3464 | + // do nothing |
|
| 3465 | + } else { |
|
| 3466 | + echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3467 | + } |
|
| 3468 | + } |
|
| 3469 | 3469 | |
| 3470 | - echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3470 | + echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3471 | 3471 | |
| 3472 | - // get the content |
|
| 3473 | - $first_item = 0; |
|
| 3474 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3475 | - if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3472 | + // get the content |
|
| 3473 | + $first_item = 0; |
|
| 3474 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 3475 | + if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3476 | 3476 | |
| 3477 | - if ( $new_key === 'content' ) { |
|
| 3478 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 3479 | - }else if ( $new_key === 'if_content' ) { |
|
| 3480 | - echo $this->block_props_replace( $new_value ); |
|
| 3481 | - } |
|
| 3477 | + if ( $new_key === 'content' ) { |
|
| 3478 | + echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 3479 | + }else if ( $new_key === 'if_content' ) { |
|
| 3480 | + echo $this->block_props_replace( $new_value ); |
|
| 3481 | + } |
|
| 3482 | 3482 | |
| 3483 | - if ( is_array( $new_value ) ) { |
|
| 3483 | + if ( is_array( $new_value ) ) { |
|
| 3484 | 3484 | |
| 3485 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 3486 | - echo str_replace( array( |
|
| 3487 | - "'+", |
|
| 3488 | - "+'" |
|
| 3489 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 3490 | - unset( $new_value['element_require'] ); |
|
| 3491 | - } |
|
| 3485 | + if ( isset( $new_value['element_require'] ) ) { |
|
| 3486 | + echo str_replace( array( |
|
| 3487 | + "'+", |
|
| 3488 | + "+'" |
|
| 3489 | + ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 3490 | + unset( $new_value['element_require'] ); |
|
| 3491 | + } |
|
| 3492 | 3492 | |
| 3493 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 3494 | - $x = 1; |
|
| 3495 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 3496 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3497 | - $x ++; |
|
| 3498 | - } |
|
| 3499 | - } else { |
|
| 3500 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3501 | - } |
|
| 3502 | - } |
|
| 3503 | - $first_item ++; |
|
| 3504 | - } |
|
| 3505 | - } |
|
| 3493 | + if ( isset( $new_value['element_repeat'] ) ) { |
|
| 3494 | + $x = 1; |
|
| 3495 | + while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 3496 | + $this->block_element( array( '' => $new_value ),$save ); |
|
| 3497 | + $x ++; |
|
| 3498 | + } |
|
| 3499 | + } else { |
|
| 3500 | + $this->block_element( array( '' => $new_value ),$save ); |
|
| 3501 | + } |
|
| 3502 | + } |
|
| 3503 | + $first_item ++; |
|
| 3504 | + } |
|
| 3505 | + } |
|
| 3506 | 3506 | |
| 3507 | 3507 | if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
| 3508 | 3508 | echo "))";// end content |
@@ -3511,517 +3511,517 @@ discard block |
||
| 3511 | 3511 | } |
| 3512 | 3512 | |
| 3513 | 3513 | |
| 3514 | - echo ", \n"; |
|
| 3514 | + echo ", \n"; |
|
| 3515 | 3515 | |
| 3516 | - } |
|
| 3517 | - } else { |
|
| 3516 | + } |
|
| 3517 | + } else { |
|
| 3518 | 3518 | |
| 3519 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 3520 | - $extra = ''; |
|
| 3521 | - if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 3522 | - $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 3523 | - $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 3524 | - } |
|
| 3525 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 3526 | - } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 3519 | + if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 3520 | + $extra = ''; |
|
| 3521 | + if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 3522 | + $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 3523 | + $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 3524 | + } |
|
| 3525 | + echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 3526 | + } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 3527 | 3527 | $new_args = str_replace('[%WrapStyle%]','',$new_args); |
| 3528 | 3528 | echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },"; |
| 3529 | 3529 | // echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
| 3530 | - } elseif ( $element == 'style' ) { |
|
| 3531 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 3532 | - } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 3530 | + } elseif ( $element == 'style' ) { |
|
| 3531 | + echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 3532 | + } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 3533 | 3533 | $new_args = str_replace('[%WrapClass%]','',$new_args); |
| 3534 | 3534 | echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),"; |
| 3535 | - } elseif ( $element == 'template' && $new_args ) { |
|
| 3536 | - echo $element . ": $new_args,"; |
|
| 3537 | - } else { |
|
| 3538 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 3539 | - } |
|
| 3535 | + } elseif ( $element == 'template' && $new_args ) { |
|
| 3536 | + echo $element . ": $new_args,"; |
|
| 3537 | + } else { |
|
| 3538 | + echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 3539 | + } |
|
| 3540 | 3540 | |
| 3541 | - } |
|
| 3542 | - } |
|
| 3543 | - } |
|
| 3544 | - } |
|
| 3541 | + } |
|
| 3542 | + } |
|
| 3543 | + } |
|
| 3544 | + } |
|
| 3545 | 3545 | |
| 3546 | - /** |
|
| 3547 | - * Replace block attributes placeholders with the proper naming. |
|
| 3548 | - * |
|
| 3549 | - * @param $string |
|
| 3550 | - * |
|
| 3551 | - * @return mixed |
|
| 3552 | - */ |
|
| 3553 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 3554 | - |
|
| 3555 | - if ( $no_wrap ) { |
|
| 3556 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 3557 | - } else { |
|
| 3558 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 3559 | - } |
|
| 3546 | + /** |
|
| 3547 | + * Replace block attributes placeholders with the proper naming. |
|
| 3548 | + * |
|
| 3549 | + * @param $string |
|
| 3550 | + * |
|
| 3551 | + * @return mixed |
|
| 3552 | + */ |
|
| 3553 | + public function block_props_replace( $string, $no_wrap = false ) { |
|
| 3560 | 3554 | |
| 3561 | - return $string; |
|
| 3562 | - } |
|
| 3555 | + if ( $no_wrap ) { |
|
| 3556 | + $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 3557 | + } else { |
|
| 3558 | + $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 3559 | + } |
|
| 3563 | 3560 | |
| 3564 | - /** |
|
| 3565 | - * Outputs the content of the widget |
|
| 3566 | - * |
|
| 3567 | - * @param array $args |
|
| 3568 | - * @param array $instance |
|
| 3569 | - */ |
|
| 3570 | - public function widget( $args, $instance ) { |
|
| 3571 | - |
|
| 3572 | - // get the filtered values |
|
| 3573 | - $argument_values = $this->argument_values( $instance ); |
|
| 3574 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 3575 | - $output = $this->output( $argument_values, $args ); |
|
| 3576 | - |
|
| 3577 | - $no_wrap = false; |
|
| 3578 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 3579 | - $no_wrap = true; |
|
| 3580 | - } |
|
| 3561 | + return $string; |
|
| 3562 | + } |
|
| 3581 | 3563 | |
| 3582 | - ob_start(); |
|
| 3583 | - if ( $output && ! $no_wrap ) { |
|
| 3564 | + /** |
|
| 3565 | + * Outputs the content of the widget |
|
| 3566 | + * |
|
| 3567 | + * @param array $args |
|
| 3568 | + * @param array $instance |
|
| 3569 | + */ |
|
| 3570 | + public function widget( $args, $instance ) { |
|
| 3584 | 3571 | |
| 3585 | - $class_original = $this->options['widget_ops']['classname']; |
|
| 3586 | - $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 3572 | + // get the filtered values |
|
| 3573 | + $argument_values = $this->argument_values( $instance ); |
|
| 3574 | + $argument_values = $this->string_to_bool( $argument_values ); |
|
| 3575 | + $output = $this->output( $argument_values, $args ); |
|
| 3587 | 3576 | |
| 3588 | - // Before widget |
|
| 3589 | - $before_widget = $args['before_widget']; |
|
| 3590 | - $before_widget = str_replace($class_original,$class,$before_widget); |
|
| 3591 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 3592 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 3577 | + $no_wrap = false; |
|
| 3578 | + if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 3579 | + $no_wrap = true; |
|
| 3580 | + } |
|
| 3593 | 3581 | |
| 3594 | - // After widget |
|
| 3595 | - $after_widget = $args['after_widget']; |
|
| 3596 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 3597 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 3582 | + ob_start(); |
|
| 3583 | + if ( $output && ! $no_wrap ) { |
|
| 3598 | 3584 | |
| 3599 | - echo $before_widget; |
|
| 3600 | - // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 3601 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3602 | - // Filter class & attrs for elementor widget output. |
|
| 3603 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 3604 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 3585 | + $class_original = $this->options['widget_ops']['classname']; |
|
| 3586 | + $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 3605 | 3587 | |
| 3606 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 3607 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 3588 | + // Before widget |
|
| 3589 | + $before_widget = $args['before_widget']; |
|
| 3590 | + $before_widget = str_replace($class_original,$class,$before_widget); |
|
| 3591 | + $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 3592 | + $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 3608 | 3593 | |
| 3609 | - echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 3610 | - } |
|
| 3611 | - echo $this->output_title( $args, $instance ); |
|
| 3612 | - echo $output; |
|
| 3613 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3614 | - echo "</span>"; |
|
| 3615 | - } |
|
| 3616 | - echo $after_widget; |
|
| 3617 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 3618 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 3619 | - echo $output; |
|
| 3620 | - } elseif ( $output && $no_wrap ) { |
|
| 3621 | - echo $output; |
|
| 3622 | - } |
|
| 3623 | - $output = ob_get_clean(); |
|
| 3594 | + // After widget |
|
| 3595 | + $after_widget = $args['after_widget']; |
|
| 3596 | + $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 3597 | + $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 3624 | 3598 | |
| 3625 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 3599 | + echo $before_widget; |
|
| 3600 | + // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 3601 | + if ( $this->is_elementor_widget_output() ) { |
|
| 3602 | + // Filter class & attrs for elementor widget output. |
|
| 3603 | + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 3604 | + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 3626 | 3605 | |
| 3627 | - echo $output; |
|
| 3628 | - } |
|
| 3606 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 3607 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 3629 | 3608 | |
| 3630 | - /** |
|
| 3631 | - * Tests if the current output is inside a elementor container. |
|
| 3632 | - * |
|
| 3633 | - * @return bool |
|
| 3634 | - *@since 1.0.4 |
|
| 3635 | - */ |
|
| 3636 | - public function is_elementor_widget_output() { |
|
| 3637 | - $result = false; |
|
| 3638 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 3639 | - $result = true; |
|
| 3640 | - } |
|
| 3609 | + echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 3610 | + } |
|
| 3611 | + echo $this->output_title( $args, $instance ); |
|
| 3612 | + echo $output; |
|
| 3613 | + if ( $this->is_elementor_widget_output() ) { |
|
| 3614 | + echo "</span>"; |
|
| 3615 | + } |
|
| 3616 | + echo $after_widget; |
|
| 3617 | + } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 3618 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 3619 | + echo $output; |
|
| 3620 | + } elseif ( $output && $no_wrap ) { |
|
| 3621 | + echo $output; |
|
| 3622 | + } |
|
| 3623 | + $output = ob_get_clean(); |
|
| 3641 | 3624 | |
| 3642 | - return $result; |
|
| 3643 | - } |
|
| 3625 | + $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 3644 | 3626 | |
| 3645 | - /** |
|
| 3646 | - * Tests if the current output is inside a elementor preview. |
|
| 3647 | - * |
|
| 3648 | - * @return bool |
|
| 3649 | - *@since 1.0.4 |
|
| 3650 | - */ |
|
| 3651 | - public function is_elementor_preview() { |
|
| 3652 | - $result = false; |
|
| 3653 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 3654 | - $result = true; |
|
| 3655 | - } |
|
| 3627 | + echo $output; |
|
| 3628 | + } |
|
| 3656 | 3629 | |
| 3657 | - return $result; |
|
| 3658 | - } |
|
| 3630 | + /** |
|
| 3631 | + * Tests if the current output is inside a elementor container. |
|
| 3632 | + * |
|
| 3633 | + * @return bool |
|
| 3634 | + *@since 1.0.4 |
|
| 3635 | + */ |
|
| 3636 | + public function is_elementor_widget_output() { |
|
| 3637 | + $result = false; |
|
| 3638 | + if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 3639 | + $result = true; |
|
| 3640 | + } |
|
| 3659 | 3641 | |
| 3660 | - /** |
|
| 3661 | - * Tests if the current output is inside a Divi preview. |
|
| 3662 | - * |
|
| 3663 | - * @return bool |
|
| 3664 | - *@since 1.0.6 |
|
| 3665 | - */ |
|
| 3666 | - public function is_divi_preview() { |
|
| 3667 | - $result = false; |
|
| 3668 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 3669 | - $result = true; |
|
| 3670 | - } |
|
| 3642 | + return $result; |
|
| 3643 | + } |
|
| 3671 | 3644 | |
| 3672 | - return $result; |
|
| 3673 | - } |
|
| 3645 | + /** |
|
| 3646 | + * Tests if the current output is inside a elementor preview. |
|
| 3647 | + * |
|
| 3648 | + * @return bool |
|
| 3649 | + *@since 1.0.4 |
|
| 3650 | + */ |
|
| 3651 | + public function is_elementor_preview() { |
|
| 3652 | + $result = false; |
|
| 3653 | + if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 3654 | + $result = true; |
|
| 3655 | + } |
|
| 3674 | 3656 | |
| 3675 | - /** |
|
| 3676 | - * Tests if the current output is inside a Beaver builder preview. |
|
| 3677 | - * |
|
| 3678 | - * @return bool |
|
| 3679 | - *@since 1.0.6 |
|
| 3680 | - */ |
|
| 3681 | - public function is_beaver_preview() { |
|
| 3682 | - $result = false; |
|
| 3683 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 3684 | - $result = true; |
|
| 3685 | - } |
|
| 3657 | + return $result; |
|
| 3658 | + } |
|
| 3686 | 3659 | |
| 3687 | - return $result; |
|
| 3688 | - } |
|
| 3660 | + /** |
|
| 3661 | + * Tests if the current output is inside a Divi preview. |
|
| 3662 | + * |
|
| 3663 | + * @return bool |
|
| 3664 | + *@since 1.0.6 |
|
| 3665 | + */ |
|
| 3666 | + public function is_divi_preview() { |
|
| 3667 | + $result = false; |
|
| 3668 | + if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 3669 | + $result = true; |
|
| 3670 | + } |
|
| 3689 | 3671 | |
| 3690 | - /** |
|
| 3691 | - * Tests if the current output is inside a siteorigin builder preview. |
|
| 3692 | - * |
|
| 3693 | - * @return bool |
|
| 3694 | - *@since 1.0.6 |
|
| 3695 | - */ |
|
| 3696 | - public function is_siteorigin_preview() { |
|
| 3697 | - $result = false; |
|
| 3698 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 3699 | - $result = true; |
|
| 3700 | - } |
|
| 3672 | + return $result; |
|
| 3673 | + } |
|
| 3701 | 3674 | |
| 3702 | - return $result; |
|
| 3703 | - } |
|
| 3675 | + /** |
|
| 3676 | + * Tests if the current output is inside a Beaver builder preview. |
|
| 3677 | + * |
|
| 3678 | + * @return bool |
|
| 3679 | + *@since 1.0.6 |
|
| 3680 | + */ |
|
| 3681 | + public function is_beaver_preview() { |
|
| 3682 | + $result = false; |
|
| 3683 | + if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 3684 | + $result = true; |
|
| 3685 | + } |
|
| 3704 | 3686 | |
| 3705 | - /** |
|
| 3706 | - * Tests if the current output is inside a cornerstone builder preview. |
|
| 3707 | - * |
|
| 3708 | - * @return bool |
|
| 3709 | - *@since 1.0.8 |
|
| 3710 | - */ |
|
| 3711 | - public function is_cornerstone_preview() { |
|
| 3712 | - $result = false; |
|
| 3713 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 3714 | - $result = true; |
|
| 3715 | - } |
|
| 3687 | + return $result; |
|
| 3688 | + } |
|
| 3716 | 3689 | |
| 3717 | - return $result; |
|
| 3718 | - } |
|
| 3690 | + /** |
|
| 3691 | + * Tests if the current output is inside a siteorigin builder preview. |
|
| 3692 | + * |
|
| 3693 | + * @return bool |
|
| 3694 | + *@since 1.0.6 |
|
| 3695 | + */ |
|
| 3696 | + public function is_siteorigin_preview() { |
|
| 3697 | + $result = false; |
|
| 3698 | + if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 3699 | + $result = true; |
|
| 3700 | + } |
|
| 3719 | 3701 | |
| 3720 | - /** |
|
| 3721 | - * Tests if the current output is inside a fusion builder preview. |
|
| 3722 | - * |
|
| 3723 | - * @return bool |
|
| 3724 | - *@since 1.1.0 |
|
| 3725 | - */ |
|
| 3726 | - public function is_fusion_preview() { |
|
| 3727 | - $result = false; |
|
| 3728 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 3729 | - $result = true; |
|
| 3730 | - } |
|
| 3702 | + return $result; |
|
| 3703 | + } |
|
| 3731 | 3704 | |
| 3732 | - return $result; |
|
| 3733 | - } |
|
| 3705 | + /** |
|
| 3706 | + * Tests if the current output is inside a cornerstone builder preview. |
|
| 3707 | + * |
|
| 3708 | + * @return bool |
|
| 3709 | + *@since 1.0.8 |
|
| 3710 | + */ |
|
| 3711 | + public function is_cornerstone_preview() { |
|
| 3712 | + $result = false; |
|
| 3713 | + if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 3714 | + $result = true; |
|
| 3715 | + } |
|
| 3734 | 3716 | |
| 3735 | - /** |
|
| 3736 | - * Tests if the current output is inside a Oxygen builder preview. |
|
| 3737 | - * |
|
| 3738 | - * @return bool |
|
| 3739 | - *@since 1.0.18 |
|
| 3740 | - */ |
|
| 3741 | - public function is_oxygen_preview() { |
|
| 3742 | - $result = false; |
|
| 3743 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 3744 | - $result = true; |
|
| 3745 | - } |
|
| 3717 | + return $result; |
|
| 3718 | + } |
|
| 3746 | 3719 | |
| 3747 | - return $result; |
|
| 3748 | - } |
|
| 3720 | + /** |
|
| 3721 | + * Tests if the current output is inside a fusion builder preview. |
|
| 3722 | + * |
|
| 3723 | + * @return bool |
|
| 3724 | + *@since 1.1.0 |
|
| 3725 | + */ |
|
| 3726 | + public function is_fusion_preview() { |
|
| 3727 | + $result = false; |
|
| 3728 | + if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 3729 | + $result = true; |
|
| 3730 | + } |
|
| 3749 | 3731 | |
| 3750 | - /** |
|
| 3751 | - * General function to check if we are in a preview situation. |
|
| 3752 | - * |
|
| 3753 | - * @return bool |
|
| 3754 | - *@since 1.0.6 |
|
| 3755 | - */ |
|
| 3756 | - public function is_preview() { |
|
| 3757 | - $preview = false; |
|
| 3758 | - if ( $this->is_divi_preview() ) { |
|
| 3759 | - $preview = true; |
|
| 3760 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 3761 | - $preview = true; |
|
| 3762 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 3763 | - $preview = true; |
|
| 3764 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 3765 | - $preview = true; |
|
| 3766 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 3767 | - $preview = true; |
|
| 3768 | - } elseif ( $this->is_fusion_preview() ) { |
|
| 3769 | - $preview = true; |
|
| 3770 | - } elseif ( $this->is_oxygen_preview() ) { |
|
| 3771 | - $preview = true; |
|
| 3772 | - } elseif( $this->is_block_content_call() ) { |
|
| 3773 | - $preview = true; |
|
| 3774 | - } |
|
| 3732 | + return $result; |
|
| 3733 | + } |
|
| 3775 | 3734 | |
| 3776 | - return $preview; |
|
| 3777 | - } |
|
| 3735 | + /** |
|
| 3736 | + * Tests if the current output is inside a Oxygen builder preview. |
|
| 3737 | + * |
|
| 3738 | + * @return bool |
|
| 3739 | + *@since 1.0.18 |
|
| 3740 | + */ |
|
| 3741 | + public function is_oxygen_preview() { |
|
| 3742 | + $result = false; |
|
| 3743 | + if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 3744 | + $result = true; |
|
| 3745 | + } |
|
| 3778 | 3746 | |
| 3779 | - /** |
|
| 3780 | - * Output the super title. |
|
| 3781 | - * |
|
| 3782 | - * @param $args |
|
| 3783 | - * @param array $instance |
|
| 3784 | - * |
|
| 3785 | - * @return string |
|
| 3786 | - */ |
|
| 3787 | - public function output_title( $args, $instance = array() ) { |
|
| 3788 | - $output = ''; |
|
| 3789 | - if ( ! empty( $instance['title'] ) ) { |
|
| 3790 | - /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 3791 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 3792 | - |
|
| 3793 | - if(empty($instance['widget_title_tag'])){ |
|
| 3794 | - $output = $args['before_title'] . $title . $args['after_title']; |
|
| 3795 | - }else{ |
|
| 3796 | - $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 3797 | - |
|
| 3798 | - // classes |
|
| 3799 | - $title_classes = array(); |
|
| 3800 | - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 3801 | - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 3802 | - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 3803 | - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 3804 | - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 3805 | - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 3806 | - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 3807 | - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 3808 | - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 3809 | - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 3810 | - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 3811 | - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 3812 | - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 3813 | - |
|
| 3814 | - $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 3815 | - $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
| 3816 | - } |
|
| 3747 | + return $result; |
|
| 3748 | + } |
|
| 3817 | 3749 | |
| 3818 | - } |
|
| 3750 | + /** |
|
| 3751 | + * General function to check if we are in a preview situation. |
|
| 3752 | + * |
|
| 3753 | + * @return bool |
|
| 3754 | + *@since 1.0.6 |
|
| 3755 | + */ |
|
| 3756 | + public function is_preview() { |
|
| 3757 | + $preview = false; |
|
| 3758 | + if ( $this->is_divi_preview() ) { |
|
| 3759 | + $preview = true; |
|
| 3760 | + } elseif ( $this->is_elementor_preview() ) { |
|
| 3761 | + $preview = true; |
|
| 3762 | + } elseif ( $this->is_beaver_preview() ) { |
|
| 3763 | + $preview = true; |
|
| 3764 | + } elseif ( $this->is_siteorigin_preview() ) { |
|
| 3765 | + $preview = true; |
|
| 3766 | + } elseif ( $this->is_cornerstone_preview() ) { |
|
| 3767 | + $preview = true; |
|
| 3768 | + } elseif ( $this->is_fusion_preview() ) { |
|
| 3769 | + $preview = true; |
|
| 3770 | + } elseif ( $this->is_oxygen_preview() ) { |
|
| 3771 | + $preview = true; |
|
| 3772 | + } elseif( $this->is_block_content_call() ) { |
|
| 3773 | + $preview = true; |
|
| 3774 | + } |
|
| 3819 | 3775 | |
| 3820 | - return $output; |
|
| 3821 | - } |
|
| 3776 | + return $preview; |
|
| 3777 | + } |
|
| 3778 | + |
|
| 3779 | + /** |
|
| 3780 | + * Output the super title. |
|
| 3781 | + * |
|
| 3782 | + * @param $args |
|
| 3783 | + * @param array $instance |
|
| 3784 | + * |
|
| 3785 | + * @return string |
|
| 3786 | + */ |
|
| 3787 | + public function output_title( $args, $instance = array() ) { |
|
| 3788 | + $output = ''; |
|
| 3789 | + if ( ! empty( $instance['title'] ) ) { |
|
| 3790 | + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 3791 | + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 3792 | + |
|
| 3793 | + if(empty($instance['widget_title_tag'])){ |
|
| 3794 | + $output = $args['before_title'] . $title . $args['after_title']; |
|
| 3795 | + }else{ |
|
| 3796 | + $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 3797 | + |
|
| 3798 | + // classes |
|
| 3799 | + $title_classes = array(); |
|
| 3800 | + $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 3801 | + $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 3802 | + $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 3803 | + $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 3804 | + $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 3805 | + $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 3806 | + $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 3807 | + $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 3808 | + $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 3809 | + $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 3810 | + $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 3811 | + $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 3812 | + $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 3813 | + |
|
| 3814 | + $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 3815 | + $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
| 3816 | + } |
|
| 3817 | + |
|
| 3818 | + } |
|
| 3819 | + |
|
| 3820 | + return $output; |
|
| 3821 | + } |
|
| 3822 | 3822 | |
| 3823 | - /** |
|
| 3824 | - * Outputs the options form inputs for the widget. |
|
| 3825 | - * |
|
| 3826 | - * @param array $instance The widget options. |
|
| 3827 | - */ |
|
| 3828 | - public function form( $instance ) { |
|
| 3823 | + /** |
|
| 3824 | + * Outputs the options form inputs for the widget. |
|
| 3825 | + * |
|
| 3826 | + * @param array $instance The widget options. |
|
| 3827 | + */ |
|
| 3828 | + public function form( $instance ) { |
|
| 3829 | 3829 | |
| 3830 | - // set widget instance |
|
| 3831 | - $this->instance = $instance; |
|
| 3830 | + // set widget instance |
|
| 3831 | + $this->instance = $instance; |
|
| 3832 | 3832 | |
| 3833 | - // set it as a SD widget |
|
| 3834 | - echo $this->widget_advanced_toggle(); |
|
| 3833 | + // set it as a SD widget |
|
| 3834 | + echo $this->widget_advanced_toggle(); |
|
| 3835 | 3835 | |
| 3836 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 3837 | - $arguments_raw = $this->get_arguments(); |
|
| 3836 | + echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 3837 | + $arguments_raw = $this->get_arguments(); |
|
| 3838 | 3838 | |
| 3839 | - if ( is_array( $arguments_raw ) ) { |
|
| 3839 | + if ( is_array( $arguments_raw ) ) { |
|
| 3840 | 3840 | |
| 3841 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
| 3841 | + $arguments = $this->group_arguments( $arguments_raw ); |
|
| 3842 | 3842 | |
| 3843 | - // Do we have sections? |
|
| 3844 | - $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 3843 | + // Do we have sections? |
|
| 3844 | + $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 3845 | 3845 | |
| 3846 | 3846 | |
| 3847 | - if ( $has_sections ) { |
|
| 3848 | - $panel_count = 0; |
|
| 3849 | - foreach ( $arguments as $key => $args ) { |
|
| 3847 | + if ( $has_sections ) { |
|
| 3848 | + $panel_count = 0; |
|
| 3849 | + foreach ( $arguments as $key => $args ) { |
|
| 3850 | 3850 | |
| 3851 | - ?> |
|
| 3851 | + ?> |
|
| 3852 | 3852 | <script> |
| 3853 | 3853 | // jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle(); |
| 3854 | 3854 | </script> |
| 3855 | 3855 | <?php |
| 3856 | 3856 | |
| 3857 | - $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 3858 | - $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 3859 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3860 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 3857 | + $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 3858 | + $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 3859 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3860 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 3861 | 3861 | |
| 3862 | - foreach ( $args as $k => $a ) { |
|
| 3862 | + foreach ( $args as $k => $a ) { |
|
| 3863 | 3863 | |
| 3864 | - $this->widget_inputs_row_start($k, $a); |
|
| 3865 | - $this->widget_inputs( $a, $instance ); |
|
| 3866 | - $this->widget_inputs_row_end($k, $a); |
|
| 3864 | + $this->widget_inputs_row_start($k, $a); |
|
| 3865 | + $this->widget_inputs( $a, $instance ); |
|
| 3866 | + $this->widget_inputs_row_end($k, $a); |
|
| 3867 | 3867 | |
| 3868 | - } |
|
| 3868 | + } |
|
| 3869 | 3869 | |
| 3870 | - echo "</div>"; |
|
| 3870 | + echo "</div>"; |
|
| 3871 | 3871 | |
| 3872 | - $panel_count ++; |
|
| 3872 | + $panel_count ++; |
|
| 3873 | 3873 | |
| 3874 | - } |
|
| 3875 | - } else { |
|
| 3876 | - foreach ( $arguments as $key => $args ) { |
|
| 3877 | - $this->widget_inputs_row_start($key, $args); |
|
| 3878 | - $this->widget_inputs( $args, $instance ); |
|
| 3879 | - $this->widget_inputs_row_end($key, $args); |
|
| 3880 | - } |
|
| 3881 | - } |
|
| 3874 | + } |
|
| 3875 | + } else { |
|
| 3876 | + foreach ( $arguments as $key => $args ) { |
|
| 3877 | + $this->widget_inputs_row_start($key, $args); |
|
| 3878 | + $this->widget_inputs( $args, $instance ); |
|
| 3879 | + $this->widget_inputs_row_end($key, $args); |
|
| 3880 | + } |
|
| 3881 | + } |
|
| 3882 | 3882 | |
| 3883 | - } |
|
| 3884 | - } |
|
| 3883 | + } |
|
| 3884 | + } |
|
| 3885 | 3885 | |
| 3886 | - public function widget_inputs_row_start($key, $args){ |
|
| 3887 | - if(!empty($args['row'])){ |
|
| 3888 | - // maybe open |
|
| 3889 | - if(!empty($args['row']['open'])){ |
|
| 3890 | - ?> |
|
| 3886 | + public function widget_inputs_row_start($key, $args){ |
|
| 3887 | + if(!empty($args['row'])){ |
|
| 3888 | + // maybe open |
|
| 3889 | + if(!empty($args['row']['open'])){ |
|
| 3890 | + ?> |
|
| 3891 | 3891 | <div class='bsui sd-argument ' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php if ( !empty($args['row']['element_require'])) { |
| 3892 | - echo $this->convert_element_require( $args['row']['element_require'] ); |
|
| 3893 | - } ?>'> |
|
| 3892 | + echo $this->convert_element_require( $args['row']['element_require'] ); |
|
| 3893 | + } ?>'> |
|
| 3894 | 3894 | <?php if(!empty($args['row']['title'])){ ?> |
| 3895 | 3895 | <label class="mb-0 "><?php echo esc_attr( $args['row']['title'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label> |
| 3896 | 3896 | <?php }?> |
| 3897 | 3897 | <div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'> |
| 3898 | 3898 | <div class='col pr-2'> |
| 3899 | 3899 | <?php |
| 3900 | - }elseif(!empty($args['row']['close'])){ |
|
| 3901 | - echo "<div class='col pl-0'>"; |
|
| 3902 | - }else{ |
|
| 3903 | - echo "<div class='col pl-0 pr-2'>"; |
|
| 3904 | - } |
|
| 3905 | - } |
|
| 3906 | - } |
|
| 3900 | + }elseif(!empty($args['row']['close'])){ |
|
| 3901 | + echo "<div class='col pl-0'>"; |
|
| 3902 | + }else{ |
|
| 3903 | + echo "<div class='col pl-0 pr-2'>"; |
|
| 3904 | + } |
|
| 3905 | + } |
|
| 3906 | + } |
|
| 3907 | 3907 | |
| 3908 | - public function widget_inputs_row_end($key, $args){ |
|
| 3908 | + public function widget_inputs_row_end($key, $args){ |
|
| 3909 | 3909 | |
| 3910 | - if(!empty($args['row'])){ |
|
| 3911 | - // maybe close |
|
| 3912 | - if(!empty($args['row']['close'])){ |
|
| 3913 | - echo "</div></div>"; |
|
| 3914 | - } |
|
| 3910 | + if(!empty($args['row'])){ |
|
| 3911 | + // maybe close |
|
| 3912 | + if(!empty($args['row']['close'])){ |
|
| 3913 | + echo "</div></div>"; |
|
| 3914 | + } |
|
| 3915 | 3915 | |
| 3916 | - echo "</div>"; |
|
| 3917 | - } |
|
| 3918 | - } |
|
| 3916 | + echo "</div>"; |
|
| 3917 | + } |
|
| 3918 | + } |
|
| 3919 | 3919 | |
| 3920 | - /** |
|
| 3921 | - * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 3922 | - * |
|
| 3923 | - * @return string |
|
| 3924 | - */ |
|
| 3925 | - public function widget_advanced_toggle() { |
|
| 3926 | - |
|
| 3927 | - $output = ''; |
|
| 3928 | - if ( $this->block_show_advanced() ) { |
|
| 3929 | - $val = 1; |
|
| 3930 | - } else { |
|
| 3931 | - $val = 0; |
|
| 3932 | - } |
|
| 3920 | + /** |
|
| 3921 | + * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 3922 | + * |
|
| 3923 | + * @return string |
|
| 3924 | + */ |
|
| 3925 | + public function widget_advanced_toggle() { |
|
| 3933 | 3926 | |
| 3934 | - $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 3927 | + $output = ''; |
|
| 3928 | + if ( $this->block_show_advanced() ) { |
|
| 3929 | + $val = 1; |
|
| 3930 | + } else { |
|
| 3931 | + $val = 0; |
|
| 3932 | + } |
|
| 3935 | 3933 | |
| 3936 | - return $output; |
|
| 3937 | - } |
|
| 3934 | + $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 3938 | 3935 | |
| 3939 | - /** |
|
| 3940 | - * Convert require element. |
|
| 3941 | - * |
|
| 3942 | - * @param string $input Input element. |
|
| 3943 | - * |
|
| 3944 | - * @return string $output |
|
| 3945 | - *@since 1.0.0 |
|
| 3946 | - * |
|
| 3947 | - */ |
|
| 3948 | - public function convert_element_require( $input ) { |
|
| 3949 | - |
|
| 3950 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 3951 | - |
|
| 3952 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 3953 | - "jQuery(form).find('[data-argument=\"", |
|
| 3954 | - "\"]').find('input,select,textarea').val()" |
|
| 3955 | - ), $input ) ); |
|
| 3956 | - |
|
| 3957 | - return $output; |
|
| 3958 | - } |
|
| 3936 | + return $output; |
|
| 3937 | + } |
|
| 3959 | 3938 | |
| 3960 | - /** |
|
| 3961 | - * Builds the inputs for the widget options. |
|
| 3962 | - * |
|
| 3963 | - * @param $args |
|
| 3964 | - * @param $instance |
|
| 3965 | - */ |
|
| 3966 | - public function widget_inputs( $args, $instance ) { |
|
| 3967 | - |
|
| 3968 | - $class = ""; |
|
| 3969 | - $element_require = ""; |
|
| 3970 | - $custom_attributes = ""; |
|
| 3971 | - |
|
| 3972 | - // get value |
|
| 3973 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 3974 | - $value = $instance[ $args['name'] ]; |
|
| 3975 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 3976 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 3977 | - } else { |
|
| 3978 | - $value = ''; |
|
| 3979 | - } |
|
| 3939 | + /** |
|
| 3940 | + * Convert require element. |
|
| 3941 | + * |
|
| 3942 | + * @param string $input Input element. |
|
| 3943 | + * |
|
| 3944 | + * @return string $output |
|
| 3945 | + *@since 1.0.0 |
|
| 3946 | + * |
|
| 3947 | + */ |
|
| 3948 | + public function convert_element_require( $input ) { |
|
| 3980 | 3949 | |
| 3981 | - // get placeholder |
|
| 3982 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 3983 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 3984 | - } else { |
|
| 3985 | - $placeholder = ''; |
|
| 3986 | - } |
|
| 3950 | + $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 3987 | 3951 | |
| 3988 | - // get if advanced |
|
| 3989 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 3990 | - $class .= " sd-advanced-setting "; |
|
| 3991 | - } |
|
| 3952 | + $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 3953 | + "jQuery(form).find('[data-argument=\"", |
|
| 3954 | + "\"]').find('input,select,textarea').val()" |
|
| 3955 | + ), $input ) ); |
|
| 3992 | 3956 | |
| 3993 | - // element_require |
|
| 3994 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 3995 | - $element_require = $args['element_require']; |
|
| 3996 | - } |
|
| 3957 | + return $output; |
|
| 3958 | + } |
|
| 3997 | 3959 | |
| 3998 | - // custom_attributes |
|
| 3999 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4000 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 4001 | - } |
|
| 3960 | + /** |
|
| 3961 | + * Builds the inputs for the widget options. |
|
| 3962 | + * |
|
| 3963 | + * @param $args |
|
| 3964 | + * @param $instance |
|
| 3965 | + */ |
|
| 3966 | + public function widget_inputs( $args, $instance ) { |
|
| 3967 | + |
|
| 3968 | + $class = ""; |
|
| 3969 | + $element_require = ""; |
|
| 3970 | + $custom_attributes = ""; |
|
| 3971 | + |
|
| 3972 | + // get value |
|
| 3973 | + if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 3974 | + $value = $instance[ $args['name'] ]; |
|
| 3975 | + } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 3976 | + $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 3977 | + } else { |
|
| 3978 | + $value = ''; |
|
| 3979 | + } |
|
| 3980 | + |
|
| 3981 | + // get placeholder |
|
| 3982 | + if ( ! empty( $args['placeholder'] ) ) { |
|
| 3983 | + $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 3984 | + } else { |
|
| 3985 | + $placeholder = ''; |
|
| 3986 | + } |
|
| 4002 | 3987 | |
| 3988 | + // get if advanced |
|
| 3989 | + if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 3990 | + $class .= " sd-advanced-setting "; |
|
| 3991 | + } |
|
| 4003 | 3992 | |
| 4004 | - // before wrapper |
|
| 4005 | - ?> |
|
| 3993 | + // element_require |
|
| 3994 | + if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 3995 | + $element_require = $args['element_require']; |
|
| 3996 | + } |
|
| 3997 | + |
|
| 3998 | + // custom_attributes |
|
| 3999 | + if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4000 | + $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 4001 | + } |
|
| 4002 | + |
|
| 4003 | + |
|
| 4004 | + // before wrapper |
|
| 4005 | + ?> |
|
| 4006 | 4006 | <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
| 4007 | 4007 | data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
| 4008 | 4008 | data-element_require='<?php if ( $element_require ) { |
| 4009 | - echo $this->convert_element_require( $element_require ); |
|
| 4010 | - } ?>' |
|
| 4009 | + echo $this->convert_element_require( $element_require ); |
|
| 4010 | + } ?>' |
|
| 4011 | 4011 | > |
| 4012 | 4012 | <?php |
| 4013 | 4013 | |
| 4014 | 4014 | |
| 4015 | - switch ( $args['type'] ) { |
|
| 4016 | - //array('text','password','number','email','tel','url','color') |
|
| 4017 | - case "text": |
|
| 4018 | - case "password": |
|
| 4019 | - case "number": |
|
| 4020 | - case "email": |
|
| 4021 | - case "tel": |
|
| 4022 | - case "url": |
|
| 4023 | - case "color": |
|
| 4024 | - ?> |
|
| 4015 | + switch ( $args['type'] ) { |
|
| 4016 | + //array('text','password','number','email','tel','url','color') |
|
| 4017 | + case "text": |
|
| 4018 | + case "password": |
|
| 4019 | + case "number": |
|
| 4020 | + case "email": |
|
| 4021 | + case "tel": |
|
| 4022 | + case "url": |
|
| 4023 | + case "color": |
|
| 4024 | + ?> |
|
| 4025 | 4025 | <label |
| 4026 | 4026 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4027 | 4027 | <input <?php echo $placeholder; ?> class="widefat" |
@@ -4032,47 +4032,47 @@ discard block |
||
| 4032 | 4032 | value="<?php echo esc_attr( $value ); ?>"> |
| 4033 | 4033 | <?php |
| 4034 | 4034 | |
| 4035 | - break; |
|
| 4036 | - case "select": |
|
| 4037 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4038 | - if ( $multiple ) { |
|
| 4039 | - if ( empty( $value ) ) { |
|
| 4040 | - $value = array(); |
|
| 4041 | - } |
|
| 4042 | - } |
|
| 4043 | - ?> |
|
| 4035 | + break; |
|
| 4036 | + case "select": |
|
| 4037 | + $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4038 | + if ( $multiple ) { |
|
| 4039 | + if ( empty( $value ) ) { |
|
| 4040 | + $value = array(); |
|
| 4041 | + } |
|
| 4042 | + } |
|
| 4043 | + ?> |
|
| 4044 | 4044 | <label |
| 4045 | 4045 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4046 | 4046 | <select <?php echo $placeholder; ?> class="widefat" |
| 4047 | 4047 | <?php echo $custom_attributes; ?> |
| 4048 | 4048 | id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 4049 | 4049 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
| 4050 | - if ( $multiple ) { |
|
| 4051 | - echo "[]"; |
|
| 4052 | - } ?>" |
|
| 4050 | + if ( $multiple ) { |
|
| 4051 | + echo "[]"; |
|
| 4052 | + } ?>" |
|
| 4053 | 4053 | <?php if ( $multiple ) { |
| 4054 | - echo "multiple"; |
|
| 4055 | - } //@todo not implemented yet due to gutenberg not supporting it |
|
| 4056 | - ?> |
|
| 4054 | + echo "multiple"; |
|
| 4055 | + } //@todo not implemented yet due to gutenberg not supporting it |
|
| 4056 | + ?> |
|
| 4057 | 4057 | > |
| 4058 | 4058 | <?php |
| 4059 | 4059 | |
| 4060 | - if ( ! empty( $args['options'] ) ) { |
|
| 4061 | - foreach ( $args['options'] as $val => $label ) { |
|
| 4062 | - if ( $multiple ) { |
|
| 4063 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4064 | - } else { |
|
| 4065 | - $selected = selected( $value, $val, false ); |
|
| 4066 | - } |
|
| 4067 | - echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 4068 | - } |
|
| 4069 | - } |
|
| 4070 | - ?> |
|
| 4060 | + if ( ! empty( $args['options'] ) ) { |
|
| 4061 | + foreach ( $args['options'] as $val => $label ) { |
|
| 4062 | + if ( $multiple ) { |
|
| 4063 | + $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4064 | + } else { |
|
| 4065 | + $selected = selected( $value, $val, false ); |
|
| 4066 | + } |
|
| 4067 | + echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 4068 | + } |
|
| 4069 | + } |
|
| 4070 | + ?> |
|
| 4071 | 4071 | </select> |
| 4072 | 4072 | <?php |
| 4073 | - break; |
|
| 4074 | - case "checkbox": |
|
| 4075 | - ?> |
|
| 4073 | + break; |
|
| 4074 | + case "checkbox": |
|
| 4075 | + ?> |
|
| 4076 | 4076 | <input <?php echo $placeholder; ?> |
| 4077 | 4077 | <?php checked( 1, $value, true ) ?> |
| 4078 | 4078 | <?php echo $custom_attributes; ?> |
@@ -4082,9 +4082,9 @@ discard block |
||
| 4082 | 4082 | <label |
| 4083 | 4083 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4084 | 4084 | <?php |
| 4085 | - break; |
|
| 4086 | - case "textarea": |
|
| 4087 | - ?> |
|
| 4085 | + break; |
|
| 4086 | + case "textarea": |
|
| 4087 | + ?> |
|
| 4088 | 4088 | <label |
| 4089 | 4089 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4090 | 4090 | <textarea <?php echo $placeholder; ?> class="widefat" |
@@ -4094,282 +4094,282 @@ discard block |
||
| 4094 | 4094 | ><?php echo esc_attr( $value ); ?></textarea> |
| 4095 | 4095 | <?php |
| 4096 | 4096 | |
| 4097 | - break; |
|
| 4098 | - case "hidden": |
|
| 4099 | - ?> |
|
| 4097 | + break; |
|
| 4098 | + case "hidden": |
|
| 4099 | + ?> |
|
| 4100 | 4100 | <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 4101 | 4101 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
| 4102 | 4102 | value="<?php echo esc_attr( $value ); ?>"> |
| 4103 | 4103 | <?php |
| 4104 | - break; |
|
| 4105 | - default: |
|
| 4106 | - echo "No input type found!"; // @todo we need to add more input types. |
|
| 4107 | - } |
|
| 4104 | + break; |
|
| 4105 | + default: |
|
| 4106 | + echo "No input type found!"; // @todo we need to add more input types. |
|
| 4107 | + } |
|
| 4108 | 4108 | |
| 4109 | - // after wrapper |
|
| 4110 | - ?> |
|
| 4109 | + // after wrapper |
|
| 4110 | + ?> |
|
| 4111 | 4111 | </p> |
| 4112 | 4112 | <?php |
| 4113 | 4113 | |
| 4114 | 4114 | |
| 4115 | - } |
|
| 4115 | + } |
|
| 4116 | 4116 | |
| 4117 | - public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4118 | - if($icon=='box-top'){ |
|
| 4119 | - 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>'; |
|
| 4120 | - }elseif($icon=='box-right'){ |
|
| 4121 | - 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>'; |
|
| 4122 | - }elseif($icon=='box-bottom'){ |
|
| 4123 | - 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>'; |
|
| 4124 | - }elseif($icon=='box-left'){ |
|
| 4125 | - 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>'; |
|
| 4126 | - } |
|
| 4127 | - } |
|
| 4117 | + public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4118 | + if($icon=='box-top'){ |
|
| 4119 | + 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>'; |
|
| 4120 | + }elseif($icon=='box-right'){ |
|
| 4121 | + 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>'; |
|
| 4122 | + }elseif($icon=='box-bottom'){ |
|
| 4123 | + 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>'; |
|
| 4124 | + }elseif($icon=='box-left'){ |
|
| 4125 | + 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>'; |
|
| 4126 | + } |
|
| 4127 | + } |
|
| 4128 | 4128 | |
| 4129 | - /** |
|
| 4130 | - * Get the widget input description html. |
|
| 4131 | - * |
|
| 4132 | - * @param $args |
|
| 4133 | - * |
|
| 4134 | - * @return string |
|
| 4135 | - * @todo, need to make its own tooltip script |
|
| 4136 | - */ |
|
| 4137 | - public function widget_field_desc( $args ) { |
|
| 4138 | - |
|
| 4139 | - $description = ''; |
|
| 4140 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4141 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4142 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 4143 | - } else { |
|
| 4144 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4145 | - } |
|
| 4146 | - } |
|
| 4129 | + /** |
|
| 4130 | + * Get the widget input description html. |
|
| 4131 | + * |
|
| 4132 | + * @param $args |
|
| 4133 | + * |
|
| 4134 | + * @return string |
|
| 4135 | + * @todo, need to make its own tooltip script |
|
| 4136 | + */ |
|
| 4137 | + public function widget_field_desc( $args ) { |
|
| 4138 | + |
|
| 4139 | + $description = ''; |
|
| 4140 | + if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4141 | + if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4142 | + $description = $this->desc_tip( $args['desc'] ); |
|
| 4143 | + } else { |
|
| 4144 | + $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4145 | + } |
|
| 4146 | + } |
|
| 4147 | 4147 | |
| 4148 | - return $description; |
|
| 4149 | - } |
|
| 4148 | + return $description; |
|
| 4149 | + } |
|
| 4150 | 4150 | |
| 4151 | - /** |
|
| 4152 | - * Get the widget input title html. |
|
| 4153 | - * |
|
| 4154 | - * @param $args |
|
| 4155 | - * |
|
| 4156 | - * @return string |
|
| 4157 | - */ |
|
| 4158 | - public function widget_field_title( $args ) { |
|
| 4159 | - |
|
| 4160 | - $title = ''; |
|
| 4161 | - if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4162 | - if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4163 | - $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4164 | - } else { |
|
| 4165 | - $title = esc_attr($args['title']); |
|
| 4166 | - } |
|
| 4167 | - } |
|
| 4151 | + /** |
|
| 4152 | + * Get the widget input title html. |
|
| 4153 | + * |
|
| 4154 | + * @param $args |
|
| 4155 | + * |
|
| 4156 | + * @return string |
|
| 4157 | + */ |
|
| 4158 | + public function widget_field_title( $args ) { |
|
| 4159 | + |
|
| 4160 | + $title = ''; |
|
| 4161 | + if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4162 | + if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4163 | + $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4164 | + } else { |
|
| 4165 | + $title = esc_attr($args['title']); |
|
| 4166 | + } |
|
| 4167 | + } |
|
| 4168 | 4168 | |
| 4169 | - return $title; |
|
| 4170 | - } |
|
| 4169 | + return $title; |
|
| 4170 | + } |
|
| 4171 | 4171 | |
| 4172 | - /** |
|
| 4173 | - * Get the tool tip html. |
|
| 4174 | - * |
|
| 4175 | - * @param $tip |
|
| 4176 | - * @param bool $allow_html |
|
| 4177 | - * |
|
| 4178 | - * @return string |
|
| 4179 | - */ |
|
| 4180 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 4181 | - if ( $allow_html ) { |
|
| 4182 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 4183 | - } else { |
|
| 4184 | - $tip = esc_attr( $tip ); |
|
| 4185 | - } |
|
| 4172 | + /** |
|
| 4173 | + * Get the tool tip html. |
|
| 4174 | + * |
|
| 4175 | + * @param $tip |
|
| 4176 | + * @param bool $allow_html |
|
| 4177 | + * |
|
| 4178 | + * @return string |
|
| 4179 | + */ |
|
| 4180 | + function desc_tip( $tip, $allow_html = false ) { |
|
| 4181 | + if ( $allow_html ) { |
|
| 4182 | + $tip = $this->sanitize_tooltip( $tip ); |
|
| 4183 | + } else { |
|
| 4184 | + $tip = esc_attr( $tip ); |
|
| 4185 | + } |
|
| 4186 | 4186 | |
| 4187 | - return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 4188 | - } |
|
| 4187 | + return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 4188 | + } |
|
| 4189 | 4189 | |
| 4190 | - /** |
|
| 4191 | - * Sanitize a string destined to be a tooltip. |
|
| 4192 | - * |
|
| 4193 | - * @param string $var |
|
| 4194 | - * |
|
| 4195 | - * @return string |
|
| 4196 | - */ |
|
| 4197 | - public function sanitize_tooltip( $var ) { |
|
| 4198 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4199 | - 'br' => array(), |
|
| 4200 | - 'em' => array(), |
|
| 4201 | - 'strong' => array(), |
|
| 4202 | - 'small' => array(), |
|
| 4203 | - 'span' => array(), |
|
| 4204 | - 'ul' => array(), |
|
| 4205 | - 'li' => array(), |
|
| 4206 | - 'ol' => array(), |
|
| 4207 | - 'p' => array(), |
|
| 4208 | - ) ) ); |
|
| 4209 | - } |
|
| 4190 | + /** |
|
| 4191 | + * Sanitize a string destined to be a tooltip. |
|
| 4192 | + * |
|
| 4193 | + * @param string $var |
|
| 4194 | + * |
|
| 4195 | + * @return string |
|
| 4196 | + */ |
|
| 4197 | + public function sanitize_tooltip( $var ) { |
|
| 4198 | + return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4199 | + 'br' => array(), |
|
| 4200 | + 'em' => array(), |
|
| 4201 | + 'strong' => array(), |
|
| 4202 | + 'small' => array(), |
|
| 4203 | + 'span' => array(), |
|
| 4204 | + 'ul' => array(), |
|
| 4205 | + 'li' => array(), |
|
| 4206 | + 'ol' => array(), |
|
| 4207 | + 'p' => array(), |
|
| 4208 | + ) ) ); |
|
| 4209 | + } |
|
| 4210 | 4210 | |
| 4211 | - /** |
|
| 4212 | - * Processing widget options on save |
|
| 4213 | - * |
|
| 4214 | - * @param array $new_instance The new options |
|
| 4215 | - * @param array $old_instance The previous options |
|
| 4216 | - * |
|
| 4217 | - * @return array |
|
| 4218 | - * @todo we should add some sanitation here. |
|
| 4219 | - */ |
|
| 4220 | - public function update( $new_instance, $old_instance ) { |
|
| 4221 | - |
|
| 4222 | - //save the widget |
|
| 4223 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4224 | - |
|
| 4225 | - // set widget instance |
|
| 4226 | - $this->instance = $instance; |
|
| 4227 | - |
|
| 4228 | - if ( empty( $this->arguments ) ) { |
|
| 4229 | - $this->get_arguments(); |
|
| 4230 | - } |
|
| 4211 | + /** |
|
| 4212 | + * Processing widget options on save |
|
| 4213 | + * |
|
| 4214 | + * @param array $new_instance The new options |
|
| 4215 | + * @param array $old_instance The previous options |
|
| 4216 | + * |
|
| 4217 | + * @return array |
|
| 4218 | + * @todo we should add some sanitation here. |
|
| 4219 | + */ |
|
| 4220 | + public function update( $new_instance, $old_instance ) { |
|
| 4231 | 4221 | |
| 4232 | - // check for checkboxes |
|
| 4233 | - if ( ! empty( $this->arguments ) ) { |
|
| 4234 | - foreach ( $this->arguments as $argument ) { |
|
| 4235 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4236 | - $instance[ $argument['name'] ] = '0'; |
|
| 4237 | - } |
|
| 4238 | - } |
|
| 4239 | - } |
|
| 4222 | + //save the widget |
|
| 4223 | + $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4240 | 4224 | |
| 4241 | - return $instance; |
|
| 4242 | - } |
|
| 4225 | + // set widget instance |
|
| 4226 | + $this->instance = $instance; |
|
| 4243 | 4227 | |
| 4244 | - /** |
|
| 4245 | - * Checks if the current call is a ajax call to get the block content. |
|
| 4246 | - * |
|
| 4247 | - * This can be used in your widget to return different content as the block content. |
|
| 4248 | - * |
|
| 4249 | - * @return bool |
|
| 4250 | - *@since 1.0.3 |
|
| 4251 | - */ |
|
| 4252 | - public function is_block_content_call() { |
|
| 4253 | - $result = false; |
|
| 4254 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4255 | - $result = true; |
|
| 4256 | - } |
|
| 4228 | + if ( empty( $this->arguments ) ) { |
|
| 4229 | + $this->get_arguments(); |
|
| 4230 | + } |
|
| 4257 | 4231 | |
| 4258 | - return $result; |
|
| 4259 | - } |
|
| 4232 | + // check for checkboxes |
|
| 4233 | + if ( ! empty( $this->arguments ) ) { |
|
| 4234 | + foreach ( $this->arguments as $argument ) { |
|
| 4235 | + if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4236 | + $instance[ $argument['name'] ] = '0'; |
|
| 4237 | + } |
|
| 4238 | + } |
|
| 4239 | + } |
|
| 4260 | 4240 | |
| 4261 | - /** |
|
| 4262 | - * Get an instance hash that will be unique to the type and settings. |
|
| 4263 | - * |
|
| 4264 | - * @return string |
|
| 4265 | - *@since 1.0.20 |
|
| 4266 | - */ |
|
| 4267 | - public function get_instance_hash(){ |
|
| 4268 | - $instance_string = $this->base_id.serialize($this->instance); |
|
| 4269 | - return hash('crc32b',$instance_string); |
|
| 4270 | - } |
|
| 4241 | + return $instance; |
|
| 4242 | + } |
|
| 4271 | 4243 | |
| 4272 | - /** |
|
| 4273 | - * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
| 4274 | - * |
|
| 4275 | - * @param array $rules |
|
| 4276 | - * |
|
| 4277 | - * @return string |
|
| 4278 | - *@since 1.0.20 |
|
| 4279 | - */ |
|
| 4280 | - public function get_instance_style($rules = array()){ |
|
| 4281 | - $css = ''; |
|
| 4282 | - |
|
| 4283 | - if(!empty($rules)){ |
|
| 4284 | - $rules = array_unique($rules); |
|
| 4285 | - $instance_hash = $this->get_instance_hash(); |
|
| 4286 | - $css .= "<style>"; |
|
| 4287 | - foreach($rules as $rule){ |
|
| 4288 | - $css .= ".sdel-$instance_hash $rule"; |
|
| 4289 | - } |
|
| 4290 | - $css .= "</style>"; |
|
| 4291 | - } |
|
| 4244 | + /** |
|
| 4245 | + * Checks if the current call is a ajax call to get the block content. |
|
| 4246 | + * |
|
| 4247 | + * This can be used in your widget to return different content as the block content. |
|
| 4248 | + * |
|
| 4249 | + * @return bool |
|
| 4250 | + *@since 1.0.3 |
|
| 4251 | + */ |
|
| 4252 | + public function is_block_content_call() { |
|
| 4253 | + $result = false; |
|
| 4254 | + if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4255 | + $result = true; |
|
| 4256 | + } |
|
| 4292 | 4257 | |
| 4293 | - return $css; |
|
| 4294 | - } |
|
| 4258 | + return $result; |
|
| 4259 | + } |
|
| 4260 | + |
|
| 4261 | + /** |
|
| 4262 | + * Get an instance hash that will be unique to the type and settings. |
|
| 4263 | + * |
|
| 4264 | + * @return string |
|
| 4265 | + *@since 1.0.20 |
|
| 4266 | + */ |
|
| 4267 | + public function get_instance_hash(){ |
|
| 4268 | + $instance_string = $this->base_id.serialize($this->instance); |
|
| 4269 | + return hash('crc32b',$instance_string); |
|
| 4270 | + } |
|
| 4271 | + |
|
| 4272 | + /** |
|
| 4273 | + * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
| 4274 | + * |
|
| 4275 | + * @param array $rules |
|
| 4276 | + * |
|
| 4277 | + * @return string |
|
| 4278 | + *@since 1.0.20 |
|
| 4279 | + */ |
|
| 4280 | + public function get_instance_style($rules = array()){ |
|
| 4281 | + $css = ''; |
|
| 4282 | + |
|
| 4283 | + if(!empty($rules)){ |
|
| 4284 | + $rules = array_unique($rules); |
|
| 4285 | + $instance_hash = $this->get_instance_hash(); |
|
| 4286 | + $css .= "<style>"; |
|
| 4287 | + foreach($rules as $rule){ |
|
| 4288 | + $css .= ".sdel-$instance_hash $rule"; |
|
| 4289 | + } |
|
| 4290 | + $css .= "</style>"; |
|
| 4291 | + } |
|
| 4292 | + |
|
| 4293 | + return $css; |
|
| 4294 | + } |
|
| 4295 | 4295 | |
| 4296 | - /** |
|
| 4297 | - * Encode shortcodes tags. |
|
| 4298 | - * |
|
| 4299 | - * @param string $content Content to search for shortcode tags. |
|
| 4300 | - * |
|
| 4296 | + /** |
|
| 4297 | + * Encode shortcodes tags. |
|
| 4298 | + * |
|
| 4299 | + * @param string $content Content to search for shortcode tags. |
|
| 4300 | + * |
|
| 4301 | 4301 | *@return string Content with shortcode tags removed. |
| 4302 | - *@since 1.0.28 |
|
| 4303 | - * |
|
| 4304 | - */ |
|
| 4305 | - public function encode_shortcodes( $content ) { |
|
| 4306 | - // Avoids existing encoded tags. |
|
| 4307 | - $trans = array( |
|
| 4308 | - '[' => '[', |
|
| 4309 | - ']' => ']', |
|
| 4310 | - '&#91;' => '[', |
|
| 4311 | - '&#93;' => ']', |
|
| 4312 | - '<' => '&0lt;', |
|
| 4313 | - '>' => '&0gt;', |
|
| 4314 | - '&lt;' => '&0lt;', |
|
| 4315 | - '&gt;' => '&0gt;', |
|
| 4316 | - ); |
|
| 4317 | - |
|
| 4318 | - $content = strtr( $content, $trans ); |
|
| 4319 | - |
|
| 4320 | - $trans = array( |
|
| 4321 | - '[' => '[', |
|
| 4322 | - ']' => ']', |
|
| 4323 | - '<' => '<', |
|
| 4324 | - '>' => '>', |
|
| 4325 | - '"' => '"', |
|
| 4326 | - "'" => ''', |
|
| 4327 | - ); |
|
| 4328 | - |
|
| 4329 | - $content = strtr( $content, $trans ); |
|
| 4330 | - |
|
| 4331 | - return $content; |
|
| 4332 | - } |
|
| 4302 | + *@since 1.0.28 |
|
| 4303 | + * |
|
| 4304 | + */ |
|
| 4305 | + public function encode_shortcodes( $content ) { |
|
| 4306 | + // Avoids existing encoded tags. |
|
| 4307 | + $trans = array( |
|
| 4308 | + '[' => '[', |
|
| 4309 | + ']' => ']', |
|
| 4310 | + '&#91;' => '[', |
|
| 4311 | + '&#93;' => ']', |
|
| 4312 | + '<' => '&0lt;', |
|
| 4313 | + '>' => '&0gt;', |
|
| 4314 | + '&lt;' => '&0lt;', |
|
| 4315 | + '&gt;' => '&0gt;', |
|
| 4316 | + ); |
|
| 4317 | + |
|
| 4318 | + $content = strtr( $content, $trans ); |
|
| 4319 | + |
|
| 4320 | + $trans = array( |
|
| 4321 | + '[' => '[', |
|
| 4322 | + ']' => ']', |
|
| 4323 | + '<' => '<', |
|
| 4324 | + '>' => '>', |
|
| 4325 | + '"' => '"', |
|
| 4326 | + "'" => ''', |
|
| 4327 | + ); |
|
| 4328 | + |
|
| 4329 | + $content = strtr( $content, $trans ); |
|
| 4330 | + |
|
| 4331 | + return $content; |
|
| 4332 | + } |
|
| 4333 | 4333 | |
| 4334 | - /** |
|
| 4335 | - * Remove encoded shortcod tags. |
|
| 4336 | - * |
|
| 4337 | - * @param string $content Content to search for shortcode tags. |
|
| 4338 | - * |
|
| 4334 | + /** |
|
| 4335 | + * Remove encoded shortcod tags. |
|
| 4336 | + * |
|
| 4337 | + * @param string $content Content to search for shortcode tags. |
|
| 4338 | + * |
|
| 4339 | 4339 | *@return string Content with decoded shortcode tags. |
| 4340 | - *@since 1.0.28 |
|
| 4341 | - * |
|
| 4342 | - */ |
|
| 4343 | - public function decode_shortcodes( $content ) { |
|
| 4344 | - $trans = array( |
|
| 4345 | - '[' => '[', |
|
| 4346 | - ']' => ']', |
|
| 4347 | - '&#91;' => '[', |
|
| 4348 | - '&#93;' => ']', |
|
| 4349 | - '<' => '<', |
|
| 4350 | - '>' => '>', |
|
| 4351 | - '&lt;' => '<', |
|
| 4352 | - '&gt;' => '>', |
|
| 4353 | - '"' => '"', |
|
| 4354 | - ''' => "'", |
|
| 4355 | - ); |
|
| 4356 | - |
|
| 4357 | - $content = strtr( $content, $trans ); |
|
| 4358 | - |
|
| 4359 | - $trans = array( |
|
| 4360 | - '[' => '[', |
|
| 4361 | - ']' => ']', |
|
| 4362 | - '&#091;' => '[', |
|
| 4363 | - '&#093;' => ']', |
|
| 4364 | - '&0lt;' => '<', |
|
| 4365 | - '&0gt;' => '>', |
|
| 4366 | - '&0lt;' => '<', |
|
| 4367 | - '&0gt;' => '>', |
|
| 4368 | - ); |
|
| 4369 | - |
|
| 4370 | - $content = strtr( $content, $trans ); |
|
| 4371 | - |
|
| 4372 | - return $content; |
|
| 4373 | - } |
|
| 4374 | - } |
|
| 4340 | + *@since 1.0.28 |
|
| 4341 | + * |
|
| 4342 | + */ |
|
| 4343 | + public function decode_shortcodes( $content ) { |
|
| 4344 | + $trans = array( |
|
| 4345 | + '[' => '[', |
|
| 4346 | + ']' => ']', |
|
| 4347 | + '&#91;' => '[', |
|
| 4348 | + '&#93;' => ']', |
|
| 4349 | + '<' => '<', |
|
| 4350 | + '>' => '>', |
|
| 4351 | + '&lt;' => '<', |
|
| 4352 | + '&gt;' => '>', |
|
| 4353 | + '"' => '"', |
|
| 4354 | + ''' => "'", |
|
| 4355 | + ); |
|
| 4356 | + |
|
| 4357 | + $content = strtr( $content, $trans ); |
|
| 4358 | + |
|
| 4359 | + $trans = array( |
|
| 4360 | + '[' => '[', |
|
| 4361 | + ']' => ']', |
|
| 4362 | + '&#091;' => '[', |
|
| 4363 | + '&#093;' => ']', |
|
| 4364 | + '&0lt;' => '<', |
|
| 4365 | + '&0gt;' => '>', |
|
| 4366 | + '&0lt;' => '<', |
|
| 4367 | + '&0gt;' => '>', |
|
| 4368 | + ); |
|
| 4369 | + |
|
| 4370 | + $content = strtr( $content, $trans ); |
|
| 4371 | + |
|
| 4372 | + return $content; |
|
| 4373 | + } |
|
| 4374 | + } |
|
| 4375 | 4375 | } |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | -if ( ! class_exists( 'WP_Super_Duper' ) ) { |
|
| 6 | +if (!class_exists('WP_Super_Duper')) { |
|
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | /** |
@@ -37,40 +37,40 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Take the array options and use them to build. |
| 39 | 39 | */ |
| 40 | - public function __construct( $options ) { |
|
| 40 | + public function __construct($options) { |
|
| 41 | 41 | global $sd_widgets; |
| 42 | 42 | |
| 43 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 43 | + $sd_widgets[$options['base_id']] = array( |
|
| 44 | 44 | 'name' => $options['name'], |
| 45 | 45 | 'class_name' => $options['class_name'], |
| 46 | 46 | 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
| 47 | 47 | ); |
| 48 | - $this->base_id = $options['base_id']; |
|
| 48 | + $this->base_id = $options['base_id']; |
|
| 49 | 49 | // lets filter the options before we do anything |
| 50 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 51 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 52 | - $options = $this->add_name_from_key( $options ); |
|
| 50 | + $options = apply_filters("wp_super_duper_options", $options); |
|
| 51 | + $options = apply_filters("wp_super_duper_options_{$this->base_id}", $options); |
|
| 52 | + $options = $this->add_name_from_key($options); |
|
| 53 | 53 | $this->options = $options; |
| 54 | 54 | |
| 55 | 55 | $this->base_id = $options['base_id']; |
| 56 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 56 | + $this->arguments = isset($options['arguments']) ? $options['arguments'] : array(); |
|
| 57 | 57 | |
| 58 | 58 | // nested blocks can't work as a widget |
| 59 | - if(!empty($this->options['nested-block'])){ |
|
| 60 | - if(empty($this->options['output_types'])){ |
|
| 61 | - $this->options['output_types'] = array('shortcode','block'); |
|
| 59 | + if (!empty($this->options['nested-block'])) { |
|
| 60 | + if (empty($this->options['output_types'])) { |
|
| 61 | + $this->options['output_types'] = array('shortcode', 'block'); |
|
| 62 | 62 | }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { |
| 63 | 63 | unset($this->options['output_types'][$key]); |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // init parent |
| 68 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 69 | - parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
| 68 | + if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) { |
|
| 69 | + parent::__construct($options['base_id'], $options['name'], $options['widget_ops']); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
| 73 | - if ( isset( $options['class_name'] ) ) { |
|
| 73 | + if (isset($options['class_name'])) { |
|
| 74 | 74 | // register widget |
| 75 | 75 | $this->class_name = $options['class_name']; |
| 76 | 76 | |
@@ -79,60 +79,60 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | // Fusion Builder (avada) support |
| 82 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 83 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 82 | + if (function_exists('fusion_builder_map')) { |
|
| 83 | + add_action('init', array($this, 'register_fusion_element')); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // register block |
| 87 | - if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 88 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 87 | + if (empty($this->options['output_types']) || in_array('block', $this->options['output_types'])) { |
|
| 88 | + add_action('admin_enqueue_scripts', array($this, 'register_block')); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // add the CSS and JS we need ONCE |
| 93 | 93 | global $sd_widget_scripts; |
| 94 | 94 | |
| 95 | - if ( ! $sd_widget_scripts ) { |
|
| 96 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 97 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 98 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 95 | + if (!$sd_widget_scripts) { |
|
| 96 | + wp_add_inline_script('admin-widgets', $this->widget_js()); |
|
| 97 | + wp_add_inline_script('customize-controls', $this->widget_js()); |
|
| 98 | + wp_add_inline_style('widgets', $this->widget_css()); |
|
| 99 | 99 | |
| 100 | 100 | // maybe add elementor editor styles |
| 101 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 101 | + add_action('elementor/editor/after_enqueue_styles', array($this, 'elementor_editor_styles')); |
|
| 102 | 102 | |
| 103 | 103 | $sd_widget_scripts = true; |
| 104 | 104 | |
| 105 | 105 | // add shortcode insert button once |
| 106 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 106 | + add_action('media_buttons', array($this, 'shortcode_insert_button')); |
|
| 107 | 107 | // generatepress theme sections compatibility |
| 108 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 109 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 108 | + if (function_exists('generate_sections_sections_metabox')) { |
|
| 109 | + add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script')); |
|
| 110 | 110 | } |
| 111 | 111 | /* Load script on Divi theme builder page */ |
| 112 | - if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 112 | + if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) { |
|
| 113 | 113 | add_thickbox(); |
| 114 | - add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 114 | + add_action('admin_footer', array($this, 'shortcode_insert_button_script')); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( $this->is_preview() ) { |
|
| 118 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 117 | + if ($this->is_preview()) { |
|
| 118 | + add_action('wp_footer', array($this, 'shortcode_insert_button_script')); |
|
| 119 | 119 | // this makes the insert button work for elementor |
| 120 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 120 | + add_action('elementor/editor/after_enqueue_scripts', array( |
|
| 121 | 121 | $this, |
| 122 | 122 | 'shortcode_insert_button_script' |
| 123 | - ) ); // for elementor |
|
| 123 | + )); // for elementor |
|
| 124 | 124 | } |
| 125 | 125 | // this makes the insert button work for cornerstone |
| 126 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 126 | + add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder')); |
|
| 127 | 127 | |
| 128 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 129 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 128 | + add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings')); |
|
| 129 | + add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker')); |
|
| 130 | 130 | |
| 131 | 131 | // add generator text to admin head |
| 132 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 132 | + add_action('admin_head', array($this, 'generator')); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 135 | + do_action('wp_super_duper_widget_init', $options, $this); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @return void |
| 141 | 141 | */ |
| 142 | 142 | public function _register() { |
| 143 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 143 | + if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) { |
|
| 144 | 144 | parent::_register(); |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | * Add our widget CSS to elementor editor. |
| 150 | 150 | */ |
| 151 | 151 | public function elementor_editor_styles() { |
| 152 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 152 | + wp_add_inline_style('elementor-editor', $this->widget_css(false)); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function register_fusion_element() { |
| 156 | 156 | |
| 157 | 157 | $options = $this->options; |
| 158 | 158 | |
| 159 | - if ( $this->base_id ) { |
|
| 159 | + if ($this->base_id) { |
|
| 160 | 160 | |
| 161 | 161 | $params = $this->get_fusion_params(); |
| 162 | 162 | |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | 'allow_generator' => true, |
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - if ( ! empty( $params ) ) { |
|
| 170 | + if (!empty($params)) { |
|
| 171 | 171 | $args['params'] = $params; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - fusion_builder_map( $args ); |
|
| 174 | + fusion_builder_map($args); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | } |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | $params = array(); |
| 181 | 181 | $arguments = $this->get_arguments(); |
| 182 | 182 | |
| 183 | - if ( ! empty( $arguments ) ) { |
|
| 184 | - foreach ( $arguments as $key => $val ) { |
|
| 183 | + if (!empty($arguments)) { |
|
| 184 | + foreach ($arguments as $key => $val) { |
|
| 185 | 185 | $param = array(); |
| 186 | 186 | // type |
| 187 | 187 | $param['type'] = str_replace( |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $val['type'] ); |
| 204 | 204 | |
| 205 | 205 | // multiselect |
| 206 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 206 | + if ($val['type'] == 'multiselect' || (($param['type'] == 'select' || $val['type'] == 'select') && !empty($val['multiple']))) { |
|
| 207 | 207 | $param['type'] = 'multiple_select'; |
| 208 | 208 | $param['multiple'] = true; |
| 209 | 209 | } |
@@ -212,29 +212,29 @@ discard block |
||
| 212 | 212 | $param['heading'] = $val['title']; |
| 213 | 213 | |
| 214 | 214 | // description |
| 215 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 215 | + $param['description'] = isset($val['desc']) ? $val['desc'] : ''; |
|
| 216 | 216 | |
| 217 | 217 | // param_name |
| 218 | 218 | $param['param_name'] = $key; |
| 219 | 219 | |
| 220 | 220 | // Default |
| 221 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 221 | + $param['default'] = isset($val['default']) ? $val['default'] : ''; |
|
| 222 | 222 | |
| 223 | 223 | // Group |
| 224 | - if ( isset( $val['group'] ) ) { |
|
| 224 | + if (isset($val['group'])) { |
|
| 225 | 225 | $param['group'] = $val['group']; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // value |
| 229 | - if ( $val['type'] == 'checkbox' ) { |
|
| 230 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 231 | - unset( $param['default'] ); |
|
| 229 | + if ($val['type'] == 'checkbox') { |
|
| 230 | + if (isset($val['default']) && $val['default'] == '0') { |
|
| 231 | + unset($param['default']); |
|
| 232 | 232 | } |
| 233 | - $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 234 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 235 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 233 | + $param['value'] = array('' => __("No"), '1' => __("Yes")); |
|
| 234 | + } elseif ($param['type'] == 'select' || $param['type'] == 'multiple_select') { |
|
| 235 | + $param['value'] = isset($val['options']) ? $val['options'] : array(); |
|
| 236 | 236 | } else { |
| 237 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 237 | + $param['value'] = isset($val['default']) ? $val['default'] : ''; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // setup the param |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
| 252 | 252 | */ |
| 253 | 253 | public static function maybe_cornerstone_builder() { |
| 254 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 254 | + if (did_action('cornerstone_before_boot_app')) { |
|
| 255 | 255 | self::shortcode_insert_button_script(); |
| 256 | 256 | } |
| 257 | 257 | } |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return string |
| 265 | 265 | */ |
| 266 | - public static function get_picker( $editor_id = '' ) { |
|
| 266 | + public static function get_picker($editor_id = '') { |
|
| 267 | 267 | |
| 268 | 268 | ob_start(); |
| 269 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 270 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 271 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 269 | + if (isset($_POST['editor_id'])) { |
|
| 270 | + $editor_id = esc_attr($_POST['editor_id']); |
|
| 271 | + } elseif (isset($_REQUEST['et_fb'])) { |
|
| 272 | 272 | $editor_id = 'main_content_content_vb_tiny_mce'; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -279,14 +279,14 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | <div class="sd-shortcode-left-wrap"> |
| 281 | 281 | <?php |
| 282 | - ksort( $sd_widgets ); |
|
| 282 | + ksort($sd_widgets); |
|
| 283 | 283 | // print_r($sd_widgets);exit; |
| 284 | - if ( ! empty( $sd_widgets ) ) { |
|
| 284 | + if (!empty($sd_widgets)) { |
|
| 285 | 285 | echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
| 286 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 287 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 288 | - if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 289 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 286 | + echo "<option>" . __('Select shortcode') . "</option>"; |
|
| 287 | + foreach ($sd_widgets as $shortcode => $class) { |
|
| 288 | + if (!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])) { continue; } |
|
| 289 | + echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>"; |
|
| 290 | 290 | } |
| 291 | 291 | echo "</select>"; |
| 292 | 292 | |
@@ -299,37 +299,37 @@ discard block |
||
| 299 | 299 | <div class="sd-shortcode-right-wrap"> |
| 300 | 300 | <textarea id='sd-shortcode-output' disabled></textarea> |
| 301 | 301 | <div id='sd-shortcode-output-actions'> |
| 302 | - <?php if ( $editor_id != '' ) { ?> |
|
| 302 | + <?php if ($editor_id != '') { ?> |
|
| 303 | 303 | <button class="button sd-insert-shortcode-button" |
| 304 | - onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
|
| 304 | + onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) { |
|
| 305 | 305 | echo "'" . $editor_id . "'"; |
| 306 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 306 | + } ?>)"><?php _e('Insert shortcode'); ?></button> |
|
| 307 | 307 | <?php } ?> |
| 308 | 308 | <button class="button" |
| 309 | - onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
|
| 309 | + onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button> |
|
| 310 | 310 | </div> |
| 311 | 311 | </div> |
| 312 | 312 | <?php |
| 313 | 313 | |
| 314 | 314 | $html = ob_get_clean(); |
| 315 | 315 | |
| 316 | - if ( wp_doing_ajax() ) { |
|
| 316 | + if (wp_doing_ajax()) { |
|
| 317 | 317 | echo $html; |
| 318 | 318 | $should_die = true; |
| 319 | 319 | |
| 320 | 320 | // some builder get the editor via ajax so we should not die on those occasions |
| 321 | 321 | $dont_die = array( |
| 322 | - 'parent_tag',// WP Bakery |
|
| 322 | + 'parent_tag', // WP Bakery |
|
| 323 | 323 | 'avia_request' // enfold |
| 324 | 324 | ); |
| 325 | 325 | |
| 326 | - foreach ( $dont_die as $request ) { |
|
| 327 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 326 | + foreach ($dont_die as $request) { |
|
| 327 | + if (isset($_REQUEST[$request])) { |
|
| 328 | 328 | $should_die = false; |
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if ( $should_die ) { |
|
| 332 | + if ($should_die) { |
|
| 333 | 333 | wp_die(); |
| 334 | 334 | } |
| 335 | 335 | |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | public static function get_widget_settings() { |
| 357 | 357 | global $sd_widgets; |
| 358 | 358 | |
| 359 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 360 | - if ( ! $shortcode ) { |
|
| 359 | + $shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : ''; |
|
| 360 | + if (!$shortcode) { |
|
| 361 | 361 | wp_die(); |
| 362 | 362 | } |
| 363 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 364 | - if ( ! $widget_args ) { |
|
| 363 | + $widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : ''; |
|
| 364 | + if (!$widget_args) { |
|
| 365 | 365 | wp_die(); |
| 366 | 366 | } |
| 367 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 368 | - if ( ! $class_name ) { |
|
| 367 | + $class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 368 | + if (!$class_name) { |
|
| 369 | 369 | wp_die(); |
| 370 | 370 | } |
| 371 | 371 | |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | $widget = new $class_name; |
| 374 | 374 | |
| 375 | 375 | ob_start(); |
| 376 | - $widget->form( array() ); |
|
| 376 | + $widget->form(array()); |
|
| 377 | 377 | $form = ob_get_clean(); |
| 378 | 378 | echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
| 379 | 379 | echo "<style>" . $widget->widget_css() . "</style>"; |
@@ -392,9 +392,9 @@ discard block |
||
| 392 | 392 | *@since 1.0.0 |
| 393 | 393 | * |
| 394 | 394 | */ |
| 395 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 395 | + public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') { |
|
| 396 | 396 | global $sd_widgets, $shortcode_insert_button_once; |
| 397 | - if ( $shortcode_insert_button_once ) { |
|
| 397 | + if ($shortcode_insert_button_once) { |
|
| 398 | 398 | return; |
| 399 | 399 | } |
| 400 | 400 | add_thickbox(); |
@@ -404,21 +404,21 @@ discard block |
||
| 404 | 404 | * Cornerstone makes us play dirty tricks :/ |
| 405 | 405 | * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
| 406 | 406 | */ |
| 407 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 407 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 408 | 408 | echo '<span id="insert-media-button">'; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 411 | + echo self::shortcode_button('this', 'true'); |
|
| 412 | 412 | |
| 413 | 413 | // see opening note |
| 414 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 414 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 415 | 415 | echo '</span>'; // end #insert-media-button |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // Add separate script for generatepress theme sections |
| 419 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 419 | + if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) { |
|
| 420 | 420 | } else { |
| 421 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 421 | + self::shortcode_insert_button_script($editor_id, $insert_shortcode_function); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | $shortcode_insert_button_once = true; |
@@ -432,12 +432,12 @@ discard block |
||
| 432 | 432 | * |
| 433 | 433 | * @return mixed |
| 434 | 434 | */ |
| 435 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 435 | + public static function shortcode_button($id = '', $search_for_id = '') { |
|
| 436 | 436 | ob_start(); |
| 437 | 437 | ?> |
| 438 | 438 | <span class="sd-lable-shortcode-inserter"> |
| 439 | 439 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 440 | - if ( $search_for_id ) { |
|
| 440 | + if ($search_for_id) { |
|
| 441 | 441 | echo "," . $search_for_id; |
| 442 | 442 | } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
| 443 | 443 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | $html = ob_get_clean(); |
| 454 | 454 | |
| 455 | 455 | // remove line breaks so we can use it in js |
| 456 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 456 | + return preg_replace("/\r|\n/", "", trim($html)); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | jQuery($this).data('sd-widget-enabled', true); |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
| 514 | + var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
| 515 | 515 | var form = jQuery($this).parents('' + $selector + ''); |
| 516 | 516 | |
| 517 | 517 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -546,10 +546,10 @@ discard block |
||
| 546 | 546 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 547 | 547 | */ |
| 548 | 548 | |
| 549 | - return str_replace( array( |
|
| 549 | + return str_replace(array( |
|
| 550 | 550 | '<script>', |
| 551 | 551 | '</script>' |
| 552 | - ), '', $output ); |
|
| 552 | + ), '', $output); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | /** |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | *@since 1.0.6 |
| 562 | 562 | * |
| 563 | 563 | */ |
| 564 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 564 | + public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') { |
|
| 565 | 565 | ?> |
| 566 | 566 | <style> |
| 567 | 567 | .sd-shortcode-left-wrap { |
@@ -680,25 +680,25 @@ discard block |
||
| 680 | 680 | width: 100%; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - <?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?> |
|
| 683 | + <?php if (function_exists('generate_sections_sections_metabox')) { ?> |
|
| 684 | 684 | .generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter { |
| 685 | 685 | display: inline; |
| 686 | 686 | } |
| 687 | 687 | <?php } ?> |
| 688 | - <?php if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { ?> |
|
| 688 | + <?php if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) { ?> |
|
| 689 | 689 | body.divi_page_et_theme_builder div#TB_window.gd-tb-window{z-index:9999999} |
| 690 | 690 | <?php } ?> |
| 691 | 691 | </style> |
| 692 | 692 | <?php |
| 693 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 693 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 694 | 694 | echo "<script>" . self::siteorigin_js() . "</script>"; |
| 695 | 695 | } |
| 696 | 696 | ?> |
| 697 | 697 | <script> |
| 698 | 698 | <?php |
| 699 | - if(! empty( $insert_shortcode_function )){ |
|
| 699 | + if (!empty($insert_shortcode_function)) { |
|
| 700 | 700 | echo $insert_shortcode_function; |
| 701 | - }else{ |
|
| 701 | + } else { |
|
| 702 | 702 | |
| 703 | 703 | /** |
| 704 | 704 | * Function for super duper insert shortcode. |
@@ -711,9 +711,9 @@ discard block |
||
| 711 | 711 | if ($shortcode) { |
| 712 | 712 | if (!$editor_id) { |
| 713 | 713 | <?php |
| 714 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 714 | + if (isset($_REQUEST['et_fb'])) { |
|
| 715 | 715 | echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
| 716 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 716 | + } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') { |
|
| 717 | 717 | echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
| 718 | 718 | } else { |
| 719 | 719 | echo '$editor_id = "#wp-content-editor-container textarea";'; |
@@ -798,11 +798,11 @@ discard block |
||
| 798 | 798 | 'shortcode': $short_code, |
| 799 | 799 | 'attributes': 123, |
| 800 | 800 | 'post_id': 321, |
| 801 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 801 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 802 | 802 | }; |
| 803 | 803 | |
| 804 | 804 | if (typeof ajaxurl === 'undefined') { |
| 805 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>"; |
|
| 805 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | jQuery.post(ajaxurl, data, function (response) { |
@@ -1011,11 +1011,11 @@ discard block |
||
| 1011 | 1011 | var data = { |
| 1012 | 1012 | 'action': 'super_duper_get_picker', |
| 1013 | 1013 | 'editor_id': $id, |
| 1014 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>' |
|
| 1014 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>' |
|
| 1015 | 1015 | }; |
| 1016 | 1016 | |
| 1017 | 1017 | if (!ajaxurl) { |
| 1018 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>"; |
|
| 1018 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | jQuery.post(ajaxurl, data, function (response) { |
@@ -1037,9 +1037,9 @@ discard block |
||
| 1037 | 1037 | */ |
| 1038 | 1038 | function sd_shortcode_button($id) { |
| 1039 | 1039 | if ($id) { |
| 1040 | - return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>'; |
|
| 1040 | + return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>'; |
|
| 1041 | 1041 | } else { |
| 1042 | - return '<?php echo self::shortcode_button();?>'; |
|
| 1042 | + return '<?php echo self::shortcode_button(); ?>'; |
|
| 1043 | 1043 | } |
| 1044 | 1044 | } |
| 1045 | 1045 | |
@@ -1054,11 +1054,11 @@ discard block |
||
| 1054 | 1054 | * |
| 1055 | 1055 | * @return mixed |
| 1056 | 1056 | */ |
| 1057 | - public function widget_css( $advanced = true ) { |
|
| 1057 | + public function widget_css($advanced = true) { |
|
| 1058 | 1058 | ob_start(); |
| 1059 | 1059 | ?> |
| 1060 | 1060 | <style> |
| 1061 | - <?php if( $advanced ){ ?> |
|
| 1061 | + <?php if ($advanced) { ?> |
|
| 1062 | 1062 | .sd-advanced-setting { |
| 1063 | 1063 | display: none; |
| 1064 | 1064 | } |
@@ -1100,10 +1100,10 @@ discard block |
||
| 1100 | 1100 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1101 | 1101 | */ |
| 1102 | 1102 | |
| 1103 | - return str_replace( array( |
|
| 1103 | + return str_replace(array( |
|
| 1104 | 1104 | '<style>', |
| 1105 | 1105 | '</style>' |
| 1106 | - ), '', $output ); |
|
| 1106 | + ), '', $output); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | /** |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | jQuery($this).data('sd-widget-enabled', true); |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | - var $button = '<button title="<?php _e( 'Advanced Settings' );?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
| 1173 | + var $button = '<button title="<?php _e('Advanced Settings'); ?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
| 1174 | 1174 | var form = jQuery($this).parents('' + $selector + ''); |
| 1175 | 1175 | |
| 1176 | 1176 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -1265,7 +1265,7 @@ discard block |
||
| 1265 | 1265 | }); |
| 1266 | 1266 | |
| 1267 | 1267 | } |
| 1268 | - <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
|
| 1268 | + <?php do_action('wp_super_duper_widget_js', $this); ?> |
|
| 1269 | 1269 | </script> |
| 1270 | 1270 | <?php |
| 1271 | 1271 | $output = ob_get_clean(); |
@@ -1274,10 +1274,10 @@ discard block |
||
| 1274 | 1274 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1275 | 1275 | */ |
| 1276 | 1276 | |
| 1277 | - return str_replace( array( |
|
| 1277 | + return str_replace(array( |
|
| 1278 | 1278 | '<script>', |
| 1279 | 1279 | '</script>' |
| 1280 | - ), '', $output ); |
|
| 1280 | + ), '', $output); |
|
| 1281 | 1281 | } |
| 1282 | 1282 | |
| 1283 | 1283 | |
@@ -1288,14 +1288,14 @@ discard block |
||
| 1288 | 1288 | * |
| 1289 | 1289 | * @return mixed |
| 1290 | 1290 | */ |
| 1291 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1292 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1293 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1294 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1291 | + private function add_name_from_key($options, $arguments = false) { |
|
| 1292 | + if (!empty($options['arguments'])) { |
|
| 1293 | + foreach ($options['arguments'] as $key => $val) { |
|
| 1294 | + $options['arguments'][$key]['name'] = $key; |
|
| 1295 | 1295 | } |
| 1296 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1297 | - foreach ( $options as $key => $val ) { |
|
| 1298 | - $options[ $key ]['name'] = $key; |
|
| 1296 | + } elseif ($arguments && is_array($options) && !empty($options)) { |
|
| 1297 | + foreach ($options as $key => $val) { |
|
| 1298 | + $options[$key]['name'] = $key; |
|
| 1299 | 1299 | } |
| 1300 | 1300 | } |
| 1301 | 1301 | |
@@ -1308,8 +1308,8 @@ discard block |
||
| 1308 | 1308 | * @since 1.0.0 |
| 1309 | 1309 | */ |
| 1310 | 1310 | public function register_shortcode() { |
| 1311 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1312 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1311 | + add_shortcode($this->base_id, array($this, 'shortcode_output')); |
|
| 1312 | + add_action('wp_ajax_super_duper_output_shortcode', array($this, 'render_shortcode')); |
|
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | /** |
@@ -1318,50 +1318,50 @@ discard block |
||
| 1318 | 1318 | * @since 1.0.0 |
| 1319 | 1319 | */ |
| 1320 | 1320 | public function render_shortcode() { |
| 1321 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1322 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1321 | + check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true); |
|
| 1322 | + if (!current_user_can('manage_options')) { |
|
| 1323 | 1323 | wp_die(); |
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | // we might need the $post value here so lets set it. |
| 1327 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1328 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1329 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1327 | + if (isset($_POST['post_id']) && $_POST['post_id']) { |
|
| 1328 | + $post_obj = get_post(absint($_POST['post_id'])); |
|
| 1329 | + if (!empty($post_obj) && empty($post)) { |
|
| 1330 | 1330 | global $post; |
| 1331 | 1331 | $post = $post_obj; |
| 1332 | 1332 | } |
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1335 | + if (isset($_POST['shortcode']) && $_POST['shortcode']) { |
|
| 1336 | 1336 | $is_preview = $this->is_preview(); |
| 1337 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1338 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1337 | + $shortcode_name = sanitize_title_with_dashes($_POST['shortcode']); |
|
| 1338 | + $attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1339 | 1339 | $attributes = ''; |
| 1340 | - if ( ! empty( $attributes_array ) ) { |
|
| 1341 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1342 | - if ( is_array( $value ) ) { |
|
| 1343 | - $value = implode( ",", $value ); |
|
| 1340 | + if (!empty($attributes_array)) { |
|
| 1341 | + foreach ($attributes_array as $key => $value) { |
|
| 1342 | + if (is_array($value)) { |
|
| 1343 | + $value = implode(",", $value); |
|
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | - if ( ! empty( $value ) ) { |
|
| 1347 | - $value = wp_unslash( $value ); |
|
| 1346 | + if (!empty($value)) { |
|
| 1347 | + $value = wp_unslash($value); |
|
| 1348 | 1348 | |
| 1349 | 1349 | // Encode [ and ]. |
| 1350 | - if ( $is_preview ) { |
|
| 1351 | - $value = $this->encode_shortcodes( $value ); |
|
| 1350 | + if ($is_preview) { |
|
| 1351 | + $value = $this->encode_shortcodes($value); |
|
| 1352 | 1352 | } |
| 1353 | 1353 | } |
| 1354 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1354 | + $attributes .= " " . sanitize_title_with_dashes($key) . "='" . esc_attr($value) . "' "; |
|
| 1355 | 1355 | } |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
| 1359 | 1359 | |
| 1360 | - $content = do_shortcode( $shortcode ); |
|
| 1360 | + $content = do_shortcode($shortcode); |
|
| 1361 | 1361 | |
| 1362 | 1362 | // Decode [ and ]. |
| 1363 | - if ( ! empty( $content ) && $is_preview ) { |
|
| 1364 | - $content = $this->decode_shortcodes( $content ); |
|
| 1363 | + if (!empty($content) && $is_preview) { |
|
| 1364 | + $content = $this->decode_shortcodes($content); |
|
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | 1367 | echo $content; |
@@ -1377,21 +1377,21 @@ discard block |
||
| 1377 | 1377 | * |
| 1378 | 1378 | * @return string |
| 1379 | 1379 | */ |
| 1380 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1380 | + public function shortcode_output($args = array(), $content = '') { |
|
| 1381 | 1381 | $_instance = $args; |
| 1382 | 1382 | |
| 1383 | - $args = $this->argument_values( $args ); |
|
| 1383 | + $args = $this->argument_values($args); |
|
| 1384 | 1384 | |
| 1385 | 1385 | // add extra argument so we know its a output to gutenberg |
| 1386 | 1386 | //$args |
| 1387 | - $args = $this->string_to_bool( $args ); |
|
| 1387 | + $args = $this->string_to_bool($args); |
|
| 1388 | 1388 | |
| 1389 | 1389 | // if we have a enclosed shortcode we add it to the special `html` argument |
| 1390 | - if ( ! empty( $content ) ) { |
|
| 1390 | + if (!empty($content)) { |
|
| 1391 | 1391 | $args['html'] = $content; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | - if ( ! $this->is_preview() ) { |
|
| 1394 | + if (!$this->is_preview()) { |
|
| 1395 | 1395 | /** |
| 1396 | 1396 | * Filters the settings for a particular widget args. |
| 1397 | 1397 | * |
@@ -1402,40 +1402,40 @@ discard block |
||
| 1402 | 1402 | *@since 1.0.28 |
| 1403 | 1403 | * |
| 1404 | 1404 | */ |
| 1405 | - $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1405 | + $args = apply_filters('wp_super_duper_widget_display_callback', $args, $this, $_instance); |
|
| 1406 | 1406 | |
| 1407 | - if ( ! is_array( $args ) ) { |
|
| 1407 | + if (!is_array($args)) { |
|
| 1408 | 1408 | return $args; |
| 1409 | 1409 | } |
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1413 | - $class .= " sdel-".$this->get_instance_hash(); |
|
| 1412 | + $class = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : ''; |
|
| 1413 | + $class .= " sdel-" . $this->get_instance_hash(); |
|
| 1414 | 1414 | |
| 1415 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1416 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1415 | + $class = apply_filters('wp_super_duper_div_classname', $class, $args, $this); |
|
| 1416 | + $class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this); |
|
| 1417 | 1417 | |
| 1418 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1419 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1418 | + $attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this); |
|
| 1419 | + $attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); |
|
| 1420 | 1420 | |
| 1421 | 1421 | $shortcode_args = array(); |
| 1422 | 1422 | $output = ''; |
| 1423 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1424 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1423 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
| 1424 | + if (isset($args['no_wrap']) && $args['no_wrap']) { |
|
| 1425 | 1425 | $no_wrap = true; |
| 1426 | 1426 | } |
| 1427 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1428 | - if ( $main_content && ! $no_wrap ) { |
|
| 1427 | + $main_content = $this->output($args, $shortcode_args, $content); |
|
| 1428 | + if ($main_content && !$no_wrap) { |
|
| 1429 | 1429 | // wrap the shortcode in a div with the same class as the widget |
| 1430 | 1430 | $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
| 1431 | - if ( ! empty( $args['title'] ) ) { |
|
| 1431 | + if (!empty($args['title'])) { |
|
| 1432 | 1432 | // if its a shortcode and there is a title try to grab the title wrappers |
| 1433 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1434 | - if ( empty( $instance ) ) { |
|
| 1433 | + $shortcode_args = array('before_title' => '', 'after_title' => ''); |
|
| 1434 | + if (empty($instance)) { |
|
| 1435 | 1435 | global $wp_registered_sidebars; |
| 1436 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1437 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1438 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1436 | + if (!empty($wp_registered_sidebars)) { |
|
| 1437 | + foreach ($wp_registered_sidebars as $sidebar) { |
|
| 1438 | + if (!empty($sidebar['before_title'])) { |
|
| 1439 | 1439 | $shortcode_args['before_title'] = $sidebar['before_title']; |
| 1440 | 1440 | $shortcode_args['after_title'] = $sidebar['after_title']; |
| 1441 | 1441 | break; |
@@ -1443,20 +1443,20 @@ discard block |
||
| 1443 | 1443 | } |
| 1444 | 1444 | } |
| 1445 | 1445 | } |
| 1446 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1446 | + $output .= $this->output_title($shortcode_args, $args); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | $output .= $main_content; |
| 1449 | 1449 | $output .= '</div>'; |
| 1450 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1450 | + } elseif ($main_content && $no_wrap) { |
|
| 1451 | 1451 | $output .= $main_content; |
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | 1454 | // if preview show a placeholder if empty |
| 1455 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1456 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1455 | + if ($this->is_preview() && $output == '') { |
|
| 1456 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
| 1457 | 1457 | } |
| 1458 | 1458 | |
| 1459 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1459 | + return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this); |
|
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | /** |
@@ -1466,8 +1466,8 @@ discard block |
||
| 1466 | 1466 | * |
| 1467 | 1467 | * @return string |
| 1468 | 1468 | */ |
| 1469 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1470 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1469 | + public function preview_placeholder_text($name = '') { |
|
| 1470 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>"; |
|
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | /** |
@@ -1477,13 +1477,13 @@ discard block |
||
| 1477 | 1477 | * |
| 1478 | 1478 | * @return mixed |
| 1479 | 1479 | */ |
| 1480 | - public function string_to_bool( $options ) { |
|
| 1480 | + public function string_to_bool($options) { |
|
| 1481 | 1481 | // convert bool strings to booleans |
| 1482 | - foreach ( $options as $key => $val ) { |
|
| 1483 | - if ( $val == 'false' ) { |
|
| 1484 | - $options[ $key ] = false; |
|
| 1485 | - } elseif ( $val == 'true' ) { |
|
| 1486 | - $options[ $key ] = true; |
|
| 1482 | + foreach ($options as $key => $val) { |
|
| 1483 | + if ($val == 'false') { |
|
| 1484 | + $options[$key] = false; |
|
| 1485 | + } elseif ($val == 'true') { |
|
| 1486 | + $options[$key] = true; |
|
| 1487 | 1487 | } |
| 1488 | 1488 | } |
| 1489 | 1489 | |
@@ -1499,26 +1499,26 @@ discard block |
||
| 1499 | 1499 | *@since 1.0.12 Don't set checkbox default value if the value is empty. |
| 1500 | 1500 | * |
| 1501 | 1501 | */ |
| 1502 | - public function argument_values( $instance ) { |
|
| 1502 | + public function argument_values($instance) { |
|
| 1503 | 1503 | $argument_values = array(); |
| 1504 | 1504 | |
| 1505 | 1505 | // set widget instance |
| 1506 | 1506 | $this->instance = $instance; |
| 1507 | 1507 | |
| 1508 | - if ( empty( $this->arguments ) ) { |
|
| 1508 | + if (empty($this->arguments)) { |
|
| 1509 | 1509 | $this->arguments = $this->get_arguments(); |
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | - if ( ! empty( $this->arguments ) ) { |
|
| 1513 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1512 | + if (!empty($this->arguments)) { |
|
| 1513 | + foreach ($this->arguments as $key => $args) { |
|
| 1514 | 1514 | // set the input name from the key |
| 1515 | 1515 | $args['name'] = $key; |
| 1516 | 1516 | // |
| 1517 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1518 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1517 | + $argument_values[$key] = isset($instance[$key]) ? $instance[$key] : ''; |
|
| 1518 | + if ($args['type'] == 'checkbox' && $argument_values[$key] == '') { |
|
| 1519 | 1519 | // don't set default for an empty checkbox |
| 1520 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1521 | - $argument_values[ $key ] = $args['default']; |
|
| 1520 | + } elseif ($argument_values[$key] == '' && isset($args['default'])) { |
|
| 1521 | + $argument_values[$key] = $args['default']; |
|
| 1522 | 1522 | } |
| 1523 | 1523 | } |
| 1524 | 1524 | } |
@@ -1545,12 +1545,12 @@ discard block |
||
| 1545 | 1545 | * |
| 1546 | 1546 | */ |
| 1547 | 1547 | public function get_arguments() { |
| 1548 | - if ( empty( $this->arguments ) ) { |
|
| 1548 | + if (empty($this->arguments)) { |
|
| 1549 | 1549 | $this->arguments = $this->set_arguments(); |
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1553 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1552 | + $this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance); |
|
| 1553 | + $this->arguments = $this->add_name_from_key($this->arguments, true); |
|
| 1554 | 1554 | |
| 1555 | 1555 | return $this->arguments; |
| 1556 | 1556 | } |
@@ -1562,7 +1562,7 @@ discard block |
||
| 1562 | 1562 | * @param array $widget_args |
| 1563 | 1563 | * @param string $content |
| 1564 | 1564 | */ |
| 1565 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1565 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 1566 | 1566 | |
| 1567 | 1567 | } |
| 1568 | 1568 | |
@@ -1570,9 +1570,9 @@ discard block |
||
| 1570 | 1570 | * Add the dynamic block code inline when the wp-block in enqueued. |
| 1571 | 1571 | */ |
| 1572 | 1572 | public function register_block() { |
| 1573 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1574 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1575 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1573 | + wp_add_inline_script('wp-blocks', $this->block()); |
|
| 1574 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 1575 | + wp_add_inline_script('wp-blocks', $this->siteorigin_js()); |
|
| 1576 | 1576 | } |
| 1577 | 1577 | } |
| 1578 | 1578 | |
@@ -1586,9 +1586,9 @@ discard block |
||
| 1586 | 1586 | $show = false; |
| 1587 | 1587 | $arguments = $this->get_arguments(); |
| 1588 | 1588 | |
| 1589 | - if ( ! empty( $arguments ) ) { |
|
| 1590 | - foreach ( $arguments as $argument ) { |
|
| 1591 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1589 | + if (!empty($arguments)) { |
|
| 1590 | + foreach ($arguments as $argument) { |
|
| 1591 | + if (isset($argument['advanced']) && $argument['advanced']) { |
|
| 1592 | 1592 | $show = true; |
| 1593 | 1593 | break; // no need to continue if we know we have it |
| 1594 | 1594 | } |
@@ -1606,19 +1606,19 @@ discard block |
||
| 1606 | 1606 | public function get_url() { |
| 1607 | 1607 | $url = $this->url; |
| 1608 | 1608 | |
| 1609 | - if ( ! $url ) { |
|
| 1610 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1611 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1609 | + if (!$url) { |
|
| 1610 | + $content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR)); |
|
| 1611 | + $content_url = untrailingslashit(WP_CONTENT_URL); |
|
| 1612 | 1612 | |
| 1613 | 1613 | // Replace http:// to https://. |
| 1614 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1615 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1614 | + if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) { |
|
| 1615 | + $content_url = str_replace('http://', 'https://', $content_url); |
|
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | 1618 | // Check if we are inside a plugin |
| 1619 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1620 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1621 | - $url = trailingslashit( $url ); |
|
| 1619 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
| 1620 | + $url = str_replace($content_dir, $content_url, $file_dir); |
|
| 1621 | + $url = trailingslashit($url); |
|
| 1622 | 1622 | $this->url = $url; |
| 1623 | 1623 | } |
| 1624 | 1624 | |
@@ -1634,15 +1634,15 @@ discard block |
||
| 1634 | 1634 | |
| 1635 | 1635 | $url = $this->url; |
| 1636 | 1636 | |
| 1637 | - if ( ! $url ) { |
|
| 1637 | + if (!$url) { |
|
| 1638 | 1638 | // check if we are inside a plugin |
| 1639 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1639 | + $file_dir = str_replace("/includes", "", dirname(__FILE__)); |
|
| 1640 | 1640 | |
| 1641 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1642 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1641 | + $dir_parts = explode("/wp-content/", $file_dir); |
|
| 1642 | + $url_parts = explode("/wp-content/", plugins_url()); |
|
| 1643 | 1643 | |
| 1644 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1645 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1644 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
| 1645 | + $url = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]); |
|
| 1646 | 1646 | $this->url = $url; |
| 1647 | 1647 | } |
| 1648 | 1648 | } |
@@ -1663,46 +1663,46 @@ discard block |
||
| 1663 | 1663 | * @return string |
| 1664 | 1664 | *@since 1.1.0 |
| 1665 | 1665 | */ |
| 1666 | - public function get_block_icon( $icon ) { |
|
| 1666 | + public function get_block_icon($icon) { |
|
| 1667 | 1667 | |
| 1668 | 1668 | // check if we have a Font Awesome icon |
| 1669 | 1669 | $fa_type = ''; |
| 1670 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1670 | + if (substr($icon, 0, 7) === "fas fa-") { |
|
| 1671 | 1671 | $fa_type = 'solid'; |
| 1672 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1672 | + } elseif (substr($icon, 0, 7) === "far fa-") { |
|
| 1673 | 1673 | $fa_type = 'regular'; |
| 1674 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1674 | + } elseif (substr($icon, 0, 7) === "fab fa-") { |
|
| 1675 | 1675 | $fa_type = 'brands'; |
| 1676 | 1676 | } else { |
| 1677 | 1677 | $icon = "'" . $icon . "'"; |
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | 1680 | // set the icon if we found one |
| 1681 | - if ( $fa_type ) { |
|
| 1682 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1681 | + if ($fa_type) { |
|
| 1682 | + $fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon); |
|
| 1683 | 1683 | $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | return $icon; |
| 1687 | 1687 | } |
| 1688 | 1688 | |
| 1689 | - public function group_arguments( $arguments ) { |
|
| 1689 | + public function group_arguments($arguments) { |
|
| 1690 | 1690 | // echo '###';print_r($arguments); |
| 1691 | - if ( ! empty( $arguments ) ) { |
|
| 1691 | + if (!empty($arguments)) { |
|
| 1692 | 1692 | $temp_arguments = array(); |
| 1693 | - $general = __( "General" ); |
|
| 1693 | + $general = __("General"); |
|
| 1694 | 1694 | $add_sections = false; |
| 1695 | - foreach ( $arguments as $key => $args ) { |
|
| 1696 | - if ( isset( $args['group'] ) ) { |
|
| 1697 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1695 | + foreach ($arguments as $key => $args) { |
|
| 1696 | + if (isset($args['group'])) { |
|
| 1697 | + $temp_arguments[$args['group']][$key] = $args; |
|
| 1698 | 1698 | $add_sections = true; |
| 1699 | 1699 | } else { |
| 1700 | - $temp_arguments[ $general ][ $key ] = $args; |
|
| 1700 | + $temp_arguments[$general][$key] = $args; |
|
| 1701 | 1701 | } |
| 1702 | 1702 | } |
| 1703 | 1703 | |
| 1704 | 1704 | // only add sections if more than one |
| 1705 | - if ( $add_sections ) { |
|
| 1705 | + if ($add_sections) { |
|
| 1706 | 1706 | $arguments = $temp_arguments; |
| 1707 | 1707 | } |
| 1708 | 1708 | } |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | <script> |
| 1733 | 1733 | |
| 1734 | 1734 | <?php |
| 1735 | - if(!$sd_is_js_functions_loaded){ |
|
| 1735 | + if (!$sd_is_js_functions_loaded) { |
|
| 1736 | 1736 | $sd_is_js_functions_loaded = true; |
| 1737 | 1737 | ?> |
| 1738 | 1738 | |
@@ -2033,7 +2033,7 @@ discard block |
||
| 2033 | 2033 | } |
| 2034 | 2034 | |
| 2035 | 2035 | function sd_get_class_build_keys(){ |
| 2036 | - return <?php echo json_encode(sd_get_class_build_keys());?>; |
|
| 2036 | + return <?php echo json_encode(sd_get_class_build_keys()); ?>; |
|
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | 2039 | <?php |
@@ -2041,7 +2041,7 @@ discard block |
||
| 2041 | 2041 | |
| 2042 | 2042 | } |
| 2043 | 2043 | |
| 2044 | - if(method_exists($this,'block_global_js')){ |
|
| 2044 | + if (method_exists($this, 'block_global_js')) { |
|
| 2045 | 2045 | echo $this->block_global_js(); |
| 2046 | 2046 | } |
| 2047 | 2047 | ?> |
@@ -2070,9 +2070,9 @@ discard block |
||
| 2070 | 2070 | var InnerBlocks = blockEditor.InnerBlocks; |
| 2071 | 2071 | |
| 2072 | 2072 | var term_query_type = ''; |
| 2073 | - 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 "[]";} ?>; |
|
| 2074 | - const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
|
| 2075 | - const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
|
| 2073 | + 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 "[]"; } ?>; |
|
| 2074 | + const taxonomies_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}]; |
|
| 2075 | + const sort_by_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}]; |
|
| 2076 | 2076 | const MediaUpload = wp.blockEditor.MediaUpload; |
| 2077 | 2077 | |
| 2078 | 2078 | /** |
@@ -2087,20 +2087,20 @@ discard block |
||
| 2087 | 2087 | * @return {?WPBlock} The block, if it has been successfully |
| 2088 | 2088 | * registered; otherwise `undefined`. |
| 2089 | 2089 | */ |
| 2090 | - registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) ); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
|
| 2090 | + registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
|
| 2091 | 2091 | apiVersion: 2, |
| 2092 | - title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title. |
|
| 2093 | - description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title. |
|
| 2094 | - icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
|
| 2092 | + title: '<?php echo addslashes($this->options['name']); ?>', // Block title. |
|
| 2093 | + description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title. |
|
| 2094 | + icon: <?php echo $this->get_block_icon($this->options['block-icon']); ?>,//'<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
|
| 2095 | 2095 | supports: { |
| 2096 | 2096 | <?php |
| 2097 | - if ( isset( $this->options['block-supports'] ) ) { |
|
| 2098 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2097 | + if (isset($this->options['block-supports'])) { |
|
| 2098 | + echo $this->array_to_attributes($this->options['block-supports']); |
|
| 2099 | 2099 | } |
| 2100 | 2100 | ?> |
| 2101 | 2101 | }, |
| 2102 | 2102 | <?php |
| 2103 | - if ( isset( $this->options['block-label'] ) ) { |
|
| 2103 | + if (isset($this->options['block-label'])) { |
|
| 2104 | 2104 | ?> |
| 2105 | 2105 | __experimentalLabel( attributes, { context } ) { |
| 2106 | 2106 | return <?php echo $this->options['block-label']; ?>; |
@@ -2108,8 +2108,8 @@ discard block |
||
| 2108 | 2108 | <?php |
| 2109 | 2109 | } |
| 2110 | 2110 | ?> |
| 2111 | - category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
|
| 2112 | - <?php if ( isset( $this->options['block-keywords'] ) ) { |
|
| 2111 | + category: '<?php echo isset($this->options['block-category']) ? esc_attr($this->options['block-category']) : 'common'; ?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
|
| 2112 | + <?php if (isset($this->options['block-keywords'])) { |
|
| 2113 | 2113 | echo "keywords : " . $this->options['block-keywords'] . ","; |
| 2114 | 2114 | |
| 2115 | 2115 | // // block hover preview. |
@@ -2136,11 +2136,11 @@ discard block |
||
| 2136 | 2136 | } |
| 2137 | 2137 | |
| 2138 | 2138 | // maybe set no_wrap |
| 2139 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2140 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2139 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
| 2140 | + if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) { |
|
| 2141 | 2141 | $no_wrap = true; |
| 2142 | 2142 | } |
| 2143 | - if ( $no_wrap ) { |
|
| 2143 | + if ($no_wrap) { |
|
| 2144 | 2144 | $this->options['block-wrap'] = ''; |
| 2145 | 2145 | } |
| 2146 | 2146 | |
@@ -2154,10 +2154,10 @@ discard block |
||
| 2154 | 2154 | echo " html: false"; |
| 2155 | 2155 | echo "},";*/ |
| 2156 | 2156 | |
| 2157 | - if ( ! empty( $this->arguments ) ) { |
|
| 2157 | + if (!empty($this->arguments)) { |
|
| 2158 | 2158 | echo "attributes : {"; |
| 2159 | 2159 | |
| 2160 | - if ( $show_advanced ) { |
|
| 2160 | + if ($show_advanced) { |
|
| 2161 | 2161 | echo "show_advanced: {"; |
| 2162 | 2162 | echo " type: 'boolean',"; |
| 2163 | 2163 | echo " default: false,"; |
@@ -2165,53 +2165,53 @@ discard block |
||
| 2165 | 2165 | } |
| 2166 | 2166 | |
| 2167 | 2167 | // block wrap element |
| 2168 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2168 | + if (!empty($this->options['block-wrap'])) { //@todo we should validate this? |
|
| 2169 | 2169 | echo "block_wrap: {"; |
| 2170 | 2170 | echo " type: 'string',"; |
| 2171 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2171 | + echo " default: '" . esc_attr($this->options['block-wrap']) . "',"; |
|
| 2172 | 2172 | echo "},"; |
| 2173 | 2173 | } |
| 2174 | 2174 | |
| 2175 | 2175 | |
| 2176 | 2176 | |
| 2177 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2177 | + foreach ($this->arguments as $key => $args) { |
|
| 2178 | 2178 | |
| 2179 | - if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2179 | + if ($args['type'] == 'image' || $args['type'] == 'images') { |
|
| 2180 | 2180 | $img_drag_drop = true; |
| 2181 | 2181 | } |
| 2182 | 2182 | |
| 2183 | 2183 | // set if we should show alignment |
| 2184 | - if ( $key == 'alignment' ) { |
|
| 2184 | + if ($key == 'alignment') { |
|
| 2185 | 2185 | $show_alignment = true; |
| 2186 | 2186 | } |
| 2187 | 2187 | |
| 2188 | 2188 | $extra = ''; |
| 2189 | 2189 | |
| 2190 | - if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2190 | + if ($args['type'] == 'notice' || $args['type'] == 'tab') { |
|
| 2191 | 2191 | continue; |
| 2192 | 2192 | } |
| 2193 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2193 | + elseif ($args['type'] == 'checkbox') { |
|
| 2194 | 2194 | $type = 'boolean'; |
| 2195 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2196 | - } elseif ( $args['type'] == 'number' ) { |
|
| 2195 | + $default = isset($args['default']) && $args['default'] ? 'true' : 'false'; |
|
| 2196 | + } elseif ($args['type'] == 'number') { |
|
| 2197 | 2197 | $type = 'number'; |
| 2198 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2199 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2198 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2199 | + } elseif ($args['type'] == 'select' && !empty($args['multiple'])) { |
|
| 2200 | 2200 | $type = 'array'; |
| 2201 | - if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2202 | - $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2201 | + if (isset($args['default']) && is_array($args['default'])) { |
|
| 2202 | + $default = !empty($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]"; |
|
| 2203 | 2203 | } else { |
| 2204 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2204 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2205 | 2205 | } |
| 2206 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2206 | + } elseif ($args['type'] == 'multiselect') { |
|
| 2207 | 2207 | $type = 'array'; |
| 2208 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2209 | - } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2208 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2209 | + } elseif ($args['type'] == 'image_xy') { |
|
| 2210 | 2210 | $type = 'object'; |
| 2211 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2212 | - } elseif ( $args['type'] == 'image' ) { |
|
| 2211 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2212 | + } elseif ($args['type'] == 'image') { |
|
| 2213 | 2213 | $type = 'string'; |
| 2214 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2214 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2215 | 2215 | |
| 2216 | 2216 | // add a field for ID |
| 2217 | 2217 | // echo $key . "_id : {"; |
@@ -2223,7 +2223,7 @@ discard block |
||
| 2223 | 2223 | |
| 2224 | 2224 | } else { |
| 2225 | 2225 | $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
| 2226 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2226 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2227 | 2227 | |
| 2228 | 2228 | } |
| 2229 | 2229 | echo $key . " : {"; |
@@ -2247,7 +2247,7 @@ discard block |
||
| 2247 | 2247 | |
| 2248 | 2248 | <?php |
| 2249 | 2249 | // only include the drag/drop functions if required. |
| 2250 | -if( $img_drag_drop ){ |
|
| 2250 | +if ($img_drag_drop) { |
|
| 2251 | 2251 | |
| 2252 | 2252 | ?> |
| 2253 | 2253 | |
@@ -2313,9 +2313,9 @@ discard block |
||
| 2313 | 2313 | } |
| 2314 | 2314 | |
| 2315 | 2315 | <?php |
| 2316 | - if(!empty($this->options['block-edit-raw'])) { |
|
| 2316 | + if (!empty($this->options['block-edit-raw'])) { |
|
| 2317 | 2317 | echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues |
| 2318 | - }else{ |
|
| 2318 | + } else { |
|
| 2319 | 2319 | ?> |
| 2320 | 2320 | |
| 2321 | 2321 | function hasSelectedInnerBlock(props) { |
@@ -2340,7 +2340,7 @@ discard block |
||
| 2340 | 2340 | var $value = ''; |
| 2341 | 2341 | <?php |
| 2342 | 2342 | // if we have a post_type and a category then link them |
| 2343 | - if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2343 | + if (isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked'])) { |
|
| 2344 | 2344 | ?> |
| 2345 | 2345 | if(typeof(prev_attributes[props.clientId]) != 'undefined' ){ |
| 2346 | 2346 | $pt = props.attributes.post_type; |
@@ -2356,13 +2356,13 @@ discard block |
||
| 2356 | 2356 | |
| 2357 | 2357 | // taxonomies |
| 2358 | 2358 | if( $value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run ){ |
| 2359 | - wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];}else{'/wp/v2/"+$value+"/categories/?per_page=100';} ?>"}).then(terms => { |
|
| 2360 | - while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) { |
|
| 2361 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop(); |
|
| 2359 | + wp.apiFetch({path: "<?php if (isset($this->arguments['post_type']['onchange_rest']['path'])) {echo $this->arguments['post_type']['onchange_rest']['path']; } else {'/wp/v2/"+$value+"/categories/?per_page=100'; } ?>"}).then(terms => { |
|
| 2360 | + while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) { |
|
| 2361 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop(); |
|
| 2362 | 2362 | } |
| 2363 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0}); |
|
| 2363 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0}); |
|
| 2364 | 2364 | jQuery.each( terms, function( key, val ) { |
| 2365 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id}); |
|
| 2365 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id}); |
|
| 2366 | 2366 | }); |
| 2367 | 2367 | |
| 2368 | 2368 | // setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. |
@@ -2370,7 +2370,7 @@ discard block |
||
| 2370 | 2370 | props.setAttributes({category: [0] }); |
| 2371 | 2371 | props.setAttributes({category: $old_cat_value }); |
| 2372 | 2372 | |
| 2373 | - return taxonomies_<?php echo str_replace("-","_", $this->id);?>; |
|
| 2373 | + return taxonomies_<?php echo str_replace("-", "_", $this->id); ?>; |
|
| 2374 | 2374 | }); |
| 2375 | 2375 | } |
| 2376 | 2376 | |
@@ -2382,12 +2382,12 @@ discard block |
||
| 2382 | 2382 | }; |
| 2383 | 2383 | jQuery.post(ajaxurl, data, function(response) { |
| 2384 | 2384 | response = JSON.parse(response); |
| 2385 | - while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) { |
|
| 2386 | - sort_by_<?php echo str_replace("-","_", $this->id);?>.pop(); |
|
| 2385 | + while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) { |
|
| 2386 | + sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop(); |
|
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | 2389 | jQuery.each( response, function( key, val ) { |
| 2390 | - sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key}); |
|
| 2390 | + sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key}); |
|
| 2391 | 2391 | }); |
| 2392 | 2392 | |
| 2393 | 2393 | // setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. |
@@ -2395,7 +2395,7 @@ discard block |
||
| 2395 | 2395 | props.setAttributes({sort_by: [0] }); |
| 2396 | 2396 | props.setAttributes({sort_by: $old_sort_by_value }); |
| 2397 | 2397 | |
| 2398 | - return sort_by_<?php echo str_replace("-","_", $this->id);?>; |
|
| 2398 | + return sort_by_<?php echo str_replace("-", "_", $this->id); ?>; |
|
| 2399 | 2399 | }); |
| 2400 | 2400 | |
| 2401 | 2401 | } |
@@ -2428,13 +2428,13 @@ discard block |
||
| 2428 | 2428 | |
| 2429 | 2429 | var data = { |
| 2430 | 2430 | 'action': 'super_duper_output_shortcode', |
| 2431 | - 'shortcode': '<?php echo $this->options['base_id'];?>', |
|
| 2431 | + 'shortcode': '<?php echo $this->options['base_id']; ?>', |
|
| 2432 | 2432 | 'attributes': props.attributes, |
| 2433 | 2433 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
| 2434 | - 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
|
| 2434 | + 'post_id': <?php global $post; if (isset($post->ID)) { |
|
| 2435 | 2435 | echo $post->ID; |
| 2436 | - }else{echo '0';}?>, |
|
| 2437 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 2436 | + } else {echo '0'; }?>, |
|
| 2437 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 2438 | 2438 | }; |
| 2439 | 2439 | |
| 2440 | 2440 | jQuery.post(ajaxurl, data, function (response) { |
@@ -2443,17 +2443,17 @@ discard block |
||
| 2443 | 2443 | |
| 2444 | 2444 | // if the content is empty then we place some placeholder text |
| 2445 | 2445 | if (env == '') { |
| 2446 | - env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>"; |
|
| 2446 | + env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>"; |
|
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | 2449 | <?php |
| 2450 | - if(!empty($this->options['nested-block'])){ |
|
| 2450 | + if (!empty($this->options['nested-block'])) { |
|
| 2451 | 2451 | ?> |
| 2452 | 2452 | // props.setAttributes({content: env}); |
| 2453 | 2453 | is_fetching = false; |
| 2454 | 2454 | prev_attributes[props.clientId] = props.attributes; |
| 2455 | 2455 | <?php |
| 2456 | - }else{ |
|
| 2456 | + } else { |
|
| 2457 | 2457 | ?> |
| 2458 | 2458 | props.setAttributes({content: env}); |
| 2459 | 2459 | is_fetching = false; |
@@ -2478,8 +2478,8 @@ discard block |
||
| 2478 | 2478 | } |
| 2479 | 2479 | |
| 2480 | 2480 | <?php |
| 2481 | - if(!empty($this->options['block-edit-js'])) { |
|
| 2482 | - echo $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues |
|
| 2481 | + if (!empty($this->options['block-edit-js'])) { |
|
| 2482 | + echo $this->options['block-edit-js']; // strings have to be in single quotes, may cause issues |
|
| 2483 | 2483 | } |
| 2484 | 2484 | |
| 2485 | 2485 | |
@@ -2492,7 +2492,7 @@ discard block |
||
| 2492 | 2492 | |
| 2493 | 2493 | el(wp.blockEditor.BlockControls, {key: 'controls'}, |
| 2494 | 2494 | |
| 2495 | - <?php if($show_alignment){?> |
|
| 2495 | + <?php if ($show_alignment) {?> |
|
| 2496 | 2496 | el( |
| 2497 | 2497 | wp.blockEditor.AlignmentToolbar, |
| 2498 | 2498 | { |
@@ -2510,9 +2510,9 @@ discard block |
||
| 2510 | 2510 | |
| 2511 | 2511 | <?php |
| 2512 | 2512 | |
| 2513 | - if(! empty( $this->arguments )){ |
|
| 2513 | + if (!empty($this->arguments)) { |
|
| 2514 | 2514 | |
| 2515 | - if ( $show_advanced ) { |
|
| 2515 | + if ($show_advanced) { |
|
| 2516 | 2516 | ?> |
| 2517 | 2517 | el('div', { |
| 2518 | 2518 | style: {'padding-left': '16px','padding-right': '16px'} |
@@ -2537,46 +2537,46 @@ discard block |
||
| 2537 | 2537 | |
| 2538 | 2538 | //echo '####'; |
| 2539 | 2539 | |
| 2540 | - $arguments = $this->group_arguments( $this->arguments ); |
|
| 2540 | + $arguments = $this->group_arguments($this->arguments); |
|
| 2541 | 2541 | //print_r($arguments ); exit; |
| 2542 | 2542 | // Do we have sections? |
| 2543 | 2543 | $has_sections = $arguments == $this->arguments ? false : true; |
| 2544 | 2544 | |
| 2545 | 2545 | |
| 2546 | - if($has_sections){ |
|
| 2546 | + if ($has_sections) { |
|
| 2547 | 2547 | $panel_count = 0; |
| 2548 | 2548 | $open_tab = ''; |
| 2549 | 2549 | |
| 2550 | 2550 | $open_tab_groups = array(); |
| 2551 | 2551 | $used_tabs = array(); |
| 2552 | - foreach($arguments as $key => $args){ |
|
| 2552 | + foreach ($arguments as $key => $args) { |
|
| 2553 | 2553 | |
| 2554 | 2554 | $close_tab = false; |
| 2555 | 2555 | $close_tabs = false; |
| 2556 | 2556 | |
| 2557 | - if(!empty($this->options['block_group_tabs'])) { |
|
| 2558 | - foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){ |
|
| 2559 | - if(in_array($key,$tab_args['groups'])){ |
|
| 2557 | + if (!empty($this->options['block_group_tabs'])) { |
|
| 2558 | + foreach ($this->options['block_group_tabs'] as $tab_name => $tab_args) { |
|
| 2559 | + if (in_array($key, $tab_args['groups'])) { |
|
| 2560 | 2560 | |
| 2561 | 2561 | $open_tab_groups[] = $key; |
| 2562 | 2562 | |
| 2563 | - if($open_tab != $tab_name){ |
|
| 2563 | + if ($open_tab != $tab_name) { |
|
| 2564 | 2564 | $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
| 2565 | 2565 | $tab_args['tab']['open'] = true; |
| 2566 | 2566 | |
| 2567 | - $this->block_tab_start( '', $tab_args ); |
|
| 2567 | + $this->block_tab_start('', $tab_args); |
|
| 2568 | 2568 | // echo '###open'.$tab_name;print_r($tab_args); |
| 2569 | 2569 | $open_tab = $tab_name; |
| 2570 | 2570 | $used_tabs[] = $tab_name; |
| 2571 | 2571 | } |
| 2572 | 2572 | |
| 2573 | - if($open_tab_groups == $tab_args['groups']){ |
|
| 2573 | + if ($open_tab_groups == $tab_args['groups']) { |
|
| 2574 | 2574 | //$open_tab = ''; |
| 2575 | 2575 | $close_tab = true; |
| 2576 | 2576 | $open_tab_groups = array(); |
| 2577 | 2577 | |
| 2578 | 2578 | // print_r(array_keys($this->options['block_group_tabs']));echo '####';print_r($used_tabs); |
| 2579 | - if($used_tabs == array_keys($this->options['block_group_tabs'])){ |
|
| 2579 | + if ($used_tabs == array_keys($this->options['block_group_tabs'])) { |
|
| 2580 | 2580 | // echo '@@@'; |
| 2581 | 2581 | $close_tabs = true; |
| 2582 | 2582 | } |
@@ -2592,8 +2592,8 @@ discard block |
||
| 2592 | 2592 | |
| 2593 | 2593 | ?> |
| 2594 | 2594 | el(wp.components.PanelBody, { |
| 2595 | - title: '<?php esc_attr_e( $key ); ?>', |
|
| 2596 | - initialOpen: <?php if ( $panel_count ) { |
|
| 2595 | + title: '<?php esc_attr_e($key); ?>', |
|
| 2596 | + initialOpen: <?php if ($panel_count) { |
|
| 2597 | 2597 | echo "false"; |
| 2598 | 2598 | } else { |
| 2599 | 2599 | echo "true"; |
@@ -2603,21 +2603,21 @@ discard block |
||
| 2603 | 2603 | |
| 2604 | 2604 | |
| 2605 | 2605 | |
| 2606 | - foreach ( $args as $k => $a ) { |
|
| 2606 | + foreach ($args as $k => $a) { |
|
| 2607 | 2607 | |
| 2608 | - $this->block_tab_start( $k, $a ); |
|
| 2609 | - $this->block_row_start( $k, $a ); |
|
| 2610 | - $this->build_block_arguments( $k, $a ); |
|
| 2611 | - $this->block_row_end( $k, $a ); |
|
| 2612 | - $this->block_tab_end( $k, $a ); |
|
| 2608 | + $this->block_tab_start($k, $a); |
|
| 2609 | + $this->block_row_start($k, $a); |
|
| 2610 | + $this->build_block_arguments($k, $a); |
|
| 2611 | + $this->block_row_end($k, $a); |
|
| 2612 | + $this->block_tab_end($k, $a); |
|
| 2613 | 2613 | } |
| 2614 | 2614 | ?> |
| 2615 | 2615 | ), |
| 2616 | 2616 | <?php |
| 2617 | - $panel_count ++; |
|
| 2617 | + $panel_count++; |
|
| 2618 | 2618 | |
| 2619 | 2619 | |
| 2620 | - if($close_tab || $close_tabs){ |
|
| 2620 | + if ($close_tab || $close_tabs) { |
|
| 2621 | 2621 | $tab_args = array( |
| 2622 | 2622 | 'tab' => array( |
| 2623 | 2623 | 'tabs_close' => $close_tabs, |
@@ -2625,24 +2625,24 @@ discard block |
||
| 2625 | 2625 | ) |
| 2626 | 2626 | |
| 2627 | 2627 | ); |
| 2628 | - $this->block_tab_end( '', $tab_args ); |
|
| 2628 | + $this->block_tab_end('', $tab_args); |
|
| 2629 | 2629 | // echo '###close'; print_r($tab_args); |
| 2630 | 2630 | $panel_count = 0; |
| 2631 | 2631 | } |
| 2632 | 2632 | // |
| 2633 | 2633 | |
| 2634 | 2634 | } |
| 2635 | - }else { |
|
| 2635 | + } else { |
|
| 2636 | 2636 | ?> |
| 2637 | 2637 | el(wp.components.PanelBody, { |
| 2638 | - title: '<?php esc_attr_e( "Settings" ); ?>', |
|
| 2638 | + title: '<?php esc_attr_e("Settings"); ?>', |
|
| 2639 | 2639 | initialOpen: true |
| 2640 | 2640 | }, |
| 2641 | 2641 | <?php |
| 2642 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2643 | - $this->block_row_start( $key, $args ); |
|
| 2644 | - $this->build_block_arguments( $key, $args ); |
|
| 2645 | - $this->block_row_end( $key, $args ); |
|
| 2642 | + foreach ($this->arguments as $key => $args) { |
|
| 2643 | + $this->block_row_start($key, $args); |
|
| 2644 | + $this->build_block_arguments($key, $args); |
|
| 2645 | + $this->block_row_end($key, $args); |
|
| 2646 | 2646 | } |
| 2647 | 2647 | ?> |
| 2648 | 2648 | ), |
@@ -2656,11 +2656,11 @@ discard block |
||
| 2656 | 2656 | |
| 2657 | 2657 | <?php |
| 2658 | 2658 | // If the user sets block-output array then build it |
| 2659 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 2660 | - $this->block_element( $this->options['block-output'] ); |
|
| 2661 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2659 | + if (!empty($this->options['block-output'])) { |
|
| 2660 | + $this->block_element($this->options['block-output']); |
|
| 2661 | + }elseif (!empty($this->options['block-edit-return'])) { |
|
| 2662 | 2662 | echo $this->options['block-edit-return']; |
| 2663 | - }else{ |
|
| 2663 | + } else { |
|
| 2664 | 2664 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 2665 | 2665 | ?> |
| 2666 | 2666 | el('div', wp.blockEditor.useBlockProps({ |
@@ -2685,22 +2685,22 @@ discard block |
||
| 2685 | 2685 | var align = ''; |
| 2686 | 2686 | |
| 2687 | 2687 | // build the shortcode. |
| 2688 | - var content = "[<?php echo $this->options['base_id'];?>"; |
|
| 2688 | + var content = "[<?php echo $this->options['base_id']; ?>"; |
|
| 2689 | 2689 | $html = ''; |
| 2690 | 2690 | <?php |
| 2691 | 2691 | |
| 2692 | - if(! empty( $this->arguments )){ |
|
| 2692 | + if (!empty($this->arguments)) { |
|
| 2693 | 2693 | |
| 2694 | - foreach($this->arguments as $key => $args){ |
|
| 2694 | + foreach ($this->arguments as $key => $args) { |
|
| 2695 | 2695 | // if($args['type']=='tabs'){continue;} |
| 2696 | 2696 | ?> |
| 2697 | - if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
|
| 2698 | - if ('<?php echo esc_attr( $key );?>' == 'html') { |
|
| 2699 | - $html = attr.<?php echo esc_attr( $key );?>; |
|
| 2700 | - } else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') { |
|
| 2701 | - content += " <?php echo esc_attr( $key );?>='{x:" + attr.<?php echo esc_attr( $key );?>.x + ",y:"+attr.<?php echo esc_attr( $key );?>.y +"}' "; |
|
| 2697 | + if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) { |
|
| 2698 | + if ('<?php echo esc_attr($key); ?>' == 'html') { |
|
| 2699 | + $html = attr.<?php echo esc_attr($key); ?>; |
|
| 2700 | + } else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') { |
|
| 2701 | + content += " <?php echo esc_attr($key); ?>='{x:" + attr.<?php echo esc_attr($key); ?>.x + ",y:"+attr.<?php echo esc_attr($key); ?>.y +"}' "; |
|
| 2702 | 2702 | } else { |
| 2703 | - content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' "; |
|
| 2703 | + content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' "; |
|
| 2704 | 2704 | } |
| 2705 | 2705 | } |
| 2706 | 2706 | <?php |
@@ -2719,7 +2719,7 @@ discard block |
||
| 2719 | 2719 | ?> |
| 2720 | 2720 | // if has html element |
| 2721 | 2721 | if ($html) { |
| 2722 | - content += $html + "[/<?php echo $this->options['base_id'];?>]"; |
|
| 2722 | + content += $html + "[/<?php echo $this->options['base_id']; ?>]"; |
|
| 2723 | 2723 | } |
| 2724 | 2724 | |
| 2725 | 2725 | // @todo should we add inline style here or just css classes? |
@@ -2749,7 +2749,7 @@ discard block |
||
| 2749 | 2749 | // <x?php |
| 2750 | 2750 | // }else |
| 2751 | 2751 | |
| 2752 | - if(!empty($this->options['block-output'])){ |
|
| 2752 | + if (!empty($this->options['block-output'])) { |
|
| 2753 | 2753 | // echo "return"; |
| 2754 | 2754 | // $this->block_element( $this->options['block-output'], true ); |
| 2755 | 2755 | // echo ";"; |
@@ -2759,30 +2759,30 @@ discard block |
||
| 2759 | 2759 | '', |
| 2760 | 2760 | {}, |
| 2761 | 2761 | el('', {dangerouslySetInnerHTML: {__html: content}}), |
| 2762 | - <?php $this->block_element( $this->options['block-output'], true ); ?> |
|
| 2763 | - el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
|
| 2762 | + <?php $this->block_element($this->options['block-output'], true); ?> |
|
| 2763 | + el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}}) |
|
| 2764 | 2764 | ); |
| 2765 | 2765 | <?php |
| 2766 | 2766 | |
| 2767 | - }elseif(!empty($this->options['block-save-return'])){ |
|
| 2767 | + }elseif (!empty($this->options['block-save-return'])) { |
|
| 2768 | 2768 | echo 'return ' . $this->options['block-save-return']; |
| 2769 | - }elseif(!empty($this->options['nested-block'])){ |
|
| 2769 | + }elseif (!empty($this->options['nested-block'])) { |
|
| 2770 | 2770 | ?> |
| 2771 | 2771 | return el( |
| 2772 | 2772 | '', |
| 2773 | 2773 | {}, |
| 2774 | 2774 | el('', {dangerouslySetInnerHTML: {__html: content+"\n"}}), |
| 2775 | 2775 | InnerBlocks.Content ? el( InnerBlocks.Content ) : '', // @todo i think we need a comma here |
| 2776 | - el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
|
| 2776 | + el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}}) |
|
| 2777 | 2777 | ); |
| 2778 | 2778 | <?php |
| 2779 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2780 | - echo "return ". $this->options['block-edit-return'].";"; |
|
| 2781 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2779 | + }elseif (!empty($this->options['block-save-return'])) { |
|
| 2780 | + echo "return " . $this->options['block-edit-return'] . ";"; |
|
| 2781 | + }elseif (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') { |
|
| 2782 | 2782 | ?> |
| 2783 | 2783 | return content; |
| 2784 | 2784 | <?php |
| 2785 | - }else{ |
|
| 2785 | + } else { |
|
| 2786 | 2786 | ?> |
| 2787 | 2787 | var block_wrap = 'div'; |
| 2788 | 2788 | if (attr.hasOwnProperty("block_wrap")) { |
@@ -2811,48 +2811,48 @@ discard block |
||
| 2811 | 2811 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 2812 | 2812 | */ |
| 2813 | 2813 | |
| 2814 | - return str_replace( array( |
|
| 2814 | + return str_replace(array( |
|
| 2815 | 2815 | '<script>', |
| 2816 | 2816 | '</script>' |
| 2817 | - ), '', $output ); |
|
| 2817 | + ), '', $output); |
|
| 2818 | 2818 | } |
| 2819 | 2819 | |
| 2820 | 2820 | |
| 2821 | 2821 | |
| 2822 | - public function block_row_start($key, $args){ |
|
| 2822 | + public function block_row_start($key, $args) { |
|
| 2823 | 2823 | |
| 2824 | 2824 | // check for row |
| 2825 | - if(!empty($args['row'])){ |
|
| 2825 | + if (!empty($args['row'])) { |
|
| 2826 | 2826 | |
| 2827 | - if(!empty($args['row']['open'])){ |
|
| 2827 | + if (!empty($args['row']['open'])) { |
|
| 2828 | 2828 | |
| 2829 | 2829 | // element require |
| 2830 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 2831 | - $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
|
| 2832 | - $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
| 2830 | + $element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : ""; |
|
| 2831 | + $device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : ''; |
|
| 2832 | + $device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
| 2833 | 2833 | $device_type_icon = ''; |
| 2834 | - if($device_type=='Desktop'){ |
|
| 2834 | + if ($device_type == 'Desktop') { |
|
| 2835 | 2835 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;"></span>'; |
| 2836 | - }elseif($device_type=='Tablet'){ |
|
| 2836 | + }elseif ($device_type == 'Tablet') { |
|
| 2837 | 2837 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;"></span>'; |
| 2838 | - }elseif($device_type=='Mobile'){ |
|
| 2838 | + }elseif ($device_type == 'Mobile') { |
|
| 2839 | 2839 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;"></span>'; |
| 2840 | 2840 | } |
| 2841 | 2841 | echo $element_require; |
| 2842 | 2842 | echo $device_type_require; |
| 2843 | 2843 | |
| 2844 | - if(false){?><script><?php }?> |
|
| 2844 | + if (false) {?><script><?php }?> |
|
| 2845 | 2845 | el('div', { |
| 2846 | 2846 | className: 'bsui components-base-control', |
| 2847 | 2847 | }, |
| 2848 | - <?php if(!empty($args['row']['title'])){ ?> |
|
| 2848 | + <?php if (!empty($args['row']['title'])) { ?> |
|
| 2849 | 2849 | el('label', { |
| 2850 | 2850 | className: 'components-base-control__label', |
| 2851 | 2851 | style: {width:"100%"} |
| 2852 | 2852 | }, |
| 2853 | - el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['row']['title'] ) ?>'}}), |
|
| 2854 | - <?php if($device_type_icon){ ?> |
|
| 2855 | - deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {float:"right",color:"var(--wp-admin-theme-color)"}}) |
|
| 2853 | + el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['row']['title']) ?>'}}), |
|
| 2854 | + <?php if ($device_type_icon) { ?> |
|
| 2855 | + deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {float:"right",color:"var(--wp-admin-theme-color)"}}) |
|
| 2856 | 2856 | <?php |
| 2857 | 2857 | } |
| 2858 | 2858 | ?> |
@@ -2860,17 +2860,17 @@ discard block |
||
| 2860 | 2860 | |
| 2861 | 2861 | ), |
| 2862 | 2862 | <?php }?> |
| 2863 | - <?php if(!empty($args['row']['desc'])){ ?> |
|
| 2863 | + <?php if (!empty($args['row']['desc'])) { ?> |
|
| 2864 | 2864 | el('p', { |
| 2865 | 2865 | className: 'components-base-control__help mb-0', |
| 2866 | 2866 | }, |
| 2867 | - '<?php echo addslashes( $args['row']['desc'] ); ?>' |
|
| 2867 | + '<?php echo addslashes($args['row']['desc']); ?>' |
|
| 2868 | 2868 | ), |
| 2869 | 2869 | <?php }?> |
| 2870 | 2870 | el( |
| 2871 | 2871 | 'div', |
| 2872 | 2872 | { |
| 2873 | - className: 'row mb-n2 <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>', |
|
| 2873 | + className: 'row mb-n2 <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>', |
|
| 2874 | 2874 | }, |
| 2875 | 2875 | el( |
| 2876 | 2876 | 'div', |
@@ -2879,36 +2879,36 @@ discard block |
||
| 2879 | 2879 | }, |
| 2880 | 2880 | |
| 2881 | 2881 | <?php |
| 2882 | - if(false){?></script><?php } |
|
| 2883 | - }elseif(!empty($args['row']['close'])){ |
|
| 2884 | - if(false){?><script><?php }?> |
|
| 2882 | + if (false) {?></script><?php } |
|
| 2883 | + }elseif (!empty($args['row']['close'])) { |
|
| 2884 | + if (false) {?><script><?php }?> |
|
| 2885 | 2885 | el( |
| 2886 | 2886 | 'div', |
| 2887 | 2887 | { |
| 2888 | 2888 | className: 'col pl-0', |
| 2889 | 2889 | }, |
| 2890 | 2890 | <?php |
| 2891 | - if(false){?></script><?php } |
|
| 2892 | - }else{ |
|
| 2893 | - if(false){?><script><?php }?> |
|
| 2891 | + if (false) {?></script><?php } |
|
| 2892 | + } else { |
|
| 2893 | + if (false) {?><script><?php }?> |
|
| 2894 | 2894 | el( |
| 2895 | 2895 | 'div', |
| 2896 | 2896 | { |
| 2897 | 2897 | className: 'col pl-0 pr-2', |
| 2898 | 2898 | }, |
| 2899 | 2899 | <?php |
| 2900 | - if(false){?></script><?php } |
|
| 2900 | + if (false) {?></script><?php } |
|
| 2901 | 2901 | } |
| 2902 | 2902 | |
| 2903 | 2903 | } |
| 2904 | 2904 | |
| 2905 | 2905 | } |
| 2906 | 2906 | |
| 2907 | - public function block_row_end($key, $args){ |
|
| 2907 | + public function block_row_end($key, $args) { |
|
| 2908 | 2908 | |
| 2909 | - if(!empty($args['row'])){ |
|
| 2909 | + if (!empty($args['row'])) { |
|
| 2910 | 2910 | // maybe close |
| 2911 | - if(!empty($args['row']['close'])){ |
|
| 2911 | + if (!empty($args['row']['close'])) { |
|
| 2912 | 2912 | echo "))"; |
| 2913 | 2913 | } |
| 2914 | 2914 | |
@@ -2916,14 +2916,14 @@ discard block |
||
| 2916 | 2916 | } |
| 2917 | 2917 | } |
| 2918 | 2918 | |
| 2919 | - public function block_tab_start($key, $args){ |
|
| 2919 | + public function block_tab_start($key, $args) { |
|
| 2920 | 2920 | |
| 2921 | 2921 | // check for row |
| 2922 | - if(!empty($args['tab'])){ |
|
| 2922 | + if (!empty($args['tab'])) { |
|
| 2923 | 2923 | |
| 2924 | - if(!empty($args['tab']['tabs_open'])){ |
|
| 2924 | + if (!empty($args['tab']['tabs_open'])) { |
|
| 2925 | 2925 | |
| 2926 | - if(false){?><script><?php }?> |
|
| 2926 | + if (false) {?><script><?php }?> |
|
| 2927 | 2927 | |
| 2928 | 2928 | el('div',{className: 'bsui'}, |
| 2929 | 2929 | |
@@ -2932,41 +2932,41 @@ discard block |
||
| 2932 | 2932 | { |
| 2933 | 2933 | activeClass: 'is-active', |
| 2934 | 2934 | className: 'btn-groupx', |
| 2935 | - initialTabName: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
|
| 2935 | + initialTabName: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>', |
|
| 2936 | 2936 | tabs: [ |
| 2937 | 2937 | |
| 2938 | 2938 | <?php |
| 2939 | - if(false){?></script><?php } |
|
| 2939 | + if (false) {?></script><?php } |
|
| 2940 | 2940 | } |
| 2941 | 2941 | |
| 2942 | - if(!empty($args['tab']['open'])){ |
|
| 2942 | + if (!empty($args['tab']['open'])) { |
|
| 2943 | 2943 | |
| 2944 | - if(false){?><script><?php }?> |
|
| 2944 | + if (false) {?><script><?php }?> |
|
| 2945 | 2945 | { |
| 2946 | - name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
|
| 2947 | - title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}), |
|
| 2948 | - className: '<?php echo addslashes( esc_attr( $args['tab']['class']) ); ?>', |
|
| 2949 | - content: el('div',{}, <?php if(!empty($args['tab']['desc'])){ ?>el('p', { |
|
| 2946 | + name: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>', |
|
| 2947 | + title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes(esc_attr($args['tab']['title'])); ?>'}}), |
|
| 2948 | + className: '<?php echo addslashes(esc_attr($args['tab']['class'])); ?>', |
|
| 2949 | + content: el('div',{}, <?php if (!empty($args['tab']['desc'])) { ?>el('p', { |
|
| 2950 | 2950 | className: 'components-base-control__help mb-0', |
| 2951 | - dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'} |
|
| 2951 | + dangerouslySetInnerHTML: {__html:'<?php echo addslashes($args['tab']['desc']); ?>'} |
|
| 2952 | 2952 | }),<?php } |
| 2953 | - if(false){?></script><?php } |
|
| 2953 | + if (false) {?></script><?php } |
|
| 2954 | 2954 | } |
| 2955 | 2955 | |
| 2956 | 2956 | } |
| 2957 | 2957 | |
| 2958 | 2958 | } |
| 2959 | 2959 | |
| 2960 | - public function block_tab_end($key, $args){ |
|
| 2960 | + public function block_tab_end($key, $args) { |
|
| 2961 | 2961 | |
| 2962 | - if(!empty($args['tab'])){ |
|
| 2962 | + if (!empty($args['tab'])) { |
|
| 2963 | 2963 | // maybe close |
| 2964 | - if(!empty($args['tab']['close'])){ |
|
| 2964 | + if (!empty($args['tab']['close'])) { |
|
| 2965 | 2965 | echo ")}, /* tab close */"; |
| 2966 | 2966 | } |
| 2967 | 2967 | |
| 2968 | - if(!empty($args['tab']['tabs_close'])){ |
|
| 2969 | - if(false){?><script><?php }?> |
|
| 2968 | + if (!empty($args['tab']['tabs_close'])) { |
|
| 2969 | + if (false) {?><script><?php }?> |
|
| 2970 | 2970 | ], |
| 2971 | 2971 | }, |
| 2972 | 2972 | ( tab ) => { |
@@ -2975,41 +2975,41 @@ discard block |
||
| 2975 | 2975 | |
| 2976 | 2976 | } |
| 2977 | 2977 | )), /* tabs close */ |
| 2978 | - <?php if(false){ ?></script><?php } |
|
| 2978 | + <?php if (false) { ?></script><?php } |
|
| 2979 | 2979 | } |
| 2980 | 2980 | } |
| 2981 | 2981 | } |
| 2982 | 2982 | |
| 2983 | - public function build_block_arguments( $key, $args ) { |
|
| 2984 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 2983 | + public function build_block_arguments($key, $args) { |
|
| 2984 | + $custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : ''; |
|
| 2985 | 2985 | $options = ''; |
| 2986 | 2986 | $extra = ''; |
| 2987 | 2987 | $require = ''; |
| 2988 | - $inside_elements = ''; |
|
| 2988 | + $inside_elements = ''; |
|
| 2989 | 2989 | |
| 2990 | 2990 | // `content` is a protected and special argument |
| 2991 | - if ( $key == 'content' ) { |
|
| 2991 | + if ($key == 'content') { |
|
| 2992 | 2992 | return; |
| 2993 | 2993 | } |
| 2994 | 2994 | |
| 2995 | - $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
|
| 2996 | - $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
| 2995 | + $device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : ''; |
|
| 2996 | + $device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
| 2997 | 2997 | $device_type_icon = ''; |
| 2998 | - if($device_type=='Desktop'){ |
|
| 2998 | + if ($device_type == 'Desktop') { |
|
| 2999 | 2999 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;"></span>'; |
| 3000 | - }elseif($device_type=='Tablet'){ |
|
| 3000 | + }elseif ($device_type == 'Tablet') { |
|
| 3001 | 3001 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;"></span>'; |
| 3002 | - }elseif($device_type=='Mobile'){ |
|
| 3002 | + }elseif ($device_type == 'Mobile') { |
|
| 3003 | 3003 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;"></span>'; |
| 3004 | 3004 | } |
| 3005 | 3005 | |
| 3006 | 3006 | // icon |
| 3007 | 3007 | $icon = ''; |
| 3008 | - if( !empty( $args['icon'] ) ){ |
|
| 3008 | + if (!empty($args['icon'])) { |
|
| 3009 | 3009 | $icon .= "el('div', {"; |
| 3010 | - $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3010 | + $icon .= "dangerouslySetInnerHTML: {__html: '" . self::get_widget_icon(esc_attr($args['icon'])) . "'},"; |
|
| 3011 | 3011 | $icon .= "className: 'text-center',"; |
| 3012 | - $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3012 | + $icon .= "title: '" . addslashes($args['title']) . "',"; |
|
| 3013 | 3013 | $icon .= "}),"; |
| 3014 | 3014 | |
| 3015 | 3015 | // blank title as its added to the icon. |
@@ -3017,28 +3017,28 @@ discard block |
||
| 3017 | 3017 | } |
| 3018 | 3018 | |
| 3019 | 3019 | // require advanced |
| 3020 | - $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3020 | + $require_advanced = !empty($args['advanced']) ? "props.attributes.show_advanced && " : ""; |
|
| 3021 | 3021 | |
| 3022 | 3022 | // element require |
| 3023 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3023 | + $element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : ""; |
|
| 3024 | 3024 | |
| 3025 | 3025 | |
| 3026 | 3026 | $onchange = "props.setAttributes({ $key: $key } )"; |
| 3027 | - $onchangecomplete = ""; |
|
| 3027 | + $onchangecomplete = ""; |
|
| 3028 | 3028 | $value = "props.attributes.$key"; |
| 3029 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3030 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 3029 | + $text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'colorx', 'range'); |
|
| 3030 | + if (in_array($args['type'], $text_type)) { |
|
| 3031 | 3031 | $type = 'TextControl'; |
| 3032 | 3032 | // Save numbers as numbers and not strings |
| 3033 | - if ( $args['type'] == 'number' ) { |
|
| 3033 | + if ($args['type'] == 'number') { |
|
| 3034 | 3034 | $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
| 3035 | 3035 | } |
| 3036 | - }else if ( $args['type'] == 'styleid' ) { |
|
| 3036 | + } else if ($args['type'] == 'styleid') { |
|
| 3037 | 3037 | $type = 'TextControl'; |
| 3038 | 3038 | $args['type'] == 'text'; |
| 3039 | 3039 | // Save numbers as numbers and not strings |
| 3040 | - $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3041 | - }else if ( $args['type'] == 'notice' ) { |
|
| 3040 | + $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3041 | + } else if ($args['type'] == 'notice') { |
|
| 3042 | 3042 | |
| 3043 | 3043 | $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
| 3044 | 3044 | $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
@@ -3100,11 +3100,11 @@ discard block |
||
| 3100 | 3100 | return; |
| 3101 | 3101 | } |
| 3102 | 3102 | */ |
| 3103 | - elseif ( $args['type'] == 'color' ) { |
|
| 3103 | + elseif ($args['type'] == 'color') { |
|
| 3104 | 3104 | $type = 'ColorPicker'; |
| 3105 | 3105 | $onchange = ""; |
| 3106 | 3106 | $extra = "color: $value,"; |
| 3107 | - if(!empty($args['disable_alpha'])){ |
|
| 3107 | + if (!empty($args['disable_alpha'])) { |
|
| 3108 | 3108 | $extra .= "disableAlpha: true,"; |
| 3109 | 3109 | } |
| 3110 | 3110 | $onchangecomplete = "onChangeComplete: function($key) { |
@@ -3113,10 +3113,10 @@ discard block |
||
| 3113 | 3113 | $key: value |
| 3114 | 3114 | }); |
| 3115 | 3115 | },"; |
| 3116 | - }elseif ( $args['type'] == 'gradient' ) { |
|
| 3116 | + }elseif ($args['type'] == 'gradient') { |
|
| 3117 | 3117 | $type = 'GradientPicker'; |
| 3118 | 3118 | |
| 3119 | - }elseif ( $args['type'] == 'image' ) { |
|
| 3119 | + }elseif ($args['type'] == 'image') { |
|
| 3120 | 3120 | // print_r($args); |
| 3121 | 3121 | |
| 3122 | 3122 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? "props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " props.attributes.$key && el(wp.components.FocalPointPicker,{ |
@@ -3176,7 +3176,7 @@ discard block |
||
| 3176 | 3176 | $onchange = ""; |
| 3177 | 3177 | |
| 3178 | 3178 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3179 | - }elseif ( $args['type'] == 'images' ) { |
|
| 3179 | + }elseif ($args['type'] == 'images') { |
|
| 3180 | 3180 | // print_r($args); |
| 3181 | 3181 | |
| 3182 | 3182 | $img_preview = "props.attributes.$key && (function() { |
@@ -3188,7 +3188,7 @@ discard block |
||
| 3188 | 3188 | images.push( el('div',{className: 'col p-2',draggable: 'true','data-index': index}, el('img', { src: upload.sizes.thumbnail.url,style: {maxWidth:'100%',background: '#ccc',pointerEvents:'none'}}),el('i',{ |
| 3189 | 3189 | className: 'fas fa-times-circle text-danger position-absolute ml-n2 mt-n1 bg-white rounded-circle c-pointer', |
| 3190 | 3190 | onClick: function(){ |
| 3191 | - aui_confirm('".__('Are you sure?')."', '".__('Delete')."', '".__('Cancel')."', true).then(function(confirmed) { |
|
| 3191 | + aui_confirm('" . __('Are you sure?') . "', '" . __('Delete') . "', '" . __('Cancel') . "', true).then(function(confirmed) { |
|
| 3192 | 3192 | if (confirmed) { |
| 3193 | 3193 | let new_uploads = JSON.parse(props.attributes.$key); |
| 3194 | 3194 | new_uploads.splice(index, 1); //remove |
@@ -3262,49 +3262,49 @@ discard block |
||
| 3262 | 3262 | |
| 3263 | 3263 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3264 | 3264 | } |
| 3265 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 3265 | + elseif ($args['type'] == 'checkbox') { |
|
| 3266 | 3266 | $type = 'CheckboxControl'; |
| 3267 | 3267 | $extra .= "checked: props.attributes.$key,"; |
| 3268 | 3268 | $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
| 3269 | - } elseif ( $args['type'] == 'textarea' ) { |
|
| 3269 | + } elseif ($args['type'] == 'textarea') { |
|
| 3270 | 3270 | $type = 'TextareaControl'; |
| 3271 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3271 | + } elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') { |
|
| 3272 | 3272 | $type = 'SelectControl'; |
| 3273 | 3273 | |
| 3274 | - if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3275 | - $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3276 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3277 | - $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3278 | - }else { |
|
| 3274 | + if ($args['name'] == 'category' && !empty($args['post_type_linked'])) { |
|
| 3275 | + $options .= "options: taxonomies_" . str_replace("-", "_", $this->id) . ","; |
|
| 3276 | + }elseif ($args['name'] == 'sort_by' && !empty($args['post_type_linked'])) { |
|
| 3277 | + $options .= "options: sort_by_" . str_replace("-", "_", $this->id) . ","; |
|
| 3278 | + } else { |
|
| 3279 | 3279 | |
| 3280 | - if ( ! empty( $args['options'] ) ) { |
|
| 3280 | + if (!empty($args['options'])) { |
|
| 3281 | 3281 | $options .= "options: ["; |
| 3282 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3283 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 3282 | + foreach ($args['options'] as $option_val => $option_label) { |
|
| 3283 | + $options .= "{ value: '" . esc_attr($option_val) . "', label: '" . addslashes($option_label) . "' },"; |
|
| 3284 | 3284 | } |
| 3285 | 3285 | $options .= "],"; |
| 3286 | 3286 | } |
| 3287 | 3287 | } |
| 3288 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3288 | + if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3289 | 3289 | $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px"}, '; |
| 3290 | 3290 | } |
| 3291 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 3291 | + } elseif ($args['type'] == 'alignment') { |
|
| 3292 | 3292 | $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
| 3293 | - }elseif ( $args['type'] == 'margins' ) { |
|
| 3293 | + }elseif ($args['type'] == 'margins') { |
|
| 3294 | 3294 | |
| 3295 | 3295 | } else { |
| 3296 | - return;// if we have not implemented the control then don't break the JS. |
|
| 3296 | + return; // if we have not implemented the control then don't break the JS. |
|
| 3297 | 3297 | } |
| 3298 | 3298 | |
| 3299 | 3299 | |
| 3300 | 3300 | |
| 3301 | 3301 | // color input does not show the labels so we add them |
| 3302 | - if($args['type']=='color'){ |
|
| 3302 | + if ($args['type'] == 'color') { |
|
| 3303 | 3303 | // add show only if advanced |
| 3304 | 3304 | echo $require_advanced; |
| 3305 | 3305 | // add setting require if defined |
| 3306 | 3306 | echo $element_require; |
| 3307 | - echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3307 | + echo "el('div', {style: {'marginBottom': '8px'}}, '" . addslashes($args['title']) . "'),"; |
|
| 3308 | 3308 | } |
| 3309 | 3309 | |
| 3310 | 3310 | // add show only if advanced |
@@ -3316,18 +3316,18 @@ discard block |
||
| 3316 | 3316 | // icon |
| 3317 | 3317 | echo $icon; |
| 3318 | 3318 | ?> |
| 3319 | - el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components.".$type; ?>, { |
|
| 3319 | + el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components." . $type; ?>, { |
|
| 3320 | 3320 | label: <?php |
| 3321 | - if(empty($args['title'])){ |
|
| 3321 | + if (empty($args['title'])) { |
|
| 3322 | 3322 | echo "''"; |
| 3323 | - }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3323 | + }elseif (empty($args['row']) && !empty($args['device_type'])) { |
|
| 3324 | 3324 | ?>el('label', { |
| 3325 | 3325 | className: 'components-base-control__label', |
| 3326 | 3326 | style: {width:"100%"} |
| 3327 | 3327 | }, |
| 3328 | - el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}), |
|
| 3329 | - <?php if($device_type_icon){ ?> |
|
| 3330 | - deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}}) |
|
| 3328 | + el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['title']) ?>'}}), |
|
| 3329 | + <?php if ($device_type_icon) { ?> |
|
| 3330 | + deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}}) |
|
| 3331 | 3331 | <?php |
| 3332 | 3332 | } |
| 3333 | 3333 | ?> |
@@ -3335,27 +3335,27 @@ discard block |
||
| 3335 | 3335 | |
| 3336 | 3336 | )<?php |
| 3337 | 3337 | |
| 3338 | - }else{ |
|
| 3339 | - ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
|
| 3338 | + } else { |
|
| 3339 | + ?>'<?php echo addslashes($args['title']); ?>'<?php |
|
| 3340 | 3340 | |
| 3341 | 3341 | } |
| 3342 | 3342 | |
| 3343 | 3343 | ?>, |
| 3344 | - help: <?php if ( isset( $args['desc'] ) ) { |
|
| 3345 | - echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
|
| 3346 | - }else{ echo "''"; } ?>, |
|
| 3344 | + help: <?php if (isset($args['desc'])) { |
|
| 3345 | + echo "el('span',{dangerouslySetInnerHTML: {__html: '" . wp_kses_post(addslashes($args['desc'])) . "'}})"; |
|
| 3346 | + } else { echo "''"; } ?>, |
|
| 3347 | 3347 | value: <?php echo $value; ?>, |
| 3348 | - <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
|
| 3349 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3348 | + <?php if ($type == 'TextControl' && $args['type'] != 'text') { |
|
| 3349 | + echo "type: '" . addslashes($args['type']) . "',"; |
|
| 3350 | 3350 | } ?> |
| 3351 | - <?php if ( ! empty( $args['placeholder'] ) ) { |
|
| 3352 | - echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 3351 | + <?php if (!empty($args['placeholder'])) { |
|
| 3352 | + echo "placeholder: '" . addslashes($args['placeholder']) . "',"; |
|
| 3353 | 3353 | } ?> |
| 3354 | 3354 | <?php echo $options; ?> |
| 3355 | 3355 | <?php echo $extra; ?> |
| 3356 | 3356 | <?php echo $custom_attributes; ?> |
| 3357 | 3357 | <?php echo $onchangecomplete; |
| 3358 | - if($onchange){ |
|
| 3358 | + if ($onchange) { |
|
| 3359 | 3359 | ?> |
| 3360 | 3360 | onChange: function ( <?php echo $key; ?> ) { |
| 3361 | 3361 | <?php echo $onchange; ?> |
@@ -3376,15 +3376,15 @@ discard block |
||
| 3376 | 3376 | *@todo there is prob a faster way to do this, also we could add some validation here. |
| 3377 | 3377 | * |
| 3378 | 3378 | */ |
| 3379 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3379 | + public function array_to_attributes($custom_attributes, $html = false) { |
|
| 3380 | 3380 | $attributes = ''; |
| 3381 | - if ( ! empty( $custom_attributes ) ) { |
|
| 3381 | + if (!empty($custom_attributes)) { |
|
| 3382 | 3382 | |
| 3383 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 3384 | - if(is_array($val)){ |
|
| 3385 | - $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3386 | - }else{ |
|
| 3387 | - $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3383 | + foreach ($custom_attributes as $key => $val) { |
|
| 3384 | + if (is_array($val)) { |
|
| 3385 | + $attributes .= $key . ': {' . $this->array_to_attributes($val, $html) . '},'; |
|
| 3386 | + } else { |
|
| 3387 | + $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3388 | 3388 | } |
| 3389 | 3389 | } |
| 3390 | 3390 | |
@@ -3402,112 +3402,112 @@ discard block |
||
| 3402 | 3402 | * |
| 3403 | 3403 | * @param $args |
| 3404 | 3404 | */ |
| 3405 | - public function block_element( $args, $save = false ) { |
|
| 3405 | + public function block_element($args, $save = false) { |
|
| 3406 | 3406 | |
| 3407 | 3407 | |
| 3408 | - if ( ! empty( $args ) ) { |
|
| 3409 | - foreach ( $args as $element => $new_args ) { |
|
| 3408 | + if (!empty($args)) { |
|
| 3409 | + foreach ($args as $element => $new_args) { |
|
| 3410 | 3410 | |
| 3411 | - if ( is_array( $new_args ) ) { // its an element |
|
| 3411 | + if (is_array($new_args)) { // its an element |
|
| 3412 | 3412 | |
| 3413 | 3413 | |
| 3414 | - if ( isset( $new_args['element'] ) ) { |
|
| 3414 | + if (isset($new_args['element'])) { |
|
| 3415 | 3415 | |
| 3416 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 3417 | - echo str_replace( array( |
|
| 3416 | + if (isset($new_args['element_require'])) { |
|
| 3417 | + echo str_replace(array( |
|
| 3418 | 3418 | "'+", |
| 3419 | 3419 | "+'" |
| 3420 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3421 | - unset( $new_args['element_require'] ); |
|
| 3420 | + ), '', $this->block_props_replace($new_args['element_require'])) . " && "; |
|
| 3421 | + unset($new_args['element_require']); |
|
| 3422 | 3422 | } |
| 3423 | 3423 | |
| 3424 | - if($new_args['element']=='InnerBlocks'){ |
|
| 3424 | + if ($new_args['element'] == 'InnerBlocks') { |
|
| 3425 | 3425 | echo "\n el( InnerBlocks, {"; |
| 3426 | - }elseif($new_args['element']=='innerBlocksProps'){ |
|
| 3426 | + }elseif ($new_args['element'] == 'innerBlocksProps') { |
|
| 3427 | 3427 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3428 | 3428 | // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
| 3429 | 3429 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3430 | 3430 | echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3431 | 3431 | echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; |
| 3432 | - echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
|
| 3432 | + echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : ''; |
|
| 3433 | 3433 | |
| 3434 | 3434 | echo "} ), {"; |
| 3435 | - echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; |
|
| 3435 | + echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element($new_args['innerBlocksProps'], $save) : ''; |
|
| 3436 | 3436 | // echo '###'; |
| 3437 | 3437 | |
| 3438 | 3438 | // echo '###'; |
| 3439 | - }elseif($new_args['element']=='BlocksProps'){ |
|
| 3439 | + }elseif ($new_args['element'] == 'BlocksProps') { |
|
| 3440 | 3440 | |
| 3441 | - if ( isset($new_args['if_inner_element']) ) { |
|
| 3441 | + if (isset($new_args['if_inner_element'])) { |
|
| 3442 | 3442 | $element = $new_args['if_inner_element']; |
| 3443 | - }else { |
|
| 3444 | - $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3443 | + } else { |
|
| 3444 | + $element = isset($new_args['inner_element']) ? "'" . esc_attr($new_args['inner_element']) . "'" : "'div'"; |
|
| 3445 | 3445 | } |
| 3446 | 3446 | |
| 3447 | 3447 | unset($new_args['inner_element']); |
| 3448 | 3448 | echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {"; |
| 3449 | - echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
|
| 3449 | + echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : ''; |
|
| 3450 | 3450 | |
| 3451 | 3451 | |
| 3452 | 3452 | // echo "} ),"; |
| 3453 | 3453 | |
| 3454 | - }else{ |
|
| 3454 | + } else { |
|
| 3455 | 3455 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 3456 | 3456 | } |
| 3457 | 3457 | |
| 3458 | 3458 | |
| 3459 | 3459 | // get the attributes |
| 3460 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3460 | + foreach ($new_args as $new_key => $new_value) { |
|
| 3461 | 3461 | |
| 3462 | 3462 | |
| 3463 | - if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3463 | + if ($new_key == 'element' || $new_key == 'content' || $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) { |
|
| 3464 | 3464 | // do nothing |
| 3465 | 3465 | } else { |
| 3466 | - echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3466 | + echo $this->block_element(array($new_key => $new_value), $save); |
|
| 3467 | 3467 | } |
| 3468 | 3468 | } |
| 3469 | 3469 | |
| 3470 | - echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3470 | + echo $new_args['element'] == 'BlocksProps' ? '} ),' : "},"; // end attributes |
|
| 3471 | 3471 | |
| 3472 | 3472 | // get the content |
| 3473 | 3473 | $first_item = 0; |
| 3474 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3475 | - if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3474 | + foreach ($new_args as $new_key => $new_value) { |
|
| 3475 | + if ($new_key === 'content' || $new_key === 'if_content' || is_array($new_value)) { |
|
| 3476 | 3476 | |
| 3477 | - if ( $new_key === 'content' ) { |
|
| 3478 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 3479 | - }else if ( $new_key === 'if_content' ) { |
|
| 3480 | - echo $this->block_props_replace( $new_value ); |
|
| 3477 | + if ($new_key === 'content') { |
|
| 3478 | + echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'"; |
|
| 3479 | + } else if ($new_key === 'if_content') { |
|
| 3480 | + echo $this->block_props_replace($new_value); |
|
| 3481 | 3481 | } |
| 3482 | 3482 | |
| 3483 | - if ( is_array( $new_value ) ) { |
|
| 3483 | + if (is_array($new_value)) { |
|
| 3484 | 3484 | |
| 3485 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 3486 | - echo str_replace( array( |
|
| 3485 | + if (isset($new_value['element_require'])) { |
|
| 3486 | + echo str_replace(array( |
|
| 3487 | 3487 | "'+", |
| 3488 | 3488 | "+'" |
| 3489 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 3490 | - unset( $new_value['element_require'] ); |
|
| 3489 | + ), '', $this->block_props_replace($new_value['element_require'])) . " && "; |
|
| 3490 | + unset($new_value['element_require']); |
|
| 3491 | 3491 | } |
| 3492 | 3492 | |
| 3493 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 3493 | + if (isset($new_value['element_repeat'])) { |
|
| 3494 | 3494 | $x = 1; |
| 3495 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 3496 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3497 | - $x ++; |
|
| 3495 | + while ($x <= absint($new_value['element_repeat'])) { |
|
| 3496 | + $this->block_element(array('' => $new_value), $save); |
|
| 3497 | + $x++; |
|
| 3498 | 3498 | } |
| 3499 | 3499 | } else { |
| 3500 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3500 | + $this->block_element(array('' => $new_value), $save); |
|
| 3501 | 3501 | } |
| 3502 | 3502 | } |
| 3503 | - $first_item ++; |
|
| 3503 | + $first_item++; |
|
| 3504 | 3504 | } |
| 3505 | 3505 | } |
| 3506 | 3506 | |
| 3507 | - if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
|
| 3508 | - echo "))";// end content |
|
| 3509 | - }else{ |
|
| 3510 | - echo ")";// end content |
|
| 3507 | + if ($new_args['element'] == 'innerBlocksProps' || $new_args['element'] == 'xBlocksProps') { |
|
| 3508 | + echo "))"; // end content |
|
| 3509 | + } else { |
|
| 3510 | + echo ")"; // end content |
|
| 3511 | 3511 | } |
| 3512 | 3512 | |
| 3513 | 3513 | |
@@ -3516,26 +3516,26 @@ discard block |
||
| 3516 | 3516 | } |
| 3517 | 3517 | } else { |
| 3518 | 3518 | |
| 3519 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 3519 | + if (substr($element, 0, 3) === "if_") { |
|
| 3520 | 3520 | $extra = ''; |
| 3521 | - if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 3522 | - $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 3523 | - $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 3521 | + if (strpos($new_args, '[%WrapClass%]') !== false) { |
|
| 3522 | + $new_args = str_replace('[%WrapClass%]"', '" + sd_build_aui_class(props.attributes)', $new_args); |
|
| 3523 | + $new_args = str_replace('[%WrapClass%]', '+ sd_build_aui_class(props.attributes)', $new_args); |
|
| 3524 | 3524 | } |
| 3525 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 3526 | - } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 3527 | - $new_args = str_replace('[%WrapStyle%]','',$new_args); |
|
| 3528 | - echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },"; |
|
| 3525 | + echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ","; |
|
| 3526 | + } elseif ($element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false) { |
|
| 3527 | + $new_args = str_replace('[%WrapStyle%]', '', $new_args); |
|
| 3528 | + echo $element . ": {..." . $this->block_props_replace($new_args) . " , ...sd_build_aui_styles(props.attributes) },"; |
|
| 3529 | 3529 | // echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
| 3530 | - } elseif ( $element == 'style' ) { |
|
| 3531 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 3532 | - } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 3533 | - $new_args = str_replace('[%WrapClass%]','',$new_args); |
|
| 3534 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),"; |
|
| 3535 | - } elseif ( $element == 'template' && $new_args ) { |
|
| 3530 | + } elseif ($element == 'style') { |
|
| 3531 | + echo $element . ": " . $this->block_props_replace($new_args) . ","; |
|
| 3532 | + } elseif (($element == 'class' || $element == 'className') && strpos($new_args, '[%WrapClass%]') !== false) { |
|
| 3533 | + $new_args = str_replace('[%WrapClass%]', '', $new_args); |
|
| 3534 | + echo $element . ": '" . $this->block_props_replace($new_args) . "' + sd_build_aui_class(props.attributes),"; |
|
| 3535 | + } elseif ($element == 'template' && $new_args) { |
|
| 3536 | 3536 | echo $element . ": $new_args,"; |
| 3537 | 3537 | } else { |
| 3538 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 3538 | + echo $element . ": '" . $this->block_props_replace($new_args) . "',"; |
|
| 3539 | 3539 | } |
| 3540 | 3540 | |
| 3541 | 3541 | } |
@@ -3550,12 +3550,12 @@ discard block |
||
| 3550 | 3550 | * |
| 3551 | 3551 | * @return mixed |
| 3552 | 3552 | */ |
| 3553 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 3553 | + public function block_props_replace($string, $no_wrap = false) { |
|
| 3554 | 3554 | |
| 3555 | - if ( $no_wrap ) { |
|
| 3556 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 3555 | + if ($no_wrap) { |
|
| 3556 | + $string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string); |
|
| 3557 | 3557 | } else { |
| 3558 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 3558 | + $string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string); |
|
| 3559 | 3559 | } |
| 3560 | 3560 | |
| 3561 | 3561 | return $string; |
@@ -3567,62 +3567,62 @@ discard block |
||
| 3567 | 3567 | * @param array $args |
| 3568 | 3568 | * @param array $instance |
| 3569 | 3569 | */ |
| 3570 | - public function widget( $args, $instance ) { |
|
| 3570 | + public function widget($args, $instance) { |
|
| 3571 | 3571 | |
| 3572 | 3572 | // get the filtered values |
| 3573 | - $argument_values = $this->argument_values( $instance ); |
|
| 3574 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 3575 | - $output = $this->output( $argument_values, $args ); |
|
| 3573 | + $argument_values = $this->argument_values($instance); |
|
| 3574 | + $argument_values = $this->string_to_bool($argument_values); |
|
| 3575 | + $output = $this->output($argument_values, $args); |
|
| 3576 | 3576 | |
| 3577 | 3577 | $no_wrap = false; |
| 3578 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 3578 | + if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) { |
|
| 3579 | 3579 | $no_wrap = true; |
| 3580 | 3580 | } |
| 3581 | 3581 | |
| 3582 | 3582 | ob_start(); |
| 3583 | - if ( $output && ! $no_wrap ) { |
|
| 3583 | + if ($output && !$no_wrap) { |
|
| 3584 | 3584 | |
| 3585 | 3585 | $class_original = $this->options['widget_ops']['classname']; |
| 3586 | - $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 3586 | + $class = $this->options['widget_ops']['classname'] . " sdel-" . $this->get_instance_hash(); |
|
| 3587 | 3587 | |
| 3588 | 3588 | // Before widget |
| 3589 | 3589 | $before_widget = $args['before_widget']; |
| 3590 | - $before_widget = str_replace($class_original,$class,$before_widget); |
|
| 3591 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 3592 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 3590 | + $before_widget = str_replace($class_original, $class, $before_widget); |
|
| 3591 | + $before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this); |
|
| 3592 | + $before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this); |
|
| 3593 | 3593 | |
| 3594 | 3594 | // After widget |
| 3595 | 3595 | $after_widget = $args['after_widget']; |
| 3596 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 3597 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 3596 | + $after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this); |
|
| 3597 | + $after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this); |
|
| 3598 | 3598 | |
| 3599 | 3599 | echo $before_widget; |
| 3600 | 3600 | // elementor strips the widget wrapping div so we check for and add it back if needed |
| 3601 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3601 | + if ($this->is_elementor_widget_output()) { |
|
| 3602 | 3602 | // Filter class & attrs for elementor widget output. |
| 3603 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 3604 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 3603 | + $class = apply_filters('wp_super_duper_div_classname', $class, $args, $this); |
|
| 3604 | + $class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this); |
|
| 3605 | 3605 | |
| 3606 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 3607 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 3606 | + $attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this); |
|
| 3607 | + $attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); |
|
| 3608 | 3608 | |
| 3609 | - echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 3609 | + echo "<span class='" . esc_attr($class) . "' " . $attrs . ">"; |
|
| 3610 | 3610 | } |
| 3611 | - echo $this->output_title( $args, $instance ); |
|
| 3611 | + echo $this->output_title($args, $instance); |
|
| 3612 | 3612 | echo $output; |
| 3613 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3613 | + if ($this->is_elementor_widget_output()) { |
|
| 3614 | 3614 | echo "</span>"; |
| 3615 | 3615 | } |
| 3616 | 3616 | echo $after_widget; |
| 3617 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 3618 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 3617 | + } elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty |
|
| 3618 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
| 3619 | 3619 | echo $output; |
| 3620 | - } elseif ( $output && $no_wrap ) { |
|
| 3620 | + } elseif ($output && $no_wrap) { |
|
| 3621 | 3621 | echo $output; |
| 3622 | 3622 | } |
| 3623 | 3623 | $output = ob_get_clean(); |
| 3624 | 3624 | |
| 3625 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 3625 | + $output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this); |
|
| 3626 | 3626 | |
| 3627 | 3627 | echo $output; |
| 3628 | 3628 | } |
@@ -3635,7 +3635,7 @@ discard block |
||
| 3635 | 3635 | */ |
| 3636 | 3636 | public function is_elementor_widget_output() { |
| 3637 | 3637 | $result = false; |
| 3638 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 3638 | + if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') { |
|
| 3639 | 3639 | $result = true; |
| 3640 | 3640 | } |
| 3641 | 3641 | |
@@ -3650,7 +3650,7 @@ discard block |
||
| 3650 | 3650 | */ |
| 3651 | 3651 | public function is_elementor_preview() { |
| 3652 | 3652 | $result = false; |
| 3653 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 3653 | + if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) { |
|
| 3654 | 3654 | $result = true; |
| 3655 | 3655 | } |
| 3656 | 3656 | |
@@ -3665,7 +3665,7 @@ discard block |
||
| 3665 | 3665 | */ |
| 3666 | 3666 | public function is_divi_preview() { |
| 3667 | 3667 | $result = false; |
| 3668 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 3668 | + if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) { |
|
| 3669 | 3669 | $result = true; |
| 3670 | 3670 | } |
| 3671 | 3671 | |
@@ -3680,7 +3680,7 @@ discard block |
||
| 3680 | 3680 | */ |
| 3681 | 3681 | public function is_beaver_preview() { |
| 3682 | 3682 | $result = false; |
| 3683 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 3683 | + if (isset($_REQUEST['fl_builder'])) { |
|
| 3684 | 3684 | $result = true; |
| 3685 | 3685 | } |
| 3686 | 3686 | |
@@ -3695,7 +3695,7 @@ discard block |
||
| 3695 | 3695 | */ |
| 3696 | 3696 | public function is_siteorigin_preview() { |
| 3697 | 3697 | $result = false; |
| 3698 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 3698 | + if (!empty($_REQUEST['siteorigin_panels_live_editor'])) { |
|
| 3699 | 3699 | $result = true; |
| 3700 | 3700 | } |
| 3701 | 3701 | |
@@ -3710,7 +3710,7 @@ discard block |
||
| 3710 | 3710 | */ |
| 3711 | 3711 | public function is_cornerstone_preview() { |
| 3712 | 3712 | $result = false; |
| 3713 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 3713 | + if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') { |
|
| 3714 | 3714 | $result = true; |
| 3715 | 3715 | } |
| 3716 | 3716 | |
@@ -3725,7 +3725,7 @@ discard block |
||
| 3725 | 3725 | */ |
| 3726 | 3726 | public function is_fusion_preview() { |
| 3727 | 3727 | $result = false; |
| 3728 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 3728 | + if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) { |
|
| 3729 | 3729 | $result = true; |
| 3730 | 3730 | } |
| 3731 | 3731 | |
@@ -3740,7 +3740,7 @@ discard block |
||
| 3740 | 3740 | */ |
| 3741 | 3741 | public function is_oxygen_preview() { |
| 3742 | 3742 | $result = false; |
| 3743 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 3743 | + if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) { |
|
| 3744 | 3744 | $result = true; |
| 3745 | 3745 | } |
| 3746 | 3746 | |
@@ -3755,21 +3755,21 @@ discard block |
||
| 3755 | 3755 | */ |
| 3756 | 3756 | public function is_preview() { |
| 3757 | 3757 | $preview = false; |
| 3758 | - if ( $this->is_divi_preview() ) { |
|
| 3758 | + if ($this->is_divi_preview()) { |
|
| 3759 | 3759 | $preview = true; |
| 3760 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 3760 | + } elseif ($this->is_elementor_preview()) { |
|
| 3761 | 3761 | $preview = true; |
| 3762 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 3762 | + } elseif ($this->is_beaver_preview()) { |
|
| 3763 | 3763 | $preview = true; |
| 3764 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 3764 | + } elseif ($this->is_siteorigin_preview()) { |
|
| 3765 | 3765 | $preview = true; |
| 3766 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 3766 | + } elseif ($this->is_cornerstone_preview()) { |
|
| 3767 | 3767 | $preview = true; |
| 3768 | - } elseif ( $this->is_fusion_preview() ) { |
|
| 3768 | + } elseif ($this->is_fusion_preview()) { |
|
| 3769 | 3769 | $preview = true; |
| 3770 | - } elseif ( $this->is_oxygen_preview() ) { |
|
| 3770 | + } elseif ($this->is_oxygen_preview()) { |
|
| 3771 | 3771 | $preview = true; |
| 3772 | - } elseif( $this->is_block_content_call() ) { |
|
| 3772 | + } elseif ($this->is_block_content_call()) { |
|
| 3773 | 3773 | $preview = true; |
| 3774 | 3774 | } |
| 3775 | 3775 | |
@@ -3784,34 +3784,34 @@ discard block |
||
| 3784 | 3784 | * |
| 3785 | 3785 | * @return string |
| 3786 | 3786 | */ |
| 3787 | - public function output_title( $args, $instance = array() ) { |
|
| 3787 | + public function output_title($args, $instance = array()) { |
|
| 3788 | 3788 | $output = ''; |
| 3789 | - if ( ! empty( $instance['title'] ) ) { |
|
| 3789 | + if (!empty($instance['title'])) { |
|
| 3790 | 3790 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
| 3791 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 3791 | + $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); |
|
| 3792 | 3792 | |
| 3793 | - if(empty($instance['widget_title_tag'])){ |
|
| 3793 | + if (empty($instance['widget_title_tag'])) { |
|
| 3794 | 3794 | $output = $args['before_title'] . $title . $args['after_title']; |
| 3795 | - }else{ |
|
| 3796 | - $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 3795 | + } else { |
|
| 3796 | + $title_tag = esc_attr($instance['widget_title_tag']); |
|
| 3797 | 3797 | |
| 3798 | 3798 | // classes |
| 3799 | 3799 | $title_classes = array(); |
| 3800 | - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 3801 | - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 3802 | - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 3803 | - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 3804 | - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 3805 | - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 3806 | - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 3807 | - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 3808 | - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 3809 | - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 3810 | - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 3811 | - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 3812 | - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 3813 | - |
|
| 3814 | - $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 3800 | + $title_classes[] = !empty($instance['widget_title_size_class']) ? sanitize_html_class($instance['widget_title_size_class']) : ''; |
|
| 3801 | + $title_classes[] = !empty($instance['widget_title_align_class']) ? sanitize_html_class($instance['widget_title_align_class']) : ''; |
|
| 3802 | + $title_classes[] = !empty($instance['widget_title_color_class']) ? "text-" . sanitize_html_class($instance['widget_title_color_class']) : ''; |
|
| 3803 | + $title_classes[] = !empty($instance['widget_title_border_class']) ? sanitize_html_class($instance['widget_title_border_class']) : ''; |
|
| 3804 | + $title_classes[] = !empty($instance['widget_title_border_color_class']) ? "border-" . sanitize_html_class($instance['widget_title_border_color_class']) : ''; |
|
| 3805 | + $title_classes[] = !empty($instance['widget_title_mt_class']) ? "mt-" . absint($instance['widget_title_mt_class']) : ''; |
|
| 3806 | + $title_classes[] = !empty($instance['widget_title_mr_class']) ? "mr-" . absint($instance['widget_title_mr_class']) : ''; |
|
| 3807 | + $title_classes[] = !empty($instance['widget_title_mb_class']) ? "mb-" . absint($instance['widget_title_mb_class']) : ''; |
|
| 3808 | + $title_classes[] = !empty($instance['widget_title_ml_class']) ? "ml-" . absint($instance['widget_title_ml_class']) : ''; |
|
| 3809 | + $title_classes[] = !empty($instance['widget_title_pt_class']) ? "pt-" . absint($instance['widget_title_pt_class']) : ''; |
|
| 3810 | + $title_classes[] = !empty($instance['widget_title_pr_class']) ? "pr-" . absint($instance['widget_title_pr_class']) : ''; |
|
| 3811 | + $title_classes[] = !empty($instance['widget_title_pb_class']) ? "pb-" . absint($instance['widget_title_pb_class']) : ''; |
|
| 3812 | + $title_classes[] = !empty($instance['widget_title_pl_class']) ? "pl-" . absint($instance['widget_title_pl_class']) : ''; |
|
| 3813 | + |
|
| 3814 | + $class = !empty($title_classes) ? implode(" ", $title_classes) : ''; |
|
| 3815 | 3815 | $output = "<$title_tag class='$class' >$title</$title_tag>"; |
| 3816 | 3816 | } |
| 3817 | 3817 | |
@@ -3825,7 +3825,7 @@ discard block |
||
| 3825 | 3825 | * |
| 3826 | 3826 | * @param array $instance The widget options. |
| 3827 | 3827 | */ |
| 3828 | - public function form( $instance ) { |
|
| 3828 | + public function form($instance) { |
|
| 3829 | 3829 | |
| 3830 | 3830 | // set widget instance |
| 3831 | 3831 | $this->instance = $instance; |
@@ -3833,20 +3833,20 @@ discard block |
||
| 3833 | 3833 | // set it as a SD widget |
| 3834 | 3834 | echo $this->widget_advanced_toggle(); |
| 3835 | 3835 | |
| 3836 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 3836 | + echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>"; |
|
| 3837 | 3837 | $arguments_raw = $this->get_arguments(); |
| 3838 | 3838 | |
| 3839 | - if ( is_array( $arguments_raw ) ) { |
|
| 3839 | + if (is_array($arguments_raw)) { |
|
| 3840 | 3840 | |
| 3841 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
| 3841 | + $arguments = $this->group_arguments($arguments_raw); |
|
| 3842 | 3842 | |
| 3843 | 3843 | // Do we have sections? |
| 3844 | 3844 | $has_sections = $arguments == $arguments_raw ? false : true; |
| 3845 | 3845 | |
| 3846 | 3846 | |
| 3847 | - if ( $has_sections ) { |
|
| 3847 | + if ($has_sections) { |
|
| 3848 | 3848 | $panel_count = 0; |
| 3849 | - foreach ( $arguments as $key => $args ) { |
|
| 3849 | + foreach ($arguments as $key => $args) { |
|
| 3850 | 3850 | |
| 3851 | 3851 | ?> |
| 3852 | 3852 | <script> |
@@ -3856,26 +3856,26 @@ discard block |
||
| 3856 | 3856 | |
| 3857 | 3857 | $hide = $panel_count ? ' style="display:none;" ' : ''; |
| 3858 | 3858 | $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
| 3859 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3860 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 3859 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes($key) . "'>" . esc_attr($key) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3860 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>"; |
|
| 3861 | 3861 | |
| 3862 | - foreach ( $args as $k => $a ) { |
|
| 3862 | + foreach ($args as $k => $a) { |
|
| 3863 | 3863 | |
| 3864 | 3864 | $this->widget_inputs_row_start($k, $a); |
| 3865 | - $this->widget_inputs( $a, $instance ); |
|
| 3865 | + $this->widget_inputs($a, $instance); |
|
| 3866 | 3866 | $this->widget_inputs_row_end($k, $a); |
| 3867 | 3867 | |
| 3868 | 3868 | } |
| 3869 | 3869 | |
| 3870 | 3870 | echo "</div>"; |
| 3871 | 3871 | |
| 3872 | - $panel_count ++; |
|
| 3872 | + $panel_count++; |
|
| 3873 | 3873 | |
| 3874 | 3874 | } |
| 3875 | 3875 | } else { |
| 3876 | - foreach ( $arguments as $key => $args ) { |
|
| 3876 | + foreach ($arguments as $key => $args) { |
|
| 3877 | 3877 | $this->widget_inputs_row_start($key, $args); |
| 3878 | - $this->widget_inputs( $args, $instance ); |
|
| 3878 | + $this->widget_inputs($args, $instance); |
|
| 3879 | 3879 | $this->widget_inputs_row_end($key, $args); |
| 3880 | 3880 | } |
| 3881 | 3881 | } |
@@ -3883,33 +3883,33 @@ discard block |
||
| 3883 | 3883 | } |
| 3884 | 3884 | } |
| 3885 | 3885 | |
| 3886 | - public function widget_inputs_row_start($key, $args){ |
|
| 3887 | - if(!empty($args['row'])){ |
|
| 3886 | + public function widget_inputs_row_start($key, $args) { |
|
| 3887 | + if (!empty($args['row'])) { |
|
| 3888 | 3888 | // maybe open |
| 3889 | - if(!empty($args['row']['open'])){ |
|
| 3889 | + if (!empty($args['row']['open'])) { |
|
| 3890 | 3890 | ?> |
| 3891 | - <div class='bsui sd-argument ' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php if ( !empty($args['row']['element_require'])) { |
|
| 3892 | - echo $this->convert_element_require( $args['row']['element_require'] ); |
|
| 3891 | + <div class='bsui sd-argument ' data-argument='<?php echo esc_attr($args['row']['key']); ?>' data-element_require='<?php if (!empty($args['row']['element_require'])) { |
|
| 3892 | + echo $this->convert_element_require($args['row']['element_require']); |
|
| 3893 | 3893 | } ?>'> |
| 3894 | - <?php if(!empty($args['row']['title'])){ ?> |
|
| 3895 | - <label class="mb-0 "><?php echo esc_attr( $args['row']['title'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label> |
|
| 3894 | + <?php if (!empty($args['row']['title'])) { ?> |
|
| 3895 | + <label class="mb-0 "><?php echo esc_attr($args['row']['title']); ?><?php echo $this->widget_field_desc($args['row']); ?></label> |
|
| 3896 | 3896 | <?php }?> |
| 3897 | - <div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'> |
|
| 3897 | + <div class='row <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>'> |
|
| 3898 | 3898 | <div class='col pr-2'> |
| 3899 | 3899 | <?php |
| 3900 | - }elseif(!empty($args['row']['close'])){ |
|
| 3900 | + }elseif (!empty($args['row']['close'])) { |
|
| 3901 | 3901 | echo "<div class='col pl-0'>"; |
| 3902 | - }else{ |
|
| 3902 | + } else { |
|
| 3903 | 3903 | echo "<div class='col pl-0 pr-2'>"; |
| 3904 | 3904 | } |
| 3905 | 3905 | } |
| 3906 | 3906 | } |
| 3907 | 3907 | |
| 3908 | - public function widget_inputs_row_end($key, $args){ |
|
| 3908 | + public function widget_inputs_row_end($key, $args) { |
|
| 3909 | 3909 | |
| 3910 | - if(!empty($args['row'])){ |
|
| 3910 | + if (!empty($args['row'])) { |
|
| 3911 | 3911 | // maybe close |
| 3912 | - if(!empty($args['row']['close'])){ |
|
| 3912 | + if (!empty($args['row']['close'])) { |
|
| 3913 | 3913 | echo "</div></div>"; |
| 3914 | 3914 | } |
| 3915 | 3915 | |
@@ -3925,7 +3925,7 @@ discard block |
||
| 3925 | 3925 | public function widget_advanced_toggle() { |
| 3926 | 3926 | |
| 3927 | 3927 | $output = ''; |
| 3928 | - if ( $this->block_show_advanced() ) { |
|
| 3928 | + if ($this->block_show_advanced()) { |
|
| 3929 | 3929 | $val = 1; |
| 3930 | 3930 | } else { |
| 3931 | 3931 | $val = 0; |
@@ -3945,14 +3945,14 @@ discard block |
||
| 3945 | 3945 | *@since 1.0.0 |
| 3946 | 3946 | * |
| 3947 | 3947 | */ |
| 3948 | - public function convert_element_require( $input ) { |
|
| 3948 | + public function convert_element_require($input) { |
|
| 3949 | 3949 | |
| 3950 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 3950 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
| 3951 | 3951 | |
| 3952 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 3952 | + $output = esc_attr(str_replace(array("[%", "%]"), array( |
|
| 3953 | 3953 | "jQuery(form).find('[data-argument=\"", |
| 3954 | 3954 | "\"]').find('input,select,textarea').val()" |
| 3955 | - ), $input ) ); |
|
| 3955 | + ), $input)); |
|
| 3956 | 3956 | |
| 3957 | 3957 | return $output; |
| 3958 | 3958 | } |
@@ -3963,56 +3963,56 @@ discard block |
||
| 3963 | 3963 | * @param $args |
| 3964 | 3964 | * @param $instance |
| 3965 | 3965 | */ |
| 3966 | - public function widget_inputs( $args, $instance ) { |
|
| 3966 | + public function widget_inputs($args, $instance) { |
|
| 3967 | 3967 | |
| 3968 | 3968 | $class = ""; |
| 3969 | 3969 | $element_require = ""; |
| 3970 | 3970 | $custom_attributes = ""; |
| 3971 | 3971 | |
| 3972 | 3972 | // get value |
| 3973 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 3974 | - $value = $instance[ $args['name'] ]; |
|
| 3975 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 3976 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 3973 | + if (isset($instance[$args['name']])) { |
|
| 3974 | + $value = $instance[$args['name']]; |
|
| 3975 | + } elseif (!isset($instance[$args['name']]) && !empty($args['default'])) { |
|
| 3976 | + $value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']); |
|
| 3977 | 3977 | } else { |
| 3978 | 3978 | $value = ''; |
| 3979 | 3979 | } |
| 3980 | 3980 | |
| 3981 | 3981 | // get placeholder |
| 3982 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 3983 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 3982 | + if (!empty($args['placeholder'])) { |
|
| 3983 | + $placeholder = "placeholder='" . esc_html($args['placeholder']) . "'"; |
|
| 3984 | 3984 | } else { |
| 3985 | 3985 | $placeholder = ''; |
| 3986 | 3986 | } |
| 3987 | 3987 | |
| 3988 | 3988 | // get if advanced |
| 3989 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 3989 | + if (isset($args['advanced']) && $args['advanced']) { |
|
| 3990 | 3990 | $class .= " sd-advanced-setting "; |
| 3991 | 3991 | } |
| 3992 | 3992 | |
| 3993 | 3993 | // element_require |
| 3994 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 3994 | + if (isset($args['element_require']) && $args['element_require']) { |
|
| 3995 | 3995 | $element_require = $args['element_require']; |
| 3996 | 3996 | } |
| 3997 | 3997 | |
| 3998 | 3998 | // custom_attributes |
| 3999 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4000 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 3999 | + if (isset($args['custom_attributes']) && $args['custom_attributes']) { |
|
| 4000 | + $custom_attributes = $this->array_to_attributes($args['custom_attributes'], true); |
|
| 4001 | 4001 | } |
| 4002 | 4002 | |
| 4003 | 4003 | |
| 4004 | 4004 | // before wrapper |
| 4005 | 4005 | ?> |
| 4006 | - <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
|
| 4007 | - data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
|
| 4008 | - data-element_require='<?php if ( $element_require ) { |
|
| 4009 | - echo $this->convert_element_require( $element_require ); |
|
| 4006 | + <p class="sd-argument <?php echo esc_attr($class); ?>" |
|
| 4007 | + data-argument='<?php echo esc_attr($args['name']); ?>' |
|
| 4008 | + data-element_require='<?php if ($element_require) { |
|
| 4009 | + echo $this->convert_element_require($element_require); |
|
| 4010 | 4010 | } ?>' |
| 4011 | 4011 | > |
| 4012 | 4012 | <?php |
| 4013 | 4013 | |
| 4014 | 4014 | |
| 4015 | - switch ( $args['type'] ) { |
|
| 4015 | + switch ($args['type']) { |
|
| 4016 | 4016 | //array('text','password','number','email','tel','url','color') |
| 4017 | 4017 | case "text": |
| 4018 | 4018 | case "password": |
@@ -4023,46 +4023,46 @@ discard block |
||
| 4023 | 4023 | case "color": |
| 4024 | 4024 | ?> |
| 4025 | 4025 | <label |
| 4026 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 4026 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 4027 | 4027 | <input <?php echo $placeholder; ?> class="widefat" |
| 4028 | 4028 | <?php echo $custom_attributes; ?> |
| 4029 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4030 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
| 4031 | - type="<?php echo esc_attr( $args['type'] ); ?>" |
|
| 4032 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 4029 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4030 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
| 4031 | + type="<?php echo esc_attr($args['type']); ?>" |
|
| 4032 | + value="<?php echo esc_attr($value); ?>"> |
|
| 4033 | 4033 | <?php |
| 4034 | 4034 | |
| 4035 | 4035 | break; |
| 4036 | 4036 | case "select": |
| 4037 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4038 | - if ( $multiple ) { |
|
| 4039 | - if ( empty( $value ) ) { |
|
| 4037 | + $multiple = isset($args['multiple']) && $args['multiple'] ? true : false; |
|
| 4038 | + if ($multiple) { |
|
| 4039 | + if (empty($value)) { |
|
| 4040 | 4040 | $value = array(); |
| 4041 | 4041 | } |
| 4042 | 4042 | } |
| 4043 | 4043 | ?> |
| 4044 | 4044 | <label |
| 4045 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 4045 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 4046 | 4046 | <select <?php echo $placeholder; ?> class="widefat" |
| 4047 | 4047 | <?php echo $custom_attributes; ?> |
| 4048 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4049 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
|
| 4050 | - if ( $multiple ) { |
|
| 4048 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4049 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); |
|
| 4050 | + if ($multiple) { |
|
| 4051 | 4051 | echo "[]"; |
| 4052 | 4052 | } ?>" |
| 4053 | - <?php if ( $multiple ) { |
|
| 4053 | + <?php if ($multiple) { |
|
| 4054 | 4054 | echo "multiple"; |
| 4055 | 4055 | } //@todo not implemented yet due to gutenberg not supporting it |
| 4056 | 4056 | ?> |
| 4057 | 4057 | > |
| 4058 | 4058 | <?php |
| 4059 | 4059 | |
| 4060 | - if ( ! empty( $args['options'] ) ) { |
|
| 4061 | - foreach ( $args['options'] as $val => $label ) { |
|
| 4062 | - if ( $multiple ) { |
|
| 4063 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4060 | + if (!empty($args['options'])) { |
|
| 4061 | + foreach ($args['options'] as $val => $label) { |
|
| 4062 | + if ($multiple) { |
|
| 4063 | + $selected = in_array($val, $value) ? 'selected="selected"' : ''; |
|
| 4064 | 4064 | } else { |
| 4065 | - $selected = selected( $value, $val, false ); |
|
| 4065 | + $selected = selected($value, $val, false); |
|
| 4066 | 4066 | } |
| 4067 | 4067 | echo "<option value='$val' " . $selected . ">$label</option>"; |
| 4068 | 4068 | } |
@@ -4074,32 +4074,32 @@ discard block |
||
| 4074 | 4074 | case "checkbox": |
| 4075 | 4075 | ?> |
| 4076 | 4076 | <input <?php echo $placeholder; ?> |
| 4077 | - <?php checked( 1, $value, true ) ?> |
|
| 4077 | + <?php checked(1, $value, true) ?> |
|
| 4078 | 4078 | <?php echo $custom_attributes; ?> |
| 4079 | - class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4080 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" |
|
| 4079 | + class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4080 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox" |
|
| 4081 | 4081 | value="1"> |
| 4082 | 4082 | <label |
| 4083 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 4083 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 4084 | 4084 | <?php |
| 4085 | 4085 | break; |
| 4086 | 4086 | case "textarea": |
| 4087 | 4087 | ?> |
| 4088 | 4088 | <label |
| 4089 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 4089 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 4090 | 4090 | <textarea <?php echo $placeholder; ?> class="widefat" |
| 4091 | 4091 | <?php echo $custom_attributes; ?> |
| 4092 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4093 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
| 4094 | - ><?php echo esc_attr( $value ); ?></textarea> |
|
| 4092 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4093 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
| 4094 | + ><?php echo esc_attr($value); ?></textarea> |
|
| 4095 | 4095 | <?php |
| 4096 | 4096 | |
| 4097 | 4097 | break; |
| 4098 | 4098 | case "hidden": |
| 4099 | 4099 | ?> |
| 4100 | - <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4101 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
|
| 4102 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 4100 | + <input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4101 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden" |
|
| 4102 | + value="<?php echo esc_attr($value); ?>"> |
|
| 4103 | 4103 | <?php |
| 4104 | 4104 | break; |
| 4105 | 4105 | default: |
@@ -4114,15 +4114,15 @@ discard block |
||
| 4114 | 4114 | |
| 4115 | 4115 | } |
| 4116 | 4116 | |
| 4117 | - public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4118 | - if($icon=='box-top'){ |
|
| 4119 | - 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>'; |
|
| 4120 | - }elseif($icon=='box-right'){ |
|
| 4121 | - 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>'; |
|
| 4122 | - }elseif($icon=='box-bottom'){ |
|
| 4123 | - 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>'; |
|
| 4124 | - }elseif($icon=='box-left'){ |
|
| 4125 | - 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>'; |
|
| 4117 | + public function get_widget_icon($icon = 'box-top', $title = '') { |
|
| 4118 | + if ($icon == 'box-top') { |
|
| 4119 | + 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>'; |
|
| 4120 | + }elseif ($icon == 'box-right') { |
|
| 4121 | + 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>'; |
|
| 4122 | + }elseif ($icon == 'box-bottom') { |
|
| 4123 | + 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>'; |
|
| 4124 | + }elseif ($icon == 'box-left') { |
|
| 4125 | + 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>'; |
|
| 4126 | 4126 | } |
| 4127 | 4127 | } |
| 4128 | 4128 | |
@@ -4134,14 +4134,14 @@ discard block |
||
| 4134 | 4134 | * @return string |
| 4135 | 4135 | * @todo, need to make its own tooltip script |
| 4136 | 4136 | */ |
| 4137 | - public function widget_field_desc( $args ) { |
|
| 4137 | + public function widget_field_desc($args) { |
|
| 4138 | 4138 | |
| 4139 | 4139 | $description = ''; |
| 4140 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4141 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4142 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 4140 | + if (isset($args['desc']) && $args['desc']) { |
|
| 4141 | + if (isset($args['desc_tip']) && $args['desc_tip']) { |
|
| 4142 | + $description = $this->desc_tip($args['desc']); |
|
| 4143 | 4143 | } else { |
| 4144 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4144 | + $description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>'; |
|
| 4145 | 4145 | } |
| 4146 | 4146 | } |
| 4147 | 4147 | |
@@ -4155,12 +4155,12 @@ discard block |
||
| 4155 | 4155 | * |
| 4156 | 4156 | * @return string |
| 4157 | 4157 | */ |
| 4158 | - public function widget_field_title( $args ) { |
|
| 4158 | + public function widget_field_title($args) { |
|
| 4159 | 4159 | |
| 4160 | 4160 | $title = ''; |
| 4161 | - if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4162 | - if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4163 | - $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4161 | + if (isset($args['title']) && $args['title']) { |
|
| 4162 | + if (isset($args['icon']) && $args['icon']) { |
|
| 4163 | + $title = self::get_widget_icon($args['icon'], $args['title']); |
|
| 4164 | 4164 | } else { |
| 4165 | 4165 | $title = esc_attr($args['title']); |
| 4166 | 4166 | } |
@@ -4177,11 +4177,11 @@ discard block |
||
| 4177 | 4177 | * |
| 4178 | 4178 | * @return string |
| 4179 | 4179 | */ |
| 4180 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 4181 | - if ( $allow_html ) { |
|
| 4182 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 4180 | + function desc_tip($tip, $allow_html = false) { |
|
| 4181 | + if ($allow_html) { |
|
| 4182 | + $tip = $this->sanitize_tooltip($tip); |
|
| 4183 | 4183 | } else { |
| 4184 | - $tip = esc_attr( $tip ); |
|
| 4184 | + $tip = esc_attr($tip); |
|
| 4185 | 4185 | } |
| 4186 | 4186 | |
| 4187 | 4187 | return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -4194,8 +4194,8 @@ discard block |
||
| 4194 | 4194 | * |
| 4195 | 4195 | * @return string |
| 4196 | 4196 | */ |
| 4197 | - public function sanitize_tooltip( $var ) { |
|
| 4198 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4197 | + public function sanitize_tooltip($var) { |
|
| 4198 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 4199 | 4199 | 'br' => array(), |
| 4200 | 4200 | 'em' => array(), |
| 4201 | 4201 | 'strong' => array(), |
@@ -4205,7 +4205,7 @@ discard block |
||
| 4205 | 4205 | 'li' => array(), |
| 4206 | 4206 | 'ol' => array(), |
| 4207 | 4207 | 'p' => array(), |
| 4208 | - ) ) ); |
|
| 4208 | + ))); |
|
| 4209 | 4209 | } |
| 4210 | 4210 | |
| 4211 | 4211 | /** |
@@ -4217,23 +4217,23 @@ discard block |
||
| 4217 | 4217 | * @return array |
| 4218 | 4218 | * @todo we should add some sanitation here. |
| 4219 | 4219 | */ |
| 4220 | - public function update( $new_instance, $old_instance ) { |
|
| 4220 | + public function update($new_instance, $old_instance) { |
|
| 4221 | 4221 | |
| 4222 | 4222 | //save the widget |
| 4223 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4223 | + $instance = array_merge((array) $old_instance, (array) $new_instance); |
|
| 4224 | 4224 | |
| 4225 | 4225 | // set widget instance |
| 4226 | 4226 | $this->instance = $instance; |
| 4227 | 4227 | |
| 4228 | - if ( empty( $this->arguments ) ) { |
|
| 4228 | + if (empty($this->arguments)) { |
|
| 4229 | 4229 | $this->get_arguments(); |
| 4230 | 4230 | } |
| 4231 | 4231 | |
| 4232 | 4232 | // check for checkboxes |
| 4233 | - if ( ! empty( $this->arguments ) ) { |
|
| 4234 | - foreach ( $this->arguments as $argument ) { |
|
| 4235 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4236 | - $instance[ $argument['name'] ] = '0'; |
|
| 4233 | + if (!empty($this->arguments)) { |
|
| 4234 | + foreach ($this->arguments as $argument) { |
|
| 4235 | + if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) { |
|
| 4236 | + $instance[$argument['name']] = '0'; |
|
| 4237 | 4237 | } |
| 4238 | 4238 | } |
| 4239 | 4239 | } |
@@ -4251,7 +4251,7 @@ discard block |
||
| 4251 | 4251 | */ |
| 4252 | 4252 | public function is_block_content_call() { |
| 4253 | 4253 | $result = false; |
| 4254 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4254 | + if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') { |
|
| 4255 | 4255 | $result = true; |
| 4256 | 4256 | } |
| 4257 | 4257 | |
@@ -4264,9 +4264,9 @@ discard block |
||
| 4264 | 4264 | * @return string |
| 4265 | 4265 | *@since 1.0.20 |
| 4266 | 4266 | */ |
| 4267 | - public function get_instance_hash(){ |
|
| 4268 | - $instance_string = $this->base_id.serialize($this->instance); |
|
| 4269 | - return hash('crc32b',$instance_string); |
|
| 4267 | + public function get_instance_hash() { |
|
| 4268 | + $instance_string = $this->base_id . serialize($this->instance); |
|
| 4269 | + return hash('crc32b', $instance_string); |
|
| 4270 | 4270 | } |
| 4271 | 4271 | |
| 4272 | 4272 | /** |
@@ -4277,14 +4277,14 @@ discard block |
||
| 4277 | 4277 | * @return string |
| 4278 | 4278 | *@since 1.0.20 |
| 4279 | 4279 | */ |
| 4280 | - public function get_instance_style($rules = array()){ |
|
| 4280 | + public function get_instance_style($rules = array()) { |
|
| 4281 | 4281 | $css = ''; |
| 4282 | 4282 | |
| 4283 | - if(!empty($rules)){ |
|
| 4283 | + if (!empty($rules)) { |
|
| 4284 | 4284 | $rules = array_unique($rules); |
| 4285 | 4285 | $instance_hash = $this->get_instance_hash(); |
| 4286 | 4286 | $css .= "<style>"; |
| 4287 | - foreach($rules as $rule){ |
|
| 4287 | + foreach ($rules as $rule) { |
|
| 4288 | 4288 | $css .= ".sdel-$instance_hash $rule"; |
| 4289 | 4289 | } |
| 4290 | 4290 | $css .= "</style>"; |
@@ -4302,9 +4302,9 @@ discard block |
||
| 4302 | 4302 | *@since 1.0.28 |
| 4303 | 4303 | * |
| 4304 | 4304 | */ |
| 4305 | - public function encode_shortcodes( $content ) { |
|
| 4305 | + public function encode_shortcodes($content) { |
|
| 4306 | 4306 | // Avoids existing encoded tags. |
| 4307 | - $trans = array( |
|
| 4307 | + $trans = array( |
|
| 4308 | 4308 | '[' => '[', |
| 4309 | 4309 | ']' => ']', |
| 4310 | 4310 | '&#91;' => '[', |
@@ -4315,7 +4315,7 @@ discard block |
||
| 4315 | 4315 | '&gt;' => '&0gt;', |
| 4316 | 4316 | ); |
| 4317 | 4317 | |
| 4318 | - $content = strtr( $content, $trans ); |
|
| 4318 | + $content = strtr($content, $trans); |
|
| 4319 | 4319 | |
| 4320 | 4320 | $trans = array( |
| 4321 | 4321 | '[' => '[', |
@@ -4326,7 +4326,7 @@ discard block |
||
| 4326 | 4326 | "'" => ''', |
| 4327 | 4327 | ); |
| 4328 | 4328 | |
| 4329 | - $content = strtr( $content, $trans ); |
|
| 4329 | + $content = strtr($content, $trans); |
|
| 4330 | 4330 | |
| 4331 | 4331 | return $content; |
| 4332 | 4332 | } |
@@ -4340,8 +4340,8 @@ discard block |
||
| 4340 | 4340 | *@since 1.0.28 |
| 4341 | 4341 | * |
| 4342 | 4342 | */ |
| 4343 | - public function decode_shortcodes( $content ) { |
|
| 4344 | - $trans = array( |
|
| 4343 | + public function decode_shortcodes($content) { |
|
| 4344 | + $trans = array( |
|
| 4345 | 4345 | '[' => '[', |
| 4346 | 4346 | ']' => ']', |
| 4347 | 4347 | '&#91;' => '[', |
@@ -4354,7 +4354,7 @@ discard block |
||
| 4354 | 4354 | ''' => "'", |
| 4355 | 4355 | ); |
| 4356 | 4356 | |
| 4357 | - $content = strtr( $content, $trans ); |
|
| 4357 | + $content = strtr($content, $trans); |
|
| 4358 | 4358 | |
| 4359 | 4359 | $trans = array( |
| 4360 | 4360 | '[' => '[', |
@@ -4367,7 +4367,7 @@ discard block |
||
| 4367 | 4367 | '&0gt;' => '>', |
| 4368 | 4368 | ); |
| 4369 | 4369 | |
| 4370 | - $content = strtr( $content, $trans ); |
|
| 4370 | + $content = strtr($content, $trans); |
|
| 4371 | 4371 | |
| 4372 | 4372 | return $content; |
| 4373 | 4373 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if(!empty($this->options['nested-block'])){ |
| 60 | 60 | if(empty($this->options['output_types'])){ |
| 61 | 61 | $this->options['output_types'] = array('shortcode','block'); |
| 62 | - }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { |
|
| 62 | + } elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { |
|
| 63 | 63 | unset($this->options['output_types'][$key]); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | <?php |
| 699 | 699 | if(! empty( $insert_shortcode_function )){ |
| 700 | 700 | echo $insert_shortcode_function; |
| 701 | - }else{ |
|
| 701 | + } else{ |
|
| 702 | 702 | |
| 703 | 703 | /** |
| 704 | 704 | * Function for super duper insert shortcode. |
@@ -2070,7 +2070,7 @@ discard block |
||
| 2070 | 2070 | var InnerBlocks = blockEditor.InnerBlocks; |
| 2071 | 2071 | |
| 2072 | 2072 | var term_query_type = ''; |
| 2073 | - 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 "[]";} ?>; |
|
| 2073 | + 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 "[]";} ?>; |
|
| 2074 | 2074 | const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
| 2075 | 2075 | const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
| 2076 | 2076 | const MediaUpload = wp.blockEditor.MediaUpload; |
@@ -2189,8 +2189,7 @@ discard block |
||
| 2189 | 2189 | |
| 2190 | 2190 | if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
| 2191 | 2191 | continue; |
| 2192 | - } |
|
| 2193 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2192 | + } elseif ( $args['type'] == 'checkbox' ) { |
|
| 2194 | 2193 | $type = 'boolean'; |
| 2195 | 2194 | $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
| 2196 | 2195 | } elseif ( $args['type'] == 'number' ) { |
@@ -2315,7 +2314,7 @@ discard block |
||
| 2315 | 2314 | <?php |
| 2316 | 2315 | if(!empty($this->options['block-edit-raw'])) { |
| 2317 | 2316 | echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues |
| 2318 | - }else{ |
|
| 2317 | + } else{ |
|
| 2319 | 2318 | ?> |
| 2320 | 2319 | |
| 2321 | 2320 | function hasSelectedInnerBlock(props) { |
@@ -2356,7 +2355,7 @@ discard block |
||
| 2356 | 2355 | |
| 2357 | 2356 | // taxonomies |
| 2358 | 2357 | if( $value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run ){ |
| 2359 | - wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];}else{'/wp/v2/"+$value+"/categories/?per_page=100';} ?>"}).then(terms => { |
|
| 2358 | + wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];} else{'/wp/v2/"+$value+"/categories/?per_page=100';} ?>"}).then(terms => { |
|
| 2360 | 2359 | while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) { |
| 2361 | 2360 | taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop(); |
| 2362 | 2361 | } |
@@ -2433,7 +2432,7 @@ discard block |
||
| 2433 | 2432 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
| 2434 | 2433 | 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
| 2435 | 2434 | echo $post->ID; |
| 2436 | - }else{echo '0';}?>, |
|
| 2435 | + } else{echo '0';}?>, |
|
| 2437 | 2436 | '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
| 2438 | 2437 | }; |
| 2439 | 2438 | |
@@ -2453,7 +2452,7 @@ discard block |
||
| 2453 | 2452 | is_fetching = false; |
| 2454 | 2453 | prev_attributes[props.clientId] = props.attributes; |
| 2455 | 2454 | <?php |
| 2456 | - }else{ |
|
| 2455 | + } else{ |
|
| 2457 | 2456 | ?> |
| 2458 | 2457 | props.setAttributes({content: env}); |
| 2459 | 2458 | is_fetching = false; |
@@ -2632,7 +2631,7 @@ discard block |
||
| 2632 | 2631 | // |
| 2633 | 2632 | |
| 2634 | 2633 | } |
| 2635 | - }else { |
|
| 2634 | + } else { |
|
| 2636 | 2635 | ?> |
| 2637 | 2636 | el(wp.components.PanelBody, { |
| 2638 | 2637 | title: '<?php esc_attr_e( "Settings" ); ?>', |
@@ -2658,9 +2657,9 @@ discard block |
||
| 2658 | 2657 | // If the user sets block-output array then build it |
| 2659 | 2658 | if ( ! empty( $this->options['block-output'] ) ) { |
| 2660 | 2659 | $this->block_element( $this->options['block-output'] ); |
| 2661 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2660 | + } elseif(!empty($this->options['block-edit-return'])){ |
|
| 2662 | 2661 | echo $this->options['block-edit-return']; |
| 2663 | - }else{ |
|
| 2662 | + } else{ |
|
| 2664 | 2663 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 2665 | 2664 | ?> |
| 2666 | 2665 | el('div', wp.blockEditor.useBlockProps({ |
@@ -2764,9 +2763,9 @@ discard block |
||
| 2764 | 2763 | ); |
| 2765 | 2764 | <?php |
| 2766 | 2765 | |
| 2767 | - }elseif(!empty($this->options['block-save-return'])){ |
|
| 2766 | + } elseif(!empty($this->options['block-save-return'])){ |
|
| 2768 | 2767 | echo 'return ' . $this->options['block-save-return']; |
| 2769 | - }elseif(!empty($this->options['nested-block'])){ |
|
| 2768 | + } elseif(!empty($this->options['nested-block'])){ |
|
| 2770 | 2769 | ?> |
| 2771 | 2770 | return el( |
| 2772 | 2771 | '', |
@@ -2776,13 +2775,13 @@ discard block |
||
| 2776 | 2775 | el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
| 2777 | 2776 | ); |
| 2778 | 2777 | <?php |
| 2779 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2778 | + } elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2780 | 2779 | echo "return ". $this->options['block-edit-return'].";"; |
| 2781 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2780 | + } elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2782 | 2781 | ?> |
| 2783 | 2782 | return content; |
| 2784 | 2783 | <?php |
| 2785 | - }else{ |
|
| 2784 | + } else{ |
|
| 2786 | 2785 | ?> |
| 2787 | 2786 | var block_wrap = 'div'; |
| 2788 | 2787 | if (attr.hasOwnProperty("block_wrap")) { |
@@ -2833,9 +2832,9 @@ discard block |
||
| 2833 | 2832 | $device_type_icon = ''; |
| 2834 | 2833 | if($device_type=='Desktop'){ |
| 2835 | 2834 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;"></span>'; |
| 2836 | - }elseif($device_type=='Tablet'){ |
|
| 2835 | + } elseif($device_type=='Tablet'){ |
|
| 2837 | 2836 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;"></span>'; |
| 2838 | - }elseif($device_type=='Mobile'){ |
|
| 2837 | + } elseif($device_type=='Mobile'){ |
|
| 2839 | 2838 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;"></span>'; |
| 2840 | 2839 | } |
| 2841 | 2840 | echo $element_require; |
@@ -2880,7 +2879,7 @@ discard block |
||
| 2880 | 2879 | |
| 2881 | 2880 | <?php |
| 2882 | 2881 | if(false){?></script><?php } |
| 2883 | - }elseif(!empty($args['row']['close'])){ |
|
| 2882 | + } elseif(!empty($args['row']['close'])){ |
|
| 2884 | 2883 | if(false){?><script><?php }?> |
| 2885 | 2884 | el( |
| 2886 | 2885 | 'div', |
@@ -2889,7 +2888,7 @@ discard block |
||
| 2889 | 2888 | }, |
| 2890 | 2889 | <?php |
| 2891 | 2890 | if(false){?></script><?php } |
| 2892 | - }else{ |
|
| 2891 | + } else{ |
|
| 2893 | 2892 | if(false){?><script><?php }?> |
| 2894 | 2893 | el( |
| 2895 | 2894 | 'div', |
@@ -2997,9 +2996,9 @@ discard block |
||
| 2997 | 2996 | $device_type_icon = ''; |
| 2998 | 2997 | if($device_type=='Desktop'){ |
| 2999 | 2998 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;"></span>'; |
| 3000 | - }elseif($device_type=='Tablet'){ |
|
| 2999 | + } elseif($device_type=='Tablet'){ |
|
| 3001 | 3000 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;"></span>'; |
| 3002 | - }elseif($device_type=='Mobile'){ |
|
| 3001 | + } elseif($device_type=='Mobile'){ |
|
| 3003 | 3002 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;"></span>'; |
| 3004 | 3003 | } |
| 3005 | 3004 | |
@@ -3033,12 +3032,12 @@ discard block |
||
| 3033 | 3032 | if ( $args['type'] == 'number' ) { |
| 3034 | 3033 | $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
| 3035 | 3034 | } |
| 3036 | - }else if ( $args['type'] == 'styleid' ) { |
|
| 3035 | + } else if ( $args['type'] == 'styleid' ) { |
|
| 3037 | 3036 | $type = 'TextControl'; |
| 3038 | 3037 | $args['type'] == 'text'; |
| 3039 | 3038 | // Save numbers as numbers and not strings |
| 3040 | 3039 | $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
| 3041 | - }else if ( $args['type'] == 'notice' ) { |
|
| 3040 | + } else if ( $args['type'] == 'notice' ) { |
|
| 3042 | 3041 | |
| 3043 | 3042 | $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
| 3044 | 3043 | $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
@@ -3113,10 +3112,10 @@ discard block |
||
| 3113 | 3112 | $key: value |
| 3114 | 3113 | }); |
| 3115 | 3114 | },"; |
| 3116 | - }elseif ( $args['type'] == 'gradient' ) { |
|
| 3115 | + } elseif ( $args['type'] == 'gradient' ) { |
|
| 3117 | 3116 | $type = 'GradientPicker'; |
| 3118 | 3117 | |
| 3119 | - }elseif ( $args['type'] == 'image' ) { |
|
| 3118 | + } elseif ( $args['type'] == 'image' ) { |
|
| 3120 | 3119 | // print_r($args); |
| 3121 | 3120 | |
| 3122 | 3121 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? "props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " props.attributes.$key && el(wp.components.FocalPointPicker,{ |
@@ -3176,7 +3175,7 @@ discard block |
||
| 3176 | 3175 | $onchange = ""; |
| 3177 | 3176 | |
| 3178 | 3177 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3179 | - }elseif ( $args['type'] == 'images' ) { |
|
| 3178 | + } elseif ( $args['type'] == 'images' ) { |
|
| 3180 | 3179 | // print_r($args); |
| 3181 | 3180 | |
| 3182 | 3181 | $img_preview = "props.attributes.$key && (function() { |
@@ -3261,8 +3260,7 @@ discard block |
||
| 3261 | 3260 | $onchange = ""; |
| 3262 | 3261 | |
| 3263 | 3262 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3264 | - } |
|
| 3265 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 3263 | + } elseif ( $args['type'] == 'checkbox' ) { |
|
| 3266 | 3264 | $type = 'CheckboxControl'; |
| 3267 | 3265 | $extra .= "checked: props.attributes.$key,"; |
| 3268 | 3266 | $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
@@ -3273,9 +3271,9 @@ discard block |
||
| 3273 | 3271 | |
| 3274 | 3272 | if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
| 3275 | 3273 | $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
| 3276 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3274 | + } elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3277 | 3275 | $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
| 3278 | - }else { |
|
| 3276 | + } else { |
|
| 3279 | 3277 | |
| 3280 | 3278 | if ( ! empty( $args['options'] ) ) { |
| 3281 | 3279 | $options .= "options: ["; |
@@ -3290,7 +3288,7 @@ discard block |
||
| 3290 | 3288 | } |
| 3291 | 3289 | } elseif ( $args['type'] == 'alignment' ) { |
| 3292 | 3290 | $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
| 3293 | - }elseif ( $args['type'] == 'margins' ) { |
|
| 3291 | + } elseif ( $args['type'] == 'margins' ) { |
|
| 3294 | 3292 | |
| 3295 | 3293 | } else { |
| 3296 | 3294 | return;// if we have not implemented the control then don't break the JS. |
@@ -3320,7 +3318,7 @@ discard block |
||
| 3320 | 3318 | label: <?php |
| 3321 | 3319 | if(empty($args['title'])){ |
| 3322 | 3320 | echo "''"; |
| 3323 | - }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3321 | + } elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3324 | 3322 | ?>el('label', { |
| 3325 | 3323 | className: 'components-base-control__label', |
| 3326 | 3324 | style: {width:"100%"} |
@@ -3335,7 +3333,7 @@ discard block |
||
| 3335 | 3333 | |
| 3336 | 3334 | )<?php |
| 3337 | 3335 | |
| 3338 | - }else{ |
|
| 3336 | + } else{ |
|
| 3339 | 3337 | ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
| 3340 | 3338 | |
| 3341 | 3339 | } |
@@ -3343,7 +3341,7 @@ discard block |
||
| 3343 | 3341 | ?>, |
| 3344 | 3342 | help: <?php if ( isset( $args['desc'] ) ) { |
| 3345 | 3343 | echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
| 3346 | - }else{ echo "''"; } ?>, |
|
| 3344 | + } else{ echo "''"; } ?>, |
|
| 3347 | 3345 | value: <?php echo $value; ?>, |
| 3348 | 3346 | <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
| 3349 | 3347 | echo "type: '" . addslashes( $args['type'] ) . "',"; |
@@ -3383,7 +3381,7 @@ discard block |
||
| 3383 | 3381 | foreach ( $custom_attributes as $key => $val ) { |
| 3384 | 3382 | if(is_array($val)){ |
| 3385 | 3383 | $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
| 3386 | - }else{ |
|
| 3384 | + } else{ |
|
| 3387 | 3385 | $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
| 3388 | 3386 | } |
| 3389 | 3387 | } |
@@ -3423,7 +3421,7 @@ discard block |
||
| 3423 | 3421 | |
| 3424 | 3422 | if($new_args['element']=='InnerBlocks'){ |
| 3425 | 3423 | echo "\n el( InnerBlocks, {"; |
| 3426 | - }elseif($new_args['element']=='innerBlocksProps'){ |
|
| 3424 | + } elseif($new_args['element']=='innerBlocksProps'){ |
|
| 3427 | 3425 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3428 | 3426 | // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
| 3429 | 3427 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
@@ -3436,11 +3434,11 @@ discard block |
||
| 3436 | 3434 | // echo '###'; |
| 3437 | 3435 | |
| 3438 | 3436 | // echo '###'; |
| 3439 | - }elseif($new_args['element']=='BlocksProps'){ |
|
| 3437 | + } elseif($new_args['element']=='BlocksProps'){ |
|
| 3440 | 3438 | |
| 3441 | 3439 | if ( isset($new_args['if_inner_element']) ) { |
| 3442 | 3440 | $element = $new_args['if_inner_element']; |
| 3443 | - }else { |
|
| 3441 | + } else { |
|
| 3444 | 3442 | $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
| 3445 | 3443 | } |
| 3446 | 3444 | |
@@ -3451,7 +3449,7 @@ discard block |
||
| 3451 | 3449 | |
| 3452 | 3450 | // echo "} ),"; |
| 3453 | 3451 | |
| 3454 | - }else{ |
|
| 3452 | + } else{ |
|
| 3455 | 3453 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 3456 | 3454 | } |
| 3457 | 3455 | |
@@ -3476,7 +3474,7 @@ discard block |
||
| 3476 | 3474 | |
| 3477 | 3475 | if ( $new_key === 'content' ) { |
| 3478 | 3476 | echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
| 3479 | - }else if ( $new_key === 'if_content' ) { |
|
| 3477 | + } else if ( $new_key === 'if_content' ) { |
|
| 3480 | 3478 | echo $this->block_props_replace( $new_value ); |
| 3481 | 3479 | } |
| 3482 | 3480 | |
@@ -3506,7 +3504,7 @@ discard block |
||
| 3506 | 3504 | |
| 3507 | 3505 | if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
| 3508 | 3506 | echo "))";// end content |
| 3509 | - }else{ |
|
| 3507 | + } else{ |
|
| 3510 | 3508 | echo ")";// end content |
| 3511 | 3509 | } |
| 3512 | 3510 | |
@@ -3792,7 +3790,7 @@ discard block |
||
| 3792 | 3790 | |
| 3793 | 3791 | if(empty($instance['widget_title_tag'])){ |
| 3794 | 3792 | $output = $args['before_title'] . $title . $args['after_title']; |
| 3795 | - }else{ |
|
| 3793 | + } else{ |
|
| 3796 | 3794 | $title_tag = esc_attr( $instance['widget_title_tag'] ); |
| 3797 | 3795 | |
| 3798 | 3796 | // classes |
@@ -3897,9 +3895,9 @@ discard block |
||
| 3897 | 3895 | <div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'> |
| 3898 | 3896 | <div class='col pr-2'> |
| 3899 | 3897 | <?php |
| 3900 | - }elseif(!empty($args['row']['close'])){ |
|
| 3898 | + } elseif(!empty($args['row']['close'])){ |
|
| 3901 | 3899 | echo "<div class='col pl-0'>"; |
| 3902 | - }else{ |
|
| 3900 | + } else{ |
|
| 3903 | 3901 | echo "<div class='col pl-0 pr-2'>"; |
| 3904 | 3902 | } |
| 3905 | 3903 | } |
@@ -4117,11 +4115,11 @@ discard block |
||
| 4117 | 4115 | public function get_widget_icon($icon = 'box-top', $title = ''){ |
| 4118 | 4116 | if($icon=='box-top'){ |
| 4119 | 4117 | 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>'; |
| 4120 | - }elseif($icon=='box-right'){ |
|
| 4118 | + } elseif($icon=='box-right'){ |
|
| 4121 | 4119 | 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>'; |
| 4122 | - }elseif($icon=='box-bottom'){ |
|
| 4120 | + } elseif($icon=='box-bottom'){ |
|
| 4123 | 4121 | 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>'; |
| 4124 | - }elseif($icon=='box-left'){ |
|
| 4122 | + } elseif($icon=='box-left'){ |
|
| 4125 | 4123 | 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>'; |
| 4126 | 4124 | } |
| 4127 | 4125 | } |
@@ -11,18 +11,18 @@ discard block |
||
| 11 | 11 | * @return mixed|void |
| 12 | 12 | */ |
| 13 | 13 | function sd_pagenow_exclude() { |
| 14 | - return apply_filters( 'sd_pagenow_exclude', array( |
|
| 15 | - 'upload.php', |
|
| 16 | - 'edit-comments.php', |
|
| 17 | - 'edit-tags.php', |
|
| 18 | - 'index.php', |
|
| 19 | - 'media-new.php', |
|
| 20 | - 'options-discussion.php', |
|
| 21 | - 'options-writing.php', |
|
| 22 | - 'edit.php', |
|
| 23 | - 'themes.php', |
|
| 24 | - 'users.php', |
|
| 25 | - ) ); |
|
| 14 | + return apply_filters( 'sd_pagenow_exclude', array( |
|
| 15 | + 'upload.php', |
|
| 16 | + 'edit-comments.php', |
|
| 17 | + 'edit-tags.php', |
|
| 18 | + 'index.php', |
|
| 19 | + 'media-new.php', |
|
| 20 | + 'options-discussion.php', |
|
| 21 | + 'options-writing.php', |
|
| 22 | + 'edit.php', |
|
| 23 | + 'themes.php', |
|
| 24 | + 'users.php', |
|
| 25 | + ) ); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return mixed|void |
| 35 | 35 | */ |
| 36 | 36 | function sd_widget_exclude() { |
| 37 | - return apply_filters( 'sd_widget_exclude', array() ); |
|
| 37 | + return apply_filters( 'sd_widget_exclude', array() ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -47,70 +47,70 @@ discard block |
||
| 47 | 47 | * @return array |
| 48 | 48 | */ |
| 49 | 49 | function sd_get_margin_input( $type = 'mt', $overwrite = array(), $include_negatives = true ) { |
| 50 | - $options = array( |
|
| 51 | - "" => __( 'None' ), |
|
| 52 | - "auto" => __( 'auto' ), |
|
| 53 | - "0" => "0", |
|
| 54 | - "1" => "1", |
|
| 55 | - "2" => "2", |
|
| 56 | - "3" => "3", |
|
| 57 | - "4" => "4", |
|
| 58 | - "5" => "5", |
|
| 59 | - ); |
|
| 60 | - |
|
| 61 | - if ( $include_negatives ) { |
|
| 62 | - $options['n1'] = '-1'; |
|
| 63 | - $options['n2'] = '-2'; |
|
| 64 | - $options['n3'] = '-3'; |
|
| 65 | - $options['n4'] = '-4'; |
|
| 66 | - $options['n5'] = '-5'; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $defaults = array( |
|
| 70 | - 'type' => 'select', |
|
| 71 | - 'title' => __( 'Margin top' ), |
|
| 72 | - 'options' => $options, |
|
| 73 | - 'default' => '', |
|
| 74 | - 'desc_tip' => true, |
|
| 75 | - 'group' => __( "Wrapper Styles", "geodirectory" ), |
|
| 50 | + $options = array( |
|
| 51 | + "" => __( 'None' ), |
|
| 52 | + "auto" => __( 'auto' ), |
|
| 53 | + "0" => "0", |
|
| 54 | + "1" => "1", |
|
| 55 | + "2" => "2", |
|
| 56 | + "3" => "3", |
|
| 57 | + "4" => "4", |
|
| 58 | + "5" => "5", |
|
| 59 | + ); |
|
| 60 | + |
|
| 61 | + if ( $include_negatives ) { |
|
| 62 | + $options['n1'] = '-1'; |
|
| 63 | + $options['n2'] = '-2'; |
|
| 64 | + $options['n3'] = '-3'; |
|
| 65 | + $options['n4'] = '-4'; |
|
| 66 | + $options['n5'] = '-5'; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $defaults = array( |
|
| 70 | + 'type' => 'select', |
|
| 71 | + 'title' => __( 'Margin top' ), |
|
| 72 | + 'options' => $options, |
|
| 73 | + 'default' => '', |
|
| 74 | + 'desc_tip' => true, |
|
| 75 | + 'group' => __( "Wrapper Styles", "geodirectory" ), |
|
| 76 | 76 | // 'device_type' => 'Desktop', |
| 77 | - ); |
|
| 78 | - |
|
| 79 | - // title |
|
| 80 | - if ( $type == 'mt' ) { |
|
| 81 | - $defaults['title'] = __( 'Margin top' ); |
|
| 82 | - $defaults['icon'] = 'box-top'; |
|
| 83 | - $defaults['row'] = array( |
|
| 84 | - 'title' => __( 'Margins' ), |
|
| 85 | - 'key' => 'wrapper-margins', |
|
| 86 | - 'open' => true, |
|
| 87 | - 'class' => 'text-center', |
|
| 88 | - ); |
|
| 89 | - } elseif ( $type == 'mr' ) { |
|
| 90 | - $defaults['title'] = __( 'Margin right' ); |
|
| 91 | - $defaults['icon'] = 'box-right'; |
|
| 92 | - $defaults['row'] = array( |
|
| 93 | - 'key' => 'wrapper-margins', |
|
| 94 | - ); |
|
| 95 | - } elseif ( $type == 'mb' ) { |
|
| 96 | - $defaults['title'] = __( 'Margin bottom' ); |
|
| 97 | - $defaults['icon'] = 'box-bottom'; |
|
| 98 | - $defaults['row'] = array( |
|
| 99 | - 'key' => 'wrapper-margins', |
|
| 100 | - ); |
|
| 101 | - } elseif ( $type == 'ml' ) { |
|
| 102 | - $defaults['title'] = __( 'Margin left' ); |
|
| 103 | - $defaults['icon'] = 'box-left'; |
|
| 104 | - $defaults['row'] = array( |
|
| 105 | - 'key' => 'wrapper-margins', |
|
| 106 | - 'close' => true, |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - return $input; |
|
| 77 | + ); |
|
| 78 | + |
|
| 79 | + // title |
|
| 80 | + if ( $type == 'mt' ) { |
|
| 81 | + $defaults['title'] = __( 'Margin top' ); |
|
| 82 | + $defaults['icon'] = 'box-top'; |
|
| 83 | + $defaults['row'] = array( |
|
| 84 | + 'title' => __( 'Margins' ), |
|
| 85 | + 'key' => 'wrapper-margins', |
|
| 86 | + 'open' => true, |
|
| 87 | + 'class' => 'text-center', |
|
| 88 | + ); |
|
| 89 | + } elseif ( $type == 'mr' ) { |
|
| 90 | + $defaults['title'] = __( 'Margin right' ); |
|
| 91 | + $defaults['icon'] = 'box-right'; |
|
| 92 | + $defaults['row'] = array( |
|
| 93 | + 'key' => 'wrapper-margins', |
|
| 94 | + ); |
|
| 95 | + } elseif ( $type == 'mb' ) { |
|
| 96 | + $defaults['title'] = __( 'Margin bottom' ); |
|
| 97 | + $defaults['icon'] = 'box-bottom'; |
|
| 98 | + $defaults['row'] = array( |
|
| 99 | + 'key' => 'wrapper-margins', |
|
| 100 | + ); |
|
| 101 | + } elseif ( $type == 'ml' ) { |
|
| 102 | + $defaults['title'] = __( 'Margin left' ); |
|
| 103 | + $defaults['icon'] = 'box-left'; |
|
| 104 | + $defaults['row'] = array( |
|
| 105 | + 'key' => 'wrapper-margins', |
|
| 106 | + 'close' => true, |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + return $input; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -122,61 +122,61 @@ discard block |
||
| 122 | 122 | * @return array |
| 123 | 123 | */ |
| 124 | 124 | function sd_get_padding_input( $type = 'pt', $overwrite = array() ) { |
| 125 | - $options = array( |
|
| 126 | - "" => __( 'None' ), |
|
| 127 | - "0" => "0", |
|
| 128 | - "1" => "1", |
|
| 129 | - "2" => "2", |
|
| 130 | - "3" => "3", |
|
| 131 | - "4" => "4", |
|
| 132 | - "5" => "5", |
|
| 133 | - ); |
|
| 134 | - |
|
| 135 | - $defaults = array( |
|
| 136 | - 'type' => 'select', |
|
| 137 | - 'title' => __( 'Padding top' ), |
|
| 138 | - 'options' => $options, |
|
| 139 | - 'default' => '', |
|
| 140 | - 'desc_tip' => true, |
|
| 141 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 142 | - ); |
|
| 143 | - |
|
| 144 | - // title |
|
| 145 | - if ( $type == 'pt' ) { |
|
| 146 | - $defaults['title'] = __( 'Padding top' ); |
|
| 147 | - $defaults['icon'] = 'box-top'; |
|
| 148 | - $defaults['row'] = array( |
|
| 149 | - 'title' => __( 'Padding' ), |
|
| 150 | - 'key' => 'wrapper-padding', |
|
| 151 | - 'open' => true, |
|
| 152 | - 'class' => 'text-center', |
|
| 153 | - ); |
|
| 154 | - } elseif ( $type == 'pr' ) { |
|
| 155 | - $defaults['title'] = __( 'Padding right' ); |
|
| 156 | - $defaults['icon'] = 'box-right'; |
|
| 157 | - $defaults['row'] = array( |
|
| 158 | - 'key' => 'wrapper-padding', |
|
| 159 | - ); |
|
| 160 | - } elseif ( $type == 'pb' ) { |
|
| 161 | - $defaults['title'] = __( 'Padding bottom' ); |
|
| 162 | - $defaults['icon'] = 'box-bottom'; |
|
| 163 | - $defaults['row'] = array( |
|
| 164 | - 'key' => 'wrapper-padding', |
|
| 165 | - ); |
|
| 166 | - } elseif ( $type == 'pl' ) { |
|
| 167 | - $defaults['title'] = __( 'Padding left' ); |
|
| 168 | - $defaults['icon'] = 'box-left'; |
|
| 169 | - $defaults['row'] = array( |
|
| 170 | - 'key' => 'wrapper-padding', |
|
| 171 | - 'close' => true, |
|
| 172 | - |
|
| 173 | - ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 177 | - |
|
| 178 | - |
|
| 179 | - return $input; |
|
| 125 | + $options = array( |
|
| 126 | + "" => __( 'None' ), |
|
| 127 | + "0" => "0", |
|
| 128 | + "1" => "1", |
|
| 129 | + "2" => "2", |
|
| 130 | + "3" => "3", |
|
| 131 | + "4" => "4", |
|
| 132 | + "5" => "5", |
|
| 133 | + ); |
|
| 134 | + |
|
| 135 | + $defaults = array( |
|
| 136 | + 'type' => 'select', |
|
| 137 | + 'title' => __( 'Padding top' ), |
|
| 138 | + 'options' => $options, |
|
| 139 | + 'default' => '', |
|
| 140 | + 'desc_tip' => true, |
|
| 141 | + 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 142 | + ); |
|
| 143 | + |
|
| 144 | + // title |
|
| 145 | + if ( $type == 'pt' ) { |
|
| 146 | + $defaults['title'] = __( 'Padding top' ); |
|
| 147 | + $defaults['icon'] = 'box-top'; |
|
| 148 | + $defaults['row'] = array( |
|
| 149 | + 'title' => __( 'Padding' ), |
|
| 150 | + 'key' => 'wrapper-padding', |
|
| 151 | + 'open' => true, |
|
| 152 | + 'class' => 'text-center', |
|
| 153 | + ); |
|
| 154 | + } elseif ( $type == 'pr' ) { |
|
| 155 | + $defaults['title'] = __( 'Padding right' ); |
|
| 156 | + $defaults['icon'] = 'box-right'; |
|
| 157 | + $defaults['row'] = array( |
|
| 158 | + 'key' => 'wrapper-padding', |
|
| 159 | + ); |
|
| 160 | + } elseif ( $type == 'pb' ) { |
|
| 161 | + $defaults['title'] = __( 'Padding bottom' ); |
|
| 162 | + $defaults['icon'] = 'box-bottom'; |
|
| 163 | + $defaults['row'] = array( |
|
| 164 | + 'key' => 'wrapper-padding', |
|
| 165 | + ); |
|
| 166 | + } elseif ( $type == 'pl' ) { |
|
| 167 | + $defaults['title'] = __( 'Padding left' ); |
|
| 168 | + $defaults['icon'] = 'box-left'; |
|
| 169 | + $defaults['row'] = array( |
|
| 170 | + 'key' => 'wrapper-padding', |
|
| 171 | + 'close' => true, |
|
| 172 | + |
|
| 173 | + ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 177 | + |
|
| 178 | + |
|
| 179 | + return $input; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -189,58 +189,58 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | function sd_get_border_input( $type = 'border', $overwrite = array() ) { |
| 191 | 191 | |
| 192 | - $defaults = array( |
|
| 193 | - 'type' => 'select', |
|
| 194 | - 'title' => __( 'Border' ), |
|
| 195 | - 'options' => array(), |
|
| 196 | - 'default' => '', |
|
| 197 | - 'desc_tip' => true, |
|
| 198 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 199 | - ); |
|
| 200 | - |
|
| 201 | - // title |
|
| 202 | - if ( $type == 'rounded' ) { |
|
| 203 | - $defaults['title'] = __( 'Border radius type' ); |
|
| 204 | - $defaults['options'] = array( |
|
| 205 | - '' => __( "Default", "geodirectory" ), |
|
| 206 | - 'rounded' => 'rounded', |
|
| 207 | - 'rounded-top' => 'rounded-top', |
|
| 208 | - 'rounded-right' => 'rounded-right', |
|
| 209 | - 'rounded-bottom' => 'rounded-bottom', |
|
| 210 | - 'rounded-left' => 'rounded-left', |
|
| 211 | - 'rounded-circle' => 'rounded-circle', |
|
| 212 | - 'rounded-pill' => 'rounded-pill', |
|
| 213 | - 'rounded-0' => 'rounded-0', |
|
| 214 | - ); |
|
| 215 | - } elseif ( $type == 'rounded_size' ) { |
|
| 216 | - $defaults['title'] = __( 'Border radius size' ); |
|
| 217 | - $defaults['options'] = array( |
|
| 218 | - '' => __( "Default", "geodirectory" ), |
|
| 219 | - 'sm' => __( "Small", "geodirectory" ), |
|
| 220 | - 'lg' => __( "Large", "geodirectory" ), |
|
| 221 | - ); |
|
| 222 | - } elseif ( $type == 'type' ) { |
|
| 223 | - $defaults['title'] = __( 'Border type' ); |
|
| 224 | - $defaults['options'] = array( |
|
| 225 | - '' => __( "None", "geodirectory" ), |
|
| 226 | - 'border' => __( "Full", "geodirectory" ), |
|
| 227 | - 'border-top' => __( "Top", "geodirectory" ), |
|
| 228 | - 'border-bottom' => __( "Bottom", "geodirectory" ), |
|
| 229 | - 'border-left' => __( "Left", "geodirectory" ), |
|
| 230 | - 'border-right' => __( "Right", "geodirectory" ), |
|
| 231 | - ); |
|
| 232 | - } else { |
|
| 233 | - $defaults['title'] = __( 'Border color' ); |
|
| 234 | - $defaults['options'] = array( |
|
| 235 | - '' => __( "Default", "geodirectory" ), |
|
| 236 | - '0' => __( "None", "geodirectory" ), |
|
| 237 | - ) + sd_aui_colors(); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - return $input; |
|
| 192 | + $defaults = array( |
|
| 193 | + 'type' => 'select', |
|
| 194 | + 'title' => __( 'Border' ), |
|
| 195 | + 'options' => array(), |
|
| 196 | + 'default' => '', |
|
| 197 | + 'desc_tip' => true, |
|
| 198 | + 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 199 | + ); |
|
| 200 | + |
|
| 201 | + // title |
|
| 202 | + if ( $type == 'rounded' ) { |
|
| 203 | + $defaults['title'] = __( 'Border radius type' ); |
|
| 204 | + $defaults['options'] = array( |
|
| 205 | + '' => __( "Default", "geodirectory" ), |
|
| 206 | + 'rounded' => 'rounded', |
|
| 207 | + 'rounded-top' => 'rounded-top', |
|
| 208 | + 'rounded-right' => 'rounded-right', |
|
| 209 | + 'rounded-bottom' => 'rounded-bottom', |
|
| 210 | + 'rounded-left' => 'rounded-left', |
|
| 211 | + 'rounded-circle' => 'rounded-circle', |
|
| 212 | + 'rounded-pill' => 'rounded-pill', |
|
| 213 | + 'rounded-0' => 'rounded-0', |
|
| 214 | + ); |
|
| 215 | + } elseif ( $type == 'rounded_size' ) { |
|
| 216 | + $defaults['title'] = __( 'Border radius size' ); |
|
| 217 | + $defaults['options'] = array( |
|
| 218 | + '' => __( "Default", "geodirectory" ), |
|
| 219 | + 'sm' => __( "Small", "geodirectory" ), |
|
| 220 | + 'lg' => __( "Large", "geodirectory" ), |
|
| 221 | + ); |
|
| 222 | + } elseif ( $type == 'type' ) { |
|
| 223 | + $defaults['title'] = __( 'Border type' ); |
|
| 224 | + $defaults['options'] = array( |
|
| 225 | + '' => __( "None", "geodirectory" ), |
|
| 226 | + 'border' => __( "Full", "geodirectory" ), |
|
| 227 | + 'border-top' => __( "Top", "geodirectory" ), |
|
| 228 | + 'border-bottom' => __( "Bottom", "geodirectory" ), |
|
| 229 | + 'border-left' => __( "Left", "geodirectory" ), |
|
| 230 | + 'border-right' => __( "Right", "geodirectory" ), |
|
| 231 | + ); |
|
| 232 | + } else { |
|
| 233 | + $defaults['title'] = __( 'Border color' ); |
|
| 234 | + $defaults['options'] = array( |
|
| 235 | + '' => __( "Default", "geodirectory" ), |
|
| 236 | + '0' => __( "None", "geodirectory" ), |
|
| 237 | + ) + sd_aui_colors(); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + return $input; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -252,27 +252,27 @@ discard block |
||
| 252 | 252 | * @return array |
| 253 | 253 | */ |
| 254 | 254 | function sd_get_shadow_input( $type = 'shadow', $overwrite = array() ) { |
| 255 | - $options = array( |
|
| 256 | - "" => __( 'None' ), |
|
| 257 | - "shadow-sm" => __( 'Small' ), |
|
| 258 | - "shadow" => __( 'Regular' ), |
|
| 259 | - "shadow-lg" => __( 'Large' ), |
|
| 260 | - ); |
|
| 255 | + $options = array( |
|
| 256 | + "" => __( 'None' ), |
|
| 257 | + "shadow-sm" => __( 'Small' ), |
|
| 258 | + "shadow" => __( 'Regular' ), |
|
| 259 | + "shadow-lg" => __( 'Large' ), |
|
| 260 | + ); |
|
| 261 | 261 | |
| 262 | - $defaults = array( |
|
| 263 | - 'type' => 'select', |
|
| 264 | - 'title' => __( 'Shadow' ), |
|
| 265 | - 'options' => $options, |
|
| 266 | - 'default' => '', |
|
| 267 | - 'desc_tip' => true, |
|
| 268 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 269 | - ); |
|
| 262 | + $defaults = array( |
|
| 263 | + 'type' => 'select', |
|
| 264 | + 'title' => __( 'Shadow' ), |
|
| 265 | + 'options' => $options, |
|
| 266 | + 'default' => '', |
|
| 267 | + 'desc_tip' => true, |
|
| 268 | + 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 269 | + ); |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 272 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 273 | 273 | |
| 274 | 274 | |
| 275 | - return $input; |
|
| 275 | + return $input; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -284,25 +284,25 @@ discard block |
||
| 284 | 284 | * @return array |
| 285 | 285 | */ |
| 286 | 286 | function sd_get_background_input( $type = 'bg', $overwrite = array() ) { |
| 287 | - $options = array( |
|
| 288 | - '' => __( "None", "geodirectory" ), |
|
| 289 | - 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 290 | - ) + sd_aui_colors(); |
|
| 287 | + $options = array( |
|
| 288 | + '' => __( "None", "geodirectory" ), |
|
| 289 | + 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 290 | + ) + sd_aui_colors(); |
|
| 291 | 291 | |
| 292 | - $defaults = array( |
|
| 293 | - 'type' => 'select', |
|
| 294 | - 'title' => __( 'Background color' ), |
|
| 295 | - 'options' => $options, |
|
| 296 | - 'default' => '', |
|
| 297 | - 'desc_tip' => true, |
|
| 298 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 299 | - ); |
|
| 292 | + $defaults = array( |
|
| 293 | + 'type' => 'select', |
|
| 294 | + 'title' => __( 'Background color' ), |
|
| 295 | + 'options' => $options, |
|
| 296 | + 'default' => '', |
|
| 297 | + 'desc_tip' => true, |
|
| 298 | + 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 299 | + ); |
|
| 300 | 300 | |
| 301 | 301 | |
| 302 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 302 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 303 | 303 | |
| 304 | 304 | |
| 305 | - return $input; |
|
| 305 | + return $input; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -314,98 +314,98 @@ discard block |
||
| 314 | 314 | * @return array |
| 315 | 315 | */ |
| 316 | 316 | function sd_get_background_inputs( $type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
| 317 | - $options = array( |
|
| 318 | - '' => __( "None", "geodirectory" ), |
|
| 319 | - 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 320 | - ) + sd_aui_colors() |
|
| 321 | - + array( |
|
| 322 | - 'custom-color' => __( "Custom Color", "geodirectory" ), |
|
| 323 | - 'custom-gradient' => __( "Custom Gradient", "geodirectory" ), |
|
| 317 | + $options = array( |
|
| 318 | + '' => __( "None", "geodirectory" ), |
|
| 319 | + 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 320 | + ) + sd_aui_colors() |
|
| 321 | + + array( |
|
| 322 | + 'custom-color' => __( "Custom Color", "geodirectory" ), |
|
| 323 | + 'custom-gradient' => __( "Custom Gradient", "geodirectory" ), |
|
| 324 | 324 | // 'custom-image' => __("Custom Image","geodirectory"), |
| 325 | - ); |
|
| 326 | - |
|
| 327 | - $defaults = array( |
|
| 328 | - 'type' => 'select', |
|
| 329 | - 'title' => __( 'Background Color' ), |
|
| 330 | - 'options' => $options, |
|
| 331 | - 'default' => '', |
|
| 332 | - 'desc_tip' => true, |
|
| 333 | - 'group' => __( "Background", "geodirectory" ) |
|
| 334 | - ); |
|
| 335 | - |
|
| 336 | - |
|
| 337 | - if ( $overwrite !== false ) { |
|
| 338 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - if ( $overwrite_color !== false ) { |
|
| 343 | - $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 344 | - 'type' => 'color', |
|
| 345 | - 'title' => __( 'Custom color' ), |
|
| 346 | - 'placeholder' => '', |
|
| 347 | - 'default' => '#0073aa', |
|
| 348 | - 'desc_tip' => true, |
|
| 349 | - 'group' => __( "Background" ), |
|
| 350 | - 'element_require' => '[%' . $type . '%]=="custom-color"' |
|
| 351 | - ) ); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - |
|
| 355 | - if ( $overwrite_gradient !== false ) { |
|
| 356 | - $input[ $type . '_gradient' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 357 | - 'type' => 'gradient', |
|
| 358 | - 'title' => __( 'Custom gradient' ), |
|
| 359 | - 'placeholder' => '', |
|
| 360 | - 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 361 | - 'desc_tip' => true, |
|
| 362 | - 'group' => __( "Background" ), |
|
| 363 | - 'element_require' => '[%' . $type . '%]=="custom-gradient"' |
|
| 364 | - ) ); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - if ( $overwrite_image !== false ) { |
|
| 368 | - |
|
| 369 | - $input[ $type . '_image_fixed' ] = array( |
|
| 370 | - 'type' => 'checkbox', |
|
| 371 | - 'title' => __( 'Fixed background' ), |
|
| 372 | - 'default' => '', |
|
| 373 | - 'desc_tip' => true, |
|
| 374 | - 'group' => __( "Background" ), |
|
| 375 | - 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
|
| 376 | - |
|
| 377 | - ); |
|
| 378 | - |
|
| 379 | - |
|
| 380 | - $input[ $type . '_image' ] = wp_parse_args( $overwrite_image, array( |
|
| 381 | - 'type' => 'image', |
|
| 382 | - 'title' => __( 'Custom image' ), |
|
| 383 | - 'placeholder' => '', |
|
| 384 | - 'default' => '', |
|
| 385 | - 'desc_tip' => true, |
|
| 386 | - 'group' => __( "Background" ), |
|
| 325 | + ); |
|
| 326 | + |
|
| 327 | + $defaults = array( |
|
| 328 | + 'type' => 'select', |
|
| 329 | + 'title' => __( 'Background Color' ), |
|
| 330 | + 'options' => $options, |
|
| 331 | + 'default' => '', |
|
| 332 | + 'desc_tip' => true, |
|
| 333 | + 'group' => __( "Background", "geodirectory" ) |
|
| 334 | + ); |
|
| 335 | + |
|
| 336 | + |
|
| 337 | + if ( $overwrite !== false ) { |
|
| 338 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + if ( $overwrite_color !== false ) { |
|
| 343 | + $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 344 | + 'type' => 'color', |
|
| 345 | + 'title' => __( 'Custom color' ), |
|
| 346 | + 'placeholder' => '', |
|
| 347 | + 'default' => '#0073aa', |
|
| 348 | + 'desc_tip' => true, |
|
| 349 | + 'group' => __( "Background" ), |
|
| 350 | + 'element_require' => '[%' . $type . '%]=="custom-color"' |
|
| 351 | + ) ); |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + |
|
| 355 | + if ( $overwrite_gradient !== false ) { |
|
| 356 | + $input[ $type . '_gradient' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 357 | + 'type' => 'gradient', |
|
| 358 | + 'title' => __( 'Custom gradient' ), |
|
| 359 | + 'placeholder' => '', |
|
| 360 | + 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 361 | + 'desc_tip' => true, |
|
| 362 | + 'group' => __( "Background" ), |
|
| 363 | + 'element_require' => '[%' . $type . '%]=="custom-gradient"' |
|
| 364 | + ) ); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + if ( $overwrite_image !== false ) { |
|
| 368 | + |
|
| 369 | + $input[ $type . '_image_fixed' ] = array( |
|
| 370 | + 'type' => 'checkbox', |
|
| 371 | + 'title' => __( 'Fixed background' ), |
|
| 372 | + 'default' => '', |
|
| 373 | + 'desc_tip' => true, |
|
| 374 | + 'group' => __( "Background" ), |
|
| 375 | + 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
|
| 376 | + |
|
| 377 | + ); |
|
| 378 | + |
|
| 379 | + |
|
| 380 | + $input[ $type . '_image' ] = wp_parse_args( $overwrite_image, array( |
|
| 381 | + 'type' => 'image', |
|
| 382 | + 'title' => __( 'Custom image' ), |
|
| 383 | + 'placeholder' => '', |
|
| 384 | + 'default' => '', |
|
| 385 | + 'desc_tip' => true, |
|
| 386 | + 'group' => __( "Background" ), |
|
| 387 | 387 | // 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
| 388 | - ) ); |
|
| 389 | - |
|
| 390 | - $input[ $type . '_image_id' ] = wp_parse_args( $overwrite_image, array( |
|
| 391 | - 'type' => 'hidden', |
|
| 392 | - 'hidden_type' => 'number', |
|
| 393 | - 'title' => '', |
|
| 394 | - 'placeholder' => '', |
|
| 395 | - 'default' => '', |
|
| 396 | - 'group' => __( "Background" ), |
|
| 397 | - ) ); |
|
| 398 | - |
|
| 399 | - $input[ $type . '_image_xy' ] = wp_parse_args( $overwrite_image, array( |
|
| 400 | - 'type' => 'image_xy', |
|
| 401 | - 'title' => '', |
|
| 402 | - 'placeholder' => '', |
|
| 403 | - 'default' => '', |
|
| 404 | - 'group' => __( "Background" ), |
|
| 405 | - ) ); |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - return $input; |
|
| 388 | + ) ); |
|
| 389 | + |
|
| 390 | + $input[ $type . '_image_id' ] = wp_parse_args( $overwrite_image, array( |
|
| 391 | + 'type' => 'hidden', |
|
| 392 | + 'hidden_type' => 'number', |
|
| 393 | + 'title' => '', |
|
| 394 | + 'placeholder' => '', |
|
| 395 | + 'default' => '', |
|
| 396 | + 'group' => __( "Background" ), |
|
| 397 | + ) ); |
|
| 398 | + |
|
| 399 | + $input[ $type . '_image_xy' ] = wp_parse_args( $overwrite_image, array( |
|
| 400 | + 'type' => 'image_xy', |
|
| 401 | + 'title' => '', |
|
| 402 | + 'placeholder' => '', |
|
| 403 | + 'default' => '', |
|
| 404 | + 'group' => __( "Background" ), |
|
| 405 | + ) ); |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + return $input; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -418,169 +418,169 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | function sd_get_shape_divider_inputs( $type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
| 420 | 420 | |
| 421 | - $options = array( |
|
| 422 | - '' => __( "None" ), |
|
| 423 | - 'mountains' => __( "Mountains" ), |
|
| 424 | - 'drops' => __( "Drops" ), |
|
| 425 | - 'clouds' => __( "Clouds" ), |
|
| 426 | - 'zigzag' => __( "Zigzag" ), |
|
| 427 | - 'pyramids' => __( "Pyramids" ), |
|
| 428 | - 'triangle' => __( "Triangle" ), |
|
| 429 | - 'triangle-asymmetrical' => __( "Triangle Asymmetrical" ), |
|
| 430 | - 'tilt' => __( "Tilt" ), |
|
| 431 | - 'opacity-tilt' => __( "Opacity Tilt" ), |
|
| 432 | - 'opacity-fan' => __( "Opacity Fan" ), |
|
| 433 | - 'curve' => __( "Curve" ), |
|
| 434 | - 'curve-asymmetrical' => __( "Curve Asymmetrical" ), |
|
| 435 | - 'waves' => __( "Waves" ), |
|
| 436 | - 'wave-brush' => __( "Wave Brush" ), |
|
| 437 | - 'waves-pattern' => __( "Waves Pattern" ), |
|
| 438 | - 'arrow' => __( "Arrow" ), |
|
| 439 | - 'split' => __( "Split" ), |
|
| 440 | - 'book' => __( "Book" ), |
|
| 441 | - ); |
|
| 442 | - |
|
| 443 | - $defaults = array( |
|
| 444 | - 'type' => 'select', |
|
| 445 | - 'title' => __( 'Type' ), |
|
| 446 | - 'options' => $options, |
|
| 447 | - 'default' => '', |
|
| 448 | - 'desc_tip' => true, |
|
| 449 | - 'group' => __( "Shape Divider" ), |
|
| 450 | - ); |
|
| 451 | - |
|
| 452 | - |
|
| 453 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - $input[ $type . '_notice' ] = array( |
|
| 457 | - 'type' => 'notice', |
|
| 458 | - 'desc' => __( 'Parent element must be position `relative`' ), |
|
| 459 | - 'status' => 'warning', |
|
| 460 | - 'group' => __( "Shape Divider" ), |
|
| 461 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 462 | - ); |
|
| 463 | - |
|
| 464 | - |
|
| 465 | - $input[ $type . '_position' ] = wp_parse_args( $overwrite_color, array( |
|
| 466 | - 'type' => 'select', |
|
| 467 | - 'title' => __( 'Position' ), |
|
| 468 | - 'options' => array( |
|
| 469 | - 'top' => __( 'Top' ), |
|
| 470 | - 'bottom' => __( 'Bottom' ), |
|
| 471 | - //'left' => __('Left'), |
|
| 472 | - //'right' => __('Right'), |
|
| 473 | - ), |
|
| 474 | - 'desc_tip' => true, |
|
| 475 | - 'group' => __( "Shape Divider" ), |
|
| 476 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 477 | - ) ); |
|
| 478 | - |
|
| 479 | - $options = array( |
|
| 480 | - '' => __( "None" ), |
|
| 481 | - 'transparent' => __( "Transparent" ), |
|
| 482 | - ) + sd_aui_colors() |
|
| 483 | - + array( |
|
| 484 | - 'custom-color' => __( "Custom Color" ), |
|
| 485 | - ); |
|
| 486 | - |
|
| 487 | - $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 488 | - 'type' => 'select', |
|
| 489 | - 'title' => __( 'Color' ), |
|
| 490 | - 'options' => $options, |
|
| 491 | - 'desc_tip' => true, |
|
| 492 | - 'group' => __( "Shape Divider" ), |
|
| 493 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 494 | - ) ); |
|
| 495 | - |
|
| 496 | - $input[ $type . '_custom_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 497 | - 'type' => 'color', |
|
| 498 | - 'title' => __( 'Custom color' ), |
|
| 499 | - 'placeholder' => '', |
|
| 500 | - 'default' => '#0073aa', |
|
| 501 | - 'desc_tip' => true, |
|
| 502 | - 'group' => __( "Shape Divider" ), |
|
| 503 | - 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""' |
|
| 504 | - ) ); |
|
| 505 | - |
|
| 506 | - $input[ $type . '_width' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 507 | - 'type' => 'range', |
|
| 508 | - 'title' => __( 'Width' ), |
|
| 509 | - 'placeholder' => '', |
|
| 510 | - 'default' => '200', |
|
| 511 | - 'desc_tip' => true, |
|
| 512 | - 'custom_attributes' => array( |
|
| 513 | - 'min' => 100, |
|
| 514 | - 'max' => 300, |
|
| 515 | - ), |
|
| 516 | - 'group' => __( "Shape Divider" ), |
|
| 517 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 518 | - ) ); |
|
| 519 | - |
|
| 520 | - $input[ $type . '_height' ] = array( |
|
| 521 | - 'type' => 'range', |
|
| 522 | - 'title' => __( 'Height' ), |
|
| 523 | - 'default' => '100', |
|
| 524 | - 'desc_tip' => true, |
|
| 525 | - 'custom_attributes' => array( |
|
| 526 | - 'min' => 0, |
|
| 527 | - 'max' => 500, |
|
| 528 | - ), |
|
| 529 | - 'group' => __( "Shape Divider" ), |
|
| 530 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 531 | - ); |
|
| 532 | - |
|
| 533 | - $requires = array( |
|
| 534 | - 'mountains' => array( 'flip' ), |
|
| 535 | - 'drops' => array( 'flip', 'invert' ), |
|
| 536 | - 'clouds' => array( 'flip', 'invert' ), |
|
| 537 | - 'zigzag' => array(), |
|
| 538 | - 'pyramids' => array( 'flip', 'invert' ), |
|
| 539 | - 'triangle' => array( 'invert' ), |
|
| 540 | - 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 541 | - 'tilt' => array( 'flip' ), |
|
| 542 | - 'opacity-tilt' => array( 'flip' ), |
|
| 543 | - 'opacity-fan' => array(), |
|
| 544 | - 'curve' => array( 'invert' ), |
|
| 545 | - 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 546 | - 'waves' => array( 'flip', 'invert' ), |
|
| 547 | - 'wave-brush' => array( 'flip' ), |
|
| 548 | - 'waves-pattern' => array( 'flip' ), |
|
| 549 | - 'arrow' => array( 'invert' ), |
|
| 550 | - 'split' => array( 'invert' ), |
|
| 551 | - 'book' => array( 'invert' ), |
|
| 552 | - ); |
|
| 553 | - |
|
| 554 | - $input[ $type . '_flip' ] = array( |
|
| 555 | - 'type' => 'checkbox', |
|
| 556 | - 'title' => __( 'Flip' ), |
|
| 557 | - 'default' => '', |
|
| 558 | - 'desc_tip' => true, |
|
| 559 | - 'group' => __( "Shape Divider" ), |
|
| 560 | - 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ) |
|
| 561 | - ); |
|
| 562 | - |
|
| 563 | - $input[ $type . '_invert' ] = array( |
|
| 564 | - 'type' => 'checkbox', |
|
| 565 | - 'title' => __( 'Invert' ), |
|
| 566 | - 'default' => '', |
|
| 567 | - 'desc_tip' => true, |
|
| 568 | - 'group' => __( "Shape Divider" ), |
|
| 569 | - 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ) |
|
| 570 | - ); |
|
| 571 | - |
|
| 572 | - $input[ $type . '_btf' ] = array( |
|
| 573 | - 'type' => 'checkbox', |
|
| 574 | - 'title' => __( 'Bring to front' ), |
|
| 575 | - 'default' => '', |
|
| 576 | - 'desc_tip' => true, |
|
| 577 | - 'group' => __( "Shape Divider" ), |
|
| 578 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 579 | - |
|
| 580 | - ); |
|
| 581 | - |
|
| 582 | - |
|
| 583 | - return $input; |
|
| 421 | + $options = array( |
|
| 422 | + '' => __( "None" ), |
|
| 423 | + 'mountains' => __( "Mountains" ), |
|
| 424 | + 'drops' => __( "Drops" ), |
|
| 425 | + 'clouds' => __( "Clouds" ), |
|
| 426 | + 'zigzag' => __( "Zigzag" ), |
|
| 427 | + 'pyramids' => __( "Pyramids" ), |
|
| 428 | + 'triangle' => __( "Triangle" ), |
|
| 429 | + 'triangle-asymmetrical' => __( "Triangle Asymmetrical" ), |
|
| 430 | + 'tilt' => __( "Tilt" ), |
|
| 431 | + 'opacity-tilt' => __( "Opacity Tilt" ), |
|
| 432 | + 'opacity-fan' => __( "Opacity Fan" ), |
|
| 433 | + 'curve' => __( "Curve" ), |
|
| 434 | + 'curve-asymmetrical' => __( "Curve Asymmetrical" ), |
|
| 435 | + 'waves' => __( "Waves" ), |
|
| 436 | + 'wave-brush' => __( "Wave Brush" ), |
|
| 437 | + 'waves-pattern' => __( "Waves Pattern" ), |
|
| 438 | + 'arrow' => __( "Arrow" ), |
|
| 439 | + 'split' => __( "Split" ), |
|
| 440 | + 'book' => __( "Book" ), |
|
| 441 | + ); |
|
| 442 | + |
|
| 443 | + $defaults = array( |
|
| 444 | + 'type' => 'select', |
|
| 445 | + 'title' => __( 'Type' ), |
|
| 446 | + 'options' => $options, |
|
| 447 | + 'default' => '', |
|
| 448 | + 'desc_tip' => true, |
|
| 449 | + 'group' => __( "Shape Divider" ), |
|
| 450 | + ); |
|
| 451 | + |
|
| 452 | + |
|
| 453 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + $input[ $type . '_notice' ] = array( |
|
| 457 | + 'type' => 'notice', |
|
| 458 | + 'desc' => __( 'Parent element must be position `relative`' ), |
|
| 459 | + 'status' => 'warning', |
|
| 460 | + 'group' => __( "Shape Divider" ), |
|
| 461 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 462 | + ); |
|
| 463 | + |
|
| 464 | + |
|
| 465 | + $input[ $type . '_position' ] = wp_parse_args( $overwrite_color, array( |
|
| 466 | + 'type' => 'select', |
|
| 467 | + 'title' => __( 'Position' ), |
|
| 468 | + 'options' => array( |
|
| 469 | + 'top' => __( 'Top' ), |
|
| 470 | + 'bottom' => __( 'Bottom' ), |
|
| 471 | + //'left' => __('Left'), |
|
| 472 | + //'right' => __('Right'), |
|
| 473 | + ), |
|
| 474 | + 'desc_tip' => true, |
|
| 475 | + 'group' => __( "Shape Divider" ), |
|
| 476 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 477 | + ) ); |
|
| 478 | + |
|
| 479 | + $options = array( |
|
| 480 | + '' => __( "None" ), |
|
| 481 | + 'transparent' => __( "Transparent" ), |
|
| 482 | + ) + sd_aui_colors() |
|
| 483 | + + array( |
|
| 484 | + 'custom-color' => __( "Custom Color" ), |
|
| 485 | + ); |
|
| 486 | + |
|
| 487 | + $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 488 | + 'type' => 'select', |
|
| 489 | + 'title' => __( 'Color' ), |
|
| 490 | + 'options' => $options, |
|
| 491 | + 'desc_tip' => true, |
|
| 492 | + 'group' => __( "Shape Divider" ), |
|
| 493 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 494 | + ) ); |
|
| 495 | + |
|
| 496 | + $input[ $type . '_custom_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 497 | + 'type' => 'color', |
|
| 498 | + 'title' => __( 'Custom color' ), |
|
| 499 | + 'placeholder' => '', |
|
| 500 | + 'default' => '#0073aa', |
|
| 501 | + 'desc_tip' => true, |
|
| 502 | + 'group' => __( "Shape Divider" ), |
|
| 503 | + 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""' |
|
| 504 | + ) ); |
|
| 505 | + |
|
| 506 | + $input[ $type . '_width' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 507 | + 'type' => 'range', |
|
| 508 | + 'title' => __( 'Width' ), |
|
| 509 | + 'placeholder' => '', |
|
| 510 | + 'default' => '200', |
|
| 511 | + 'desc_tip' => true, |
|
| 512 | + 'custom_attributes' => array( |
|
| 513 | + 'min' => 100, |
|
| 514 | + 'max' => 300, |
|
| 515 | + ), |
|
| 516 | + 'group' => __( "Shape Divider" ), |
|
| 517 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 518 | + ) ); |
|
| 519 | + |
|
| 520 | + $input[ $type . '_height' ] = array( |
|
| 521 | + 'type' => 'range', |
|
| 522 | + 'title' => __( 'Height' ), |
|
| 523 | + 'default' => '100', |
|
| 524 | + 'desc_tip' => true, |
|
| 525 | + 'custom_attributes' => array( |
|
| 526 | + 'min' => 0, |
|
| 527 | + 'max' => 500, |
|
| 528 | + ), |
|
| 529 | + 'group' => __( "Shape Divider" ), |
|
| 530 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 531 | + ); |
|
| 532 | + |
|
| 533 | + $requires = array( |
|
| 534 | + 'mountains' => array( 'flip' ), |
|
| 535 | + 'drops' => array( 'flip', 'invert' ), |
|
| 536 | + 'clouds' => array( 'flip', 'invert' ), |
|
| 537 | + 'zigzag' => array(), |
|
| 538 | + 'pyramids' => array( 'flip', 'invert' ), |
|
| 539 | + 'triangle' => array( 'invert' ), |
|
| 540 | + 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 541 | + 'tilt' => array( 'flip' ), |
|
| 542 | + 'opacity-tilt' => array( 'flip' ), |
|
| 543 | + 'opacity-fan' => array(), |
|
| 544 | + 'curve' => array( 'invert' ), |
|
| 545 | + 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 546 | + 'waves' => array( 'flip', 'invert' ), |
|
| 547 | + 'wave-brush' => array( 'flip' ), |
|
| 548 | + 'waves-pattern' => array( 'flip' ), |
|
| 549 | + 'arrow' => array( 'invert' ), |
|
| 550 | + 'split' => array( 'invert' ), |
|
| 551 | + 'book' => array( 'invert' ), |
|
| 552 | + ); |
|
| 553 | + |
|
| 554 | + $input[ $type . '_flip' ] = array( |
|
| 555 | + 'type' => 'checkbox', |
|
| 556 | + 'title' => __( 'Flip' ), |
|
| 557 | + 'default' => '', |
|
| 558 | + 'desc_tip' => true, |
|
| 559 | + 'group' => __( "Shape Divider" ), |
|
| 560 | + 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ) |
|
| 561 | + ); |
|
| 562 | + |
|
| 563 | + $input[ $type . '_invert' ] = array( |
|
| 564 | + 'type' => 'checkbox', |
|
| 565 | + 'title' => __( 'Invert' ), |
|
| 566 | + 'default' => '', |
|
| 567 | + 'desc_tip' => true, |
|
| 568 | + 'group' => __( "Shape Divider" ), |
|
| 569 | + 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ) |
|
| 570 | + ); |
|
| 571 | + |
|
| 572 | + $input[ $type . '_btf' ] = array( |
|
| 573 | + 'type' => 'checkbox', |
|
| 574 | + 'title' => __( 'Bring to front' ), |
|
| 575 | + 'default' => '', |
|
| 576 | + 'desc_tip' => true, |
|
| 577 | + 'group' => __( "Shape Divider" ), |
|
| 578 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 579 | + |
|
| 580 | + ); |
|
| 581 | + |
|
| 582 | + |
|
| 583 | + return $input; |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /** |
@@ -593,23 +593,23 @@ discard block |
||
| 593 | 593 | * @return string |
| 594 | 594 | */ |
| 595 | 595 | function sd_get_element_require_string( $args, $key, $type ) { |
| 596 | - $output = ''; |
|
| 597 | - $requires = array(); |
|
| 596 | + $output = ''; |
|
| 597 | + $requires = array(); |
|
| 598 | 598 | |
| 599 | - if ( ! empty( $args ) ) { |
|
| 600 | - foreach ( $args as $t => $k ) { |
|
| 601 | - if ( in_array( $key, $k ) ) { |
|
| 602 | - $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 603 | - } |
|
| 604 | - } |
|
| 599 | + if ( ! empty( $args ) ) { |
|
| 600 | + foreach ( $args as $t => $k ) { |
|
| 601 | + if ( in_array( $key, $k ) ) { |
|
| 602 | + $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 603 | + } |
|
| 604 | + } |
|
| 605 | 605 | |
| 606 | - if ( ! empty( $requires ) ) { |
|
| 607 | - $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 608 | - } |
|
| 609 | - } |
|
| 606 | + if ( ! empty( $requires ) ) { |
|
| 607 | + $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 608 | + } |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | 611 | |
| 612 | - return $output; |
|
| 612 | + return $output; |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -621,24 +621,24 @@ discard block |
||
| 621 | 621 | * @return array |
| 622 | 622 | */ |
| 623 | 623 | function sd_get_text_color_input( $type = 'text_color', $overwrite = array() ) { |
| 624 | - $options = array( |
|
| 625 | - '' => __( "None" ), |
|
| 626 | - ) + sd_aui_colors(); |
|
| 624 | + $options = array( |
|
| 625 | + '' => __( "None" ), |
|
| 626 | + ) + sd_aui_colors(); |
|
| 627 | 627 | |
| 628 | - $defaults = array( |
|
| 629 | - 'type' => 'select', |
|
| 630 | - 'title' => __( 'Text color' ), |
|
| 631 | - 'options' => $options, |
|
| 632 | - 'default' => '', |
|
| 633 | - 'desc_tip' => true, |
|
| 634 | - 'group' => __( "Typography" ) |
|
| 635 | - ); |
|
| 628 | + $defaults = array( |
|
| 629 | + 'type' => 'select', |
|
| 630 | + 'title' => __( 'Text color' ), |
|
| 631 | + 'options' => $options, |
|
| 632 | + 'default' => '', |
|
| 633 | + 'desc_tip' => true, |
|
| 634 | + 'group' => __( "Typography" ) |
|
| 635 | + ); |
|
| 636 | 636 | |
| 637 | 637 | |
| 638 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 638 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 639 | 639 | |
| 640 | 640 | |
| 641 | - return $input; |
|
| 641 | + return $input; |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
@@ -651,45 +651,45 @@ discard block |
||
| 651 | 651 | */ |
| 652 | 652 | function sd_get_col_input( $type = 'col', $overwrite = array() ) { |
| 653 | 653 | |
| 654 | - $device_size = ''; |
|
| 655 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 656 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 657 | - $device_size = '-md'; |
|
| 658 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 659 | - $device_size = '-lg'; |
|
| 660 | - } |
|
| 661 | - } |
|
| 662 | - $options = array( |
|
| 663 | - '' => __( 'auto' ), |
|
| 664 | - '1' => '1/12', |
|
| 665 | - '2' => '2/12', |
|
| 666 | - '3' => '3/12', |
|
| 667 | - '4' => '4/12', |
|
| 668 | - '5' => '5/12', |
|
| 669 | - '6' => '6/12', |
|
| 670 | - '7' => '7/12', |
|
| 671 | - '8' => '8/12', |
|
| 672 | - '9' => '9/12', |
|
| 673 | - '10' => '10/12', |
|
| 674 | - '11' => '11/12', |
|
| 675 | - '12' => '12/12', |
|
| 676 | - ); |
|
| 677 | - |
|
| 678 | - $defaults = array( |
|
| 679 | - 'type' => 'select', |
|
| 680 | - 'title' => __( 'Column width' ), |
|
| 681 | - 'options' => $options, |
|
| 682 | - 'default' => '', |
|
| 683 | - 'desc_tip' => true, |
|
| 684 | - 'group' => __( "Container" ), |
|
| 685 | - 'element_require' => '[%container%]=="col"', |
|
| 686 | - ); |
|
| 687 | - |
|
| 688 | - |
|
| 689 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 690 | - |
|
| 691 | - |
|
| 692 | - return $input; |
|
| 654 | + $device_size = ''; |
|
| 655 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 656 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 657 | + $device_size = '-md'; |
|
| 658 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 659 | + $device_size = '-lg'; |
|
| 660 | + } |
|
| 661 | + } |
|
| 662 | + $options = array( |
|
| 663 | + '' => __( 'auto' ), |
|
| 664 | + '1' => '1/12', |
|
| 665 | + '2' => '2/12', |
|
| 666 | + '3' => '3/12', |
|
| 667 | + '4' => '4/12', |
|
| 668 | + '5' => '5/12', |
|
| 669 | + '6' => '6/12', |
|
| 670 | + '7' => '7/12', |
|
| 671 | + '8' => '8/12', |
|
| 672 | + '9' => '9/12', |
|
| 673 | + '10' => '10/12', |
|
| 674 | + '11' => '11/12', |
|
| 675 | + '12' => '12/12', |
|
| 676 | + ); |
|
| 677 | + |
|
| 678 | + $defaults = array( |
|
| 679 | + 'type' => 'select', |
|
| 680 | + 'title' => __( 'Column width' ), |
|
| 681 | + 'options' => $options, |
|
| 682 | + 'default' => '', |
|
| 683 | + 'desc_tip' => true, |
|
| 684 | + 'group' => __( "Container" ), |
|
| 685 | + 'element_require' => '[%container%]=="col"', |
|
| 686 | + ); |
|
| 687 | + |
|
| 688 | + |
|
| 689 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 690 | + |
|
| 691 | + |
|
| 692 | + return $input; |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /** |
@@ -702,39 +702,39 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | function sd_get_row_cols_input( $type = 'row_cols', $overwrite = array() ) { |
| 704 | 704 | |
| 705 | - $device_size = ''; |
|
| 706 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 707 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 708 | - $device_size = '-md'; |
|
| 709 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 710 | - $device_size = '-lg'; |
|
| 711 | - } |
|
| 712 | - } |
|
| 713 | - $options = array( |
|
| 714 | - '' => __( 'auto' ), |
|
| 715 | - '1' => '1', |
|
| 716 | - '2' => '2', |
|
| 717 | - '3' => '3', |
|
| 718 | - '4' => '4', |
|
| 719 | - '5' => '5', |
|
| 720 | - '6' => '6', |
|
| 721 | - ); |
|
| 722 | - |
|
| 723 | - $defaults = array( |
|
| 724 | - 'type' => 'select', |
|
| 725 | - 'title' => __( 'Row columns' ), |
|
| 726 | - 'options' => $options, |
|
| 727 | - 'default' => '', |
|
| 728 | - 'desc_tip' => true, |
|
| 729 | - 'group' => __( "Container" ), |
|
| 730 | - 'element_require' => '[%container%]=="row"', |
|
| 731 | - ); |
|
| 732 | - |
|
| 733 | - |
|
| 734 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 735 | - |
|
| 736 | - |
|
| 737 | - return $input; |
|
| 705 | + $device_size = ''; |
|
| 706 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 707 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 708 | + $device_size = '-md'; |
|
| 709 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 710 | + $device_size = '-lg'; |
|
| 711 | + } |
|
| 712 | + } |
|
| 713 | + $options = array( |
|
| 714 | + '' => __( 'auto' ), |
|
| 715 | + '1' => '1', |
|
| 716 | + '2' => '2', |
|
| 717 | + '3' => '3', |
|
| 718 | + '4' => '4', |
|
| 719 | + '5' => '5', |
|
| 720 | + '6' => '6', |
|
| 721 | + ); |
|
| 722 | + |
|
| 723 | + $defaults = array( |
|
| 724 | + 'type' => 'select', |
|
| 725 | + 'title' => __( 'Row columns' ), |
|
| 726 | + 'options' => $options, |
|
| 727 | + 'default' => '', |
|
| 728 | + 'desc_tip' => true, |
|
| 729 | + 'group' => __( "Container" ), |
|
| 730 | + 'element_require' => '[%container%]=="row"', |
|
| 731 | + ); |
|
| 732 | + |
|
| 733 | + |
|
| 734 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 735 | + |
|
| 736 | + |
|
| 737 | + return $input; |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
@@ -747,35 +747,35 @@ discard block |
||
| 747 | 747 | */ |
| 748 | 748 | function sd_get_text_align_input( $type = 'text_align', $overwrite = array() ) { |
| 749 | 749 | |
| 750 | - $device_size = ''; |
|
| 751 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 752 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 753 | - $device_size = '-md'; |
|
| 754 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 755 | - $device_size = '-lg'; |
|
| 756 | - } |
|
| 757 | - } |
|
| 758 | - $options = array( |
|
| 759 | - '' => __( "Default" ), |
|
| 760 | - 'text' . $device_size . '-left' => __( "Left" ), |
|
| 761 | - 'text' . $device_size . '-right' => __( "Right" ), |
|
| 762 | - 'text' . $device_size . '-center' => __( "Center" ), |
|
| 763 | - ); |
|
| 764 | - |
|
| 765 | - $defaults = array( |
|
| 766 | - 'type' => 'select', |
|
| 767 | - 'title' => __( 'Text align' ), |
|
| 768 | - 'options' => $options, |
|
| 769 | - 'default' => '', |
|
| 770 | - 'desc_tip' => true, |
|
| 771 | - 'group' => __( "Typography" ) |
|
| 772 | - ); |
|
| 773 | - |
|
| 774 | - |
|
| 775 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 776 | - |
|
| 777 | - |
|
| 778 | - return $input; |
|
| 750 | + $device_size = ''; |
|
| 751 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 752 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 753 | + $device_size = '-md'; |
|
| 754 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 755 | + $device_size = '-lg'; |
|
| 756 | + } |
|
| 757 | + } |
|
| 758 | + $options = array( |
|
| 759 | + '' => __( "Default" ), |
|
| 760 | + 'text' . $device_size . '-left' => __( "Left" ), |
|
| 761 | + 'text' . $device_size . '-right' => __( "Right" ), |
|
| 762 | + 'text' . $device_size . '-center' => __( "Center" ), |
|
| 763 | + ); |
|
| 764 | + |
|
| 765 | + $defaults = array( |
|
| 766 | + 'type' => 'select', |
|
| 767 | + 'title' => __( 'Text align' ), |
|
| 768 | + 'options' => $options, |
|
| 769 | + 'default' => '', |
|
| 770 | + 'desc_tip' => true, |
|
| 771 | + 'group' => __( "Typography" ) |
|
| 772 | + ); |
|
| 773 | + |
|
| 774 | + |
|
| 775 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 776 | + |
|
| 777 | + |
|
| 778 | + return $input; |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
@@ -788,41 +788,41 @@ discard block |
||
| 788 | 788 | */ |
| 789 | 789 | function sd_get_display_input( $type = 'display', $overwrite = array() ) { |
| 790 | 790 | |
| 791 | - $device_size = ''; |
|
| 792 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 793 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 794 | - $device_size = '-md'; |
|
| 795 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 796 | - $device_size = '-lg'; |
|
| 797 | - } |
|
| 798 | - } |
|
| 799 | - $options = array( |
|
| 800 | - '' => __( "Default" ), |
|
| 801 | - 'd' . $device_size . '-none' => "none", |
|
| 802 | - 'd' . $device_size . '-inline' => "inline", |
|
| 803 | - 'd' . $device_size . '-inline-block' => "inline-block", |
|
| 804 | - 'd' . $device_size . '-block' => "block", |
|
| 805 | - 'd' . $device_size . '-table' => "table", |
|
| 806 | - 'd' . $device_size . '-table-cell' => "table-cell", |
|
| 807 | - 'd' . $device_size . '-table-row' => "table-row", |
|
| 808 | - 'd' . $device_size . '-flex' => "flex", |
|
| 809 | - 'd' . $device_size . '-inline-flex' => "inline-flex", |
|
| 810 | - ); |
|
| 811 | - |
|
| 812 | - $defaults = array( |
|
| 813 | - 'type' => 'select', |
|
| 814 | - 'title' => __( 'Display' ), |
|
| 815 | - 'options' => $options, |
|
| 816 | - 'default' => '', |
|
| 817 | - 'desc_tip' => true, |
|
| 818 | - 'group' => __( "Wrapper Styles" ) |
|
| 819 | - ); |
|
| 820 | - |
|
| 821 | - |
|
| 822 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 823 | - |
|
| 824 | - |
|
| 825 | - return $input; |
|
| 791 | + $device_size = ''; |
|
| 792 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 793 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 794 | + $device_size = '-md'; |
|
| 795 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 796 | + $device_size = '-lg'; |
|
| 797 | + } |
|
| 798 | + } |
|
| 799 | + $options = array( |
|
| 800 | + '' => __( "Default" ), |
|
| 801 | + 'd' . $device_size . '-none' => "none", |
|
| 802 | + 'd' . $device_size . '-inline' => "inline", |
|
| 803 | + 'd' . $device_size . '-inline-block' => "inline-block", |
|
| 804 | + 'd' . $device_size . '-block' => "block", |
|
| 805 | + 'd' . $device_size . '-table' => "table", |
|
| 806 | + 'd' . $device_size . '-table-cell' => "table-cell", |
|
| 807 | + 'd' . $device_size . '-table-row' => "table-row", |
|
| 808 | + 'd' . $device_size . '-flex' => "flex", |
|
| 809 | + 'd' . $device_size . '-inline-flex' => "inline-flex", |
|
| 810 | + ); |
|
| 811 | + |
|
| 812 | + $defaults = array( |
|
| 813 | + 'type' => 'select', |
|
| 814 | + 'title' => __( 'Display' ), |
|
| 815 | + 'options' => $options, |
|
| 816 | + 'default' => '', |
|
| 817 | + 'desc_tip' => true, |
|
| 818 | + 'group' => __( "Wrapper Styles" ) |
|
| 819 | + ); |
|
| 820 | + |
|
| 821 | + |
|
| 822 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 823 | + |
|
| 824 | + |
|
| 825 | + return $input; |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | /** |
@@ -835,19 +835,19 @@ discard block |
||
| 835 | 835 | */ |
| 836 | 836 | function sd_get_text_justify_input( $type = 'text_justify', $overwrite = array() ) { |
| 837 | 837 | |
| 838 | - $defaults = array( |
|
| 839 | - 'type' => 'checkbox', |
|
| 840 | - 'title' => __( 'Text justify' ), |
|
| 841 | - 'default' => '', |
|
| 842 | - 'desc_tip' => true, |
|
| 843 | - 'group' => __( "Typography" ) |
|
| 844 | - ); |
|
| 838 | + $defaults = array( |
|
| 839 | + 'type' => 'checkbox', |
|
| 840 | + 'title' => __( 'Text justify' ), |
|
| 841 | + 'default' => '', |
|
| 842 | + 'desc_tip' => true, |
|
| 843 | + 'group' => __( "Typography" ) |
|
| 844 | + ); |
|
| 845 | 845 | |
| 846 | 846 | |
| 847 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 847 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 848 | 848 | |
| 849 | 849 | |
| 850 | - return $input; |
|
| 850 | + return $input; |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | /** |
@@ -860,49 +860,49 @@ discard block |
||
| 860 | 860 | * @return array |
| 861 | 861 | */ |
| 862 | 862 | function sd_aui_colors( $include_branding = false, $include_outlines = false, $outline_button_only_text = false ) { |
| 863 | - $theme_colors = array(); |
|
| 864 | - |
|
| 865 | - $theme_colors["primary"] = __( 'Primary' ); |
|
| 866 | - $theme_colors["secondary"] = __( 'Secondary' ); |
|
| 867 | - $theme_colors["success"] = __( 'Success' ); |
|
| 868 | - $theme_colors["danger"] = __( 'Danger' ); |
|
| 869 | - $theme_colors["warning"] = __( 'Warning' ); |
|
| 870 | - $theme_colors["info"] = __( 'Info' ); |
|
| 871 | - $theme_colors["light"] = __( 'Light' ); |
|
| 872 | - $theme_colors["dark"] = __( 'Dark' ); |
|
| 873 | - $theme_colors["white"] = __( 'White' ); |
|
| 874 | - $theme_colors["purple"] = __( 'Purple' ); |
|
| 875 | - $theme_colors["salmon"] = __( 'Salmon' ); |
|
| 876 | - $theme_colors["cyan"] = __( 'Cyan' ); |
|
| 877 | - $theme_colors["gray"] = __( 'Gray' ); |
|
| 878 | - $theme_colors["indigo"] = __( 'Indigo' ); |
|
| 879 | - $theme_colors["orange"] = __( 'Orange' ); |
|
| 880 | - |
|
| 881 | - if ( $include_outlines ) { |
|
| 882 | - $button_only = $outline_button_only_text ? " " . __( "(button only)" ) : ''; |
|
| 883 | - $theme_colors["outline-primary"] = __( 'Primary outline' ) . $button_only; |
|
| 884 | - $theme_colors["outline-secondary"] = __( 'Secondary outline' ) . $button_only; |
|
| 885 | - $theme_colors["outline-success"] = __( 'Success outline' ) . $button_only; |
|
| 886 | - $theme_colors["outline-danger"] = __( 'Danger outline' ) . $button_only; |
|
| 887 | - $theme_colors["outline-warning"] = __( 'Warning outline' ) . $button_only; |
|
| 888 | - $theme_colors["outline-info"] = __( 'Info outline' ) . $button_only; |
|
| 889 | - $theme_colors["outline-light"] = __( 'Light outline' ) . $button_only; |
|
| 890 | - $theme_colors["outline-dark"] = __( 'Dark outline' ) . $button_only; |
|
| 891 | - $theme_colors["outline-white"] = __( 'White outline' ) . $button_only; |
|
| 892 | - $theme_colors["outline-purple"] = __( 'Purple outline' ) . $button_only; |
|
| 893 | - $theme_colors["outline-salmon"] = __( 'Salmon outline' ) . $button_only; |
|
| 894 | - $theme_colors["outline-cyan"] = __( 'Cyan outline' ) . $button_only; |
|
| 895 | - $theme_colors["outline-gray"] = __( 'Gray outline' ) . $button_only; |
|
| 896 | - $theme_colors["outline-indigo"] = __( 'Indigo outline' ) . $button_only; |
|
| 897 | - $theme_colors["outline-orange"] = __( 'Orange outline' ) . $button_only; |
|
| 898 | - } |
|
| 899 | - |
|
| 900 | - |
|
| 901 | - if ( $include_branding ) { |
|
| 902 | - $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 903 | - } |
|
| 904 | - |
|
| 905 | - return $theme_colors; |
|
| 863 | + $theme_colors = array(); |
|
| 864 | + |
|
| 865 | + $theme_colors["primary"] = __( 'Primary' ); |
|
| 866 | + $theme_colors["secondary"] = __( 'Secondary' ); |
|
| 867 | + $theme_colors["success"] = __( 'Success' ); |
|
| 868 | + $theme_colors["danger"] = __( 'Danger' ); |
|
| 869 | + $theme_colors["warning"] = __( 'Warning' ); |
|
| 870 | + $theme_colors["info"] = __( 'Info' ); |
|
| 871 | + $theme_colors["light"] = __( 'Light' ); |
|
| 872 | + $theme_colors["dark"] = __( 'Dark' ); |
|
| 873 | + $theme_colors["white"] = __( 'White' ); |
|
| 874 | + $theme_colors["purple"] = __( 'Purple' ); |
|
| 875 | + $theme_colors["salmon"] = __( 'Salmon' ); |
|
| 876 | + $theme_colors["cyan"] = __( 'Cyan' ); |
|
| 877 | + $theme_colors["gray"] = __( 'Gray' ); |
|
| 878 | + $theme_colors["indigo"] = __( 'Indigo' ); |
|
| 879 | + $theme_colors["orange"] = __( 'Orange' ); |
|
| 880 | + |
|
| 881 | + if ( $include_outlines ) { |
|
| 882 | + $button_only = $outline_button_only_text ? " " . __( "(button only)" ) : ''; |
|
| 883 | + $theme_colors["outline-primary"] = __( 'Primary outline' ) . $button_only; |
|
| 884 | + $theme_colors["outline-secondary"] = __( 'Secondary outline' ) . $button_only; |
|
| 885 | + $theme_colors["outline-success"] = __( 'Success outline' ) . $button_only; |
|
| 886 | + $theme_colors["outline-danger"] = __( 'Danger outline' ) . $button_only; |
|
| 887 | + $theme_colors["outline-warning"] = __( 'Warning outline' ) . $button_only; |
|
| 888 | + $theme_colors["outline-info"] = __( 'Info outline' ) . $button_only; |
|
| 889 | + $theme_colors["outline-light"] = __( 'Light outline' ) . $button_only; |
|
| 890 | + $theme_colors["outline-dark"] = __( 'Dark outline' ) . $button_only; |
|
| 891 | + $theme_colors["outline-white"] = __( 'White outline' ) . $button_only; |
|
| 892 | + $theme_colors["outline-purple"] = __( 'Purple outline' ) . $button_only; |
|
| 893 | + $theme_colors["outline-salmon"] = __( 'Salmon outline' ) . $button_only; |
|
| 894 | + $theme_colors["outline-cyan"] = __( 'Cyan outline' ) . $button_only; |
|
| 895 | + $theme_colors["outline-gray"] = __( 'Gray outline' ) . $button_only; |
|
| 896 | + $theme_colors["outline-indigo"] = __( 'Indigo outline' ) . $button_only; |
|
| 897 | + $theme_colors["outline-orange"] = __( 'Orange outline' ) . $button_only; |
|
| 898 | + } |
|
| 899 | + |
|
| 900 | + |
|
| 901 | + if ( $include_branding ) { |
|
| 902 | + $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 903 | + } |
|
| 904 | + |
|
| 905 | + return $theme_colors; |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | /** |
@@ -911,19 +911,19 @@ discard block |
||
| 911 | 911 | * @return array |
| 912 | 912 | */ |
| 913 | 913 | function sd_aui_branding_colors() { |
| 914 | - return array( |
|
| 915 | - "facebook" => __( 'Facebook' ), |
|
| 916 | - "twitter" => __( 'Twitter' ), |
|
| 917 | - "instagram" => __( 'Instagram' ), |
|
| 918 | - "linkedin" => __( 'Linkedin' ), |
|
| 919 | - "flickr" => __( 'Flickr' ), |
|
| 920 | - "github" => __( 'GitHub' ), |
|
| 921 | - "youtube" => __( 'YouTube' ), |
|
| 922 | - "wordpress" => __( 'WordPress' ), |
|
| 923 | - "google" => __( 'Google' ), |
|
| 924 | - "yahoo" => __( 'Yahoo' ), |
|
| 925 | - "vkontakte" => __( 'Vkontakte' ), |
|
| 926 | - ); |
|
| 914 | + return array( |
|
| 915 | + "facebook" => __( 'Facebook' ), |
|
| 916 | + "twitter" => __( 'Twitter' ), |
|
| 917 | + "instagram" => __( 'Instagram' ), |
|
| 918 | + "linkedin" => __( 'Linkedin' ), |
|
| 919 | + "flickr" => __( 'Flickr' ), |
|
| 920 | + "github" => __( 'GitHub' ), |
|
| 921 | + "youtube" => __( 'YouTube' ), |
|
| 922 | + "wordpress" => __( 'WordPress' ), |
|
| 923 | + "google" => __( 'Google' ), |
|
| 924 | + "yahoo" => __( 'Yahoo' ), |
|
| 925 | + "vkontakte" => __( 'Vkontakte' ), |
|
| 926 | + ); |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | |
@@ -938,38 +938,38 @@ discard block |
||
| 938 | 938 | function sd_get_container_class_input( $type = 'container', $overwrite = array() ) { |
| 939 | 939 | |
| 940 | 940 | |
| 941 | - $options = array( |
|
| 942 | - "container" => __( 'container (default)' ), |
|
| 943 | - "container-sm" => 'container-sm', |
|
| 944 | - "container-md" => 'container-md', |
|
| 945 | - "container-lg" => 'container-lg', |
|
| 946 | - "container-xl" => 'container-xl', |
|
| 947 | - "container-xxl" => 'container-xxl', |
|
| 948 | - "container-fluid" => 'container-fluid', |
|
| 949 | - "row" => 'row', |
|
| 950 | - "col" => 'col', |
|
| 951 | - "card" => 'card', |
|
| 952 | - "card-header" => 'card-header', |
|
| 953 | - "card-body" => 'card-body', |
|
| 954 | - "card-footer" => 'card-footer', |
|
| 955 | - "list-group" => 'list-group', |
|
| 956 | - "list-group-item" => 'list-group-item', |
|
| 957 | - ); |
|
| 958 | - |
|
| 959 | - $defaults = array( |
|
| 960 | - 'type' => 'select', |
|
| 961 | - 'title' => __( 'Type' ), |
|
| 962 | - 'options' => $options, |
|
| 963 | - 'default' => '', |
|
| 964 | - 'desc_tip' => true, |
|
| 965 | - 'group' => __( "Container" ) |
|
| 966 | - ); |
|
| 967 | - |
|
| 968 | - |
|
| 969 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 970 | - |
|
| 971 | - |
|
| 972 | - return $input; |
|
| 941 | + $options = array( |
|
| 942 | + "container" => __( 'container (default)' ), |
|
| 943 | + "container-sm" => 'container-sm', |
|
| 944 | + "container-md" => 'container-md', |
|
| 945 | + "container-lg" => 'container-lg', |
|
| 946 | + "container-xl" => 'container-xl', |
|
| 947 | + "container-xxl" => 'container-xxl', |
|
| 948 | + "container-fluid" => 'container-fluid', |
|
| 949 | + "row" => 'row', |
|
| 950 | + "col" => 'col', |
|
| 951 | + "card" => 'card', |
|
| 952 | + "card-header" => 'card-header', |
|
| 953 | + "card-body" => 'card-body', |
|
| 954 | + "card-footer" => 'card-footer', |
|
| 955 | + "list-group" => 'list-group', |
|
| 956 | + "list-group-item" => 'list-group-item', |
|
| 957 | + ); |
|
| 958 | + |
|
| 959 | + $defaults = array( |
|
| 960 | + 'type' => 'select', |
|
| 961 | + 'title' => __( 'Type' ), |
|
| 962 | + 'options' => $options, |
|
| 963 | + 'default' => '', |
|
| 964 | + 'desc_tip' => true, |
|
| 965 | + 'group' => __( "Container" ) |
|
| 966 | + ); |
|
| 967 | + |
|
| 968 | + |
|
| 969 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 970 | + |
|
| 971 | + |
|
| 972 | + return $input; |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | /** |
@@ -983,32 +983,32 @@ discard block |
||
| 983 | 983 | function sd_get_position_class_input( $type = 'position', $overwrite = array() ) { |
| 984 | 984 | |
| 985 | 985 | |
| 986 | - $options = array( |
|
| 987 | - "" => __( 'Default' ), |
|
| 988 | - "position-static" => 'static', |
|
| 989 | - "position-relative" => 'relative', |
|
| 990 | - "position-absolute" => 'absolute', |
|
| 991 | - "position-fixed" => 'fixed', |
|
| 992 | - "position-sticky" => 'sticky', |
|
| 993 | - "fixed-top" => 'fixed-top', |
|
| 994 | - "fixed-bottom" => 'fixed-bottom', |
|
| 995 | - "sticky-top" => 'sticky-top', |
|
| 996 | - ); |
|
| 986 | + $options = array( |
|
| 987 | + "" => __( 'Default' ), |
|
| 988 | + "position-static" => 'static', |
|
| 989 | + "position-relative" => 'relative', |
|
| 990 | + "position-absolute" => 'absolute', |
|
| 991 | + "position-fixed" => 'fixed', |
|
| 992 | + "position-sticky" => 'sticky', |
|
| 993 | + "fixed-top" => 'fixed-top', |
|
| 994 | + "fixed-bottom" => 'fixed-bottom', |
|
| 995 | + "sticky-top" => 'sticky-top', |
|
| 996 | + ); |
|
| 997 | 997 | |
| 998 | - $defaults = array( |
|
| 999 | - 'type' => 'select', |
|
| 1000 | - 'title' => __( 'Position' ), |
|
| 1001 | - 'options' => $options, |
|
| 1002 | - 'default' => '', |
|
| 1003 | - 'desc_tip' => true, |
|
| 1004 | - 'group' => __( "Wrapper Styles" ) |
|
| 1005 | - ); |
|
| 998 | + $defaults = array( |
|
| 999 | + 'type' => 'select', |
|
| 1000 | + 'title' => __( 'Position' ), |
|
| 1001 | + 'options' => $options, |
|
| 1002 | + 'default' => '', |
|
| 1003 | + 'desc_tip' => true, |
|
| 1004 | + 'group' => __( "Wrapper Styles" ) |
|
| 1005 | + ); |
|
| 1006 | 1006 | |
| 1007 | 1007 | |
| 1008 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1008 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1009 | 1009 | |
| 1010 | 1010 | |
| 1011 | - return $input; |
|
| 1011 | + return $input; |
|
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | /** |
@@ -1021,40 +1021,40 @@ discard block |
||
| 1021 | 1021 | */ |
| 1022 | 1022 | function sd_get_sticky_offset_input( $type = 'top', $overwrite = array() ) { |
| 1023 | 1023 | |
| 1024 | - $defaults = array( |
|
| 1025 | - 'type' => 'number', |
|
| 1026 | - 'title' => __( 'Sticky offset' ), |
|
| 1027 | - //'desc' => __('Sticky offset'), |
|
| 1028 | - 'default' => '', |
|
| 1029 | - 'desc_tip' => true, |
|
| 1030 | - 'group' => __( "Wrapper Styles" ), |
|
| 1031 | - 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"' |
|
| 1032 | - ); |
|
| 1033 | - |
|
| 1034 | - // title |
|
| 1035 | - if ( $type == 'top' ) { |
|
| 1036 | - $defaults['title'] = __( 'Top offset' ); |
|
| 1037 | - $defaults['icon'] = 'box-top'; |
|
| 1038 | - $defaults['row'] = array( |
|
| 1039 | - 'title' => __( 'Sticky offset' ), |
|
| 1040 | - 'key' => 'sticky-offset', |
|
| 1041 | - 'open' => true, |
|
| 1042 | - 'class' => 'text-center', |
|
| 1043 | - ); |
|
| 1044 | - } elseif ( $type == 'bottom' ) { |
|
| 1045 | - $defaults['title'] = __( 'Bottom offset' ); |
|
| 1046 | - $defaults['icon'] = 'box-bottom'; |
|
| 1047 | - $defaults['row'] = array( |
|
| 1048 | - 'key' => 'sticky-offset', |
|
| 1049 | - 'close' => true, |
|
| 1050 | - ); |
|
| 1051 | - } |
|
| 1052 | - |
|
| 1053 | - |
|
| 1054 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1055 | - |
|
| 1056 | - |
|
| 1057 | - return $input; |
|
| 1024 | + $defaults = array( |
|
| 1025 | + 'type' => 'number', |
|
| 1026 | + 'title' => __( 'Sticky offset' ), |
|
| 1027 | + //'desc' => __('Sticky offset'), |
|
| 1028 | + 'default' => '', |
|
| 1029 | + 'desc_tip' => true, |
|
| 1030 | + 'group' => __( "Wrapper Styles" ), |
|
| 1031 | + 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"' |
|
| 1032 | + ); |
|
| 1033 | + |
|
| 1034 | + // title |
|
| 1035 | + if ( $type == 'top' ) { |
|
| 1036 | + $defaults['title'] = __( 'Top offset' ); |
|
| 1037 | + $defaults['icon'] = 'box-top'; |
|
| 1038 | + $defaults['row'] = array( |
|
| 1039 | + 'title' => __( 'Sticky offset' ), |
|
| 1040 | + 'key' => 'sticky-offset', |
|
| 1041 | + 'open' => true, |
|
| 1042 | + 'class' => 'text-center', |
|
| 1043 | + ); |
|
| 1044 | + } elseif ( $type == 'bottom' ) { |
|
| 1045 | + $defaults['title'] = __( 'Bottom offset' ); |
|
| 1046 | + $defaults['icon'] = 'box-bottom'; |
|
| 1047 | + $defaults['row'] = array( |
|
| 1048 | + 'key' => 'sticky-offset', |
|
| 1049 | + 'close' => true, |
|
| 1050 | + ); |
|
| 1051 | + } |
|
| 1052 | + |
|
| 1053 | + |
|
| 1054 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1055 | + |
|
| 1056 | + |
|
| 1057 | + return $input; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | /** |
@@ -1068,38 +1068,38 @@ discard block |
||
| 1068 | 1068 | function sd_get_font_size_input( $type = 'font_size', $overwrite = array(), $has_custom = false ) { |
| 1069 | 1069 | |
| 1070 | 1070 | |
| 1071 | - $options = array( |
|
| 1072 | - "" => __( 'Inherit from parent' ), |
|
| 1073 | - "h6" => 'h6', |
|
| 1074 | - "h5" => 'h5', |
|
| 1075 | - "h4" => 'h4', |
|
| 1076 | - "h3" => 'h3', |
|
| 1077 | - "h2" => 'h2', |
|
| 1078 | - "h1" => 'h1', |
|
| 1079 | - "display-1" => "display-1", |
|
| 1080 | - "display-2" => "display-2", |
|
| 1081 | - "display-3" => "display-3", |
|
| 1082 | - "display-4" => "display-4", |
|
| 1083 | - ); |
|
| 1071 | + $options = array( |
|
| 1072 | + "" => __( 'Inherit from parent' ), |
|
| 1073 | + "h6" => 'h6', |
|
| 1074 | + "h5" => 'h5', |
|
| 1075 | + "h4" => 'h4', |
|
| 1076 | + "h3" => 'h3', |
|
| 1077 | + "h2" => 'h2', |
|
| 1078 | + "h1" => 'h1', |
|
| 1079 | + "display-1" => "display-1", |
|
| 1080 | + "display-2" => "display-2", |
|
| 1081 | + "display-3" => "display-3", |
|
| 1082 | + "display-4" => "display-4", |
|
| 1083 | + ); |
|
| 1084 | 1084 | |
| 1085 | - if ( $has_custom ) { |
|
| 1086 | - $options['custom'] = __( 'Custom size' ); |
|
| 1087 | - } |
|
| 1085 | + if ( $has_custom ) { |
|
| 1086 | + $options['custom'] = __( 'Custom size' ); |
|
| 1087 | + } |
|
| 1088 | 1088 | |
| 1089 | - $defaults = array( |
|
| 1090 | - 'type' => 'select', |
|
| 1091 | - 'title' => __( 'Font size' ), |
|
| 1092 | - 'options' => $options, |
|
| 1093 | - 'default' => '', |
|
| 1094 | - 'desc_tip' => true, |
|
| 1095 | - 'group' => __( "Typography" ) |
|
| 1096 | - ); |
|
| 1089 | + $defaults = array( |
|
| 1090 | + 'type' => 'select', |
|
| 1091 | + 'title' => __( 'Font size' ), |
|
| 1092 | + 'options' => $options, |
|
| 1093 | + 'default' => '', |
|
| 1094 | + 'desc_tip' => true, |
|
| 1095 | + 'group' => __( "Typography" ) |
|
| 1096 | + ); |
|
| 1097 | 1097 | |
| 1098 | 1098 | |
| 1099 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1099 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1100 | 1100 | |
| 1101 | 1101 | |
| 1102 | - return $input; |
|
| 1102 | + return $input; |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | 1105 | /** |
@@ -1113,29 +1113,29 @@ discard block |
||
| 1113 | 1113 | function sd_get_font_custom_size_input( $type = 'font_size_custom', $overwrite = array(), $parent_type = '' ) { |
| 1114 | 1114 | |
| 1115 | 1115 | |
| 1116 | - $defaults = array( |
|
| 1117 | - 'type' => 'number', |
|
| 1118 | - 'title' => __( 'Font size (rem)' ), |
|
| 1119 | - 'default' => '', |
|
| 1120 | - 'placeholder' => '1.25', |
|
| 1121 | - 'custom_attributes' => array( |
|
| 1122 | - 'step' => '0.1', |
|
| 1123 | - 'min' => '0', |
|
| 1124 | - 'max' => '100', |
|
| 1125 | - ), |
|
| 1126 | - 'desc_tip' => true, |
|
| 1127 | - 'group' => __( "Typography" ) |
|
| 1128 | - ); |
|
| 1116 | + $defaults = array( |
|
| 1117 | + 'type' => 'number', |
|
| 1118 | + 'title' => __( 'Font size (rem)' ), |
|
| 1119 | + 'default' => '', |
|
| 1120 | + 'placeholder' => '1.25', |
|
| 1121 | + 'custom_attributes' => array( |
|
| 1122 | + 'step' => '0.1', |
|
| 1123 | + 'min' => '0', |
|
| 1124 | + 'max' => '100', |
|
| 1125 | + ), |
|
| 1126 | + 'desc_tip' => true, |
|
| 1127 | + 'group' => __( "Typography" ) |
|
| 1128 | + ); |
|
| 1129 | 1129 | |
| 1130 | - if ( $parent_type ) { |
|
| 1131 | - $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1132 | - } |
|
| 1130 | + if ( $parent_type ) { |
|
| 1131 | + $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1132 | + } |
|
| 1133 | 1133 | |
| 1134 | 1134 | |
| 1135 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1135 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1136 | 1136 | |
| 1137 | 1137 | |
| 1138 | - return $input; |
|
| 1138 | + return $input; |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | /** |
@@ -1149,19 +1149,19 @@ discard block |
||
| 1149 | 1149 | function sd_get_font_size_input_group( $type = 'font_size', $overwrite = array(), $overwrite_custom = array() ) { |
| 1150 | 1150 | |
| 1151 | 1151 | |
| 1152 | - $inputs = array(); |
|
| 1152 | + $inputs = array(); |
|
| 1153 | 1153 | |
| 1154 | - if ( $overwrite !== false ) { |
|
| 1155 | - $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1156 | - } |
|
| 1154 | + if ( $overwrite !== false ) { |
|
| 1155 | + $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1156 | + } |
|
| 1157 | 1157 | |
| 1158 | - if ( $overwrite_custom !== false ) { |
|
| 1159 | - $custom = $type . "_custom"; |
|
| 1160 | - $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1161 | - } |
|
| 1158 | + if ( $overwrite_custom !== false ) { |
|
| 1159 | + $custom = $type . "_custom"; |
|
| 1160 | + $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1161 | + } |
|
| 1162 | 1162 | |
| 1163 | 1163 | |
| 1164 | - return $inputs; |
|
| 1164 | + return $inputs; |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | /** |
@@ -1175,35 +1175,35 @@ discard block |
||
| 1175 | 1175 | function sd_get_font_weight_input( $type = 'font_weight', $overwrite = array() ) { |
| 1176 | 1176 | |
| 1177 | 1177 | |
| 1178 | - $options = array( |
|
| 1179 | - "" => __( 'Inherit' ), |
|
| 1180 | - "font-weight-bold" => 'bold', |
|
| 1181 | - "font-weight-bolder" => 'bolder', |
|
| 1182 | - "font-weight-normal" => 'normal', |
|
| 1183 | - "font-weight-light" => 'light', |
|
| 1184 | - "font-weight-lighter" => 'lighter', |
|
| 1185 | - "font-italic" => 'italic', |
|
| 1186 | - "font-weight-bold font-italic" => 'bold italic', |
|
| 1187 | - "font-weight-bolder font-italic" => 'bolder italic', |
|
| 1188 | - "font-weight-normal font-italic" => 'normal italic', |
|
| 1189 | - "font-weight-light font-italic" => 'light italic', |
|
| 1190 | - "font-weight-lighter font-italic" => 'lighter italic', |
|
| 1191 | - ); |
|
| 1178 | + $options = array( |
|
| 1179 | + "" => __( 'Inherit' ), |
|
| 1180 | + "font-weight-bold" => 'bold', |
|
| 1181 | + "font-weight-bolder" => 'bolder', |
|
| 1182 | + "font-weight-normal" => 'normal', |
|
| 1183 | + "font-weight-light" => 'light', |
|
| 1184 | + "font-weight-lighter" => 'lighter', |
|
| 1185 | + "font-italic" => 'italic', |
|
| 1186 | + "font-weight-bold font-italic" => 'bold italic', |
|
| 1187 | + "font-weight-bolder font-italic" => 'bolder italic', |
|
| 1188 | + "font-weight-normal font-italic" => 'normal italic', |
|
| 1189 | + "font-weight-light font-italic" => 'light italic', |
|
| 1190 | + "font-weight-lighter font-italic" => 'lighter italic', |
|
| 1191 | + ); |
|
| 1192 | 1192 | |
| 1193 | - $defaults = array( |
|
| 1194 | - 'type' => 'select', |
|
| 1195 | - 'title' => __( 'Appearance' ), |
|
| 1196 | - 'options' => $options, |
|
| 1197 | - 'default' => '', |
|
| 1198 | - 'desc_tip' => true, |
|
| 1199 | - 'group' => __( "Typography" ) |
|
| 1200 | - ); |
|
| 1193 | + $defaults = array( |
|
| 1194 | + 'type' => 'select', |
|
| 1195 | + 'title' => __( 'Appearance' ), |
|
| 1196 | + 'options' => $options, |
|
| 1197 | + 'default' => '', |
|
| 1198 | + 'desc_tip' => true, |
|
| 1199 | + 'group' => __( "Typography" ) |
|
| 1200 | + ); |
|
| 1201 | 1201 | |
| 1202 | 1202 | |
| 1203 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1203 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1204 | 1204 | |
| 1205 | 1205 | |
| 1206 | - return $input; |
|
| 1206 | + return $input; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | /** |
@@ -1217,27 +1217,27 @@ discard block |
||
| 1217 | 1217 | function sd_get_font_case_input( $type = 'font_weight', $overwrite = array() ) { |
| 1218 | 1218 | |
| 1219 | 1219 | |
| 1220 | - $options = array( |
|
| 1221 | - "" => __( 'Default' ), |
|
| 1222 | - "text-lowercase" => __( 'lowercase' ), |
|
| 1223 | - "text-uppercase" => __( 'UPPERCASE' ), |
|
| 1224 | - "text-capitalize" => __( 'Capitalize' ), |
|
| 1225 | - ); |
|
| 1220 | + $options = array( |
|
| 1221 | + "" => __( 'Default' ), |
|
| 1222 | + "text-lowercase" => __( 'lowercase' ), |
|
| 1223 | + "text-uppercase" => __( 'UPPERCASE' ), |
|
| 1224 | + "text-capitalize" => __( 'Capitalize' ), |
|
| 1225 | + ); |
|
| 1226 | 1226 | |
| 1227 | - $defaults = array( |
|
| 1228 | - 'type' => 'select', |
|
| 1229 | - 'title' => __( 'Letter case' ), |
|
| 1230 | - 'options' => $options, |
|
| 1231 | - 'default' => '', |
|
| 1232 | - 'desc_tip' => true, |
|
| 1233 | - 'group' => __( "Typography" ) |
|
| 1234 | - ); |
|
| 1227 | + $defaults = array( |
|
| 1228 | + 'type' => 'select', |
|
| 1229 | + 'title' => __( 'Letter case' ), |
|
| 1230 | + 'options' => $options, |
|
| 1231 | + 'default' => '', |
|
| 1232 | + 'desc_tip' => true, |
|
| 1233 | + 'group' => __( "Typography" ) |
|
| 1234 | + ); |
|
| 1235 | 1235 | |
| 1236 | 1236 | |
| 1237 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1237 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1238 | 1238 | |
| 1239 | 1239 | |
| 1240 | - return $input; |
|
| 1240 | + return $input; |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | /** |
@@ -1252,24 +1252,24 @@ discard block |
||
| 1252 | 1252 | function sd_get_font_italic_input( $type = 'font_italic', $overwrite = array() ) { |
| 1253 | 1253 | |
| 1254 | 1254 | |
| 1255 | - $options = array( |
|
| 1256 | - "" => __( 'No' ), |
|
| 1257 | - "font-italic" => __( 'Yes' ) |
|
| 1258 | - ); |
|
| 1255 | + $options = array( |
|
| 1256 | + "" => __( 'No' ), |
|
| 1257 | + "font-italic" => __( 'Yes' ) |
|
| 1258 | + ); |
|
| 1259 | 1259 | |
| 1260 | - $defaults = array( |
|
| 1261 | - 'type' => 'select', |
|
| 1262 | - 'title' => __( 'Font italic' ), |
|
| 1263 | - 'options' => $options, |
|
| 1264 | - 'default' => '', |
|
| 1265 | - 'desc_tip' => true, |
|
| 1266 | - 'group' => __( "Typography" ) |
|
| 1267 | - ); |
|
| 1260 | + $defaults = array( |
|
| 1261 | + 'type' => 'select', |
|
| 1262 | + 'title' => __( 'Font italic' ), |
|
| 1263 | + 'options' => $options, |
|
| 1264 | + 'default' => '', |
|
| 1265 | + 'desc_tip' => true, |
|
| 1266 | + 'group' => __( "Typography" ) |
|
| 1267 | + ); |
|
| 1268 | 1268 | |
| 1269 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1269 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1270 | 1270 | |
| 1271 | 1271 | |
| 1272 | - return $input; |
|
| 1272 | + return $input; |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | /** |
@@ -1283,19 +1283,19 @@ discard block |
||
| 1283 | 1283 | function sd_get_anchor_input( $type = 'anchor', $overwrite = array() ) { |
| 1284 | 1284 | |
| 1285 | 1285 | |
| 1286 | - $defaults = array( |
|
| 1287 | - 'type' => 'text', |
|
| 1288 | - 'title' => __( 'HTML anchor' ), |
|
| 1289 | - '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.' ), |
|
| 1290 | - 'default' => '', |
|
| 1291 | - 'desc_tip' => true, |
|
| 1292 | - 'group' => __( "Advanced" ) |
|
| 1293 | - ); |
|
| 1286 | + $defaults = array( |
|
| 1287 | + 'type' => 'text', |
|
| 1288 | + 'title' => __( 'HTML anchor' ), |
|
| 1289 | + '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.' ), |
|
| 1290 | + 'default' => '', |
|
| 1291 | + 'desc_tip' => true, |
|
| 1292 | + 'group' => __( "Advanced" ) |
|
| 1293 | + ); |
|
| 1294 | 1294 | |
| 1295 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1295 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1296 | 1296 | |
| 1297 | 1297 | |
| 1298 | - return $input; |
|
| 1298 | + return $input; |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | /** |
@@ -1308,19 +1308,19 @@ discard block |
||
| 1308 | 1308 | */ |
| 1309 | 1309 | function sd_get_class_input( $type = 'css_class', $overwrite = array() ) { |
| 1310 | 1310 | |
| 1311 | - $defaults = array( |
|
| 1312 | - 'type' => 'text', |
|
| 1313 | - 'title' => __( 'Additional CSS class(es)' ), |
|
| 1314 | - 'desc' => __( 'Separate multiple classes with spaces.' ), |
|
| 1315 | - 'default' => '', |
|
| 1316 | - 'desc_tip' => true, |
|
| 1317 | - 'group' => __( "Advanced" ) |
|
| 1318 | - ); |
|
| 1311 | + $defaults = array( |
|
| 1312 | + 'type' => 'text', |
|
| 1313 | + 'title' => __( 'Additional CSS class(es)' ), |
|
| 1314 | + 'desc' => __( 'Separate multiple classes with spaces.' ), |
|
| 1315 | + 'default' => '', |
|
| 1316 | + 'desc_tip' => true, |
|
| 1317 | + 'group' => __( "Advanced" ) |
|
| 1318 | + ); |
|
| 1319 | 1319 | |
| 1320 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1320 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1321 | 1321 | |
| 1322 | 1322 | |
| 1323 | - return $input; |
|
| 1323 | + return $input; |
|
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | |
@@ -1334,318 +1334,318 @@ discard block |
||
| 1334 | 1334 | */ |
| 1335 | 1335 | function sd_build_aui_class( $args ) { |
| 1336 | 1336 | |
| 1337 | - $classes = array(); |
|
| 1338 | - |
|
| 1339 | - // margins. |
|
| 1340 | - if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 1341 | - $classes[] = "mt-" . sanitize_html_class( $args['mt'] ); |
|
| 1342 | - $mt = $args['mt']; |
|
| 1343 | - } else { |
|
| 1344 | - $mt = null; |
|
| 1345 | - } |
|
| 1346 | - if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 1347 | - $classes[] = "mr-" . sanitize_html_class( $args['mr'] ); |
|
| 1348 | - $mr = $args['mr']; |
|
| 1349 | - } else { |
|
| 1350 | - $mr = null; |
|
| 1351 | - } |
|
| 1352 | - if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 1353 | - $classes[] = "mb-" . sanitize_html_class( $args['mb'] ); |
|
| 1354 | - $mb = $args['mb']; |
|
| 1355 | - } else { |
|
| 1356 | - $mb = null; |
|
| 1357 | - } |
|
| 1358 | - if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 1359 | - $classes[] = "ml-" . sanitize_html_class( $args['ml'] ); |
|
| 1360 | - $ml = $args['ml']; |
|
| 1361 | - } else { |
|
| 1362 | - $ml = null; |
|
| 1363 | - } |
|
| 1364 | - |
|
| 1365 | - // margins tablet. |
|
| 1366 | - if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 1367 | - $classes[] = "mt-md-" . sanitize_html_class( $args['mt_md'] ); |
|
| 1368 | - $mt_md = $args['mt_md']; |
|
| 1369 | - } else { |
|
| 1370 | - $mt_md = null; |
|
| 1371 | - } |
|
| 1372 | - if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 1373 | - $classes[] = "mr-md-" . sanitize_html_class( $args['mr_md'] ); |
|
| 1374 | - $mt_md = $args['mr_md']; |
|
| 1375 | - } else { |
|
| 1376 | - $mr_md = null; |
|
| 1377 | - } |
|
| 1378 | - if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 1379 | - $classes[] = "mb-md-" . sanitize_html_class( $args['mb_md'] ); |
|
| 1380 | - $mt_md = $args['mb_md']; |
|
| 1381 | - } else { |
|
| 1382 | - $mb_md = null; |
|
| 1383 | - } |
|
| 1384 | - if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 1385 | - $classes[] = "ml-md-" . sanitize_html_class( $args['ml_md'] ); |
|
| 1386 | - $mt_md = $args['ml_md']; |
|
| 1387 | - } else { |
|
| 1388 | - $ml_md = null; |
|
| 1389 | - } |
|
| 1390 | - |
|
| 1391 | - // margins desktop. |
|
| 1392 | - if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 1393 | - if ( $mt == null && $mt_md == null ) { |
|
| 1394 | - $classes[] = "mt-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1395 | - } else { |
|
| 1396 | - $classes[] = "mt-lg-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1397 | - } |
|
| 1398 | - } |
|
| 1399 | - if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 1400 | - if ( $mr == null && $mr_md == null ) { |
|
| 1401 | - $classes[] = "mr-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1402 | - } else { |
|
| 1403 | - $classes[] = "mr-lg-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1404 | - } |
|
| 1405 | - } |
|
| 1406 | - if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 1407 | - if ( $mb == null && $mb_md == null ) { |
|
| 1408 | - $classes[] = "mb-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1409 | - } else { |
|
| 1410 | - $classes[] = "mb-lg-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1411 | - } |
|
| 1412 | - } |
|
| 1413 | - if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 1414 | - if ( $ml == null && $ml_md == null ) { |
|
| 1415 | - $classes[] = "ml-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1416 | - } else { |
|
| 1417 | - $classes[] = "ml-lg-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1418 | - } |
|
| 1419 | - } |
|
| 1420 | - |
|
| 1421 | - |
|
| 1422 | - // padding. |
|
| 1423 | - if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 1424 | - $classes[] = "pt-" . sanitize_html_class( $args['pt'] ); |
|
| 1425 | - $pt = $args['pt']; |
|
| 1426 | - } else { |
|
| 1427 | - $pt = null; |
|
| 1428 | - } |
|
| 1429 | - if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 1430 | - $classes[] = "pr-" . sanitize_html_class( $args['pr'] ); |
|
| 1431 | - $pr = $args['pr']; |
|
| 1432 | - } else { |
|
| 1433 | - $pr = null; |
|
| 1434 | - } |
|
| 1435 | - if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 1436 | - $classes[] = "pb-" . sanitize_html_class( $args['pb'] ); |
|
| 1437 | - $pb = $args['pb']; |
|
| 1438 | - } else { |
|
| 1439 | - $pb = null; |
|
| 1440 | - } |
|
| 1441 | - if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 1442 | - $classes[] = "pl-" . sanitize_html_class( $args['pl'] ); |
|
| 1443 | - $pl = $args['pl']; |
|
| 1444 | - } else { |
|
| 1445 | - $pl = null; |
|
| 1446 | - } |
|
| 1447 | - |
|
| 1448 | - // padding tablet. |
|
| 1449 | - if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 1450 | - $classes[] = "pt-md-" . sanitize_html_class( $args['pt_md'] ); |
|
| 1451 | - $pt_md = $args['pt_md']; |
|
| 1452 | - } else { |
|
| 1453 | - $pt_md = null; |
|
| 1454 | - } |
|
| 1455 | - if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 1456 | - $classes[] = "pr-md-" . sanitize_html_class( $args['pr_md'] ); |
|
| 1457 | - $pt_md = $args['pr_md']; |
|
| 1458 | - } else { |
|
| 1459 | - $pr_md = null; |
|
| 1460 | - } |
|
| 1461 | - if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 1462 | - $classes[] = "pb-md-" . sanitize_html_class( $args['pb_md'] ); |
|
| 1463 | - $pt_md = $args['pb_md']; |
|
| 1464 | - } else { |
|
| 1465 | - $pb_md = null; |
|
| 1466 | - } |
|
| 1467 | - if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 1468 | - $classes[] = "pl-md-" . sanitize_html_class( $args['pl_md'] ); |
|
| 1469 | - $pt_md = $args['pl_md']; |
|
| 1470 | - } else { |
|
| 1471 | - $pl_md = null; |
|
| 1472 | - } |
|
| 1473 | - |
|
| 1474 | - // padding desktop. |
|
| 1475 | - if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 1476 | - if ( $pt == null && $pt_md == null ) { |
|
| 1477 | - $classes[] = "pt-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1478 | - } else { |
|
| 1479 | - $classes[] = "pt-lg-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1480 | - } |
|
| 1481 | - } |
|
| 1482 | - if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 1483 | - if ( $pr == null && $pr_md == null ) { |
|
| 1484 | - $classes[] = "pr-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1485 | - } else { |
|
| 1486 | - $classes[] = "pr-lg-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1487 | - } |
|
| 1488 | - } |
|
| 1489 | - if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 1490 | - if ( $pb == null && $pb_md == null ) { |
|
| 1491 | - $classes[] = "pb-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1492 | - } else { |
|
| 1493 | - $classes[] = "pb-lg-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1494 | - } |
|
| 1495 | - } |
|
| 1496 | - if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 1497 | - if ( $pl == null && $pl_md == null ) { |
|
| 1498 | - $classes[] = "pl-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1499 | - } else { |
|
| 1500 | - $classes[] = "pl-lg-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1501 | - } |
|
| 1502 | - } |
|
| 1503 | - |
|
| 1504 | - // row cols, mobile, tablet, desktop |
|
| 1505 | - if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 1506 | - $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols'] ); |
|
| 1507 | - $row_cols = $args['row_cols']; |
|
| 1508 | - } else { |
|
| 1509 | - $row_cols = null; |
|
| 1510 | - } |
|
| 1511 | - if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 1512 | - $classes[] = sanitize_html_class( "row-cols-md-" . $args['row_cols_md'] ); |
|
| 1513 | - $row_cols_md = $args['row_cols_md']; |
|
| 1514 | - } else { |
|
| 1515 | - $row_cols_md = null; |
|
| 1516 | - } |
|
| 1517 | - if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 1518 | - if ( $row_cols == null && $row_cols_md == null ) { |
|
| 1519 | - $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols_lg'] ); |
|
| 1520 | - } else { |
|
| 1521 | - $classes[] = sanitize_html_class( "row-cols-lg-" . $args['row_cols_lg'] ); |
|
| 1522 | - } |
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - // columns , mobile, tablet, desktop |
|
| 1526 | - if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 1527 | - $classes[] = sanitize_html_class( "col-" . $args['col'] ); |
|
| 1528 | - $col = $args['col']; |
|
| 1529 | - } else { |
|
| 1530 | - $col = null; |
|
| 1531 | - } |
|
| 1532 | - if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 1533 | - $classes[] = sanitize_html_class( "col-md-" . $args['col_md'] ); |
|
| 1534 | - $col_md = $args['col_md']; |
|
| 1535 | - } else { |
|
| 1536 | - $col_md = null; |
|
| 1537 | - } |
|
| 1538 | - if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 1539 | - if ( $col == null && $col_md == null ) { |
|
| 1540 | - $classes[] = sanitize_html_class( "col-" . $args['col_lg'] ); |
|
| 1541 | - } else { |
|
| 1542 | - $classes[] = sanitize_html_class( "col-lg-" . $args['col_lg'] ); |
|
| 1543 | - } |
|
| 1544 | - } |
|
| 1545 | - |
|
| 1546 | - |
|
| 1547 | - // border |
|
| 1548 | - if ( ! empty( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' ) ) { |
|
| 1549 | - $classes[] = "border-0"; |
|
| 1550 | - } elseif ( ! empty( $args['border'] ) ) { |
|
| 1551 | - $classes[] = "border border-" . sanitize_html_class( $args['border'] ); |
|
| 1552 | - } |
|
| 1553 | - |
|
| 1554 | - // border radius type |
|
| 1555 | - if ( ! empty( $args['rounded'] ) ) { |
|
| 1556 | - $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 1557 | - } |
|
| 1558 | - |
|
| 1559 | - // border radius size |
|
| 1560 | - if ( ! empty( $args['rounded_size'] ) ) { |
|
| 1561 | - $classes[] = "rounded-" . sanitize_html_class( $args['rounded_size'] ); |
|
| 1562 | - // if we set a size then we need to remove "rounded" if set |
|
| 1563 | - if ( ( $key = array_search( "rounded", $classes ) ) !== false ) { |
|
| 1564 | - unset( $classes[ $key ] ); |
|
| 1565 | - } |
|
| 1566 | - } |
|
| 1567 | - |
|
| 1568 | - // shadow |
|
| 1569 | - //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 1570 | - |
|
| 1571 | - // background |
|
| 1572 | - if ( ! empty( $args['bg'] ) ) { |
|
| 1573 | - $classes[] = "bg-" . sanitize_html_class( $args['bg'] ); |
|
| 1574 | - } |
|
| 1575 | - |
|
| 1576 | - // text_color |
|
| 1577 | - if ( ! empty( $args['text_color'] ) ) { |
|
| 1578 | - $classes[] = "text-" . sanitize_html_class( $args['text_color'] ); |
|
| 1579 | - } |
|
| 1580 | - |
|
| 1581 | - // text_align |
|
| 1582 | - if ( ! empty( $args['text_justify'] ) ) { |
|
| 1583 | - $classes[] = 'text-justify'; |
|
| 1584 | - } else { |
|
| 1585 | - if ( ! empty( $args['text_align'] ) ) { |
|
| 1586 | - $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 1587 | - $text_align = $args['text_align']; |
|
| 1588 | - } else { |
|
| 1589 | - $text_align = null; |
|
| 1590 | - } |
|
| 1591 | - if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 1592 | - $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 1593 | - $text_align_md = $args['text_align_md']; |
|
| 1594 | - } else { |
|
| 1595 | - $text_align_md = null; |
|
| 1596 | - } |
|
| 1597 | - if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 1598 | - if ( $text_align == null && $text_align_md == null ) { |
|
| 1599 | - $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['text_align_lg'] ) ); |
|
| 1600 | - } else { |
|
| 1601 | - $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 1602 | - } |
|
| 1603 | - } |
|
| 1604 | - } |
|
| 1605 | - |
|
| 1606 | - // display |
|
| 1607 | - if ( ! empty( $args['display'] ) ) { |
|
| 1608 | - $classes[] = sanitize_html_class( $args['display'] ); |
|
| 1609 | - $display = $args['display']; |
|
| 1610 | - } else { |
|
| 1611 | - $display = null; |
|
| 1612 | - } |
|
| 1613 | - if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 1614 | - $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 1615 | - $display_md = $args['display_md']; |
|
| 1616 | - } else { |
|
| 1617 | - $display_md = null; |
|
| 1618 | - } |
|
| 1619 | - if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 1620 | - if ( $display == null && $display_md == null ) { |
|
| 1621 | - $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['display_lg'] ) ); |
|
| 1622 | - } else { |
|
| 1623 | - $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 1624 | - } |
|
| 1625 | - } |
|
| 1626 | - |
|
| 1627 | - |
|
| 1628 | - // bgtus - background transparent until scroll |
|
| 1629 | - if ( ! empty( $args['bgtus'] ) ) { |
|
| 1630 | - $classes[] = sanitize_html_class( "bg-transparent-until-scroll" ); |
|
| 1631 | - } |
|
| 1632 | - |
|
| 1633 | - |
|
| 1634 | - // build classes from build keys |
|
| 1635 | - $build_keys = sd_get_class_build_keys(); |
|
| 1636 | - if ( ! empty( $build_keys ) ) { |
|
| 1637 | - foreach ( $build_keys as $key ) { |
|
| 1638 | - if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 1639 | - continue; |
|
| 1640 | - } |
|
| 1641 | - if ( ! empty( $args[ $key ] ) ) { |
|
| 1642 | - $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 1643 | - } |
|
| 1644 | - } |
|
| 1645 | - } |
|
| 1646 | - |
|
| 1647 | - |
|
| 1648 | - return implode( " ", $classes ); |
|
| 1337 | + $classes = array(); |
|
| 1338 | + |
|
| 1339 | + // margins. |
|
| 1340 | + if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 1341 | + $classes[] = "mt-" . sanitize_html_class( $args['mt'] ); |
|
| 1342 | + $mt = $args['mt']; |
|
| 1343 | + } else { |
|
| 1344 | + $mt = null; |
|
| 1345 | + } |
|
| 1346 | + if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 1347 | + $classes[] = "mr-" . sanitize_html_class( $args['mr'] ); |
|
| 1348 | + $mr = $args['mr']; |
|
| 1349 | + } else { |
|
| 1350 | + $mr = null; |
|
| 1351 | + } |
|
| 1352 | + if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 1353 | + $classes[] = "mb-" . sanitize_html_class( $args['mb'] ); |
|
| 1354 | + $mb = $args['mb']; |
|
| 1355 | + } else { |
|
| 1356 | + $mb = null; |
|
| 1357 | + } |
|
| 1358 | + if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 1359 | + $classes[] = "ml-" . sanitize_html_class( $args['ml'] ); |
|
| 1360 | + $ml = $args['ml']; |
|
| 1361 | + } else { |
|
| 1362 | + $ml = null; |
|
| 1363 | + } |
|
| 1364 | + |
|
| 1365 | + // margins tablet. |
|
| 1366 | + if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 1367 | + $classes[] = "mt-md-" . sanitize_html_class( $args['mt_md'] ); |
|
| 1368 | + $mt_md = $args['mt_md']; |
|
| 1369 | + } else { |
|
| 1370 | + $mt_md = null; |
|
| 1371 | + } |
|
| 1372 | + if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 1373 | + $classes[] = "mr-md-" . sanitize_html_class( $args['mr_md'] ); |
|
| 1374 | + $mt_md = $args['mr_md']; |
|
| 1375 | + } else { |
|
| 1376 | + $mr_md = null; |
|
| 1377 | + } |
|
| 1378 | + if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 1379 | + $classes[] = "mb-md-" . sanitize_html_class( $args['mb_md'] ); |
|
| 1380 | + $mt_md = $args['mb_md']; |
|
| 1381 | + } else { |
|
| 1382 | + $mb_md = null; |
|
| 1383 | + } |
|
| 1384 | + if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 1385 | + $classes[] = "ml-md-" . sanitize_html_class( $args['ml_md'] ); |
|
| 1386 | + $mt_md = $args['ml_md']; |
|
| 1387 | + } else { |
|
| 1388 | + $ml_md = null; |
|
| 1389 | + } |
|
| 1390 | + |
|
| 1391 | + // margins desktop. |
|
| 1392 | + if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 1393 | + if ( $mt == null && $mt_md == null ) { |
|
| 1394 | + $classes[] = "mt-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1395 | + } else { |
|
| 1396 | + $classes[] = "mt-lg-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1397 | + } |
|
| 1398 | + } |
|
| 1399 | + if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 1400 | + if ( $mr == null && $mr_md == null ) { |
|
| 1401 | + $classes[] = "mr-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1402 | + } else { |
|
| 1403 | + $classes[] = "mr-lg-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1404 | + } |
|
| 1405 | + } |
|
| 1406 | + if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 1407 | + if ( $mb == null && $mb_md == null ) { |
|
| 1408 | + $classes[] = "mb-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1409 | + } else { |
|
| 1410 | + $classes[] = "mb-lg-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1411 | + } |
|
| 1412 | + } |
|
| 1413 | + if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 1414 | + if ( $ml == null && $ml_md == null ) { |
|
| 1415 | + $classes[] = "ml-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1416 | + } else { |
|
| 1417 | + $classes[] = "ml-lg-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1418 | + } |
|
| 1419 | + } |
|
| 1420 | + |
|
| 1421 | + |
|
| 1422 | + // padding. |
|
| 1423 | + if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 1424 | + $classes[] = "pt-" . sanitize_html_class( $args['pt'] ); |
|
| 1425 | + $pt = $args['pt']; |
|
| 1426 | + } else { |
|
| 1427 | + $pt = null; |
|
| 1428 | + } |
|
| 1429 | + if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 1430 | + $classes[] = "pr-" . sanitize_html_class( $args['pr'] ); |
|
| 1431 | + $pr = $args['pr']; |
|
| 1432 | + } else { |
|
| 1433 | + $pr = null; |
|
| 1434 | + } |
|
| 1435 | + if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 1436 | + $classes[] = "pb-" . sanitize_html_class( $args['pb'] ); |
|
| 1437 | + $pb = $args['pb']; |
|
| 1438 | + } else { |
|
| 1439 | + $pb = null; |
|
| 1440 | + } |
|
| 1441 | + if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 1442 | + $classes[] = "pl-" . sanitize_html_class( $args['pl'] ); |
|
| 1443 | + $pl = $args['pl']; |
|
| 1444 | + } else { |
|
| 1445 | + $pl = null; |
|
| 1446 | + } |
|
| 1447 | + |
|
| 1448 | + // padding tablet. |
|
| 1449 | + if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 1450 | + $classes[] = "pt-md-" . sanitize_html_class( $args['pt_md'] ); |
|
| 1451 | + $pt_md = $args['pt_md']; |
|
| 1452 | + } else { |
|
| 1453 | + $pt_md = null; |
|
| 1454 | + } |
|
| 1455 | + if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 1456 | + $classes[] = "pr-md-" . sanitize_html_class( $args['pr_md'] ); |
|
| 1457 | + $pt_md = $args['pr_md']; |
|
| 1458 | + } else { |
|
| 1459 | + $pr_md = null; |
|
| 1460 | + } |
|
| 1461 | + if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 1462 | + $classes[] = "pb-md-" . sanitize_html_class( $args['pb_md'] ); |
|
| 1463 | + $pt_md = $args['pb_md']; |
|
| 1464 | + } else { |
|
| 1465 | + $pb_md = null; |
|
| 1466 | + } |
|
| 1467 | + if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 1468 | + $classes[] = "pl-md-" . sanitize_html_class( $args['pl_md'] ); |
|
| 1469 | + $pt_md = $args['pl_md']; |
|
| 1470 | + } else { |
|
| 1471 | + $pl_md = null; |
|
| 1472 | + } |
|
| 1473 | + |
|
| 1474 | + // padding desktop. |
|
| 1475 | + if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 1476 | + if ( $pt == null && $pt_md == null ) { |
|
| 1477 | + $classes[] = "pt-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1478 | + } else { |
|
| 1479 | + $classes[] = "pt-lg-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1480 | + } |
|
| 1481 | + } |
|
| 1482 | + if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 1483 | + if ( $pr == null && $pr_md == null ) { |
|
| 1484 | + $classes[] = "pr-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1485 | + } else { |
|
| 1486 | + $classes[] = "pr-lg-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1487 | + } |
|
| 1488 | + } |
|
| 1489 | + if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 1490 | + if ( $pb == null && $pb_md == null ) { |
|
| 1491 | + $classes[] = "pb-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1492 | + } else { |
|
| 1493 | + $classes[] = "pb-lg-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1494 | + } |
|
| 1495 | + } |
|
| 1496 | + if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 1497 | + if ( $pl == null && $pl_md == null ) { |
|
| 1498 | + $classes[] = "pl-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1499 | + } else { |
|
| 1500 | + $classes[] = "pl-lg-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1501 | + } |
|
| 1502 | + } |
|
| 1503 | + |
|
| 1504 | + // row cols, mobile, tablet, desktop |
|
| 1505 | + if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 1506 | + $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols'] ); |
|
| 1507 | + $row_cols = $args['row_cols']; |
|
| 1508 | + } else { |
|
| 1509 | + $row_cols = null; |
|
| 1510 | + } |
|
| 1511 | + if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 1512 | + $classes[] = sanitize_html_class( "row-cols-md-" . $args['row_cols_md'] ); |
|
| 1513 | + $row_cols_md = $args['row_cols_md']; |
|
| 1514 | + } else { |
|
| 1515 | + $row_cols_md = null; |
|
| 1516 | + } |
|
| 1517 | + if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 1518 | + if ( $row_cols == null && $row_cols_md == null ) { |
|
| 1519 | + $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols_lg'] ); |
|
| 1520 | + } else { |
|
| 1521 | + $classes[] = sanitize_html_class( "row-cols-lg-" . $args['row_cols_lg'] ); |
|
| 1522 | + } |
|
| 1523 | + } |
|
| 1524 | + |
|
| 1525 | + // columns , mobile, tablet, desktop |
|
| 1526 | + if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 1527 | + $classes[] = sanitize_html_class( "col-" . $args['col'] ); |
|
| 1528 | + $col = $args['col']; |
|
| 1529 | + } else { |
|
| 1530 | + $col = null; |
|
| 1531 | + } |
|
| 1532 | + if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 1533 | + $classes[] = sanitize_html_class( "col-md-" . $args['col_md'] ); |
|
| 1534 | + $col_md = $args['col_md']; |
|
| 1535 | + } else { |
|
| 1536 | + $col_md = null; |
|
| 1537 | + } |
|
| 1538 | + if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 1539 | + if ( $col == null && $col_md == null ) { |
|
| 1540 | + $classes[] = sanitize_html_class( "col-" . $args['col_lg'] ); |
|
| 1541 | + } else { |
|
| 1542 | + $classes[] = sanitize_html_class( "col-lg-" . $args['col_lg'] ); |
|
| 1543 | + } |
|
| 1544 | + } |
|
| 1545 | + |
|
| 1546 | + |
|
| 1547 | + // border |
|
| 1548 | + if ( ! empty( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' ) ) { |
|
| 1549 | + $classes[] = "border-0"; |
|
| 1550 | + } elseif ( ! empty( $args['border'] ) ) { |
|
| 1551 | + $classes[] = "border border-" . sanitize_html_class( $args['border'] ); |
|
| 1552 | + } |
|
| 1553 | + |
|
| 1554 | + // border radius type |
|
| 1555 | + if ( ! empty( $args['rounded'] ) ) { |
|
| 1556 | + $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 1557 | + } |
|
| 1558 | + |
|
| 1559 | + // border radius size |
|
| 1560 | + if ( ! empty( $args['rounded_size'] ) ) { |
|
| 1561 | + $classes[] = "rounded-" . sanitize_html_class( $args['rounded_size'] ); |
|
| 1562 | + // if we set a size then we need to remove "rounded" if set |
|
| 1563 | + if ( ( $key = array_search( "rounded", $classes ) ) !== false ) { |
|
| 1564 | + unset( $classes[ $key ] ); |
|
| 1565 | + } |
|
| 1566 | + } |
|
| 1567 | + |
|
| 1568 | + // shadow |
|
| 1569 | + //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 1570 | + |
|
| 1571 | + // background |
|
| 1572 | + if ( ! empty( $args['bg'] ) ) { |
|
| 1573 | + $classes[] = "bg-" . sanitize_html_class( $args['bg'] ); |
|
| 1574 | + } |
|
| 1575 | + |
|
| 1576 | + // text_color |
|
| 1577 | + if ( ! empty( $args['text_color'] ) ) { |
|
| 1578 | + $classes[] = "text-" . sanitize_html_class( $args['text_color'] ); |
|
| 1579 | + } |
|
| 1580 | + |
|
| 1581 | + // text_align |
|
| 1582 | + if ( ! empty( $args['text_justify'] ) ) { |
|
| 1583 | + $classes[] = 'text-justify'; |
|
| 1584 | + } else { |
|
| 1585 | + if ( ! empty( $args['text_align'] ) ) { |
|
| 1586 | + $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 1587 | + $text_align = $args['text_align']; |
|
| 1588 | + } else { |
|
| 1589 | + $text_align = null; |
|
| 1590 | + } |
|
| 1591 | + if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 1592 | + $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 1593 | + $text_align_md = $args['text_align_md']; |
|
| 1594 | + } else { |
|
| 1595 | + $text_align_md = null; |
|
| 1596 | + } |
|
| 1597 | + if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 1598 | + if ( $text_align == null && $text_align_md == null ) { |
|
| 1599 | + $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['text_align_lg'] ) ); |
|
| 1600 | + } else { |
|
| 1601 | + $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 1602 | + } |
|
| 1603 | + } |
|
| 1604 | + } |
|
| 1605 | + |
|
| 1606 | + // display |
|
| 1607 | + if ( ! empty( $args['display'] ) ) { |
|
| 1608 | + $classes[] = sanitize_html_class( $args['display'] ); |
|
| 1609 | + $display = $args['display']; |
|
| 1610 | + } else { |
|
| 1611 | + $display = null; |
|
| 1612 | + } |
|
| 1613 | + if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 1614 | + $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 1615 | + $display_md = $args['display_md']; |
|
| 1616 | + } else { |
|
| 1617 | + $display_md = null; |
|
| 1618 | + } |
|
| 1619 | + if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 1620 | + if ( $display == null && $display_md == null ) { |
|
| 1621 | + $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['display_lg'] ) ); |
|
| 1622 | + } else { |
|
| 1623 | + $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 1624 | + } |
|
| 1625 | + } |
|
| 1626 | + |
|
| 1627 | + |
|
| 1628 | + // bgtus - background transparent until scroll |
|
| 1629 | + if ( ! empty( $args['bgtus'] ) ) { |
|
| 1630 | + $classes[] = sanitize_html_class( "bg-transparent-until-scroll" ); |
|
| 1631 | + } |
|
| 1632 | + |
|
| 1633 | + |
|
| 1634 | + // build classes from build keys |
|
| 1635 | + $build_keys = sd_get_class_build_keys(); |
|
| 1636 | + if ( ! empty( $build_keys ) ) { |
|
| 1637 | + foreach ( $build_keys as $key ) { |
|
| 1638 | + if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 1639 | + continue; |
|
| 1640 | + } |
|
| 1641 | + if ( ! empty( $args[ $key ] ) ) { |
|
| 1642 | + $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 1643 | + } |
|
| 1644 | + } |
|
| 1645 | + } |
|
| 1646 | + |
|
| 1647 | + |
|
| 1648 | + return implode( " ", $classes ); |
|
| 1649 | 1649 | } |
| 1650 | 1650 | |
| 1651 | 1651 | /** |
@@ -1657,76 +1657,76 @@ discard block |
||
| 1657 | 1657 | */ |
| 1658 | 1658 | function sd_build_aui_styles( $args ) { |
| 1659 | 1659 | |
| 1660 | - $styles = array(); |
|
| 1661 | - |
|
| 1662 | - // background color |
|
| 1663 | - if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 1664 | - if ( $args['bg'] == 'custom-color' ) { |
|
| 1665 | - $styles['background-color'] = $args['bg_color']; |
|
| 1666 | - } else if ( $args['bg'] == 'custom-gradient' ) { |
|
| 1667 | - $styles['background-image'] = $args['bg_gradient']; |
|
| 1668 | - |
|
| 1669 | - // use background on text. |
|
| 1670 | - if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 1671 | - $styles['background-clip'] = "text"; |
|
| 1672 | - $styles['-webkit-background-clip'] = "text"; |
|
| 1673 | - $styles['text-fill-color'] = "transparent"; |
|
| 1674 | - $styles['-webkit-text-fill-color'] = "transparent"; |
|
| 1675 | - } |
|
| 1676 | - } |
|
| 1677 | - } |
|
| 1678 | - |
|
| 1679 | - if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 1680 | - $hasImage = true; |
|
| 1681 | - if ( $styles['background-color'] !== undefined && $args['bg'] == 'custom-color' ) { |
|
| 1682 | - $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
|
| 1683 | - $styles['background-blend-mode'] = "overlay"; |
|
| 1684 | - } else if ( $styles['background-image'] !== undefined && $args['bg'] == 'custom-gradient' ) { |
|
| 1685 | - $styles['background-image'] .= ",url(" . $args['bg_image'] . ")"; |
|
| 1686 | - } else if ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 1687 | - // do nothing as we alreay have a preset |
|
| 1688 | - $hasImage = false; |
|
| 1689 | - } else { |
|
| 1690 | - $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
|
| 1691 | - } |
|
| 1692 | - |
|
| 1693 | - if ( $hasImage ) { |
|
| 1694 | - $styles['background-size'] = "cover"; |
|
| 1695 | - |
|
| 1696 | - if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 1697 | - $styles['background-attachment'] = "fixed"; |
|
| 1698 | - } |
|
| 1699 | - } |
|
| 1700 | - |
|
| 1701 | - if ( $hasImage && ! empty( $args['bg_image_xy'] ) && $args['bg_image_xy'] . x . length ) { |
|
| 1702 | - $styles['background-position'] = ( $args['bg_image_xy'] . x * 100 ) . "% " . ( $args['bg_image_xy'] . y * 100 ) . "%"; |
|
| 1703 | - } |
|
| 1704 | - } |
|
| 1705 | - |
|
| 1706 | - // sticky offset top |
|
| 1707 | - if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 1708 | - $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 1709 | - } |
|
| 1710 | - |
|
| 1711 | - // sticky offset bottom |
|
| 1712 | - if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 1713 | - $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 1714 | - } |
|
| 1715 | - |
|
| 1716 | - // font size |
|
| 1717 | - if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 1718 | - $styles['font-size'] = (float) $args['font_size_custom'] . "rem"; |
|
| 1719 | - |
|
| 1720 | - } |
|
| 1721 | - |
|
| 1722 | - $style_string = ''; |
|
| 1723 | - if ( ! empty( $styles ) ) { |
|
| 1724 | - foreach ( $styles as $key => $val ) { |
|
| 1725 | - $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 1726 | - } |
|
| 1727 | - } |
|
| 1728 | - |
|
| 1729 | - return $style_string; |
|
| 1660 | + $styles = array(); |
|
| 1661 | + |
|
| 1662 | + // background color |
|
| 1663 | + if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 1664 | + if ( $args['bg'] == 'custom-color' ) { |
|
| 1665 | + $styles['background-color'] = $args['bg_color']; |
|
| 1666 | + } else if ( $args['bg'] == 'custom-gradient' ) { |
|
| 1667 | + $styles['background-image'] = $args['bg_gradient']; |
|
| 1668 | + |
|
| 1669 | + // use background on text. |
|
| 1670 | + if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 1671 | + $styles['background-clip'] = "text"; |
|
| 1672 | + $styles['-webkit-background-clip'] = "text"; |
|
| 1673 | + $styles['text-fill-color'] = "transparent"; |
|
| 1674 | + $styles['-webkit-text-fill-color'] = "transparent"; |
|
| 1675 | + } |
|
| 1676 | + } |
|
| 1677 | + } |
|
| 1678 | + |
|
| 1679 | + if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 1680 | + $hasImage = true; |
|
| 1681 | + if ( $styles['background-color'] !== undefined && $args['bg'] == 'custom-color' ) { |
|
| 1682 | + $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
|
| 1683 | + $styles['background-blend-mode'] = "overlay"; |
|
| 1684 | + } else if ( $styles['background-image'] !== undefined && $args['bg'] == 'custom-gradient' ) { |
|
| 1685 | + $styles['background-image'] .= ",url(" . $args['bg_image'] . ")"; |
|
| 1686 | + } else if ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 1687 | + // do nothing as we alreay have a preset |
|
| 1688 | + $hasImage = false; |
|
| 1689 | + } else { |
|
| 1690 | + $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
|
| 1691 | + } |
|
| 1692 | + |
|
| 1693 | + if ( $hasImage ) { |
|
| 1694 | + $styles['background-size'] = "cover"; |
|
| 1695 | + |
|
| 1696 | + if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 1697 | + $styles['background-attachment'] = "fixed"; |
|
| 1698 | + } |
|
| 1699 | + } |
|
| 1700 | + |
|
| 1701 | + if ( $hasImage && ! empty( $args['bg_image_xy'] ) && $args['bg_image_xy'] . x . length ) { |
|
| 1702 | + $styles['background-position'] = ( $args['bg_image_xy'] . x * 100 ) . "% " . ( $args['bg_image_xy'] . y * 100 ) . "%"; |
|
| 1703 | + } |
|
| 1704 | + } |
|
| 1705 | + |
|
| 1706 | + // sticky offset top |
|
| 1707 | + if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 1708 | + $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 1709 | + } |
|
| 1710 | + |
|
| 1711 | + // sticky offset bottom |
|
| 1712 | + if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 1713 | + $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 1714 | + } |
|
| 1715 | + |
|
| 1716 | + // font size |
|
| 1717 | + if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 1718 | + $styles['font-size'] = (float) $args['font_size_custom'] . "rem"; |
|
| 1719 | + |
|
| 1720 | + } |
|
| 1721 | + |
|
| 1722 | + $style_string = ''; |
|
| 1723 | + if ( ! empty( $styles ) ) { |
|
| 1724 | + foreach ( $styles as $key => $val ) { |
|
| 1725 | + $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 1726 | + } |
|
| 1727 | + } |
|
| 1728 | + |
|
| 1729 | + return $style_string; |
|
| 1730 | 1730 | |
| 1731 | 1731 | } |
| 1732 | 1732 | |
@@ -1739,19 +1739,19 @@ discard block |
||
| 1739 | 1739 | * @return string |
| 1740 | 1740 | */ |
| 1741 | 1741 | function sd_sanitize_html_classes( $classes, $sep = " " ) { |
| 1742 | - $return = ""; |
|
| 1742 | + $return = ""; |
|
| 1743 | 1743 | |
| 1744 | - if ( ! is_array( $classes ) ) { |
|
| 1745 | - $classes = explode( $sep, $classes ); |
|
| 1746 | - } |
|
| 1744 | + if ( ! is_array( $classes ) ) { |
|
| 1745 | + $classes = explode( $sep, $classes ); |
|
| 1746 | + } |
|
| 1747 | 1747 | |
| 1748 | - if ( ! empty( $classes ) ) { |
|
| 1749 | - foreach ( $classes as $class ) { |
|
| 1750 | - $return .= sanitize_html_class( $class ) . " "; |
|
| 1751 | - } |
|
| 1752 | - } |
|
| 1748 | + if ( ! empty( $classes ) ) { |
|
| 1749 | + foreach ( $classes as $class ) { |
|
| 1750 | + $return .= sanitize_html_class( $class ) . " "; |
|
| 1751 | + } |
|
| 1752 | + } |
|
| 1753 | 1753 | |
| 1754 | - return $return; |
|
| 1754 | + return $return; |
|
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | |
@@ -1761,21 +1761,21 @@ discard block |
||
| 1761 | 1761 | * @return void |
| 1762 | 1762 | */ |
| 1763 | 1763 | function sd_get_class_build_keys() { |
| 1764 | - $keys = array( |
|
| 1765 | - 'container', |
|
| 1766 | - 'position', |
|
| 1767 | - 'flex_direction', |
|
| 1768 | - 'shadow', |
|
| 1769 | - 'rounded', |
|
| 1770 | - 'nav_style', |
|
| 1771 | - 'horizontal_alignment', |
|
| 1772 | - 'nav_fill', |
|
| 1773 | - 'width', |
|
| 1774 | - 'font_weight', |
|
| 1775 | - 'font_size', |
|
| 1776 | - 'font_case', |
|
| 1777 | - 'css_class', |
|
| 1778 | - ); |
|
| 1779 | - |
|
| 1780 | - return apply_filters( "sd_class_build_keys", $keys ); |
|
| 1764 | + $keys = array( |
|
| 1765 | + 'container', |
|
| 1766 | + 'position', |
|
| 1767 | + 'flex_direction', |
|
| 1768 | + 'shadow', |
|
| 1769 | + 'rounded', |
|
| 1770 | + 'nav_style', |
|
| 1771 | + 'horizontal_alignment', |
|
| 1772 | + 'nav_fill', |
|
| 1773 | + 'width', |
|
| 1774 | + 'font_weight', |
|
| 1775 | + 'font_size', |
|
| 1776 | + 'font_case', |
|
| 1777 | + 'css_class', |
|
| 1778 | + ); |
|
| 1779 | + |
|
| 1780 | + return apply_filters( "sd_class_build_keys", $keys ); |
|
| 1781 | 1781 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @return mixed|void |
| 12 | 12 | */ |
| 13 | 13 | function sd_pagenow_exclude() { |
| 14 | - return apply_filters( 'sd_pagenow_exclude', array( |
|
| 14 | + return apply_filters('sd_pagenow_exclude', array( |
|
| 15 | 15 | 'upload.php', |
| 16 | 16 | 'edit-comments.php', |
| 17 | 17 | 'edit-tags.php', |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | 'edit.php', |
| 23 | 23 | 'themes.php', |
| 24 | 24 | 'users.php', |
| 25 | - ) ); |
|
| 25 | + )); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return mixed|void |
| 35 | 35 | */ |
| 36 | 36 | function sd_widget_exclude() { |
| 37 | - return apply_filters( 'sd_widget_exclude', array() ); |
|
| 37 | + return apply_filters('sd_widget_exclude', array()); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return array |
| 48 | 48 | */ |
| 49 | -function sd_get_margin_input( $type = 'mt', $overwrite = array(), $include_negatives = true ) { |
|
| 49 | +function sd_get_margin_input($type = 'mt', $overwrite = array(), $include_negatives = true) { |
|
| 50 | 50 | $options = array( |
| 51 | - "" => __( 'None' ), |
|
| 52 | - "auto" => __( 'auto' ), |
|
| 51 | + "" => __('None'), |
|
| 52 | + "auto" => __('auto'), |
|
| 53 | 53 | "0" => "0", |
| 54 | 54 | "1" => "1", |
| 55 | 55 | "2" => "2", |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | "5" => "5", |
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | - if ( $include_negatives ) { |
|
| 61 | + if ($include_negatives) { |
|
| 62 | 62 | $options['n1'] = '-1'; |
| 63 | 63 | $options['n2'] = '-2'; |
| 64 | 64 | $options['n3'] = '-3'; |
@@ -68,38 +68,38 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $defaults = array( |
| 70 | 70 | 'type' => 'select', |
| 71 | - 'title' => __( 'Margin top' ), |
|
| 71 | + 'title' => __('Margin top'), |
|
| 72 | 72 | 'options' => $options, |
| 73 | 73 | 'default' => '', |
| 74 | 74 | 'desc_tip' => true, |
| 75 | - 'group' => __( "Wrapper Styles", "geodirectory" ), |
|
| 75 | + 'group' => __("Wrapper Styles", "geodirectory"), |
|
| 76 | 76 | // 'device_type' => 'Desktop', |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | // title |
| 80 | - if ( $type == 'mt' ) { |
|
| 81 | - $defaults['title'] = __( 'Margin top' ); |
|
| 80 | + if ($type == 'mt') { |
|
| 81 | + $defaults['title'] = __('Margin top'); |
|
| 82 | 82 | $defaults['icon'] = 'box-top'; |
| 83 | 83 | $defaults['row'] = array( |
| 84 | - 'title' => __( 'Margins' ), |
|
| 84 | + 'title' => __('Margins'), |
|
| 85 | 85 | 'key' => 'wrapper-margins', |
| 86 | 86 | 'open' => true, |
| 87 | 87 | 'class' => 'text-center', |
| 88 | 88 | ); |
| 89 | - } elseif ( $type == 'mr' ) { |
|
| 90 | - $defaults['title'] = __( 'Margin right' ); |
|
| 89 | + } elseif ($type == 'mr') { |
|
| 90 | + $defaults['title'] = __('Margin right'); |
|
| 91 | 91 | $defaults['icon'] = 'box-right'; |
| 92 | 92 | $defaults['row'] = array( |
| 93 | 93 | 'key' => 'wrapper-margins', |
| 94 | 94 | ); |
| 95 | - } elseif ( $type == 'mb' ) { |
|
| 96 | - $defaults['title'] = __( 'Margin bottom' ); |
|
| 95 | + } elseif ($type == 'mb') { |
|
| 96 | + $defaults['title'] = __('Margin bottom'); |
|
| 97 | 97 | $defaults['icon'] = 'box-bottom'; |
| 98 | 98 | $defaults['row'] = array( |
| 99 | 99 | 'key' => 'wrapper-margins', |
| 100 | 100 | ); |
| 101 | - } elseif ( $type == 'ml' ) { |
|
| 102 | - $defaults['title'] = __( 'Margin left' ); |
|
| 101 | + } elseif ($type == 'ml') { |
|
| 102 | + $defaults['title'] = __('Margin left'); |
|
| 103 | 103 | $defaults['icon'] = 'box-left'; |
| 104 | 104 | $defaults['row'] = array( |
| 105 | 105 | 'key' => 'wrapper-margins', |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 110 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | return $input; |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @return array |
| 123 | 123 | */ |
| 124 | -function sd_get_padding_input( $type = 'pt', $overwrite = array() ) { |
|
| 124 | +function sd_get_padding_input($type = 'pt', $overwrite = array()) { |
|
| 125 | 125 | $options = array( |
| 126 | - "" => __( 'None' ), |
|
| 126 | + "" => __('None'), |
|
| 127 | 127 | "0" => "0", |
| 128 | 128 | "1" => "1", |
| 129 | 129 | "2" => "2", |
@@ -134,37 +134,37 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $defaults = array( |
| 136 | 136 | 'type' => 'select', |
| 137 | - 'title' => __( 'Padding top' ), |
|
| 137 | + 'title' => __('Padding top'), |
|
| 138 | 138 | 'options' => $options, |
| 139 | 139 | 'default' => '', |
| 140 | 140 | 'desc_tip' => true, |
| 141 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 141 | + 'group' => __("Wrapper Styles", "geodirectory") |
|
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | 144 | // title |
| 145 | - if ( $type == 'pt' ) { |
|
| 146 | - $defaults['title'] = __( 'Padding top' ); |
|
| 145 | + if ($type == 'pt') { |
|
| 146 | + $defaults['title'] = __('Padding top'); |
|
| 147 | 147 | $defaults['icon'] = 'box-top'; |
| 148 | 148 | $defaults['row'] = array( |
| 149 | - 'title' => __( 'Padding' ), |
|
| 149 | + 'title' => __('Padding'), |
|
| 150 | 150 | 'key' => 'wrapper-padding', |
| 151 | 151 | 'open' => true, |
| 152 | 152 | 'class' => 'text-center', |
| 153 | 153 | ); |
| 154 | - } elseif ( $type == 'pr' ) { |
|
| 155 | - $defaults['title'] = __( 'Padding right' ); |
|
| 154 | + } elseif ($type == 'pr') { |
|
| 155 | + $defaults['title'] = __('Padding right'); |
|
| 156 | 156 | $defaults['icon'] = 'box-right'; |
| 157 | 157 | $defaults['row'] = array( |
| 158 | 158 | 'key' => 'wrapper-padding', |
| 159 | 159 | ); |
| 160 | - } elseif ( $type == 'pb' ) { |
|
| 161 | - $defaults['title'] = __( 'Padding bottom' ); |
|
| 160 | + } elseif ($type == 'pb') { |
|
| 161 | + $defaults['title'] = __('Padding bottom'); |
|
| 162 | 162 | $defaults['icon'] = 'box-bottom'; |
| 163 | 163 | $defaults['row'] = array( |
| 164 | 164 | 'key' => 'wrapper-padding', |
| 165 | 165 | ); |
| 166 | - } elseif ( $type == 'pl' ) { |
|
| 167 | - $defaults['title'] = __( 'Padding left' ); |
|
| 166 | + } elseif ($type == 'pl') { |
|
| 167 | + $defaults['title'] = __('Padding left'); |
|
| 168 | 168 | $defaults['icon'] = 'box-left'; |
| 169 | 169 | $defaults['row'] = array( |
| 170 | 170 | 'key' => 'wrapper-padding', |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | ); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 176 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 177 | 177 | |
| 178 | 178 | |
| 179 | 179 | return $input; |
@@ -187,22 +187,22 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @return array |
| 189 | 189 | */ |
| 190 | -function sd_get_border_input( $type = 'border', $overwrite = array() ) { |
|
| 190 | +function sd_get_border_input($type = 'border', $overwrite = array()) { |
|
| 191 | 191 | |
| 192 | 192 | $defaults = array( |
| 193 | 193 | 'type' => 'select', |
| 194 | - 'title' => __( 'Border' ), |
|
| 194 | + 'title' => __('Border'), |
|
| 195 | 195 | 'options' => array(), |
| 196 | 196 | 'default' => '', |
| 197 | 197 | 'desc_tip' => true, |
| 198 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 198 | + 'group' => __("Wrapper Styles", "geodirectory") |
|
| 199 | 199 | ); |
| 200 | 200 | |
| 201 | 201 | // title |
| 202 | - if ( $type == 'rounded' ) { |
|
| 203 | - $defaults['title'] = __( 'Border radius type' ); |
|
| 202 | + if ($type == 'rounded') { |
|
| 203 | + $defaults['title'] = __('Border radius type'); |
|
| 204 | 204 | $defaults['options'] = array( |
| 205 | - '' => __( "Default", "geodirectory" ), |
|
| 205 | + '' => __("Default", "geodirectory"), |
|
| 206 | 206 | 'rounded' => 'rounded', |
| 207 | 207 | 'rounded-top' => 'rounded-top', |
| 208 | 208 | 'rounded-right' => 'rounded-right', |
@@ -212,32 +212,32 @@ discard block |
||
| 212 | 212 | 'rounded-pill' => 'rounded-pill', |
| 213 | 213 | 'rounded-0' => 'rounded-0', |
| 214 | 214 | ); |
| 215 | - } elseif ( $type == 'rounded_size' ) { |
|
| 216 | - $defaults['title'] = __( 'Border radius size' ); |
|
| 215 | + } elseif ($type == 'rounded_size') { |
|
| 216 | + $defaults['title'] = __('Border radius size'); |
|
| 217 | 217 | $defaults['options'] = array( |
| 218 | - '' => __( "Default", "geodirectory" ), |
|
| 219 | - 'sm' => __( "Small", "geodirectory" ), |
|
| 220 | - 'lg' => __( "Large", "geodirectory" ), |
|
| 218 | + '' => __("Default", "geodirectory"), |
|
| 219 | + 'sm' => __("Small", "geodirectory"), |
|
| 220 | + 'lg' => __("Large", "geodirectory"), |
|
| 221 | 221 | ); |
| 222 | - } elseif ( $type == 'type' ) { |
|
| 223 | - $defaults['title'] = __( 'Border type' ); |
|
| 222 | + } elseif ($type == 'type') { |
|
| 223 | + $defaults['title'] = __('Border type'); |
|
| 224 | 224 | $defaults['options'] = array( |
| 225 | - '' => __( "None", "geodirectory" ), |
|
| 226 | - 'border' => __( "Full", "geodirectory" ), |
|
| 227 | - 'border-top' => __( "Top", "geodirectory" ), |
|
| 228 | - 'border-bottom' => __( "Bottom", "geodirectory" ), |
|
| 229 | - 'border-left' => __( "Left", "geodirectory" ), |
|
| 230 | - 'border-right' => __( "Right", "geodirectory" ), |
|
| 225 | + '' => __("None", "geodirectory"), |
|
| 226 | + 'border' => __("Full", "geodirectory"), |
|
| 227 | + 'border-top' => __("Top", "geodirectory"), |
|
| 228 | + 'border-bottom' => __("Bottom", "geodirectory"), |
|
| 229 | + 'border-left' => __("Left", "geodirectory"), |
|
| 230 | + 'border-right' => __("Right", "geodirectory"), |
|
| 231 | 231 | ); |
| 232 | 232 | } else { |
| 233 | - $defaults['title'] = __( 'Border color' ); |
|
| 233 | + $defaults['title'] = __('Border color'); |
|
| 234 | 234 | $defaults['options'] = array( |
| 235 | - '' => __( "Default", "geodirectory" ), |
|
| 236 | - '0' => __( "None", "geodirectory" ), |
|
| 235 | + '' => __("Default", "geodirectory"), |
|
| 236 | + '0' => __("None", "geodirectory"), |
|
| 237 | 237 | ) + sd_aui_colors(); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 240 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 241 | 241 | |
| 242 | 242 | |
| 243 | 243 | return $input; |
@@ -251,25 +251,25 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return array |
| 253 | 253 | */ |
| 254 | -function sd_get_shadow_input( $type = 'shadow', $overwrite = array() ) { |
|
| 254 | +function sd_get_shadow_input($type = 'shadow', $overwrite = array()) { |
|
| 255 | 255 | $options = array( |
| 256 | - "" => __( 'None' ), |
|
| 257 | - "shadow-sm" => __( 'Small' ), |
|
| 258 | - "shadow" => __( 'Regular' ), |
|
| 259 | - "shadow-lg" => __( 'Large' ), |
|
| 256 | + "" => __('None'), |
|
| 257 | + "shadow-sm" => __('Small'), |
|
| 258 | + "shadow" => __('Regular'), |
|
| 259 | + "shadow-lg" => __('Large'), |
|
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | 262 | $defaults = array( |
| 263 | 263 | 'type' => 'select', |
| 264 | - 'title' => __( 'Shadow' ), |
|
| 264 | + 'title' => __('Shadow'), |
|
| 265 | 265 | 'options' => $options, |
| 266 | 266 | 'default' => '', |
| 267 | 267 | 'desc_tip' => true, |
| 268 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 268 | + 'group' => __("Wrapper Styles", "geodirectory") |
|
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | 271 | |
| 272 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 272 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 273 | 273 | |
| 274 | 274 | |
| 275 | 275 | return $input; |
@@ -283,23 +283,23 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @return array |
| 285 | 285 | */ |
| 286 | -function sd_get_background_input( $type = 'bg', $overwrite = array() ) { |
|
| 286 | +function sd_get_background_input($type = 'bg', $overwrite = array()) { |
|
| 287 | 287 | $options = array( |
| 288 | - '' => __( "None", "geodirectory" ), |
|
| 289 | - 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 288 | + '' => __("None", "geodirectory"), |
|
| 289 | + 'transparent' => __("Transparent", "geodirectory"), |
|
| 290 | 290 | ) + sd_aui_colors(); |
| 291 | 291 | |
| 292 | 292 | $defaults = array( |
| 293 | 293 | 'type' => 'select', |
| 294 | - 'title' => __( 'Background color' ), |
|
| 294 | + 'title' => __('Background color'), |
|
| 295 | 295 | 'options' => $options, |
| 296 | 296 | 'default' => '', |
| 297 | 297 | 'desc_tip' => true, |
| 298 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 298 | + 'group' => __("Wrapper Styles", "geodirectory") |
|
| 299 | 299 | ); |
| 300 | 300 | |
| 301 | 301 | |
| 302 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 302 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | return $input; |
@@ -313,96 +313,96 @@ discard block |
||
| 313 | 313 | * |
| 314 | 314 | * @return array |
| 315 | 315 | */ |
| 316 | -function sd_get_background_inputs( $type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
|
| 316 | +function sd_get_background_inputs($type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array()) { |
|
| 317 | 317 | $options = array( |
| 318 | - '' => __( "None", "geodirectory" ), |
|
| 319 | - 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 318 | + '' => __("None", "geodirectory"), |
|
| 319 | + 'transparent' => __("Transparent", "geodirectory"), |
|
| 320 | 320 | ) + sd_aui_colors() |
| 321 | 321 | + array( |
| 322 | - 'custom-color' => __( "Custom Color", "geodirectory" ), |
|
| 323 | - 'custom-gradient' => __( "Custom Gradient", "geodirectory" ), |
|
| 322 | + 'custom-color' => __("Custom Color", "geodirectory"), |
|
| 323 | + 'custom-gradient' => __("Custom Gradient", "geodirectory"), |
|
| 324 | 324 | // 'custom-image' => __("Custom Image","geodirectory"), |
| 325 | 325 | ); |
| 326 | 326 | |
| 327 | 327 | $defaults = array( |
| 328 | 328 | 'type' => 'select', |
| 329 | - 'title' => __( 'Background Color' ), |
|
| 329 | + 'title' => __('Background Color'), |
|
| 330 | 330 | 'options' => $options, |
| 331 | 331 | 'default' => '', |
| 332 | 332 | 'desc_tip' => true, |
| 333 | - 'group' => __( "Background", "geodirectory" ) |
|
| 333 | + 'group' => __("Background", "geodirectory") |
|
| 334 | 334 | ); |
| 335 | 335 | |
| 336 | 336 | |
| 337 | - if ( $overwrite !== false ) { |
|
| 338 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 337 | + if ($overwrite !== false) { |
|
| 338 | + $input[$type] = wp_parse_args($overwrite, $defaults); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | |
| 342 | - if ( $overwrite_color !== false ) { |
|
| 343 | - $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 342 | + if ($overwrite_color !== false) { |
|
| 343 | + $input[$type . '_color'] = wp_parse_args($overwrite_color, array( |
|
| 344 | 344 | 'type' => 'color', |
| 345 | - 'title' => __( 'Custom color' ), |
|
| 345 | + 'title' => __('Custom color'), |
|
| 346 | 346 | 'placeholder' => '', |
| 347 | 347 | 'default' => '#0073aa', |
| 348 | 348 | 'desc_tip' => true, |
| 349 | - 'group' => __( "Background" ), |
|
| 349 | + 'group' => __("Background"), |
|
| 350 | 350 | 'element_require' => '[%' . $type . '%]=="custom-color"' |
| 351 | - ) ); |
|
| 351 | + )); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | |
| 355 | - if ( $overwrite_gradient !== false ) { |
|
| 356 | - $input[ $type . '_gradient' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 355 | + if ($overwrite_gradient !== false) { |
|
| 356 | + $input[$type . '_gradient'] = wp_parse_args($overwrite_gradient, array( |
|
| 357 | 357 | 'type' => 'gradient', |
| 358 | - 'title' => __( 'Custom gradient' ), |
|
| 358 | + 'title' => __('Custom gradient'), |
|
| 359 | 359 | 'placeholder' => '', |
| 360 | 360 | 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
| 361 | 361 | 'desc_tip' => true, |
| 362 | - 'group' => __( "Background" ), |
|
| 362 | + 'group' => __("Background"), |
|
| 363 | 363 | 'element_require' => '[%' . $type . '%]=="custom-gradient"' |
| 364 | - ) ); |
|
| 364 | + )); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if ( $overwrite_image !== false ) { |
|
| 367 | + if ($overwrite_image !== false) { |
|
| 368 | 368 | |
| 369 | - $input[ $type . '_image_fixed' ] = array( |
|
| 369 | + $input[$type . '_image_fixed'] = array( |
|
| 370 | 370 | 'type' => 'checkbox', |
| 371 | - 'title' => __( 'Fixed background' ), |
|
| 371 | + 'title' => __('Fixed background'), |
|
| 372 | 372 | 'default' => '', |
| 373 | 373 | 'desc_tip' => true, |
| 374 | - 'group' => __( "Background" ), |
|
| 374 | + 'group' => __("Background"), |
|
| 375 | 375 | 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
| 376 | 376 | |
| 377 | 377 | ); |
| 378 | 378 | |
| 379 | 379 | |
| 380 | - $input[ $type . '_image' ] = wp_parse_args( $overwrite_image, array( |
|
| 380 | + $input[$type . '_image'] = wp_parse_args($overwrite_image, array( |
|
| 381 | 381 | 'type' => 'image', |
| 382 | - 'title' => __( 'Custom image' ), |
|
| 382 | + 'title' => __('Custom image'), |
|
| 383 | 383 | 'placeholder' => '', |
| 384 | 384 | 'default' => '', |
| 385 | 385 | 'desc_tip' => true, |
| 386 | - 'group' => __( "Background" ), |
|
| 386 | + 'group' => __("Background"), |
|
| 387 | 387 | // 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
| 388 | - ) ); |
|
| 388 | + )); |
|
| 389 | 389 | |
| 390 | - $input[ $type . '_image_id' ] = wp_parse_args( $overwrite_image, array( |
|
| 390 | + $input[$type . '_image_id'] = wp_parse_args($overwrite_image, array( |
|
| 391 | 391 | 'type' => 'hidden', |
| 392 | 392 | 'hidden_type' => 'number', |
| 393 | 393 | 'title' => '', |
| 394 | 394 | 'placeholder' => '', |
| 395 | 395 | 'default' => '', |
| 396 | - 'group' => __( "Background" ), |
|
| 397 | - ) ); |
|
| 396 | + 'group' => __("Background"), |
|
| 397 | + )); |
|
| 398 | 398 | |
| 399 | - $input[ $type . '_image_xy' ] = wp_parse_args( $overwrite_image, array( |
|
| 399 | + $input[$type . '_image_xy'] = wp_parse_args($overwrite_image, array( |
|
| 400 | 400 | 'type' => 'image_xy', |
| 401 | 401 | 'title' => '', |
| 402 | 402 | 'placeholder' => '', |
| 403 | 403 | 'default' => '', |
| 404 | - 'group' => __( "Background" ), |
|
| 405 | - ) ); |
|
| 404 | + 'group' => __("Background"), |
|
| 405 | + )); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | return $input; |
@@ -416,96 +416,96 @@ discard block |
||
| 416 | 416 | * |
| 417 | 417 | * @return array |
| 418 | 418 | */ |
| 419 | -function sd_get_shape_divider_inputs( $type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
|
| 419 | +function sd_get_shape_divider_inputs($type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array()) { |
|
| 420 | 420 | |
| 421 | 421 | $options = array( |
| 422 | - '' => __( "None" ), |
|
| 423 | - 'mountains' => __( "Mountains" ), |
|
| 424 | - 'drops' => __( "Drops" ), |
|
| 425 | - 'clouds' => __( "Clouds" ), |
|
| 426 | - 'zigzag' => __( "Zigzag" ), |
|
| 427 | - 'pyramids' => __( "Pyramids" ), |
|
| 428 | - 'triangle' => __( "Triangle" ), |
|
| 429 | - 'triangle-asymmetrical' => __( "Triangle Asymmetrical" ), |
|
| 430 | - 'tilt' => __( "Tilt" ), |
|
| 431 | - 'opacity-tilt' => __( "Opacity Tilt" ), |
|
| 432 | - 'opacity-fan' => __( "Opacity Fan" ), |
|
| 433 | - 'curve' => __( "Curve" ), |
|
| 434 | - 'curve-asymmetrical' => __( "Curve Asymmetrical" ), |
|
| 435 | - 'waves' => __( "Waves" ), |
|
| 436 | - 'wave-brush' => __( "Wave Brush" ), |
|
| 437 | - 'waves-pattern' => __( "Waves Pattern" ), |
|
| 438 | - 'arrow' => __( "Arrow" ), |
|
| 439 | - 'split' => __( "Split" ), |
|
| 440 | - 'book' => __( "Book" ), |
|
| 422 | + '' => __("None"), |
|
| 423 | + 'mountains' => __("Mountains"), |
|
| 424 | + 'drops' => __("Drops"), |
|
| 425 | + 'clouds' => __("Clouds"), |
|
| 426 | + 'zigzag' => __("Zigzag"), |
|
| 427 | + 'pyramids' => __("Pyramids"), |
|
| 428 | + 'triangle' => __("Triangle"), |
|
| 429 | + 'triangle-asymmetrical' => __("Triangle Asymmetrical"), |
|
| 430 | + 'tilt' => __("Tilt"), |
|
| 431 | + 'opacity-tilt' => __("Opacity Tilt"), |
|
| 432 | + 'opacity-fan' => __("Opacity Fan"), |
|
| 433 | + 'curve' => __("Curve"), |
|
| 434 | + 'curve-asymmetrical' => __("Curve Asymmetrical"), |
|
| 435 | + 'waves' => __("Waves"), |
|
| 436 | + 'wave-brush' => __("Wave Brush"), |
|
| 437 | + 'waves-pattern' => __("Waves Pattern"), |
|
| 438 | + 'arrow' => __("Arrow"), |
|
| 439 | + 'split' => __("Split"), |
|
| 440 | + 'book' => __("Book"), |
|
| 441 | 441 | ); |
| 442 | 442 | |
| 443 | 443 | $defaults = array( |
| 444 | 444 | 'type' => 'select', |
| 445 | - 'title' => __( 'Type' ), |
|
| 445 | + 'title' => __('Type'), |
|
| 446 | 446 | 'options' => $options, |
| 447 | 447 | 'default' => '', |
| 448 | 448 | 'desc_tip' => true, |
| 449 | - 'group' => __( "Shape Divider" ), |
|
| 449 | + 'group' => __("Shape Divider"), |
|
| 450 | 450 | ); |
| 451 | 451 | |
| 452 | 452 | |
| 453 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 453 | + $input[$type] = wp_parse_args($overwrite, $defaults); |
|
| 454 | 454 | |
| 455 | 455 | |
| 456 | - $input[ $type . '_notice' ] = array( |
|
| 456 | + $input[$type . '_notice'] = array( |
|
| 457 | 457 | 'type' => 'notice', |
| 458 | - 'desc' => __( 'Parent element must be position `relative`' ), |
|
| 458 | + 'desc' => __('Parent element must be position `relative`'), |
|
| 459 | 459 | 'status' => 'warning', |
| 460 | - 'group' => __( "Shape Divider" ), |
|
| 460 | + 'group' => __("Shape Divider"), |
|
| 461 | 461 | 'element_require' => '[%' . $type . '%]!=""', |
| 462 | 462 | ); |
| 463 | 463 | |
| 464 | 464 | |
| 465 | - $input[ $type . '_position' ] = wp_parse_args( $overwrite_color, array( |
|
| 465 | + $input[$type . '_position'] = wp_parse_args($overwrite_color, array( |
|
| 466 | 466 | 'type' => 'select', |
| 467 | - 'title' => __( 'Position' ), |
|
| 467 | + 'title' => __('Position'), |
|
| 468 | 468 | 'options' => array( |
| 469 | - 'top' => __( 'Top' ), |
|
| 470 | - 'bottom' => __( 'Bottom' ), |
|
| 469 | + 'top' => __('Top'), |
|
| 470 | + 'bottom' => __('Bottom'), |
|
| 471 | 471 | //'left' => __('Left'), |
| 472 | 472 | //'right' => __('Right'), |
| 473 | 473 | ), |
| 474 | 474 | 'desc_tip' => true, |
| 475 | - 'group' => __( "Shape Divider" ), |
|
| 475 | + 'group' => __("Shape Divider"), |
|
| 476 | 476 | 'element_require' => '[%' . $type . '%]!=""' |
| 477 | - ) ); |
|
| 477 | + )); |
|
| 478 | 478 | |
| 479 | 479 | $options = array( |
| 480 | - '' => __( "None" ), |
|
| 481 | - 'transparent' => __( "Transparent" ), |
|
| 480 | + '' => __("None"), |
|
| 481 | + 'transparent' => __("Transparent"), |
|
| 482 | 482 | ) + sd_aui_colors() |
| 483 | 483 | + array( |
| 484 | - 'custom-color' => __( "Custom Color" ), |
|
| 484 | + 'custom-color' => __("Custom Color"), |
|
| 485 | 485 | ); |
| 486 | 486 | |
| 487 | - $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 487 | + $input[$type . '_color'] = wp_parse_args($overwrite_color, array( |
|
| 488 | 488 | 'type' => 'select', |
| 489 | - 'title' => __( 'Color' ), |
|
| 489 | + 'title' => __('Color'), |
|
| 490 | 490 | 'options' => $options, |
| 491 | 491 | 'desc_tip' => true, |
| 492 | - 'group' => __( "Shape Divider" ), |
|
| 492 | + 'group' => __("Shape Divider"), |
|
| 493 | 493 | 'element_require' => '[%' . $type . '%]!=""' |
| 494 | - ) ); |
|
| 494 | + )); |
|
| 495 | 495 | |
| 496 | - $input[ $type . '_custom_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 496 | + $input[$type . '_custom_color'] = wp_parse_args($overwrite_color, array( |
|
| 497 | 497 | 'type' => 'color', |
| 498 | - 'title' => __( 'Custom color' ), |
|
| 498 | + 'title' => __('Custom color'), |
|
| 499 | 499 | 'placeholder' => '', |
| 500 | 500 | 'default' => '#0073aa', |
| 501 | 501 | 'desc_tip' => true, |
| 502 | - 'group' => __( "Shape Divider" ), |
|
| 502 | + 'group' => __("Shape Divider"), |
|
| 503 | 503 | 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""' |
| 504 | - ) ); |
|
| 504 | + )); |
|
| 505 | 505 | |
| 506 | - $input[ $type . '_width' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 506 | + $input[$type . '_width'] = wp_parse_args($overwrite_gradient, array( |
|
| 507 | 507 | 'type' => 'range', |
| 508 | - 'title' => __( 'Width' ), |
|
| 508 | + 'title' => __('Width'), |
|
| 509 | 509 | 'placeholder' => '', |
| 510 | 510 | 'default' => '200', |
| 511 | 511 | 'desc_tip' => true, |
@@ -513,68 +513,68 @@ discard block |
||
| 513 | 513 | 'min' => 100, |
| 514 | 514 | 'max' => 300, |
| 515 | 515 | ), |
| 516 | - 'group' => __( "Shape Divider" ), |
|
| 516 | + 'group' => __("Shape Divider"), |
|
| 517 | 517 | 'element_require' => '[%' . $type . '%]!=""' |
| 518 | - ) ); |
|
| 518 | + )); |
|
| 519 | 519 | |
| 520 | - $input[ $type . '_height' ] = array( |
|
| 520 | + $input[$type . '_height'] = array( |
|
| 521 | 521 | 'type' => 'range', |
| 522 | - 'title' => __( 'Height' ), |
|
| 522 | + 'title' => __('Height'), |
|
| 523 | 523 | 'default' => '100', |
| 524 | 524 | 'desc_tip' => true, |
| 525 | 525 | 'custom_attributes' => array( |
| 526 | 526 | 'min' => 0, |
| 527 | 527 | 'max' => 500, |
| 528 | 528 | ), |
| 529 | - 'group' => __( "Shape Divider" ), |
|
| 529 | + 'group' => __("Shape Divider"), |
|
| 530 | 530 | 'element_require' => '[%' . $type . '%]!=""' |
| 531 | 531 | ); |
| 532 | 532 | |
| 533 | 533 | $requires = array( |
| 534 | - 'mountains' => array( 'flip' ), |
|
| 535 | - 'drops' => array( 'flip', 'invert' ), |
|
| 536 | - 'clouds' => array( 'flip', 'invert' ), |
|
| 534 | + 'mountains' => array('flip'), |
|
| 535 | + 'drops' => array('flip', 'invert'), |
|
| 536 | + 'clouds' => array('flip', 'invert'), |
|
| 537 | 537 | 'zigzag' => array(), |
| 538 | - 'pyramids' => array( 'flip', 'invert' ), |
|
| 539 | - 'triangle' => array( 'invert' ), |
|
| 540 | - 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 541 | - 'tilt' => array( 'flip' ), |
|
| 542 | - 'opacity-tilt' => array( 'flip' ), |
|
| 538 | + 'pyramids' => array('flip', 'invert'), |
|
| 539 | + 'triangle' => array('invert'), |
|
| 540 | + 'triangle-asymmetrical' => array('flip', 'invert'), |
|
| 541 | + 'tilt' => array('flip'), |
|
| 542 | + 'opacity-tilt' => array('flip'), |
|
| 543 | 543 | 'opacity-fan' => array(), |
| 544 | - 'curve' => array( 'invert' ), |
|
| 545 | - 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 546 | - 'waves' => array( 'flip', 'invert' ), |
|
| 547 | - 'wave-brush' => array( 'flip' ), |
|
| 548 | - 'waves-pattern' => array( 'flip' ), |
|
| 549 | - 'arrow' => array( 'invert' ), |
|
| 550 | - 'split' => array( 'invert' ), |
|
| 551 | - 'book' => array( 'invert' ), |
|
| 544 | + 'curve' => array('invert'), |
|
| 545 | + 'curve-asymmetrical' => array('flip', 'invert'), |
|
| 546 | + 'waves' => array('flip', 'invert'), |
|
| 547 | + 'wave-brush' => array('flip'), |
|
| 548 | + 'waves-pattern' => array('flip'), |
|
| 549 | + 'arrow' => array('invert'), |
|
| 550 | + 'split' => array('invert'), |
|
| 551 | + 'book' => array('invert'), |
|
| 552 | 552 | ); |
| 553 | 553 | |
| 554 | - $input[ $type . '_flip' ] = array( |
|
| 554 | + $input[$type . '_flip'] = array( |
|
| 555 | 555 | 'type' => 'checkbox', |
| 556 | - 'title' => __( 'Flip' ), |
|
| 556 | + 'title' => __('Flip'), |
|
| 557 | 557 | 'default' => '', |
| 558 | 558 | 'desc_tip' => true, |
| 559 | - 'group' => __( "Shape Divider" ), |
|
| 560 | - 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ) |
|
| 559 | + 'group' => __("Shape Divider"), |
|
| 560 | + 'element_require' => sd_get_element_require_string($requires, 'flip', 'sd') |
|
| 561 | 561 | ); |
| 562 | 562 | |
| 563 | - $input[ $type . '_invert' ] = array( |
|
| 563 | + $input[$type . '_invert'] = array( |
|
| 564 | 564 | 'type' => 'checkbox', |
| 565 | - 'title' => __( 'Invert' ), |
|
| 565 | + 'title' => __('Invert'), |
|
| 566 | 566 | 'default' => '', |
| 567 | 567 | 'desc_tip' => true, |
| 568 | - 'group' => __( "Shape Divider" ), |
|
| 569 | - 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ) |
|
| 568 | + 'group' => __("Shape Divider"), |
|
| 569 | + 'element_require' => sd_get_element_require_string($requires, 'invert', 'sd') |
|
| 570 | 570 | ); |
| 571 | 571 | |
| 572 | - $input[ $type . '_btf' ] = array( |
|
| 572 | + $input[$type . '_btf'] = array( |
|
| 573 | 573 | 'type' => 'checkbox', |
| 574 | - 'title' => __( 'Bring to front' ), |
|
| 574 | + 'title' => __('Bring to front'), |
|
| 575 | 575 | 'default' => '', |
| 576 | 576 | 'desc_tip' => true, |
| 577 | - 'group' => __( "Shape Divider" ), |
|
| 577 | + 'group' => __("Shape Divider"), |
|
| 578 | 578 | 'element_require' => '[%' . $type . '%]!=""' |
| 579 | 579 | |
| 580 | 580 | ); |
@@ -592,19 +592,19 @@ discard block |
||
| 592 | 592 | * |
| 593 | 593 | * @return string |
| 594 | 594 | */ |
| 595 | -function sd_get_element_require_string( $args, $key, $type ) { |
|
| 595 | +function sd_get_element_require_string($args, $key, $type) { |
|
| 596 | 596 | $output = ''; |
| 597 | 597 | $requires = array(); |
| 598 | 598 | |
| 599 | - if ( ! empty( $args ) ) { |
|
| 600 | - foreach ( $args as $t => $k ) { |
|
| 601 | - if ( in_array( $key, $k ) ) { |
|
| 599 | + if (!empty($args)) { |
|
| 600 | + foreach ($args as $t => $k) { |
|
| 601 | + if (in_array($key, $k)) { |
|
| 602 | 602 | $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
| 603 | 603 | } |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - if ( ! empty( $requires ) ) { |
|
| 607 | - $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 606 | + if (!empty($requires)) { |
|
| 607 | + $output = '(' . implode(' || ', $requires) . ')'; |
|
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | |
@@ -620,22 +620,22 @@ discard block |
||
| 620 | 620 | * |
| 621 | 621 | * @return array |
| 622 | 622 | */ |
| 623 | -function sd_get_text_color_input( $type = 'text_color', $overwrite = array() ) { |
|
| 623 | +function sd_get_text_color_input($type = 'text_color', $overwrite = array()) { |
|
| 624 | 624 | $options = array( |
| 625 | - '' => __( "None" ), |
|
| 625 | + '' => __("None"), |
|
| 626 | 626 | ) + sd_aui_colors(); |
| 627 | 627 | |
| 628 | 628 | $defaults = array( |
| 629 | 629 | 'type' => 'select', |
| 630 | - 'title' => __( 'Text color' ), |
|
| 630 | + 'title' => __('Text color'), |
|
| 631 | 631 | 'options' => $options, |
| 632 | 632 | 'default' => '', |
| 633 | 633 | 'desc_tip' => true, |
| 634 | - 'group' => __( "Typography" ) |
|
| 634 | + 'group' => __("Typography") |
|
| 635 | 635 | ); |
| 636 | 636 | |
| 637 | 637 | |
| 638 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 638 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 639 | 639 | |
| 640 | 640 | |
| 641 | 641 | return $input; |
@@ -649,18 +649,18 @@ discard block |
||
| 649 | 649 | * |
| 650 | 650 | * @return array |
| 651 | 651 | */ |
| 652 | -function sd_get_col_input( $type = 'col', $overwrite = array() ) { |
|
| 652 | +function sd_get_col_input($type = 'col', $overwrite = array()) { |
|
| 653 | 653 | |
| 654 | 654 | $device_size = ''; |
| 655 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 656 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 655 | + if (!empty($overwrite['device_type'])) { |
|
| 656 | + if ($overwrite['device_type'] == 'Tablet') { |
|
| 657 | 657 | $device_size = '-md'; |
| 658 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 658 | + } elseif ($overwrite['device_type'] == 'Desktop') { |
|
| 659 | 659 | $device_size = '-lg'; |
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | $options = array( |
| 663 | - '' => __( 'auto' ), |
|
| 663 | + '' => __('auto'), |
|
| 664 | 664 | '1' => '1/12', |
| 665 | 665 | '2' => '2/12', |
| 666 | 666 | '3' => '3/12', |
@@ -677,16 +677,16 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | $defaults = array( |
| 679 | 679 | 'type' => 'select', |
| 680 | - 'title' => __( 'Column width' ), |
|
| 680 | + 'title' => __('Column width'), |
|
| 681 | 681 | 'options' => $options, |
| 682 | 682 | 'default' => '', |
| 683 | 683 | 'desc_tip' => true, |
| 684 | - 'group' => __( "Container" ), |
|
| 684 | + 'group' => __("Container"), |
|
| 685 | 685 | 'element_require' => '[%container%]=="col"', |
| 686 | 686 | ); |
| 687 | 687 | |
| 688 | 688 | |
| 689 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 689 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 690 | 690 | |
| 691 | 691 | |
| 692 | 692 | return $input; |
@@ -700,18 +700,18 @@ discard block |
||
| 700 | 700 | * |
| 701 | 701 | * @return array |
| 702 | 702 | */ |
| 703 | -function sd_get_row_cols_input( $type = 'row_cols', $overwrite = array() ) { |
|
| 703 | +function sd_get_row_cols_input($type = 'row_cols', $overwrite = array()) { |
|
| 704 | 704 | |
| 705 | 705 | $device_size = ''; |
| 706 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 707 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 706 | + if (!empty($overwrite['device_type'])) { |
|
| 707 | + if ($overwrite['device_type'] == 'Tablet') { |
|
| 708 | 708 | $device_size = '-md'; |
| 709 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 709 | + } elseif ($overwrite['device_type'] == 'Desktop') { |
|
| 710 | 710 | $device_size = '-lg'; |
| 711 | 711 | } |
| 712 | 712 | } |
| 713 | 713 | $options = array( |
| 714 | - '' => __( 'auto' ), |
|
| 714 | + '' => __('auto'), |
|
| 715 | 715 | '1' => '1', |
| 716 | 716 | '2' => '2', |
| 717 | 717 | '3' => '3', |
@@ -722,16 +722,16 @@ discard block |
||
| 722 | 722 | |
| 723 | 723 | $defaults = array( |
| 724 | 724 | 'type' => 'select', |
| 725 | - 'title' => __( 'Row columns' ), |
|
| 725 | + 'title' => __('Row columns'), |
|
| 726 | 726 | 'options' => $options, |
| 727 | 727 | 'default' => '', |
| 728 | 728 | 'desc_tip' => true, |
| 729 | - 'group' => __( "Container" ), |
|
| 729 | + 'group' => __("Container"), |
|
| 730 | 730 | 'element_require' => '[%container%]=="row"', |
| 731 | 731 | ); |
| 732 | 732 | |
| 733 | 733 | |
| 734 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 734 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 735 | 735 | |
| 736 | 736 | |
| 737 | 737 | return $input; |
@@ -745,34 +745,34 @@ discard block |
||
| 745 | 745 | * |
| 746 | 746 | * @return array |
| 747 | 747 | */ |
| 748 | -function sd_get_text_align_input( $type = 'text_align', $overwrite = array() ) { |
|
| 748 | +function sd_get_text_align_input($type = 'text_align', $overwrite = array()) { |
|
| 749 | 749 | |
| 750 | 750 | $device_size = ''; |
| 751 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 752 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 751 | + if (!empty($overwrite['device_type'])) { |
|
| 752 | + if ($overwrite['device_type'] == 'Tablet') { |
|
| 753 | 753 | $device_size = '-md'; |
| 754 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 754 | + } elseif ($overwrite['device_type'] == 'Desktop') { |
|
| 755 | 755 | $device_size = '-lg'; |
| 756 | 756 | } |
| 757 | 757 | } |
| 758 | 758 | $options = array( |
| 759 | - '' => __( "Default" ), |
|
| 760 | - 'text' . $device_size . '-left' => __( "Left" ), |
|
| 761 | - 'text' . $device_size . '-right' => __( "Right" ), |
|
| 762 | - 'text' . $device_size . '-center' => __( "Center" ), |
|
| 759 | + '' => __("Default"), |
|
| 760 | + 'text' . $device_size . '-left' => __("Left"), |
|
| 761 | + 'text' . $device_size . '-right' => __("Right"), |
|
| 762 | + 'text' . $device_size . '-center' => __("Center"), |
|
| 763 | 763 | ); |
| 764 | 764 | |
| 765 | 765 | $defaults = array( |
| 766 | 766 | 'type' => 'select', |
| 767 | - 'title' => __( 'Text align' ), |
|
| 767 | + 'title' => __('Text align'), |
|
| 768 | 768 | 'options' => $options, |
| 769 | 769 | 'default' => '', |
| 770 | 770 | 'desc_tip' => true, |
| 771 | - 'group' => __( "Typography" ) |
|
| 771 | + 'group' => __("Typography") |
|
| 772 | 772 | ); |
| 773 | 773 | |
| 774 | 774 | |
| 775 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 775 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 776 | 776 | |
| 777 | 777 | |
| 778 | 778 | return $input; |
@@ -786,18 +786,18 @@ discard block |
||
| 786 | 786 | * |
| 787 | 787 | * @return array |
| 788 | 788 | */ |
| 789 | -function sd_get_display_input( $type = 'display', $overwrite = array() ) { |
|
| 789 | +function sd_get_display_input($type = 'display', $overwrite = array()) { |
|
| 790 | 790 | |
| 791 | 791 | $device_size = ''; |
| 792 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 793 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 792 | + if (!empty($overwrite['device_type'])) { |
|
| 793 | + if ($overwrite['device_type'] == 'Tablet') { |
|
| 794 | 794 | $device_size = '-md'; |
| 795 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 795 | + } elseif ($overwrite['device_type'] == 'Desktop') { |
|
| 796 | 796 | $device_size = '-lg'; |
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | 799 | $options = array( |
| 800 | - '' => __( "Default" ), |
|
| 800 | + '' => __("Default"), |
|
| 801 | 801 | 'd' . $device_size . '-none' => "none", |
| 802 | 802 | 'd' . $device_size . '-inline' => "inline", |
| 803 | 803 | 'd' . $device_size . '-inline-block' => "inline-block", |
@@ -811,15 +811,15 @@ discard block |
||
| 811 | 811 | |
| 812 | 812 | $defaults = array( |
| 813 | 813 | 'type' => 'select', |
| 814 | - 'title' => __( 'Display' ), |
|
| 814 | + 'title' => __('Display'), |
|
| 815 | 815 | 'options' => $options, |
| 816 | 816 | 'default' => '', |
| 817 | 817 | 'desc_tip' => true, |
| 818 | - 'group' => __( "Wrapper Styles" ) |
|
| 818 | + 'group' => __("Wrapper Styles") |
|
| 819 | 819 | ); |
| 820 | 820 | |
| 821 | 821 | |
| 822 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 822 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 823 | 823 | |
| 824 | 824 | |
| 825 | 825 | return $input; |
@@ -833,18 +833,18 @@ discard block |
||
| 833 | 833 | * |
| 834 | 834 | * @return array |
| 835 | 835 | */ |
| 836 | -function sd_get_text_justify_input( $type = 'text_justify', $overwrite = array() ) { |
|
| 836 | +function sd_get_text_justify_input($type = 'text_justify', $overwrite = array()) { |
|
| 837 | 837 | |
| 838 | 838 | $defaults = array( |
| 839 | 839 | 'type' => 'checkbox', |
| 840 | - 'title' => __( 'Text justify' ), |
|
| 840 | + 'title' => __('Text justify'), |
|
| 841 | 841 | 'default' => '', |
| 842 | 842 | 'desc_tip' => true, |
| 843 | - 'group' => __( "Typography" ) |
|
| 843 | + 'group' => __("Typography") |
|
| 844 | 844 | ); |
| 845 | 845 | |
| 846 | 846 | |
| 847 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 847 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 848 | 848 | |
| 849 | 849 | |
| 850 | 850 | return $input; |
@@ -859,46 +859,46 @@ discard block |
||
| 859 | 859 | * |
| 860 | 860 | * @return array |
| 861 | 861 | */ |
| 862 | -function sd_aui_colors( $include_branding = false, $include_outlines = false, $outline_button_only_text = false ) { |
|
| 862 | +function sd_aui_colors($include_branding = false, $include_outlines = false, $outline_button_only_text = false) { |
|
| 863 | 863 | $theme_colors = array(); |
| 864 | 864 | |
| 865 | - $theme_colors["primary"] = __( 'Primary' ); |
|
| 866 | - $theme_colors["secondary"] = __( 'Secondary' ); |
|
| 867 | - $theme_colors["success"] = __( 'Success' ); |
|
| 868 | - $theme_colors["danger"] = __( 'Danger' ); |
|
| 869 | - $theme_colors["warning"] = __( 'Warning' ); |
|
| 870 | - $theme_colors["info"] = __( 'Info' ); |
|
| 871 | - $theme_colors["light"] = __( 'Light' ); |
|
| 872 | - $theme_colors["dark"] = __( 'Dark' ); |
|
| 873 | - $theme_colors["white"] = __( 'White' ); |
|
| 874 | - $theme_colors["purple"] = __( 'Purple' ); |
|
| 875 | - $theme_colors["salmon"] = __( 'Salmon' ); |
|
| 876 | - $theme_colors["cyan"] = __( 'Cyan' ); |
|
| 877 | - $theme_colors["gray"] = __( 'Gray' ); |
|
| 878 | - $theme_colors["indigo"] = __( 'Indigo' ); |
|
| 879 | - $theme_colors["orange"] = __( 'Orange' ); |
|
| 880 | - |
|
| 881 | - if ( $include_outlines ) { |
|
| 882 | - $button_only = $outline_button_only_text ? " " . __( "(button only)" ) : ''; |
|
| 883 | - $theme_colors["outline-primary"] = __( 'Primary outline' ) . $button_only; |
|
| 884 | - $theme_colors["outline-secondary"] = __( 'Secondary outline' ) . $button_only; |
|
| 885 | - $theme_colors["outline-success"] = __( 'Success outline' ) . $button_only; |
|
| 886 | - $theme_colors["outline-danger"] = __( 'Danger outline' ) . $button_only; |
|
| 887 | - $theme_colors["outline-warning"] = __( 'Warning outline' ) . $button_only; |
|
| 888 | - $theme_colors["outline-info"] = __( 'Info outline' ) . $button_only; |
|
| 889 | - $theme_colors["outline-light"] = __( 'Light outline' ) . $button_only; |
|
| 890 | - $theme_colors["outline-dark"] = __( 'Dark outline' ) . $button_only; |
|
| 891 | - $theme_colors["outline-white"] = __( 'White outline' ) . $button_only; |
|
| 892 | - $theme_colors["outline-purple"] = __( 'Purple outline' ) . $button_only; |
|
| 893 | - $theme_colors["outline-salmon"] = __( 'Salmon outline' ) . $button_only; |
|
| 894 | - $theme_colors["outline-cyan"] = __( 'Cyan outline' ) . $button_only; |
|
| 895 | - $theme_colors["outline-gray"] = __( 'Gray outline' ) . $button_only; |
|
| 896 | - $theme_colors["outline-indigo"] = __( 'Indigo outline' ) . $button_only; |
|
| 897 | - $theme_colors["outline-orange"] = __( 'Orange outline' ) . $button_only; |
|
| 898 | - } |
|
| 899 | - |
|
| 900 | - |
|
| 901 | - if ( $include_branding ) { |
|
| 865 | + $theme_colors["primary"] = __('Primary'); |
|
| 866 | + $theme_colors["secondary"] = __('Secondary'); |
|
| 867 | + $theme_colors["success"] = __('Success'); |
|
| 868 | + $theme_colors["danger"] = __('Danger'); |
|
| 869 | + $theme_colors["warning"] = __('Warning'); |
|
| 870 | + $theme_colors["info"] = __('Info'); |
|
| 871 | + $theme_colors["light"] = __('Light'); |
|
| 872 | + $theme_colors["dark"] = __('Dark'); |
|
| 873 | + $theme_colors["white"] = __('White'); |
|
| 874 | + $theme_colors["purple"] = __('Purple'); |
|
| 875 | + $theme_colors["salmon"] = __('Salmon'); |
|
| 876 | + $theme_colors["cyan"] = __('Cyan'); |
|
| 877 | + $theme_colors["gray"] = __('Gray'); |
|
| 878 | + $theme_colors["indigo"] = __('Indigo'); |
|
| 879 | + $theme_colors["orange"] = __('Orange'); |
|
| 880 | + |
|
| 881 | + if ($include_outlines) { |
|
| 882 | + $button_only = $outline_button_only_text ? " " . __("(button only)") : ''; |
|
| 883 | + $theme_colors["outline-primary"] = __('Primary outline') . $button_only; |
|
| 884 | + $theme_colors["outline-secondary"] = __('Secondary outline') . $button_only; |
|
| 885 | + $theme_colors["outline-success"] = __('Success outline') . $button_only; |
|
| 886 | + $theme_colors["outline-danger"] = __('Danger outline') . $button_only; |
|
| 887 | + $theme_colors["outline-warning"] = __('Warning outline') . $button_only; |
|
| 888 | + $theme_colors["outline-info"] = __('Info outline') . $button_only; |
|
| 889 | + $theme_colors["outline-light"] = __('Light outline') . $button_only; |
|
| 890 | + $theme_colors["outline-dark"] = __('Dark outline') . $button_only; |
|
| 891 | + $theme_colors["outline-white"] = __('White outline') . $button_only; |
|
| 892 | + $theme_colors["outline-purple"] = __('Purple outline') . $button_only; |
|
| 893 | + $theme_colors["outline-salmon"] = __('Salmon outline') . $button_only; |
|
| 894 | + $theme_colors["outline-cyan"] = __('Cyan outline') . $button_only; |
|
| 895 | + $theme_colors["outline-gray"] = __('Gray outline') . $button_only; |
|
| 896 | + $theme_colors["outline-indigo"] = __('Indigo outline') . $button_only; |
|
| 897 | + $theme_colors["outline-orange"] = __('Orange outline') . $button_only; |
|
| 898 | + } |
|
| 899 | + |
|
| 900 | + |
|
| 901 | + if ($include_branding) { |
|
| 902 | 902 | $theme_colors = $theme_colors + sd_aui_branding_colors(); |
| 903 | 903 | } |
| 904 | 904 | |
@@ -912,17 +912,17 @@ discard block |
||
| 912 | 912 | */ |
| 913 | 913 | function sd_aui_branding_colors() { |
| 914 | 914 | return array( |
| 915 | - "facebook" => __( 'Facebook' ), |
|
| 916 | - "twitter" => __( 'Twitter' ), |
|
| 917 | - "instagram" => __( 'Instagram' ), |
|
| 918 | - "linkedin" => __( 'Linkedin' ), |
|
| 919 | - "flickr" => __( 'Flickr' ), |
|
| 920 | - "github" => __( 'GitHub' ), |
|
| 921 | - "youtube" => __( 'YouTube' ), |
|
| 922 | - "wordpress" => __( 'WordPress' ), |
|
| 923 | - "google" => __( 'Google' ), |
|
| 924 | - "yahoo" => __( 'Yahoo' ), |
|
| 925 | - "vkontakte" => __( 'Vkontakte' ), |
|
| 915 | + "facebook" => __('Facebook'), |
|
| 916 | + "twitter" => __('Twitter'), |
|
| 917 | + "instagram" => __('Instagram'), |
|
| 918 | + "linkedin" => __('Linkedin'), |
|
| 919 | + "flickr" => __('Flickr'), |
|
| 920 | + "github" => __('GitHub'), |
|
| 921 | + "youtube" => __('YouTube'), |
|
| 922 | + "wordpress" => __('WordPress'), |
|
| 923 | + "google" => __('Google'), |
|
| 924 | + "yahoo" => __('Yahoo'), |
|
| 925 | + "vkontakte" => __('Vkontakte'), |
|
| 926 | 926 | ); |
| 927 | 927 | } |
| 928 | 928 | |
@@ -935,11 +935,11 @@ discard block |
||
| 935 | 935 | * |
| 936 | 936 | * @return array |
| 937 | 937 | */ |
| 938 | -function sd_get_container_class_input( $type = 'container', $overwrite = array() ) { |
|
| 938 | +function sd_get_container_class_input($type = 'container', $overwrite = array()) { |
|
| 939 | 939 | |
| 940 | 940 | |
| 941 | 941 | $options = array( |
| 942 | - "container" => __( 'container (default)' ), |
|
| 942 | + "container" => __('container (default)'), |
|
| 943 | 943 | "container-sm" => 'container-sm', |
| 944 | 944 | "container-md" => 'container-md', |
| 945 | 945 | "container-lg" => 'container-lg', |
@@ -958,15 +958,15 @@ discard block |
||
| 958 | 958 | |
| 959 | 959 | $defaults = array( |
| 960 | 960 | 'type' => 'select', |
| 961 | - 'title' => __( 'Type' ), |
|
| 961 | + 'title' => __('Type'), |
|
| 962 | 962 | 'options' => $options, |
| 963 | 963 | 'default' => '', |
| 964 | 964 | 'desc_tip' => true, |
| 965 | - 'group' => __( "Container" ) |
|
| 965 | + 'group' => __("Container") |
|
| 966 | 966 | ); |
| 967 | 967 | |
| 968 | 968 | |
| 969 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 969 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 970 | 970 | |
| 971 | 971 | |
| 972 | 972 | return $input; |
@@ -980,11 +980,11 @@ discard block |
||
| 980 | 980 | * |
| 981 | 981 | * @return array |
| 982 | 982 | */ |
| 983 | -function sd_get_position_class_input( $type = 'position', $overwrite = array() ) { |
|
| 983 | +function sd_get_position_class_input($type = 'position', $overwrite = array()) { |
|
| 984 | 984 | |
| 985 | 985 | |
| 986 | 986 | $options = array( |
| 987 | - "" => __( 'Default' ), |
|
| 987 | + "" => __('Default'), |
|
| 988 | 988 | "position-static" => 'static', |
| 989 | 989 | "position-relative" => 'relative', |
| 990 | 990 | "position-absolute" => 'absolute', |
@@ -997,15 +997,15 @@ discard block |
||
| 997 | 997 | |
| 998 | 998 | $defaults = array( |
| 999 | 999 | 'type' => 'select', |
| 1000 | - 'title' => __( 'Position' ), |
|
| 1000 | + 'title' => __('Position'), |
|
| 1001 | 1001 | 'options' => $options, |
| 1002 | 1002 | 'default' => '', |
| 1003 | 1003 | 'desc_tip' => true, |
| 1004 | - 'group' => __( "Wrapper Styles" ) |
|
| 1004 | + 'group' => __("Wrapper Styles") |
|
| 1005 | 1005 | ); |
| 1006 | 1006 | |
| 1007 | 1007 | |
| 1008 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1008 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1009 | 1009 | |
| 1010 | 1010 | |
| 1011 | 1011 | return $input; |
@@ -1019,30 +1019,30 @@ discard block |
||
| 1019 | 1019 | * |
| 1020 | 1020 | * @return array |
| 1021 | 1021 | */ |
| 1022 | -function sd_get_sticky_offset_input( $type = 'top', $overwrite = array() ) { |
|
| 1022 | +function sd_get_sticky_offset_input($type = 'top', $overwrite = array()) { |
|
| 1023 | 1023 | |
| 1024 | 1024 | $defaults = array( |
| 1025 | 1025 | 'type' => 'number', |
| 1026 | - 'title' => __( 'Sticky offset' ), |
|
| 1026 | + 'title' => __('Sticky offset'), |
|
| 1027 | 1027 | //'desc' => __('Sticky offset'), |
| 1028 | 1028 | 'default' => '', |
| 1029 | 1029 | 'desc_tip' => true, |
| 1030 | - 'group' => __( "Wrapper Styles" ), |
|
| 1030 | + 'group' => __("Wrapper Styles"), |
|
| 1031 | 1031 | 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"' |
| 1032 | 1032 | ); |
| 1033 | 1033 | |
| 1034 | 1034 | // title |
| 1035 | - if ( $type == 'top' ) { |
|
| 1036 | - $defaults['title'] = __( 'Top offset' ); |
|
| 1035 | + if ($type == 'top') { |
|
| 1036 | + $defaults['title'] = __('Top offset'); |
|
| 1037 | 1037 | $defaults['icon'] = 'box-top'; |
| 1038 | 1038 | $defaults['row'] = array( |
| 1039 | - 'title' => __( 'Sticky offset' ), |
|
| 1039 | + 'title' => __('Sticky offset'), |
|
| 1040 | 1040 | 'key' => 'sticky-offset', |
| 1041 | 1041 | 'open' => true, |
| 1042 | 1042 | 'class' => 'text-center', |
| 1043 | 1043 | ); |
| 1044 | - } elseif ( $type == 'bottom' ) { |
|
| 1045 | - $defaults['title'] = __( 'Bottom offset' ); |
|
| 1044 | + } elseif ($type == 'bottom') { |
|
| 1045 | + $defaults['title'] = __('Bottom offset'); |
|
| 1046 | 1046 | $defaults['icon'] = 'box-bottom'; |
| 1047 | 1047 | $defaults['row'] = array( |
| 1048 | 1048 | 'key' => 'sticky-offset', |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | |
| 1054 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1054 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1055 | 1055 | |
| 1056 | 1056 | |
| 1057 | 1057 | return $input; |
@@ -1065,11 +1065,11 @@ discard block |
||
| 1065 | 1065 | * |
| 1066 | 1066 | * @return array |
| 1067 | 1067 | */ |
| 1068 | -function sd_get_font_size_input( $type = 'font_size', $overwrite = array(), $has_custom = false ) { |
|
| 1068 | +function sd_get_font_size_input($type = 'font_size', $overwrite = array(), $has_custom = false) { |
|
| 1069 | 1069 | |
| 1070 | 1070 | |
| 1071 | 1071 | $options = array( |
| 1072 | - "" => __( 'Inherit from parent' ), |
|
| 1072 | + "" => __('Inherit from parent'), |
|
| 1073 | 1073 | "h6" => 'h6', |
| 1074 | 1074 | "h5" => 'h5', |
| 1075 | 1075 | "h4" => 'h4', |
@@ -1082,21 +1082,21 @@ discard block |
||
| 1082 | 1082 | "display-4" => "display-4", |
| 1083 | 1083 | ); |
| 1084 | 1084 | |
| 1085 | - if ( $has_custom ) { |
|
| 1086 | - $options['custom'] = __( 'Custom size' ); |
|
| 1085 | + if ($has_custom) { |
|
| 1086 | + $options['custom'] = __('Custom size'); |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | $defaults = array( |
| 1090 | 1090 | 'type' => 'select', |
| 1091 | - 'title' => __( 'Font size' ), |
|
| 1091 | + 'title' => __('Font size'), |
|
| 1092 | 1092 | 'options' => $options, |
| 1093 | 1093 | 'default' => '', |
| 1094 | 1094 | 'desc_tip' => true, |
| 1095 | - 'group' => __( "Typography" ) |
|
| 1095 | + 'group' => __("Typography") |
|
| 1096 | 1096 | ); |
| 1097 | 1097 | |
| 1098 | 1098 | |
| 1099 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1099 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1100 | 1100 | |
| 1101 | 1101 | |
| 1102 | 1102 | return $input; |
@@ -1110,12 +1110,12 @@ discard block |
||
| 1110 | 1110 | * |
| 1111 | 1111 | * @return array |
| 1112 | 1112 | */ |
| 1113 | -function sd_get_font_custom_size_input( $type = 'font_size_custom', $overwrite = array(), $parent_type = '' ) { |
|
| 1113 | +function sd_get_font_custom_size_input($type = 'font_size_custom', $overwrite = array(), $parent_type = '') { |
|
| 1114 | 1114 | |
| 1115 | 1115 | |
| 1116 | 1116 | $defaults = array( |
| 1117 | 1117 | 'type' => 'number', |
| 1118 | - 'title' => __( 'Font size (rem)' ), |
|
| 1118 | + 'title' => __('Font size (rem)'), |
|
| 1119 | 1119 | 'default' => '', |
| 1120 | 1120 | 'placeholder' => '1.25', |
| 1121 | 1121 | 'custom_attributes' => array( |
@@ -1124,15 +1124,15 @@ discard block |
||
| 1124 | 1124 | 'max' => '100', |
| 1125 | 1125 | ), |
| 1126 | 1126 | 'desc_tip' => true, |
| 1127 | - 'group' => __( "Typography" ) |
|
| 1127 | + 'group' => __("Typography") |
|
| 1128 | 1128 | ); |
| 1129 | 1129 | |
| 1130 | - if ( $parent_type ) { |
|
| 1130 | + if ($parent_type) { |
|
| 1131 | 1131 | $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | |
| 1135 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1135 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1136 | 1136 | |
| 1137 | 1137 | |
| 1138 | 1138 | return $input; |
@@ -1146,18 +1146,18 @@ discard block |
||
| 1146 | 1146 | * |
| 1147 | 1147 | * @return array |
| 1148 | 1148 | */ |
| 1149 | -function sd_get_font_size_input_group( $type = 'font_size', $overwrite = array(), $overwrite_custom = array() ) { |
|
| 1149 | +function sd_get_font_size_input_group($type = 'font_size', $overwrite = array(), $overwrite_custom = array()) { |
|
| 1150 | 1150 | |
| 1151 | 1151 | |
| 1152 | 1152 | $inputs = array(); |
| 1153 | 1153 | |
| 1154 | - if ( $overwrite !== false ) { |
|
| 1155 | - $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1154 | + if ($overwrite !== false) { |
|
| 1155 | + $inputs[$type] = sd_get_font_size_input($type, $overwrite, true); |
|
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | - if ( $overwrite_custom !== false ) { |
|
| 1158 | + if ($overwrite_custom !== false) { |
|
| 1159 | 1159 | $custom = $type . "_custom"; |
| 1160 | - $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1160 | + $inputs[$custom] = sd_get_font_custom_size_input($custom, $overwrite_custom, $type); |
|
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | |
@@ -1172,11 +1172,11 @@ discard block |
||
| 1172 | 1172 | * |
| 1173 | 1173 | * @return array |
| 1174 | 1174 | */ |
| 1175 | -function sd_get_font_weight_input( $type = 'font_weight', $overwrite = array() ) { |
|
| 1175 | +function sd_get_font_weight_input($type = 'font_weight', $overwrite = array()) { |
|
| 1176 | 1176 | |
| 1177 | 1177 | |
| 1178 | 1178 | $options = array( |
| 1179 | - "" => __( 'Inherit' ), |
|
| 1179 | + "" => __('Inherit'), |
|
| 1180 | 1180 | "font-weight-bold" => 'bold', |
| 1181 | 1181 | "font-weight-bolder" => 'bolder', |
| 1182 | 1182 | "font-weight-normal" => 'normal', |
@@ -1192,15 +1192,15 @@ discard block |
||
| 1192 | 1192 | |
| 1193 | 1193 | $defaults = array( |
| 1194 | 1194 | 'type' => 'select', |
| 1195 | - 'title' => __( 'Appearance' ), |
|
| 1195 | + 'title' => __('Appearance'), |
|
| 1196 | 1196 | 'options' => $options, |
| 1197 | 1197 | 'default' => '', |
| 1198 | 1198 | 'desc_tip' => true, |
| 1199 | - 'group' => __( "Typography" ) |
|
| 1199 | + 'group' => __("Typography") |
|
| 1200 | 1200 | ); |
| 1201 | 1201 | |
| 1202 | 1202 | |
| 1203 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1203 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1204 | 1204 | |
| 1205 | 1205 | |
| 1206 | 1206 | return $input; |
@@ -1214,27 +1214,27 @@ discard block |
||
| 1214 | 1214 | * |
| 1215 | 1215 | * @return array |
| 1216 | 1216 | */ |
| 1217 | -function sd_get_font_case_input( $type = 'font_weight', $overwrite = array() ) { |
|
| 1217 | +function sd_get_font_case_input($type = 'font_weight', $overwrite = array()) { |
|
| 1218 | 1218 | |
| 1219 | 1219 | |
| 1220 | 1220 | $options = array( |
| 1221 | - "" => __( 'Default' ), |
|
| 1222 | - "text-lowercase" => __( 'lowercase' ), |
|
| 1223 | - "text-uppercase" => __( 'UPPERCASE' ), |
|
| 1224 | - "text-capitalize" => __( 'Capitalize' ), |
|
| 1221 | + "" => __('Default'), |
|
| 1222 | + "text-lowercase" => __('lowercase'), |
|
| 1223 | + "text-uppercase" => __('UPPERCASE'), |
|
| 1224 | + "text-capitalize" => __('Capitalize'), |
|
| 1225 | 1225 | ); |
| 1226 | 1226 | |
| 1227 | 1227 | $defaults = array( |
| 1228 | 1228 | 'type' => 'select', |
| 1229 | - 'title' => __( 'Letter case' ), |
|
| 1229 | + 'title' => __('Letter case'), |
|
| 1230 | 1230 | 'options' => $options, |
| 1231 | 1231 | 'default' => '', |
| 1232 | 1232 | 'desc_tip' => true, |
| 1233 | - 'group' => __( "Typography" ) |
|
| 1233 | + 'group' => __("Typography") |
|
| 1234 | 1234 | ); |
| 1235 | 1235 | |
| 1236 | 1236 | |
| 1237 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1237 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1238 | 1238 | |
| 1239 | 1239 | |
| 1240 | 1240 | return $input; |
@@ -1249,24 +1249,24 @@ discard block |
||
| 1249 | 1249 | * A helper function for font size |
| 1250 | 1250 | * |
| 1251 | 1251 | */ |
| 1252 | -function sd_get_font_italic_input( $type = 'font_italic', $overwrite = array() ) { |
|
| 1252 | +function sd_get_font_italic_input($type = 'font_italic', $overwrite = array()) { |
|
| 1253 | 1253 | |
| 1254 | 1254 | |
| 1255 | 1255 | $options = array( |
| 1256 | - "" => __( 'No' ), |
|
| 1257 | - "font-italic" => __( 'Yes' ) |
|
| 1256 | + "" => __('No'), |
|
| 1257 | + "font-italic" => __('Yes') |
|
| 1258 | 1258 | ); |
| 1259 | 1259 | |
| 1260 | 1260 | $defaults = array( |
| 1261 | 1261 | 'type' => 'select', |
| 1262 | - 'title' => __( 'Font italic' ), |
|
| 1262 | + 'title' => __('Font italic'), |
|
| 1263 | 1263 | 'options' => $options, |
| 1264 | 1264 | 'default' => '', |
| 1265 | 1265 | 'desc_tip' => true, |
| 1266 | - 'group' => __( "Typography" ) |
|
| 1266 | + 'group' => __("Typography") |
|
| 1267 | 1267 | ); |
| 1268 | 1268 | |
| 1269 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1269 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1270 | 1270 | |
| 1271 | 1271 | |
| 1272 | 1272 | return $input; |
@@ -1280,19 +1280,19 @@ discard block |
||
| 1280 | 1280 | * |
| 1281 | 1281 | * @return array |
| 1282 | 1282 | */ |
| 1283 | -function sd_get_anchor_input( $type = 'anchor', $overwrite = array() ) { |
|
| 1283 | +function sd_get_anchor_input($type = 'anchor', $overwrite = array()) { |
|
| 1284 | 1284 | |
| 1285 | 1285 | |
| 1286 | 1286 | $defaults = array( |
| 1287 | 1287 | 'type' => 'text', |
| 1288 | - 'title' => __( 'HTML anchor' ), |
|
| 1289 | - '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.' ), |
|
| 1288 | + 'title' => __('HTML anchor'), |
|
| 1289 | + '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.'), |
|
| 1290 | 1290 | 'default' => '', |
| 1291 | 1291 | 'desc_tip' => true, |
| 1292 | - 'group' => __( "Advanced" ) |
|
| 1292 | + 'group' => __("Advanced") |
|
| 1293 | 1293 | ); |
| 1294 | 1294 | |
| 1295 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1295 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1296 | 1296 | |
| 1297 | 1297 | |
| 1298 | 1298 | return $input; |
@@ -1306,18 +1306,18 @@ discard block |
||
| 1306 | 1306 | * |
| 1307 | 1307 | * @return array |
| 1308 | 1308 | */ |
| 1309 | -function sd_get_class_input( $type = 'css_class', $overwrite = array() ) { |
|
| 1309 | +function sd_get_class_input($type = 'css_class', $overwrite = array()) { |
|
| 1310 | 1310 | |
| 1311 | 1311 | $defaults = array( |
| 1312 | 1312 | 'type' => 'text', |
| 1313 | - 'title' => __( 'Additional CSS class(es)' ), |
|
| 1314 | - 'desc' => __( 'Separate multiple classes with spaces.' ), |
|
| 1313 | + 'title' => __('Additional CSS class(es)'), |
|
| 1314 | + 'desc' => __('Separate multiple classes with spaces.'), |
|
| 1315 | 1315 | 'default' => '', |
| 1316 | 1316 | 'desc_tip' => true, |
| 1317 | - 'group' => __( "Advanced" ) |
|
| 1317 | + 'group' => __("Advanced") |
|
| 1318 | 1318 | ); |
| 1319 | 1319 | |
| 1320 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1320 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1321 | 1321 | |
| 1322 | 1322 | |
| 1323 | 1323 | return $input; |
@@ -1332,236 +1332,236 @@ discard block |
||
| 1332 | 1332 | * @return string |
| 1333 | 1333 | * @todo find best way to use px- py- or general p- |
| 1334 | 1334 | */ |
| 1335 | -function sd_build_aui_class( $args ) { |
|
| 1335 | +function sd_build_aui_class($args) { |
|
| 1336 | 1336 | |
| 1337 | 1337 | $classes = array(); |
| 1338 | 1338 | |
| 1339 | 1339 | // margins. |
| 1340 | - if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 1341 | - $classes[] = "mt-" . sanitize_html_class( $args['mt'] ); |
|
| 1340 | + if (isset($args['mt']) && $args['mt'] !== '') { |
|
| 1341 | + $classes[] = "mt-" . sanitize_html_class($args['mt']); |
|
| 1342 | 1342 | $mt = $args['mt']; |
| 1343 | 1343 | } else { |
| 1344 | 1344 | $mt = null; |
| 1345 | 1345 | } |
| 1346 | - if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 1347 | - $classes[] = "mr-" . sanitize_html_class( $args['mr'] ); |
|
| 1346 | + if (isset($args['mr']) && $args['mr'] !== '') { |
|
| 1347 | + $classes[] = "mr-" . sanitize_html_class($args['mr']); |
|
| 1348 | 1348 | $mr = $args['mr']; |
| 1349 | 1349 | } else { |
| 1350 | 1350 | $mr = null; |
| 1351 | 1351 | } |
| 1352 | - if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 1353 | - $classes[] = "mb-" . sanitize_html_class( $args['mb'] ); |
|
| 1352 | + if (isset($args['mb']) && $args['mb'] !== '') { |
|
| 1353 | + $classes[] = "mb-" . sanitize_html_class($args['mb']); |
|
| 1354 | 1354 | $mb = $args['mb']; |
| 1355 | 1355 | } else { |
| 1356 | 1356 | $mb = null; |
| 1357 | 1357 | } |
| 1358 | - if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 1359 | - $classes[] = "ml-" . sanitize_html_class( $args['ml'] ); |
|
| 1358 | + if (isset($args['ml']) && $args['ml'] !== '') { |
|
| 1359 | + $classes[] = "ml-" . sanitize_html_class($args['ml']); |
|
| 1360 | 1360 | $ml = $args['ml']; |
| 1361 | 1361 | } else { |
| 1362 | 1362 | $ml = null; |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | // margins tablet. |
| 1366 | - if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 1367 | - $classes[] = "mt-md-" . sanitize_html_class( $args['mt_md'] ); |
|
| 1366 | + if (isset($args['mt_md']) && $args['mt_md'] !== '') { |
|
| 1367 | + $classes[] = "mt-md-" . sanitize_html_class($args['mt_md']); |
|
| 1368 | 1368 | $mt_md = $args['mt_md']; |
| 1369 | 1369 | } else { |
| 1370 | 1370 | $mt_md = null; |
| 1371 | 1371 | } |
| 1372 | - if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 1373 | - $classes[] = "mr-md-" . sanitize_html_class( $args['mr_md'] ); |
|
| 1372 | + if (isset($args['mr_md']) && $args['mr_md'] !== '') { |
|
| 1373 | + $classes[] = "mr-md-" . sanitize_html_class($args['mr_md']); |
|
| 1374 | 1374 | $mt_md = $args['mr_md']; |
| 1375 | 1375 | } else { |
| 1376 | 1376 | $mr_md = null; |
| 1377 | 1377 | } |
| 1378 | - if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 1379 | - $classes[] = "mb-md-" . sanitize_html_class( $args['mb_md'] ); |
|
| 1378 | + if (isset($args['mb_md']) && $args['mb_md'] !== '') { |
|
| 1379 | + $classes[] = "mb-md-" . sanitize_html_class($args['mb_md']); |
|
| 1380 | 1380 | $mt_md = $args['mb_md']; |
| 1381 | 1381 | } else { |
| 1382 | 1382 | $mb_md = null; |
| 1383 | 1383 | } |
| 1384 | - if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 1385 | - $classes[] = "ml-md-" . sanitize_html_class( $args['ml_md'] ); |
|
| 1384 | + if (isset($args['ml_md']) && $args['ml_md'] !== '') { |
|
| 1385 | + $classes[] = "ml-md-" . sanitize_html_class($args['ml_md']); |
|
| 1386 | 1386 | $mt_md = $args['ml_md']; |
| 1387 | 1387 | } else { |
| 1388 | 1388 | $ml_md = null; |
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | 1391 | // margins desktop. |
| 1392 | - if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 1393 | - if ( $mt == null && $mt_md == null ) { |
|
| 1394 | - $classes[] = "mt-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1392 | + if (isset($args['mt_lg']) && $args['mt_lg'] !== '') { |
|
| 1393 | + if ($mt == null && $mt_md == null) { |
|
| 1394 | + $classes[] = "mt-" . sanitize_html_class($args['mt_lg']); |
|
| 1395 | 1395 | } else { |
| 1396 | - $classes[] = "mt-lg-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1396 | + $classes[] = "mt-lg-" . sanitize_html_class($args['mt_lg']); |
|
| 1397 | 1397 | } |
| 1398 | 1398 | } |
| 1399 | - if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 1400 | - if ( $mr == null && $mr_md == null ) { |
|
| 1401 | - $classes[] = "mr-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1399 | + if (isset($args['mr_lg']) && $args['mr_lg'] !== '') { |
|
| 1400 | + if ($mr == null && $mr_md == null) { |
|
| 1401 | + $classes[] = "mr-" . sanitize_html_class($args['mr_lg']); |
|
| 1402 | 1402 | } else { |
| 1403 | - $classes[] = "mr-lg-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1403 | + $classes[] = "mr-lg-" . sanitize_html_class($args['mr_lg']); |
|
| 1404 | 1404 | } |
| 1405 | 1405 | } |
| 1406 | - if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 1407 | - if ( $mb == null && $mb_md == null ) { |
|
| 1408 | - $classes[] = "mb-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1406 | + if (isset($args['mb_lg']) && $args['mb_lg'] !== '') { |
|
| 1407 | + if ($mb == null && $mb_md == null) { |
|
| 1408 | + $classes[] = "mb-" . sanitize_html_class($args['mb_lg']); |
|
| 1409 | 1409 | } else { |
| 1410 | - $classes[] = "mb-lg-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1410 | + $classes[] = "mb-lg-" . sanitize_html_class($args['mb_lg']); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | } |
| 1413 | - if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 1414 | - if ( $ml == null && $ml_md == null ) { |
|
| 1415 | - $classes[] = "ml-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1413 | + if (isset($args['ml_lg']) && $args['ml_lg'] !== '') { |
|
| 1414 | + if ($ml == null && $ml_md == null) { |
|
| 1415 | + $classes[] = "ml-" . sanitize_html_class($args['ml_lg']); |
|
| 1416 | 1416 | } else { |
| 1417 | - $classes[] = "ml-lg-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1417 | + $classes[] = "ml-lg-" . sanitize_html_class($args['ml_lg']); |
|
| 1418 | 1418 | } |
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | 1421 | |
| 1422 | 1422 | // padding. |
| 1423 | - if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 1424 | - $classes[] = "pt-" . sanitize_html_class( $args['pt'] ); |
|
| 1423 | + if (isset($args['pt']) && $args['pt'] !== '') { |
|
| 1424 | + $classes[] = "pt-" . sanitize_html_class($args['pt']); |
|
| 1425 | 1425 | $pt = $args['pt']; |
| 1426 | 1426 | } else { |
| 1427 | 1427 | $pt = null; |
| 1428 | 1428 | } |
| 1429 | - if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 1430 | - $classes[] = "pr-" . sanitize_html_class( $args['pr'] ); |
|
| 1429 | + if (isset($args['pr']) && $args['pr'] !== '') { |
|
| 1430 | + $classes[] = "pr-" . sanitize_html_class($args['pr']); |
|
| 1431 | 1431 | $pr = $args['pr']; |
| 1432 | 1432 | } else { |
| 1433 | 1433 | $pr = null; |
| 1434 | 1434 | } |
| 1435 | - if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 1436 | - $classes[] = "pb-" . sanitize_html_class( $args['pb'] ); |
|
| 1435 | + if (isset($args['pb']) && $args['pb'] !== '') { |
|
| 1436 | + $classes[] = "pb-" . sanitize_html_class($args['pb']); |
|
| 1437 | 1437 | $pb = $args['pb']; |
| 1438 | 1438 | } else { |
| 1439 | 1439 | $pb = null; |
| 1440 | 1440 | } |
| 1441 | - if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 1442 | - $classes[] = "pl-" . sanitize_html_class( $args['pl'] ); |
|
| 1441 | + if (isset($args['pl']) && $args['pl'] !== '') { |
|
| 1442 | + $classes[] = "pl-" . sanitize_html_class($args['pl']); |
|
| 1443 | 1443 | $pl = $args['pl']; |
| 1444 | 1444 | } else { |
| 1445 | 1445 | $pl = null; |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | 1448 | // padding tablet. |
| 1449 | - if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 1450 | - $classes[] = "pt-md-" . sanitize_html_class( $args['pt_md'] ); |
|
| 1449 | + if (isset($args['pt_md']) && $args['pt_md'] !== '') { |
|
| 1450 | + $classes[] = "pt-md-" . sanitize_html_class($args['pt_md']); |
|
| 1451 | 1451 | $pt_md = $args['pt_md']; |
| 1452 | 1452 | } else { |
| 1453 | 1453 | $pt_md = null; |
| 1454 | 1454 | } |
| 1455 | - if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 1456 | - $classes[] = "pr-md-" . sanitize_html_class( $args['pr_md'] ); |
|
| 1455 | + if (isset($args['pr_md']) && $args['pr_md'] !== '') { |
|
| 1456 | + $classes[] = "pr-md-" . sanitize_html_class($args['pr_md']); |
|
| 1457 | 1457 | $pt_md = $args['pr_md']; |
| 1458 | 1458 | } else { |
| 1459 | 1459 | $pr_md = null; |
| 1460 | 1460 | } |
| 1461 | - if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 1462 | - $classes[] = "pb-md-" . sanitize_html_class( $args['pb_md'] ); |
|
| 1461 | + if (isset($args['pb_md']) && $args['pb_md'] !== '') { |
|
| 1462 | + $classes[] = "pb-md-" . sanitize_html_class($args['pb_md']); |
|
| 1463 | 1463 | $pt_md = $args['pb_md']; |
| 1464 | 1464 | } else { |
| 1465 | 1465 | $pb_md = null; |
| 1466 | 1466 | } |
| 1467 | - if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 1468 | - $classes[] = "pl-md-" . sanitize_html_class( $args['pl_md'] ); |
|
| 1467 | + if (isset($args['pl_md']) && $args['pl_md'] !== '') { |
|
| 1468 | + $classes[] = "pl-md-" . sanitize_html_class($args['pl_md']); |
|
| 1469 | 1469 | $pt_md = $args['pl_md']; |
| 1470 | 1470 | } else { |
| 1471 | 1471 | $pl_md = null; |
| 1472 | 1472 | } |
| 1473 | 1473 | |
| 1474 | 1474 | // padding desktop. |
| 1475 | - if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 1476 | - if ( $pt == null && $pt_md == null ) { |
|
| 1477 | - $classes[] = "pt-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1475 | + if (isset($args['pt_lg']) && $args['pt_lg'] !== '') { |
|
| 1476 | + if ($pt == null && $pt_md == null) { |
|
| 1477 | + $classes[] = "pt-" . sanitize_html_class($args['pt_lg']); |
|
| 1478 | 1478 | } else { |
| 1479 | - $classes[] = "pt-lg-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1479 | + $classes[] = "pt-lg-" . sanitize_html_class($args['pt_lg']); |
|
| 1480 | 1480 | } |
| 1481 | 1481 | } |
| 1482 | - if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 1483 | - if ( $pr == null && $pr_md == null ) { |
|
| 1484 | - $classes[] = "pr-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1482 | + if (isset($args['pr_lg']) && $args['pr_lg'] !== '') { |
|
| 1483 | + if ($pr == null && $pr_md == null) { |
|
| 1484 | + $classes[] = "pr-" . sanitize_html_class($args['pr_lg']); |
|
| 1485 | 1485 | } else { |
| 1486 | - $classes[] = "pr-lg-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1486 | + $classes[] = "pr-lg-" . sanitize_html_class($args['pr_lg']); |
|
| 1487 | 1487 | } |
| 1488 | 1488 | } |
| 1489 | - if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 1490 | - if ( $pb == null && $pb_md == null ) { |
|
| 1491 | - $classes[] = "pb-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1489 | + if (isset($args['pb_lg']) && $args['pb_lg'] !== '') { |
|
| 1490 | + if ($pb == null && $pb_md == null) { |
|
| 1491 | + $classes[] = "pb-" . sanitize_html_class($args['pb_lg']); |
|
| 1492 | 1492 | } else { |
| 1493 | - $classes[] = "pb-lg-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1493 | + $classes[] = "pb-lg-" . sanitize_html_class($args['pb_lg']); |
|
| 1494 | 1494 | } |
| 1495 | 1495 | } |
| 1496 | - if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 1497 | - if ( $pl == null && $pl_md == null ) { |
|
| 1498 | - $classes[] = "pl-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1496 | + if (isset($args['pl_lg']) && $args['pl_lg'] !== '') { |
|
| 1497 | + if ($pl == null && $pl_md == null) { |
|
| 1498 | + $classes[] = "pl-" . sanitize_html_class($args['pl_lg']); |
|
| 1499 | 1499 | } else { |
| 1500 | - $classes[] = "pl-lg-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1500 | + $classes[] = "pl-lg-" . sanitize_html_class($args['pl_lg']); |
|
| 1501 | 1501 | } |
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | 1504 | // row cols, mobile, tablet, desktop |
| 1505 | - if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 1506 | - $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols'] ); |
|
| 1505 | + if (!empty($args['row_cols']) && $args['row_cols'] !== '') { |
|
| 1506 | + $classes[] = sanitize_html_class("row-cols-" . $args['row_cols']); |
|
| 1507 | 1507 | $row_cols = $args['row_cols']; |
| 1508 | 1508 | } else { |
| 1509 | 1509 | $row_cols = null; |
| 1510 | 1510 | } |
| 1511 | - if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 1512 | - $classes[] = sanitize_html_class( "row-cols-md-" . $args['row_cols_md'] ); |
|
| 1511 | + if (!empty($args['row_cols_md']) && $args['row_cols_md'] !== '') { |
|
| 1512 | + $classes[] = sanitize_html_class("row-cols-md-" . $args['row_cols_md']); |
|
| 1513 | 1513 | $row_cols_md = $args['row_cols_md']; |
| 1514 | 1514 | } else { |
| 1515 | 1515 | $row_cols_md = null; |
| 1516 | 1516 | } |
| 1517 | - if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 1518 | - if ( $row_cols == null && $row_cols_md == null ) { |
|
| 1519 | - $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols_lg'] ); |
|
| 1517 | + if (!empty($args['row_cols_lg']) && $args['row_cols_lg'] !== '') { |
|
| 1518 | + if ($row_cols == null && $row_cols_md == null) { |
|
| 1519 | + $classes[] = sanitize_html_class("row-cols-" . $args['row_cols_lg']); |
|
| 1520 | 1520 | } else { |
| 1521 | - $classes[] = sanitize_html_class( "row-cols-lg-" . $args['row_cols_lg'] ); |
|
| 1521 | + $classes[] = sanitize_html_class("row-cols-lg-" . $args['row_cols_lg']); |
|
| 1522 | 1522 | } |
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | // columns , mobile, tablet, desktop |
| 1526 | - if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 1527 | - $classes[] = sanitize_html_class( "col-" . $args['col'] ); |
|
| 1526 | + if (!empty($args['col']) && $args['col'] !== '') { |
|
| 1527 | + $classes[] = sanitize_html_class("col-" . $args['col']); |
|
| 1528 | 1528 | $col = $args['col']; |
| 1529 | 1529 | } else { |
| 1530 | 1530 | $col = null; |
| 1531 | 1531 | } |
| 1532 | - if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 1533 | - $classes[] = sanitize_html_class( "col-md-" . $args['col_md'] ); |
|
| 1532 | + if (!empty($args['col_md']) && $args['col_md'] !== '') { |
|
| 1533 | + $classes[] = sanitize_html_class("col-md-" . $args['col_md']); |
|
| 1534 | 1534 | $col_md = $args['col_md']; |
| 1535 | 1535 | } else { |
| 1536 | 1536 | $col_md = null; |
| 1537 | 1537 | } |
| 1538 | - if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 1539 | - if ( $col == null && $col_md == null ) { |
|
| 1540 | - $classes[] = sanitize_html_class( "col-" . $args['col_lg'] ); |
|
| 1538 | + if (!empty($args['col_lg']) && $args['col_lg'] !== '') { |
|
| 1539 | + if ($col == null && $col_md == null) { |
|
| 1540 | + $classes[] = sanitize_html_class("col-" . $args['col_lg']); |
|
| 1541 | 1541 | } else { |
| 1542 | - $classes[] = sanitize_html_class( "col-lg-" . $args['col_lg'] ); |
|
| 1542 | + $classes[] = sanitize_html_class("col-lg-" . $args['col_lg']); |
|
| 1543 | 1543 | } |
| 1544 | 1544 | } |
| 1545 | 1545 | |
| 1546 | 1546 | |
| 1547 | 1547 | // border |
| 1548 | - if ( ! empty( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' ) ) { |
|
| 1548 | + if (!empty($args['border']) && ($args['border'] == 'none' || $args['border'] === '0')) { |
|
| 1549 | 1549 | $classes[] = "border-0"; |
| 1550 | - } elseif ( ! empty( $args['border'] ) ) { |
|
| 1551 | - $classes[] = "border border-" . sanitize_html_class( $args['border'] ); |
|
| 1550 | + } elseif (!empty($args['border'])) { |
|
| 1551 | + $classes[] = "border border-" . sanitize_html_class($args['border']); |
|
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | 1554 | // border radius type |
| 1555 | - if ( ! empty( $args['rounded'] ) ) { |
|
| 1556 | - $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 1555 | + if (!empty($args['rounded'])) { |
|
| 1556 | + $classes[] = sanitize_html_class($args['rounded']); |
|
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | 1559 | // border radius size |
| 1560 | - if ( ! empty( $args['rounded_size'] ) ) { |
|
| 1561 | - $classes[] = "rounded-" . sanitize_html_class( $args['rounded_size'] ); |
|
| 1560 | + if (!empty($args['rounded_size'])) { |
|
| 1561 | + $classes[] = "rounded-" . sanitize_html_class($args['rounded_size']); |
|
| 1562 | 1562 | // if we set a size then we need to remove "rounded" if set |
| 1563 | - if ( ( $key = array_search( "rounded", $classes ) ) !== false ) { |
|
| 1564 | - unset( $classes[ $key ] ); |
|
| 1563 | + if (($key = array_search("rounded", $classes)) !== false) { |
|
| 1564 | + unset($classes[$key]); |
|
| 1565 | 1565 | } |
| 1566 | 1566 | } |
| 1567 | 1567 | |
@@ -1569,83 +1569,83 @@ discard block |
||
| 1569 | 1569 | //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
| 1570 | 1570 | |
| 1571 | 1571 | // background |
| 1572 | - if ( ! empty( $args['bg'] ) ) { |
|
| 1573 | - $classes[] = "bg-" . sanitize_html_class( $args['bg'] ); |
|
| 1572 | + if (!empty($args['bg'])) { |
|
| 1573 | + $classes[] = "bg-" . sanitize_html_class($args['bg']); |
|
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | // text_color |
| 1577 | - if ( ! empty( $args['text_color'] ) ) { |
|
| 1578 | - $classes[] = "text-" . sanitize_html_class( $args['text_color'] ); |
|
| 1577 | + if (!empty($args['text_color'])) { |
|
| 1578 | + $classes[] = "text-" . sanitize_html_class($args['text_color']); |
|
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | // text_align |
| 1582 | - if ( ! empty( $args['text_justify'] ) ) { |
|
| 1582 | + if (!empty($args['text_justify'])) { |
|
| 1583 | 1583 | $classes[] = 'text-justify'; |
| 1584 | 1584 | } else { |
| 1585 | - if ( ! empty( $args['text_align'] ) ) { |
|
| 1586 | - $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 1585 | + if (!empty($args['text_align'])) { |
|
| 1586 | + $classes[] = sanitize_html_class($args['text_align']); |
|
| 1587 | 1587 | $text_align = $args['text_align']; |
| 1588 | 1588 | } else { |
| 1589 | 1589 | $text_align = null; |
| 1590 | 1590 | } |
| 1591 | - if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 1592 | - $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 1591 | + if (!empty($args['text_align_md']) && $args['text_align_md'] !== '') { |
|
| 1592 | + $classes[] = sanitize_html_class($args['text_align_md']); |
|
| 1593 | 1593 | $text_align_md = $args['text_align_md']; |
| 1594 | 1594 | } else { |
| 1595 | 1595 | $text_align_md = null; |
| 1596 | 1596 | } |
| 1597 | - if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 1598 | - if ( $text_align == null && $text_align_md == null ) { |
|
| 1599 | - $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['text_align_lg'] ) ); |
|
| 1597 | + if (!empty($args['text_align_lg']) && $args['text_align_lg'] !== '') { |
|
| 1598 | + if ($text_align == null && $text_align_md == null) { |
|
| 1599 | + $classes[] = sanitize_html_class(str_replace("-lg", "", $args['text_align_lg'])); |
|
| 1600 | 1600 | } else { |
| 1601 | - $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 1601 | + $classes[] = sanitize_html_class($args['text_align_lg']); |
|
| 1602 | 1602 | } |
| 1603 | 1603 | } |
| 1604 | 1604 | } |
| 1605 | 1605 | |
| 1606 | 1606 | // display |
| 1607 | - if ( ! empty( $args['display'] ) ) { |
|
| 1608 | - $classes[] = sanitize_html_class( $args['display'] ); |
|
| 1607 | + if (!empty($args['display'])) { |
|
| 1608 | + $classes[] = sanitize_html_class($args['display']); |
|
| 1609 | 1609 | $display = $args['display']; |
| 1610 | 1610 | } else { |
| 1611 | 1611 | $display = null; |
| 1612 | 1612 | } |
| 1613 | - if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 1614 | - $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 1613 | + if (!empty($args['display_md']) && $args['display_md'] !== '') { |
|
| 1614 | + $classes[] = sanitize_html_class($args['display_md']); |
|
| 1615 | 1615 | $display_md = $args['display_md']; |
| 1616 | 1616 | } else { |
| 1617 | 1617 | $display_md = null; |
| 1618 | 1618 | } |
| 1619 | - if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 1620 | - if ( $display == null && $display_md == null ) { |
|
| 1621 | - $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['display_lg'] ) ); |
|
| 1619 | + if (!empty($args['display_lg']) && $args['display_lg'] !== '') { |
|
| 1620 | + if ($display == null && $display_md == null) { |
|
| 1621 | + $classes[] = sanitize_html_class(str_replace("-lg", "", $args['display_lg'])); |
|
| 1622 | 1622 | } else { |
| 1623 | - $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 1623 | + $classes[] = sanitize_html_class($args['display_lg']); |
|
| 1624 | 1624 | } |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | 1627 | |
| 1628 | 1628 | // bgtus - background transparent until scroll |
| 1629 | - if ( ! empty( $args['bgtus'] ) ) { |
|
| 1630 | - $classes[] = sanitize_html_class( "bg-transparent-until-scroll" ); |
|
| 1629 | + if (!empty($args['bgtus'])) { |
|
| 1630 | + $classes[] = sanitize_html_class("bg-transparent-until-scroll"); |
|
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | |
| 1634 | 1634 | // build classes from build keys |
| 1635 | 1635 | $build_keys = sd_get_class_build_keys(); |
| 1636 | - if ( ! empty( $build_keys ) ) { |
|
| 1637 | - foreach ( $build_keys as $key ) { |
|
| 1638 | - if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 1636 | + if (!empty($build_keys)) { |
|
| 1637 | + foreach ($build_keys as $key) { |
|
| 1638 | + if ($key == 'font_size' && !empty($args[$key]) && $args[$key] == 'custom') { |
|
| 1639 | 1639 | continue; |
| 1640 | 1640 | } |
| 1641 | - if ( ! empty( $args[ $key ] ) ) { |
|
| 1642 | - $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 1641 | + if (!empty($args[$key])) { |
|
| 1642 | + $classes[] = sd_sanitize_html_classes($args[$key]); |
|
| 1643 | 1643 | } |
| 1644 | 1644 | } |
| 1645 | 1645 | } |
| 1646 | 1646 | |
| 1647 | 1647 | |
| 1648 | - return implode( " ", $classes ); |
|
| 1648 | + return implode(" ", $classes); |
|
| 1649 | 1649 | } |
| 1650 | 1650 | |
| 1651 | 1651 | /** |
@@ -1655,19 +1655,19 @@ discard block |
||
| 1655 | 1655 | * |
| 1656 | 1656 | * @return array |
| 1657 | 1657 | */ |
| 1658 | -function sd_build_aui_styles( $args ) { |
|
| 1658 | +function sd_build_aui_styles($args) { |
|
| 1659 | 1659 | |
| 1660 | 1660 | $styles = array(); |
| 1661 | 1661 | |
| 1662 | 1662 | // background color |
| 1663 | - if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 1664 | - if ( $args['bg'] == 'custom-color' ) { |
|
| 1663 | + if (!empty($args['bg']) && $args['bg'] !== '') { |
|
| 1664 | + if ($args['bg'] == 'custom-color') { |
|
| 1665 | 1665 | $styles['background-color'] = $args['bg_color']; |
| 1666 | - } else if ( $args['bg'] == 'custom-gradient' ) { |
|
| 1666 | + } else if ($args['bg'] == 'custom-gradient') { |
|
| 1667 | 1667 | $styles['background-image'] = $args['bg_gradient']; |
| 1668 | 1668 | |
| 1669 | 1669 | // use background on text. |
| 1670 | - if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 1670 | + if (!empty($args['bg_on_text']) && $args['bg_on_text']) { |
|
| 1671 | 1671 | $styles['background-clip'] = "text"; |
| 1672 | 1672 | $styles['-webkit-background-clip'] = "text"; |
| 1673 | 1673 | $styles['text-fill-color'] = "transparent"; |
@@ -1676,53 +1676,53 @@ discard block |
||
| 1676 | 1676 | } |
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | - if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 1679 | + if (!empty($args['bg_image']) && $args['bg_image'] !== '') { |
|
| 1680 | 1680 | $hasImage = true; |
| 1681 | - if ( $styles['background-color'] !== undefined && $args['bg'] == 'custom-color' ) { |
|
| 1681 | + if ($styles['background-color'] !== undefined && $args['bg'] == 'custom-color') { |
|
| 1682 | 1682 | $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
| 1683 | 1683 | $styles['background-blend-mode'] = "overlay"; |
| 1684 | - } else if ( $styles['background-image'] !== undefined && $args['bg'] == 'custom-gradient' ) { |
|
| 1684 | + } else if ($styles['background-image'] !== undefined && $args['bg'] == 'custom-gradient') { |
|
| 1685 | 1685 | $styles['background-image'] .= ",url(" . $args['bg_image'] . ")"; |
| 1686 | - } else if ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 1686 | + } else if (!empty($args['bg']) && $args['bg'] != '' && $args['bg'] != 'transparent') { |
|
| 1687 | 1687 | // do nothing as we alreay have a preset |
| 1688 | 1688 | $hasImage = false; |
| 1689 | 1689 | } else { |
| 1690 | 1690 | $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
| 1691 | 1691 | } |
| 1692 | 1692 | |
| 1693 | - if ( $hasImage ) { |
|
| 1693 | + if ($hasImage) { |
|
| 1694 | 1694 | $styles['background-size'] = "cover"; |
| 1695 | 1695 | |
| 1696 | - if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 1696 | + if (!empty($args['bg_image_fixed']) && $args['bg_image_fixed']) { |
|
| 1697 | 1697 | $styles['background-attachment'] = "fixed"; |
| 1698 | 1698 | } |
| 1699 | 1699 | } |
| 1700 | 1700 | |
| 1701 | - if ( $hasImage && ! empty( $args['bg_image_xy'] ) && $args['bg_image_xy'] . x . length ) { |
|
| 1702 | - $styles['background-position'] = ( $args['bg_image_xy'] . x * 100 ) . "% " . ( $args['bg_image_xy'] . y * 100 ) . "%"; |
|
| 1701 | + if ($hasImage && !empty($args['bg_image_xy']) && $args['bg_image_xy'] . x . length) { |
|
| 1702 | + $styles['background-position'] = ($args['bg_image_xy'] . x * 100) . "% " . ($args['bg_image_xy'] . y * 100) . "%"; |
|
| 1703 | 1703 | } |
| 1704 | 1704 | } |
| 1705 | 1705 | |
| 1706 | 1706 | // sticky offset top |
| 1707 | - if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 1708 | - $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 1707 | + if (!empty($args['sticky_offset_top']) && $args['sticky_offset_top'] !== '') { |
|
| 1708 | + $styles['top'] = absint($args['sticky_offset_top']); |
|
| 1709 | 1709 | } |
| 1710 | 1710 | |
| 1711 | 1711 | // sticky offset bottom |
| 1712 | - if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 1713 | - $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 1712 | + if (!empty($args['sticky_offset_bottom']) && $args['sticky_offset_bottom'] !== '') { |
|
| 1713 | + $styles['bottom'] = absint($args['sticky_offset_bottom']); |
|
| 1714 | 1714 | } |
| 1715 | 1715 | |
| 1716 | 1716 | // font size |
| 1717 | - if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 1717 | + if (!empty($args['font_size_custom']) && $args['font_size_custom'] !== '') { |
|
| 1718 | 1718 | $styles['font-size'] = (float) $args['font_size_custom'] . "rem"; |
| 1719 | 1719 | |
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | $style_string = ''; |
| 1723 | - if ( ! empty( $styles ) ) { |
|
| 1724 | - foreach ( $styles as $key => $val ) { |
|
| 1725 | - $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 1723 | + if (!empty($styles)) { |
|
| 1724 | + foreach ($styles as $key => $val) { |
|
| 1725 | + $style_string .= esc_attr($key) . ':' . esc_attr($val) . ';'; |
|
| 1726 | 1726 | } |
| 1727 | 1727 | } |
| 1728 | 1728 | |
@@ -1738,16 +1738,16 @@ discard block |
||
| 1738 | 1738 | * |
| 1739 | 1739 | * @return string |
| 1740 | 1740 | */ |
| 1741 | -function sd_sanitize_html_classes( $classes, $sep = " " ) { |
|
| 1741 | +function sd_sanitize_html_classes($classes, $sep = " ") { |
|
| 1742 | 1742 | $return = ""; |
| 1743 | 1743 | |
| 1744 | - if ( ! is_array( $classes ) ) { |
|
| 1745 | - $classes = explode( $sep, $classes ); |
|
| 1744 | + if (!is_array($classes)) { |
|
| 1745 | + $classes = explode($sep, $classes); |
|
| 1746 | 1746 | } |
| 1747 | 1747 | |
| 1748 | - if ( ! empty( $classes ) ) { |
|
| 1749 | - foreach ( $classes as $class ) { |
|
| 1750 | - $return .= sanitize_html_class( $class ) . " "; |
|
| 1748 | + if (!empty($classes)) { |
|
| 1749 | + foreach ($classes as $class) { |
|
| 1750 | + $return .= sanitize_html_class($class) . " "; |
|
| 1751 | 1751 | } |
| 1752 | 1752 | } |
| 1753 | 1753 | |
@@ -1777,5 +1777,5 @@ discard block |
||
| 1777 | 1777 | 'css_class', |
| 1778 | 1778 | ); |
| 1779 | 1779 | |
| 1780 | - return apply_filters( "sd_class_build_keys", $keys ); |
|
| 1780 | + return apply_filters("sd_class_build_keys", $keys); |
|
| 1781 | 1781 | } |