Issues (377)

css/field/class-kirki-output-field-dimensions.php (1 issue)

1
<?php
2
/**
3
 * Handles CSS output for dimensions fields.
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license    https://opensource.org/licenses/MIT
9
 * @since       2.2.0
10
 */
11
12
/**
13
 * Output overrides.
14
 */
15
class Kirki_Output_Field_Dimensions extends Kirki_Output {
16
17
	/**
18
	 * Processes a single item from the `output` array.
19
	 *
20
	 * @access protected
21
	 * @param array $output The `output` item.
22
	 * @param array $value  The field's value.
23
	 */
24
	protected function process_output( $output, $value ) {
25
		$output = wp_parse_args(
26
			$output, array(
27
				'element'     => '',
28
				'property'    => '',
29
				'media_query' => 'global',
30
				'prefix'      => '',
31
				'suffix'      => '',
32
			)
33
		);
34
35
		if ( ! is_array( $value ) ) {
36
			return;
37
		}
38
39
		foreach ( array_keys( $value ) as $key ) {
40
41
			$property = ( empty( $output['property'] ) ) ? $key : $output['property'] . '-' . $key;
42
			if ( isset( $output['choice'] ) && $output['property'] ) {
43
				if ( $key === $output['choice'] ) {
44
					$property = $output['property'];
45
				} else {
46
					continue;
47
				}
48
			}
49
			if ( false !== strpos( $output['property'], '%%' ) ) {
50
				$property = str_replace( '%%', $key, $output['property'] );
51
			}
52
			$this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $key ] ) . $output['suffix'];
0 ignored issues
show
Are you sure $this->process_property_...property, $value[$key]) of type array can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

52
			$this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . /** @scrutinizer ignore-type */ $this->process_property_value( $property, $value[ $key ] ) . $output['suffix'];
Loading history...
53
		}
54
	}
55
}
56