| @@ -217,7 +217,8 @@ | ||
| 217 | 217 | } | 
| 218 | 218 | // If 'choice' is defined check for sub-values too. | 
| 219 | 219 | // Fixes https://github.com/aristath/kirki/issues/1416. | 
| 220 | -						if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison | |
| 220 | +						if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { | |
| 221 | +// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison | |
| 221 | 222 | $skip = true; | 
| 222 | 223 | } | 
| 223 | 224 | } | 
| @@ -83,13 +83,13 @@ discard block | ||
| 83 | 83 | */ | 
| 84 | 84 |  	protected function apply_sanitize_callback( $output, $value ) { | 
| 85 | 85 | |
| 86 | -		if ( isset( $output['sanitize_callback'] ) && null !== $output['sanitize_callback'] ) { | |
| 86 | +		if ( isset( $output[ 'sanitize_callback' ] ) && null !== $output[ 'sanitize_callback' ] ) { | |
| 87 | 87 | |
| 88 | 88 | // If the sanitize_callback is invalid, return the value. | 
| 89 | -			if ( ! is_callable( $output['sanitize_callback'] ) ) { | |
| 89 | +			if ( ! is_callable( $output[ 'sanitize_callback' ] ) ) { | |
| 90 | 90 | return $value; | 
| 91 | 91 | } | 
| 92 | - return call_user_func( $output['sanitize_callback'], $this->value ); | |
| 92 | + return call_user_func( $output[ 'sanitize_callback' ], $this->value ); | |
| 93 | 93 | } | 
| 94 | 94 | |
| 95 | 95 | return $value; | 
| @@ -105,22 +105,22 @@ discard block | ||
| 105 | 105 | */ | 
| 106 | 106 |  	protected function apply_value_pattern( $output, $value ) { | 
| 107 | 107 | |
| 108 | -		if ( isset( $output['value_pattern'] ) && ! empty( $output['value_pattern'] ) && is_string( $output['value_pattern'] ) ) { | |
| 108 | +		if ( isset( $output[ 'value_pattern' ] ) && ! empty( $output[ 'value_pattern' ] ) && is_string( $output[ 'value_pattern' ] ) ) { | |
| 109 | 109 |  			if ( ! is_array( $value ) ) { | 
| 110 | - $value = str_replace( '$', $value, $output['value_pattern'] ); | |
| 110 | + $value = str_replace( '$', $value, $output[ 'value_pattern' ] ); | |
| 111 | 111 | } | 
| 112 | 112 |  			if ( is_array( $value ) ) { | 
| 113 | 113 |  				foreach ( array_keys( $value ) as $value_k ) { | 
| 114 | 114 |  					if ( ! is_string( $value[ $value_k ] ) ) { | 
| 115 | 115 | continue; | 
| 116 | 116 | } | 
| 117 | -					if ( isset( $output['choice'] ) ) { | |
| 118 | -						if ( $output['choice'] === $value_k ) { | |
| 119 | - $value[ $output['choice'] ] = str_replace( '$', $value[ $output['choice'] ], $output['value_pattern'] ); | |
| 117 | +					if ( isset( $output[ 'choice' ] ) ) { | |
| 118 | +						if ( $output[ 'choice' ] === $value_k ) { | |
| 119 | + $value[ $output[ 'choice' ] ] = str_replace( '$', $value[ $output[ 'choice' ] ], $output[ 'value_pattern' ] ); | |
| 120 | 120 | } | 
| 121 | 121 | continue; | 
| 122 | 122 | } | 
| 123 | - $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output['value_pattern'] ); | |
| 123 | + $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output[ 'value_pattern' ] ); | |
| 124 | 124 | } | 
| 125 | 125 | } | 
| 126 | 126 | $value = $this->apply_pattern_replace( $output, $value ); | 
| @@ -136,14 +136,14 @@ discard block | ||
| 136 | 136 | * @return string|array | 
| 137 | 137 | */ | 
| 138 | 138 |  	protected function apply_pattern_replace( $output, $value ) { | 
| 139 | -		if ( isset( $output['pattern_replace'] ) && is_array( $output['pattern_replace'] ) ) { | |
| 139 | +		if ( isset( $output[ 'pattern_replace' ] ) && is_array( $output[ 'pattern_replace' ] ) ) { | |
| 140 | 140 | $option_type = ( '' !== Kirki::get_config_param( $this->config_id, 'option_type' ) ) ? Kirki::get_config_param( $this->config_id, 'option_type' ) : 'theme_mod'; | 
| 141 | 141 | $option_name = Kirki::get_config_param( $this->config_id, 'option_name' ); | 
| 142 | 142 | $options = array(); | 
| 143 | 143 |  			if ( $option_name ) { | 
| 144 | 144 | $options = ( 'site_option' === $option_type ) ? get_site_option( $option_name ) : get_option( $option_name ); | 
| 145 | 145 | } | 
| 146 | -			foreach ( $output['pattern_replace'] as $search => $replace ) { | |
| 146 | +			foreach ( $output[ 'pattern_replace' ] as $search => $replace ) { | |
| 147 | 147 | $replacement = ''; | 
| 148 | 148 |  				switch ( $option_type ) { | 
| 149 | 149 | case 'option': | 
| @@ -203,8 +203,8 @@ discard block | ||
| 203 | 203 | } | 
| 204 | 204 | |
| 205 | 205 | // No need to proceed this if the current value is the same as in the "exclude" value. | 
| 206 | -			if ( isset( $output['exclude'] ) && is_array( $output['exclude'] ) ) { | |
| 207 | -				foreach ( $output['exclude'] as $exclude ) { | |
| 206 | +			if ( isset( $output[ 'exclude' ] ) && is_array( $output[ 'exclude' ] ) ) { | |
| 207 | +				foreach ( $output[ 'exclude' ] as $exclude ) { | |
| 208 | 208 |  					if ( is_array( $value ) ) { | 
| 209 | 209 |  						if ( is_array( $exclude ) ) { | 
| 210 | 210 | $diff1 = array_diff( $value, $exclude ); | 
| @@ -216,7 +216,7 @@ discard block | ||
| 216 | 216 | } | 
| 217 | 217 | // If 'choice' is defined check for sub-values too. | 
| 218 | 218 | // Fixes https://github.com/aristath/kirki/issues/1416. | 
| 219 | -						if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison | |
| 219 | +						if ( isset( $output[ 'choice' ] ) && isset( $value[ $output[ 'choice' ] ] ) && $exclude == $value[ $output[ 'choice' ] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison | |
| 220 | 220 | $skip = true; | 
| 221 | 221 | } | 
| 222 | 222 | } | 
| @@ -237,10 +237,10 @@ discard block | ||
| 237 | 237 | // Apply any value patterns defined. | 
| 238 | 238 | $value = $this->apply_value_pattern( $output, $value ); | 
| 239 | 239 | |
| 240 | -			if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { | |
| 241 | - $output['element'] = array_unique( $output['element'] ); | |
| 242 | - sort( $output['element'] ); | |
| 243 | - $output['element'] = implode( ',', $output['element'] ); | |
| 240 | +			if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { | |
| 241 | + $output[ 'element' ] = array_unique( $output[ 'element' ] ); | |
| 242 | + sort( $output[ 'element' ] ); | |
| 243 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); | |
| 244 | 244 | } | 
| 245 | 245 | |
| 246 | 246 | $value = $this->process_value( $value, $output ); | 
| @@ -258,13 +258,13 @@ discard block | ||
| 258 | 258 | * @return null | 
| 259 | 259 | */ | 
| 260 | 260 |  	protected function process_output( $output, $value ) { | 
| 261 | -		if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { | |
| 261 | +		if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { | |
| 262 | 262 | return; | 
| 263 | 263 | } | 
| 264 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; | |
| 265 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; | |
| 266 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; | |
| 267 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; | |
| 264 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; | |
| 265 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; | |
| 266 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; | |
| 267 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; | |
| 268 | 268 | |
| 269 | 269 | // Properties that can accept multiple values. | 
| 270 | 270 | // Useful for example for gradients where all browsers use the "background-image" property | 
| @@ -273,15 +273,15 @@ discard block | ||
| 273 | 273 | 'background-image', | 
| 274 | 274 | 'background', | 
| 275 | 275 | ); | 
| 276 | -		if ( in_array( $output['property'], $accepts_multiple, true ) ) { | |
| 277 | -			if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { | |
| 278 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; | |
| 276 | +		if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { | |
| 277 | +			if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { | |
| 278 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; | |
| 279 | 279 | } | 
| 280 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; | |
| 280 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; | |
| 281 | 281 | return; | 
| 282 | 282 | } | 
| 283 | 283 |  		if ( is_string( $value ) || is_numeric( $value ) ) { | 
| 284 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; | |
| 284 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; | |
| 285 | 285 | } | 
| 286 | 286 | } | 
| 287 | 287 | |
| @@ -320,8 +320,8 @@ discard block | ||
| 320 | 320 | * @return string|array | 
| 321 | 321 | */ | 
| 322 | 322 |  	protected function process_value( $value, $output ) { | 
| 323 | -		if ( isset( $output['property'] ) ) { | |
| 324 | - return $this->process_property_value( $output['property'], $value ); | |
| 323 | +		if ( isset( $output[ 'property' ] ) ) { | |
| 324 | + return $this->process_property_value( $output[ 'property' ], $value ); | |
| 325 | 325 | } | 
| 326 | 326 | return $value; | 
| 327 | 327 | } | 
| @@ -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'] = ''; | |
| 179 | + $value[ 'text-align' ] = ''; | |
| 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'] = ''; | |
| 184 | + $value[ 'text-transform' ] = ''; | |
| 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'] = ''; | |
| 189 | + $value[ 'text-transform' ] = ''; | |
| 190 | 190 | } | 
| 191 | 191 | break; | 
| 192 | 192 | case 'color': | 
| 193 | - $value['color'] = '' === $value['color'] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); | |
| 193 | + $value[ 'color' ] = '' === $value[ 'color' ] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); | |
| 194 | 194 | break; | 
| 195 | 195 | } | 
| 196 | 196 | } | 
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | $config = apply_filters( 'kirki_config', array() ); | 
| 78 | 78 | |
| 79 | 79 | // If we have set $config['disable_google_fonts'] to true then do not proceed any further. | 
| 80 | -		if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) { | |
| 80 | +		if ( isset( $config[ 'disable_google_fonts' ] ) && true === $config[ 'disable_google_fonts' ] ) { | |
| 81 | 81 | return; | 
| 82 | 82 | } | 
| 83 | 83 | |
| @@ -115,57 +115,57 @@ discard block | ||
| 115 | 115 | global $wp_customize; | 
| 116 | 116 | |
| 117 | 117 | // Process typography fields. | 
| 118 | -		if ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) { | |
| 118 | +		if ( isset( $args[ 'type' ] ) && 'kirki-typography' === $args[ 'type' ] ) { | |
| 119 | 119 | |
| 120 | 120 | // Get the value. | 
| 121 | 121 | $value = Kirki_Values::get_sanitized_field_value( $args ); | 
| 122 | 122 | |
| 123 | -			if ( isset( $value['downloadFont'] ) && $value['downloadFont'] ) { | |
| 124 | - $this->hosted_fonts[] = $value['font-family']; | |
| 123 | +			if ( isset( $value[ 'downloadFont' ] ) && $value[ 'downloadFont' ] ) { | |
| 124 | + $this->hosted_fonts[ ] = $value[ 'font-family' ]; | |
| 125 | 125 | } | 
| 126 | 126 | |
| 127 | 127 | // If we don't have a font-family then we can skip this. | 
| 128 | -			if ( ! $wp_customize && ( ! isset( $value['font-family'] ) || in_array( $value['font-family'], $this->hosted_fonts, true ) ) ) { | |
| 128 | +			if ( ! $wp_customize && ( ! isset( $value[ 'font-family' ] ) || in_array( $value[ 'font-family' ], $this->hosted_fonts, true ) ) ) { | |
| 129 | 129 | return; | 
| 130 | 130 | } | 
| 131 | 131 | |
| 132 | 132 | // If not a google-font, then we can skip this. | 
| 133 | -			if ( ! isset( $value['font-family'] ) || ! Kirki_Fonts::is_google_font( $value['font-family'] ) ) { | |
| 133 | +			if ( ! isset( $value[ 'font-family' ] ) || ! Kirki_Fonts::is_google_font( $value[ 'font-family' ] ) ) { | |
| 134 | 134 | return; | 
| 135 | 135 | } | 
| 136 | 136 | |
| 137 | 137 | // Set a default value for variants. | 
| 138 | -			if ( ! isset( $value['variant'] ) ) { | |
| 139 | - $value['variant'] = 'regular'; | |
| 138 | +			if ( ! isset( $value[ 'variant' ] ) ) { | |
| 139 | + $value[ 'variant' ] = 'regular'; | |
| 140 | 140 | } | 
| 141 | 141 | |
| 142 | 142 | // Add the requested google-font. | 
| 143 | -			if ( ! isset( $this->fonts[ $value['font-family'] ] ) ) { | |
| 144 | - $this->fonts[ $value['font-family'] ] = array(); | |
| 143 | +			if ( ! isset( $this->fonts[ $value[ 'font-family' ] ] ) ) { | |
| 144 | + $this->fonts[ $value[ 'font-family' ] ] = array(); | |
| 145 | 145 | } | 
| 146 | -			if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) { | |
| 147 | - $this->fonts[ $value['font-family'] ][] = $value['variant']; | |
| 146 | +			if ( ! in_array( $value[ 'variant' ], $this->fonts[ $value[ 'font-family' ] ], true ) ) { | |
| 147 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $value[ 'variant' ]; | |
| 148 | 148 | } | 
| 149 | 149 | // Are we force-loading all variants? | 
| 150 | 150 |  			if ( true === self::$force_load_all_variants ) { | 
| 151 | 151 | $all_variants = Kirki_Fonts::get_all_variants(); | 
| 152 | - $args['choices']['variant'] = array_keys( $all_variants ); | |
| 152 | + $args[ 'choices' ][ 'variant' ] = array_keys( $all_variants ); | |
| 153 | 153 | } | 
| 154 | 154 | |
| 155 | -			if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) { | |
| 156 | -				foreach ( $args['choices']['variant'] as $extra_variant ) { | |
| 157 | - $this->fonts[ $value['font-family'] ][] = $extra_variant; | |
| 155 | +			if ( ! empty( $args[ 'choices' ][ 'variant' ] ) && is_array( $args[ 'choices' ][ 'variant' ] ) ) { | |
| 156 | +				foreach ( $args[ 'choices' ][ 'variant' ] as $extra_variant ) { | |
| 157 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $extra_variant; | |
| 158 | 158 | } | 
| 159 | 159 | } | 
| 160 | 160 | return; | 
| 161 | 161 | } | 
| 162 | 162 | |
| 163 | 163 | // Process non-typography fields. | 
| 164 | -		if ( isset( $args['output'] ) && is_array( $args['output'] ) ) { | |
| 165 | -			foreach ( $args['output'] as $output ) { | |
| 164 | +		if ( isset( $args[ 'output' ] ) && is_array( $args[ 'output' ] ) ) { | |
| 165 | +			foreach ( $args[ 'output' ] as $output ) { | |
| 166 | 166 | |
| 167 | 167 | // If we don't have a typography-related output argument we can skip this. | 
| 168 | -				if ( ! isset( $output['property'] ) || ! in_array( $output['property'], array( 'font-family', 'font-weight' ), true ) ) { | |
| 168 | +				if ( ! isset( $output[ 'property' ] ) || ! in_array( $output[ 'property' ], array( 'font-family', 'font-weight' ), true ) ) { | |
| 169 | 169 | continue; | 
| 170 | 170 | } | 
| 171 | 171 | |
| @@ -173,14 +173,14 @@ discard block | ||
| 173 | 173 | $value = Kirki_Values::get_sanitized_field_value( $args ); | 
| 174 | 174 | |
| 175 | 175 |  				if ( is_string( $value ) ) { | 
| 176 | -					if ( 'font-family' === $output['property'] ) { | |
| 176 | +					if ( 'font-family' === $output[ 'property' ] ) { | |
| 177 | 177 |  						if ( ! array_key_exists( $value, $this->fonts ) ) { | 
| 178 | 178 | $this->fonts[ $value ] = array(); | 
| 179 | 179 | } | 
| 180 | -					} elseif ( 'font-weight' === $output['property'] ) { | |
| 180 | +					} elseif ( 'font-weight' === $output[ 'property' ] ) { | |
| 181 | 181 |  						foreach ( $this->fonts as $font => $variants ) { | 
| 182 | 182 |  							if ( ! in_array( $value, $variants, true ) ) { | 
| 183 | - $this->fonts[ $font ][] = $value; | |
| 183 | + $this->fonts[ $font ][ ] = $value; | |
| 184 | 184 | } | 
| 185 | 185 | } | 
| 186 | 186 | } | 
| @@ -212,8 +212,8 @@ discard block | ||
| 212 | 212 | |
| 213 | 213 | // Get all valid font variants for this font. | 
| 214 | 214 | $font_variants = array(); | 
| 215 | -			if ( isset( $this->google_fonts[ $font ]['variants'] ) ) { | |
| 216 | - $font_variants = $this->google_fonts[ $font ]['variants']; | |
| 215 | +			if ( isset( $this->google_fonts[ $font ][ 'variants' ] ) ) { | |
| 216 | + $font_variants = $this->google_fonts[ $font ][ 'variants' ]; | |
| 217 | 217 | } | 
| 218 | 218 |  			foreach ( $variants as $variant ) { | 
| 219 | 219 | |
| @@ -453,7 +453,8 @@ | ||
| 453 | 453 | $variants = array_keys( $this->files ); | 
| 454 | 454 | } | 
| 455 | 455 |  		foreach ( $this->files as $variant => $file ) { | 
| 456 | -			if ( in_array( $variant, $variants ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 456 | +			if ( in_array( $variant, $variants ) ) { | |
| 457 | +// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 457 | 458 | $this->download_font_file( $file ); | 
| 458 | 459 | } | 
| 459 | 460 | } | 
| @@ -76,13 +76,13 @@ | ||
| 76 | 76 | |
| 77 | 77 | $fields = Kirki::$fields; | 
| 78 | 78 |  		foreach ( $fields as $field ) { | 
| 79 | -			if ( isset( $field['tooltip'] ) && ! empty( $field['tooltip'] ) ) { | |
| 79 | +			if ( isset( $field[ 'tooltip' ] ) && ! empty( $field[ 'tooltip' ] ) ) { | |
| 80 | 80 | // Get the control ID and properly format it for the tooltips. | 
| 81 | - $id = str_replace( '[', '-', str_replace( ']', '', $field['settings'] ) ); | |
| 81 | + $id = str_replace( '[', '-', str_replace( ']', '', $field[ 'settings' ] ) ); | |
| 82 | 82 | // Add the tooltips content. | 
| 83 | 83 | $this->tooltips_content[ $id ] = array( | 
| 84 | 84 | 'id' => $id, | 
| 85 | - 'content' => wp_kses_post( $field['tooltip'] ), | |
| 85 | + 'content' => wp_kses_post( $field[ 'tooltip' ] ), | |
| 86 | 86 | ); | 
| 87 | 87 | } | 
| 88 | 88 | } | 
| @@ -69,14 +69,14 @@ | ||
| 69 | 69 | |
| 70 | 70 | // Start parsing the fields. | 
| 71 | 71 |  		foreach ( $fields as $field ) { | 
| 72 | -			if ( isset( $field['partial_refresh'] ) && ! empty( $field['partial_refresh'] ) ) { | |
| 72 | +			if ( isset( $field[ 'partial_refresh' ] ) && ! empty( $field[ 'partial_refresh' ] ) ) { | |
| 73 | 73 | // Start going through each item in the array of partial refreshes. | 
| 74 | -				foreach ( $field['partial_refresh'] as $partial_refresh => $partial_refresh_args ) { | |
| 74 | +				foreach ( $field[ 'partial_refresh' ] as $partial_refresh => $partial_refresh_args ) { | |
| 75 | 75 | // If we have all we need, create the selective refresh call. | 
| 76 | -					if ( isset( $partial_refresh_args['render_callback'] ) && isset( $partial_refresh_args['selector'] ) ) { | |
| 76 | +					if ( isset( $partial_refresh_args[ 'render_callback' ] ) && isset( $partial_refresh_args[ 'selector' ] ) ) { | |
| 77 | 77 | $partial_refresh_args = wp_parse_args( | 
| 78 | 78 | $partial_refresh_args, array( | 
| 79 | - 'settings' => $field['settings'], | |
| 79 | + 'settings' => $field[ 'settings' ], | |
| 80 | 80 | ) | 
| 81 | 81 | ); | 
| 82 | 82 | $wp_customize->selective_refresh->add_partial( $partial_refresh, $partial_refresh_args ); | 
| @@ -66,10 +66,10 @@ discard block | ||
| 66 | 66 |  	public function custom_css() { | 
| 67 | 67 | |
| 68 | 68 | $config = apply_filters( 'kirki_config', array() ); | 
| 69 | -		if ( ! isset( $config['color_accent'] ) && ! isset( $config['color_back'] ) ) { | |
| 69 | +		if ( ! isset( $config[ 'color_accent' ] ) && ! isset( $config[ 'color_back' ] ) ) { | |
| 70 | 70 | return; | 
| 71 | 71 | } | 
| 72 | - $back = isset( $config['color_back'] ) ? $config['color_back'] : false; | |
| 72 | + $back = isset( $config[ 'color_back' ] ) ? $config[ 'color_back' ] : false; | |
| 73 | 73 | |
| 74 | 74 | $text_on_back = ''; | 
| 75 | 75 | $border_on_back = ''; | 
| @@ -91,7 +91,7 @@ discard block | ||
| 91 | 91 | $hover_on_back = ( 90 < $back_obj->lightness ) ? $back_obj->getNew( 'lightness', $back_obj->lightness - 3 )->toCSS( $back_obj->mode ) : $back_obj->getNew( 'lightness', $back_obj->lightness + 3 )->toCSS( $back_obj->mode ); | 
| 92 | 92 | $arrows_on_back = ( 50 > $back_obj->lightness ) ? $back_obj->getNew( 'lightness', $back_obj->lightness + 30 )->toCSS( $back_obj->mode ) : $back_obj->getNew( 'lightness', $back_obj->lightness - 30 )->toCSS( $back_obj->mode ); | 
| 93 | 93 | } | 
| 94 | - $accent = ( isset( $config['color_accent'] ) ) ? $config['color_accent'] : false; | |
| 94 | + $accent = ( isset( $config[ 'color_accent' ] ) ) ? $config[ 'color_accent' ] : false; | |
| 95 | 95 |  		if ( $accent ) { | 
| 96 | 96 | $accent_obj = ariColor::newColor( $accent ); | 
| 97 | 97 | $text_on_accent = ( 60 > $accent_obj->lightness ) ? $accent_obj->getNew( 'lightness', $accent_obj->lightness + 60 )->toCSS( $accent_obj->mode ) : $accent_obj->getNew( 'lightness', $accent_obj->lightness - 60 )->toCSS( $accent_obj->mode ); | 
| @@ -403,18 +403,18 @@ discard block | ||
| 403 | 403 | color: #444 !important; | 
| 404 | 404 | } | 
| 405 | 405 | |
| 406 | - <?php if ( isset( $config['width'] ) ) : ?> | |
| 406 | + <?php if ( isset( $config[ 'width' ] ) ) : ?> | |
| 407 | 407 |  			.wp-full-overlay-sidebar { | 
| 408 | - width: <?php echo esc_attr( $config['width'] ); ?>; | |
| 408 | + width: <?php echo esc_attr( $config[ 'width' ] ); ?>; | |
| 409 | 409 | } | 
| 410 | 410 |  			.expanded .wp-full-overlay-footer { | 
| 411 | - width: <?php echo esc_attr( $config['width'] ); ?>; | |
| 411 | + width: <?php echo esc_attr( $config[ 'width' ] ); ?>; | |
| 412 | 412 | } | 
| 413 | 413 |  			.wp-full-overlay.expanded { | 
| 414 | - margin-left: <?php echo esc_attr( $config['width'] ); ?>; | |
| 414 | + margin-left: <?php echo esc_attr( $config[ 'width' ] ); ?>; | |
| 415 | 415 | } | 
| 416 | 416 |  			.wp-full-overlay.collapsed .wp-full-overlay-sidebar { | 
| 417 | - margin-left: -<?php echo esc_attr( $config['width'] ); ?>; | |
| 417 | + margin-left: -<?php echo esc_attr( $config[ 'width' ] ); ?>; | |
| 418 | 418 | } | 
| 419 | 419 | <?php endif; ?> | 
| 420 | 420 | </style> | 
| @@ -23,10 +23,10 @@ discard block | ||
| 23 | 23 | */ | 
| 24 | 24 |  	protected function process_output( $output, $value ) { | 
| 25 | 25 | |
| 26 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; | |
| 27 | - $output['element'] = ( isset( $output['element'] ) ) ? $output['element'] : 'body'; | |
| 28 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; | |
| 29 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; | |
| 26 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; | |
| 27 | + $output[ 'element' ] = ( isset( $output[ 'element' ] ) ) ? $output[ 'element' ] : 'body'; | |
| 28 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; | |
| 29 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; | |
| 30 | 30 | |
| 31 | 31 | $value = Kirki_Field_Typography::sanitize( $value ); | 
| 32 | 32 | |
| @@ -48,7 +48,7 @@ discard block | ||
| 48 | 48 |  		foreach ( $properties as $property ) { | 
| 49 | 49 | |
| 50 | 50 | // Early exit if the value is not in the defaults. | 
| 51 | -			if ( ! isset( $this->field['default'][ $property ] ) ) { | |
| 51 | +			if ( ! isset( $this->field[ 'default' ][ $property ] ) ) { | |
| 52 | 52 | continue; | 
| 53 | 53 | } | 
| 54 | 54 | |
| @@ -58,39 +58,39 @@ discard block | ||
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 | // Early exit if we use "choice" but not for this property. | 
| 61 | -			if ( isset( $output['choice'] ) && $output['choice'] !== $property ) { | |
| 61 | +			if ( isset( $output[ 'choice' ] ) && $output[ 'choice' ] !== $property ) { | |
| 62 | 62 | continue; | 
| 63 | 63 | } | 
| 64 | 64 | |
| 65 | 65 | // Take care of variants. | 
| 66 | -			if ( 'variant' === $property && isset( $value['variant'] ) && ! empty( $value['variant'] ) ) { | |
| 66 | +			if ( 'variant' === $property && isset( $value[ 'variant' ] ) && ! empty( $value[ 'variant' ] ) ) { | |
| 67 | 67 | |
| 68 | 68 | // Get the font_weight. | 
| 69 | - $font_weight = str_replace( 'italic', '', $value['variant'] ); | |
| 69 | + $font_weight = str_replace( 'italic', '', $value[ 'variant' ] ); | |
| 70 | 70 | $font_weight = ( in_array( $font_weight, array( '', 'regular' ), true ) ) ? '400' : $font_weight; | 
| 71 | 71 | |
| 72 | 72 | // Is this italic? | 
| 73 | - $is_italic = ( false !== strpos( $value['variant'], 'italic' ) ); | |
| 74 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['font-weight'] = $font_weight; | |
| 73 | + $is_italic = ( false !== strpos( $value[ 'variant' ], 'italic' ) ); | |
| 74 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ 'font-weight' ] = $font_weight; | |
| 75 | 75 |  				if ( $is_italic ) { | 
| 76 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['font-style'] = 'italic'; | |
| 76 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ 'font-style' ] = 'italic'; | |
| 77 | 77 | } | 
| 78 | 78 | continue; | 
| 79 | 79 | } | 
| 80 | 80 | |
| 81 | 81 | $property_value = $this->process_property_value( $property, $value[ $property ] ); | 
| 82 | 82 |  			if ( 'font-family' === $property ) { | 
| 83 | - $value['font-backup'] = ( isset( $value['font-backup'] ) ) ? $value['font-backup'] : ''; | |
| 83 | + $value[ 'font-backup' ] = ( isset( $value[ 'font-backup' ] ) ) ? $value[ 'font-backup' ] : ''; | |
| 84 | 84 | $property_value = $this->process_property_value( | 
| 85 | 85 | $property, array( | 
| 86 | - $value['font-family'], | |
| 87 | - $value['font-backup'], | |
| 86 | + $value[ 'font-family' ], | |
| 87 | + $value[ 'font-backup' ], | |
| 88 | 88 | ) | 
| 89 | 89 | ); | 
| 90 | 90 | } | 
| 91 | - $property = ( isset( $output['choice'] ) && isset( $output['property'] ) ) ? $output['property'] : $property; | |
| 92 | - $property_value = ( is_array( $property_value ) && isset( $property_value[0] ) ) ? $property_value[0] : $property_value; | |
| 93 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $property_value . $output['suffix']; | |
| 91 | + $property = ( isset( $output[ 'choice' ] ) && isset( $output[ 'property' ] ) ) ? $output[ 'property' ] : $property; | |
| 92 | + $property_value = ( is_array( $property_value ) && isset( $property_value[ 0 ] ) ) ? $property_value[ 0 ] : $property_value; | |
| 93 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $property_value . $output[ 'suffix' ]; | |
| 94 | 94 | } | 
| 95 | 95 | } | 
| 96 | 96 | } | 
| @@ -23,7 +23,7 @@ discard block | ||
| 23 | 23 | */ | 
| 24 | 24 |  	protected function process_output( $output, $value ) { | 
| 25 | 25 | |
| 26 | -		if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { | |
| 26 | +		if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { | |
| 27 | 27 | return; | 
| 28 | 28 | } | 
| 29 | 29 | $output = wp_parse_args( | 
| @@ -35,16 +35,16 @@ discard block | ||
| 35 | 35 | ) | 
| 36 | 36 | ); | 
| 37 | 37 |  		if ( is_array( $value ) ) { | 
| 38 | -			if ( isset( $output['choice'] ) && $output['choice'] ) { | |
| 39 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value[ $output['choice'] ] ) . $output['units'] . $output['suffix']; | |
| 38 | +			if ( isset( $output[ 'choice' ] ) && $output[ 'choice' ] ) { | |
| 39 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value[ $output[ 'choice' ] ] ) . $output[ 'units' ] . $output[ 'suffix' ]; | |
| 40 | 40 | return; | 
| 41 | 41 | } | 
| 42 | -			if ( isset( $value['url'] ) ) { | |
| 43 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value['url'] ) . $output['units'] . $output['suffix']; | |
| 42 | +			if ( isset( $value[ 'url' ] ) ) { | |
| 43 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value[ 'url' ] ) . $output[ 'units' ] . $output[ 'suffix' ]; | |
| 44 | 44 | return; | 
| 45 | 45 | } | 
| 46 | 46 | return; | 
| 47 | 47 | } | 
| 48 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; | |
| 48 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; | |
| 49 | 49 | } | 
| 50 | 50 | } |