Uses
Uses | Description |
---|---|
wp-includes/rest-api/class-wp-rest-request.php: WP_REST_Request::get_header() | Retrieves the given header from the request. |
Retrieves the content-type of the request.
(array|null) Map containing 'value' and 'parameters' keys or null when no valid content-type header was available.
File: wp-includes/rest-api/class-wp-rest-request.php
public function get_content_type() { $value = $this->get_header( 'content-type' ); if ( empty( $value ) ) { return null; } $parameters = ''; if ( strpos( $value, ';' ) ) { list( $value, $parameters ) = explode( ';', $value, 2 ); } $value = strtolower( $value ); if ( false === strpos( $value, '/' ) ) { return null; } // Parse type and subtype out. list( $type, $subtype ) = explode( '/', $value, 2 ); $data = compact( 'value', 'type', 'subtype', 'parameters' ); $data = array_map( 'trim', $data ); return $data; }
Version | Description |
---|---|
4.4.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_request/get_content_type