Retrieves the Content-Type of the request.
Source
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 ( ! str_contains( $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;
}
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.