WP_Http::normalize_cookies()
Normalizes cookies for using in Requests.
Method of the class: WP_Http{}
No Hooks.
Return
WpOrg\Requests\Cookie\Jar
. Cookie holder object.
Usage
$result = WP_Http::normalize_cookies( $cookies );
- $cookies(array) (required)
- Array of cookies to send with the request.
Changelog
Since 4.6.0 | Introduced. |
WP_Http::normalize_cookies() WP Http::normalize cookies code WP 6.6.2
public static function normalize_cookies( $cookies ) { $cookie_jar = new WpOrg\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 WpOrg\Requests\Cookie( (string) $value->name, $value->value, $attributes, array( 'host-only' => $value->host_only ) ); } elseif ( is_scalar( $value ) ) { $cookie_jar[ $name ] = new WpOrg\Requests\Cookie( (string) $name, (string) $value ); } } return $cookie_jar; }