Completed
Push — develop ( 78a124...956be6 )
by Aristeides
03:10
created

process_value()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 8
nc 4
nop 0
dl 0
loc 14
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * Handles CSS output for background-image.
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       2.2.0
10
 */
11
12
/**
13
 * Output overrides.
14
 */
15
class Kirki_Output_Property_Background_Image extends Kirki_Output_Property {
16
17
	/**
18
	 * Modifies the value.
19
	 *
20
	 * @access protected
21
	 */
22
	protected function process_value() {
23
24
		if ( false === strpos( $this->value, 'gradient' ) && false === strpos( $this->value, 'url(' ) ) {
25
			if ( empty( $this->value ) ) {
26
				return;
27
			}
28
29
			if ( preg_match( '/^\d+$/', $this->value ) ) {
30
				$this->value = 'url("' . wp_get_attachment_url( $this->value ) . '")';
31
			} else {
32
				$this->value = 'url("' . $this->value . '")';
33
			}
34
		}
35
	}
36
}
37