1 | <?php |
||
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'] : '', |
||
|
|||
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'] : '', |
||
59 |