Skip to content

Instantly share code, notes, and snippets.

@danpette
Created January 8, 2015 07:47
Show Gist options
  • Save danpette/28098bd7d55c19fbaaa7 to your computer and use it in GitHub Desktop.
Save danpette/28098bd7d55c19fbaaa7 to your computer and use it in GitHub Desktop.
$now = time();
$cache_timer = get_option('frontpage_categories_box_cachetime', $now);
if ($cache_timer > $now) {
$content = get_option('frontpage_cateogires_box_content');
if (empty($content)) {
ob_start();
include 'views/frontpage_categories_box.php';
$content = ob_get_clean();
update_option('frontpage_cateogires_box_content', $content);
update_option('frontpage_categories_box_cachetime', (time() + (60 * 60)));
}
return $content;
}
else {
ob_start();
include 'views/frontpage_categories_box.php';
$content = ob_get_clean();
update_option('frontpage_categories_box_cachetime', (time() + (60 * 60)));
update_option('frontpage_cateogires_box_content', $content);
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment