Skip to content

Instantly share code, notes, and snippets.

@lewg
Created September 12, 2012 18:40
Show Gist options
  • Select an option

  • Save lewg/3708966 to your computer and use it in GitHub Desktop.

Select an option

Save lewg/3708966 to your computer and use it in GitHub Desktop.

Revisions

  1. lewg created this gist Sep 12, 2012.
    41 changes: 41 additions & 0 deletions wp-config-batcache.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    <?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);