$value ) { if ( in_array( (string) $key, $exclude, true ) ) { continue; } if ( is_array( $value ) ) { continue; } $out[ sanitize_key( (string) $key ) ] = sanitize_text_field( (string) wp_unslash( $value ) ); } return $out; } private static function sanitize( $value, $type ) { switch ( $type ) { case 'int': return intval( $value ); case 'int_array': if ( is_array( $value ) ) { $out = array(); foreach ( $value as $v ) { $out[] = intval( $v ); } // unique + remove zeros $out = array_values( array_filter( array_unique( $out ), static function ( $n ) { return $n > 0; } ) ); return $out; } // Accept comma/space separated lists as a convenience. $str = (string) $value; if ( trim( $str ) === '' ) { return array(); } $parts = preg_split( '/[^0-9]+/', $str ); if ( ! is_array( $parts ) ) { return array(); } $out = array(); foreach ( $parts as $p ) { $out[] = intval( $p ); } $out = array_values( array_filter( array_unique( $out ), static function ( $n ) { return $n > 0; } ) ); return $out; case 'bool': return (bool) $value; case 'key': return sanitize_key( (string) $value ); case 'url': return esc_url_raw( (string) $value ); case 'html': return wp_kses_post( (string) $value ); case 'raw': return $value; default: return sanitize_text_field( (string) $value ); } } // phpcs:enable } }