Skip to content

Instantly share code, notes, and snippets.

@lewg
Created September 12, 2012 18:40
Show Gist options
  • Save lewg/3708966 to your computer and use it in GitHub Desktop.
Save lewg/3708966 to your computer and use it in GitHub Desktop.
WordPress config for batcache + wptouch
<?php
/* Custom Config for Batcache */
// Determine if this is a WP Touch User Agent
function is_wptouch_user_agent() {
// This needs to match your WP Touch list!!
$useragents = array(
// Apple iOS/Webkit
"iphone", "ipod", "incognito", "webmate",
// Android OS
"android", "dream", "cupcake", "froyo",
// Blackberry Storm/Torch/Bold 3
"blackberry9500", "blackberry9520", "blackberry9530", "blackberry9550",
"blackberry 9800", "blackberry 9850", "blackberry 9860", "blackberry 9780",
// Windows Phone 7
"iemobile/7.0",
// Palm Pre/Pixi
"webos",
// Samsung
"s8000", "bada",
// Other
"googlebot-mobile", "adsbot-google"
);
$browser_agent = $_SERVER['HTTP_USER_AGENT'];
$is_wptouch_ua = false;
foreach ( $useragents as $useragent ) {
if ( preg_match( "#$useragent#i", $browser_agent ) ) {
$is_wptouch_ua = true;
break;
}
}
return($is_wptouch_ua);
}
global $batcache;
$batcache['unique']['wptouch'] = is_wptouch_user_agent();
/* Enable Page Cache */
define('WP_CACHE', true);
@r-a-y
Copy link

r-a-y commented Apr 9, 2014

Thanks for this! I guess we can't use Batcache for mobile users, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment