/**
  * Creates or returns an instance of this class.
  * @since  1.0.0
  * @return cmb_Meta_Box_Sanitize A single instance of this class.
  */
 public static function get()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemplo n.º 2
0
 /**
  * Checks if field has a registered validation callback
  * @since  1.0.1
  * @param  mixed $meta_value Meta value
  * @param  array $field      Field config array
  * @return mixed             Possibly validated meta value
  */
 public static function sanitization_cb($meta_value, $field = array())
 {
     if (empty($meta_value)) {
         return $meta_value;
     }
     $field = $field !== array() ? $field : self::$field;
     // Check if the field has a registered validation callback
     $cb = self::maybe_callback($field, 'sanitization_cb');
     if (false === $cb) {
         // If requestion NO validation, return meta value
         return $meta_value;
     } elseif ($cb) {
         // Ok, callback is good, let's run it.
         return call_user_func($cb, $meta_value, $field);
     }
     // Validation via 'cmb_Meta_Box_Sanitize' (with fallback filter)
     return call_user_func(array(cmb_Meta_Box_Sanitize::get(), $field['type']), $meta_value, $field);
 }