ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-kirki-field-multicheck.php (1228B)


      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_Multicheck' ) ) {
     13 
     14 	/**
     15 	 * Field overrides.
     16 	 */
     17 	class Kirki_Field_Multicheck 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-multicheck';
     27 
     28 		}
     29 
     30 		/**
     31 		 * Sets the $sanitize_callback
     32 		 *
     33 		 * @access protected
     34 		 */
     35 		protected function set_sanitize_callback() {
     36 
     37 			// If a custom sanitize_callback has been defined,
     38 			// then we don't need to proceed any further.
     39 			if ( ! empty( $this->sanitize_callback ) ) {
     40 				return;
     41 			}
     42 			$this->sanitize_callback = array( $this, 'sanitize' );
     43 
     44 		}
     45 
     46 		/**
     47 		 * The sanitize method that will be used as a falback
     48 		 *
     49 		 * @param string|array $value The control's value.
     50 		 */
     51 		public function sanitize( $value ) {
     52 
     53 			$value = ( ! is_array( $value ) ) ? explode( ',', $value ) : $value;
     54 			return ( ! empty( $value ) ) ? array_map( 'sanitize_text_field', $value ) : array();
     55 
     56 		}
     57 	}
     58 }