Positive-
<?php
define( ‘DONOTCACHEPAGE’, 1 );
?>
<!DOCTYPE HTML>
<html>
<head>
from line 1.
I am wondering if it is a functional issue.
I use the following code in the function.php file to cache the sidebar to a text file that is refreshed by a timed expire. Perhaps I need to rename a variable?
// add sidebar function
function cache($task, $cacheFile, $cacheTime = 600){
global $cache;
// Configure files and directories:
$cacheDir = TEMPLATEPATH.”/cache”;
$cacheFileName = $cacheDir.”/cache-$cacheFile.txt”;
$cacheLogFile = $cacheDir.”/cache-log.txt”;
// Make cache directory if it doesn’t exist
if(!is_dir($cacheDir)) mkdir($cacheDir, 0755);
// Make a log of the cache files with their current status
if(file_exists($cacheLogFile))
$cacheLog = unserialize(file_get_contents($cacheLogFile));
else
$cacheLog = array();
if($task == ‘start’){
// If cache exists, is less than 6 hours old and is not in deletion queue, keep it – otherwise rebuild cache
if(file_exists($cacheFileName) && (time() – filemtime($cacheFileName)) < $cacheTime && $cacheLog[$cacheFile] == 1){
$cache = false;
} else {
$cache = true;
ob_start();
}
}elseif($task == ‘end’ && $cache){
// If caching, save file contents and update log
file_put_contents($cacheFileName,ob_get_contents());
ob_end_flush();
$cacheLog[$cacheFile] = 1;
file_put_contents($cacheLogFile,serialize($cacheLog));
}elseif($task == ‘purge’){
// Set cache to delete and update log
$cacheLog[$cacheFile] = 0;
file_put_contents($cacheLogFile,serialize($cacheLog));
}
}
function cache_purge(){
$cacheDir = TEMPLATEPATH.”/cache”;
$cacheLogFile = $cacheDir.”/cache-log.txt”;
if(file_exists($cacheLogFile))
$cacheLog = unserialize(file_get_contents($cacheLogFile));
else
$cacheLog = array();
foreach($cacheLog as $key=>$value)
$cacheLog[$key] = 0;
file_put_contents($cacheLogFile,serialize($cacheLog));
add_action(‘switch_theme’,’cache_purge’, 10);
add_action(‘publish_post’,’cache_purge’, 10);
add_filter(‘widget_update_callback’,’cache_purge’, 10);
}
This is the file that the cache is pulled from called sidebar-right.php
<?php
cache(‘start’, ‘sidebar’);
/**
* Sidebar Right Template
*
* Please do not edit this file. This file is part of the Cyber Chimps Framework and all modifications
* should be made in a child theme.
*
* @category CyberChimps Framework
* @package Framework
* @since 1.0
* @author CyberChimps
* @license https://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
* @link https://www.cyberchimps.com/
*/
?>
<div id=”secondary” <?php cyberchimps_filter_sidebar_right_class(); ?>>
<?php do_action( ‘cyberchimps_before_sidebar’ ); ?>
<div id=”sidebar”>
<?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar( ‘sidebar-right’ ) ) : ?>
<div class=”widget-container”>
<h3 class=”widget-title”><?php _e(‘Pages’, ‘cyberchimps’ ); ?></h3>
<?php wp_list_pages(‘title_li=’ ); ?>
</div>
<div class=”widget-container”>
<h3 class=”widget-title”><?php _e( ‘Archives’, ‘cyberchimps’ ); ?></h3>
<?php wp_get_archives(‘type=monthly’); ?>
</div>
<div class=”widget-container”>
<h3 class=”widget-title”><?php _e(‘Categories’, ‘cyberchimps’ ); ?></h3>
<?php wp_list_categories(‘show_count=1&title_li=’); ?>
</div>
<div class=”widget-container”>
<h3 class=”widget-title”><?php _e(‘WordPress’, ‘cyberchimps’ ); ?></h3>
</div>
<div class=”widget-container”>
<h3 class=”widget-title”><?php _e(‘Subscribe’, ‘cyberchimps’ ); ?></h3>
</div>
<?php endif; ?>
</div><!– #sidebar –>
<?php do_action( ‘cyberchimps_after_sidebar’ ); ?>
</div><!– #secondary .widget-area .span3 –>
<?php cache(‘end’, ‘sidebar’); ?>
It simply creates a text cache that I use to clone the calendar into the quick access app that I created in bootstrap 3.0 .