@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $config_ids = Kirki_Config::get_config_ids(); |
54 | 54 | global $kirki_deprecated_filters_iteration; |
55 | 55 | foreach ( $config_ids as $config_id ) { |
56 | - foreach( array( |
|
56 | + foreach ( array( |
|
57 | 57 | '/dynamic_css', |
58 | 58 | '/output/control-classnames', |
59 | 59 | '/css/skip_hidden', |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | $kirki_deprecated_filters_iteration = array( $config_id, $filter_suffix ); |
65 | 65 | add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) { |
66 | 66 | global $kirki_deprecated_filters_iteration; |
67 | - $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
|
68 | - return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args ); |
|
67 | + $kirki_deprecated_filters_iteration[ 1 ] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[ 1 ] ); |
|
68 | + return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[ 0 ]}/{$kirki_deprecated_filters_iteration[ 1 ]}", $args ); |
|
69 | 69 | }, 99 ); |
70 | - if ( false !== strpos( $kirki_deprecated_filters_iteration[1], '-' ) ) { |
|
71 | - $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
|
70 | + if ( false !== strpos( $kirki_deprecated_filters_iteration[ 1 ], '-' ) ) { |
|
71 | + $kirki_deprecated_filters_iteration[ 1 ] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[ 1 ] ); |
|
72 | 72 | add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) { |
73 | 73 | global $kirki_deprecated_filters_iteration; |
74 | - $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
|
75 | - return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args ); |
|
74 | + $kirki_deprecated_filters_iteration[ 1 ] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[ 1 ] ); |
|
75 | + return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[ 0 ]}/{$kirki_deprecated_filters_iteration[ 1 ]}", $args ); |
|
76 | 76 | }, 99 ); |
77 | 77 | } |
78 | 78 | } |
@@ -1,55 +1,68 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // @codingStandardsIgnoreFile |
3 | 3 | |
4 | -add_filter( 'kirki_config', function( $args ) { |
|
4 | +add_filter( 'kirki_config', function( $args ) |
|
5 | +{ |
|
5 | 6 | return apply_filters( 'kirki/config', $args ); |
6 | 7 | }, 99 ); |
7 | 8 | |
8 | -add_filter( 'kirki_control_types', function( $args ) { |
|
9 | +add_filter( 'kirki_control_types', function( $args ) |
|
10 | +{ |
|
9 | 11 | return apply_filters( 'kirki/control_types', $args ); |
10 | 12 | }, 99 ); |
11 | 13 | |
12 | -add_filter( 'kirki_section_types', function( $args ) { |
|
14 | +add_filter( 'kirki_section_types', function( $args ) |
|
15 | +{ |
|
13 | 16 | return apply_filters( 'kirki/section_types', $args ); |
14 | 17 | }, 99 ); |
15 | 18 | |
16 | -add_filter( 'kirki_section_types_exclude', function( $args ) { |
|
19 | +add_filter( 'kirki_section_types_exclude', function( $args ) |
|
20 | +{ |
|
17 | 21 | return apply_filters( 'kirki/section_types/exclude', $args ); |
18 | 22 | }, 99 ); |
19 | 23 | |
20 | -add_filter( 'kirki_control_types_exclude', function( $args ) { |
|
24 | +add_filter( 'kirki_control_types_exclude', function( $args ) |
|
25 | +{ |
|
21 | 26 | return apply_filters( 'kirki/control_types/exclude', $args ); |
22 | 27 | }, 99 ); |
23 | 28 | |
24 | -add_filter( 'kirki_controls', function( $args ) { |
|
29 | +add_filter( 'kirki_controls', function( $args ) |
|
30 | +{ |
|
25 | 31 | return apply_filters( 'kirki/controls', $args ); |
26 | 32 | }, 99 ); |
27 | 33 | |
28 | -add_filter( 'kirki_fields', function( $args ) { |
|
34 | +add_filter( 'kirki_fields', function( $args ) |
|
35 | +{ |
|
29 | 36 | return apply_filters( 'kirki/fields', $args ); |
30 | 37 | }, 99 ); |
31 | 38 | |
32 | -add_filter( 'kirki_modules', function( $args ) { |
|
39 | +add_filter( 'kirki_modules', function( $args ) |
|
40 | +{ |
|
33 | 41 | return apply_filters( 'kirki/modules', $args ); |
34 | 42 | }, 99 ); |
35 | 43 | |
36 | -add_filter( 'kirki_panel_types', function( $args ) { |
|
44 | +add_filter( 'kirki_panel_types', function( $args ) |
|
45 | +{ |
|
37 | 46 | return apply_filters( 'kirki/panel_types', $args ); |
38 | 47 | }, 99 ); |
39 | 48 | |
40 | -add_filter( 'kirki_setting_types', function( $args ) { |
|
49 | +add_filter( 'kirki_setting_types', function( $args ) |
|
50 | +{ |
|
41 | 51 | return apply_filters( 'kirki/setting_types', $args ); |
42 | 52 | }, 99 ); |
43 | 53 | |
44 | -add_filter( 'kirki_variable', function( $args ) { |
|
54 | +add_filter( 'kirki_variable', function( $args ) |
|
55 | +{ |
|
45 | 56 | return apply_filters( 'kirki/variable', $args ); |
46 | 57 | }, 99 ); |
47 | 58 | |
48 | -add_filter( 'kirki_values_get_value', function( $arg1, $arg2 ) { |
|
59 | +add_filter( 'kirki_values_get_value', function( $arg1, $arg2 ) |
|
60 | +{ |
|
49 | 61 | return apply_filters( 'kirki/values/get_value', $arg1, $arg2 ); |
50 | 62 | }, 99, 2 ); |
51 | 63 | |
52 | -add_action( 'init', function() { |
|
64 | +add_action( 'init', function() |
|
65 | +{ |
|
53 | 66 | $config_ids = Kirki_Config::get_config_ids(); |
54 | 67 | global $kirki_deprecated_filters_iteration; |
55 | 68 | foreach ( $config_ids as $config_id ) { |
@@ -62,14 +75,16 @@ discard block |
||
62 | 75 | '/webfonts/skip_hidden', |
63 | 76 | ) as $filter_suffix ) { |
64 | 77 | $kirki_deprecated_filters_iteration = array( $config_id, $filter_suffix ); |
65 | - add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) { |
|
78 | + add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) |
|
79 | + { |
|
66 | 80 | global $kirki_deprecated_filters_iteration; |
67 | 81 | $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
68 | 82 | return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args ); |
69 | 83 | }, 99 ); |
70 | 84 | if ( false !== strpos( $kirki_deprecated_filters_iteration[1], '-' ) ) { |
71 | 85 | $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
72 | - add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) { |
|
86 | + add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) |
|
87 | + { |
|
73 | 88 | global $kirki_deprecated_filters_iteration; |
74 | 89 | $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
75 | 90 | return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args ); |
@@ -79,38 +94,47 @@ discard block |
||
79 | 94 | } |
80 | 95 | }, 99 ); |
81 | 96 | |
82 | -add_filter( 'kirki_enqueue_google_fonts', function( $args ) { |
|
97 | +add_filter( 'kirki_enqueue_google_fonts', function( $args ) |
|
98 | +{ |
|
83 | 99 | return apply_filters( 'kirki/enqueue_google_fonts', $args ); |
84 | 100 | }, 99 ); |
85 | 101 | |
86 | -add_filter( 'kirki_styles_array', function( $args ) { |
|
102 | +add_filter( 'kirki_styles_array', function( $args ) |
|
103 | +{ |
|
87 | 104 | return apply_filters( 'kirki/styles_array', $args ); |
88 | 105 | }, 99 ); |
89 | 106 | |
90 | -add_filter( 'kirki_dynamic_css_method', function( $args ) { |
|
107 | +add_filter( 'kirki_dynamic_css_method', function( $args ) |
|
108 | +{ |
|
91 | 109 | return apply_filters( 'kirki/dynamic_css/method', $args ); |
92 | 110 | }, 99 ); |
93 | 111 | |
94 | -add_filter( 'kirki_postmessage_script', function( $args ) { |
|
112 | +add_filter( 'kirki_postmessage_script', function( $args ) |
|
113 | +{ |
|
95 | 114 | return apply_filters( 'kirki/postmessage/script', $args ); |
96 | 115 | }, 99 ); |
97 | 116 | |
98 | -add_filter( 'kirki_fonts_all', function( $args ) { |
|
117 | +add_filter( 'kirki_fonts_all', function( $args ) |
|
118 | +{ |
|
99 | 119 | return apply_filters( 'kirki/fonts/all', $args ); |
100 | 120 | }, 99 ); |
101 | 121 | |
102 | -add_filter( 'kirki_fonts_standard_fonts', function( $args ) { |
|
122 | +add_filter( 'kirki_fonts_standard_fonts', function( $args ) |
|
123 | +{ |
|
103 | 124 | return apply_filters( 'kirki/fonts/standard_fonts', $args ); |
104 | 125 | }, 99 ); |
105 | 126 | |
106 | -add_filter( 'kirki_fonts_backup_fonts', function( $args ) { |
|
127 | +add_filter( 'kirki_fonts_backup_fonts', function( $args ) |
|
128 | +{ |
|
107 | 129 | return apply_filters( 'kirki/fonts/backup_fonts', $args ); |
108 | 130 | }, 99 ); |
109 | 131 | |
110 | -add_filter( 'kirki_fonts_google_fonts', function( $args ) { |
|
132 | +add_filter( 'kirki_fonts_google_fonts', function( $args ) |
|
133 | +{ |
|
111 | 134 | return apply_filters( 'kirki/fonts/google_fonts', $args ); |
112 | 135 | }, 99 ); |
113 | 136 | |
114 | -add_filter( 'kirki_googlefonts_load_method', function( $args ) { |
|
137 | +add_filter( 'kirki_googlefonts_load_method', function( $args ) |
|
138 | +{ |
|
115 | 139 | return apply_filters( 'kirki/googlefonts_load_method', $args ); |
116 | 140 | }, 99 ); |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * @access protected |
60 | 60 | */ |
61 | 61 | protected function set_choices() { |
62 | - if ( ! isset( $this->choices['language'] ) ) { |
|
62 | + if ( ! isset( $this->choices[ 'language' ] ) ) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | - $language = $this->choices['language']; |
|
65 | + $language = $this->choices[ 'language' ]; |
|
66 | 66 | switch ( $language ) { |
67 | 67 | case 'json': |
68 | 68 | case 'xml': |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | $language = 'text/x-' . $language; |
91 | 91 | break; |
92 | 92 | } |
93 | - if ( ! isset( $this->editor_settings['codemirror'] ) ) { |
|
94 | - $this->editor_settings['codemirror'] = array(); |
|
93 | + if ( ! isset( $this->editor_settings[ 'codemirror' ] ) ) { |
|
94 | + $this->editor_settings[ 'codemirror' ] = array(); |
|
95 | 95 | } |
96 | - if ( ! isset( $this->editor_settings['codemirror']['mode'] ) ) { |
|
97 | - $this->editor_settings['codemirror']['mode'] = $language; |
|
96 | + if ( ! isset( $this->editor_settings[ 'codemirror' ][ 'mode' ] ) ) { |
|
97 | + $this->editor_settings[ 'codemirror' ][ 'mode' ] = $language; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | if ( ! is_array( $this->choices ) ) { |
61 | 61 | $this->choices = (array) $this->choices; |
62 | 62 | } |
63 | - if ( ! isset( $this->choices['save_as'] ) ) { |
|
64 | - $this->choices['save_as'] = 'url'; |
|
63 | + if ( ! isset( $this->choices[ 'save_as' ] ) ) { |
|
64 | + $this->choices[ 'save_as' ] = 'url'; |
|
65 | 65 | } |
66 | - if ( ! isset( $this->choices['labels'] ) ) { |
|
67 | - $this->choices['labels'] = array(); |
|
66 | + if ( ! isset( $this->choices[ 'labels' ] ) ) { |
|
67 | + $this->choices[ 'labels' ] = array(); |
|
68 | 68 | } |
69 | 69 | $this->set_button_labels(); |
70 | - $this->choices['labels'] = wp_parse_args( $this->choices['labels'], $this->button_labels ); |
|
70 | + $this->choices[ 'labels' ] = wp_parse_args( $this->choices[ 'labels' ], $this->button_labels ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function sanitize( $value ) { |
95 | 95 | |
96 | - if ( isset( $this->choices['save_as'] ) && 'array' === $this->choices['save_as'] ) { |
|
96 | + if ( isset( $this->choices[ 'save_as' ] ) && 'array' === $this->choices[ 'save_as' ] ) { |
|
97 | 97 | return array( |
98 | - 'id' => ( isset( $value['id'] ) && '' !== $value['id'] ) ? (int) $value['id'] : '', |
|
99 | - 'url' => ( isset( $value['url'] ) && '' !== $value['url'] ) ? esc_url_raw( $value['url'] ) : '', |
|
100 | - 'width' => ( isset( $value['width'] ) && '' !== $value['width'] ) ? (int) $value['width'] : '', |
|
101 | - 'height' => ( isset( $value['height'] ) && '' !== $value['height'] ) ? (int) $value['height'] : '', |
|
98 | + 'id' => ( isset( $value[ 'id' ] ) && '' !== $value[ 'id' ] ) ? (int) $value[ 'id' ] : '', |
|
99 | + 'url' => ( isset( $value[ 'url' ] ) && '' !== $value[ 'url' ] ) ? esc_url_raw( $value[ 'url' ] ) : '', |
|
100 | + 'width' => ( isset( $value[ 'width' ] ) && '' !== $value[ 'width' ] ) ? (int) $value[ 'width' ] : '', |
|
101 | + 'height' => ( isset( $value[ 'height' ] ) && '' !== $value[ 'height' ] ) ? (int) $value[ 'height' ] : '', |
|
102 | 102 | ); |
103 | 103 | } |
104 | - if ( isset( $this->choices['save_as'] ) && 'id' === $this->choices['save_as'] ) { |
|
104 | + if ( isset( $this->choices[ 'save_as' ] ) && 'id' === $this->choices[ 'save_as' ] ) { |
|
105 | 105 | return absint( $value ); |
106 | 106 | } |
107 | 107 | if ( is_string( $value ) ) { |
@@ -32,6 +32,6 @@ |
||
32 | 32 | */ |
33 | 33 | public function to_json() { |
34 | 34 | parent::to_json(); |
35 | - $this->json['required'] = $this->required; |
|
35 | + $this->json[ 'required' ] = $this->required; |
|
36 | 36 | } |
37 | 37 | } |
@@ -32,6 +32,6 @@ |
||
32 | 32 | */ |
33 | 33 | public function to_json() { |
34 | 34 | parent::to_json(); |
35 | - $this->json['required'] = $this->required; |
|
35 | + $this->json[ 'required' ] = $this->required; |
|
36 | 36 | } |
37 | 37 | } |
@@ -136,37 +136,37 @@ |
||
136 | 136 | // Get the basics from the parent class. |
137 | 137 | parent::to_json(); |
138 | 138 | // Default. |
139 | - $this->json['default'] = $this->setting->default; |
|
139 | + $this->json[ 'default' ] = $this->setting->default; |
|
140 | 140 | if ( isset( $this->default ) ) { |
141 | - $this->json['default'] = $this->default; |
|
141 | + $this->json[ 'default' ] = $this->default; |
|
142 | 142 | } |
143 | 143 | // Required. |
144 | - $this->json['required'] = $this->required; |
|
144 | + $this->json[ 'required' ] = $this->required; |
|
145 | 145 | // Output. |
146 | - $this->json['output'] = $this->output; |
|
146 | + $this->json[ 'output' ] = $this->output; |
|
147 | 147 | // Value. |
148 | - $this->json['value'] = $this->value(); |
|
148 | + $this->json[ 'value' ] = $this->value(); |
|
149 | 149 | // Choices. |
150 | - $this->json['choices'] = $this->choices; |
|
150 | + $this->json[ 'choices' ] = $this->choices; |
|
151 | 151 | // The link. |
152 | - $this->json['link'] = $this->get_link(); |
|
152 | + $this->json[ 'link' ] = $this->get_link(); |
|
153 | 153 | // The ID. |
154 | - $this->json['id'] = $this->id; |
|
154 | + $this->json[ 'id' ] = $this->id; |
|
155 | 155 | // Translation strings. |
156 | - $this->json['l10n'] = $this->l10n(); |
|
156 | + $this->json[ 'l10n' ] = $this->l10n(); |
|
157 | 157 | // The ajaxurl in case we need it. |
158 | - $this->json['ajaxurl'] = admin_url( 'admin-ajax.php' ); |
|
158 | + $this->json[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); |
|
159 | 159 | // Input attributes. |
160 | - $this->json['inputAttrs'] = ''; |
|
160 | + $this->json[ 'inputAttrs' ] = ''; |
|
161 | 161 | foreach ( $this->input_attrs as $attr => $value ) { |
162 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
162 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
163 | 163 | } |
164 | 164 | // The kirki-config. |
165 | - $this->json['kirkiConfig'] = $this->kirki_config; |
|
165 | + $this->json[ 'kirkiConfig' ] = $this->kirki_config; |
|
166 | 166 | // The option-type. |
167 | - $this->json['kirkiOptionType'] = $this->option_type; |
|
167 | + $this->json[ 'kirkiOptionType' ] = $this->option_type; |
|
168 | 168 | // The option-name. |
169 | - $this->json['kirkiOptionName'] = $this->option_name; |
|
169 | + $this->json[ 'kirkiOptionName' ] = $this->option_name; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -35,23 +35,23 @@ discard block |
||
35 | 35 | public function to_json() { |
36 | 36 | parent::to_json(); |
37 | 37 | |
38 | - if ( is_array( $this->json['value'] ) ) { |
|
39 | - foreach ( array_keys( $this->json['value'] ) as $key ) { |
|
40 | - if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json['default'][ $key ] ) ) { |
|
41 | - unset( $this->json['value'][ $key ] ); |
|
38 | + if ( is_array( $this->json[ 'value' ] ) ) { |
|
39 | + foreach ( array_keys( $this->json[ 'value' ] ) as $key ) { |
|
40 | + if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
41 | + unset( $this->json[ 'value' ][ $key ] ); |
|
42 | 42 | } |
43 | 43 | // Fix for https://wordpress.org/support/topic/white-font-after-updateing-to-3-0-16. |
44 | - if ( ! isset( $this->json['default'][ $key ] ) ) { |
|
45 | - unset( $this->json['value'][ $key ] ); |
|
44 | + if ( ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
45 | + unset( $this->json[ 'value' ][ $key ] ); |
|
46 | 46 | } |
47 | 47 | // Fix for https://github.com/aristath/kirki/issues/1405. |
48 | - if ( isset( $this->json['default'][ $key ] ) && false === $this->json['default'][ $key ] ) { |
|
49 | - unset( $this->json['value'][ $key ] ); |
|
48 | + if ( isset( $this->json[ 'default' ][ $key ] ) && false === $this->json[ 'default' ][ $key ] ) { |
|
49 | + unset( $this->json[ 'value' ][ $key ] ); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - $this->json['show_variants'] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
54 | + $this->json[ 'show_variants' ] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | $final_variants = array(); |
239 | 239 | foreach ( $variants as $variant ) { |
240 | 240 | if ( is_string( $variant ) ) { |
241 | - $final_variants[] = array( |
|
241 | + $final_variants[ ] = array( |
|
242 | 242 | 'id' => $variant, |
243 | 243 | 'label' => isset( $all_variants[ $variant ] ) ? $all_variants[ $variant ] : $variant, |
244 | 244 | ); |
245 | - } elseif ( is_array( $variant ) && isset( $variant['id'] ) && isset( $variant['label'] ) ) { |
|
246 | - $final_variants[] = $variant; |
|
245 | + } elseif ( is_array( $variant ) && isset( $variant[ 'id' ] ) && isset( $variant[ 'label' ] ) ) { |
|
246 | + $final_variants[ ] = $variant; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | return $final_variants; |
@@ -137,11 +137,11 @@ |
||
137 | 137 | |
138 | 138 | $google_fonts = array(); |
139 | 139 | if ( is_array( $fonts ) ) { |
140 | - foreach ( $fonts['items'] as $font ) { |
|
141 | - $google_fonts[ $font['family'] ] = array( |
|
142 | - 'label' => $font['family'], |
|
143 | - 'variants' => $font['variants'], |
|
144 | - 'category' => $font['category'], |
|
140 | + foreach ( $fonts[ 'items' ] as $font ) { |
|
141 | + $google_fonts[ $font[ 'family' ] ] = array( |
|
142 | + 'label' => $font[ 'family' ], |
|
143 | + 'variants' => $font[ 'variants' ], |
|
144 | + 'category' => $font[ 'category' ], |
|
145 | 145 | ); |
146 | 146 | } |
147 | 147 | } |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | protected function set_default() { |
50 | 50 | |
51 | 51 | // Accomodate the use of font-weight and convert to variant. |
52 | - if ( isset( $this->default['font-weight'] ) ) { |
|
53 | - $this->default['variant'] = ( 'regular' === $this->default['font-weight'] ) ? 400 : (string) intval( $this->default['font-weight'] ); |
|
52 | + if ( isset( $this->default[ 'font-weight' ] ) ) { |
|
53 | + $this->default[ 'variant' ] = ( 'regular' === $this->default[ 'font-weight' ] ) ? 400 : (string) intval( $this->default[ 'font-weight' ] ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | // Make sure letter-spacing has units. |
57 | - if ( isset( $this->default['letter-spacing'] ) && is_numeric( $this->default['letter-spacing'] ) && $this->default['letter-spacing'] ) { |
|
58 | - $this->default['letter-spacing'] .= 'px'; |
|
57 | + if ( isset( $this->default[ 'letter-spacing' ] ) && is_numeric( $this->default[ 'letter-spacing' ] ) && $this->default[ 'letter-spacing' ] ) { |
|
58 | + $this->default[ 'letter-spacing' ] .= 'px'; |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | foreach ( $this->output as $output ) { |
107 | 107 | |
108 | 108 | // If 'element' or 'property' are not defined, skip this. |
109 | - if ( ! isset( $output['element'] ) ) { |
|
109 | + if ( ! isset( $output[ 'element' ] ) ) { |
|
110 | 110 | continue; |
111 | 111 | } |
112 | - if ( is_array( $output['element'] ) ) { |
|
113 | - $output['element'] = implode( ',', $output['element'] ); |
|
112 | + if ( is_array( $output[ 'element' ] ) ) { |
|
113 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // If we got this far, it's safe to add this. |
117 | - $js_vars[] = $output; |
|
117 | + $js_vars[ ] = $output; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Did we manage to get all the items from 'output'? |
@@ -146,26 +146,26 @@ discard block |
||
146 | 146 | foreach ( $value as $key => $val ) { |
147 | 147 | switch ( $key ) { |
148 | 148 | case 'font-family': |
149 | - $value['font-family'] = esc_attr( $val ); |
|
149 | + $value[ 'font-family' ] = esc_attr( $val ); |
|
150 | 150 | break; |
151 | 151 | case 'font-weight': |
152 | - if ( isset( $value['variant'] ) ) { |
|
152 | + if ( isset( $value[ 'variant' ] ) ) { |
|
153 | 153 | break; |
154 | 154 | } |
155 | - $value['variant'] = $val; |
|
156 | - if ( isset( $value['font-style'] ) && 'italic' === $value['font-style'] ) { |
|
157 | - $value['variant'] = ( '400' !== $val || 400 !== $val ) ? $value['variant'] . 'italic' : 'italic'; |
|
155 | + $value[ 'variant' ] = $val; |
|
156 | + if ( isset( $value[ 'font-style' ] ) && 'italic' === $value[ 'font-style' ] ) { |
|
157 | + $value[ 'variant' ] = ( '400' !== $val || 400 !== $val ) ? $value[ 'variant' ] . 'italic' : 'italic'; |
|
158 | 158 | } |
159 | 159 | break; |
160 | 160 | case 'variant': |
161 | 161 | // Use 'regular' instead of 400 for font-variant. |
162 | - $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
162 | + $value[ 'variant' ] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
163 | 163 | // Get font-weight from variant. |
164 | - $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
165 | - $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : absint( $value['font-weight'] ); |
|
164 | + $value[ 'font-weight' ] = filter_var( $value[ 'variant' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
165 | + $value[ 'font-weight' ] = ( 'regular' === $value[ 'variant' ] || 'italic' === $value[ 'variant' ] ) ? 400 : absint( $value[ 'font-weight' ] ); |
|
166 | 166 | // Get font-style from variant. |
167 | - if ( ! isset( $value['font-style'] ) ) { |
|
168 | - $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; |
|
167 | + if ( ! isset( $value[ 'font-style' ] ) ) { |
|
168 | + $value[ 'font-style' ] = ( false === strpos( $value[ 'variant' ], 'italic' ) ) ? 'normal' : 'italic'; |
|
169 | 169 | } |
170 | 170 | break; |
171 | 171 | case 'font-size': |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | break; |
177 | 177 | case 'text-align': |
178 | 178 | if ( ! in_array( $val, array( 'inherit', 'left', 'center', 'right', 'justify' ), true ) ) { |
179 | - $value['text-align'] = 'inherit'; |
|
179 | + $value[ 'text-align' ] = 'inherit'; |
|
180 | 180 | } |
181 | 181 | break; |
182 | 182 | case 'text-transform': |
183 | 183 | if ( ! in_array( $val, array( 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ), true ) ) { |
184 | - $value['text-transform'] = 'none'; |
|
184 | + $value[ 'text-transform' ] = 'none'; |
|
185 | 185 | } |
186 | 186 | break; |
187 | 187 | case 'text-decoration': |
188 | 188 | if ( ! in_array( $val, array( 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) { |
189 | - $value['text-transform'] = 'none'; |
|
189 | + $value[ 'text-transform' ] = 'none'; |
|
190 | 190 | } |
191 | 191 | break; |
192 | 192 | case 'color': |
193 | - $value['color'] = ariColor::newColor( $val )->toCSS( 'hex' ); |
|
193 | + $value[ 'color' ] = ariColor::newColor( $val )->toCSS( 'hex' ); |
|
194 | 194 | break; |
195 | 195 | } // End switch(). |
196 | 196 | } // End foreach(). |