WP_Http::buildCookieHeader

Advertisement

Summery Summery

Takes the arguments for a ::request() and checks for the cookie array.

Syntax Syntax

WP_Http::buildCookieHeader( array $r )

Description Description

If it’s found, then it upgrades any basic name => value pairs to WP_Http_Cookie instances, which are each parsed into strings and added to the Cookie: header (within the arguments array). Edits the array by reference.

Parameters Parameters

$r

(Required) Full array of args passed into ::request()

Source Source

File: wp-includes/class-http.php

	 * which are each parsed into strings and added to the Cookie: header (within the arguments array).
	 * Edits the array by reference.
	 *
	 * @since 2.8.0
	 *
	 * @param array $r Full array of args passed into ::request()
	 */
	public static function buildCookieHeader( &$r ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
		if ( ! empty( $r['cookies'] ) ) {
			// Upgrade any name => value cookie pairs to WP_HTTP_Cookie instances.
			foreach ( $r['cookies'] as $name => $value ) {
				if ( ! is_object( $value ) ) {
					$r['cookies'][ $name ] = new WP_Http_Cookie(
						array(
							'name'  => $name,
							'value' => $value,
						)
					);
				}
			}

			$cookies_header = '';
			foreach ( (array) $r['cookies'] as $cookie ) {

Advertisement

Changelog Changelog

Changelog
Version Description
2.8.0 Introduced.

Advertisement

Leave a Reply