Sanitize a value

@param   mixed  $value Input string/array-of-string to be 'cleaned'
@return  mixed   'Cleaned' version of input parameter
558915
public function sanitize($value)
    {
        $value = (string) $value;

        // Filter var for XSS and other 'bad' code etc.
        if (!empty ($value)) {
            $value = $this->_remove($this->_decode($value));
        }

        return $value;
    }
1069944
protected function sanitizePercent($value)
    {
        if ($value instanceof Price) {
            return (string) $value->getTaxPercent();
        }

        return (string) Price::round($value);
    }
831894
public function stripTags($value)
	{
		if ( ! is_array($value))
		{
			$value = filter_var($value, FILTER_SANITIZE_STRING);
		}
		else
		{
			foreach ($value as $k => $v)
			{
				$value[$k] = $this->stripTags($v);
			}
		}

		return $value;
	}
1144840
protected function _sanitize($value)
    {
        $value = trim($value);

        $parts  = explode('-', $value, 2);
        if (2 != count($parts)) {
            return null;
        }

        $parts[0]   = substr(preg_replace('/[^a-z]*/', '', $parts[0]), 0, 2);
        $parts[1]   = substr(preg_replace('/[^A-Z]*/', '', $parts[1]), 0, 2);
        $result = implode('-', $parts);

        // just making sure :-)
        if ($this->_validate($result)) {
            return $result;
        }

        return null;
    }
652203
private static function sanitizeString($value)
    {
        // $_GET and $_REQUEST already urldecode()'d
        // decode
        // note: before php 5.2.7, htmlspecialchars() double encodes &#x hex items
        $value = html_entity_decode($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');

        $value = self::sanitizeNullBytes($value);

        // escape
        $tmp = @htmlspecialchars($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');

        // note: php 5.2.5 and above, htmlspecialchars is destructive if input is not UTF-8
        if ($value != '' && $tmp == '') {
            // convert and escape
            $value = utf8_encode($value);
            $tmp = htmlspecialchars($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');
            return $tmp;
        }
        return $tmp;
    }
923479
public function get_sanitization_value( $value ) {
		if ( $this->is_repeatable() && is_callable( $sanitizer = $this->get_option( 'sanitization_cb' ) ) ) {
			$sanitized = is_array( $value ) ? array_map( $sanitizer, $value ) : [];

			return Utils::filter_blank( $sanitized );
		}

		return $this->sanitization_cb( $value );
	}
74832
protected function _sanitize($value)
    {
        if (null === $this->_charList) {
            return trim((string) $value);
        } else {
            return trim((string) $value, $this->_charList);
        }
    }
493324
protected function _sanitize($value)
    {
        $value = (string) $value;

        // Filter var for XSS and other 'bad' code etc.
        if (!empty($value)) {
            $value = $this->_remove($this->_decode($value));
        }

        return $value;
    }
1158745
public static function prep_value($value) {
		if (\is_array($value)) {
			$value=implode(",", $value);
		}
		if (self::containsCode($value)===false) {
			$value=\str_replace(["\\","\""], ["\\\\","\\\""], $value);
			$value='"'.$value.'"';
		}
		return trim($value,"%");
	}
336688
public function validate($value)
    {
        $value = trim($value);
        return ((string) $value === $this->sanitize($value));
    }
783528
public function sanitize( $value = [] ) {
		if ( is_string( $value ) || is_numeric( $value ) ) {
			return [
				sanitize_text_field( $value ),
			];
		}
		$sanitized_value = [];
		foreach ( $value as $sub_value ) {
			if ( isset( $this->choices[ $sub_value ] ) ) {
				$sanitized_value[] = sanitize_text_field( $sub_value );
			}
		}
		return $sanitized_value;
	}
1305698
public function wrapSanitizer($value)
    {
        // Its a raw query, just cast as string, object has __toString()
        if ($value instanceof Raw) {
            return (string)$value;
        }

        if ($value instanceof \Closure) {
            return $value;
        }

        // Separate our table and fields which are joined with a ".", like my_table.id
        $valueArr = explode('.', $value, 2);

        foreach ($valueArr as $key => $subValue) {
            // Don't wrap if we have *, which is not a usual field
            $valueArr[$key] = trim($subValue) === '*' ? $subValue : static::SANITIZER . $subValue . static::SANITIZER;
        }

        // Join these back with "." and return
        return implode('.', $valueArr);
    }
1045968
public static function sanitize( $value ) {
		if ( class_exists( '\Kirki\Field\Color' ) ) {
			return \Kirki\Field\Color::sanitize( $value );
		}
		return esc_attr( $value );
	}
310651
protected function sanitizeValue($str)
    {
        if (is_array($str)) {
            foreach ($str as &$value) {
                $value = $this->sanitizeValue($value);
            }
            unset($value);

            return $str;
        }

        $str = filter_var((string) $str, FILTER_UNSAFE_RAW, array('flags' => FILTER_FLAG_STRIP_LOW));
        $str = trim($str);

        return $str;
    }
1114647
public static function FILTER_SANITIZE_PERSON_NAME($value)
	{
		$value = preg_replace('/\s+/', ' ', $value);			// no multiple spaces,
		$value = mb_strtoupper($value,'UTF-8');					// move to upper (preserving accents)
		$value = trim($value); 									// no trailing and ending blancs
		
		return $value?:null;									// multibyte uppercase
	}
800980
public static function clean($value) {
    if (!get_magic_quotes_gpc() && !self::$forceStripSlashes) return $value;
    
    return is_array($value) ?
            array_map(array('GPC','clean'), $value) :
            stripslashes($value);
  }
1211597
public function sanitize($value)
    {
        foreach($this->_queue as $filter) {
            $value = $filter->sanitize($value);
        }

        return $value;
    }