} // Add some debug info just before </head> if ($this->debug) { $tag = "<!--\n\tgenerated in " . $cache['timer'] . " seconds\n\t" . strlen(serialize($cache)) . " bytes batcached for " . $this->max_age . " seconds\n-->\n"; if (false !== ($tag_position = strpos($output, '</head>'))) { $tag = "<!--\n\tgenerated in " . $cache['timer'] . " seconds\n\t" . strlen(serialize($cache)) . " bytes batcached for " . $this->max_age . " seconds\n-->\n"; $output = substr($output, 0, $tag_position) . $tag . substr($output, $tag_position); } } // Pass output to next ob handler return $output; } } global $batcache; // Pass in the global variable which may be an array of settings to override defaults. $batcache = new batcache($batcache); if (!defined('WP_CONTENT_DIR')) { return; } // Never batcache interactive scripts or API endpoints. if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('wp-app.php', 'xmlrpc.php', 'ms-files.php'))) { return; } // Never batcache WP javascript generators if (strstr($_SERVER['SCRIPT_FILENAME'], 'wp-includes/js')) { return; } // Never batcache when POST data is present. if (!empty($GLOBALS['HTTP_RAW_POST_DATA']) || !empty($_POST)) { return; }
// Casing on the Content-Type header is inconsistent foreach (array('Content-Type', 'Content-type') as $key) { if (isset($this->cache['headers'][$key][0]) && 0 !== strpos($this->cache['headers'][$key][0], 'text/html')) { return; } } $head_position = strpos($this->cache['output'], '<head'); if (false === $head_position) { return; } $this->cache['output'] .= "\n{$debug_html}"; } } global $batcache; // Pass in the global variable which may be an array of settings to override defaults. $batcache = new batcache($batcache); if (!defined('WP_CONTENT_DIR')) { return; } // Never batcache interactive scripts or API endpoints. if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('wp-app.php', 'xmlrpc.php'))) { return; } // Never batcache WP javascript generators if (strstr($_SERVER['SCRIPT_FILENAME'], 'wp-includes/js')) { return; } // Never batcache when POST data is present. if (!empty($GLOBALS['HTTP_RAW_POST_DATA']) || !empty($_POST)) { return; }
$tag = "<!--\n\tgenerated in " . $cache['timer'] . " seconds\n\t" . strlen(serialize($cache)) . " bytes batcached for " . $this->max_age . " seconds\n-->\n"; if (false !== ($tag_position = strpos($output, '</head>'))) { $tag = "<!--\n\tgenerated in " . $cache['timer'] . " seconds\n\t" . strlen(serialize($cache)) . " bytes batcached for " . $this->max_age . " seconds\n-->\n"; $output = substr($output, 0, $tag_position) . $tag . substr($output, $tag_position); } } if ($this->debug_header) { header(sprintf("X-batcache: Caching, generated in %ums, expires in %us (%us TTL)", $cache['timer'] * 1000, $this->max_age, $this->max_age), true); } // Pass output to next ob handler return $output; } } global $batcache; // Pass in the global variable which may be an array of settings to override defaults. $batcache = new batcache($batcache); if (!defined('WP_CONTENT_DIR')) { return; } // Never batcache interactive scripts or API endpoints. if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('wp-app.php', 'xmlrpc.php', 'ms-files.php'))) { return; } // Never batcache WP javascript generators if (strstr($_SERVER['SCRIPT_FILENAME'], 'wp-includes/js')) { return; } // Never batcache when POST data is present. if (!empty($GLOBALS['HTTP_RAW_POST_DATA']) || !empty($_POST)) { return; }