Completed
Push — develop ( 86b8b3...86b8b3 )
by Aristeides
06:38 queued 04:32
created

Kirki_Output_Field_Background   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 18
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
F process_output() 0 38 18
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
		// Background-image.
33
		if ( isset( $value['background-image'] ) && ! empty( $value['background-image'] ) ) {
34
			$this->styles[ $output['media_query'] ][ $output['element'] ]['background-image'] = $output['prefix'] . $this->process_property_value( 'background-image', $value['background-image'] ) . $output['suffix'];
35
		}
36
37
		// Background-color.
38
		if ( isset( $value['background-color'] ) && ! empty( $value['background-color'] ) ) {
39
			$this->styles[ $output['media_query'] ][ $output['element'] ]['background-color'] = $output['prefix'] . $this->process_property_value( 'background-color', $value['background-color'] ) . $output['suffix'];
40
		}
41
42
		// Background-repeat.
43
		if ( isset( $value['background-repeat'] ) && ! empty( $value['background-repeat'] ) ) {
44
			$this->styles[ $output['media_query'] ][ $output['element'] ]['background-repeat'] = $output['prefix'] . $this->process_property_value( 'background-repeat', $value['background-repeat'] ) . $output['suffix'];
45
		}
46
47
		// Background-position.
48
		if ( isset( $value['background-position'] ) && ! empty( $value['background-position'] ) ) {
49
			$this->styles[ $output['media_query'] ][ $output['element'] ]['background-position'] = $output['prefix'] . $this->process_property_value( 'background-position', $value['background-position'] ) . $output['suffix'];
50
		}
51
52
		// Background-size.
53
		if ( isset( $value['background-size'] ) && ! empty( $value['background-size'] ) ) {
54
			$this->styles[ $output['media_query'] ][ $output['element'] ]['background-size'] = $output['prefix'] . $this->process_property_value( 'background-size', $value['background-size'] ) . $output['suffix'];
55
		}
56
57
		// Background-attachment.
58
		if ( isset( $value['background-attachment'] ) && ! empty( $value['background-attachment'] ) ) {
59
			$this->styles[ $output['media_query'] ][ $output['element'] ]['background-attachment'] = $output['prefix'] . $this->process_property_value( 'background-attachment', $value['background-attachment'] ) . $output['suffix'];
60
		}
61
	}
62
}
63