wp_cache_check_mobile()WPSCache 1.0

From https://wordpress.org/plugins/wordpress-mobile-edition/ by Alex King

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wp_cache_check_mobile( $cache_key );
$cache_key (обязательный)
-

Код wp_cache_check_mobile() WPSCache 1.12.0

function wp_cache_check_mobile( $cache_key ) {
	global $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
	if ( ! isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled ) {
		return $cache_key;
	}

	// a check of wp_is_mobile() should be added here, but if the Jetpack WPSC plugin
	// is enabled, jetpack_is_mobile() is used through the wp_cache_check_mobile action.

	wp_cache_debug( "wp_cache_check_mobile: $cache_key" );

	// allow plugins to short circuit mobile check. Cookie, extra UA checks?
	switch ( do_cacheaction( 'wp_cache_check_mobile', $cache_key ) ) {
		case 'normal':
			wp_cache_debug( 'wp_cache_check_mobile: desktop user agent detected by wp_cache_check_mobile action' );
			return $cache_key;
		break;
		case 'mobile':
			wp_cache_debug( 'wp_cache_check_mobile: mobile user agent detected by wp_cache_check_mobile action' );
			return $cache_key . '-mobile';
		break;
	}

	if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
		return $cache_key;
	}

	if ( do_cacheaction( 'disable_mobile_check', false ) ) {
		wp_cache_debug( 'wp_cache_check_mobile: disable_mobile_check disabled mobile check' );
		return $cache_key;
	}

	$browsers   = explode( ',', $wp_cache_mobile_browsers );
	$user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
	foreach ( $browsers as $browser ) {
		if ( strstr( $user_agent, trim( strtolower( $browser ) ) ) ) {
			wp_cache_debug( 'mobile browser detected: ' . $browser );
			return $cache_key . '-' . wp_cache_mobile_group( $user_agent );
		}
	}
	if ( isset( $_SERVER['HTTP_X_WAP_PROFILE'] ) ) {
		return $cache_key . '-' . $_SERVER['HTTP_X_WAP_PROFILE'];
	}
	if ( isset( $_SERVER['HTTP_PROFILE'] ) ) {
		return $cache_key . '-' . $_SERVER['HTTP_PROFILE'];
	}

	if ( isset( $wp_cache_mobile_prefixes ) ) {
		$browsers = explode( ',', $wp_cache_mobile_prefixes );
		foreach ( $browsers as $browser_prefix ) {
			if ( substr( $user_agent, 0, 4 ) == $browser_prefix ) {
				wp_cache_debug( 'mobile browser (prefix) detected: ' . $browser_prefix );
				return $cache_key . '-' . $browser_prefix;
			}
		}
	}
	$accept = isset( $_SERVER['HTTP_ACCEPT'] ) ? strtolower( $_SERVER['HTTP_ACCEPT'] ) : '';
	if ( str_contains( $accept, 'wap' ) ) {
		return $cache_key . '-' . 'wap';
	}

	if ( isset( $_SERVER['ALL_HTTP'] ) && strpos( strtolower( $_SERVER['ALL_HTTP'] ), 'operamini' ) !== false ) {
		return $cache_key . '-' . 'operamini';
	}

	return $cache_key;
}