PluginProbe ʕ •ᴥ•ʔ
Custom Twitter Feeds – A Tweets Widget or X Feed Widget / 2.7.0
Custom Twitter Feeds – A Tweets Widget or X Feed Widget v2.7.0
2.8.0 2.7.0 2.6.1 2.6.0 1.0 1.0.1 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3 1.4 1.4.1 1.5 1.5.1 1.6 1.6.1 1.7 1.8 1.8.1 1.8.2 1.8.3 1.8.4 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1 2.1.1 2.1.2 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.5.4 2.5.5 trunk
custom-twitter-feeds / inc / Admin / CTF_Cache_Handler.php
custom-twitter-feeds / inc / Admin Last commit date
Traits 1 month ago CTF_About_Us.php 1 month ago CTF_Admin_Notices.php 1 month ago CTF_Cache_Handler.php 1 month ago CTF_Global_Settings.php 1 month ago CTF_HTTP_Request.php 1 month ago CTF_New_User.php 1 month ago CTF_Notifications.php 1 month ago CTF_Response.php 1 month ago CTF_Support.php 1 month ago CTF_Upgrader.php 1 month ago CTF_View.php 1 month ago PluginSilentUpgrader.php 1 month ago PluginSilentUpgraderSkin.php 1 month ago SB_Twitter_Cache.php 1 month ago addon-functions.php 1 month ago class-install-skin.php 1 month ago
CTF_Cache_Handler.php
190 lines
1 <?php
2
3 namespace TwitterFeed\Admin;
4 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
5
6 /**
7 * Custom Twitter Feed Cache Handler.
8 *
9 * @since 2.0
10 */
11 class CTF_Cache_Handler {
12
13 /**
14 * Clears all cache.
15 *
16 * @return void
17 */
18 public function clear_all_cache() {
19 $this->clear_db_caches();
20 $this->clear_third_party_caches();
21 }
22
23 /**
24 * Clear the stored caches from the database.
25 *
26 * @since 2.0
27 */
28 public function clear_db_caches() {
29 global $wpdb;
30
31 $cache_table_name = $wpdb->prefix . 'ctf_feed_caches';
32
33 $sql = "UPDATE $cache_table_name
34 SET cache_value = ''
35 WHERE cache_key NOT LIKE 'ctf_!_%';";
36
37 $wpdb->query( $sql );
38
39 $sql = "DELETE FROM $cache_table_name
40 WHERE feed_id LIKE '%_CUSTOMIZER';";
41
42 $wpdb->query( $sql );
43
44 $this->clear_legacy_caches();
45 }
46
47 public function clear_single_feed_cache( $feed_id ) {
48 global $wpdb;
49
50 $cache_table_name = $wpdb->prefix . 'ctf_feed_caches';
51
52 $wpdb->query( $wpdb->prepare(
53 "UPDATE $cache_table_name
54 SET cache_value = ''
55 WHERE cache_key NOT LIKE 'ctf_!_%'
56 AND feed_id = %s;", $feed_id
57 ) );
58
59 $wpdb->query( $wpdb->prepare(
60 "UPDATE $cache_table_name
61 SET cache_value = ''
62 WHERE cache_key NOT LIKE 'ctf_!_%'
63 AND feed_id = %s;", $feed_id . '_CUSTOMIZER'
64 ) );
65
66 $wpdb->query( $wpdb->prepare(
67 "UPDATE $cache_table_name
68 SET last_updated = '2000-04-04 00:00:00'
69 WHERE cache_key NOT LIKE 'ctf_!_%'
70 AND feed_id = %s;", $feed_id . '_CUSTOMIZER'
71 ) );
72
73 $wpdb->query( $wpdb->prepare(
74 "UPDATE $cache_table_name
75 SET last_updated = '2000-04-04 00:00:00'
76 WHERE cache_key NOT LIKE 'ctf_!_%'
77 AND feed_id = %s;", $feed_id
78 ) );
79 }
80
81 public function clear_legacy_caches() {
82 global $wpdb;
83
84 $cache_table_name = $wpdb->prefix . 'ctf_feed_caches';
85
86 $sql = "UPDATE $cache_table_name
87 SET cache_value = ''
88 WHERE feed_id = 'legacy';";
89
90 $wpdb->query( $sql );
91
92 global $wpdb;
93
94 //Delete all CTF transients
95 $table_name = $wpdb->prefix . "options";
96 $wpdb->query( "
97 DELETE
98 FROM $table_name
99 WHERE `option_name` LIKE ('%\_transient\_ctf\_%')
100 " );
101 $wpdb->query( "
102 DELETE
103 FROM $table_name
104 WHERE `option_name` LIKE ('%\_transient\_timeout\_ctf\_%')
105 " );
106 $wpdb->query( "
107 DELETE
108 FROM $table_name
109 WHERE `option_name` LIKE ('%\_transient\_&ctf\_%')
110 " );
111 $wpdb->query( "
112 DELETE
113 FROM $table_name
114 WHERE `option_name` LIKE ('%\_transient\_timeout\_&ctf\_%')
115 " );
116 $wpdb->query( "
117 DELETE
118 FROM $table_name
119 WHERE `option_name` LIKE ('%\_transient\_\$ctf\_%')
120 " );
121 $wpdb->query( "
122 DELETE
123 FROM $table_name
124 WHERE `option_name` LIKE ('%\_transient\_timeout\_\$ctf\_%')
125 " );
126 }
127
128 /**
129 * Clears the third party cache.
130 *
131 * When certain events occur, page caches need to
132 * clear or errors occur or changes will not be seen
133 *
134 * @since 2.0
135 */
136 public function clear_third_party_caches() {
137 /**
138 * Filters whether to clear page caches.
139 *
140 * @since 2.0
141 *
142 * @param bool Whether to clear cache.
143 */
144 $clear_page_caches = apply_filters( 'ctf_clear_page_caches', true );
145
146 if ( ! $clear_page_caches ) {
147 return;
148 }
149
150 // Clear WP Fastest Cache.
151 if ( isset( $GLOBALS['wp_fastest_cache'] ) && method_exists( $GLOBALS['wp_fastest_cache'], 'deleteCache' ) ){
152 $GLOBALS['wp_fastest_cache']->deleteCache();
153 }
154
155 // Clear WP Super Cache
156 if ( function_exists( 'wp_cache_clear_cache' ) ) {
157 wp_cache_clear_cache();
158 }
159
160 // Clear W3 Total Cache.
161 if ( class_exists('W3_Plugin_TotalCacheAdmin') && function_exists( 'w3_instance' ) ) {
162 $plugin_total_cache_admin = &w3_instance('W3_Plugin_TotalCacheAdmin');
163
164 $plugin_total_cache_admin->flush_all();
165 }
166
167 // Clear WP Rocket cache.
168 if ( function_exists( 'rocket_clean_domain' ) ) {
169 rocket_clean_domain();
170 }
171 }
172
173 /**
174 * Clear the stored caches from the database.
175 *
176 * @since 2.0
177 */
178 public function clear_persistent_cache() {
179 global $wpdb;
180
181 $cache_table_name = $wpdb->prefix . 'ctf_feed_caches';
182
183 $sql = "UPDATE $cache_table_name
184 SET cache_value = ''";
185 $wpdb->query( $sql );
186 }
187
188
189 }
190