Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/WordPressUtilities/wpucacheblocks
Cache Blocks
https://github.com/WordPressUtilities/wpucacheblocks
wordpress wordpress-plugin
Last synced: 3 months ago
JSON representation
Cache Blocks
- Host: GitHub
- URL: https://github.com/WordPressUtilities/wpucacheblocks
- Owner: WordPressUtilities
- License: mit
- Created: 2017-01-07T16:20:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-02T15:57:43.000Z (over 1 year ago)
- Last Synced: 2024-08-02T08:09:38.834Z (6 months ago)
- Topics: wordpress, wordpress-plugin
- Language: PHP
- Size: 42 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-wp-speed-up - Cache Blocks - Cache blocks. (Caching Helping Plugins)
README
# WPU Cache Blocks
Cache Blocks
## How to setup blocks.
```php
add_filter('wpucacheblocks_blocks', 'demo_wpucacheblocks_blocks', 10, 1);
function demo_wpucacheblocks_blocks($blocks) {
$blocks['headersearch'] = array(
'path' => '/tpl/header/searchform.php'
);
return $blocks;
}
```### Global settings :
#### filter : wpucacheblocks_cacheprefix (string: default wpucacheblocks_)
String used to prefix cache keys & cache filenames (only [a-z0-9_] chars). Default : *wpucacheblocks_*.
#### filter : wpucacheblocks_cachetype (string: default file)
Cache method. You can choose between 'file' and 'apc'
#### filter : wpucacheblocks_cachedir (string: default wp-content/uploads/wpucacheblocks/)
Absolute path to the file cache dir.
### Settings per block :
#### path (string)
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.#### expires (int: default 3600)
Duration in seconds after which the block will be refreshed.
If 0, the block will never be refreshed in front, only via a hook.#### reload_hooks (array of callbacks)
An array of hooks that will trigger a refresh for the block.
#### callback_prefix (callback function)
A callback for a function to prefix version of each cached block.
## How to display a block content.
```php
echo wpucacheblocks_block('headersearch');
```## Custom function to allow plugin deactivation :
```php
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');
```