PluginProbe
wpForo Forum / 2.0.9
wpForo Forum v2.0.9
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / classes / Cache.php

Cache.php in wpForo Forum 2.0.9, at classes/Cache.php

495 lines 22.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace wpforo\classes;
4
5 use FilesystemIterator;
6
7 // Exit if accessed directly
8 if( ! defined( 'ABSPATH' ) ) exit;
9
10 class Cache {
11 public $object;
12 public $dir;
13 public $lang;
14
15 function __construct() {
16 add_action( 'wpforo_after_init_folders', function( $folders ) {
17 $cache_dir = $folders['cache']['dir'];
18 if( ! is_dir( $cache_dir ) ) $this->dir( $cache_dir );
19 if( ! is_dir( $cache_dir . DIRECTORY_SEPARATOR . 'tag' ) ) $this->mkdir( $cache_dir . DIRECTORY_SEPARATOR . 'tag' );
20 if( ! is_dir( $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'tag' ) ) $this->mkdir( $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'tag' );
21 if( ! is_dir( $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'url' ) ) $this->mkdir( $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'url' );
22 if( ! is_dir( $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'option' ) ) $this->mkdir( $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'option' );
23
24 $this->dir = $cache_dir;
25 } );
26
27 add_action( 'wpforo_after_set_locale', function( $locale ) { $this->lang = $locale; } );
28
29 add_action( 'wpforo_after_add_board', function( $board ){
30 if( $board['status'] ){
31 WPF()->change_board( $board['boardid'] );
32 wpforo_clean_cache();
33 }
34 } );
35
36 add_action( 'wpforo_after_edit_board', function( $boardid ){
37 $board = WPF()->board->_get_board( $boardid );
38 if( wpfval($board, 'status' ) ){
39 WPF()->change_board( $boardid );
40 wpforo_clean_cache();
41 }
42 } );
43 }
44
45 public function get_key( $type = 'html' ) {
46 if( $type === 'html' ) {
47 $ug = WPF()->current_user_groupid;
48
49 return md5( preg_replace( '#(.+)\#.+?$#is', '$1', $_SERVER['REQUEST_URI'] ) . $ug );
50 }
51 }
52
53 private function dir( $cache_dir ) {
54 $dirs = [
55 $cache_dir,
56 $cache_dir . DIRECTORY_SEPARATOR . 'forum',
57 $cache_dir . DIRECTORY_SEPARATOR . 'topic',
58 $cache_dir . DIRECTORY_SEPARATOR . 'post',
59 $cache_dir . DIRECTORY_SEPARATOR . 'tag',
60 $cache_dir . DIRECTORY_SEPARATOR . 'item',
61 $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'forum',
62 $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'topic',
63 $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'post',
64 $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'tag',
65 $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'url',
66 $cache_dir . DIRECTORY_SEPARATOR . 'item' . DIRECTORY_SEPARATOR . 'option',
67 ];
68 $this->mkdir( $dirs );
69 }
70
71 private function mkdir( $dirs ) {
72 foreach( (array) $dirs as $dir ) {
73 wp_mkdir_p( $dir );
74 wpforo_write_file( $dir . '/index.html', '' );
75 wpforo_write_file( $dir . '/.htaccess', 'deny from all' );
76 }
77 }
78
79 public function on(){
80 return wpforo_setting( 'board', 'cache' );
81 }
82
83 public function get( $key, $type = 'loop', $template = null ) {
84 $template = ( $template ) ?: WPF()->current_object['template'];
85 $loop_templates = [ 'forum', 'topic', 'post', 'tag', 'url', 'option' ];
86 if( $type === 'loop' && $template ) {
87 if( $this->exists( $key, $template ) ) {
88 if( in_array( $template, $loop_templates ) ) {
89 $cache_file = $this->dir . '/' . $template . '/' . $key;
90 $array = wpforo_get_file_content( $cache_file );
91
92 return @unserialize( $array );
93 }
94 }
95 }
96 }
97
98 public function get_item( $id, $type = 'post', $sub_type = '' ) {
99 if( $id ) {
100 $key = $id . '_' . $this->lang;
101 if( $this->exists( $key, 'item', $type, $sub_type ) ) {
102 $cache_file = $this->dir . '/item/' . $type . '/' . ( $sub_type ? $sub_type . '_' : '' ) . $key;
103 $array = wpforo_get_file_content( $cache_file );
104 return @unserialize( $array );
105 }
106 }
107 }
108
109 public function get_html() {
110 $template = WPF()->current_object['template'];
111 if( $template == 'forum' ) {
112 $key = $this->get_key();
113 if( $this->exists( $key, $template ) ) {
114 $cache_file = $this->dir . '/' . $template . '/' . $key;
115 $html = wpforo_get_file_content( $cache_file );
116
117 return $this->filter( $html );
118 }
119 }
120
121 return false;
122 }
123
124 public function html( $content ) {
125 /*$template = WPF()->current_object['template'];
126 if( $template === 'forum' ){
127 $key = $this->get_key();
128 $this->create_html( $content, $template, $key );
129 }*/
130 }
131
132 public function create( $mode = 'loop', $cache = [], $type = 'post' ) {
133 if( ! $this->on() ) return false;
134 $template = WPF()->current_object['template'];
135 if( $template == 'forum' ) {
136 $this->check( $this->dir . '/item/post' );
137 }
138
139 if( $mode === 'loop' && $template ) {
140 if( wpfval( $cache, 'tags' ) ) {
141 $this->create_files( $cache['tags'], 'tag' );
142 }
143 if( $template === 'forum' || $template === 'topic' || $template === 'post' ) {
144 $cache = WPF()->forum->get_cache( 'forums' );
145 $this->create_files( $cache, $template );
146 $cache = WPF()->topic->get_cache( 'topics' );
147 $this->create_files( $cache, $template );
148 $cache = WPF()->post->get_cache( 'posts' );
149 $this->create_files( $cache, $template );
150 }
151 } elseif( $mode === 'item' && ! empty( $cache ) ) {
152 $this->create_files( $cache, 'item', $type );
153 }
154 }
155
156 public function create_files( $cache = [], $template = '', $type = '' ) {
157 if( ! empty( $cache ) ) {
158 $type = ( $type ) ? $type . '/' : '';
159 foreach( $cache as $key => $object ) {
160 if( $template == 'item' ) $key = $key . '_' . $this->lang;
161 if( ! $this->exists( $key, $template ) ) {
162 $object = serialize( $object );
163 wpforo_write_file( $this->dir . '/' . $template . '/' . $type . $key, $object );
164 }
165 }
166 }
167 }
168
169 public function create_html( $content, $template = '', $key = '' ) {
170 if( $content ) {
171 if( ! $this->exists( $key, $template ) ) {
172 wpforo_write_file( $this->dir . '/' . $template . '/' . $key, $content );
173 }
174 }
175 }
176
177 public function create_custom( $args = [], $items = [], $template = 'post', $items_count = 0 ) {
178 if( empty( $args ) || ! is_array( $args ) ) return;
179 if( empty( $items ) || ! is_array( $items ) ) return;
180 $cache = [];
181 $hach = serialize( $args );
182 $object_key = md5( $hach . WPF()->current_user_groupid );
183 $cache[ $object_key ]['items'] = $items;
184 $cache[ $object_key ]['items_count'] = $items_count;
185 $this->create_files( $cache, $template );
186 }
187
188 public function filter( $html = '' ) {
189 //exit();
190 $html = preg_replace( '|<div[\s\t]*id=\"wpf\-msg\-box\"|is', '<div style="display:none;"', $html );
191
192 return $html;
193 }
194
195 #################################################################################
196
197 /**
198 * Cleans forum cache
199 *
200 * @param integer Item ID (e.g.: $topicid or $postid) | (!) ID is 0 on dome actions (e.g.: delete actions)
201 * @param string Item Type (e.g.: 'forum', 'topic', 'post', 'user', 'widget', etc...)
202 * @param array Item data as array
203 *
204 * @return NULL
205 * @since 1.2.1
206 *
207 */
208
209 public function clean( $id, $template, $item = [] ) {
210
211 $dirs = [];
212 $userid = ( isset( $item['userid'] ) && $item['userid'] ) ? $item['userid'] : 0;
213 $postid = ( isset( $item['postid'] ) && $item['postid'] ) ? $item['postid'] : 0;
214 $topicid = ( isset( $item['topicid'] ) && $item['topicid'] ) ? $item['topicid'] : 0;
215 $forumid = ( isset( $item['forumid'] ) && $item['forumid'] ) ? $item['forumid'] : 0;
216 $parentid = ( isset( $item['parentid'] ) && $item['parentid'] ) ? $item['parentid'] : 0;
217 $root = ( isset( $item['root'] ) && $item['root'] ) ? $item['root'] : 0;
218 $tagid = ( isset( $item['tagid'] ) && $item['tagid'] ) ? $item['tagid'] : 0;
219
220 WPF()->forum->reset();
221 WPF()->topic->reset();
222 WPF()->post->reset();
223
224 if( $template === 'forum' || $template === 'forum-soft' ) {
225 $id = isset( $id ) ? $id : $forumid;
226 if( $template === 'forum' ) {
227 $dirs = [ $this->dir . '/forum', $this->dir . '/item/forum', $this->dir . '/item/url' ];
228 WPF()->seo->clear_cache();
229 }
230 if( $template === 'forum-soft' ) {
231 $dirs = [ $this->dir . '/forum' ];
232 }
233 if( $id ) {
234 $file = $this->dir . '/item/forum/' . $id . '_' . $this->lang;
235 $this->clean_file( $file );
236 }
237 } elseif( $template === 'topic' || $template === 'topic-first-post' || $template === 'topic-soft' ) {
238 $id = isset( $id ) ? $id : $topicid;
239 if( $template === 'topic' || $template === 'topic-first-post' ) {
240 WPF()->seo->clear_cache();
241 $dirs = [ $this->dir . '/forum', $this->dir . '/topic', $this->dir . '/post' ];
242 }
243 if( $forumid ) {
244 $file = $this->dir . '/item/forum/' . $forumid . '_' . $this->lang;
245 $this->clean_file( $file );
246 }
247 if( $id ) {
248 $file = $this->dir . '/item/topic/' . $id . '_' . $this->lang;
249 $this->clean_file( $file );
250 $file = $this->dir . '/item/url/topic_' . $id . '_' . $this->lang;
251 $this->clean_file( $file );
252 $postid = ( isset( $item['first_postid'] ) && $item['first_postid'] ) ? $item['first_postid'] : 0;
253 if( $postid ) $file = $this->dir . '/item/post/' . $postid . '_' . $this->lang;
254 $this->clean_file( $file );
255 if( $template === 'topic' ) $this->clear_topic_posts_urls( $id );
256 }
257 WPF()->statistic_cache_clean();
258 $this->clear_visitor_tracking();
259 } elseif( $template === 'post' || $template === 'post-soft' ) {
260 $id = isset( $id ) ? $id : $postid;
261 if( $template === 'post' ) {
262 $dirs = [ $this->dir . '/forum', $this->dir . '/topic', $this->dir . '/post' ];
263 }
264 if( $forumid ) {
265 $file = $this->dir . '/item/forum/' . $forumid . '_' . $this->lang;
266 $this->clean_file( $file );
267 }
268 if( $topicid ) {
269 $file = $this->dir . '/item/topic/' . $topicid . '_' . $this->lang;
270 $this->clean_file( $file );
271 }
272 if( $parentid ) {
273 $file = $this->dir . '/item/post/' . $parentid . '_' . $this->lang;
274 $this->clean_file( $file );
275 }
276 if( $root ) {
277 $file = $this->dir . '/item/post/' . $root . '_' . $this->lang;
278 $this->clean_file( $file );
279 }
280 if( $id ) {
281 $file = $this->dir . '/item/post/' . $id . '_' . $this->lang;
282 $this->clean_file( $file );
283 $file = $this->dir . '/item/url/post_' . $id . '_' . $this->lang;
284 $this->clean_file( $file );
285 $this->clear_topic_next_posts_urls( $id, $topicid );
286 }
287 WPF()->statistic_cache_clean();
288 $this->clear_visitor_tracking();
289 } elseif( $template === 'tag' ) {
290 if( $id ) {
291 $file = $this->dir . '/item/tag/' . md5( $id ) . '_' . $this->lang;
292 $this->clean_file( $file );
293 } else {
294 $dirs = [ $this->dir . '/tag' ];
295 }
296 } elseif( $template === 'option' ) {
297 $dirs = [ $this->dir . '/item/option/' ];
298 } elseif( $template === 'url' ) {
299 $dirs = [ $this->dir . '/item/url/' ];
300 } elseif( $template === 'user' ) {
301 if( wpforo_setting( 'seo', 'seo_profile' ) ) WPF()->seo->clear_cache();
302 } elseif( $template === 'loop' ) {
303 $dirs = [ $this->dir . '/forum', $this->dir . '/topic', $this->dir . '/post' ];
304 WPF()->seo->clear_cache();
305 } elseif( $template === 'item' ) {
306 $dirs = [ $this->dir . '/item/post', $this->dir . '/item/topic', $this->dir . '/item/forum' ];
307 WPF()->seo->clear_cache();
308 } else {
309 $dirs = [ $this->dir . '/forum', $this->dir . '/topic', $this->dir . '/post', $this->dir . '/tag', $this->dir . '/item/post', $this->dir . '/item/topic', $this->dir . '/item/forum', $this->dir . '/item/tag', $this->dir . '/item/url', $this->dir . '/item/option/' ];
310 WPF()->seo->clear_cache();
311 }
312
313 if( ! empty( $dirs ) ) {
314 foreach( $dirs as $dir ) {
315 $this->clean_files( $dir );
316 }
317 }
318 }
319
320 public function clean_files( $directory ) {
321 $directory = wpforo_fix_dir_sep( $directory );
322 $directory_ns = trim( $directory, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . '*';
323 $directory_ws = DIRECTORY_SEPARATOR . trim( $directory, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . '*';
324 $glob = glob( $directory_ns );
325 if( empty( $glob ) ) $glob = glob( $directory_ws );
326 foreach( $glob as $item ) {
327 if( strpos( $item, 'index.html' ) !== false || strpos( $item, '.htaccess' ) !== false ) continue;
328 if( ! is_dir( $item ) && file_exists( $item ) ) {
329 @unlink( $item );
330 }
331 }
332 }
333
334 public function clean_file( $file ) {
335 if( ! is_dir( $file ) && file_exists( $file ) ) {
336 @unlink( $file );
337 }
338 }
339
340 public function clear_topic_posts_urls( $topicid ){
341 if( !$topicid ) return;
342 $post_ids = WPF()->db->get_results("SELECT `postid` FROM " . WPF()->tables->posts . " WHERE `topicid` = " . intval( $topicid ), ARRAY_A );
343 if( !empty( $post_ids ) ){
344 foreach( $post_ids as $post_id ){
345 $this->clean_file( $this->dir . '/item/post/' . $post_id['postid'] . '_' . $this->lang );
346 $this->clean_file( $this->dir . '/item/url/post_' . $post_id['postid'] . '_' . $this->lang );
347 }
348 }
349 }
350
351 public function clear_topic_next_posts_urls( $postid, $topicid ){
352 $topicid = ( $topicid ) ? : wpforo_post( $postid, 'topicid' );
353 $post_ids = WPF()->db->get_results("SELECT `postid` FROM " . WPF()->tables->posts . " WHERE `topicid` = " . intval( $topicid ) . " AND `postid` > " . intval( $postid ), ARRAY_A );
354 if( !empty( $post_ids ) ){
355 foreach( $post_ids as $post_id ){
356 $this->clean_file( $this->dir . '/item/post/' . $post_id['postid'] . '_' . $this->lang );
357 $this->clean_file( $this->dir . '/item/url/post_' . $post_id['postid'] . '_' . $this->lang );
358 }
359 }
360 }
361
362 public function exists( $key, $template, $type = '', $sub_type = '' ) {
363 $type = ( $type ) ? $type . '/' : '';
364 if( file_exists( $this->dir . '/' . $template . '/' . $type . ( $sub_type ? $sub_type . '_' : '' ) . $key ) ) {
365 return true;
366 } else {
367 return false;
368 }
369 }
370
371 public function check( $directory ) {
372 $directory = wpforo_fix_dir_sep( $directory );
373 $filecount = 0;
374 if( class_exists( 'FilesystemIterator' ) && is_dir( $directory ) ) {
375 $fi = new FilesystemIterator( $directory, FilesystemIterator::SKIP_DOTS );
376 $filecount = iterator_count( $fi );
377 }
378 if( ! $filecount ) {
379 $directory_ns = trim( $directory, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . '*';
380 $directory_ws = DIRECTORY_SEPARATOR . trim( $directory, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . '*';
381 $files = glob( $directory_ns );
382 if( empty( $files ) ) $files = glob( $directory_ws );
383 $filecount = count( $files );
384 }
385 if( $filecount > 1000 ) {
386 $this->clean_files( $directory );
387 }
388 }
389
390 public function clear_visitor_tracking() {
391 $keep_vistors_data = apply_filters( 'wpforo_keep_visitors_data', 4000 );
392 $time = (int) current_time( 'timestamp', 1 ) - (int) $keep_vistors_data;
393 $online = (int) current_time( 'timestamp', 1 ) - (int) wpforo_setting( 'profiles', 'online_status_timeout' );
394 if( $time > 1 ) {
395 WPF()->db->query( "DELETE FROM `" . WPF()->tables->visits . "` WHERE `time` < " . intval( $time ) . " OR (`time` < " . intval( $online ) . " AND `userid` = 0)" );
396 }
397 }
398
399 public function cache_plugins(){
400 $board_paths = [];
401 $cache_plugins = [];
402
403 if( is_wpforo_multiboard() ){
404 $boards = WPF()->board->get_boards();
405 if(!empty($boards)){
406 foreach($boards as $board){
407 $board_paths[] = '/' . $board['slug'] . '/';
408 }
409 }
410 } else {
411 $board_paths[] = '/' . WPF()->board->get_current( 'slug' ) . '/';
412 }
413
414 $board_paths[] = '/' . wpforo_settings_get_slug('member') . '/';
415 $board_paths[] = '/' . wpforo_settings_get_slug('register') . '/';
416 $board_paths[] = '/' . wpforo_settings_get_slug('login') . '/';
417 $board_paths[] = '/' . wpforo_settings_get_slug('lostpassword') . '/';
418
419 if (function_exists("wpsc_init")) {
420 //WP Super Cache
421 $cache_plugins['WPSuper']['name'] = 'WP Super Cache';
422 $cache_plugins['WPSuper']['steps'][] = __('Please navigate in Dashboard to Settings > WP Super Cache', 'wpforo');
423 $cache_plugins['WPSuper']['steps'][] = __('Go to Advanced Tab, scroll down to "Rejected URL Strings" option', 'wpforo');
424 $cache_plugins['WPSuper']['steps'][] = __('Insert the URL path(s) of your forum page(s) one per line in the option textarea:', 'wpforo') . ' <br><code>' . implode('</code> <br> <code>', $board_paths) . '</code>';
425 $cache_plugins['WPSuper']['steps'][] = __('Save it and delete all caches.', 'wpforo');
426 }
427 if (defined("LSCWP_V")) {
428 //LiteSpeed Cache
429 $cache_plugins['LiteSpeed']['name'] = 'LiteSpeed Cache';
430 $cache_plugins['LiteSpeed']['steps'][] = __('Please navigate in Dashboard to LiteSpeed Cache > Cache admin page', 'wpforo');
431 $cache_plugins['LiteSpeed']['steps'][] = __('Go to Exclude Tab, find the "Do Not Cache URIs" option', 'wpforo');
432 $cache_plugins['LiteSpeed']['steps'][] = __('Insert the URL path(s) of your forum page(s) one per line in the option textarea:', 'wpforo') . ' <br><code>' . implode('</code> <br> <code>', $board_paths) . '</code>';
433 $cache_plugins['LiteSpeed']['steps'][] = __('Save it and delete all caches.', 'wpforo');
434 }
435 if (function_exists("rocket_clean_post")) {
436 //WP Rocket Cache
437 $cache_plugins['WPRocket']['name'] = 'WP Rocket Cache';
438 $cache_plugins['WPRocket']['steps'][] = __('Please navigate in Dashboard to WP Rocket > Advanced Rules Tab', 'wpforo');
439 $cache_plugins['WPRocket']['steps'][] = __('Scroll down to "Never cache (URLs)" option', 'wpforo');
440 $cache_plugins['WPRocket']['steps'][] = __('Insert the URL path(s) of your forum page(s) one per line with wildcard (.*) in the option textarea:', 'wpforo') . ' <br><code>' . implode('</code> <br> <code>', array_map( function ( $value ){ return $value . '(.*)'; }, $board_paths)) . '</code>';
441 $cache_plugins['WPRocket']['steps'][] = __('Save it and delete all caches.', 'wpforo');
442 }
443 if (function_exists("wpfc_clear_post_cache_by_id")) {
444 //WP Fastest Cache
445 $cache_plugins['WPFastest']['name'] = 'WP Fastest Cache';
446 $cache_plugins['WPFastest']['steps'][] = __('Please navigate in Dashboard to WP Fastest Cache > Exclude Tab', 'wpforo');
447 $cache_plugins['WPFastest']['steps'][] = __('In the "Exclude Pages" section click the [Add New Rule] button', 'wpforo');
448 $cache_plugins['WPFastest']['steps'][] = __('Select [Start with] option in the drop-down menu and insert the URL path(s) of your forum page(s) one per rule in the next field:', 'wpforo') . ' <br><code>' . implode('</code> <br> <code>', $board_paths) . '</code>';
449 $cache_plugins['WPFastest']['steps'][] = __('If you have more than one forum pages (boards) you should create separate rules for each forum board.', 'wpforo');
450 $cache_plugins['WPFastest']['steps'][] = __('Save rules and delete all caches.', 'wpforo');
451 }
452 if (function_exists("w3tc_flush_post")) {
453 //W3 Total Cache
454 $cache_plugins['W3Total']['name'] = 'W3 Total Cache';
455 $cache_plugins['W3Total']['steps'][] = __('Please navigate in Dashboard to Performance > Page Cache admin page', 'wpforo');
456 $cache_plugins['W3Total']['steps'][] = __('Go to Advanced Tab, scroll down to Rejected URL Strings option', 'wpforo');
457 $cache_plugins['W3Total']['steps'][] = __('Scroll to Advanced section and insert the URL path(s) of your forum page(s) one per line in the "Never cache the following pages" textarea:', 'wpforo') . ' <br><code>' . implode('</code> <br> <code>', $board_paths) . '</code>';
458 $cache_plugins['W3Total']['steps'][] = __('Save it and delete all caches.', 'wpforo');
459 }
460 if (is_callable(["WPO_Page_Cache", "delete_single_post_cache"])) {
461 //WP-Optimize Cache
462 $cache_plugins['WPOptimize']['name'] = 'WP-Optimize Cache';
463 $cache_plugins['WPOptimize']['steps'][] = __('Please navigate in Dashboard to WP-Optimize > Cache admin page', 'wpforo');
464 $cache_plugins['WPOptimize']['steps'][] = __('Go to Advanced Settings Tab, find the "URLs to exclude from caching" option', 'wpforo');
465 $cache_plugins['WPOptimize']['steps'][] = __('Insert the URL path(s) of your forum page(s) one per line with wildcard [*] in the option textarea:', 'wpforo') . ' <br><code>' . implode('</code> <br> <code>', array_map( function ( $value ){ return $value . '*'; }, $board_paths)) . '</code>';
466 $cache_plugins['WPOptimize']['steps'][] = __('Save it and delete all caches.', 'wpforo');
467 }
468 if (class_exists("\SiteGround_Optimizer\Supercacher\Supercacher")) {
469 //SiteGround Optimizer
470 $cache_plugins['SiteGround']['name'] = 'SiteGround Optimizer';
471 $cache_plugins['SiteGround']['steps'][] = __('Please navigate in Dashboard to SG Optimizer > Caching admin page', 'wpforo');
472 $cache_plugins['SiteGround']['steps'][] = __('Scroll to Exclude URLs from Caching section and click the "pencil" button, enable it, and click the button again', 'wpforo');
473 $cache_plugins['SiteGround']['steps'][] = __('Insert the URL path(s) of your forum page(s) with wildcard [*] in the pop-up filed:', 'wpforo') . ' <br><code>' . implode('</code> <br> <code>', array_map( function ( $value ){ return $value . '*'; }, $board_paths)) . '</code>';
474 $cache_plugins['SiteGround']['steps'][] = __('Save it and delete all caches.', 'wpforo');
475 }
476 return $cache_plugins;
477 }
478
479 public function cache_plugins_status(){
480 $not_exluded = [];
481 $cache_plugins = $this->cache_plugins();
482 $excluded = wpforo_get_option( 'wpforo_excluded_cache', null, false );
483 $excluded = explode(',', $excluded );
484 if( ! empty( $cache_plugins ) ){
485 foreach( $cache_plugins as $cache_plugin ){
486 if( ! in_array( $cache_plugin['name'], $excluded ) ){
487 $not_exluded[] = $cache_plugin;
488 }
489 }
490 }
491 return $not_exluded;
492 }
493
494 }
495