Exemplo n.º 1
0
 /**
  * Escape the value before output. Defaults to 'esc_attr()'
  * @since  1.0.1
  * @param  mixed  $meta_value Meta value
  * @param  mixed  $func       Escaping function (if not esc_attr())
  * @return mixed              Final value
  */
 public static function esc($meta_value, $func = '')
 {
     $field = cmb_Meta_Box::$field;
     // Check if the field has a registered escaping callback
     $cb = cmb_Meta_Box::maybe_callback($field, 'escape_cb');
     if (false === $cb) {
         // If requesting NO escaping, return meta value
         return $meta_value;
     } elseif ($cb) {
         // Ok, callback is good, let's run it.
         return call_user_func($cb, $meta_value, $field);
     }
     // Or custom escaping filter can be used
     $esc = apply_filters('cmb_types_esc_' . $field['type'], null, $meta_value, $field);
     if (null !== $esc) {
         return $esc;
     }
     // escaping function passed in?
     $func = is_string($func) && !empty($func) ? $func : 'esc_attr';
     $meta_value = !empty($meta_value) ? $meta_value : $field['default'];
     return call_user_func($func, $meta_value);
 }