GravityView
2.17
The best, easiest way to display Gravity Forms entries on your website.
|
Handle caching using transients for GravityView. More...
Public Member Functions | |
__construct ( $form_ids=NULL, $args=array()) | |
add_hooks () | |
Add actions for clearing out caches when entries are updated. More... | |
blacklist_add ( $form_ids) | |
blacklist_remove ( $form_ids) | |
blocklist_add ( $form_ids) | |
Add form IDs to a "blocklist" to force the cache to be refreshed. More... | |
blocklist_remove ( $form_ids) | |
Remove Form IDs from blocklist. More... | |
delete ( $form_ids=NULL) | |
Delete cached transients based on form IDs. More... | |
delete_expired_transients () | |
Delete expired transients. More... | |
entry_added ( $entry, $form) | |
Clear the cache when entries are added via GFAPI::add_entry(). More... | |
entry_created ( $entry, $form) | |
When an entry is created, add the entry's form to the cache blocklist. More... | |
entry_property_changed ( $lead_id, $property_name='', $property_value='', $previous_value='') | |
Force refreshing a cache when an entry is deleted. More... | |
entry_status_changed ( $lead_id, $property_value='', $previous_value='') | |
Force refreshing a cache when an entry is deleted. More... | |
entry_updated ( $form, $lead_id) | |
When an entry is updated, add the entry's form to the cache blocklist. More... | |
get ( $key=null) | |
Get transient result. More... | |
get_key () | |
Allow public access to get transient key. More... | |
in_blacklist ( $form_ids=NULL) | |
Is a form ID in the cache blocklist? More... | |
in_blocklist ( $form_ids=NULL) | |
Is a form ID in the cache blocklist. More... | |
schedule_transient_cleanup () | |
Schedule expired transient cleanup twice a day. More... | |
set ( $content, $filter_name='', $expiration=null) | |
Cache content as a transient. More... | |
use_cache () | |
Check whether to use cached results, if available. More... | |
Data Fields | |
const | BLACKLIST_OPTION_NAME = 'gravityview_cache_blocklist' |
const | BLOCKLIST_OPTION_NAME = 'gravityview_cache_blocklist' |
Protected Member Functions | |
get_cache_key_prefix ( $form_ids=NULL) | |
Calculate the prefix based on the Form IDs. More... | |
set_key () | |
Set the transient key based on the form IDs and the arguments passed to the class. More... | |
Protected Attributes | |
$args | |
$form_ids | |
Private Member Functions | |
blocklist_get () | |
Get the blocklist array. More... | |
Private Attributes | |
$key = '' | |
$use_cache = null | |
Whether to use the cache or not. More... | |
Handle caching using transients for GravityView.
Definition at line 6 of file class-cache.php.
__construct | ( | $form_ids = NULL , |
|
$args = array() |
|||
) |
array | int | $form_ids | Form ID or array of form IDs used in a request |
array | $args | Extra request parameters used to generate the query. This is used to generate the unique transient key. |
Definition at line 46 of file class-cache.php.
References $args, $form_ids, add_hooks(), and set_key().
add_hooks | ( | ) |
Add actions for clearing out caches when entries are updated.
Definition at line 63 of file class-cache.php.
Referenced by __construct().
blacklist_add | ( | $form_ids | ) |
int | array | $form_ids | Form IDs to force to be updated |
Definition at line 319 of file class-cache.php.
References $form_ids, and blocklist_remove().
blacklist_remove | ( | $form_ids | ) |
int | array | $form_ids | Form IDs to add |
Definition at line 353 of file class-cache.php.
References $form_ids, and blocklist_remove().
blocklist_add | ( | $form_ids | ) |
Add form IDs to a "blocklist" to force the cache to be refreshed.
int | array | $form_ids | Form IDs to force to be updated |
Definition at line 283 of file class-cache.php.
References $form_ids, blocklist_get(), and gravityview().
Referenced by entry_added(), entry_created(), entry_property_changed(), entry_status_changed(), and entry_updated().
|
private |
Get the blocklist array.
Definition at line 270 of file class-cache.php.
Referenced by blocklist_add(), and in_blocklist().
blocklist_remove | ( | $form_ids | ) |
Remove Form IDs from blocklist.
int | array | $form_ids | Form IDs to remove |
Definition at line 331 of file class-cache.php.
References $form_ids, and gravityview().
Referenced by blacklist_add(), blacklist_remove(), and use_cache().
delete | ( | $form_ids = NULL | ) |
Delete cached transients based on form IDs.
int | array | $form_ids | Form IDs to delete |
Definition at line 499 of file class-cache.php.
References $form_id, $form_ids, $key, and gravityview().
delete_expired_transients | ( | ) |
Delete expired transients.
The code is copied from the Delete Expired Transients, with slight modifications to track # of results and to get the blog ID dynamically
Definition at line 569 of file class-cache.php.
References gravityview().
entry_added | ( | $entry, | |
$form | |||
) |
Clear the cache when entries are added via GFAPI::add_entry().
array | $entry | The GF Entry array |
array | $form | The GF Form array |
Definition at line 201 of file class-cache.php.
References $entry, GV\$form, blocklist_add(), and gravityview().
entry_created | ( | $entry, | |
$form | |||
) |
When an entry is created, add the entry's form to the cache blocklist.
We don't want old caches; when an entry is added, we want to clear the cache.
array | $entry | GF entry array |
array | $form | GF form array |
Definition at line 186 of file class-cache.php.
References $entry, GV\$form, blocklist_add(), and gravityview().
entry_property_changed | ( | $lead_id, | |
$property_name = '' , |
|||
$property_value = '' , |
|||
$previous_value = '' |
|||
) |
Force refreshing a cache when an entry is deleted.
The gform_delete_lead
action is called before the lead is deleted; we fetch the entry to find out the form ID so it can be added to the blocklist.
int | $lead_id | The Entry ID. |
string | $property_name | The property that was updated. |
string | $property_value | The new value of the property that was updated. |
string | $previous_value | The previous property value before the update. |
Definition at line 134 of file class-cache.php.
References $entry, blocklist_add(), and gravityview().
entry_status_changed | ( | $lead_id, | |
$property_value = '' , |
|||
$previous_value = '' |
|||
) |
Force refreshing a cache when an entry is deleted.
The gform_delete_lead
action is called before the lead is deleted; we fetch the entry to find out the form ID so it can be added to the blocklist.
int | $lead_id | Entry ID |
string | $property_value | Previous value of the lead status passed by gform_update_status hook |
string | $previous_value | Previous value of the lead status passed by gform_update_status hook |
Definition at line 104 of file class-cache.php.
References $entry, blocklist_add(), and gravityview().
entry_updated | ( | $form, | |
$lead_id | |||
) |
When an entry is updated, add the entry's form to the cache blocklist.
array | $form | GF form array |
int | $lead_id | Entry ID |
Definition at line 169 of file class-cache.php.
References GV\$form, blocklist_add(), and gravityview().
get | ( | $key = null | ) |
Get transient result.
string | $key | Transient key to fetch |
Definition at line 414 of file class-cache.php.
References $key, gravityview(), and use_cache().
|
protected |
get_key | ( | ) |
Allow public access to get transient key.
Definition at line 259 of file class-cache.php.
References $key.
in_blacklist | ( | $form_ids = NULL | ) |
Is a form ID in the cache blocklist?
int | array | $form_ids | Form IDs to check if in blocklist |
Definition at line 367 of file class-cache.php.
References $form_ids, and in_blocklist().
in_blocklist | ( | $form_ids = NULL | ) |
Is a form ID in the cache blocklist.
int | array | $form_ids | Form IDs to check if in blocklist |
Definition at line 379 of file class-cache.php.
References $form_id, $form_ids, blocklist_get(), and gravityview().
Referenced by in_blacklist(), and use_cache().
schedule_transient_cleanup | ( | ) |
Schedule expired transient cleanup twice a day.
Can be overruled by the gravityview_cleanup_transients
filter (returns boolean)
gravityview_cleanup_transients
Override GravityView cleanup of transients by setting this to false boolean | $cleanup | Whether to run the GravityView auto-cleanup of transients. Default: true |
Definition at line 543 of file class-cache.php.
set | ( | $content, | |
$filter_name = '' , |
|||
$expiration = null |
|||
) |
Cache content as a transient.
Cache time defaults to 1 day.
mixed | $content | The content to cache. |
string | $filter_name | Name used to modify the cache time. Will be set to gravityview_cache_time_{$filter_name} . |
int | null | $expiration | Cache time in seconds. If not set, DAYS_IN_SECONDS will be used. |
gravityview_cache_time_{$filter_name}
Modify the cache time for a type of cache int | $time_in_seconds | Default: DAY_IN_SECONDS |
Definition at line 460 of file class-cache.php.
References $content, gravityview(), and use_cache().
Referenced by GravityView_Welcome\getting_started_screen().
|
protected |
Set the transient key based on the form IDs and the arguments passed to the class.
Definition at line 238 of file class-cache.php.
References $key, and get_cache_key_prefix().
Referenced by __construct().
use_cache | ( | ) |
Check whether to use cached results, if available.
If the user can edit posts, they are able to override whether to cache results by adding cache
or nocache
to the URL requested.
gravityview_use_cache
Modify whether to use the cache or not boolean | $use_cache | Previous setting |
GravityView_Cache | $this | The GravityView_Cache object |
Definition at line 619 of file class-cache.php.
References $form_ids, $use_cache, blocklist_remove(), gravityview(), GVCommon\has_cap(), and in_blocklist().
Referenced by get(), GravityView_Welcome\getting_started_screen(), and set().
|
protected |
Definition at line 25 of file class-cache.php.
Referenced by __construct().
|
protected |
Definition at line 18 of file class-cache.php.
Referenced by __construct(), blacklist_add(), blacklist_remove(), blocklist_add(), blocklist_remove(), delete(), get_cache_key_prefix(), in_blacklist(), in_blocklist(), and use_cache().
|
private |
|
private |
Whether to use the cache or not.
Set in {
Definition at line 39 of file class-cache.php.
Referenced by use_cache().
const BLACKLIST_OPTION_NAME = 'gravityview_cache_blocklist' |
Definition at line 9 of file class-cache.php.
const BLOCKLIST_OPTION_NAME = 'gravityview_cache_blocklist' |
Definition at line 11 of file class-cache.php.