@@ -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 | } |
@@ -126,12 +126,12 @@ |
||
| 126 | 126 | |
| 127 | 127 | $google_fonts = array(); |
| 128 | 128 | if ( is_array( $fonts ) ) { |
| 129 | - foreach ( $fonts['items'] as $font ) { |
|
| 130 | - $google_fonts[ $font['family'] ] = array( |
|
| 131 | - 'label' => $font['family'], |
|
| 132 | - 'variants' => $font['variants'], |
|
| 133 | - 'subsets' => $font['subsets'], |
|
| 134 | - 'category' => $font['category'], |
|
| 129 | + foreach ( $fonts[ 'items' ] as $font ) { |
|
| 130 | + $google_fonts[ $font[ 'family' ] ] = array( |
|
| 131 | + 'label' => $font[ 'family' ], |
|
| 132 | + 'variants' => $font[ 'variants' ], |
|
| 133 | + 'subsets' => $font[ 'subsets' ], |
|
| 134 | + 'category' => $font[ 'category' ], |
|
| 135 | 135 | ); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $this->webfonts = $webfonts; |
| 75 | 75 | $this->googlefonts = $googlefonts; |
| 76 | 76 | |
| 77 | - if ( ! isset( $args['enqueue'] ) || false !== $args['enqueue'] ) { |
|
| 77 | + if ( ! isset( $args[ 'enqueue' ] ) || false !== $args[ 'enqueue' ] ) { |
|
| 78 | 78 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 105 ); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | if ( ! empty( $variants ) ) { |
| 125 | 125 | $link_font .= ':' . $variants; |
| 126 | 126 | } |
| 127 | - $link_fonts[] = $link_font; |
|
| 127 | + $link_fonts[ ] = $link_font; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // Are we force-loading all subsets? |
| 131 | 131 | if ( true === Kirki_Fonts_Google::$force_load_all_subsets ) { |
| 132 | 132 | |
| 133 | - if ( isset( $this->googlefonts->fonts[ $font ]['subsets'] ) ) { |
|
| 134 | - foreach ( $this->googlefonts->fonts[ $font ]['subsets'] as $subset ) { |
|
| 135 | - $this->subsets[] = $subset; |
|
| 133 | + if ( isset( $this->googlefonts->fonts[ $font ][ 'subsets' ] ) ) { |
|
| 134 | + foreach ( $this->googlefonts->fonts[ $font ][ 'subsets' ] as $subset ) { |
|
| 135 | + $this->subsets[ ] = $subset; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | } |
| 64 | 64 | // Allow disabling the custom loader using the kirki/config filter. |
| 65 | 65 | $config = apply_filters( 'kirki/config', array() ); |
| 66 | - if ( isset( $config['disable_loader'] ) && true === $config['disable_loader'] ) { |
|
| 66 | + if ( isset( $config[ 'disable_loader' ] ) && true === $config[ 'disable_loader' ] ) { |
|
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | // Add the "loading" icon. |
@@ -72,8 +72,8 @@ |
||
| 72 | 72 | $collapsible_fields = array(); |
| 73 | 73 | $fields = Kirki::$fields; |
| 74 | 74 | foreach ( $fields as $field ) { |
| 75 | - if ( isset( $field['collapsible'] ) && true === $field['collapsible'] && isset( $field['settings'] ) && isset( $field['label'] ) ) { |
|
| 76 | - $collapsible_fields[ $field['settings'] ] = $field['label']; |
|
| 75 | + if ( isset( $field[ 'collapsible' ] ) && true === $field[ 'collapsible' ] && isset( $field[ 'settings' ] ) && isset( $field[ 'label' ] ) ) { |
|
| 76 | + $collapsible_fields[ $field[ 'settings' ] ] = $field[ 'label' ]; |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | $collapsible_fields = array_unique( $collapsible_fields ); |
@@ -89,15 +89,15 @@ |
||
| 89 | 89 | |
| 90 | 90 | // Parse sections and find ones with icons. |
| 91 | 91 | foreach ( $sections as $section ) { |
| 92 | - if ( isset( $section['icon'] ) ) { |
|
| 93 | - $this->add_icon( $section['id'], $section['icon'], 'section' ); |
|
| 92 | + if ( isset( $section[ 'icon' ] ) ) { |
|
| 93 | + $this->add_icon( $section[ 'id' ], $section[ 'icon' ], 'section' ); |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Parse panels and find ones with icons. |
| 98 | 98 | foreach ( $panels as $panel ) { |
| 99 | - if ( isset( $panel['icon'] ) ) { |
|
| 100 | - $this->add_icon( $panel['id'], $panel['icon'], 'panel' ); |
|
| 99 | + if ( isset( $panel[ 'icon' ] ) ) { |
|
| 100 | + $this->add_icon( $panel[ 'id' ], $panel[ 'icon' ], 'panel' ); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -76,11 +76,11 @@ |
||
| 76 | 76 | |
| 77 | 77 | $fields = Kirki::$fields; |
| 78 | 78 | foreach ( $fields as $field ) { |
| 79 | - if ( isset( $field['tooltip'] ) && ! empty( $field['tooltip'] ) ) { |
|
| 80 | - $id = str_replace( '[', '-', str_replace( ']', '', $field['settings'] ) ); |
|
| 79 | + if ( isset( $field[ 'tooltip' ] ) && ! empty( $field[ 'tooltip' ] ) ) { |
|
| 80 | + $id = str_replace( '[', '-', str_replace( ']', '', $field[ 'settings' ] ) ); |
|
| 81 | 81 | $this->tooltips_content[ $id ] = array( |
| 82 | 82 | 'id' => $id, |
| 83 | - 'content' => wp_kses_post( $field['tooltip'] ), |
|
| 83 | + 'content' => wp_kses_post( $field[ 'tooltip' ] ), |
|
| 84 | 84 | ); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -53,8 +53,8 @@ |
||
| 53 | 53 | public function to_json() { |
| 54 | 54 | parent::to_json(); |
| 55 | 55 | |
| 56 | - $this->json['palette'] = $this->palette; |
|
| 57 | - $this->json['choices']['alpha'] = ( isset( $this->choices['alpha'] ) && $this->choices['alpha'] ) ? 'true' : 'false'; |
|
| 58 | - $this->json['mode'] = $this->mode; |
|
| 56 | + $this->json[ 'palette' ] = $this->palette; |
|
| 57 | + $this->json[ 'choices' ][ 'alpha' ] = ( isset( $this->choices[ 'alpha' ] ) && $this->choices[ 'alpha' ] ) ? 'true' : 'false'; |
|
| 58 | + $this->json[ 'mode' ] = $this->mode; |
|
| 59 | 59 | } |
| 60 | 60 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | public function to_json() { |
| 36 | 36 | parent::to_json(); |
| 37 | 37 | |
| 38 | - $this->json['icons'] = Kirki_Helper::get_dashicons(); |
|
| 38 | + $this->json[ 'icons' ] = Kirki_Helper::get_dashicons(); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |