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.10.0
function wpsc_get_accept_header() { static $accept = 'N/A'; if ( $accept === 'N/A' ) { $json_list = array( 'application/json', 'application/activity+json', 'application/ld+json' ); // 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 ( $json_list as $header ) { if ( strpos( $accept, $header ) ) { $accept = 'application/json'; } } if ( $accept !== 'application/json' ) { $accept = 'text/html'; } wp_cache_debug( 'ACCEPT: ' . $accept ); } return $accept; }