abstracts
2 years ago
admin
2 years ago
elementor
4 years ago
export
3 years ago
fields
2 years ago
interfaces
8 years ago
libraries
2 years ago
log-handlers
4 years ago
shortcodes
2 years ago
stats
3 years ago
templates
5 years ago
class-everest-forms.php
2 years ago
class-evf-ajax.php
2 years ago
class-evf-autoloader.php
7 years ago
class-evf-background-updater.php
7 years ago
class-evf-cache-helper.php
6 years ago
class-evf-cron.php
3 years ago
class-evf-deprecated-action-hooks.php
6 years ago
class-evf-deprecated-filter-hooks.php
5 years ago
class-evf-emails.php
2 years ago
class-evf-fields.php
2 years ago
class-evf-form-block.php
4 years ago
class-evf-form-handler.php
3 years ago
class-evf-form-task.php
2 years ago
class-evf-forms-features.php
2 years ago
class-evf-frontend-scripts.php
2 years ago
class-evf-install.php
2 years ago
class-evf-integrations.php
7 years ago
class-evf-log-levels.php
8 years ago
class-evf-logger.php
5 years ago
class-evf-post-types.php
5 years ago
class-evf-privacy.php
6 years ago
class-evf-session-handler.php
7 years ago
class-evf-shortcodes.php
4 years ago
class-evf-smart-tags.php
2 years ago
class-evf-template-loader.php
2 years ago
class-evf-validation.php
6 years ago
evf-conditional-functions.php
6 years ago
evf-core-functions.php
2 years ago
evf-deprecated-functions.php
6 years ago
evf-entry-functions.php
3 years ago
evf-formatting-functions.php
4 years ago
evf-notice-functions.php
4 years ago
evf-template-functions.php
4 years ago
evf-template-hooks.php
7 years ago
evf-update-functions.php
5 years ago
class-evf-cache-helper.php
91 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Cache Helper Class |
| 4 | * |
| 5 | * @class EVF_Cache_Helper |
| 6 | * @version 1.0.0 |
| 7 | * @package EverestForms/Classes |
| 8 | */ |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | /** |
| 13 | * EVF_Cache_Helper Class. |
| 14 | */ |
| 15 | class EVF_Cache_Helper { |
| 16 | |
| 17 | /** |
| 18 | * Hook in methods. |
| 19 | */ |
| 20 | public static function init() { |
| 21 | add_action( 'admin_notices', array( __CLASS__, 'notices' ) ); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Get prefix for use with wp_cache_set. Allows all cache in a group to be invalidated at once. |
| 26 | * |
| 27 | * @param string $group Group of cache to get. |
| 28 | * @return string |
| 29 | */ |
| 30 | public static function get_cache_prefix( $group ) { |
| 31 | $prefix = wp_cache_get( 'evf_' . $group . '_cache_prefix', $group ); |
| 32 | |
| 33 | if ( false === $prefix ) { |
| 34 | $prefix = 1; |
| 35 | wp_cache_set( 'evf_' . $group . '_cache_prefix', $prefix, $group ); |
| 36 | } |
| 37 | |
| 38 | return 'evf_cache_' . $prefix . '_'; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Increment group cache prefix (invalidates cache). |
| 43 | * |
| 44 | * @param string $group Group of cache to clear. |
| 45 | */ |
| 46 | public static function incr_cache_prefix( $group ) { |
| 47 | wp_cache_incr( 'evf_' . $group . '_cache_prefix', 1, $group ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Set constants to prevent caching by some plugins. |
| 52 | * |
| 53 | * @param mixed $return Value to return. Previously hooked into a filter. |
| 54 | * @return mixed |
| 55 | */ |
| 56 | public static function set_nocache_constants( $return = true ) { |
| 57 | evf_maybe_define_constant( 'DONOTCACHEPAGE', true ); |
| 58 | evf_maybe_define_constant( 'DONOTCACHEOBJECT', true ); |
| 59 | evf_maybe_define_constant( 'DONOTCACHEDB', true ); |
| 60 | return $return; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Notices function. |
| 65 | */ |
| 66 | public static function notices() { |
| 67 | if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | $config = w3_instance( 'W3_Config' ); |
| 72 | $enabled = $config->get_integer( 'dbcache.enabled' ); |
| 73 | $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
| 74 | |
| 75 | if ( $enabled && ! in_array( '_evf_session_', $settings, true ) ) { |
| 76 | ?> |
| 77 | <div class="error"> |
| 78 | <p> |
| 79 | <?php |
| 80 | /* translators: 1: key 2: URL */ |
| 81 | echo wp_kses_post( sprintf( __( 'In order for <strong>database caching</strong> to work with Everest Forms you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'everest-forms' ), '<code>_evf_session_</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ) ); |
| 82 | ?> |
| 83 | </p> |
| 84 | </div> |
| 85 | <?php |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | EVF_Cache_Helper::init(); |
| 91 |