Completed
Pull Request — master (#1454)
by Aristeides
05:30 queued 02:31
created

Kirki_Output_Field_Background::process_output()   B

Complexity

Conditions 9
Paths 96

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 10
nc 96
nop 2
dl 0
loc 15
rs 7.756
c 0
b 0
f 0
1
<?php
2
/**
3
 * Handles CSS output for background 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.0
10
 */
11
12
/**
13
 * Output overrides.
14
 */
15
class Kirki_Output_Field_Background 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
		$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
		$output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global';
31
32
		foreach ( array( 'image', 'color', 'repeat', 'position', 'size', 'attachment' ) as $key ) {
33
			$key = 'background-' . $key;
34
			if ( isset( $value[ $key ] ) && ! empty( $value[ $key ] ) ) {
35
				$this->styles[ $output['media_query'] ][ $output['element'] ][ $key ] = $output['prefix'] . $this->process_property_value( $key, $value[ $key ] ) . $output['suffix'];
36
			}
37
		}
38
	}
39
}
40