-
Notifications
You must be signed in to change notification settings - Fork 0
/
unmus_rocket.php
104 lines (82 loc) · 2.05 KB
/
unmus_rocket.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* wpRocket - All about Caching
*
* @package unmus
*/
// Security: Stops code execution if WordPress is not loaded
if (!defined('ABSPATH')) { exit; }
/**
* Removes Mathilda Pages from Cache
*
* Function will called everytime new tweets have been loaded
*
* @since 0.6
* @see Plugin Mathilda
* @see Plugin wpRocket
*/
function unmus_wprocket_refresh_mathilda_cache()
{
if (defined('WP_ROCKET_VERSION')) {
$current_host=get_site_url();
$page_slug=get_option('mathilda_slug');
$cache_mathilda_url=$current_host.'/'.$page_slug.'/';
$cache_number_of_pages=mathilda_pages();
$clear_urls=array();
for($i=0; $i < $cache_number_of_pages; $i++)
{
if($i==0) {
$clear_urls[]=$cache_mathilda_url;
} else {
$clear_urls[]=$cache_mathilda_url.($i+1).'/';
}
}
rocket_clean_files( $clear_urls );
}
}
if(function_exists('mathilda_activate')) {
add_action('mathilda_tweets_updated', 'unmus_wprocket_refresh_mathilda_cache');
}
/**
* Removes TootPress Pages from Cache
*
* Function will called everytime new toots have been loaded
*
* @since 0.6
* @see Plugin TootPress
* @see Plugin wpRocket
*/
function unmus_wprocket_fresh_tootpress_cache() {
if (defined('WP_ROCKET_VERSION')) {
$current_host=get_site_url();
$page_slug=tootpress_get_slug();
$cache_tootpress_url=$current_host.'/'.$page_slug.'/';
$cache_number_of_pages=tootpress_amount_of_pages();
$clear_urls=array();
for($i=0; $i < $cache_number_of_pages; $i++)
{
if($i==0) {
$clear_urls[]=$cache_tootpress_url;
} else {
$clear_urls[]=$cache_tootpress_url.($i+1).'/';
}
}
rocket_clean_files( $clear_urls );
}
}
if(function_exists('tootpress_activate')) {
add_action('tootpress_toots_update', 'unmus_wprocket_fresh_tootpress_cache');
}
/**
* Delete Cache if Maintenance Mode was activated or deactivated
*
* @since 0.7
* @see wpRocket Plugin
*/
function unmus_wprocket_delete_cache(){
if (defined('WP_ROCKET_VERSION')) {
rocket_clean_domain();
}
}
add_action('update_option_unmus_maintenance','unmus_wprocket_delete_cache');
?>