Created
September 12, 2012 18:40
-
-
Save lewg/3708966 to your computer and use it in GitHub Desktop.
WordPress config for batcache + wptouch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! I guess we can't use Batcache for mobile users, right?