WP_Http::normalize_cookies()public staticWP 4.6.0

Normalizes cookies for using in Requests.

{} Это метод класса: WP_Http{}

Хуков нет.

Возвращает

Requests_Cookie_Jar. Cookie holder object.

Использование

$result = WP_Http::normalize_cookies( $cookies );
$cookies(массив) (обязательный)
Array of cookies to send with the request.

Список изменений

С версии 4.6.0 Введена.

Код WP_Http::normalize_cookies() WP 6.0.2

public static function normalize_cookies( $cookies ) {
	$cookie_jar = new Requests_Cookie_Jar();

	foreach ( $cookies as $name => $value ) {
		if ( $value instanceof WP_Http_Cookie ) {
			$attributes                 = array_filter(
				$value->get_attributes(),
				static function( $attr ) {
					return null !== $attr;
				}
			);
			$cookie_jar[ $value->name ] = new Requests_Cookie( $value->name, $value->value, $attributes, array( 'host-only' => $value->host_only ) );
		} elseif ( is_scalar( $value ) ) {
			$cookie_jar[ $name ] = new Requests_Cookie( $name, $value );
		}
	}

	return $cookie_jar;
}