Completed
Push — develop ( a7b18c...06977c )
by Aristeides
17:11 queued 04:39
created

Kirki_Field_Image_Array::sanitize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Override field methods
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.7
10
 */
11
12
/**
13
 * Field overrides.
14
 */
15
class Kirki_Field_Image_Array extends Kirki_Field {
16
17
	/**
18
	 * Sets the control type.
19
	 *
20
	 * @access protected
21
	 */
22
	protected function set_type() {
23
24
		$this->type = 'kirki-image-array';
25
26
	}
27
28
	/**
29
	 * Sets the $sanitize_callback
30
	 *
31
	 * @access protected
32
	 */
33
	protected function set_sanitize_callback() {
34
35
		// If a custom sanitize_callback has been defined,
36
		// then we don't need to proceed any further.
37
		if ( ! empty( $this->sanitize_callback ) ) {
38
			return;
39
		}
40
		$this->sanitize_callback = array( $this, 'sanitize' );
41
42
	}
43
44
	/**
45
	 * The sanitize method that will be used as a falback
46
	 *
47
	 * @param string|array $value The control's value.
48
	 */
49
	public function sanitize( $value ) {
50
51
		return array(
52
			'id'     => ( isset( $value['id'] && '' !== $value['id'] ) ) ? (int) $value['id'] : '',
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_BOOLEAN_AND, expecting T_PAAMAYIM_NEKUDOTAYIM
Loading history...
53
			'url'    => ( isset( $value['url'] && '' !== $value['url'] ) ) ? esc_url_raw( $value['url'] ) : '',
54
			'width'  => ( isset( $value['width'] && '' !== $value['width'] ) ) ? (int) $value['width'] : '',
55
			'height' => ( isset( $value['height'] && '' !== $value['height'] ) ) ? (int) $value['height'] : '',
56
		)
57
	}
58
}
59