Cache Blocks
add_filter('wpucacheblocks_blocks', 'demo_wpucacheblocks_blocks', 10, 1);
function demo_wpucacheblocks_blocks($blocks) {
$blocks['headersearch'] = array(
'path' => '/tpl/header/searchform.php'
);
return $blocks;
}
String used to prefix cache keys & cache filenames (only [a-z0-9_] chars). Default : wpucacheblocks_.
Cache method. You can choose between 'file' and 'apc'
Absolute path to the file cache dir.
Path to the file, relative to the Stylesheet Directory. You can also use 'fullpath', which is an absolute path to the file that will be cached.
Duration in seconds after which the block will be refreshed. If 0, the block will never be refreshed in front, only via a hook.
An array of hooks that will trigger a refresh for the block.
A callback for a function to prefix version of each cached block.
echo wpucacheblocks_block('headersearch');
function custom_wpucacheblocks_block($blockid) {
if (function_exists('wpucacheblocks_block')) {
return wpucacheblocks_block($blockid);
}
$blocks = apply_filters('wpucacheblocks_blocks', array());
if (!is_array($blocks) || !isset($blocks[$blockid], $blocks[$blockid]['path'])) {
return '';
}
ob_start();
include $blocks[$blockid]['path'];
return ob_get_clean();
}
echo custom_wpucacheblocks_block('headersearch');