@@ -128,30 +128,30 @@ |
||
| 128 | 128 | // Get the basics from the parent class. |
| 129 | 129 | parent::to_json(); |
| 130 | 130 | // Default. |
| 131 | - $this->json['default'] = $this->setting->default; |
|
| 131 | + $this->json[ 'default' ] = $this->setting->default; |
|
| 132 | 132 | if ( isset( $this->default ) ) { |
| 133 | - $this->json['default'] = $this->default; |
|
| 133 | + $this->json[ 'default' ] = $this->default; |
|
| 134 | 134 | } |
| 135 | 135 | // Required. |
| 136 | - $this->json['required'] = $this->required; |
|
| 136 | + $this->json[ 'required' ] = $this->required; |
|
| 137 | 137 | // Output. |
| 138 | - $this->json['output'] = $this->output; |
|
| 138 | + $this->json[ 'output' ] = $this->output; |
|
| 139 | 139 | // Value. |
| 140 | - $this->json['value'] = $this->value(); |
|
| 140 | + $this->json[ 'value' ] = $this->value(); |
|
| 141 | 141 | // Choices. |
| 142 | - $this->json['choices'] = $this->choices; |
|
| 142 | + $this->json[ 'choices' ] = $this->choices; |
|
| 143 | 143 | // The link. |
| 144 | - $this->json['link'] = $this->get_link(); |
|
| 144 | + $this->json[ 'link' ] = $this->get_link(); |
|
| 145 | 145 | // The ID. |
| 146 | - $this->json['id'] = $this->id; |
|
| 146 | + $this->json[ 'id' ] = $this->id; |
|
| 147 | 147 | // Translation strings. |
| 148 | - $this->json['l10n'] = $this->l10n(); |
|
| 148 | + $this->json[ 'l10n' ] = $this->l10n(); |
|
| 149 | 149 | // The ajaxurl in case we need it. |
| 150 | - $this->json['ajaxurl'] = admin_url( 'admin-ajax.php' ); |
|
| 150 | + $this->json[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); |
|
| 151 | 151 | // Input attributes. |
| 152 | - $this->json['inputAttrs'] = ''; |
|
| 152 | + $this->json[ 'inputAttrs' ] = ''; |
|
| 153 | 153 | foreach ( $this->input_attrs as $attr => $value ) { |
| 154 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 154 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | public function to_json() { |
| 44 | 44 | parent::to_json(); |
| 45 | 45 | |
| 46 | - $this->json['alpha'] = (bool) $this->alpha; |
|
| 46 | + $this->json[ 'alpha' ] = (bool) $this->alpha; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | public function to_json() { |
| 38 | 38 | parent::to_json(); |
| 39 | 39 | |
| 40 | - $this->json['choices'] = wp_parse_args( $this->json['choices'], array( |
|
| 40 | + $this->json[ 'choices' ] = wp_parse_args( $this->json[ 'choices' ], array( |
|
| 41 | 41 | 'min' => '0', |
| 42 | 42 | 'max' => '100', |
| 43 | 43 | 'step' => '1', |
@@ -76,28 +76,28 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | if ( empty( $this->button_label ) ) { |
| 78 | 78 | /* translators: %s represents the label of the row. */ |
| 79 | - $this->button_label = sprintf( esc_attr__( 'Add new %s', 'kirki' ), $this->row_label['value'] ); |
|
| 79 | + $this->button_label = sprintf( esc_attr__( 'Add new %s', 'kirki' ), $this->row_label[ 'value' ] ); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( empty( $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
| 83 | - $args['fields'] = array(); |
|
| 82 | + if ( empty( $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
| 83 | + $args[ 'fields' ] = array(); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // An array to store keys of fields that need to be filtered. |
| 87 | 87 | $media_fields_to_filter = array(); |
| 88 | 88 | |
| 89 | - foreach ( $args['fields'] as $key => $value ) { |
|
| 90 | - if ( ! isset( $value['default'] ) ) { |
|
| 91 | - $args['fields'][ $key ]['default'] = ''; |
|
| 89 | + foreach ( $args[ 'fields' ] as $key => $value ) { |
|
| 90 | + if ( ! isset( $value[ 'default' ] ) ) { |
|
| 91 | + $args[ 'fields' ][ $key ][ 'default' ] = ''; |
|
| 92 | 92 | } |
| 93 | - if ( ! isset( $value['label'] ) ) { |
|
| 94 | - $args['fields'][ $key ]['label'] = ''; |
|
| 93 | + if ( ! isset( $value[ 'label' ] ) ) { |
|
| 94 | + $args[ 'fields' ][ $key ][ 'label' ] = ''; |
|
| 95 | 95 | } |
| 96 | - $args['fields'][ $key ]['id'] = $key; |
|
| 96 | + $args[ 'fields' ][ $key ][ 'id' ] = $key; |
|
| 97 | 97 | |
| 98 | 98 | // We check if the filed is an uploaded media ( image , file, video, etc.. ). |
| 99 | - if ( isset( $value['type'] ) ) { |
|
| 100 | - switch ( $value['type'] ) { |
|
| 99 | + if ( isset( $value[ 'type' ] ) ) { |
|
| 100 | + switch ( $value[ 'type' ] ) { |
|
| 101 | 101 | case 'image': |
| 102 | 102 | case 'cropped_image': |
| 103 | 103 | case 'upload': |
@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | ) |
| 118 | 118 | ); |
| 119 | 119 | // Hackily add in the data link parameter. |
| 120 | - $dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args['fields'][ $key ]['id'] ) . '"' . $this->get_link(), $dropdown ); |
|
| 121 | - $args['fields'][ $key ]['dropdown'] = $dropdown; |
|
| 120 | + $dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args[ 'fields' ][ $key ][ 'id' ] ) . '"' . $this->get_link(), $dropdown ); |
|
| 121 | + $args[ 'fields' ][ $key ][ 'dropdown' ] = $dropdown; |
|
| 122 | 122 | break; |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | } // End foreach(). |
| 126 | 126 | |
| 127 | - $this->fields = $args['fields']; |
|
| 127 | + $this->fields = $args[ 'fields' ]; |
|
| 128 | 128 | |
| 129 | 129 | // Now we are going to filter the fields. |
| 130 | 130 | // First we create a copy of the value that would be used otherwise. |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | $fields = $this->fields; |
| 186 | 186 | |
| 187 | - $this->json['fields'] = $fields; |
|
| 188 | - $this->json['row_label'] = $this->row_label; |
|
| 187 | + $this->json[ 'fields' ] = $fields; |
|
| 188 | + $this->json[ 'row_label' ] = $this->row_label; |
|
| 189 | 189 | |
| 190 | 190 | // If filtered_value has been set and is not empty we use it instead of the actual value. |
| 191 | 191 | if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) { |
| 192 | - $this->json['value'] = $this->filtered_value; |
|
| 192 | + $this->json[ 'value' ] = $this->filtered_value; |
|
| 193 | 193 | } |
| 194 | - $this->json['value'] = apply_filters( "kirki/controls/repeater/value/{$this->id}", $this->json['value'] ); |
|
| 194 | + $this->json[ 'value' ] = apply_filters( "kirki/controls/repeater/value/{$this->id}", $this->json[ 'value' ] ); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | <ul class="repeater-fields"></ul> |
| 216 | 216 | |
| 217 | - <?php if ( isset( $this->choices['limit'] ) ) : ?> |
|
| 217 | + <?php if ( isset( $this->choices[ 'limit' ] ) ) : ?> |
|
| 218 | 218 | <?php // @codingStandardsIgnoreLine ?> |
| 219 | 219 | <?php /* translators: %s represents the number of rows we're limiting the repeater to allow. */ ?> |
| 220 | - <p class="limit"><?php printf( esc_attr__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices['limit'] ) ); ?></p> |
|
| 220 | + <p class="limit"><?php printf( esc_attr__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices[ 'limit' ] ) ); ?></p> |
|
| 221 | 221 | <?php endif; ?> |
| 222 | 222 | <button class="button-secondary repeater-add"><?php echo esc_html( $this->button_label ); ?></button> |
| 223 | 223 | |
@@ -447,24 +447,24 @@ discard block |
||
| 447 | 447 | protected function row_label( $args ) { |
| 448 | 448 | |
| 449 | 449 | // Validating args for row labels. |
| 450 | - if ( isset( $args['row_label'] ) && is_array( $args['row_label'] ) && ! empty( $args['row_label'] ) ) { |
|
| 450 | + if ( isset( $args[ 'row_label' ] ) && is_array( $args[ 'row_label' ] ) && ! empty( $args[ 'row_label' ] ) ) { |
|
| 451 | 451 | |
| 452 | 452 | // Validating row label type. |
| 453 | - if ( isset( $args['row_label']['type'] ) && ( 'text' === $args['row_label']['type'] || 'field' === $args['row_label']['type'] ) ) { |
|
| 454 | - $this->row_label['type'] = $args['row_label']['type']; |
|
| 453 | + if ( isset( $args[ 'row_label' ][ 'type' ] ) && ( 'text' === $args[ 'row_label' ][ 'type' ] || 'field' === $args[ 'row_label' ][ 'type' ] ) ) { |
|
| 454 | + $this->row_label[ 'type' ] = $args[ 'row_label' ][ 'type' ]; |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | // Validating row label type. |
| 458 | - if ( isset( $args['row_label']['value'] ) && ! empty( $args['row_label']['value'] ) ) { |
|
| 459 | - $this->row_label['value'] = esc_attr( $args['row_label']['value'] ); |
|
| 458 | + if ( isset( $args[ 'row_label' ][ 'value' ] ) && ! empty( $args[ 'row_label' ][ 'value' ] ) ) { |
|
| 459 | + $this->row_label[ 'value' ] = esc_attr( $args[ 'row_label' ][ 'value' ] ); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | // Validating row label field. |
| 463 | - if ( isset( $args['row_label']['field'] ) && ! empty( $args['row_label']['field'] ) && isset( $args['fields'][ esc_attr( $args['row_label']['field'] ) ] ) ) { |
|
| 464 | - $this->row_label['field'] = esc_attr( $args['row_label']['field'] ); |
|
| 463 | + if ( isset( $args[ 'row_label' ][ 'field' ] ) && ! empty( $args[ 'row_label' ][ 'field' ] ) && isset( $args[ 'fields' ][ esc_attr( $args[ 'row_label' ][ 'field' ] ) ] ) ) { |
|
| 464 | + $this->row_label[ 'field' ] = esc_attr( $args[ 'row_label' ][ 'field' ] ); |
|
| 465 | 465 | } else { |
| 466 | 466 | // If from field is not set correctly, making sure standard is set as the type. |
| 467 | - $this->row_label['type'] = 'text'; |
|
| 467 | + $this->row_label[ 'type' ] = 'text'; |
|
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | } |
@@ -38,11 +38,11 @@ |
||
| 38 | 38 | parent::to_json(); |
| 39 | 39 | |
| 40 | 40 | // If no palette has been defined, use Material Design Palette. |
| 41 | - if ( ! isset( $this->json['choices']['colors'] ) || empty( $this->json['choices']['colors'] ) ) { |
|
| 42 | - $this->json['choices']['colors'] = Kirki_Helper::get_material_design_colors( 'primary' ); |
|
| 41 | + if ( ! isset( $this->json[ 'choices' ][ 'colors' ] ) || empty( $this->json[ 'choices' ][ 'colors' ] ) ) { |
|
| 42 | + $this->json[ 'choices' ][ 'colors' ] = Kirki_Helper::get_material_design_colors( 'primary' ); |
|
| 43 | 43 | } |
| 44 | - if ( ! isset( $this->json['choices']['size'] ) || empty( $this->json['choices']['size'] ) ) { |
|
| 45 | - $this->json['choices']['size'] = 20; |
|
| 44 | + if ( ! isset( $this->json[ 'choices' ][ 'size' ] ) || empty( $this->json[ 'choices' ][ 'size' ] ) ) { |
|
| 45 | + $this->json[ 'choices' ][ 'size' ] = 20; |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | if ( Kirki_Util::get_wp_version() >= 4.9 ) { |
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | - $custom_fonts_array = ( isset( $this->choices['fonts'] ) && ( isset( $this->choices['fonts']['google'] ) || isset( $this->choices['fonts']['standard'] ) ) && ( ! empty( $this->choices['fonts']['google'] ) || ! empty( $this->choices['fonts']['standard'] ) ) ); |
|
| 42 | + $custom_fonts_array = ( isset( $this->choices[ 'fonts' ] ) && ( isset( $this->choices[ 'fonts' ][ 'google' ] ) || isset( $this->choices[ 'fonts' ][ 'standard' ] ) ) && ( ! empty( $this->choices[ 'fonts' ][ 'google' ] ) || ! empty( $this->choices[ 'fonts' ][ 'standard' ] ) ) ); |
|
| 43 | 43 | $localize_script_var = ( $custom_fonts_array ) ? 'kirkiFonts' . $this->id : 'kirkiAllFonts'; |
| 44 | 44 | wp_localize_script( |
| 45 | 45 | 'kirki-script', $localize_script_var, array( |
@@ -57,25 +57,25 @@ discard block |
||
| 57 | 57 | public function to_json() { |
| 58 | 58 | parent::to_json(); |
| 59 | 59 | |
| 60 | - if ( is_array( $this->json['value'] ) ) { |
|
| 61 | - foreach ( array_keys( $this->json['value'] ) as $key ) { |
|
| 62 | - if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json['default'][ $key ] ) ) { |
|
| 63 | - unset( $this->json['value'][ $key ] ); |
|
| 60 | + if ( is_array( $this->json[ 'value' ] ) ) { |
|
| 61 | + foreach ( array_keys( $this->json[ 'value' ] ) as $key ) { |
|
| 62 | + if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
| 63 | + unset( $this->json[ 'value' ][ $key ] ); |
|
| 64 | 64 | } |
| 65 | 65 | // Fix for https://wordpress.org/support/topic/white-font-after-updateing-to-3-0-16. |
| 66 | - if ( ! isset( $this->json['default'][ $key ] ) ) { |
|
| 67 | - unset( $this->json['value'][ $key ] ); |
|
| 66 | + if ( ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
| 67 | + unset( $this->json[ 'value' ][ $key ] ); |
|
| 68 | 68 | } |
| 69 | 69 | // Fix for https://github.com/aristath/kirki/issues/1405. |
| 70 | - if ( isset( $this->json['default'][ $key ] ) && false === $this->json['default'][ $key ] ) { |
|
| 71 | - unset( $this->json['value'][ $key ] ); |
|
| 70 | + if ( isset( $this->json[ 'default' ][ $key ] ) && false === $this->json[ 'default' ][ $key ] ) { |
|
| 71 | + unset( $this->json[ 'value' ][ $key ] ); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $this->json['show_variants'] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
| 77 | - $this->json['show_subsets'] = ( true === Kirki_Fonts_Google::$force_load_all_subsets ) ? false : true; |
|
| 78 | - $this->json['languages'] = Kirki_Fonts::get_google_font_subsets(); |
|
| 76 | + $this->json[ 'show_variants' ] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
| 77 | + $this->json[ 'show_subsets' ] = ( true === Kirki_Fonts_Google::$force_load_all_subsets ) ? false : true; |
|
| 78 | + $this->json[ 'languages' ] = Kirki_Fonts::get_google_font_subsets(); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -282,12 +282,12 @@ discard block |
||
| 282 | 282 | $final_variants = array(); |
| 283 | 283 | foreach ( $variants as $variant ) { |
| 284 | 284 | if ( is_string( $variant ) ) { |
| 285 | - $final_variants[] = array( |
|
| 285 | + $final_variants[ ] = array( |
|
| 286 | 286 | 'id' => $variant, |
| 287 | 287 | 'label' => isset( $all_variants[ $variant ] ) ? $all_variants[ $variant ] : $variant, |
| 288 | 288 | ); |
| 289 | - } elseif ( is_array( $variant ) && isset( $variant['id'] ) && isset( $variant['label'] ) ) { |
|
| 290 | - $final_variants[] = $variant; |
|
| 289 | + } elseif ( is_array( $variant ) && isset( $variant[ 'id' ] ) && isset( $variant[ 'label' ] ) ) { |
|
| 290 | + $final_variants[ ] = $variant; |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | return $final_variants; |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | $standard_fonts = Kirki_Fonts::get_standard_fonts(); |
| 306 | 306 | |
| 307 | 307 | $std_user_keys = array(); |
| 308 | - if ( isset( $this->choices['fonts'] ) && isset( $this->choices['fonts']['standard'] ) ) { |
|
| 309 | - $std_user_keys = $this->choices['fonts']['standard']; |
|
| 308 | + if ( isset( $this->choices[ 'fonts' ] ) && isset( $this->choices[ 'fonts' ][ 'standard' ] ) ) { |
|
| 309 | + $std_user_keys = $this->choices[ 'fonts' ][ 'standard' ]; |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $standard_fonts_final = array(); |
@@ -319,15 +319,15 @@ discard block |
||
| 319 | 319 | ) |
| 320 | 320 | ); |
| 321 | 321 | foreach ( $standard_fonts as $key => $font ) { |
| 322 | - if ( ( ! empty( $std_user_keys ) && ! in_array( $key, $std_user_keys, true ) ) || ! isset( $font['stack'] ) || ! isset( $font['label'] ) ) { |
|
| 322 | + if ( ( ! empty( $std_user_keys ) && ! in_array( $key, $std_user_keys, true ) ) || ! isset( $font[ 'stack' ] ) || ! isset( $font[ 'label' ] ) ) { |
|
| 323 | 323 | continue; |
| 324 | 324 | } |
| 325 | - $standard_fonts_final[] = array( |
|
| 326 | - 'family' => $font['stack'], |
|
| 327 | - 'label' => $font['label'], |
|
| 325 | + $standard_fonts_final[ ] = array( |
|
| 326 | + 'family' => $font[ 'stack' ], |
|
| 327 | + 'label' => $font[ 'label' ], |
|
| 328 | 328 | 'subsets' => array(), |
| 329 | 329 | 'is_standard' => true, |
| 330 | - 'variants' => ( isset( $font['variants'] ) ) ? $this->format_variants_array( $font['variants'] ) : $default_variants, |
|
| 330 | + 'variants' => ( isset( $font[ 'variants' ] ) ) ? $this->format_variants_array( $font[ 'variants' ] ) : $default_variants, |
|
| 331 | 331 | ); |
| 332 | 332 | } |
| 333 | 333 | return $standard_fonts_final; |
@@ -347,8 +347,8 @@ discard block |
||
| 347 | 347 | $all_subsets = Kirki_Fonts::get_google_font_subsets(); |
| 348 | 348 | |
| 349 | 349 | $gf_user_keys = array(); |
| 350 | - if ( isset( $this->choices['fonts'] ) && isset( $this->choices['fonts']['google'] ) ) { |
|
| 351 | - $gf_user_keys = $this->choices['fonts']['google']; |
|
| 350 | + if ( isset( $this->choices[ 'fonts' ] ) && isset( $this->choices[ 'fonts' ][ 'google' ] ) ) { |
|
| 351 | + $gf_user_keys = $this->choices[ 'fonts' ][ 'google' ]; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | $google_fonts_final = array(); |
@@ -357,15 +357,15 @@ discard block |
||
| 357 | 357 | continue; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - $label = ( isset( $args['label'] ) ) ? $args['label'] : $family; |
|
| 361 | - $variants = ( isset( $args['variants'] ) ) ? $args['variants'] : array( 'regular', '700' ); |
|
| 362 | - $subsets = ( isset( $args['subsets'] ) ) ? $args['subsets'] : array(); |
|
| 360 | + $label = ( isset( $args[ 'label' ] ) ) ? $args[ 'label' ] : $family; |
|
| 361 | + $variants = ( isset( $args[ 'variants' ] ) ) ? $args[ 'variants' ] : array( 'regular', '700' ); |
|
| 362 | + $subsets = ( isset( $args[ 'subsets' ] ) ) ? $args[ 'subsets' ] : array(); |
|
| 363 | 363 | |
| 364 | 364 | $available_variants = array(); |
| 365 | 365 | if ( is_array( $variants ) ) { |
| 366 | 366 | foreach ( $variants as $variant ) { |
| 367 | 367 | if ( array_key_exists( $variant, $all_variants ) ) { |
| 368 | - $available_variants[] = array( |
|
| 368 | + $available_variants[ ] = array( |
|
| 369 | 369 | 'id' => $variant, |
| 370 | 370 | 'label' => $all_variants[ $variant ], |
| 371 | 371 | ); |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | if ( is_array( $subsets ) ) { |
| 378 | 378 | foreach ( $subsets as $subset ) { |
| 379 | 379 | if ( array_key_exists( $subset, $all_subsets ) ) { |
| 380 | - $available_subsets[] = array( |
|
| 380 | + $available_subsets[ ] = array( |
|
| 381 | 381 | 'id' => $subset, |
| 382 | 382 | 'label' => $all_subsets[ $subset ], |
| 383 | 383 | ); |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - $google_fonts_final[] = array( |
|
| 388 | + $google_fonts_final[ ] = array( |
|
| 389 | 389 | 'family' => $family, |
| 390 | 390 | 'label' => $label, |
| 391 | 391 | 'variants' => $available_variants, |
@@ -24,8 +24,8 @@ |
||
| 24 | 24 | if ( ! is_array( $this->choices ) ) { |
| 25 | 25 | $this->choices = array(); |
| 26 | 26 | } |
| 27 | - $this->choices['element'] = 'input'; |
|
| 28 | - $this->choices['type'] = 'text'; |
|
| 27 | + $this->choices[ 'element' ] = 'input'; |
|
| 28 | + $this->choices[ 'type' ] = 'text'; |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $config = Kirki_Config::get_instance( $config_id, $args ); |
| 146 | 146 | $config_args = $config->get_config(); |
| 147 | - self::$config[ $config_args['id'] ] = $config_args; |
|
| 147 | + self::$config[ $config_args[ 'id' ] ] = $config_args; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public static function add_panel( $id = '', $args = array() ) { |
| 159 | 159 | |
| 160 | - $args['id'] = esc_attr( $id ); |
|
| 161 | - $args['description'] = ( isset( $args['description'] ) ) ? esc_textarea( $args['description'] ) : ''; |
|
| 162 | - $args['priority'] = ( isset( $args['priority'] ) ) ? esc_attr( $args['priority'] ) : 10; |
|
| 163 | - $args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default'; |
|
| 164 | - $args['type'] = 'kirki-' . $args['type']; |
|
| 160 | + $args[ 'id' ] = esc_attr( $id ); |
|
| 161 | + $args[ 'description' ] = ( isset( $args[ 'description' ] ) ) ? esc_textarea( $args[ 'description' ] ) : ''; |
|
| 162 | + $args[ 'priority' ] = ( isset( $args[ 'priority' ] ) ) ? esc_attr( $args[ 'priority' ] ) : 10; |
|
| 163 | + $args[ 'type' ] = ( isset( $args[ 'type' ] ) ) ? $args[ 'type' ] : 'default'; |
|
| 164 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
| 165 | 165 | |
| 166 | - self::$panels[ $args['id'] ] = $args; |
|
| 166 | + self::$panels[ $args[ 'id' ] ] = $args; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public static function remove_panel( $id = '' ) { |
| 178 | 178 | if ( ! in_array( $id, self::$panels_to_remove, true ) ) { |
| 179 | - self::$panels_to_remove[] = $id; |
|
| 179 | + self::$panels_to_remove[ ] = $id; |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public static function add_section( $id, $args ) { |
| 192 | 192 | |
| 193 | - $args['id'] = esc_attr( $id ); |
|
| 194 | - $args['panel'] = ( isset( $args['panel'] ) ) ? esc_attr( $args['panel'] ) : ''; |
|
| 195 | - $args['description'] = ( isset( $args['description'] ) ) ? esc_textarea( $args['description'] ) : ''; |
|
| 196 | - $args['priority'] = ( isset( $args['priority'] ) ) ? esc_attr( $args['priority'] ) : 10; |
|
| 197 | - $args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default'; |
|
| 198 | - $args['type'] = 'kirki-' . $args['type']; |
|
| 193 | + $args[ 'id' ] = esc_attr( $id ); |
|
| 194 | + $args[ 'panel' ] = ( isset( $args[ 'panel' ] ) ) ? esc_attr( $args[ 'panel' ] ) : ''; |
|
| 195 | + $args[ 'description' ] = ( isset( $args[ 'description' ] ) ) ? esc_textarea( $args[ 'description' ] ) : ''; |
|
| 196 | + $args[ 'priority' ] = ( isset( $args[ 'priority' ] ) ) ? esc_attr( $args[ 'priority' ] ) : 10; |
|
| 197 | + $args[ 'type' ] = ( isset( $args[ 'type' ] ) ) ? $args[ 'type' ] : 'default'; |
|
| 198 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
| 199 | 199 | |
| 200 | - self::$sections[ $args['id'] ] = $args; |
|
| 200 | + self::$sections[ $args[ 'id' ] ] = $args; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public static function remove_section( $id = '' ) { |
| 212 | 212 | if ( ! in_array( $id, self::$sections_to_remove, true ) ) { |
| 213 | - self::$sections_to_remove[] = $id; |
|
| 213 | + self::$sections_to_remove[ ] = $id; |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Early exit if 'type' is not defined. |
| 232 | - if ( ! isset( $args['type'] ) ) { |
|
| 232 | + if ( ! isset( $args[ 'type' ] ) ) { |
|
| 233 | 233 | return; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - $str = str_replace( array( '-', '_' ), ' ', $args['type'] ); |
|
| 236 | + $str = str_replace( array( '-', '_' ), ' ', $args[ 'type' ] ); |
|
| 237 | 237 | $classname = 'Kirki_Field_' . str_replace( ' ', '_', ucwords( $str ) ); |
| 238 | 238 | if ( class_exists( $classname ) ) { |
| 239 | 239 | new $classname( $config_id, $args ); |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | public static function remove_control( $id ) { |
| 263 | 263 | if ( ! in_array( $id, self::$controls_to_remove, true ) ) { |
| 264 | - self::$controls_to_remove[] = $id; |
|
| 264 | + self::$controls_to_remove[ ] = $id; |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $config = apply_filters( 'kirki/config', array() ); |
| 121 | 121 | $priority = 999; |
| 122 | - if ( isset( $config['styles_priority'] ) ) { |
|
| 123 | - $priority = absint( $config['styles_priority'] ); |
|
| 122 | + if ( isset( $config[ 'styles_priority' ] ) ) { |
|
| 123 | + $priority = absint( $config[ 'styles_priority' ] ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Allow completely disabling Kirki CSS output. |
| 127 | - if ( ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) || ( isset( $config['disable_output'] ) && true === $config['disable_output'] ) ) { |
|
| 127 | + if ( ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) || ( isset( $config[ 'disable_output' ] ) && true === $config[ 'disable_output' ] ) ) { |
|
| 128 | 128 | return; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | // If we are in the customizer, load CSS using inline-styles. |
| 157 | 157 | // If we are in the frontend AND self::$ajax is true, then load dynamic CSS using AJAX. |
| 158 | - if ( ( true === self::$ajax ) || ( isset( $config['inline_css'] ) && false === $config['inline_css'] ) ) { |
|
| 158 | + if ( ( true === self::$ajax ) || ( isset( $config[ 'inline_css' ] ) && false === $config[ 'inline_css' ] ) ) { |
|
| 159 | 159 | add_action( 'wp_enqueue_scripts', array( $this, 'frontend_styles' ), $priority ); |
| 160 | 160 | add_action( 'wp_ajax_kirki_dynamic_css', array( $this, 'ajax_dynamic_css' ) ); |
| 161 | 161 | add_action( 'wp_ajax_nopriv_kirki_dynamic_css', array( $this, 'ajax_dynamic_css' ) ); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $configs = Kirki::$config; |
| 187 | 187 | if ( ! $this->processed ) { |
| 188 | 188 | foreach ( $configs as $config_id => $args ) { |
| 189 | - if ( isset( $args['disable_output'] ) && true === $args['disable_output'] ) { |
|
| 189 | + if ( isset( $args[ 'disable_output' ] ) && true === $args[ 'disable_output' ] ) { |
|
| 190 | 190 | continue; |
| 191 | 191 | } |
| 192 | 192 | $styles = self::loop_controls( $config_id ); |
@@ -243,19 +243,19 @@ discard block |
||
| 243 | 243 | foreach ( $fields as $field ) { |
| 244 | 244 | |
| 245 | 245 | // Only process fields that belong to $config_id. |
| 246 | - if ( $config_id !== $field['kirki_config'] ) { |
|
| 246 | + if ( $config_id !== $field[ 'kirki_config' ] ) { |
|
| 247 | 247 | continue; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | if ( true === apply_filters( "kirki/{$config_id}/css/skip_hidden", true ) ) { |
| 251 | 251 | // Only continue if field dependencies are met. |
| 252 | - if ( ! empty( $field['required'] ) ) { |
|
| 252 | + if ( ! empty( $field[ 'required' ] ) ) { |
|
| 253 | 253 | $valid = true; |
| 254 | 254 | |
| 255 | - foreach ( $field['required'] as $requirement ) { |
|
| 256 | - if ( isset( $requirement['setting'] ) && isset( $requirement['value'] ) && isset( $requirement['operator'] ) ) { |
|
| 257 | - $controller_value = Kirki_Values::get_value( $config_id, $requirement['setting'] ); |
|
| 258 | - if ( ! Kirki_Helper::compare_values( $controller_value, $requirement['value'], $requirement['operator'] ) ) { |
|
| 255 | + foreach ( $field[ 'required' ] as $requirement ) { |
|
| 256 | + if ( isset( $requirement[ 'setting' ] ) && isset( $requirement[ 'value' ] ) && isset( $requirement[ 'operator' ] ) ) { |
|
| 257 | + $controller_value = Kirki_Values::get_value( $config_id, $requirement[ 'setting' ] ); |
|
| 258 | + if ( ! Kirki_Helper::compare_values( $controller_value, $requirement[ 'value' ], $requirement[ 'operator' ] ) ) { |
|
| 259 | 259 | $valid = false; |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // Only continue if $field['output'] is set. |
| 271 | - if ( isset( $field['output'] ) && ! empty( $field['output'] ) ) { |
|
| 271 | + if ( isset( $field[ 'output' ] ) && ! empty( $field[ 'output' ] ) ) { |
|
| 272 | 272 | $css = Kirki_Helper::array_replace_recursive( $css, Kirki_Modules_CSS_Generator::css( $field ) ); |
| 273 | 273 | |
| 274 | 274 | // Add the globals. |