-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathExtension_AlwaysCached_Plugin_Admin.php
133 lines (119 loc) · 3.06 KB
/
Extension_AlwaysCached_Plugin_Admin.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
/**
* File: Extension_AlwaysCached_Plugin_Admin.php
*
* AlwaysCached plugin admin controller.
*
* @since 2.8.0
*
* @package W3TC
*/
namespace W3TC;
/**
* AlwaysCached Plugin Admin.
*
* @since 2.8.0
*/
class Extension_AlwaysCached_Plugin_Admin {
/**
* Adds the AlwaysCached extension to extensions list.
*
* @since 2.8.0
*
* @param array $extensions Extensions list.
* @param Config $config Config data.
*
* @return array
*/
public static function w3tc_extensions( $extensions, $config ) {
$requirements = array();
if ( ! Util_Environment::is_w3tc_pro( $config ) ) {
$requirements[] = __( 'Valid W3 Total Cache Pro license', 'w3-total-cache' );
}
$extensions['alwayscached'] = array(
'name' => 'Always Cached',
'author' => 'W3 EDGE',
'description' => __( 'Always cached.', 'w3-total-cache' ),
'author_uri' => 'https://www.w3-edge.com/',
'extension_uri' => 'https://www.w3-edge.com/',
'extension_id' => 'alwayscached',
'pro_feature' => true,
'pro_excerpt' => __( 'Prevents page/post updates from clearing corresponding cache entries and instead add them to a queue that can be manually cleared or scheduled to clear via cron.', 'w3-total-cache' ),
'pro_description' => array(),
'settings_exists' => true,
'version' => '1.0',
'enabled' => empty( $requirements ),
'requirements' => implode( ', ', $requirements ),
'path' => 'w3-total-cache/Extension_AlwaysCached_Plugin.php',
);
return $extensions;
}
/**
* Run method for AlwaysCached admin.
*
* @since 2.8.0
*
* @return void|null
*/
public function run() {
if ( ! Extension_AlwaysCached_Plugin::is_enabled() ) {
return null;
}
add_action(
'w3tc_extension_page_alwayscached',
array(
'\W3TC\Extension_AlwaysCached_Page',
'w3tc_extension_page_alwayscached',
)
);
add_action(
'admin_print_scripts',
array(
'\W3TC\Extension_AlwaysCached_Page',
'admin_print_scripts',
)
);
add_filter( 'w3tc_admin_actions', array( $this, 'w3tc_admin_actions' ) );
add_filter( 'w3tc_admin_menu', array( $this, 'w3tc_admin_menu' ) );
add_action(
'w3tc_ajax',
array(
'\W3TC\Extension_AlwaysCached_Page',
'w3tc_ajax',
)
);
}
/**
* Adds admin actions for AlwaysCached.
*
* @since 2.8.0
*
* @param array $handlers Handlers array.
*
* @return array
*/
public function w3tc_admin_actions( $handlers ) {
$handlers['alwayscached'] = 'Extension_AlwaysCached_AdminActions';
return $handlers;
}
/**
* Adds admin menu item for AlwaysCached.
*
* @since 2.8.0
*
* @param array $menu Menu array.
*
* @return array
*/
public function w3tc_admin_menu( $menu ) {
if ( Extension_AlwaysCached_Plugin::is_enabled() ) {
$menu['w3tc_extensions&extension=alwayscached&action=view'] = array(
'page_title' => __( 'Page Cache Queue', 'w3-total-cache' ),
'menu_text' => __( 'Page Cache Queue', 'w3-total-cache' ),
'visible_always' => false,
'order' => 450,
);
}
return $menu;
}
}