Bill Zeller.
Author: Matt Mullenweg
Author URI: http://photomatt.net/
*/
$http = false; // This controls whether we send etag and last-modified headers or not
define(CACHE_PATH, trailingslashit( ABSPATH . 'wp-content/staticize-cache' ) );
update_option('gzipcompression', 0);
if ( !file_exists(CACHE_PATH) ) :
if ( is_writable( dirname(CACHE_PATH) ) )
$dir = mkdir( CACHE_PATH, 0777);
else
die("Your cache directory (" . CACHE_PATH . "
) needs to be writable for this plugin to work. Double-check it. Deactivate the Staticize Reloaded plugin.");
endif;
// Array of files that have 'wp-' but should still be cached
$acceptableFiles = array(
'wp-atom.php', 'wp-comments-popup.php', 'wp-commentsrss2.php',
'wp-links-opml.php', 'wp-locations.php', 'wp-rdf.php',
'wp-rss.php', 'wp-rss2.php'
);
$staticFileName = '';
function StaticizeInit() {
global $staticFileName, $acceptableFiles, $timestart, $http;
$key = $_SERVER['REQUEST_URI'] . join($_COOKIE, ',');
$script = basename($_SERVER['SCRIPT_NAME']);
if( strstr($_SERVER['SCRIPT_NAME'], 'wp-') && !in_array($script, $acceptableFiles) )
return;
$staticFileName = md5($key) . '.php';
if( is_file(CACHE_PATH . $staticFileName) ) {
if ($http) staticize_header();
include(CACHE_PATH . $staticFileName);
$timetotal = staticize_timer();
echo "\n";
exit;
}
ob_start('StaticizeCallback');
register_shutdown_function('StaticizeEnd');
}
function StaticizeCallback($buffer) {
global $staticFileName, $timestart;
$timetotal = staticize_timer();
if ($timetotal < 0.05) : // Too fast to cache
$buffer .= "\n";
return $buffer;
endif;
if ( strstr($buffer, 'wpdberror') ) // If we detect a $wpdb error
return $buffer;
if ( !strstr($buffer, '