@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $config = apply_filters( 'kirki/config', array() ); |
| 77 | 77 | |
| 78 | 78 | // If we have set $config['disable_google_fonts'] to true then do not proceed any further. |
| 79 | - if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) { |
|
| 79 | + if ( isset( $config[ 'disable_google_fonts' ] ) && true === $config[ 'disable_google_fonts' ] ) { |
|
| 80 | 80 | return; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -113,64 +113,64 @@ discard block |
||
| 113 | 113 | public function generate_google_font( $args ) { |
| 114 | 114 | |
| 115 | 115 | // Process typography fields. |
| 116 | - if ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) { |
|
| 116 | + if ( isset( $args[ 'type' ] ) && 'kirki-typography' === $args[ 'type' ] ) { |
|
| 117 | 117 | |
| 118 | 118 | // Get the value. |
| 119 | 119 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
| 120 | 120 | |
| 121 | 121 | // If we don't have a font-family then we can skip this. |
| 122 | - if ( ! isset( $value['font-family'] ) ) { |
|
| 122 | + if ( ! isset( $value[ 'font-family' ] ) ) { |
|
| 123 | 123 | return; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // If not a google-font, then we can skip this. |
| 127 | - if ( ! Kirki_Fonts::is_google_font( $value['font-family'] ) ) { |
|
| 127 | + if ( ! Kirki_Fonts::is_google_font( $value[ 'font-family' ] ) ) { |
|
| 128 | 128 | return; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Set a default value for variants. |
| 132 | - if ( ! isset( $value['variant'] ) ) { |
|
| 133 | - $value['variant'] = 'regular'; |
|
| 132 | + if ( ! isset( $value[ 'variant' ] ) ) { |
|
| 133 | + $value[ 'variant' ] = 'regular'; |
|
| 134 | 134 | } |
| 135 | - if ( isset( $value['subsets'] ) ) { |
|
| 135 | + if ( isset( $value[ 'subsets' ] ) ) { |
|
| 136 | 136 | |
| 137 | 137 | // Add the subset directly to the array of subsets in the Kirki_GoogleFonts_Manager object. |
| 138 | 138 | // Subsets must be applied to ALL fonts if possible. |
| 139 | - if ( ! is_array( $value['subsets'] ) ) { |
|
| 140 | - $this->subsets[] = $value['subsets']; |
|
| 139 | + if ( ! is_array( $value[ 'subsets' ] ) ) { |
|
| 140 | + $this->subsets[ ] = $value[ 'subsets' ]; |
|
| 141 | 141 | } else { |
| 142 | - foreach ( $value['subsets'] as $subset ) { |
|
| 143 | - $this->subsets[] = $subset; |
|
| 142 | + foreach ( $value[ 'subsets' ] as $subset ) { |
|
| 143 | + $this->subsets[ ] = $subset; |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Add the requested google-font. |
| 149 | - if ( ! isset( $this->fonts[ $value['font-family'] ] ) ) { |
|
| 150 | - $this->fonts[ $value['font-family'] ] = array(); |
|
| 149 | + if ( ! isset( $this->fonts[ $value[ 'font-family' ] ] ) ) { |
|
| 150 | + $this->fonts[ $value[ 'font-family' ] ] = array(); |
|
| 151 | 151 | } |
| 152 | - if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) { |
|
| 153 | - $this->fonts[ $value['font-family'] ][] = $value['variant']; |
|
| 152 | + if ( ! in_array( $value[ 'variant' ], $this->fonts[ $value[ 'font-family' ] ], true ) ) { |
|
| 153 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $value[ 'variant' ]; |
|
| 154 | 154 | } |
| 155 | 155 | // Are we force-loading all variants? |
| 156 | 156 | if ( true === self::$force_load_all_variants ) { |
| 157 | 157 | $all_variants = Kirki_Fonts::get_all_variants(); |
| 158 | - $args['choices']['variant'] = array_keys( $all_variants ); |
|
| 158 | + $args[ 'choices' ][ 'variant' ] = array_keys( $all_variants ); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) { |
|
| 162 | - foreach ( $args['choices']['variant'] as $extra_variant ) { |
|
| 163 | - $this->fonts[ $value['font-family'] ][] = $extra_variant; |
|
| 161 | + if ( ! empty( $args[ 'choices' ][ 'variant' ] ) && is_array( $args[ 'choices' ][ 'variant' ] ) ) { |
|
| 162 | + foreach ( $args[ 'choices' ][ 'variant' ] as $extra_variant ) { |
|
| 163 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $extra_variant; |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } else { |
| 167 | 167 | |
| 168 | 168 | // Process non-typography fields. |
| 169 | - if ( isset( $args['output'] ) && is_array( $args['output'] ) ) { |
|
| 170 | - foreach ( $args['output'] as $output ) { |
|
| 169 | + if ( isset( $args[ 'output' ] ) && is_array( $args[ 'output' ] ) ) { |
|
| 170 | + foreach ( $args[ 'output' ] as $output ) { |
|
| 171 | 171 | |
| 172 | 172 | // If we don't have a typography-related output argument we can skip this. |
| 173 | - if ( ! isset( $output['property'] ) || ! in_array( $output['property'], array( 'font-family', 'font-weight', 'font-subset', 'subset', 'subsets' ), true ) ) { |
|
| 173 | + if ( ! isset( $output[ 'property' ] ) || ! in_array( $output[ 'property' ], array( 'font-family', 'font-weight', 'font-subset', 'subset', 'subsets' ), true ) ) { |
|
| 174 | 174 | continue; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -178,25 +178,25 @@ discard block |
||
| 178 | 178 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
| 179 | 179 | |
| 180 | 180 | if ( is_string( $value ) ) { |
| 181 | - if ( 'font-family' === $output['property'] ) { |
|
| 181 | + if ( 'font-family' === $output[ 'property' ] ) { |
|
| 182 | 182 | if ( ! array_key_exists( $value, $this->fonts ) ) { |
| 183 | 183 | $this->fonts[ $value ] = array(); |
| 184 | 184 | } |
| 185 | - } elseif ( 'font-weight' === $output['property'] ) { |
|
| 185 | + } elseif ( 'font-weight' === $output[ 'property' ] ) { |
|
| 186 | 186 | foreach ( $this->fonts as $font => $variants ) { |
| 187 | 187 | if ( ! in_array( $value, $variants, true ) ) { |
| 188 | - $this->fonts[ $font ][] = $value; |
|
| 188 | + $this->fonts[ $font ][ ] = $value; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | - } elseif ( 'font-subset' === $output['property'] || 'subset' === $output['property'] || 'subsets' === $output['property'] ) { |
|
| 191 | + } elseif ( 'font-subset' === $output[ 'property' ] || 'subset' === $output[ 'property' ] || 'subsets' === $output[ 'property' ] ) { |
|
| 192 | 192 | if ( ! is_array( $value ) ) { |
| 193 | 193 | if ( ! in_array( $value, $this->subsets, true ) ) { |
| 194 | - $this->subsets[] = $value; |
|
| 194 | + $this->subsets[ ] = $value; |
|
| 195 | 195 | } |
| 196 | 196 | } else { |
| 197 | 197 | foreach ( $value as $subset ) { |
| 198 | 198 | if ( ! in_array( $subset, $this->subsets, true ) ) { |
| 199 | - $this->subsets[] = $subset; |
|
| 199 | + $this->subsets[ ] = $subset; |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | // Get all valid font variants for this font. |
| 233 | 233 | $font_variants = array(); |
| 234 | - if ( isset( $this->google_fonts[ $font ]['variants'] ) ) { |
|
| 235 | - $font_variants = $this->google_fonts[ $font ]['variants']; |
|
| 234 | + if ( isset( $this->google_fonts[ $font ][ 'variants' ] ) ) { |
|
| 235 | + $font_variants = $this->google_fonts[ $font ][ 'variants' ]; |
|
| 236 | 236 | } |
| 237 | 237 | foreach ( $variants as $variant ) { |
| 238 | 238 | |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | // Check if the selected subsets exist, even in one of the selected fonts. |
| 249 | 249 | // If they don't, then they have to be removed otherwise the link will fail. |
| 250 | - if ( isset( $this->google_fonts[ $font ]['subsets'] ) ) { |
|
| 250 | + if ( isset( $this->google_fonts[ $font ][ 'subsets' ] ) ) { |
|
| 251 | 251 | foreach ( $this->subsets as $subset ) { |
| 252 | - if ( in_array( $subset, $this->google_fonts[ $font ]['subsets'], true ) ) { |
|
| 253 | - $valid_subsets[] = $subset; |
|
| 252 | + if ( in_array( $subset, $this->google_fonts[ $font ][ 'subsets' ], true ) ) { |
|
| 253 | + $valid_subsets[ ] = $subset; |
|
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -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 | |
@@ -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, |