LiteSpeed Cache - Version 2.1

Version Description

  • Mar 15 2018 =
  • [NEW FEATURE] Image Optimization Unlocked for non-LiteSpeed users.
  • [NEW FEATURE] Object Cache Unlocked for non-LiteSpeed users.
  • [NEW FEATURE] Crawler Unlocked for non-LiteSpeed users.
  • [NEW FEATURE] Database Cleaner and Optimizer Unlocked for non-LiteSpeed users.
  • [NEW FEATURE] Lazy Load Images Unlocked for non-LiteSpeed users.
  • [NEW FEATURE] CSS/JS/HTML Minify/Combine Optimize Unlocked for non-LiteSpeed users.
  • [IAPI] IAPI v2.0.
  • [IAPI] Increased max rows prefetch when client has additional credit.
  • [IMPROVEMENT] CDN Multiple domains may now be used.
  • [IMPROVEMENT] Report Added WP environment constants for better debugging.
  • [REFACTOR] Separated Cloudflare CDN class.
  • [BUGFIX] Image Optimization Fixed issue where certain MySQL version failed to create img_optm table. (@philippwidmer)
  • [BUGFIX] Image Optimization Fixed issue where callback validation failed when pulling and sending request simultaneously.
  • [GUI] Added Slack community banner.
  • [INTEGRATION] CDN compatibility with WPML multiple domains. (@egemensarica)
Download this release

Release Info

Developer LiteSpeedTech
Plugin Icon 128x128 LiteSpeed Cache
Version 2.1
Comparing to
See all releases

Code changes from version 2.0 to 2.1

Files changed (54) hide show
  1. admin/admin-api.class.php +9 -6
  2. admin/litespeed-cache-admin-display.class.php +14 -19
  3. admin/litespeed-cache-admin-error.class.php +0 -8
  4. admin/litespeed-cache-admin-report.class.php +35 -15
  5. admin/litespeed-cache-admin-settings.class.php +8 -4
  6. admin/litespeed-cache-admin.class.php +4 -4
  7. admin/tpl/crawler.php +1 -3
  8. admin/tpl/image_optimization.php +2 -6
  9. admin/tpl/import_export.php +0 -2
  10. admin/tpl/inc/banner_promo.php +1 -1
  11. admin/tpl/inc/banner_promo.slack.php +33 -0
  12. admin/tpl/inc/check_cache_disabled.php +41 -5
  13. admin/tpl/manage.php +1 -5
  14. admin/tpl/manage/manage_cdn.php +4 -4
  15. admin/tpl/manage/manage_purge.php +2 -0
  16. admin/tpl/setting/settings_cache.php +2 -0
  17. admin/tpl/setting/settings_cdn.php +2 -1
  18. admin/tpl/setting/settings_esi.php +1 -0
  19. admin/tpl/setting/settings_excludes.php +3 -0
  20. admin/tpl/setting/settings_general.php +2 -0
  21. admin/tpl/setting/settings_purge.php +2 -0
  22. admin/tpl/settings.php +1 -3
  23. css/litespeed.css +68 -1
  24. img/slack-logo.png +0 -0
  25. inc/activation.class.php +1 -1
  26. inc/cdn.class.php +53 -257
  27. inc/cdn/cloudflare.class.php +289 -0
  28. inc/config.class.php +37 -8
  29. inc/data_structure/img_optm.sql +1 -1
  30. inc/gui.class.php +87 -11
  31. inc/img_optm.class.php +5 -5
  32. inc/litespeed-cache.class.php +33 -25
  33. inc/litespeed.autoload.php +2 -1
  34. inc/log.class.php +1 -1
  35. inc/optimize.class.php +57 -1
  36. inc/purge.class.php +3 -0
  37. inc/router.class.php +18 -5
  38. inc/utility.class.php +21 -15
  39. includes/litespeed-cache-activation.class.php +1 -1
  40. includes/litespeed-cache-cdn.class.php +53 -257
  41. includes/litespeed-cache-config.class.php +37 -8
  42. includes/litespeed-cache-gui.class.php +87 -11
  43. includes/litespeed-cache-log.class.php +1 -1
  44. includes/litespeed-cache-optimize.class.php +57 -1
  45. includes/litespeed-cache-purge.class.php +3 -0
  46. includes/litespeed-cache-router.class.php +18 -5
  47. includes/litespeed-cache-utility.class.php +21 -15
  48. includes/litespeed-cache.class.php +33 -25
  49. includes/litespeed.autoload.php +2 -1
  50. js/litespeed-cache-admin.js +4 -0
  51. languages/litespeed-cache.pot +460 -439
  52. lib/litespeed/litespeed-file.class.php +16 -0
  53. litespeed-cache.php +1 -1
  54. readme.txt +160 -148
admin/admin-api.class.php CHANGED
@@ -206,7 +206,7 @@ class LiteSpeed_Cache_Admin_API
206
* @access public
207
* @param array $data
208
*/
209
- public static function post( $action, $data = false, $server = false )
210
{
211
$instance = self::get_instance() ;
212
@@ -218,7 +218,7 @@ class LiteSpeed_Cache_Admin_API
218
$instance->_request_key() ;
219
}
220
221
- return $instance->_post( $action, $data, $server ) ;
222
}
223
224
/**
@@ -269,11 +269,14 @@ class LiteSpeed_Cache_Admin_API
269
* @access private
270
* @param array $data
271
*/
272
- private function _post( $action, $data = false, $server = false )
273
{
274
- $hash = Litespeed_String::rrand( 16 ) ;
275
- // store hash
276
- update_option( self::DB_API_KEY_HASH, $hash ) ;
277
278
if ( $server == false ) {
279
$server = 'https://wp.api.litespeedtech.com' ;
206
* @access public
207
* @param array $data
208
*/
209
+ public static function post( $action, $data = false, $server = false, $no_hash = false )
210
{
211
$instance = self::get_instance() ;
212
218
$instance->_request_key() ;
219
}
220
221
+ return $instance->_post( $action, $data, $server, $no_hash ) ;
222
}
223
224
/**
269
* @access private
270
* @param array $data
271
*/
272
+ private function _post( $action, $data = false, $server = false, $no_hash = false )
273
{
274
+ $hash = 'no_hash' ;
275
+ if ( ! $no_hash ) {
276
+ $hash = Litespeed_String::rrand( 16 ) ;
277
+ // store hash
278
+ update_option( self::DB_API_KEY_HASH, $hash ) ;
279
+ }
280
281
if ( $server == false ) {
282
$server = 'https://wp.api.litespeedtech.com' ;
admin/litespeed-cache-admin-display.class.php CHANGED
@@ -65,9 +65,8 @@ class LiteSpeed_Cache_Admin_Display
65
$manage = 'manage_options' ;
66
}
67
if ( current_user_can($manage) ) {
68
- if ( defined( 'LITESPEED_ON' ) ) {
69
- add_action( 'wp_before_admin_bar_render', array( LiteSpeed_Cache_GUI::get_instance(), 'backend_shortcut' ) ) ;
70
- }
71
add_action('admin_enqueue_scripts', array($this, 'check_messages')) ;// We can do this bcos admin_notices hook is after admin_enqueue_scripts hook in wp-admin/admin-header.php
72
}
73
@@ -217,7 +216,7 @@ class LiteSpeed_Cache_Admin_Display
217
$localize_data[ 'ajax_url_dismiss_ruleconflict' ] = $ajax_url ;
218
}
219
220
- if ( LiteSpeed_Cache_GUI::has_promo_msg() ) {
221
$ajax_url_promo = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, true ) ;
222
$localize_data[ 'ajax_url_promo' ] = $ajax_url_promo ;
223
}
@@ -345,21 +344,6 @@ class LiteSpeed_Cache_Admin_Display
345
require_once LSCWP_DIR . 'admin/tpl/inc/help_tabs.php' ;
346
}
347
348
- /**
349
- * Check to make sure that caching is enabled.
350
- *
351
- * @since 1.0.0
352
- * @access public
353
- * @return mixed True if enabled, error message otherwise.
354
- */
355
- public function check_license()
356
- {
357
- if ( ! defined( 'LITESPEED_ALLOWED' ) ) {
358
- self::add_error(LiteSpeed_Cache_Admin_Error::E_SERVER) ;
359
- self::display_messages() ;
360
- }
361
- }
362
-
363
/**
364
* Builds the html for a single notice.
365
*
@@ -665,6 +649,17 @@ class LiteSpeed_Cache_Admin_Display
665
require_once LSCWP_DIR . 'admin/tpl/inc/show_error_cookie.php' ;
666
}
667
668
/**
669
* Build a textarea
670
*
65
$manage = 'manage_options' ;
66
}
67
if ( current_user_can($manage) ) {
68
+ add_action( 'wp_before_admin_bar_render', array( LiteSpeed_Cache_GUI::get_instance(), 'backend_shortcut' ) ) ;
69
+
70
add_action('admin_enqueue_scripts', array($this, 'check_messages')) ;// We can do this bcos admin_notices hook is after admin_enqueue_scripts hook in wp-admin/admin-header.php
71
}
72
216
$localize_data[ 'ajax_url_dismiss_ruleconflict' ] = $ajax_url ;
217
}
218
219
+ if ( LiteSpeed_Cache_GUI::has_promo_msg() || LiteSpeed_Cache_GUI::has_promo_msg( 'slack' ) ) {
220
$ajax_url_promo = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, true ) ;
221
$localize_data[ 'ajax_url_promo' ] = $ajax_url_promo ;
222
}
344
require_once LSCWP_DIR . 'admin/tpl/inc/help_tabs.php' ;
345
}
346
347
/**
348
* Builds the html for a single notice.
349
*
649
require_once LSCWP_DIR . 'admin/tpl/inc/show_error_cookie.php' ;
650
}
651
652
+ /**
653
+ * Display warning if lscache is disabled
654
+ *
655
+ * @since 2.1
656
+ * @access public
657
+ */
658
+ public function cache_disabled_warning()
659
+ {
660
+ include LSCWP_DIR . "admin/tpl/inc/check_cache_disabled.php" ;
661
+ }
662
+
663
/**
664
* Build a textarea
665
*
admin/litespeed-cache-admin-error.class.php CHANGED
@@ -52,8 +52,6 @@ class LiteSpeed_Cache_Admin_Error
52
53
const E_LC_MISMATCH = 5000 ; // login cookie mismatch
54
55
- const E_SERVER = 6000 ;
56
-
57
const E_CONF = 9000 ; // general config failed to write.
58
const E_HTA_BU = 9010 ; // backup
59
const E_HTA_PUT = 9020 ; // failed to put
@@ -188,12 +186,6 @@ class LiteSpeed_Cache_Admin_Error
188
. __('Login cookies do not match.', 'litespeed-cache') . ' '
189
. __('Please remove both and set the login cookie in LiteSpeed Cache advanced settings.', 'litespeed-cache') ;
190
191
- // Either running another server or doesn't have cache module.
192
- case self::E_SERVER:
193
- return __('Notice: This plugin requires a LiteSpeed Server with the LSCache Module enabled.', 'litespeed-cache') . ' '
194
- . __('If you are unable to change your server stack, please contact your hosting provider to request the required changes.', 'litespeed-cache') . ' '
195
- . __('This plugin will NOT work properly.', 'litespeed-cache') ;
196
-
197
case self::E_CONF:
198
return __('LiteSpeed Cache was unable to write to the wp-config.php file.', 'litespeed-cache') . ' '
199
. sprintf(__('Please add the following to the wp-config.php file: %s', 'litespeed-cache'), '<br><pre>define(\'WP_CACHE\', true);</pre>') ;
52
53
const E_LC_MISMATCH = 5000 ; // login cookie mismatch
54
55
const E_CONF = 9000 ; // general config failed to write.
56
const E_HTA_BU = 9010 ; // backup
57
const E_HTA_PUT = 9020 ; // failed to put
186
. __('Login cookies do not match.', 'litespeed-cache') . ' '
187
. __('Please remove both and set the login cookie in LiteSpeed Cache advanced settings.', 'litespeed-cache') ;
188
189
case self::E_CONF:
190
return __('LiteSpeed Cache was unable to write to the wp-config.php file.', 'litespeed-cache') . ' '
191
. sprintf(__('Please add the following to the wp-config.php file: %s', 'litespeed-cache'), '<br><pre>define(\'WP_CACHE\', true);</pre>') ;
admin/litespeed-cache-admin-report.class.php CHANGED
@@ -139,8 +139,10 @@ class LiteSpeed_Cache_Admin_Report
139
'home_url' => home_url(),
140
'locale' => get_locale(),
141
'active theme' => $active_theme,
142
- 'active plugins' => $active_plugins,
143
) ;
144
if ( is_null($options) ) {
145
$options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
146
}
@@ -196,6 +198,25 @@ class LiteSpeed_Cache_Admin_Report
196
$server_vars = array_intersect_key($server, $server_keys) ;
197
$server_vars[] = "LSWCP_TAG_PREFIX = " . LSWCP_TAG_PREFIX ;
198
199
$buf = $this->format_report_section('Server Variables', $server_vars) ;
200
201
$buf .= $this->format_report_section('Wordpress Specific Extras', $extras) ;
@@ -232,30 +253,29 @@ class LiteSpeed_Cache_Admin_Report
232
* @param array $section An array of information to output
233
* @return string The created report block.
234
*/
235
- private function format_report_section($section_header, $section)
236
{
237
$tab = ' ' ; // four spaces
238
- $nl = "\n" ;
239
240
- if ( empty($section) ) {
241
- return 'No matching ' . $section_header . $nl . $nl ;
242
}
243
$buf = $section_header ;
244
245
- foreach ( $section as $key=>$val ) {
246
- $buf .= $nl . $tab ;
247
- if ( ! is_numeric($key) ) {
248
- $buf .= $key . ' = ' ;
249
- }
250
251
- if ( ! is_string($val) ) {
252
- $buf .= var_export($val, true) ;
253
}
254
- else {
255
- $buf .= $val ;
256
}
257
}
258
- return $buf . $nl . $nl ;
259
}
260
261
/**
139
'home_url' => home_url(),
140
'locale' => get_locale(),
141
'active theme' => $active_theme,
142
) ;
143
+
144
+ $extras[ 'active plugins' ] = $active_plugins ;
145
+
146
if ( is_null($options) ) {
147
$options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
148
}
198
$server_vars = array_intersect_key($server, $server_keys) ;
199
$server_vars[] = "LSWCP_TAG_PREFIX = " . LSWCP_TAG_PREFIX ;
200
201
+ $consts = array(
202
+ 'WP_SITEURL',
203
+ 'WP_HOME',
204
+ 'WP_CONTENT_DIR',
205
+ 'SHORTINIT',
206
+ 'LSCWP_CONTENT_DIR',
207
+ 'LSCWP_DIR',
208
+ 'LITESPEED_TIME_OFFSET',
209
+ 'LITESPEED_SERVER_TYPE',
210
+ 'LITESPEED_CLI',
211
+ 'LITESPEED_ALLOWED',
212
+ 'LITESPEED_ON',
213
+ 'LITESPEED_ON_IN_SETTING',
214
+ 'LSCACHE_ADV_CACHE',
215
+ ) ;
216
+ foreach ( $consts as $v ) {
217
+ $server_vars[ $v ] = defined( $v ) ? constant( $v ) : NULL ;
218
+ }
219
+
220
$buf = $this->format_report_section('Server Variables', $server_vars) ;
221
222
$buf .= $this->format_report_section('Wordpress Specific Extras', $extras) ;
253
* @param array $section An array of information to output
254
* @return string The created report block.
255
*/
256
+ private function format_report_section( $section_header, $section )
257
{
258
$tab = ' ' ; // four spaces
259
260
+ if ( empty( $section ) ) {
261
+ return 'No matching ' . $section_header . "\n\n" ;
262
}
263
$buf = $section_header ;
264
265
+ foreach ( $section as $k => $v ) {
266
+ $buf .= "\n" . $tab ;
267
268
+ if ( ! is_numeric( $k ) ) {
269
+ $buf .= $k . ' = ' ;
270
}
271
+
272
+ if ( ! is_string( $v ) ) {
273
+ $v = var_export( $v, true ) ;
274
}
275
+
276
+ $buf .= $v ;
277
}
278
+ return $buf . "\n\n" ;
279
}
280
281
/**
admin/litespeed-cache-admin-settings.class.php CHANGED
@@ -567,10 +567,14 @@ class LiteSpeed_Cache_Admin_Settings
567
$id = LiteSpeed_Cache_Config::OPID_CDN_ORI ;
568
$this->_options[ $id ] = $this->_input[ $id ] ;
569
if ( $this->_options[ $id ] ) {
570
- $tmp = parse_url( $this->_options[ $id ] ) ;
571
- if ( ! empty( $tmp[ 'scheme' ] ) ) {
572
- $this->_options[ $id ] = str_replace( $tmp[ 'scheme' ] . ':', '', $this->_options[ $id ] ) ;
573
}
574
}
575
576
$ids = array(
@@ -648,7 +652,7 @@ class LiteSpeed_Cache_Admin_Settings
648
649
// If cloudflare API is on, refresh the zone
650
if ( $this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE ] && $cdn_cloudflare_changed ) {
651
- $zone = LiteSpeed_Cache_CDN::get_instance()->cloudflare_fetch_zone( $this->_options ) ;
652
if ( $zone ) {
653
$this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_NAME ] = $zone[ 'name' ] ;
654
$this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_ZONE ] = $zone[ 'id' ] ;
567
$id = LiteSpeed_Cache_Config::OPID_CDN_ORI ;
568
$this->_options[ $id ] = $this->_input[ $id ] ;
569
if ( $this->_options[ $id ] ) {
570
+ $ori_list = explode( ',', $this->_options[ $id ] ) ;
571
+ foreach ( $ori_list as $k => $v ) {
572
+ $tmp = parse_url( $v ) ;
573
+ if ( ! empty( $tmp[ 'scheme' ] ) ) {
574
+ $ori_list[ $k ] = str_replace( $tmp[ 'scheme' ] . ':', '', $v ) ;
575
+ }
576
}
577
+ $this->_options[ $id ] = implode( ',', $ori_list ) ;
578
}
579
580
$ids = array(
652
653
// If cloudflare API is on, refresh the zone
654
if ( $this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE ] && $cdn_cloudflare_changed ) {
655
+ $zone = LiteSpeed_Cache_CDN_Cloudflare::get_instance()->fetch_zone( $this->_options ) ;
656
if ( $zone ) {
657
$this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_NAME ] = $zone[ 'name' ] ;
658
$this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_ZONE ] = $zone[ 'id' ] ;
admin/litespeed-cache-admin.class.php CHANGED
@@ -70,7 +70,7 @@ class LiteSpeed_Cache_Admin
70
// check for upgrade
71
// NOTE: upgrade checking needs to be before `register_setting` to avoid update_options() be checked by our filter
72
$this->config->plugin_upgrade() ;
73
- if ( is_network_admin() && current_user_can('manage_network_options') ) {
74
$this->config->plugin_site_upgrade() ;
75
}
76
@@ -96,13 +96,13 @@ class LiteSpeed_Cache_Admin
96
register_setting(LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, array(LiteSpeed_Cache_Admin_Settings::get_instance(), 'validate_plugin_settings')) ;
97
}
98
99
// step out if plugin is not enabled
100
if ( ! defined( 'LITESPEED_ON' ) ) {
101
return ;
102
}
103
104
- do_action( 'litspeed_after_admin_init' ) ;
105
-
106
LiteSpeed_Cache_Control::set_nocache( 'Admin page' ) ;
107
108
if ( LiteSpeed_Cache_Router::esi_enabled() ) {
@@ -168,7 +168,7 @@ class LiteSpeed_Cache_Admin
168
// Save network settings
169
case LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK:
170
$options = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings() ;// todo: use wp network setting saving
171
- LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report($options) ;
172
break ;
173
174
default:
70
// check for upgrade
71
// NOTE: upgrade checking needs to be before `register_setting` to avoid update_options() be checked by our filter
72
$this->config->plugin_upgrade() ;
73
+ if ( is_network_admin() && current_user_can( 'manage_network_options' ) ) {
74
$this->config->plugin_site_upgrade() ;
75
}
76
96
register_setting(LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, array(LiteSpeed_Cache_Admin_Settings::get_instance(), 'validate_plugin_settings')) ;
97
}
98
99
+ do_action( 'litspeed_after_admin_init' ) ;
100
+
101
// step out if plugin is not enabled
102
if ( ! defined( 'LITESPEED_ON' ) ) {
103
return ;
104
}
105
106
LiteSpeed_Cache_Control::set_nocache( 'Admin page' ) ;
107
108
if ( LiteSpeed_Cache_Router::esi_enabled() ) {
168
// Save network settings
169
case LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK:
170
$options = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings() ;// todo: use wp network setting saving
171
+ // LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report($options) ; // As we don't save env report, no need this anymore
172
break ;
173
174
default:
admin/tpl/crawler.php CHANGED
@@ -18,7 +18,7 @@ $is_running = time() - $meta[ 'is_running' ] <= $_options[LiteSpeed_Cache_Config
18
19
$disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
20
21
- include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.php" ;
22
?>
23
24
<div class="wrap">
@@ -32,8 +32,6 @@ include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.php" ;
32
33
</div>
34
35
- <?php include_once LSCWP_DIR . "admin/tpl/inc/check_cache_disabled.php" ; ?>
36
-
37
<div class="litespeed-wrap">
38
<div class="litespeed-body">
39
<h3 class="litespeed-title"><?php echo __('Crawler File', 'litespeed-cache') ; ?></h3>
18
19
$disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
20
21
+ LiteSpeed_Cache_GUI::show_promo() ;
22
?>
23
24
<div class="wrap">
32
33
</div>
34
35
<div class="litespeed-wrap">
36
<div class="litespeed-body">
37
<h3 class="litespeed-title"><?php echo __('Crawler File', 'litespeed-cache') ; ?></h3>
admin/tpl/image_optimization.php CHANGED
@@ -62,7 +62,7 @@ else {
62
$finished_percentage = 0 ;
63
}
64
65
- include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.php" ;
66
?>
67
68
<div class="wrap">
@@ -75,8 +75,6 @@ include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.php" ;
75
<hr class="wp-header-end">
76
</div>
77
78
- <?php include_once LSCWP_DIR . "admin/tpl/inc/check_cache_disabled.php" ; ?>
79
-
80
<div class="litespeed-wrap">
81
<div class="litespeed-body">
82
<?php if ( $current_step ) : ?>
@@ -121,9 +119,7 @@ include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.php" ;
121
122
<?php include_once LSCWP_DIR . "admin/tpl/inc/api_key.php" ; ?>
123
124
- <h3 class="litespeed-title"><?php echo __('Image Information', 'litespeed-cache') ; ?>
125
- <span class="litespeed-desc"><?php echo __('Beta Version', 'litespeed-cache') ; ?></span>
126
- </h3>
127
128
<div class="litespeed-block-tiny">
129
<div class="litespeed-col-auto">
62
$finished_percentage = 0 ;
63
}
64
65
+ LiteSpeed_Cache_GUI::show_promo() ;
66
?>
67
68
<div class="wrap">
75
<hr class="wp-header-end">
76
</div>
77
78
<div class="litespeed-wrap">
79
<div class="litespeed-body">
80
<?php if ( $current_step ) : ?>
119
120
<?php include_once LSCWP_DIR . "admin/tpl/inc/api_key.php" ; ?>
121
122
+ <h3 class="litespeed-title"><?php echo __('Image Information', 'litespeed-cache') ; ?></h3>
123
124
<div class="litespeed-block-tiny">
125
<div class="litespeed-col-auto">
admin/tpl/import_export.php CHANGED
@@ -14,8 +14,6 @@ $log = get_option( LiteSpeed_Cache_Import::DB_IMPORT_LOG, array() ) ;
14
<hr class="wp-header-end">
15
</div>
16
17
- <?php include_once LSCWP_DIR . "admin/tpl/inc/check_cache_disabled.php" ; ?>
18
-
19
<div class="litespeed-wrap">
20
<div class="litespeed-body">
21
<h3 class="litespeed-title"><?php echo __('Export Settings', 'litespeed-cache') ; ?></h3>
14
<hr class="wp-header-end">
15
</div>
16
17
<div class="litespeed-wrap">
18
<div class="litespeed-body">
19
<h3 class="litespeed-title"><?php echo __('Export Settings', 'litespeed-cache') ; ?></h3>
admin/tpl/inc/banner_promo.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
if ( ! defined( 'WPINC' ) ) die ;
3
4
- if ( ! LiteSpeed_Cache_GUI::has_promo_msg() ) {
5
return ;
6
}
7
1
<?php
2
if ( ! defined( 'WPINC' ) ) die ;
3
4
+ if ( ! LiteSpeed_Cache_GUI::should_show_promo() ) {
5
return ;
6
}
7
admin/tpl/inc/banner_promo.slack.php ADDED
@@ -0,0 +1,33 @@
1
+ <?php
2
+ if ( ! defined( 'WPINC' ) ) die ;
3
+
4
+ if ( ! LiteSpeed_Cache_GUI::should_show_promo( 'slack' ) ) {
5
+ return ;
6
+ }
7
+
8
+ ?>
9
+ <div class="litespeed-wrap notice notice-info litespeed-banner-promo-full is-dismissible" id="litespeed-banner-promo-slack">
10
+ <div class="litespeed-banner-promo-logo"></div>
11
+
12
+ <div class="litespeed-banner-promo-content">
13
+ <h1><?php echo __( 'Welcome to LiteSpeed', 'litespeed-cache' ) ; ?></h1>
14
+
15
+ <div class="litespeed-banner-promo">
16
+
17
+ <div class="litespeed-banner-promo-slacklogo"></div>
18
+
19
+ <div class="litespeed-banner-promo-content">
20
+ <p class="litespeed-banner-promo-slack-line1">
21
+ <?php echo __( 'Want to connect with other LiteSpeed users?', 'litespeed-cache' ) ; ?>
22
+ <?php echo sprintf( __( 'Join the %s community.', 'litespeed-cache' ), '<a href="https://goo.gl/mrKuTw" target="_blank" class="litespeed-banner-promo-slack-textlink">LiteSpeed Slack</a>' ) ; ?>
23
+ </p>
24
+
25
+ <p class="litespeed-banner-promo-slack-line2">
26
+ <span class="litespeed-banner-promo-slack-link">golitespeed.slack.com</span>
27
+ <a href="https://goo.gl/mrKuTw" target="_blank" class="litespeed-btn-success litespeed-btn-xs litespeed-banner-promo-slack-btn"><?php echo __( 'Join Us on Slack', 'litespeed-cache' ) ; ?></a>
28
+ </p>
29
+ </div>
30
+
31
+ </div>
32
+ </div>
33
+ </div>
admin/tpl/inc/check_cache_disabled.php CHANGED
@@ -1,12 +1,48 @@
1
<?php
2
if ( ! defined( 'WPINC' ) ) die ;
3
4
- if ( defined( 'LITESPEED_ON' ) ) {
5
- return ;
6
}
7
?>
8
9
- <div class="litespeed-callout-warning">
10
- <h4><?php echo __('WARNING: LiteSpeed cache is disabled. The functionalities here can not work.', 'litespeed-cache'); ?></h4>
11
- </div>
12
1
<?php
2
if ( ! defined( 'WPINC' ) ) die ;
3
4
+ $reasons = array() ;
5
+
6
+ if ( ! defined( 'LITESPEED_ALLOWED' ) ) {
7
+ $reasons[] = array(
8
+ 'title' => __( 'LSCache Module is disabled.', 'litespeed-cache' ),
9
+ 'link' => 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache#prerequisites',
10
+ ) ;
11
+ }
12
+
13
+ if ( ! defined( 'LITESPEED_ON_IN_SETTING' ) ) {
14
+ $reasons[] = array(
15
+ 'title' => __( 'LiteSpeed cache is disabled in setting.', 'litespeed-cache' ) ,
16
+ 'link' => 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:general#enable_litespeed_cache',
17
+ ) ;
18
+ }
19
+
20
+ if ( ! $reasons && ! defined( 'LITESPEED_ON' ) ) {
21
+ $reasons[] = array(
22
+ 'title' => __( 'LiteSpeed cache is disabled.', 'litespeed-cache' ) ,
23
+ 'link' => 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:general#enable_litespeed_cache',
24
+ ) ;
25
}
26
+
27
+ if ( $reasons ) :
28
?>
29
+ <div class="litespeed-callout-danger">
30
+
31
+ <h4><?php echo __( 'WARNING', 'litespeed-cache' ) ; ?></h4>
32
+
33
+ <p>
34
+ <?php echo __( 'The functionalities here can not work due to:', 'litespeed-cache' ) ; ?>
35
+ </p>
36
+
37
+ <ul class="litespeed-list">
38
+ <?php foreach ( $reasons as $v ) : ?>
39
+ <li>
40
+ <?php echo $v[ 'title' ] ; ?>
41
42
+ <a href="<?php echo $v[ 'link' ] ; ?>" target="_blank" class="litespeed-learn-more"><?php echo __( 'How to fix it?', 'litespeed-cache' ) ; ?></a>
43
+ </li>
44
+ <?php endforeach ; ?>
45
+ </ul>
46
47
+ </div>
48
+ <?php endif ;
admin/tpl/manage.php CHANGED
@@ -1,8 +1,6 @@
1
<?php
2
if (!defined('WPINC')) die;
3
4
- LiteSpeed_Cache_Admin_Display::get_instance()->check_license();
5
-
6
$menu_list = array(
7
'purge' => __('Purge', 'litespeed-cache'),
8
'db' => __('DB Optimizer', 'litespeed-cache'),
@@ -12,7 +10,7 @@ if ( ! is_network_admin() ) {
12
$menu_list[ 'cdn' ] = __( 'CDN', 'litespeed-cache' ) ;
13
}
14
15
- include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.php" ;
16
?>
17
18
<div class="wrap">
@@ -44,8 +42,6 @@ include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.php" ;
44
?>
45
</h2>
46
47
- <?php include_once LSCWP_DIR . "admin/tpl/inc/check_cache_disabled.php" ; ?>
48
-
49
<div class="litespeed-body">
50
<?php
51
1
<?php
2
if (!defined('WPINC')) die;
3
4
$menu_list = array(
5
'purge' => __('Purge', 'litespeed-cache'),
6
'db' => __('DB Optimizer', 'litespeed-cache'),
10
$menu_list[ 'cdn' ] = __( 'CDN', 'litespeed-cache' ) ;
11
}
12
13
+ LiteSpeed_Cache_GUI::show_promo() ;
14
?>
15
16
<div class="wrap">
42
?>
43
</h2>
44
45
<div class="litespeed-body">
46
<?php
47
admin/tpl/manage/manage_cdn.php CHANGED
@@ -24,13 +24,13 @@ $curr_status = get_option( LiteSpeed_Cache_Config::ITEM_CLOUDFLARE_STATUS, array
24
25
<p>
26
<b><?php echo __( 'Development Mode', 'litespeed-cache' ) ; ?>:</b>
27
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN, LiteSpeed_Cache_CDN::TYPE_CLOUDFLARE_SET_DEVMODE_ON ) ; ?>" class="litespeed-btn-warning">
28
<?php echo __( 'Turn ON', 'litespeed-cache' ) ; ?>
29
</a>
30
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN, LiteSpeed_Cache_CDN::TYPE_CLOUDFLARE_SET_DEVMODE_OFF ) ; ?>" class="litespeed-btn-warning">
31
<?php echo __( 'Turn OFF', 'litespeed-cache' ) ; ?>
32
</a>
33
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN, LiteSpeed_Cache_CDN::TYPE_CLOUDFLARE_GET_DEVMODE ) ; ?>" class="litespeed-btn-success">
34
<?php echo __( 'Check Status', 'litespeed-cache' ) ; ?>
35
</a>
36
@@ -66,7 +66,7 @@ $curr_status = get_option( LiteSpeed_Cache_Config::ITEM_CLOUDFLARE_STATUS, array
66
<?php if ( ! $cf_on ) : ?>
67
<a href="#" class="litespeed-btn-default disabled">
68
<?php else : ?>
69
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN, LiteSpeed_Cache_CDN::TYPE_CLOUDFLARE_PURGE_ALL ) ; ?>" class="litespeed-btn-danger">
70
<?php endif ; ?>
71
<?php echo __( 'Purge Everything', 'litespeed-cache' ) ; ?>
72
</a>
24
25
<p>
26
<b><?php echo __( 'Development Mode', 'litespeed-cache' ) ; ?>:</b>
27
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE, LiteSpeed_Cache_CDN_Cloudflare::TYPE_SET_DEVMODE_ON ) ; ?>" class="litespeed-btn-warning">
28
<?php echo __( 'Turn ON', 'litespeed-cache' ) ; ?>
29
</a>
30
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE, LiteSpeed_Cache_CDN_Cloudflare::TYPE_SET_DEVMODE_OFF ) ; ?>" class="litespeed-btn-warning">
31
<?php echo __( 'Turn OFF', 'litespeed-cache' ) ; ?>
32
</a>
33
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE, LiteSpeed_Cache_CDN_Cloudflare::TYPE_GET_DEVMODE ) ; ?>" class="litespeed-btn-success">
34
<?php echo __( 'Check Status', 'litespeed-cache' ) ; ?>
35
</a>
36
66
<?php if ( ! $cf_on ) : ?>
67
<a href="#" class="litespeed-btn-default disabled">
68
<?php else : ?>
69
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE, LiteSpeed_Cache_CDN_Cloudflare::TYPE_PURGE_ALL ) ; ?>" class="litespeed-btn-danger">
70
<?php endif ; ?>
71
<?php echo __( 'Purge Everything', 'litespeed-cache' ) ; ?>
72
</a>
admin/tpl/manage/manage_purge.php CHANGED
@@ -93,6 +93,8 @@ if ( ! is_multisite() || is_network_admin() ) {
93
94
?>
95
96
<h3 class="litespeed-title"><?php echo __('Purge', 'litespeed-cache'); ?></h3>
97
98
<div class="litespeed-panel-wrapper">
93
94
?>
95
96
+ <?php include_once LSCWP_DIR . "admin/tpl/inc/check_cache_disabled.php" ; ?>
97
+
98
<h3 class="litespeed-title"><?php echo __('Purge', 'litespeed-cache'); ?></h3>
99
100
<div class="litespeed-panel-wrapper">
admin/tpl/setting/settings_cache.php CHANGED
@@ -7,6 +7,8 @@ if ( ! defined( 'WPINC' ) ) die ;
7
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:cache" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
8
</h3>
9
10
<table><tbody>
11
<tr>
12
<th><?php echo __( 'Cache Logged-in Users', 'litespeed-cache' ) ; ?></th>
7
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:cache" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
8
</h3>
9
10
+ <?php $this->cache_disabled_warning() ; ?>
11
+
12
<table><tbody>
13
<tr>
14
<th><?php echo __( 'Cache Logged-in Users', 'litespeed-cache' ) ; ?></th>
admin/tpl/setting/settings_cdn.php CHANGED
@@ -128,6 +128,7 @@ if ( ! $cdn_mapping ) {
128
<div class="litespeed-desc">
129
<?php echo sprintf( __( 'Site URL to be served through the CDN. Beginning with %1$s. For example, %2$s.', 'litespeed-cache' ), '<code>//</code>', '<code>' . $home_url . '</code>' ) ; ?>
130
<br /><?php echo sprintf( __( 'Wildcard %1$s supported (match zero or more characters). For example, to match %2$s and %3$s, use %4$s.', 'litespeed-cache' ), '<code>*</code>', '<code>//www.aa.com</code>', '<code>//aa.com</code>', '<code>//*aa.com</code>' ) ; ?>
131
</div>
132
</td>
133
</tr>
@@ -179,7 +180,7 @@ if ( ! $cdn_mapping ) {
179
<div class="litespeed-desc">
180
<?php echo sprintf( __( 'Use %s API functionality.', 'litespeed-cache' ), 'Quic Cloud' ) ; ?>
181
182
- <a id='litespeed_modal_href' href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_QUIC_CLOUD ) ; ?>">
183
<?php if ( ! empty( $_options[ LiteSpeed_Cache_Config::OPID_CDN_QUIC_EMAIL ] ) ) : ?>
184
Login API
185
<?php else : ?>
128
<div class="litespeed-desc">
129
<?php echo sprintf( __( 'Site URL to be served through the CDN. Beginning with %1$s. For example, %2$s.', 'litespeed-cache' ), '<code>//</code>', '<code>' . $home_url . '</code>' ) ; ?>
130
<br /><?php echo sprintf( __( 'Wildcard %1$s supported (match zero or more characters). For example, to match %2$s and %3$s, use %4$s.', 'litespeed-cache' ), '<code>*</code>', '<code>//www.aa.com</code>', '<code>//aa.com</code>', '<code>//*aa.com</code>' ) ; ?>
131
+ <br /><?php echo sprintf( __( 'Separate multiple original URLs with a %s.', 'litespeed-cache' ), '<code>,</code>' ) ; ?>
132
</div>
133
</td>
134
</tr>
180
<div class="litespeed-desc">
181
<?php echo sprintf( __( 'Use %s API functionality.', 'litespeed-cache' ), 'Quic Cloud' ) ; ?>
182
183
+ <a id='litespeed_modal_href' href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_QUICCLOUD ) ; ?>">
184
<?php if ( ! empty( $_options[ LiteSpeed_Cache_Config::OPID_CDN_QUIC_EMAIL ] ) ) : ?>
185
Login API
186
<?php else : ?>
admin/tpl/setting/settings_esi.php CHANGED
@@ -8,6 +8,7 @@ if ( ! defined( 'WPINC' ) ) die ;
8
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:esi" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
9
</h3>
10
11
12
<div class="litespeed-desc">
13
<p><?php echo __('With ESI (Edge Side Includes), pages may be served from cache for logged-in users.', 'litespeed-cache'); ?></p>
8
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:esi" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
9
</h3>
10
11
+ <?php $this->cache_disabled_warning() ; ?>
12
13
<div class="litespeed-desc">
14
<p><?php echo __('With ESI (Edge Side Includes), pages may be served from cache for logged-in users.', 'litespeed-cache'); ?></p>
admin/tpl/setting/settings_excludes.php CHANGED
@@ -6,6 +6,9 @@ if ( ! defined( 'WPINC' ) ) die ;
6
<?php echo __('Do Not Cache Settings', 'litespeed-cache'); ?>
7
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:excludes" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
8
</h3>
9
<table><tbody>
10
<tr>
11
<th><?php echo __( 'Do Not Cache URIs', 'litespeed-cache' ) ; ?></th>
6
<?php echo __('Do Not Cache Settings', 'litespeed-cache'); ?>
7
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:excludes" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
8
</h3>
9
+
10
+ <?php $this->cache_disabled_warning() ; ?>
11
+
12
<table><tbody>
13
<tr>
14
<th><?php echo __( 'Do Not Cache URIs', 'litespeed-cache' ) ; ?></th>
admin/tpl/setting/settings_general.php CHANGED
@@ -8,6 +8,8 @@ if (!defined('WPINC')) die;
8
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:general" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
9
</h3>
10
11
<table><tbody>
12
<tr>
13
<th><?php echo __('Enable LiteSpeed Cache', 'litespeed-cache'); ?></th>
8
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:general" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
9
</h3>
10
11
+ <?php $this->cache_disabled_warning() ; ?>
12
+
13
<table><tbody>
14
<tr>
15
<th><?php echo __('Enable LiteSpeed Cache', 'litespeed-cache'); ?></th>
admin/tpl/setting/settings_purge.php CHANGED
@@ -8,6 +8,8 @@ if (!defined('WPINC')) die;
8
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:purge" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
9
</h3>
10
11
<?php
12
$purge_options = LiteSpeed_Cache_Config::get_instance()->get_purge_options();
13
$optionArr = array(
8
<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:purge" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
9
</h3>
10
11
+ <?php $this->cache_disabled_warning() ; ?>
12
+
13
<?php
14
$purge_options = LiteSpeed_Cache_Config::get_instance()->get_purge_options();
15
$optionArr = array(
admin/tpl/settings.php CHANGED
@@ -1,8 +1,6 @@
1
<?php
2
if (!defined('WPINC')) die ;
3
4
- $this->check_license() ;
5
-
6
$menu_list = array(
7
'general' => __('General', 'litespeed-cache'),
8
'cache' => __('Cache', 'litespeed-cache'),
@@ -87,7 +85,7 @@ foreach ( $wp_roles->roles as $k => $v ) {
87
}
88
ksort( $roles ) ;
89
90
- include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.php" ;
91
92
/**
93
* Switch basic/advanced mode
1
<?php
2
if (!defined('WPINC')) die ;
3
4
$menu_list = array(
5
'general' => __('General', 'litespeed-cache'),
6
'cache' => __('Cache', 'litespeed-cache'),
85
}
86
ksort( $roles ) ;
87
88
+ LiteSpeed_Cache_GUI::show_promo() ;
89
90
/**
91
* Switch basic/advanced mode
css/litespeed.css CHANGED
@@ -700,6 +700,11 @@ h3 .litespeed-learn-more {
700
right: 0px;
701
}
702
703
/********************************* label *******************************/
704
[class*="litespeed-label-"] {
705
display: inline;
@@ -1157,11 +1162,17 @@ ul.litespeed-shell-body {
1157
}
1158
1159
/********************************* promo banner *******************************/
1160
- .litespeed-banner-promo{
1161
display: flex;
1162
padding: 10px;
1163
}
1164
1165
.litespeed-banner-promo-logo{
1166
background-image: url("../img/lscwp-logo_256x256.png") ;
1167
background-size: contain;
@@ -1172,10 +1183,64 @@ ul.litespeed-shell-body {
1172
display: inline-block;
1173
}
1174
1175
.litespeed-banner-promo-content{
1176
margin-left: 20px;
1177
}
1178
1179
/********************************* admin -> media lib icon *******************************/
1180
.litespeed-media-href {
1181
display: inline-table;
@@ -1260,8 +1325,10 @@ circle.litespeed-pie_circle {
1260
g.litespeed-pie_info text{
1261
alignment-baseline: central;
1262
text-anchor: middle;
1263
}
1264
1265
/********************************* block and columns *******************************/
1266
.litespeed-block,
1267
.litespeed-block-tiny {
700
right: 0px;
701
}
702
703
+ .litespeed-list li:before {
704
+ content: '>' ;
705
+ color: #cc3d6a ;
706
+ }
707
+
708
/********************************* label *******************************/
709
[class*="litespeed-label-"] {
710
display: inline;
1162
}
1163
1164
/********************************* promo banner *******************************/
1165
+ .litespeed-banner-promo,
1166
+ .litespeed-banner-promo-full{
1167
display: flex;
1168
padding: 10px;
1169
}
1170
1171
+ .litespeed-banner-promo-full{
1172
+ margin:0px;
1173
+ padding: 0px;
1174
+ }
1175
+
1176
.litespeed-banner-promo-logo{
1177
background-image: url("../img/lscwp-logo_256x256.png") ;
1178
background-size: contain;
1183
display: inline-block;
1184
}
1185
1186
+ .litespeed-banner-promo-full .litespeed-banner-promo-logo {
1187
+ margin: 0px;
1188
+ width: 170px;
1189
+ }
1190
+
1191
.litespeed-banner-promo-content{
1192
margin-left: 20px;
1193
}
1194
1195
+ .litespeed-banner-promo-full .litespeed-banner-promo-content {
1196
+ width: 100%;
1197
+ }
1198
+
1199
+ .litespeed-banner-promo-content h1{
1200
+ font-weight: 600;
1201
+ color:#538ac6;
1202
+ margin-top: 10px;
1203
+ }
1204
+
1205
+ .litespeed-banner-promo-slacklogo{
1206
+ background-image: url("../img/slack-logo.png") ;
1207
+ background-size: contain;
1208
+ width: 75px;
1209
+ height: 75px;
1210
+ background-repeat: no-repeat;
1211
+ display: inline-block;
1212
+ padding:0px;
1213
+ flex: 0 0 5%;
1214
+ }
1215
+
1216
+ .litespeed-banner-promo .litespeed-banner-promo-slack-line1{
1217
+ font-size: 18px;
1218
+ margin-top:0px;
1219
+ line-height: 21px;
1220
+ }
1221
+
1222
+ .litespeed-banner-promo .litespeed-banner-promo-slack-textlink{
1223
+ color: #e59544;
1224
+ text-decoration: none;
1225
+ }
1226
+
1227
+ .litespeed-banner-promo .litespeed-banner-promo-slack-textlink:hover{
1228
+ opacity: 0.8;
1229
+ }
1230
+
1231
+ .litespeed-banner-promo-slack-line2{
1232
+ font-size: 18px;
1233
+ margin: 0px;
1234
+ }
1235
+
1236
+ .litespeed-banner-promo-slack-link{
1237
+ color: #888888;
1238
+ }
1239
+
1240
+ a.litespeed-btn-xs.litespeed-banner-promo-slack-btn{
1241
+ margin:0px 50px 0px 50px;
1242
+ }
1243
+
1244
/********************************* admin -> media lib icon *******************************/
1245
.litespeed-media-href {
1246
display: inline-table;
1325
g.litespeed-pie_info text{
1326
alignment-baseline: central;
1327
text-anchor: middle;
1328
+ font-size: 11px ;
1329
}
1330
1331
+
1332
/********************************* block and columns *******************************/
1333
.litespeed-block,
1334
.litespeed-block-tiny {
img/slack-logo.png ADDED
Binary file
inc/activation.class.php CHANGED
@@ -38,7 +38,7 @@ class LiteSpeed_Cache_Activation
38
}
39
do_action( 'litespeed_cache_api_load_thirdparty' ) ;
40
LiteSpeed_Cache_Config::get_instance()->plugin_activation( $count ) ;
41
- LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report() ;
42
43
if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
44
set_transient( LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL ) ;
38
}
39
do_action( 'litespeed_cache_api_load_thirdparty' ) ;
40
LiteSpeed_Cache_Config::get_instance()->plugin_activation( $count ) ;
41
+ // LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report() ;
42
43
if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
44
set_transient( LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL ) ;
inc/cdn.class.php CHANGED
@@ -16,11 +16,6 @@ class LiteSpeed_Cache_CDN
16
17
const BYPASS = 'LITESPEED_BYPASS_CDN' ;
18
19
- const TYPE_CLOUDFLARE_PURGE_ALL = 'cloudflare_purge_all' ;
20
- const TYPE_CLOUDFLARE_GET_DEVMODE = 'cloudflare_get_devmode' ;
21
- const TYPE_CLOUDFLARE_SET_DEVMODE_ON = 'cloudflare_set_devmode_on' ;
22
- const TYPE_CLOUDFLARE_SET_DEVMODE_OFF = 'cloudflare_set_devmode_off' ;
23
-
24
private $content ;
25
26
private $cfg_cdn ;
@@ -126,6 +121,8 @@ class LiteSpeed_Cache_CDN
126
LiteSpeed_Cache_Log::debug2( 'CDN: translated rule is ' . $this->cfg_url_ori ) ;
127
}
128
129
$this->cfg_cdn_exclude = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_EXCLUDE ) ;
130
$this->cfg_cdn_exclude = explode( "\n", $this->cfg_cdn_exclude ) ;
131
@@ -184,18 +181,6 @@ class LiteSpeed_Cache_CDN
184
$type = LiteSpeed_Cache_Router::verify_type() ;
185
186
switch ( $type ) {
187
- case self::TYPE_CLOUDFLARE_PURGE_ALL :
188
- $instance->_cloudflare_purge_all() ;
189
- break ;
190
-
191
- case self::TYPE_CLOUDFLARE_GET_DEVMODE :
192
- $instance->_cloudflare_get_devmode() ;
193
- break ;
194
-
195
- case self::TYPE_CLOUDFLARE_SET_DEVMODE_ON :
196
- case self::TYPE_CLOUDFLARE_SET_DEVMODE_OFF :
197
- $instance->_cloudflare_set_devmode( $type ) ;
198
- break ;
199
200
default:
201
break ;
@@ -225,23 +210,6 @@ class LiteSpeed_Cache_CDN
225
return false ;
226
}
227
228
- /**
229
- * Check if the host is the CDN internal host
230
- *
231
- * @since 1.2.3
232
- *
233
- */
234
- public static function internal( $host )
235
- {
236
- if ( defined( self::BYPASS ) ) {
237
- return false ;
238
- }
239
-
240
- $instance = self::get_instance() ;
241
-
242
- return in_array( $host, $instance->cdn_mapping_hosts ) ;
243
- }
244
-
245
/**
246
* Run CDN process
247
* NOTE: As this is after cache finalized, can NOT set any cache control anymore
@@ -506,9 +474,11 @@ class LiteSpeed_Cache_CDN
506
}
507
508
// Check if is external url
509
- if ( ! empty( $url_parsed[ 'host' ] ) && ! LiteSpeed_Cache_Utility::internal( $url_parsed[ 'host' ] ) ) {
510
- LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: host not internal' ) ;
511
- return false ;
512
}
513
514
if ( $this->cfg_cdn_exclude ) {
@@ -551,11 +521,13 @@ class LiteSpeed_Cache_CDN
551
}
552
553
// Now lets replace CDN url
554
- if ( strpos( $this->cfg_url_ori, '*' ) !== false ) {
555
- $url = preg_replace( '#' . $scheme . $this->cfg_url_ori . '#iU', $final_url, $url ) ;
556
- }
557
- else {
558
- $url = str_replace( $scheme . $this->cfg_url_ori, $final_url, $url ) ;
559
}
560
LiteSpeed_Cache_Log::debug2( 'CDN: after rewritten: ' . $url ) ;
561
@@ -563,248 +535,75 @@ class LiteSpeed_Cache_CDN
563
}
564
565
/**
566
- * Remote load jQuery remotely
567
- *
568
- * @since 1.5
569
- * @access public
570
- */
571
- public function load_jquery_remotely()
572
- {
573
- // default jq version
574
- $v = '1.12.4' ;
575
-
576
- // load wp's jq version
577
- global $wp_scripts ;
578
- if ( isset( $wp_scripts->registered[ 'jquery' ]->ver ) ) {
579
- $v = $wp_scripts->registered[ 'jquery' ]->ver ;
580
- }
581
-
582
- $src = $this->cfg_cdn_remote_jquery === LiteSpeed_Cache_Config::VAL_ON ? "//ajax.googleapis.com/ajax/libs/jquery/$v/jquery.min.js" : "//cdnjs.cloudflare.com/ajax/libs/jquery/$v/jquery.min.js" ;
583
-
584
- LiteSpeed_Cache_Log::debug2( 'CDN: load_jquery_remotely: ' . $src ) ;
585
-
586
- wp_deregister_script( 'jquery' ) ;
587
-
588
- wp_register_script( 'jquery', $src, false, $v ) ;
589
- }
590
-
591
- /**
592
- * Get Cloudflare development mode
593
*
594
- * @since 1.7.2
595
* @access private
596
*/
597
- private function _cloudflare_get_devmode( $show_msg = true )
598
{
599
- LiteSpeed_Cache_Log::debug( 'CDN: _cloudflare_get_devmode' ) ;
600
-
601
- $zone = $this->_cloudflare_zone() ;
602
- if ( ! $zone ) {
603
- return ;
604
- }
605
-
606
- $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/settings/development_mode' ;
607
- $res = $this->_cloudflare_call( $url, 'GET', false, false, $show_msg ) ;
608
-
609
- if ( ! $res ) {
610
- return ;
611
- }
612
- LiteSpeed_Cache_Log::debug( 'CDN: _cloudflare_get_devmode result ', $res ) ;
613
-
614
- $curr_status = get_option( LiteSpeed_Cache_Config::ITEM_CLOUDFLARE_STATUS, array() ) ;
615
- $curr_status[ 'devmode' ] = $res[ 'value' ] ;
616
- $curr_status[ 'devmode_expired' ] = $res[ 'time_remaining' ] + time() ;
617
-
618
- // update status
619
- update_option( LiteSpeed_Cache_Config::ITEM_CLOUDFLARE_STATUS, $curr_status ) ;
620
-
621
- }
622
-
623
- /**
624
- * Set Cloudflare development mode
625
- *
626
- * @since 1.7.2
627
- * @access private
628
- */
629
- private function _cloudflare_set_devmode( $type )
630
- {
631
- LiteSpeed_Cache_Log::debug( 'CDN: _cloudflare_set_devmode' ) ;
632
-
633
- $zone = $this->_cloudflare_zone() ;
634
- if ( ! $zone ) {
635
- return ;
636
- }
637
-
638
- $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/settings/development_mode' ;
639
- $new_val = $type == self::TYPE_CLOUDFLARE_SET_DEVMODE_ON ? 'on' : 'off' ;
640
- $data = array( 'value' => $new_val ) ;
641
- $res = $this->_cloudflare_call( $url, 'PATCH', $data ) ;
642
-
643
- if ( ! $res ) {
644
- return ;
645
- }
646
-
647
- $res = $this->_cloudflare_get_devmode( false ) ;
648
-
649
- if ( $res ) {
650
- $msg = sprintf( __( 'Notified Cloudflare to set development mode to %s successfully.', 'litespeed-cache' ), strtoupper( $new_val ) ) ;
651
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
652
- }
653
-
654
- }
655
-
656
- /**
657
- * Purge Cloudflare cache
658
- *
659
- * @since 1.7.2
660
- * @access private
661
- */
662
- private function _cloudflare_purge_all()
663
- {
664
- LiteSpeed_Cache_Log::debug( 'CDN: _cloudflare_purge_all' ) ;
665
666
- $cf_on = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE ) ;
667
- if ( ! $cf_on ) {
668
- $msg = __( 'Cloudflare API is set to off.', 'litespeed-cache' ) ;
669
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
670
- return ;
671
- }
672
673
- $zone = $this->_cloudflare_zone() ;
674
- if ( ! $zone ) {
675
- return ;
676
}
677
678
- $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/purge_cache' ;
679
- $data = array( 'purge_everything' => true ) ;
680
-
681
- $res = $this->_cloudflare_call( $url, 'DELETE', $data ) ;
682
-
683
- if ( $res ) {
684
- $msg = __( 'Notified Cloudflare to purge all successfully.', 'litespeed-cache' ) ;
685
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
686
- }
687
}
688
689
/**
690
- * Get current Cloudflare zone from cfg
691
*
692
- * @since 1.7.2
693
- * @access private
694
- */
695
- private function _cloudflare_zone()
696
- {
697
- $zone = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_ZONE ) ;
698
- if ( ! $zone ) {
699
- $msg = __( 'No available Cloudflare zone', 'litespeed-cache' ) ;
700
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
701
- return false ;
702
- }
703
-
704
- return $zone ;
705
- }
706
-
707
- /**
708
- * Get Cloudflare zone settings
709
*
710
- * @since 1.7.2
711
- * @access public
712
*/
713
- public function cloudflare_fetch_zone( $options )
714
{
715
- $kw = $options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_NAME ] ;
716
-
717
- $url = 'https://api.cloudflare.com/client/v4/zones?status=active&match=all' ;
718
-
719
- // Try exact match first
720
- if ( $kw && strpos( $kw, '.' ) ) {
721
- $zones = $this->_cloudflare_call( $url . '&name=' . $kw, 'GET', false, $options, false ) ;
722
- if ( $zones ) {
723
- LiteSpeed_Cache_Log::debug( 'CDN: cloudflare_fetch_zone exact matched' ) ;
724
- return $zones[ 0 ] ;
725
- }
726
- }
727
-
728
- // Can't find, try to get default one
729
- $zones = $this->_cloudflare_call( $url, 'GET', false, $options, false ) ;
730
-
731
- if ( ! $zones ) {
732
- LiteSpeed_Cache_Log::debug( 'CDN: cloudflare_fetch_zone no zone' ) ;
733
return false ;
734
}
735
736
- if ( ! $kw ) {
737
- LiteSpeed_Cache_Log::debug( 'CDN: cloudflare_fetch_zone no set name, use first one by default' ) ;
738
- return $zones[ 0 ] ;
739
- }
740
-
741
- foreach ( $zones as $v ) {
742
- if ( strpos( $v[ 'name' ], $kw ) !== false ) {
743
- LiteSpeed_Cache_Log::debug( 'CDN: cloudflare_fetch_zone matched ' . $kw . ' [name] ' . $v[ 'name' ] ) ;
744
- return $v ;
745
- }
746
- }
747
748
- // Can't match current name, return default one
749
- LiteSpeed_Cache_Log::debug( 'CDN: cloudflare_fetch_zone failed match name, use first one by default' ) ;
750
- return $zones[ 0 ] ;
751
}
752
753
/**
754
- * Cloudflare API
755
*
756
- * @since 1.7.2
757
- * @access private
758
*/
759
- private function _cloudflare_call( $url, $method = 'GET', $data = false, $token = false, $show_msg = true )
760
{
761
- LiteSpeed_Cache_Log::debug( "CDN: _cloudflare_call \t\t[URL] $url" ) ;
762
763
- $header = array(
764
- 'Content-Type: application/json',
765
- ) ;
766
- if ( $token ) {
767
- LiteSpeed_Cache_Log::debug2( 'CDN: _cloudflare_call use param token' ) ;
768
- $header[] = 'X-Auth-Email: ' . $token[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_EMAIL ] ;
769
- $header[] = 'X-Auth-Key: ' . $token[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_KEY ] ;
770
- }
771
- else {
772
- $header[] = 'X-Auth-Email: ' . LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_EMAIL ) ;
773
- $header[] = 'X-Auth-Key: ' . LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_KEY ) ;
774
- }
775
-
776
- $ch = curl_init() ;
777
- curl_setopt( $ch, CURLOPT_URL, $url ) ;
778
- curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $method ) ;
779
- curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ) ;
780
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ) ;
781
- if ( $data ) {
782
- if ( is_array( $data ) ) {
783
- $data = json_encode( $data ) ;
784
- }
785
- curl_setopt( $ch, CURLOPT_POSTFIELDS, $data ) ;
786
}
787
- $result = curl_exec( $ch ) ;
788
789
- $json = json_decode( $result, true ) ;
790
-
791
- if ( $json && $json[ 'success' ] && $json[ 'result' ] ) {
792
- LiteSpeed_Cache_Log::debug( "CDN: _cloudflare_call called successfully" ) ;
793
- if ( $show_msg ) {
794
- $msg = __( 'Communicated with Cloudflare successfully.', 'litespeed-cache' ) ;
795
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
796
- }
797
798
- return $json[ 'result' ] ;
799
- }
800
801
- LiteSpeed_Cache_Log::debug( "CDN: _cloudflare_call called failed: $result" ) ;
802
- if ( $show_msg ) {
803
- $msg = __( 'Failed to communicate with Cloudflare', 'litespeed-cache' ) ;
804
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
805
- }
806
807
- return false ;
808
}
809
810
/**
@@ -816,7 +615,7 @@ class LiteSpeed_Cache_CDN
816
*/
817
public static function get_instance()
818
{
819
- if ( ! isset(self::$_instance) ) {
820
self::$_instance = new self() ;
821
}
822
@@ -824,6 +623,3 @@ class LiteSpeed_Cache_CDN
824
}
825
826
}
827
-
828
-
829
-
16
17
const BYPASS = 'LITESPEED_BYPASS_CDN' ;
18
19
private $content ;
20
21
private $cfg_cdn ;
121
LiteSpeed_Cache_Log::debug2( 'CDN: translated rule is ' . $this->cfg_url_ori ) ;
122
}
123
124
+ $this->cfg_url_ori = explode( ',', $this->cfg_url_ori ) ;
125
+
126
$this->cfg_cdn_exclude = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_EXCLUDE ) ;
127
$this->cfg_cdn_exclude = explode( "\n", $this->cfg_cdn_exclude ) ;
128
181
$type = LiteSpeed_Cache_Router::verify_type() ;
182
183
switch ( $type ) {
184
185
default:
186
break ;
210
return false ;
211
}
212
213
/**
214
* Run CDN process
215
* NOTE: As this is after cache finalized, can NOT set any cache control anymore
474
}
475
476
// Check if is external url
477
+ if ( ! empty( $url_parsed[ 'host' ] ) ) {
478
+ if ( ! LiteSpeed_Cache_Utility::internal( $url_parsed[ 'host' ] ) && ! $this->_is_ori_url( $url ) ) {
479
+ LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: host not internal' ) ;
480
+ return false ;
481
+ }
482
}
483
484
if ( $this->cfg_cdn_exclude ) {
521
}
522
523
// Now lets replace CDN url
524
+ foreach ( $this->cfg_url_ori as $v ) {
525
+ if ( strpos( $v, '*' ) !== false ) {
526
+ $url = preg_replace( '#' . $scheme . $v . '#iU', $final_url, $url ) ;
527
+ }
528
+ else {
529
+ $url = str_replace( $scheme . $v, $final_url, $url ) ;
530
+ }
531
}
532
LiteSpeed_Cache_Log::debug2( 'CDN: after rewritten: ' . $url ) ;
533
535
}
536
537
/**
538
+ * Check if is orignal URL of CDN or not
539
*
540
+ * @since 2.1
541
* @access private
542
*/
543
+ private function _is_ori_url( $url )
544
{
545
+ $url_parsed = parse_url( $url ) ;
546
547
+ $scheme = ! empty( $url_parsed[ 'scheme' ] ) ? $url_parsed[ 'scheme' ] . ':' : '' ;
548
549
+ foreach ( $this->cfg_url_ori as $v ) {
550
+ $needle = $scheme . $v ;
551
+ if ( strpos( $v, '*' ) !== false ) {
552
+ if( preg_match( '#' . $needle . '#iU', $url ) ) {
553
+ return true ;
554
+ }
555
+ }
556
+ else {
557
+ if ( strpos( $url, $needle ) === 0 ) {
558
+ return true ;
559
+ }
560
+ }
561
}
562
563
+ return false ;
564
}
565
566
/**
567
+ * Check if the host is the CDN internal host
568
*
569
+ * @since 1.2.3
570
*
571
*/
572
+ public static function internal( $host )
573
{
574
+ if ( defined( self::BYPASS ) ) {
575
return false ;
576
}
577
578
+ $instance = self::get_instance() ;
579
580
+ return in_array( $host, $instance->cdn_mapping_hosts ) ;// todo: can add $this->_is_ori_url() check in future
581
}
582
583
/**
584
+ * Remote load jQuery remotely
585
*
586
+ * @since 1.5
587
+ * @access public
588
*/
589
+ public function load_jquery_remotely()
590
{
591
+ // default jq version
592
+ $v = '1.12.4' ;
593
594
+ // load wp's jq version
595
+ global $wp_scripts ;
596
+ if ( isset( $wp_scripts->registered[ 'jquery' ]->ver ) ) {
597
+ $v = $wp_scripts->registered[ 'jquery' ]->ver ;
598
}
599
600
+ $src = $this->cfg_cdn_remote_jquery === LiteSpeed_Cache_Config::VAL_ON ? "//ajax.googleapis.com/ajax/libs/jquery/$v/jquery.min.js" : "//cdnjs.cloudflare.com/ajax/libs/jquery/$v/jquery.min.js" ;
601
602
+ LiteSpeed_Cache_Log::debug2( 'CDN: load_jquery_remotely: ' . $src ) ;
603
604
+ wp_deregister_script( 'jquery' ) ;
605
606
+ wp_register_script( 'jquery', $src, false, $v ) ;
607
}
608
609
/**
615
*/
616
public static function get_instance()
617
{
618
+ if ( ! isset( self::$_instance ) ) {
619
self::$_instance = new self() ;
620
}
621
623
}
624
625
}
inc/cdn/cloudflare.class.php ADDED
@@ -0,0 +1,289 @@
1
+ <?php
2
+
3
+ /**
4
+ * The cloudflare CDN class.
5
+ *
6
+ * @since 2.1
7
+ * @package LiteSpeed_Cache
8
+ * @subpackage LiteSpeed_Cache/inc/cdn
9
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
10
+ */
11
+
12
+ class LiteSpeed_Cache_CDN_Cloudflare
13
+ {
14
+ private static $_instance ;
15
+
16
+ const TYPE_PURGE_ALL = 'purge_all' ;
17
+ const TYPE_GET_DEVMODE = 'get_devmode' ;
18
+ const TYPE_SET_DEVMODE_ON = 'set_devmode_on' ;
19
+ const TYPE_SET_DEVMODE_OFF = 'set_devmode_off' ;
20
+
21
+ /**
22
+ * Handle all request actions from main cls
23
+ *
24
+ * @since 1.7.2
25
+ * @access public
26
+ */
27
+ public static function handler()
28
+ {
29
+ $instance = self::get_instance() ;
30
+
31
+ $type = LiteSpeed_Cache_Router::verify_type() ;
32
+
33
+ switch ( $type ) {
34
+ case self::TYPE_PURGE_ALL :
35
+ $instance->_purge_all() ;
36
+ break ;
37
+
38
+ case self::TYPE_GET_DEVMODE :
39
+ $instance->_get_devmode() ;
40
+ break ;
41
+
42
+ case self::TYPE_SET_DEVMODE_ON :
43
+ case self::TYPE_SET_DEVMODE_OFF :
44
+ $instance->_set_devmode( $type ) ;
45
+ break ;
46
+
47
+ default:
48
+ break ;
49
+ }
50
+
51
+ LiteSpeed_Cache_Admin::redirect() ;
52
+ }
53
+
54
+ /**
55
+ * Get Cloudflare development mode
56
+ *
57
+ * @since 1.7.2
58
+ * @access private
59
+ */
60
+ private function _get_devmode( $show_msg = true )
61
+ {
62
+ LiteSpeed_Cache_Log::debug( '[Cloudflare] _get_devmode' ) ;
63
+
64
+ $zone = $this->_zone() ;
65
+ if ( ! $zone ) {
66
+ return ;
67
+ }
68
+
69
+ $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/settings/development_mode' ;
70
+ $res = $this->_cloudflare_call( $url, 'GET', false, false, $show_msg ) ;
71
+
72
+ if ( ! $res ) {
73
+ return ;
74
+ }
75
+ LiteSpeed_Cache_Log::debug( '[Cloudflare] _get_devmode result ', $res ) ;
76
+
77
+ $curr_status = get_option( LiteSpeed_Cache_Config::ITEM_CLOUDFLARE_STATUS, array() ) ;
78
+ $curr_status[ 'devmode' ] = $res[ 'value' ] ;
79
+ $curr_status[ 'devmode_expired' ] = $res[ 'time_remaining' ] + time() ;
80
+
81
+ // update status
82
+ update_option( LiteSpeed_Cache_Config::ITEM_CLOUDFLARE_STATUS, $curr_status ) ;
83
+
84
+ }
85
+
86
+ /**
87
+ * Set Cloudflare development mode
88
+ *
89
+ * @since 1.7.2
90
+ * @access private
91
+ */
92
+ private function _set_devmode( $type )
93
+ {
94
+ LiteSpeed_Cache_Log::debug( '[Cloudflare] _set_devmode' ) ;
95
+
96
+ $zone = $this->_zone() ;
97
+ if ( ! $zone ) {
98
+ return ;
99
+ }
100
+
101
+ $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/settings/development_mode' ;
102
+ $new_val = $type == self::TYPE_SET_DEVMODE_ON ? 'on' : 'off' ;
103
+ $data = array( 'value' => $new_val ) ;
104
+ $res = $this->_cloudflare_call( $url, 'PATCH', $data ) ;
105
+
106
+ if ( ! $res ) {
107
+ return ;
108
+ }
109
+
110
+ $res = $this->_get_devmode( false ) ;
111
+
112
+ if ( $res ) {
113
+ $msg = sprintf( __( 'Notified Cloudflare to set development mode to %s successfully.', 'litespeed-cache' ), strtoupper( $new_val ) ) ;
114
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
115
+ }
116
+
117
+ }
118
+
119
+ /**
120
+ * Purge Cloudflare cache
121
+ *
122
+ * @since 1.7.2
123
+ * @access private
124
+ */
125
+ private function _purge_all()
126
+ {
127
+ LiteSpeed_Cache_Log::debug( '[Cloudflare] _purge_all' ) ;
128
+
129
+ $cf_on = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE ) ;
130
+ if ( ! $cf_on ) {
131
+ $msg = __( 'Cloudflare API is set to off.', 'litespeed-cache' ) ;
132
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
133
+ return ;
134
+ }
135
+
136
+ $zone = $this->_zone() ;
137
+ if ( ! $zone ) {
138
+ return ;
139
+ }
140
+
141
+ $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/purge_cache' ;
142
+ $data = array( 'purge_everything' => true ) ;
143
+
144
+ $res = $this->_cloudflare_call( $url, 'DELETE', $data ) ;
145
+
146
+ if ( $res ) {
147
+ $msg = __( 'Notified Cloudflare to purge all successfully.', 'litespeed-cache' ) ;
148
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
149
+ }
150
+ }
151
+
152
+ /**
153
+ * Get current Cloudflare zone from cfg
154
+ *
155
+ * @since 1.7.2
156
+ * @access private
157
+ */
158
+ private function _zone()
159
+ {
160
+ $zone = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_ZONE ) ;
161
+ if ( ! $zone ) {
162
+ $msg = __( 'No available Cloudflare zone', 'litespeed-cache' ) ;
163
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
164
+ return false ;
165
+ }
166
+
167
+ return $zone ;
168
+ }
169
+
170
+ /**
171
+ * Get Cloudflare zone settings
172
+ *
173
+ * @since 1.7.2
174
+ * @access public
175
+ */
176
+ public function fetch_zone( $options )
177
+ {
178
+ $kw = $options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_NAME ] ;
179
+
180
+ $url = 'https://api.cloudflare.com/client/v4/zones?status=active&match=all' ;
181
+
182
+ // Try exact match first
183
+ if ( $kw && strpos( $kw, '.' ) ) {
184
+ $zones = $this->_cloudflare_call( $url . '&name=' . $kw, 'GET', false, $options, false ) ;
185
+ if ( $zones ) {
186
+ LiteSpeed_Cache_Log::debug( '[Cloudflare] fetch_zone exact matched' ) ;
187
+ return $zones[ 0 ] ;
188
+ }
189
+ }
190
+
191
+ // Can't find, try to get default one
192
+ $zones = $this->_cloudflare_call( $url, 'GET', false, $options, false ) ;
193
+
194
+ if ( ! $zones ) {
195
+ LiteSpeed_Cache_Log::debug( '[Cloudflare] fetch_zone no zone' ) ;
196
+ return false ;
197
+ }
198
+
199
+ if ( ! $kw ) {
200
+ LiteSpeed_Cache_Log::debug( '[Cloudflare] fetch_zone no set name, use first one by default' ) ;
201
+ return $zones[ 0 ] ;
202
+ }
203
+
204
+ foreach ( $zones as $v ) {
205
+ if ( strpos( $v[ 'name' ], $kw ) !== false ) {
206
+ LiteSpeed_Cache_Log::debug( '[Cloudflare] fetch_zone matched ' . $kw . ' [name] ' . $v[ 'name' ] ) ;
207
+ return $v ;
208
+ }
209
+ }
210
+
211
+ // Can't match current name, return default one
212
+ LiteSpeed_Cache_Log::debug( '[Cloudflare] fetch_zone failed match name, use first one by default' ) ;
213
+ return $zones[ 0 ] ;
214
+ }
215
+
216
+ /**
217
+ * Cloudflare API
218
+ *
219
+ * @since 1.7.2
220
+ * @access private
221
+ */
222
+ private function _cloudflare_call( $url, $method = 'GET', $data = false, $token = false, $show_msg = true )
223
+ {
224
+ LiteSpeed_Cache_Log::debug( "[Cloudflare] _cloudflare_call \t\t[URL] $url" ) ;
225
+
226
+ $header = array(
227
+ 'Content-Type: application/json',
228
+ ) ;
229
+ if ( $token ) {
230
+ LiteSpeed_Cache_Log::debug2( '[Cloudflare] _cloudflare_call use param token' ) ;
231
+ $header[] = 'X-Auth-Email: ' . $token[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_EMAIL ] ;
232
+ $header[] = 'X-Auth-Key: ' . $token[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_KEY ] ;
233
+ }
234
+ else {
235
+ $header[] = 'X-Auth-Email: ' . LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_EMAIL ) ;
236
+ $header[] = 'X-Auth-Key: ' . LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_KEY ) ;
237
+ }
238
+
239
+ $ch = curl_init() ;
240
+ curl_setopt( $ch, CURLOPT_URL, $url ) ;
241
+ curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $method ) ;
242
+ curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ) ;
243
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ) ;
244
+ if ( $data ) {
245
+ if ( is_array( $data ) ) {
246
+ $data = json_encode( $data ) ;
247
+ }
248
+ curl_setopt( $ch, CURLOPT_POSTFIELDS, $data ) ;
249
+ }
250
+ $result = curl_exec( $ch ) ;
251
+
252
+ $json = json_decode( $result, true ) ;
253
+
254
+ if ( $json && $json[ 'success' ] && $json[ 'result' ] ) {
255
+ LiteSpeed_Cache_Log::debug( "[Cloudflare] _cloudflare_call called successfully" ) ;
256
+ if ( $show_msg ) {
257
+ $msg = __( 'Communicated with Cloudflare successfully.', 'litespeed-cache' ) ;
258
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
259
+ }
260
+
261
+ return $json[ 'result' ] ;
262
+ }
263
+
264
+ LiteSpeed_Cache_Log::debug( "[Cloudflare] _cloudflare_call called failed: $result" ) ;
265
+ if ( $show_msg ) {
266
+ $msg = __( 'Failed to communicate with Cloudflare', 'litespeed-cache' ) ;
267
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
268
+ }
269
+
270
+ return false ;
271
+ }
272
+
273
+ /**
274
+ * Get the current instance object.
275
+ *
276
+ * @since 1.2.3
277
+ * @access public
278
+ * @return Current class instance.
279
+ */
280
+ public static function get_instance()
281
+ {
282
+ if ( ! isset( self::$_instance ) ) {
283
+ self::$_instance = new self() ;
284
+ }
285
+
286
+ return self::$_instance ;
287
+ }
288
+
289
+ }
inc/config.class.php CHANGED
@@ -229,6 +229,9 @@ class LiteSpeed_Cache_Config
229
}
230
else {
231
$options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
232
}
233
234
$this->options = $options ;
@@ -238,12 +241,7 @@ class LiteSpeed_Cache_Config
238
if ( $this->options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON
239
// || ( is_multisite() && is_network_admin() && current_user_can( 'manage_network_options' ) && $this->options[ LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ] ) todo: need to check when primary is off and network is on, if can manage
240
) {
241
- defined( 'LITESPEED_ALLOWED' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
242
- }
243
-
244
- // Check advanced_cache set
245
- if ( isset( $this->options[ self::OPID_CHECK_ADVANCEDCACHE ] ) && $this->options[ self::OPID_CHECK_ADVANCEDCACHE ] === false && ! defined( 'LSCACHE_ADV_CACHE' ) ) {
246
- define( 'LSCACHE_ADV_CACHE', true ) ;
247
}
248
249
// Vary group settings
@@ -262,6 +260,35 @@ class LiteSpeed_Cache_Config
262
263
}
264
265
/**
266
* For multisite installations, the single site options need to be updated with the network wide options.
267
*
@@ -273,6 +300,8 @@ class LiteSpeed_Cache_Config
273
{
274
$site_options = get_site_option( self::OPTION_NAME ) ;
275
276
$options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
277
278
/**
@@ -287,7 +316,7 @@ class LiteSpeed_Cache_Config
287
// If don't have site options
288
if ( ! $site_options || ! is_array( $site_options ) || ! is_plugin_active_for_network( 'litespeed-cache/litespeed-cache.php' ) ) {
289
if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 ) { // Default to cache on
290
- defined( 'LITESPEED_ALLOWED' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
291
}
292
return $options ;
293
}
@@ -307,7 +336,7 @@ class LiteSpeed_Cache_Config
307
308
// If use network setting
309
if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 && $site_options[ self::NETWORK_OPID_ENABLED ] ) {
310
- defined( 'LITESPEED_ALLOWED' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
311
}
312
// Set network eanble to on
313
if ( $site_options[ self::NETWORK_OPID_ENABLED ] ) {
229
}
230
else {
231
$options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
232
+
233
+ // Check advanced_cache set
234
+ $this->_check_adv_cache( $options ) ;
235
}
236
237
$this->options = $options ;
241
if ( $this->options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON
242
// || ( is_multisite() && is_network_admin() && current_user_can( 'manage_network_options' ) && $this->options[ LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ] ) todo: need to check when primary is off and network is on, if can manage
243
) {
244
+ $this->_define_cache_on() ;
245
}
246
247
// Vary group settings
260
261
}
262
263
+ /**
264
+ * Define `LSCACHE_ADV_CACHE` based on options setting
265
+ *
266
+ * NOTE: this must be before `LITESPEED_ON` defination
267
+ *
268
+ * @since 2.1
269
+ * @access private
270
+ */
271
+ private function _check_adv_cache( $options )
272
+ {
273
+ if ( isset( $options[ self::OPID_CHECK_ADVANCEDCACHE ] ) && $options[ self::OPID_CHECK_ADVANCEDCACHE ] === false && ! defined( 'LSCACHE_ADV_CACHE' ) ) {
274
+ define( 'LSCACHE_ADV_CACHE', true ) ;
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Define `LITESPEED_ON`
280
+ *
281
+ * @since 2.1
282
+ * @access private
283
+ */
284
+ private function _define_cache_on()
285
+ {
286
+ defined( 'LITESPEED_ALLOWED' ) && defined( 'LSCACHE_ADV_CACHE' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
287
+
288
+ // Use this for cache enabled setting check
289
+ ! defined( 'LITESPEED_ON_IN_SETTING' ) && define( 'LITESPEED_ON_IN_SETTING', true ) ;
290
+ }
291
+
292
/**
293
* For multisite installations, the single site options need to be updated with the network wide options.
294
*
300
{
301
$site_options = get_site_option( self::OPTION_NAME ) ;
302
303
+ $this->_check_adv_cache( $site_options ) ;
304
+
305
$options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
306
307
/**
316
// If don't have site options
317
if ( ! $site_options || ! is_array( $site_options ) || ! is_plugin_active_for_network( 'litespeed-cache/litespeed-cache.php' ) ) {
318
if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 ) { // Default to cache on
319
+ $this->_define_cache_on() ;
320
}
321
return $options ;
322
}
336
337
// If use network setting
338
if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 && $site_options[ self::NETWORK_OPID_ENABLED ] ) {
339
+ $this->_define_cache_on() ;
340
}
341
// Set network eanble to on
342
if ( $site_options[ self::NETWORK_OPID_ENABLED ] ) {
inc/data_structure/img_optm.sql CHANGED
@@ -1,6 +1,6 @@
1
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
2
`post_id` bigint(20) unsigned NOT NULL DEFAULT '0',
3
- `optm_status` varchar(255) NOT NULL DEFAULT '',
4
`src` varchar(1000) NOT NULL DEFAULT '',
5
`srcpath_md5` varchar(128) NOT NULL DEFAULT '',
6
`src_md5` varchar(128) NOT NULL DEFAULT '',
1
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
2
`post_id` bigint(20) unsigned NOT NULL DEFAULT '0',
3
+ `optm_status` varchar(64) NOT NULL DEFAULT '',
4
`src` varchar(1000) NOT NULL DEFAULT '',
5
`srcpath_md5` varchar(128) NOT NULL DEFAULT '',
6
`src_md5` varchar(128) NOT NULL DEFAULT '',
inc/gui.class.php CHANGED
@@ -95,6 +95,12 @@ class LiteSpeed_Cache_GUI
95
96
}
97
98
public static function dismiss()
99
{
100
switch ( LiteSpeed_Cache_Router::verify_type() ) {
@@ -107,7 +113,20 @@ class LiteSpeed_Cache_GUI
107
break ;
108
109
case self::TYPE_DISMISS_PROMO :
110
- update_option( 'litespeed-banner-promo', ! empty( $_GET[ 'done' ] ) ? 'done' : time() ) ;
111
break ;
112
113
default:
@@ -142,6 +161,42 @@ class LiteSpeed_Cache_GUI
142
return get_transient( LiteSpeed_Cache::WHM_TRANSIENT ) == LiteSpeed_Cache::WHM_TRANSIENT_VAL ;
143
}
144
145
/**
146
* Check if has promotion notice
147
*
@@ -149,11 +204,22 @@ class LiteSpeed_Cache_GUI
149
* @access public
150
* @return boolean
151
*/
152
- public static function has_promo_msg()
153
{
154
- $promo = get_option( 'litespeed-banner-promo' ) ;
155
if ( ! $promo ) {
156
- update_option( 'litespeed-banner-promo', time() - 86400 * 8 ) ;
157
return false ;
158
}
159
if ( $promo == 'done' ) {
@@ -162,6 +228,7 @@ class LiteSpeed_Cache_GUI
162
if ( $promo && time() - $promo < 864000 ) {
163
return false ;
164
}
165
return true ;
166
}
167
@@ -260,12 +327,21 @@ class LiteSpeed_Cache_GUI
260
{
261
global $wp_admin_bar ;
262
263
- $wp_admin_bar->add_menu( array(
264
- 'id' => 'litespeed-menu',
265
- 'title' => '<span class="ab-icon" title="' . __( 'LiteSpeed Cache Purge All', 'litespeed-cache' ) . '""></span>',
266
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE_ALL ),
267
- 'meta' => array( 'tabindex' => 0, 'class' => 'litespeed-top-toolbar' ),
268
- ) ) ;
269
270
$wp_admin_bar->add_menu( array(
271
'parent' => 'litespeed-menu',
@@ -306,7 +382,7 @@ class LiteSpeed_Cache_GUI
306
'parent' => 'litespeed-menu',
307
'id' => 'litespeed-purge-cloudflare',
308
'title' => __( 'Cloudflare Purge All', 'litespeed-cache' ),
309
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN, LiteSpeed_Cache_CDN::TYPE_CLOUDFLARE_PURGE_ALL ),
310
'meta' => array( 'tabindex' => '0' ),
311
) );
312
}
95
96
}
97
98
+ /**
99
+ * Dismiss banner
100
+ *
101
+ * @since 1.0
102
+ * @access public
103
+ */
104
public static function dismiss()
105
{
106
switch ( LiteSpeed_Cache_Router::verify_type() ) {
113
break ;
114
115
case self::TYPE_DISMISS_PROMO :
116
+
117
+ if ( ! empty( $_GET[ 'slack' ] ) ) {
118
+ // Update slack
119
+ update_option( 'litespeed-banner-promo-slack', 'done' ) ;
120
+
121
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[GUI] Dismiss promo slack' ) ;
122
+ }
123
+ else {
124
+ // Update welcome banner
125
+ update_option( 'litespeed-banner-promo', ! empty( $_GET[ 'done' ] ) ? 'done' : time() ) ;
126
+
127
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[GUI] Dismiss promo welcome' ) ;
128
+ }
129
+
130
break ;
131
132
default:
161
return get_transient( LiteSpeed_Cache::WHM_TRANSIENT ) == LiteSpeed_Cache::WHM_TRANSIENT_VAL ;
162
}
163
164
+ /**
165
+ * Display promo banner
166
+ *
167
+ * @since 2.1
168
+ * @access public
169
+ */
170
+ public static function show_promo()
171
+ {
172
+ include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.php" ;
173
+ include_once LSCWP_DIR . "admin/tpl/inc/banner_promo.slack.php" ;
174
+ }
175
+
176
+ /**
177
+ * Detect if need to display promo banner or not
178
+ *
179
+ * @since 2.1
180
+ * @access public
181
+ */
182
+ public static function should_show_promo( $banner = false )
183
+ {
184
+ // Only show one promo at one time
185
+ if ( defined( 'LITESPEED_PROMO_SHOWN' ) ) {
186
+ return false ;
187
+ }
188
+
189
+ if ( ! self::has_promo_msg( $banner ) ) {
190
+ return false ;
191
+ }
192
+
193
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[GUI] Show promo ' . $banner ) ;
194
+
195
+ ! defined( 'LITESPEED_PROMO_SHOWN' ) && define( 'LITESPEED_PROMO_SHOWN', true ) ;
196
+
197
+ return true ;
198
+ }
199
+
200
/**
201
* Check if has promotion notice
202
*
204
* @access public
205
* @return boolean
206
*/
207
+ public static function has_promo_msg( $banner = false )
208
{
209
+ // How many days delayed to show the banner
210
+ $delay_days = 2 ;
211
+ if ( $banner == 'slack' ) {
212
+ $delay_days = 3 ;
213
+ }
214
+
215
+ $option_name = 'litespeed-banner-promo' ;
216
+ if ( $banner ) {
217
+ $option_name .= '-' . $banner ;
218
+ }
219
+
220
+ $promo = get_option( $option_name ) ;
221
if ( ! $promo ) {
222
+ update_option( $option_name, time() - 86400 * ( 10 - $delay_days ) ) ;
223
return false ;
224
}
225
if ( $promo == 'done' ) {
228
if ( $promo && time() - $promo < 864000 ) {
229
return false ;
230
}
231
+
232
return true ;
233
}
234
327
{
328
global $wp_admin_bar ;
329
330
+ if ( defined( 'LITESPEED_ON' ) ) {
331
+ $wp_admin_bar->add_menu( array(
332
+ 'id' => 'litespeed-menu',
333
+ 'title' => '<span class="ab-icon" title="' . __( 'LiteSpeed Cache Purge All', 'litespeed-cache' ) . '""></span>',
334
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE_ALL ),
335
+ 'meta' => array( 'tabindex' => 0, 'class' => 'litespeed-top-toolbar' ),
336
+ ) ) ;
337
+ }
338
+ else {
339
+ $wp_admin_bar->add_menu( array(
340
+ 'id' => 'litespeed-menu',
341
+ 'title' => '<span class="ab-icon" title="' . __( 'LiteSpeed Cache', 'litespeed-cache' ) . '""></span>',
342
+ 'meta' => array( 'tabindex' => 0, 'class' => 'litespeed-top-toolbar' ),
343
+ ) ) ;
344
+ }
345
346
$wp_admin_bar->add_menu( array(
347
'parent' => 'litespeed-menu',
382
'parent' => 'litespeed-menu',
383
'id' => 'litespeed-purge-cloudflare',
384
'title' => __( 'Cloudflare Purge All', 'litespeed-cache' ),
385
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE, LiteSpeed_Cache_CDN_Cloudflare::TYPE_PURGE_ALL ),
386
'meta' => array( 'tabindex' => '0' ),
387
) );
388
}
inc/img_optm.class.php CHANGED
@@ -126,7 +126,7 @@ class LiteSpeed_Cache_Img_Optm
126
ORDER BY a.ID DESC
127
LIMIT %d
128
" ;
129
- $q = $wpdb->prepare( $q, apply_filters( 'litespeed_img_optimize_max_rows', 100 ) ) ;
130
131
$img_set = array() ;
132
$list = $wpdb->get_results( $q ) ;
@@ -186,7 +186,7 @@ class LiteSpeed_Cache_Img_Optm
186
$this->_save_missed_into_img_optm() ;
187
188
if ( empty( $this->_img_in_queue ) ) {
189
- $msg = __( 'No image found.', 'litespeed-cache' ) ;
190
LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
191
192
LiteSpeed_Cache_Log::debug( '[Img_Optm] optimize bypass: empty _img_in_queue' ) ;
@@ -765,7 +765,7 @@ class LiteSpeed_Cache_Img_Optm
765
'pid' => $row_img->post_id,
766
'src_md5' => $row_img->src_md5,
767
) ;
768
- $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG, $data, $server ) ;
769
if ( empty( $json[ 'webp' ] ) ) {
770
LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized img: ', $json ) ;
771
return ;
@@ -803,7 +803,7 @@ class LiteSpeed_Cache_Img_Optm
803
$wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
804
805
// Notify server to update status
806
- LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG_FAILED, $data, $server ) ;
807
808
return ;// exit from running pull process
809
}
@@ -850,7 +850,7 @@ class LiteSpeed_Cache_Img_Optm
850
$wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
851
852
// Notify server to update status
853
- LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG_FAILED, $data, $server ) ;
854
855
return ; // exit from running pull process
856
}
126
ORDER BY a.ID DESC
127
LIMIT %d
128
" ;
129
+ $q = $wpdb->prepare( $q, apply_filters( 'litespeed_img_optimize_max_rows', 500 ) ) ;
130
131
$img_set = array() ;
132
$list = $wpdb->get_results( $q ) ;
186
$this->_save_missed_into_img_optm() ;
187
188
if ( empty( $this->_img_in_queue ) ) {
189
+ $msg = __( 'Requested successfully.', 'litespeed-cache' ) ;
190
LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
191
192
LiteSpeed_Cache_Log::debug( '[Img_Optm] optimize bypass: empty _img_in_queue' ) ;
765
'pid' => $row_img->post_id,
766
'src_md5' => $row_img->src_md5,
767
) ;
768
+ $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG, $data, $server, true ) ;
769
if ( empty( $json[ 'webp' ] ) ) {
770
LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized img: ', $json ) ;
771
return ;
803
$wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
804
805
// Notify server to update status
806
+ LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG_FAILED, $data, $server, true ) ;
807
808
return ;// exit from running pull process
809
}
850
$wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
851
852
// Notify server to update status
853
+ LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG_FAILED, $data, $server, true ) ;
854
855
return ; // exit from running pull process
856
}
inc/litespeed-cache.class.php CHANGED
@@ -19,7 +19,7 @@ class LiteSpeed_Cache
19
private static $_instance ;
20
21
const PLUGIN_NAME = 'litespeed-cache' ;
22
- const PLUGIN_VERSION = '2.0' ;
23
24
const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
@@ -47,7 +47,8 @@ class LiteSpeed_Cache
47
const ACTION_CRAWLER_CRON_ENABLE = 'crawler-cron-enable' ;
48
const ACTION_DO_CRAWL = 'do-crawl' ;
49
const ACTION_BLACKLIST_SAVE = 'blacklist-save' ;
50
- const ACTION_QUIC_CLOUD = 'quic_cloud' ;
51
52
const ACTION_FRONT_PURGE = 'front-purge' ;
53
const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
@@ -86,13 +87,14 @@ class LiteSpeed_Cache
86
private function __construct()
87
{
88
LiteSpeed_Cache_Config::get_instance() ;
89
// Check if debug is on
90
- if ( defined( 'LITESPEED_ON' ) ) {
91
- $should_debug = intval(self::config(LiteSpeed_Cache_Config::OPID_DEBUG)) ;
92
- if ( $should_debug == LiteSpeed_Cache_Config::VAL_ON || ($should_debug == LiteSpeed_Cache_Config::VAL_ON2 && LiteSpeed_Cache_Router::is_admin_ip()) ) {
93
- LiteSpeed_Cache_Log::init() ;
94
- }
95
96
// Load third party detection if lscache enabled.
97
include_once LSCWP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
98
}
@@ -108,9 +110,9 @@ class LiteSpeed_Cache
108
// NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
109
if( is_admin() || defined( 'LITESPEED_CLI' ) ) {
110
$plugin_file = LSCWP_DIR . 'litespeed-cache.php' ;
111
- register_activation_hook($plugin_file, array('LiteSpeed_Cache_Activation', 'register_activation' )) ;
112
- register_deactivation_hook($plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' )) ;
113
- register_uninstall_hook($plugin_file, 'LiteSpeed_Cache_Activation::uninstall_litespeed_cache') ;
114
}
115
116
add_action( 'after_setup_theme', array( $this, 'init' ) ) ;
@@ -163,12 +165,12 @@ class LiteSpeed_Cache
163
LiteSpeed_Cache_Admin::get_instance() ;
164
}
165
166
- if ( ! defined( 'LITESPEED_ON' ) || ! defined( 'LSCACHE_ADV_CACHE' ) || ! LSCACHE_ADV_CACHE ) {
167
- return ;
168
- }
169
-
170
LiteSpeed_Cache_Router::get_instance()->is_crawler_role_simulation() ;
171
172
ob_start( array( $this, 'send_headers_force' ) ) ;
173
add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
174
add_action( 'wp_footer', 'LiteSpeed_Cache::footer_hook' ) ;
@@ -342,10 +344,6 @@ class LiteSpeed_Cache
342
$msg = LiteSpeed_Cache_Admin_API::handler() ;
343
break ;
344
345
- case LiteSpeed_Cache::ACTION_CDN:
346
- $msg = LiteSpeed_Cache_CDN::handler() ;
347
- break ;
348
-
349
case LiteSpeed_Cache::ACTION_LOG:
350
$msg = LiteSpeed_Cache_Log::handler() ;
351
break ;
@@ -358,8 +356,12 @@ class LiteSpeed_Cache
358
$msg = LiteSpeed_Cache_Import::handler() ;
359
break ;
360
361
- case LiteSpeed_Cache::ACTION_QUIC_CLOUD:
362
- $msg = LiteSpeed_Cache_QUIC_CLOUD::handler() ;
363
break ;
364
365
default:
@@ -587,17 +589,23 @@ class LiteSpeed_Cache
587
if ( ! defined( 'LSCACHE_IS_ESI' ) ) {
588
$this->footer_comment .= "\n" ;
589
}
590
$this->footer_comment .= sprintf(
591
'<!-- %1$s %2$s by LiteSpeed Cache %4$s on %3$s -->',
592
defined( 'LSCACHE_IS_ESI' ) ? 'Block' : 'Page',
593
- LiteSpeed_Cache_Control::is_cacheable() ? 'generated' : 'uncached',
594
date( 'Y-m-d H:i:s', time() + LITESPEED_TIME_OFFSET ),
595
self::PLUGIN_VERSION
596
) ;
597
}
598
599
// send Control header
600
- if ( $control_header ) {
601
@header( $control_header ) ;
602
if ( defined( 'LSCWP_LOG' ) ) {
603
LiteSpeed_Cache_Log::debug( $control_header ) ;
@@ -606,7 +614,7 @@ class LiteSpeed_Cache
606
}
607
}
608
}
609
- // send PURGE header
610
if ( $purge_header ) {
611
@header( $purge_header ) ;
612
if ( defined( 'LSCWP_LOG' ) ) {
@@ -617,7 +625,7 @@ class LiteSpeed_Cache
617
}
618
}
619
// send Vary header
620
- if ( $vary_header ) {
621
@header( $vary_header ) ;
622
if ( defined( 'LSCWP_LOG' ) ) {
623
LiteSpeed_Cache_Log::debug( $vary_header ) ;
@@ -647,7 +655,7 @@ class LiteSpeed_Cache
647
}
648
else {
649
// Control header
650
- if ( LiteSpeed_Cache_Control::is_cacheable() && $tag_header ) {
651
@header( $tag_header ) ;
652
if ( defined( 'LSCWP_LOG' ) ) {
653
LiteSpeed_Cache_Log::debug( $tag_header ) ;
19
private static $_instance ;
20
21
const PLUGIN_NAME = 'litespeed-cache' ;
22
+ const PLUGIN_VERSION = '2.1' ;
23
24
const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
47
const ACTION_CRAWLER_CRON_ENABLE = 'crawler-cron-enable' ;
48
const ACTION_DO_CRAWL = 'do-crawl' ;
49
const ACTION_BLACKLIST_SAVE = 'blacklist-save' ;
50
+ const ACTION_CDN_CLOUDFLARE = 'cdn_cloudflare' ;
51
+ const ACTION_CDN_QUICCLOUD = 'cdn_quiccloud' ;
52
53
const ACTION_FRONT_PURGE = 'front-purge' ;
54
const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
87
private function __construct()
88
{
89
LiteSpeed_Cache_Config::get_instance() ;
90
+
91
// Check if debug is on
92
+ $should_debug = intval( self::config( LiteSpeed_Cache_Config::OPID_DEBUG ) ) ;
93
+ if ( $should_debug == LiteSpeed_Cache_Config::VAL_ON || ( $should_debug == LiteSpeed_Cache_Config::VAL_ON2 && LiteSpeed_Cache_Router::is_admin_ip() ) ) {
94
+ LiteSpeed_Cache_Log::init() ;
95
+ }
96
97
+ if ( defined( 'LITESPEED_ON' ) ) {
98
// Load third party detection if lscache enabled.
99
include_once LSCWP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
100
}
110
// NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
111
if( is_admin() || defined( 'LITESPEED_CLI' ) ) {
112
$plugin_file = LSCWP_DIR . 'litespeed-cache.php' ;
113
+ register_activation_hook( $plugin_file, array( 'LiteSpeed_Cache_Activation', 'register_activation' ) ) ;
114
+ register_deactivation_hook( $plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' ) ) ;
115
+ register_uninstall_hook( $plugin_file, 'LiteSpeed_Cache_Activation::uninstall_litespeed_cache' ) ;
116
}
117
118
add_action( 'after_setup_theme', array( $this, 'init' ) ) ;
165
LiteSpeed_Cache_Admin::get_instance() ;
166
}
167
168
LiteSpeed_Cache_Router::get_instance()->is_crawler_role_simulation() ;
169
170
+ // if ( ! defined( 'LITESPEED_ON' ) || ! defined( 'LSCACHE_ADV_CACHE' ) || ! LSCACHE_ADV_CACHE ) {
171
+ // return ;
172
+ // }
173
+
174
ob_start( array( $this, 'send_headers_force' ) ) ;
175
add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
176
add_action( 'wp_footer', 'LiteSpeed_Cache::footer_hook' ) ;
344
$msg = LiteSpeed_Cache_Admin_API::handler() ;
345
break ;
346
347
case LiteSpeed_Cache::ACTION_LOG:
348
$msg = LiteSpeed_Cache_Log::handler() ;
349
break ;
356
$msg = LiteSpeed_Cache_Import::handler() ;
357
break ;
358
359
+ case LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE:
360
+ $msg = LiteSpeed_Cache_CDN_Cloudflare::handler() ;
361
+ break ;
362
+
363
+ case LiteSpeed_Cache::ACTION_CDN_QUICCLOUD:
364
+ $msg = LiteSpeed_Cache_CDN_Quiccloud::handler() ;
365
break ;
366
367
default:
589
if ( ! defined( 'LSCACHE_IS_ESI' ) ) {
590
$this->footer_comment .= "\n" ;
591
}
592
+
593
+ $cache_support = 'supported' ;
594
+ if ( defined( 'LITESPEED_ON' ) ) {
595
+ $cache_support = LiteSpeed_Cache_Control::is_cacheable() ? 'generated' : 'uncached' ;
596
+ }
597
+
598
$this->footer_comment .= sprintf(
599
'<!-- %1$s %2$s by LiteSpeed Cache %4$s on %3$s -->',
600
defined( 'LSCACHE_IS_ESI' ) ? 'Block' : 'Page',
601
+ $cache_support,
602
date( 'Y-m-d H:i:s', time() + LITESPEED_TIME_OFFSET ),
603
self::PLUGIN_VERSION
604
) ;
605
}
606
607
// send Control header
608
+ if ( defined( 'LITESPEED_ON_IN_SETTING' ) && $control_header ) {
609
@header( $control_header ) ;
610
if ( defined( 'LSCWP_LOG' ) ) {
611
LiteSpeed_Cache_Log::debug( $control_header ) ;
614
}
615
}
616
}
617
+ // send PURGE header (Always send regardless of cache setting disabled/enabled)
618
if ( $purge_header ) {
619
@header( $purge_header ) ;
620
if ( defined( 'LSCWP_LOG' ) ) {
625
}
626
}
627
// send Vary header
628
+ if ( defined( 'LITESPEED_ON_IN_SETTING' ) && $vary_header ) {
629
@header( $vary_header ) ;
630
if ( defined( 'LSCWP_LOG' ) ) {
631
LiteSpeed_Cache_Log::debug( $vary_header ) ;
655
}
656
else {
657
// Control header
658
+ if ( defined( 'LITESPEED_ON_IN_SETTING' ) && LiteSpeed_Cache_Control::is_cacheable() && $tag_header ) {
659
@header( $tag_header ) ;
660
if ( defined( 'LSCWP_LOG' ) ) {
661
LiteSpeed_Cache_Log::debug( $tag_header ) ;
inc/litespeed.autoload.php CHANGED
@@ -26,6 +26,8 @@ if ( !function_exists('_litespeed_autoload') ) {
26