class-kirki-field-select.php (1424B)
1 <?php 2 /** 3 * Override field methods 4 * 5 * @package Kirki 6 * @subpackage Controls 7 * @copyright Copyright (c) 2016, Aristeides Stathopoulos 8 * @license http://opensource.org/licenses/https://opensource.org/licenses/MIT 9 * @since 2.2.7 10 */ 11 12 if ( ! class_exists( 'Kirki_Field_Select' ) ) { 13 14 /** 15 * Field overrides. 16 */ 17 class Kirki_Field_Select extends Kirki_Field { 18 19 /** 20 * Sets the control type. 21 * 22 * @access protected 23 */ 24 protected function set_type() { 25 26 $this->type = 'kirki-select'; 27 28 } 29 30 /** 31 * Sets the $multiple 32 * 33 * @access protected 34 */ 35 protected function set_multiple() { 36 37 $this->multiple = absint( $this->multiple ); 38 39 } 40 41 /** 42 * Sets the $sanitize_callback 43 * 44 * @access protected 45 */ 46 protected function set_sanitize_callback() { 47 48 // If a custom sanitize_callback has been defined, 49 // then we don't need to proceed any further. 50 if ( ! empty( $this->sanitize_callback ) ) { 51 return; 52 } 53 $this->sanitize_callback = array( $this, 'sanitize' ); 54 55 } 56 57 /** 58 * Sanitizes select control values. 59 * 60 * @since 2.2.8 61 * @access public 62 * @param array $value The value. 63 * @return string|array 64 */ 65 public function sanitize( $value ) { 66 67 if ( is_array( $value ) ) { 68 foreach ( $value as $key => $subvalue ) { 69 $value[ $key ] = esc_attr( $subvalue ); 70 } 71 return $value; 72 } 73 return esc_attr( $value ); 74 75 } 76 } 77 }