@@ -36,14 +36,26 @@ class API extends Base
36
36
const WIDGET_O_ESIENABLE = ESI ::WIDGET_O_ESIENABLE ;
37
37
const WIDGET_O_TTL = ESI ::WIDGET_O_TTL ;
38
38
39
+ protected static $ _instance ;
40
+
41
+ /**
42
+ * Instance
43
+ *
44
+ * @since 3.0
45
+ * @access protected
46
+ */
47
+ protected function __construct ()
48
+ {
49
+ }
50
+
39
51
/**
40
52
* Define hooks to be used in other plugins.
41
53
*
42
54
* The benefit to use hooks other than functions is no need to detech if LSCWP enabled and function existed or not anymore
43
55
*
44
56
* @since 3.0
45
57
*/
46
- public static function init ()
58
+ public function init ()
47
59
{
48
60
/**
49
61
* Init
@@ -101,7 +113,12 @@ public static function init()
101
113
* ESI
102
114
*/
103
115
// API::nonce_action( $action ) & API::nonce( $action = -1, $defence_for_html_filter = true ) -> Action `litespeed_nonce`
104
-
116
+ add_filter ( 'litespeed_esi_status ' , __NAMESPACE__ . '\Router::esi_enabled ' ); // API::esi_enabled() -> Filter `litespeed_esi_status` // Get ESI enable status
117
+ add_filter ( 'litespeed_esi_url ' , __NAMESPACE__ . '\ESI::sub_esi_block ' , 10 , 8 ); // API::esi_url( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false, $preserved = false, $svar = false, $inline_val = false ) // Generate ESI block url
118
+ // API::hook_widget_default_options( $hook ) -> Filter `litespeed_widget_default_options` // Hook widget default settings value. Currently used in Woo 3rd
119
+ // API::hook_esi_param( $hook ) -> Filter `litespeed_esi_params`
120
+ // API::hook_tpl_not_esi($hook) && Action `litespeed_is_not_esi_template` -> Action `litespeed_tpl_normal`
121
+ // API::hook_tpl_esi($block, $hook) -> Action `litespeed_esi_block-$block` // add_action( 'litespeed_esi_load-' . $block, $hook )
105
122
106
123
/**
107
124
* Vary
@@ -115,13 +132,22 @@ public static function init()
115
132
116
133
add_filter ( 'litespeed_is_mobile ' , __NAMESPACE__ . '\Control::is_mobile ' ); // API::set_mobile() -> Filter `litespeed_is_mobile`
117
134
135
+ /**
136
+ * GUI
137
+ */
138
+ // API::clean_wrapper_begin( $counter = false ) -> Filter `litespeed_clean_wrapper_begin` // Start a to-be-removed html wrapper
139
+ add_filter ( 'litespeed_clean_wrapper_begin ' , __NAMESPACE__ . '\GUI::clean_wrapper_begin ' );
140
+ // API::clean_wrapper_end( $counter = false ) -> Filter `litespeed_clean_wrapper_end` // End a to-be-removed html wrapper
141
+ add_filter ( 'litespeed_clean_wrapper_end ' , __NAMESPACE__ . '\GUI::clean_wrapper_end ' );
142
+
118
143
/**
119
144
* Mist
120
145
*/
121
146
add_action ( 'litespeed_debug ' , __NAMESPACE__ . '\Debug2::debug ' ); // API::debug()-> Action `litespeed_debug`
122
147
add_action ( 'litespeed_debug2 ' , __NAMESPACE__ . '\Debug2::debug2 ' ); // API::debug2()-> Action `litespeed_debug2`
148
+ add_action ( 'litespeed_disable_all ' , array ( $ this , '_disable_all ' ) ); // API::disable_all( $reason ) -> Action `litespeed_disable_all`
123
149
124
- add_action ( 'litspeed_after_admin_init ' , __CLASS__ . ' ::after_admin_init ' );
150
+ add_action ( 'litspeed_after_admin_init ' , array ( $ this , ' _after_admin_init ' ) );
125
151
}
126
152
127
153
/**
@@ -130,7 +156,7 @@ public static function init()
130
156
* @since 3.0
131
157
* @access public
132
158
*/
133
- public static function after_admin_init ()
159
+ public function _after_admin_init ()
134
160
{
135
161
/**
136
162
* GUI
@@ -142,38 +168,16 @@ public static function after_admin_init()
142
168
}
143
169
144
170
/**
145
- * Disable All
171
+ * Disable All (Note: Not for direct call, always use Hooks)
146
172
*
147
173
* @since 2.9.7.2
148
174
* @access public
149
175
*/
150
- public static function disable_all ( $ reason )
176
+ public function _disable_all ( $ reason )
151
177
{
152
178
do_action ( 'litespeed_debug ' , '[API] Disabled_all due to ' . $ reason );
153
179
154
- ! defined ( 'LITESPEED_DISABLE_ALL ' ) && define ( 'LITESPEED_DISABLE_ALL ' , true ) ;
155
- }
156
-
157
- /**
158
- * Start a to-be-removed html wrapper
159
- *
160
- * @since 1.4
161
- * @access public
162
- */
163
- public static function clean_wrapper_begin ( $ counter = false )
164
- {
165
- return GUI ::clean_wrapper_begin ( $ counter ) ;
166
- }
167
-
168
- /**
169
- * End a to-be-removed html wrapper
170
- *
171
- * @since 1.4
172
- * @access public
173
- */
174
- public static function clean_wrapper_end ( $ counter = false )
175
- {
176
- return GUI ::clean_wrapper_end ( $ counter ) ;
180
+ ! defined ( 'LITESPEED_DISABLE_ALL ' ) && define ( 'LITESPEED_DISABLE_ALL ' , true );
177
181
}
178
182
179
183
/**
@@ -238,96 +242,4 @@ public static function vary_append_commenter()
238
242
Vary::get_instance ()->append_commenter () ;
239
243
}
240
244
241
- /**
242
- * Hook not ESI template
243
- *
244
- * @since 1.1.3
245
- * @access public
246
- */
247
- public static function hook_tpl_not_esi ($ hook )
248
- {
249
- add_action ('litespeed_is_not_esi_template ' , $ hook ) ;
250
- }
251
-
252
- /**
253
- * Hook ESI template block
254
- *
255
- * @since 1.1.3
256
- * @access public
257
- */
258
- public static function hook_tpl_esi ($ block , $ hook )
259
- {
260
- add_action ('litespeed_load_esi_block- ' . $ block , $ hook ) ;
261
- }
262
-
263
- /**
264
- * Hook ESI params
265
- *
266
- * @since 1.1.3
267
- * @since 2.9.8.1 Changed hook name and params
268
- * @access public
269
- */
270
- public static function hook_esi_param ( $ hook , $ priority = 10 , $ args = 2 )
271
- {
272
- add_filter ( 'litespeed_esi_params ' , $ hook , $ priority , $ args ) ;
273
- }
274
-
275
- /**
276
- * Hook widget default settings value
277
- *
278
- * @since 1.1.3
279
- * @access public
280
- */
281
- public static function hook_widget_default_options ($ hook , $ priority = 10 , $ args = 1 )
282
- {
283
- add_filter ('litespeed_widget_default_options ' , $ hook , $ priority , $ args ) ;
284
- }
285
-
286
- /**
287
- * Generate ESI block url
288
- *
289
- * @since 1.1.3
290
- * @access public
291
- * @param string $control Cache control tag
292
- */
293
- public static function esi_url ( $ block_id , $ wrapper , $ params = array (), $ control = 'default ' , $ silence = false , $ preserved = false , $ svar = false , $ inline_val = false )
294
- {
295
- if ( $ control === 'default ' ) {
296
- $ control = 'private,no-vary ' ;
297
- }
298
- return ESI ::sub_esi_block ( $ block_id , $ wrapper , $ params , $ control , $ silence , $ preserved , $ svar , $ inline_val ) ;
299
- }
300
-
301
- /**
302
- * Get ESI enable setting value
303
- *
304
- * @since 1.2.0
305
- * @access public
306
- */
307
- public static function esi_enabled ()
308
- {
309
- return Router::esi_enabled () ;
310
- }
311
-
312
- /**
313
- * Get cache enable setting value
314
- *
315
- * @since 1.3
316
- * @access public
317
- */
318
- public static function cache_enabled ()
319
- {
320
- return defined ( 'LITESPEED_ON ' ) ;
321
- }
322
-
323
- /**
324
- * Hook to check if need to bypass CDN or not
325
- *
326
- * @since 3.0
327
- */
328
- public static function hook_can_cdn ( $ hook )
329
- {
330
- add_filter ( 'litespeed_can_cdn ' , $ hook ) ;
331
- }
332
-
333
245
}
0 commit comments