wpsc_get_accept_header()
Returns a string containing a sanitized version of the Accept header. For now, this can only respond with text/html or application/json - used to differentiate between pages which may or may not be cacheable.
Хуки из функции
Возвращает
null
. Ничего (null).
Использование
wpsc_get_accept_header();
Код wpsc_get_accept_header() wpsc get accept header WPSCache 1.12.4
function wpsc_get_accept_header() { static $accept = 'N/A'; if ( $accept === 'N/A' ) { $accept_headers = apply_filters( 'wpsc_accept_headers', array( 'application/json', 'application/activity+json', 'application/ld+json' ) ); $accept_headers = array_map( 'strtolower', $accept_headers ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- $accept is checked and set below. $accept = isset( $_SERVER['HTTP_ACCEPT'] ) ? strtolower( filter_var( $_SERVER['HTTP_ACCEPT'] ) ) : ''; foreach ( $accept_headers as $header ) { if ( str_contains( $accept, $header ) ) { $accept = 'application/json'; } } if ( $accept !== 'application/json' ) { $accept = 'text/html'; } wp_cache_debug( 'ACCEPT: ' . $accept ); } return $accept; }