@@ -36,10 +36,10 @@ |
||
| 36 | 36 | parent::to_json(); |
| 37 | 37 | foreach ( $this->input_attrs as $attr => $value ) { |
| 38 | 38 | if ( 'style' !== $attr ) { |
| 39 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 39 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 40 | 40 | continue; |
| 41 | 41 | } |
| 42 | - $this->json['labelStyle'] = 'style="' . esc_attr( $value ) . '" '; |
|
| 42 | + $this->json[ 'labelStyle' ] = 'style="' . esc_attr( $value ) . '" '; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | } |
@@ -36,8 +36,8 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | public function to_json() { |
| 38 | 38 | parent::to_json(); |
| 39 | - $this->json['choices'] = wp_parse_args( |
|
| 40 | - $this->json['choices'], array( |
|
| 39 | + $this->json[ 'choices' ] = wp_parse_args( |
|
| 40 | + $this->json[ 'choices' ], array( |
|
| 41 | 41 | 'min' => '0', |
| 42 | 42 | 'max' => '100', |
| 43 | 43 | 'step' => '1', |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | if ( ! is_array( $this->choices ) ) { |
| 24 | 24 | $this->choices = array(); |
| 25 | 25 | } |
| 26 | - $this->choices['element'] = 'input'; |
|
| 27 | - $this->choices['type'] = 'text'; |
|
| 26 | + $this->choices[ 'element' ] = 'input'; |
|
| 27 | + $this->choices[ 'type' ] = 'text'; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Get the subfield-type. |
| 100 | - if ( ! isset( $this->fields[ $subfield_id ]['type'] ) ) { |
|
| 100 | + if ( ! isset( $this->fields[ $subfield_id ][ 'type' ] ) ) { |
|
| 101 | 101 | continue; |
| 102 | 102 | } |
| 103 | - $subfield_type = $this->fields[ $subfield_id ]['type']; |
|
| 103 | + $subfield_type = $this->fields[ $subfield_id ][ 'type' ]; |
|
| 104 | 104 | |
| 105 | 105 | // Allow using a sanitize-callback on a per-field basis. |
| 106 | - if ( isset( $this->fields[ $subfield_id ]['sanitize_callback'] ) ) { |
|
| 107 | - $subfield_value = call_user_func( $this->fields[ $subfield_id ]['sanitize_callback'], $subfield_value ); |
|
| 106 | + if ( isset( $this->fields[ $subfield_id ][ 'sanitize_callback' ] ) ) { |
|
| 107 | + $subfield_value = call_user_func( $this->fields[ $subfield_id ][ 'sanitize_callback' ], $subfield_value ); |
|
| 108 | 108 | } else { |
| 109 | 109 | |
| 110 | 110 | switch ( $subfield_type ) { |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | $subfield_value = (bool) $subfield_value; |
| 140 | 140 | break; |
| 141 | 141 | case 'select': |
| 142 | - if ( isset( $this->fields[ $subfield_id ]['multiple'] ) ) { |
|
| 143 | - if ( true === $this->fields[ $subfield_id ]['multiple'] ) { |
|
| 142 | + if ( isset( $this->fields[ $subfield_id ][ 'multiple' ] ) ) { |
|
| 143 | + if ( true === $this->fields[ $subfield_id ][ 'multiple' ] ) { |
|
| 144 | 144 | $multiple = 2; |
| 145 | 145 | } |
| 146 | - $multiple = (int) $this->fields[ $subfield_id ]['multiple']; |
|
| 146 | + $multiple = (int) $this->fields[ $subfield_id ][ 'multiple' ]; |
|
| 147 | 147 | if ( 1 < $multiple ) { |
| 148 | 148 | $subfield_value = (array) $subfield_value; |
| 149 | 149 | foreach ( $subfield_value as $sub_subfield_key => $sub_subfield_value ) { |
@@ -61,10 +61,10 @@ |
||
| 61 | 61 | * @access protected |
| 62 | 62 | */ |
| 63 | 63 | protected function set_choices() { |
| 64 | - $this->choices['controls'] = array(); |
|
| 64 | + $this->choices[ 'controls' ] = array(); |
|
| 65 | 65 | if ( is_array( $this->default ) ) { |
| 66 | 66 | foreach ( $this->default as $key => $value ) { |
| 67 | - $this->choices['controls'][ $key ] = true; |
|
| 67 | + $this->choices[ 'controls' ][ $key ] = true; |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | return array(); |
| 51 | 51 | } |
| 52 | 52 | return array( |
| 53 | - 'background-color' => ( isset( $value['background-color'] ) ) ? sanitize_text_field( $value['background-color'] ) : '', |
|
| 54 | - 'background-image' => ( isset( $value['background-image'] ) ) ? esc_url_raw( $value['background-image'] ) : '', |
|
| 55 | - 'background-repeat' => ( isset( $value['background-repeat'] ) ) ? sanitize_text_field( $value['background-repeat'] ) : '', |
|
| 56 | - 'background-position' => ( isset( $value['background-position'] ) ) ? sanitize_text_field( $value['background-position'] ) : '', |
|
| 57 | - 'background-size' => ( isset( $value['background-size'] ) ) ? sanitize_text_field( $value['background-size'] ) : '', |
|
| 58 | - 'background-attachment' => ( isset( $value['background-attachment'] ) ) ? sanitize_text_field( $value['background-attachment'] ) : '', |
|
| 53 | + 'background-color' => ( isset( $value[ 'background-color' ] ) ) ? sanitize_text_field( $value[ 'background-color' ] ) : '', |
|
| 54 | + 'background-image' => ( isset( $value[ 'background-image' ] ) ) ? esc_url_raw( $value[ 'background-image' ] ) : '', |
|
| 55 | + 'background-repeat' => ( isset( $value[ 'background-repeat' ] ) ) ? sanitize_text_field( $value[ 'background-repeat' ] ) : '', |
|
| 56 | + 'background-position' => ( isset( $value[ 'background-position' ] ) ) ? sanitize_text_field( $value[ 'background-position' ] ) : '', |
|
| 57 | + 'background-size' => ( isset( $value[ 'background-size' ] ) ) ? sanitize_text_field( $value[ 'background-size' ] ) : '', |
|
| 58 | + 'background-attachment' => ( isset( $value[ 'background-attachment' ] ) ) ? sanitize_text_field( $value[ 'background-attachment' ] ) : '', |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -89,20 +89,20 @@ discard block |
||
| 89 | 89 | foreach ( $this->output as $output ) { |
| 90 | 90 | |
| 91 | 91 | // If 'element' is not defined, skip this. |
| 92 | - if ( ! isset( $output['element'] ) ) { |
|
| 92 | + if ( ! isset( $output[ 'element' ] ) ) { |
|
| 93 | 93 | continue; |
| 94 | 94 | } |
| 95 | - if ( is_array( $output['element'] ) ) { |
|
| 96 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 95 | + if ( is_array( $output[ 'element' ] ) ) { |
|
| 96 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // If there's a sanitize_callback defined, skip this. |
| 100 | - if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) ) { |
|
| 100 | + if ( isset( $output[ 'sanitize_callback' ] ) && ! empty( $output[ 'sanitize_callback' ] ) ) { |
|
| 101 | 101 | continue; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // If we got this far, it's safe to add this. |
| 105 | - $js_vars[] = $output; |
|
| 105 | + $js_vars[ ] = $output; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Did we manage to get all the items from 'output'? |
@@ -50,17 +50,17 @@ |
||
| 50 | 50 | } |
| 51 | 51 | if ( true === $this->alpha ) { |
| 52 | 52 | _doing_it_wrong( 'Kirki::add_field', esc_html__( 'Do not use "alpha" as an argument in color controls. Use "choices[alpha]" instead.', 'kirki' ), '3.0.10' ); |
| 53 | - $this->choices['alpha'] = true; |
|
| 53 | + $this->choices[ 'alpha' ] = true; |
|
| 54 | 54 | } |
| 55 | - if ( ! isset( $this->choices['alpha'] ) || true !== $this->choices['alpha'] ) { |
|
| 56 | - $this->choices['alpha'] = true; |
|
| 55 | + if ( ! isset( $this->choices[ 'alpha' ] ) || true !== $this->choices[ 'alpha' ] ) { |
|
| 56 | + $this->choices[ 'alpha' ] = true; |
|
| 57 | 57 | if ( property_exists( $this, 'default' ) && ! empty( $this->default ) && false === strpos( 'rgba', $this->default ) ) { |
| 58 | - $this->choices['alpha'] = false; |
|
| 58 | + $this->choices[ 'alpha' ] = false; |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if ( ( ! isset( $this->choices['mode'] ) ) || ( 'hex' !== $this->choices['mode'] || 'hue' !== $this->choices['mode'] ) ) { |
|
| 63 | - $this->choices['mode'] = 'hex'; |
|
| 62 | + if ( ( ! isset( $this->choices[ 'mode' ] ) ) || ( 'hex' !== $this->choices[ 'mode' ] || 'hue' !== $this->choices[ 'mode' ] ) ) { |
|
| 63 | + $this->choices[ 'mode' ] = 'hex'; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | public function sanitize( $value ) { |
| 79 | 79 | if ( is_array( $value ) ) { |
| 80 | 80 | foreach ( $value as $key => $subvalue ) { |
| 81 | - if ( '' !== $subvalue || isset( $this->choices[''] ) ) { |
|
| 81 | + if ( '' !== $subvalue || isset( $this->choices[ '' ] ) ) { |
|
| 82 | 82 | $key = sanitize_key( $key ); |
| 83 | 83 | $value[ $key ] = sanitize_text_field( $subvalue ); |
| 84 | 84 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | protected function set_choices() { |
| 24 | 24 | $default_args = array( |
| 25 | 25 | 'controls' => array( |
| 26 | - 'top' => ( isset( $this->default['top'] ) ), |
|
| 27 | - 'bottom' => ( isset( $this->default['top'] ) ), |
|
| 28 | - 'left' => ( isset( $this->default['top'] ) ), |
|
| 29 | - 'right' => ( isset( $this->default['top'] ) ), |
|
| 26 | + 'top' => ( isset( $this->default[ 'top' ] ) ), |
|
| 27 | + 'bottom' => ( isset( $this->default[ 'top' ] ) ), |
|
| 28 | + 'left' => ( isset( $this->default[ 'top' ] ) ), |
|
| 29 | + 'right' => ( isset( $this->default[ 'top' ] ) ), |
|
| 30 | 30 | ), |
| 31 | 31 | 'labels' => array( |
| 32 | 32 | 'top' => esc_html__( 'Top', 'kirki' ), |