Completed
Pull Request — master (#1592)
by Aristeides
04:27 queued 02:16
created

Kirki_Output_Field_Image   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
C process_output() 0 24 7
1
<?php
2
/**
3
 * Handles CSS output for image fields.
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license     http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
 * @since       3.0.10
10
 */
11
12
/**
13
 * Output overrides.
14
 */
15
class Kirki_Output_Field_Image 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
26
		if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) {
27
			return;
28
		}
29
		$output = wp_parse_args( $output, array(
30
			'media_query' => 'global',
31
			'prefix'      => '',
32
			'units'       => '',
33
			'suffix'      => '',
34
		) );
35
		if ( is_array( $value ) ) {
36
			if ( isset( $output['choice'] ) && $output['choice'] ) {
37
				$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
				return;
39
			}
40
			if ( isset( $value['url'] ) ) {
41
				$this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value['url'] ) . $output['units'] . $output['suffix'];
42
				return;
43
			}
44
			return;
45
		}
46
		$this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix'];
47
	}
48
}
49