LiteSpeed Cache - Version 3.0.9

Version Description

  • May 13 2020 =
  • Purge Comment cache can be successfully purged now.
  • Data Better MySQL charset support for crawler/image optimize table creation. (@Roshan Jonah)
  • API New hook to fire after Purge All. (@salvatorefresta)
  • Crawler Resolve IP for crawler.
  • Task PHP5.3 Cron compatibility fix.
  • 3rd Elementor edit mode compatibility.
  • Page Optimize Fixed an issue where Purge Stale returned 404 for next visitor on CSS/JS.
  • Page Optimize Fixed the PHP warning when srcset doesn't have size info inside. (@gvidano)
  • Cloud Fixed the potential PHP warning when applying for the domain key.
  • Core PHP DIR const replacement. (@MathiasReker)
Download this release

Release Info

Developer hailite
Plugin Icon 128x128 LiteSpeed Cache
Version 3.0.9
Comparing to
See all releases

Code changes from version 2.9.9.2 to 3.0.9

Files changed (366) hide show
  1. admin/admin-api.class.php +0 -551
  2. admin/class-litespeed-cache-admin.php +0 -7
  3. admin/litespeed-cache-admin-display.class.php +0 -1195
  4. admin/litespeed-cache-admin-error.class.php +0 -249
  5. admin/litespeed-cache-admin-optimize.class.php +0 -201
  6. admin/litespeed-cache-admin-rules.class.php +0 -1050
  7. admin/litespeed-cache-admin-settings.class.php +0 -1438
  8. admin/litespeed-cache-admin.class.php +0 -302
  9. admin/tpl/api/quic.login.php +0 -37
  10. admin/tpl/api/quic.register.php +0 -41
  11. admin/tpl/api/quic.user_welcome.php +0 -21
  12. admin/tpl/crawler.php +0 -257
  13. admin/tpl/debug_log.php +0 -45
  14. admin/tpl/edit_htaccess.php +0 -79
  15. admin/tpl/image_optimization.php +0 -45
  16. admin/tpl/import_export.php +0 -70
  17. admin/tpl/inc/img_optm.communicate_notify.php +0 -10
  18. admin/tpl/inc/img_optm.initialize.php +0 -38
  19. admin/tpl/inc/img_optm.level_info.php +0 -46
  20. admin/tpl/inc/img_optm.percentage_summary.php +0 -33
  21. admin/tpl/inc/img_optm.summary.php +0 -312
  22. admin/tpl/manage.php +0 -56
  23. admin/tpl/manage/manage_db.php +0 -93
  24. admin/tpl/network_settings.php +0 -60
  25. admin/tpl/report.php +0 -92
  26. admin/tpl/setting/network_settings_advanced.php +0 -13
  27. admin/tpl/setting/network_settings_cache.php +0 -18
  28. admin/tpl/setting/network_settings_excludes.php +0 -15
  29. admin/tpl/setting/network_settings_media.php +0 -10
  30. admin/tpl/setting/network_settings_purge.php +0 -10
  31. admin/tpl/setting/settings_advanced.php +0 -121
  32. admin/tpl/setting/settings_cache.php +0 -90
  33. admin/tpl/setting/settings_cdn.php +0 -273
  34. admin/tpl/setting/settings_compatibilities.php +0 -38
  35. admin/tpl/setting/settings_crawler.php +0 -305
  36. admin/tpl/setting/settings_debug.php +0 -173
  37. admin/tpl/setting/settings_esi.php +0 -99
  38. admin/tpl/setting/settings_excludes.php +0 -146
  39. admin/tpl/setting/settings_general.php +0 -164
  40. admin/tpl/setting/settings_inc.cache_browser.php +0 -31
  41. admin/tpl/setting/settings_inc.cache_favicon.php +0 -18
  42. admin/tpl/setting/settings_inc.cache_mobile.php +0 -70
  43. admin/tpl/setting/settings_inc.cache_object.php +0 -157
  44. admin/tpl/setting/settings_inc.cache_resources.php +0 -19
  45. admin/tpl/setting/settings_inc.check_adv_file.php +0 -23
  46. admin/tpl/setting/settings_inc.exclude_cookies.php +0 -27
  47. admin/tpl/setting/settings_inc.exclude_useragent.php +0 -26
  48. admin/tpl/setting/settings_inc.media_webp.php +0 -17
  49. admin/tpl/setting/settings_inc.purge_on_upgrade.php +0 -14
  50. admin/tpl/setting/settings_media.php +0 -269
  51. admin/tpl/setting/settings_optimize.php +0 -281
  52. admin/tpl/setting/settings_purge.php +0 -102
  53. admin/tpl/setting/settings_tuning.php +0 -200
  54. admin/tpl/settings.php +0 -220
  55. {css → assets/css}/fonts/litespeedfont.eot +0 -0
  56. {css → assets/css}/fonts/litespeedfont.svg +0 -0
  57. {css → assets/css}/fonts/litespeedfont.ttf +0 -0
  58. {css → assets/css}/fonts/litespeedfont.woff +0 -0
  59. {css → assets/css}/iziModal.min.css +0 -0
  60. assets/css/litespeed-legacy.css +58 -0
  61. assets/css/litespeed.css +3545 -0
  62. {img → assets/img}/Litespeed.icon.svg +0 -0
  63. {img → assets/img}/icons/all.svg +0 -0
  64. {img → assets/img}/icons/all_transients.svg +0 -0
  65. {img → assets/img}/icons/auto_draft.svg +0 -0
  66. {img → assets/img}/icons/cross_icon.svg +0 -0
  67. {img → assets/img}/icons/db.svg +0 -0
  68. {img → assets/img}/icons/empty-cache.svg +0 -0
  69. {img → assets/img}/icons/expired_transient.svg +0 -0
  70. {img → assets/img}/icons/img_optm.svg +0 -0
  71. {img → assets/img}/icons/img_optm_disabled.svg +0 -0
  72. {img → assets/img}/icons/img_webp.svg +0 -0
  73. {img → assets/img}/icons/img_webp_disabled.svg +0 -0
  74. {img → assets/img}/icons/optimize_tables.svg +0 -0
  75. {img → assets/img}/icons/purge-403.svg +0 -0
  76. {img → assets/img}/icons/purge-404.svg +0 -0
  77. {img → assets/img}/icons/purge-500.svg +0 -0
  78. {img → assets/img}/icons/purge-all.svg +0 -0
  79. {img → assets/img}/icons/purge-cssjs.svg +0 -0
  80. {img → assets/img}/icons/purge-front.svg +0 -0
  81. {img → assets/img}/icons/purge-object.svg +0 -0
  82. {img → assets/img}/icons/purge-opcache.svg +0 -0
  83. {img → assets/img}/icons/purge-pages.svg +0 -0
  84. {img → assets/img}/icons/revision.svg +0 -0
  85. {img → assets/img}/icons/spam_comment.svg +0 -0
  86. {img → assets/img}/icons/success_icon.svg +0 -0
  87. {img → assets/img}/icons/trackback-pingback.svg +0 -0
  88. {img → assets/img}/icons/trash_comment.svg +0 -0
  89. {img → assets/img}/icons/trash_post.svg +0 -0
  90. {img → assets/img}/lscwp-logo_90x90.png +0 -0
  91. assets/img/quic-cloud-icon-16x16.svg +22 -0
  92. {img → assets/img}/slack-logo.png +0 -0
  93. {js → assets/js}/css_async.js +0 -0
  94. {js → assets/js}/css_async.min.js +0 -0
  95. {js → assets/js}/instant_click.min.js +0 -0
  96. {js → assets/js}/instant_click.ori.js +0 -0
  97. {js → assets/js}/iziModal.min.js +0 -0
  98. {js → assets/js}/lazyload.init.js +7 -3
  99. {js → assets/js}/lazyload.lib.js +0 -0
  100. {js → assets/js}/lazyload.min.js +1 -1
  101. {js → assets/js}/litespeed-cache-admin.js +86 -39
  102. assets/js/vue.min.js +1 -0
  103. {js → assets/js}/webfontloader.js +0 -0
  104. {js → assets/js}/webfontloader.min.js +0 -0
  105. autoload.php +42 -0
  106. cli/debug.cls.php +40 -0
  107. cli/image.cls.php +166 -0
  108. cli/litespeed-cache-cli-admin.class.php +0 -341
  109. cli/litespeed-cache-cli-iapi.class.php +0 -200
  110. cli/litespeed-cache-cli-purge.class.php +0 -302
  111. cli/online.cls.php +142 -0
  112. cli/option.cls.php +353 -0
  113. cli/purge.cls.php +307 -0
  114. css/litespeed.css +0 -2413
  115. data/.htaccess +0 -0
  116. data/const.default.ini +588 -24
  117. data/const.network_default.ini +104 -0
  118. inc/activation.class.php +0 -554
  119. inc/api.class.php +0 -658
  120. inc/cdn/quic.class.php +0 -257
  121. inc/config.class.php +0 -819
  122. inc/const.cls.php +0 -662
  123. inc/control.class.php +0 -772
  124. inc/crawler-sitemap.class.php +0 -160
  125. inc/crawler.class.php +0 -660
  126. inc/css.cls.php +0 -363
  127. inc/data.class.php +0 -359
  128. inc/data_structure/img_optm.sql +0 -20
  129. inc/data_structure/optm.sql +0 -8
  130. inc/doc.cls.php +0 -42
  131. inc/img_optm.class.php +0 -2168
  132. inc/import.class.php +0 -291
  133. inc/litespeed-cache.class.php +0 -774
  134. inc/litespeed.autoload.php +0 -151
  135. inc/log.class.php +0 -498
  136. inc/media.class.php +0 -1084
  137. inc/object.lib.php +1 -653
  138. inc/purge.class.php +0 -1051
  139. inc/rest.cls.php +0 -123
  140. inc/router.class.php +0 -715
  141. inc/task.class.php +0 -274
  142. inc/utility.class.php +0 -833
  143. includes/advanced-cache.php +0 -20
  144. includes/deprecated-litespeed-cache-tags.class.php +0 -12
  145. includes/litespeed-cache-api.class.php +0 -658
  146. includes/litespeed-cache-cdn.class.php +0 -621
  147. includes/litespeed-cache-config.class.php +0 -819
  148. includes/litespeed-cache-crawler.class.php +0 -660
  149. includes/litespeed-cache-esi.class.php +0 -904
  150. includes/litespeed-cache-gui.class.php +0 -753
  151. includes/litespeed-cache-optimize.class.php +0 -1247
  152. includes/litespeed-cache-tag.class.php +0 -406
  153. includes/litespeed-cache-task.class.php +0 -274
  154. includes/litespeed-cache-vary.class.php +0 -653
  155. includes/litespeed-cache.class.php +0 -774
  156. includes/litespeed.autoload.php +0 -151
  157. lang/litespeed-cache.pot +5300 -0
  158. languages/litespeed-cache.pot +0 -4524
  159. lib/{css_min.colors.class.php → css-min/colors.cls.php} +2 -1
  160. lib/{css_min.class.php → css-min/minifier.cls.php} +2 -2
  161. lib/{css_min.url_rewritter.class.php → css-min/urirewriter.cls.php} +7 -10
  162. lib/{css_min.utils.class.php → css-min/utils.cls.php} +2 -1
  163. lib/{html_min.class.php → html-min.cls.php} +3 -7
  164. lib/{js_min.class.php → jsmin.cls.php} +2 -2
  165. lib/litespeed/litespeed-crawler.class.php +0 -711
  166. lib/object-cache.php +3 -10
  167. lib/{litespeed-php-compatibility.func.php → php-compatibility.func.php} +19 -5
  168. litespeed-cache.php +79 -52
  169. readme.txt +220 -95
  170. includes/litespeed-cache-activation.class.php → src/activation.cls.php +178 -150
  171. src/admin-display.cls.php +1174 -0
  172. src/admin-settings.cls.php +381 -0
  173. src/admin.cls.php +202 -0
  174. src/api.cls.php +246 -0
  175. src/avatar.cls.php +332 -0
  176. src/base.cls.php +1106 -0
  177. inc/cdn.class.php → src/cdn.cls.php +115 -114
  178. inc/cdn/cloudflare.class.php → src/cdn/cloudflare.cls.php +88 -70
  179. src/cdn/quic.cls.php +65 -0
  180. src/cloud.cls.php +1033 -0
  181. src/conf.cls.php +744 -0
  182. includes/litespeed-cache-control.class.php → src/control.cls.php +190 -151
  183. src/core.cls.php +594 -0
  184. src/crawler-map.cls.php +629 -0
  185. src/crawler.cls.php +980 -0
  186. src/css.cls.php +333 -0
  187. src/data.cls.php +459 -0
  188. src/data.upgrade.func.php +589 -0
  189. src/data_structure/avatar.sql +7 -0
  190. src/data_structure/crawler.sql +8 -0
  191. src/data_structure/crawler_blacklist.sql +8 -0
  192. src/data_structure/cssjs.sql +8 -0
  193. src/data_structure/img_optm.sql +10 -0
  194. src/data_structure/img_optming.sql +9 -0
  195. src/db-optm.cls.php +325 -0
  196. includes/litespeed-cache-log.class.php → src/debug2.cls.php +84 -115
  197. src/doc.cls.php +80 -0
  198. src/error.cls.php +166 -0
  199. inc/esi.class.php → src/esi.cls.php +114 -151
  200. lib/litespeed/litespeed-file.class.php → src/file.cls.php +28 -34
  201. inc/gui.class.php → src/gui.cls.php +286 -183
  202. src/health.cls.php +141 -0
  203. src/htaccess.cls.php +920 -0
  204. src/img-optm.cls.php +1871 -0
  205. src/import.cls.php +209 -0
  206. src/instance.cls.php +28 -0
  207. src/lang.cls.php +245 -0
  208. src/media.cls.php +895 -0
  209. inc/object.class.php → src/object-cache.cls.php +115 -96
  210. src/object.lib.php +661 -0
  211. inc/optimize.class.php → src/optimize.cls.php +341 -232
  212. inc/optimizer.class.php → src/optimizer.cls.php +44 -53
  213. src/placeholder.cls.php +512 -0
  214. includes/litespeed-cache-purge.class.php → src/purge.cls.php +267 -253
  215. admin/litespeed-cache-admin-report.class.php → src/report.cls.php +36 -96
  216. src/rest.cls.php +246 -0
  217. includes/litespeed-cache-router.class.php → src/router.cls.php +162 -172
  218. lib/litespeed/litespeed-string.class.php → src/str.cls.php +4 -1
  219. inc/tag.class.php → src/tag.cls.php +49 -84
  220. src/task.cls.php +151 -0
  221. src/tool.cls.php +173 -0
  222. includes/litespeed-cache-utility.class.php → src/utility.cls.php +162 -128
  223. inc/vary.class.php → src/vary.cls.php +108 -108
  224. thirdparty/{lscwp-3rd-aelia-currencyswitcher.cls.php → aelia-currencyswitcher.cls.php} +9 -10
  225. thirdparty/{lscwp-3rd-amp-bypass.cls.php → amp.cls.php} +9 -11
  226. thirdparty/autoptimize.cls.php +38 -0
  227. thirdparty/avada.cls.php +41 -0
  228. thirdparty/bbpress.cls.php +88 -0
  229. thirdparty/beaver-builder.cls.php +51 -0
  230. thirdparty/divi-theme-builder.cls.php +73 -0
  231. thirdparty/elementor.cls.php +50 -0
  232. thirdparty/entry.inc.php +49 -0
  233. thirdparty/facetwp.cls.php +35 -0
  234. thirdparty/lscwp-3rd-autoptimize.cls.php +0 -43
  235. thirdparty/lscwp-3rd-avada.cls.php +0 -46
  236. thirdparty/lscwp-3rd-bbpress.cls.php +0 -87
  237. thirdparty/lscwp-3rd-betterwp-minify.cls.php +0 -72
  238. thirdparty/lscwp-3rd-contact-form-7.cls.php +0 -46
  239. thirdparty/lscwp-3rd-divi-theme-builder.cls.php +0 -72
  240. thirdparty/lscwp-3rd-elementor.cls.php +0 -42
  241. thirdparty/lscwp-3rd-facetwp.cls.php +0 -39
  242. thirdparty/lscwp-3rd-like-dislike-counter.cls.php +0 -38
  243. thirdparty/lscwp-3rd-theme-my-login.cls.php +0 -50
  244. thirdparty/lscwp-3rd-wp-polls.cls.php +0 -24
  245. thirdparty/lscwp-3rd-wp-postratings.cls.php +0 -43
  246. thirdparty/lscwp-3rd-wplister.cls.php +0 -34
  247. thirdparty/lscwp-3rd-wptouch.cls.php +0 -47
  248. thirdparty/lscwp-registry-3rd.php +0 -43
  249. thirdparty/{lscwp-3rd-nextgengallery.cls.php → nextgengallery.cls.php} +34 -35
  250. thirdparty/theme-my-login.cls.php +45 -0
  251. thirdparty/user-switching.cls.php +25 -0
  252. thirdparty/wcml.cls.php +37 -0
  253. thirdparty/woo-paypal.cls.php +21 -0
  254. thirdparty/{lscwp-3rd-woocommerce.cls.php → woocommerce.cls.php} +148 -279
  255. thirdparty/woocommerce.content.tpl.php +82 -0
  256. thirdparty/woocommerce.tab.tpl.php +3 -0
  257. thirdparty/wp-polls.cls.php +26 -0
  258. thirdparty/wp-postratings.cls.php +38 -0
  259. thirdparty/{lscwp-3rd-wpdiscuz.cls.php → wpdiscuz.cls.php} +8 -8
  260. thirdparty/wplister.cls.php +29 -0
  261. thirdparty/{lscwp-3rd-wpml.cls.php → wpml.cls.php} +8 -12
  262. thirdparty/wptouch.cls.php +42 -0
  263. thirdparty/{lscwp-3rd-yith-wishlist.cls.php → yith-wishlist.cls.php} +21 -24
  264. admin/tpl/inc/banner_promo.ajax.php → tpl/banner/ajax.php +3 -2
  265. tpl/banner/cloud_news.tpl.php +43 -0
  266. tpl/banner/cloud_promo.tpl.php +55 -0
  267. admin/tpl/inc/banner_promo.new_version.php → tpl/banner/new_version.php +23 -20
  268. tpl/banner/new_version_dev.tpl.php +31 -0
  269. admin/tpl/inc/banner_promo.php → tpl/banner/score.php +11 -10
  270. admin/tpl/inc/banner_promo.slack.php → tpl/banner/slack.php +3 -2
  271. tpl/cache/entry.tpl.php +93 -0
  272. tpl/cache/entry_network.tpl.php +54 -0
  273. tpl/cache/more_settings_tip.tpl.php +18 -0
  274. tpl/cache/network_settings-advanced.tpl.php +18 -0
  275. tpl/cache/network_settings-browser.tpl.php +5 -0
  276. admin/tpl/setting/network_settings_general.php → tpl/cache/network_settings-cache.tpl.php +15 -9
  277. tpl/cache/network_settings-excludes.tpl.php +22 -0
  278. tpl/cache/network_settings-object.tpl.php +5 -0
  279. tpl/cache/network_settings-purge.tpl.php +18 -0
  280. tpl/cache/settings-advanced.tpl.php +57 -0
  281. tpl/cache/settings-browser.tpl.php +5 -0
  282. tpl/cache/settings-cache.tpl.php +167 -0
  283. tpl/cache/settings-esi.tpl.php +125 -0
  284. tpl/cache/settings-excludes.tpl.php +138 -0
  285. tpl/cache/settings-object.tpl.php +5 -0
  286. tpl/cache/settings-purge.tpl.php +144 -0
  287. tpl/cache/settings-ttl.tpl.php +112 -0
  288. tpl/cache/settings_inc.browser.tpl.php +48 -0
  289. tpl/cache/settings_inc.cache_favicon.tpl.php +19 -0
  290. tpl/cache/settings_inc.cache_mobile.tpl.php +76 -0
  291. tpl/cache/settings_inc.cache_resources.tpl.php +20 -0
  292. tpl/cache/settings_inc.exclude_cookies.tpl.php +20 -0
  293. tpl/cache/settings_inc.exclude_useragent.tpl.php +20 -0
  294. admin/tpl/setting/settings_inc.login_cookie.php → tpl/cache/settings_inc.login_cookie.tpl.php +28 -27
  295. tpl/cache/settings_inc.object.tpl.php +218 -0
  296. tpl/cache/settings_inc.purge_on_upgrade.tpl.php +18 -0
  297. tpl/cdn/entry.tpl.php +47 -0
  298. admin/tpl/manage/manage_cdn.php → tpl/cdn/manage.tpl.php +19 -13
  299. tpl/cdn/settings.tpl.php +296 -0
  300. tpl/crawler/blacklist.tpl.php +55 -0
  301. tpl/crawler/entry.tpl.php +53 -0
  302. tpl/crawler/map.tpl.php +68 -0
  303. tpl/crawler/settings-general.tpl.php +181 -0
  304. tpl/crawler/settings-simulation.tpl.php +115 -0
  305. tpl/crawler/settings-sitemap.tpl.php +126 -0
  306. tpl/crawler/summary.tpl.php +217 -0
  307. tpl/dash/dashboard.tpl.php +512 -0
  308. tpl/dash/entry.tpl.php +36 -0
  309. tpl/dash/network_dash.tpl.php +114 -0
  310. tpl/db_optm/entry.tpl.php +50 -0
  311. tpl/db_optm/manage.tpl.php +192 -0
  312. tpl/db_optm/settings.tpl.php +55 -0
  313. tpl/esi.tpl.php +2 -5
  314. {admin/tpl → tpl}/esi_widget_edit.php +19 -16
  315. tpl/general/entry.tpl.php +50 -0
  316. tpl/general/network_settings.tpl.php +22 -0
  317. tpl/general/settings.tpl.php +167 -0
  318. admin/tpl/setting/settings_inc.auto_upgrade.php → tpl/general/settings_inc.auto_upgrade.tpl.php +9 -5
  319. tpl/img_optm/entry.tpl.php +55 -0
  320. tpl/img_optm/network_settings.tpl.php +20 -0
  321. tpl/img_optm/settings.media_webp.tpl.php +18 -0
  322. tpl/img_optm/settings.tpl.php +182 -0
  323. tpl/img_optm/summary.tpl.php +368 -0
  324. {admin/tpl → tpl}/inc/admin_footer.php +3 -2
  325. {admin/tpl → tpl}/inc/api_key.php +3 -2
  326. {admin/tpl → tpl}/inc/check_cache_disabled.php +5 -12
  327. tpl/inc/check_if_network_disable_all.php +24 -0
  328. {admin/tpl → tpl}/inc/disabled_all.php +3 -2
  329. {admin/tpl → tpl}/inc/help_tabs.php +2 -1
  330. {admin/tpl → tpl}/inc/modal.footer.php +0 -0
  331. {admin/tpl → tpl}/inc/modal.header.php +3 -4
  332. {admin/tpl → tpl}/inc/show_display_installed.php +2 -2
  333. {admin/tpl → tpl}/inc/show_error_cookie.php +3 -2
  334. {admin/tpl → tpl}/inc/show_rule_conflict.php +2 -1
  335. tpl/page_optm/entry.tpl.php +68 -0
  336. tpl/page_optm/settings_css.tpl.php +201 -0
  337. tpl/page_optm/settings_discussion.tpl.php +86 -0
  338. tpl/page_optm/settings_html.tpl.php +176 -0
  339. tpl/page_optm/settings_js.tpl.php +99 -0
  340. tpl/page_optm/settings_media.tpl.php +220 -0
  341. tpl/page_optm/settings_media_exc.tpl.php +105 -0
  342. tpl/page_optm/settings_tuning.tpl.php +188 -0
  343. tpl/toolbox/beta_test.tpl.php +23 -0
  344. tpl/toolbox/edit_htaccess.tpl.php +110 -0
  345. tpl/toolbox/entry.tpl.php +61 -0
  346. tpl/toolbox/heartbeat.tpl.php +118 -0
  347. tpl/toolbox/import_export.tpl.php +54 -0
  348. tpl/toolbox/log_viewer.tpl.php +28 -0
  349. admin/tpl/manage/manage_purge.php → tpl/toolbox/purge.tpl.php +61 -53
  350. tpl/toolbox/report.tpl.php +99 -0
  351. tpl/toolbox/settings-debug.tpl.php +151 -0
  352. wp_assets/banner-1544x500.png +0 -0
  353. wp_assets/banner-772x250.png +0 -0
  354. wp_assets/icon-128x128.png +0 -0
  355. wp_assets/icon-256x256.png +0 -0
  356. wp_assets/screenshot-1.png +0 -0
  357. wp_assets/screenshot-10.png +0 -0
  358. wp_assets/screenshot-11.png +0 -0
  359. wp_assets/screenshot-2.png +0 -0
  360. wp_assets/screenshot-3.png +0 -0
  361. wp_assets/screenshot-4.png +0 -0
  362. wp_assets/screenshot-5.png +0 -0
  363. wp_assets/screenshot-6.png +0 -0
  364. wp_assets/screenshot-7.png +0 -0
  365. wp_assets/screenshot-8.png +0 -0
  366. wp_assets/screenshot-9.png +0 -0
admin/admin-api.class.php DELETED
@@ -1,551 +0,0 @@
1
- <?php
2
- /**
3
- * Admin API
4
- *
5
- * @since 1.5
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/admin
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
-
11
- if ( ! defined( 'WPINC' ) ) {
12
- die ;
13
- }
14
-
15
- class LiteSpeed_Cache_Admin_API
16
- {
17
- private static $_instance ;
18
-
19
- private $_iapi_key ;
20
- private $_iapi_cloud ;
21
-
22
- const DB_API_KEY = 'litespeed_api_key' ;
23
- const DB_API_CLOUD = 'litespeed_api_cloud' ;
24
- const DB_API_KEY_HASH = 'litespeed_api_key_hash' ;
25
-
26
- // For each request, send a callback to confirm
27
- const TYPE_REQUEST_CALLBACK = 'request_callback' ;
28
- const TYPE_NOTIFY_IMG = 'notify_img' ;
29
- const TYPE_CHECK_IMG = 'check_img' ;
30
- const TYPE_IMG_DESTROY_CALLBACK = 'imgoptm_destroy' ;
31
- const TYPE_RESET_KEY = 'reset_key' ;
32
-
33
- const IAPI_ACTION_REQUEST_KEY = 'request_key' ;
34
- const IAPI_ACTION_LIST_CLOUDS = 'list_clouds' ;
35
- const IAPI_ACTION_MEDIA_SYNC_DATA = 'media_sync_data' ;
36
- const IAPI_ACTION_REQUEST_OPTIMIZE = 'request_optimize' ;
37
- const IAPI_ACTION_IMG_TAKEN = 'client_img_taken' ;
38
- const IAPI_ACTION_REQUEST_DESTROY = 'imgoptm_destroy' ;
39
- const IAPI_ACTION_REQUEST_DESTROY_UNFINISHED = 'imgoptm_destroy_unfinished' ;
40
- const IAPI_ACTION_ENV_REPORT = 'env_report' ;
41
- const IAPI_ACTION_PLACEHOLDER = 'placeholder' ;
42
- const IAPI_ACTION_CCSS = 'ccss' ;
43
- const IAPI_ACTION_PAGESCORE = 'pagescore' ;
44
-
45
- /**
46
- * Init
47
- *
48
- * @since 1.5
49
- * @access private
50
- */
51
- private function __construct()
52
- {
53
- $this->_iapi_key = get_option( self::DB_API_KEY ) ?: '' ;
54
- $this->_iapi_cloud = get_option( self::DB_API_CLOUD ) ?: '' ;
55
- }
56
-
57
- /**
58
- * Handle all request actions from main cls
59
- *
60
- * @since 1.7.2
61
- * @access public
62
- */
63
- public static function handler()
64
- {
65
- $instance = self::get_instance() ;
66
-
67
- $type = LiteSpeed_Cache_Router::verify_type() ;
68
-
69
- switch ( $type ) {
70
- case self::TYPE_RESET_KEY :
71
- $instance->_reset_key() ;
72
- break ;
73
-
74
- default:
75
- break ;
76
- }
77
-
78
- LiteSpeed_Cache_Admin::redirect() ;
79
- }
80
-
81
- /**
82
- * Handle aggressive callback requests from LiteSpeed image server
83
- *
84
- * @since 1.6
85
- * @since 1.6.7 Added destroy callback
86
- * @access public
87
- */
88
- public static function sapi_aggressive_callback()
89
- {
90
- $instance = self::get_instance() ;
91
-
92
- switch ( LiteSpeed_Cache_Router::verify_type() ) {
93
- case self::TYPE_NOTIFY_IMG :
94
- LiteSpeed_Cache_Img_Optm::get_instance()->notify_img() ;
95
- break ;
96
-
97
- case self::TYPE_CHECK_IMG :
98
- $instance->validate_lsserver() ;
99
- LiteSpeed_Cache_Img_Optm::get_instance()->check_img() ;
100
- break ;
101
-
102
- case self::TYPE_IMG_DESTROY_CALLBACK :
103
- LiteSpeed_Cache_Img_Optm::get_instance()->img_optimize_destroy_callback() ;
104
- break ;
105
-
106
- default:
107
- break ;
108
- }
109
-
110
- exit ;
111
- }
112
-
113
- /**
114
- * Validate litespeed api server IP
115
- *
116
- * @since 1.6.5
117
- * @access public
118
- */
119
- public function validate_lsserver()
120
- {
121
- $ip = gethostbyname( 'wp.api.litespeedtech.com' ) ;
122
- if ( $ip != LiteSpeed_Cache_Router::get_ip() ) {
123
- exit( 'wrong ip' ) ;
124
- }
125
- }
126
-
127
- /**
128
- * Handle passive callback requests from LiteSpeed image server
129
- *
130
- * @since 1.6
131
- * @access public
132
- */
133
- public static function sapi_passive_callback()
134
- {
135
- $instance = self::get_instance() ;
136
-
137
- switch ( LiteSpeed_Cache_Router::verify_type() ) {
138
- case self::TYPE_REQUEST_CALLBACK :
139
- $instance->_request_callback() ;
140
- break ;
141
-
142
- default:
143
- break ;
144
- }
145
-
146
- exit ;
147
- }
148
-
149
- /**
150
- * request key callback from LiteSpeed
151
- *
152
- * @since 1.5
153
- * @access private
154
- */
155
- private function _request_callback()
156
- {
157
- $key_hash = get_option( self::DB_API_KEY_HASH ) ;
158
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback request hash: ' . $key_hash ) ;
159
- exit( $key_hash ) ;
160
- }
161
-
162
- /**
163
- * Check if is valid callback from litespeed passive request
164
- *
165
- * @since 1.5
166
- * @access public
167
- * @return bool True if correct
168
- */
169
- public static function sapi_valiate_passive_callback()
170
- {
171
- if ( empty( $_REQUEST[ 'hash' ] ) ) {
172
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback bypassed passive check' ) ;
173
- return false ;
174
- }
175
- $instance = self::get_instance() ;
176
-
177
- // use tmp hash to check
178
- $key_hash = get_option( self::DB_API_KEY_HASH ) ;
179
- $hash_check = md5( $key_hash ) === $_REQUEST[ 'hash' ] ;
180
-
181
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback hash check ' . $key_hash . ': ' . ( $hash_check ? 'passed' : 'failed' ) ) ;
182
-
183
- return $hash_check ;
184
- }
185
-
186
- /**
187
- * Check if is valid callback from litespeed aggressive request
188
- *
189
- * @since 1.6
190
- * @access public
191
- * @return bool True if correct
192
- */
193
- public static function sapi_validate_aggressive_callback()
194
- {
195
- $instance = self::get_instance() ;
196
-
197
- // don't have auth_key yet
198
- if ( ! $instance->_iapi_key ) {
199
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback aggressive check failed: No init key' ) ;
200
- return false ;
201
- }
202
-
203
- // Once client has auth_key, each time when callback to check, need to carry on this key
204
- if ( empty( $_REQUEST[ 'auth_key' ] ) ) {
205
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback aggressive check failed: lack of auth_key' ) ;
206
- return false ;
207
- }
208
-
209
- $res = md5( $instance->_iapi_key ) === $_REQUEST[ 'auth_key' ] ;
210
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback aggressive auth_key check: ' . ( $res ? 'passed' : 'failed' ) ) ;
211
- return $res ;
212
- }
213
-
214
- /**
215
- * Get data from LiteSpeed cloud server
216
- *
217
- * @since 2.9
218
- * @access public
219
- */
220
- public static function get( $action, $data = array(), $server = false )
221
- {
222
- $instance = self::get_instance() ;
223
-
224
- /**
225
- * All requests must have closet cloud server too
226
- * @since 2.9
227
- */
228
- if ( ! $instance->_iapi_cloud ) {
229
- $instance->_detect_cloud() ;
230
- }
231
-
232
- return $instance->_get( $action, $data, $server ) ;
233
- }
234
-
235
- /**
236
- * Post data to LiteSpeed cloud server
237
- *
238
- * @since 1.6
239
- * @access public
240
- */
241
- public static function post( $action, $data = false, $server = false, $no_hash = false, $time_out = false )
242
- {
243
- $instance = self::get_instance() ;
244
-
245
- /**
246
- * All requests must have closet cloud server too
247
- * @since 2.9
248
- */
249
- if ( ! $instance->_iapi_cloud ) {
250
- $instance->_detect_cloud() ;
251
- }
252
-
253
- /**
254
- * All requests must have api_key first
255
- * @since 1.6.5
256
- */
257
- if ( ! $instance->_iapi_key ) {
258
- $instance->_request_key() ;
259
- }
260
-
261
- return $instance->_post( $action, $data, $server, $no_hash, $time_out ) ;
262
- }
263
-
264
- /**
265
- * request key from LiteSpeed
266
- *
267
- * This needs callback validation, so don't use for generic services which don't need security
268
- *
269
- * @since 1.5
270
- * @access private
271
- */
272
- private function _request_key()
273
- {
274
- LiteSpeed_Cache_Log::debug( '[IAPI] req auth_key' ) ;
275
-
276
- // Send request to LiteSpeed
277
- $json = $this->_post( self::IAPI_ACTION_REQUEST_KEY, home_url(), true ) ;
278
-
279
- // Check if get key&server correctly
280
- if ( empty( $json[ 'auth_key' ] ) ) {
281
- LiteSpeed_Cache_Log::debug( '[IAPI] request key failed: ', $json ) ;
282
-
283
- if ( $json ) {
284
- $msg = sprintf( __( 'IAPI Error %s', 'litespeed-cache' ), $json ) ;
285
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
286
- }
287
- return ;
288
- }
289
-
290
- // store data into option locally
291
- update_option( self::DB_API_KEY, $json[ 'auth_key' ] ) ;
292
- LiteSpeed_Cache_Log::debug( '[IAPI] applied auth_key' ) ;
293
-
294
- $this->_iapi_key = $json[ 'auth_key' ] ;
295
- }
296
-
297
- /**
298
- * ping clouds from LiteSpeed
299
- *
300
- * @since 2.9
301
- * @access private
302
- */
303
- private function _detect_cloud()
304
- {
305
- // Send request to LiteSpeed
306
- $json = $this->_post( self::IAPI_ACTION_LIST_CLOUDS, home_url(), false, true ) ;
307
-
308
- // Check if get list correctly
309
- if ( empty( $json[ 'list' ] ) ) {
310
- LiteSpeed_Cache_Log::debug( '[IAPI] request cloud list failed: ', $json ) ;
311
-
312
- if ( $json ) {
313
- $msg = sprintf( __( 'IAPI Error %s', 'litespeed-cache' ), $json ) ;
314
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
315
- }
316
- return ;
317
- }
318
-
319
- // Ping closest cloud
320
- $speed_list = array() ;
321
- foreach ( $json[ 'list' ] as $v ) {
322
- $speed_list[ $v ] = LiteSpeed_Cache_Utility::ping( $v ) ;
323
- }
324
- $min = min( $speed_list ) ;
325
-
326
- if ( $min == 99999 ) {
327
- LiteSpeed_Cache_Log::debug( '[IAPI] failed to ping all clouds' ) ;
328
- return ;
329
- }
330
- $closest = array_search( $min, $speed_list ) ;
331
-
332
- LiteSpeed_Cache_Log::debug( '[IAPI] Found closest cloud ' . $closest ) ;
333
-
334
- // store data into option locally
335
- update_option( self::DB_API_CLOUD, $closest ) ;
336
-
337
- $this->_iapi_cloud = $closest ;
338
-
339
- // sync API key
340
- $this->_request_key() ;
341
- }
342
-
343
- /**
344
- * delete key
345
- *
346
- * @since 1.7.2
347
- * @access private
348
- */
349
- private function _reset_key()
350
- {
351
- delete_option( self::DB_API_KEY ) ;
352
- delete_option( self::DB_API_CLOUD ) ;
353
- LiteSpeed_Cache_Log::debug( '[IAPI] delete auth_key & closest cloud' ) ;
354
-
355
- $msg = __( 'Reset IAPI key successfully.', 'litespeed-cache' ) ;
356
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
357
- }
358
-
359
- /**
360
- * Get data from LiteSpeed cloud server
361
- *
362
- * @since 2.9
363
- * @access private
364
- */
365
- private function _get( $action, $data = false, $server = false )
366
- {
367
-
368
- if ( $server == false ) {
369
- $server = 'https://wp.api.litespeedtech.com' ;
370
- }
371
- elseif ( $server === true ) {
372
- $server = $this->_iapi_cloud ;
373
- }
374
-
375
- $url = $server . '/' . $action ;
376
-
377
- if ( $data ) {
378
- $url .= '?' . http_build_query( $data ) ;
379
- }
380
-
381
- LiteSpeed_Cache_Log::debug( '[IAPI] getting from : ' . $url ) ;
382
-
383
- $response = wp_remote_get( $url, array( 'timeout' => 15 ) ) ;
384
-
385
- // Parse response data
386
- if ( is_wp_error( $response ) ) {
387
- $error_message = $response->get_error_message() ;
388
- LiteSpeed_Cache_Log::debug( '[IAPI] failed to get: ' . $error_message ) ;
389
- return false ;
390
- }
391
-
392
- $data = $response[ 'body' ] ;
393
-
394
- return $data ;
395
-
396
- }
397
-
398
- /**
399
- * Post data to LiteSpeed cloud server
400
- *
401
- * @since 1.6
402
- * @access private
403
- * @return string | array Must return an error msg string or json array
404
- */
405
- private function _post( $action, $data = false, $server = false, $no_hash = false, $time_out = false )
406
- {
407
- $hash = 'no_hash' ;
408
- if ( ! $no_hash ) {
409
- $hash = Litespeed_String::rrand( 16 ) ;
410
- // store hash
411
- update_option( self::DB_API_KEY_HASH, $hash ) ;
412
- }
413
-
414
- if ( $server == false ) {
415
- $server = 'https://wp.api.litespeedtech.com' ;
416
- }
417
- elseif ( $server === true ) {
418
- $server = $this->_iapi_cloud ;
419
- }
420
-
421
- $url = $server . '/' . $action ;
422
-
423
- LiteSpeed_Cache_Log::debug( '[IAPI] posting to : ' . $url ) ;
424
-
425
- $param = array(
426
- 'auth_key' => $this->_iapi_key,
427
- 'cloud' => $this->_iapi_cloud,
428
- 'v' => LiteSpeed_Cache::PLUGIN_VERSION,
429
- 'hash' => $hash,
430
- 'data' => $data,
431
- ) ;
432
- /**
433
- * Extended timeout to avoid cUrl 28 timeout issue as we need callback validation
434
- * @since 1.6.4
435
- */
436
- $response = wp_remote_post( $url, array( 'body' => $param, 'timeout' => $time_out ?: 15 ) ) ;
437
-
438
- if ( is_wp_error( $response ) ) {
439
- $error_message = $response->get_error_message() ;
440
- LiteSpeed_Cache_Log::debug( '[IAPI] failed to post: ' . $error_message ) ;
441
- return $error_message ;
442
- }
443
-
444
- // parse data from server
445
- $json = json_decode( $response[ 'body' ], true ) ;
446
-
447
- if ( ! is_array( $json ) ) {
448
- LiteSpeed_Cache_Log::debug( '[IAPI] failed to decode post json: ' . $response[ 'body' ] ) ;
449
-
450
- $msg = __( 'Failed to post via WordPress', 'litespeed-cache' ) . ': ' . $response[ 'body' ] ;
451
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
452
-
453
- return false ;
454
- }
455
-
456
- if ( ! empty( $json[ '_err' ] ) ) {
457
- LiteSpeed_Cache_Log::debug( '[IAPI] _err: ' . $json[ '_err' ] ) ;
458
- $msg = __( 'Failed to communicate with LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_err' ] ;
459
- $msg .= $this->_parse_link( $json ) ;
460
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
461
- return false ;
462
- }
463
-
464
- if ( ! empty( $json[ '_503' ] ) ) {
465
- LiteSpeed_Cache_Log::debug( '[IAPI] service 503 unavailable temporarily. ' . $json[ '_503' ] ) ;
466
-
467
- $msg = __( 'We are working hard to improve your Image Optimization experience. The service will be unavailable while we work. We apologize for any inconvenience.', 'litespeed-cache' ) ;
468
- $msg .= ' ' . $json[ '_503' ] ;
469
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
470
-
471
- return false ;
472
- }
473
-
474
- if ( ! empty( $json[ '_info' ] ) ) {
475
- LiteSpeed_Cache_Log::debug( '[IAPI] _info: ' . $json[ '_info' ] ) ;
476
- $msg = __( 'Message from LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_info' ] ;
477
- $msg .= $this->_parse_link( $json ) ;
478
- LiteSpeed_Cache_Admin_Display::info( $msg ) ;
479
- unset( $json[ '_info' ] ) ;
480
- }
481
-
482
- if ( ! empty( $json[ '_note' ] ) ) {
483
- LiteSpeed_Cache_Log::debug( '[IAPI] _note: ' . $json[ '_note' ] ) ;
484
- $msg = __( 'Message from LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_note' ] ;
485
- $msg .= $this->_parse_link( $json ) ;
486
- LiteSpeed_Cache_Admin_Display::note( $msg ) ;
487
- unset( $json[ '_note' ] ) ;
488
- }
489
-
490
- if ( ! empty( $json[ '_success' ] ) ) {
491
- LiteSpeed_Cache_Log::debug( '[IAPI] _success: ' . $json[ '_success' ] ) ;
492
- $msg = __( 'Good news from LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_success' ] ;
493
- $msg .= $this->_parse_link( $json ) ;
494
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
495
- unset( $json[ '_success' ] ) ;
496
- }
497
-
498
- // Upgrade is required
499
- if ( ! empty( $json[ '_err_req_v' ] ) ) {
500
- LiteSpeed_Cache_Log::debug( '[IAPI] _err_req_v: ' . $json[ '_err_req_v' ] ) ;
501
- $msg = sprintf( __( '%s plugin version %s required for this action.', 'litespeed-cache' ), LiteSpeed_Cache::NAME, 'v' . $json[ '_err_req_v' ] . '+' ) ;
502
-
503
- // Append upgrade link
504
- $msg2 = ' ' . LiteSpeed_Cache_GUI::plugin_upgrade_link( LiteSpeed_Cache::NAME, LiteSpeed_Cache::PLUGIN_NAME, $json[ '_err_req_v' ] ) ;
505
-
506
- $msg2 .= $this->_parse_link( $json ) ;
507
- LiteSpeed_Cache_Admin_Display::error( $msg . $msg2 ) ;
508
- return false ;
509
- }
510
-
511
- return $json ;
512
- }
513
-
514
- /**
515
- * Parse _links from json
516
- *
517
- * @since 1.6.5
518
- * @since 1.6.7 Self clean the parameter
519
- * @access private
520
- */
521
- private function _parse_link( &$json )
522
- {
523
- $msg = '' ;
524
-
525
- if ( ! empty( $json[ '_links' ] ) ) {
526
- foreach ( $json[ '_links' ] as $v ) {
527
- $msg .= ' ' . sprintf( '<a href="%s" class="%s" target="_blank">%s</a>', $v[ 'link' ], ! empty( $v[ 'cls' ] ) ? $v[ 'cls' ] : '', $v[ 'title' ] ) ;
528
- }
529
-
530
- unset( $json[ '_links' ] ) ;
531
- }
532
-
533
- return $msg ;
534
- }
535
-
536
- /**
537
- * Get the current instance object.
538
- *
539
- * @since 1.5
540
- * @access public
541
- * @return Current class instance.
542
- */
543
- public static function get_instance()
544
- {
545
- if ( ! isset( self::$_instance ) ) {
546
- self::$_instance = new self() ;
547
- }
548
-
549
- return self::$_instance ;
550
- }
551
- }
admin/class-litespeed-cache-admin.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- /**
3
- * ONLY for WHM plugin old version backward compatibility @Aug/2/2017
4
- */
5
-
6
-
7
- require_once dirname(__FILE__) . '/litespeed-cache-admin.class.php' ;
admin/litespeed-cache-admin-display.class.php DELETED
@@ -1,1195 +0,0 @@
1
- <?php
2
- /**
3
- * The admin-panel specific functionality of the plugin.
4
- *
5
- *
6
- * @since 1.0.0
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Admin_Display
17
- {
18
- private static $_instance ;
19
-
20
- const NOTICE_BLUE = 'notice notice-info' ;
21
- const NOTICE_GREEN = 'notice notice-success' ;
22
- const NOTICE_RED = 'notice notice-error' ;
23
- const NOTICE_YELLOW = 'notice notice-warning' ;
24
- const LITESPEED_MSG = 'litespeed_messages' ;
25
-
26
- const PURGEBY_CAT = '0' ;
27
- const PURGEBY_PID = '1' ;
28
- const PURGEBY_TAG = '2' ;
29
- const PURGEBY_URL = '3' ;
30
-
31
- const PURGEBYOPT_SELECT = 'purgeby' ;
32
- const PURGEBYOPT_LIST = 'purgebylist' ;
33
-
34
- const DISMISS_MSG = 'litespeed-cache-dismiss' ;
35
- const RULECONFLICT_ON = 'ExpiresDefault_1' ;
36
- const RULECONFLICT_DISMISSED = 'ExpiresDefault_0' ;
37
-
38
- private $config ;
39
- private $messages = array() ;
40
- private $disable_all = false ;
41
- private $default_settings = array() ;
42
-
43
- /**
44
- * Initialize the class and set its properties.
45
- *
46
- * @since 1.0.7
47
- * @access private
48
- */
49
- private function __construct()
50
- {
51
- // load assets
52
- if( ! empty($_GET['page']) &&
53
- (substr($_GET['page'], 0, 8) == 'lscache-' || $_GET['page'] == 'litespeedcache') ) {
54
- add_action('admin_enqueue_scripts', array($this, 'load_assets')) ;
55
- }
56
-
57
- // main css
58
- add_action('admin_enqueue_scripts', array($this, 'enqueue_style')) ;
59
- // Main js
60
- add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')) ;
61
-
62
- $is_network_admin = is_network_admin() ;
63
-
64
- // Quick access menu
65
- if ( is_multisite() && $is_network_admin ) {
66
- $manage = 'manage_network_options' ;
67
- }
68
- else {
69
- $manage = 'manage_options' ;
70
- }
71
- if ( current_user_can($manage) ) {
72
- add_action( 'wp_before_admin_bar_render', array( LiteSpeed_Cache_GUI::get_instance(), 'backend_shortcut' ) ) ;
73
-
74
- // 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
75
- add_action( is_network_admin() ? 'network_admin_notices' : 'admin_notices', array( $this, 'display_messages' ) ) ;
76
- }
77
-
78
- /**
79
- * In case this is called outside the admin page
80
- * @see https://codex.wordpress.org/Function_Reference/is_plugin_active_for_network
81
- * @since 2.0
82
- */
83
- if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
84
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' ) ;
85
- }
86
-
87
- // add menus ( Also check for mu-plugins)
88
- if ( $is_network_admin && ( is_plugin_active_for_network( LSCWP_BASENAME ) || defined( 'LSCWP_MU_PLUGIN' ) ) ) {
89
- add_action('network_admin_menu', array($this, 'register_admin_menu')) ;
90
- }
91
- else {
92
- add_action('admin_menu', array($this, 'register_admin_menu')) ;
93
- }
94
-
95
- $this->config = LiteSpeed_Cache_Config::get_instance() ;
96
-
97
- // get default setting values
98
- $this->default_settings = $this->config->get_default_options() ;
99
- }
100
-
101
- /**
102
- * Load LiteSpeed assets
103
- *
104
- * @since 1.1.0
105
- * @access public
106
- * @param array $hook WP hook
107
- */
108
- public function load_assets($hook)
109
- {
110
- // Admin footer
111
- add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1) ;
112
-
113
- if( defined( 'LITESPEED_ON' ) ) {
114
- // Help tab
115
- $this->add_help_tabs() ;
116
-
117
- global $pagenow ;
118
- if ( $pagenow === 'plugins.php' ) {//todo: check if work
119
- add_action('wp_default_scripts', array($this, 'set_update_text'), 0) ;
120
- add_action('wp_default_scripts', array($this, 'unset_update_text'), 20) ;
121
- }
122
- }
123
-
124
- }
125
-
126
- /**
127
- * Update latest release news for v3.0
128
- *
129
- * @since 2.9.9.1
130
- */
131
- private function _fetch_recommended()
132
- {
133
- $news = get_option( 'litespeed-recommended', array() );
134
- if ( ! empty( $news[ 'utime' ] ) && time() - $news[ 'utime' ] < 86400*1 ) {
135
- return $news;
136
- }
137
-
138
- $data = LiteSpeed_Cache_Admin_API::post( 'news' );
139
- $news[ 'utime' ] = time();
140
- update_option( 'litespeed-recommended', $news );
141
- if ( empty( $data[ 'id' ] ) ) {
142
- return $news;
143
- }
144
-
145
- // Save news
146
- if ( empty( $news[ 'id' ] ) || $news[ 'id' ] != $data[ 'id' ] ) {
147
- $news[ 'id' ] = $data[ 'id' ];
148
- $news[ 'plugin' ] = ! empty( $data[ 'plugin' ] ) ? $data[ 'plugin' ] : '';
149
- $news[ 'title' ] = ! empty( $data[ 'title' ] ) ? $data[ 'title' ] : '';
150
- $news[ 'content' ] = ! empty( $data[ 'content' ] ) ? $data[ 'content' ] : '';
151
- $news[ 'zip' ] = ! empty( $data[ 'zip' ] ) ? $data[ 'zip' ] : '';
152
- $news[ 'new' ] = 1;
153
-
154
- if ( $news[ 'plugin' ] ) {
155
- $plugin_info = LiteSpeed_Cache_Activation::get_instance()->dash_notifier_get_plugin_info( $news[ 'plugin' ] );
156
- if ( $plugin_info && ! empty( $plugin_info->name ) ) {
157
- $news[ 'plugin_name' ] = $plugin_info->name;
158
- }
159
- }
160
-
161
- update_option( 'litespeed-recommended', $news );
162
- }
163
-
164
- return $news;
165
- }
166
-
167
- /**
168
- * Load latest news
169
- *
170
- * @since 2.9.9.1
171
- */
172
- private function _show_recommended()
173
- {
174
- // Fetch v3.0 info to show
175
- $news = $this->_fetch_recommended();
176
- if ( ! $news || empty( $news[ 'new' ] ) ) {
177
- return;
178
- }
179
-
180
- if ( ! empty( $news[ 'plugin' ] ) && LiteSpeed_Cache_Activation::get_instance()->dash_notifier_is_plugin_active( $news[ 'plugin' ] ) ) {
181
- return;
182
- }
183
-
184
- ?>
185
- <div class="litespeed-wrap notice notice-success litespeed-banner-promo-full">
186
-
187
- <div class="litespeed-banner-promo-content">
188
- <h3 class="litespeed-banner-title litespeed-top15"><?php echo $news[ 'title' ] ; ?></h3>
189
- <div class="litespeed-banner-description">
190
- <div class="litespeed-banner-description-padding-right-15">
191
- <p class="litespeed-banner-desciption-content">
192
- <?php echo $news[ 'content' ]; ?>
193
- </p>
194
- </div>
195
- <div class="litespeed-row-flex litespeed-banner-description">
196
- <div class="litespeed-banner-description-padding-right-15">
197
- <?php if ( ! empty( $news[ 'plugin' ] ) ) : ?>
198
- <?php $install_link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_ACTIVATION, LiteSpeed_Cache_Activation::TYPE_INSTALL_3RD, false, null, array( 'plugin' => $news[ 'plugin' ] ) ); ?>
199
- <a href="<?php echo $install_link ; ?>" class="litespeed-btn-success litespeed-btn-mini">
200
- <?php echo __( 'Install', 'litespeed-cache' ); ?>
201
- <?php if ( ! empty( $news[ 'plugin_name' ] ) ) echo $news[ 'plugin_name' ]; ?>
202
- </a>
203
- <?php endif; ?>
204
- <?php if ( ! empty( $news[ 'zip' ] ) ) : ?>
205
- <?php $install_link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_ACTIVATION, LiteSpeed_Cache_Activation::TYPE_INSTALL_ZIP ); ?>
206
- <a href="<?php echo $install_link ; ?>" class="litespeed-btn-success litespeed-btn-mini">
207
- <?php echo __( 'Install Beta Version', 'litespeed-cache' ); ?>
208
- </a>
209
- <?php endif; ?>
210
- </div>
211
- </div>
212
- </div>
213
- </div>
214
-
215
- <div>
216
- <?php $dismiss_url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_ACTIVATION, LiteSpeed_Cache_Activation::TYPE_DISMISS_RECOMMENDED ) ; ?>
217
- <span class="screen-reader-text">Dismiss this notice.</span>
218
- <a href="<?php echo $dismiss_url ; ?>" class="litespeed-notice-dismiss">X</a>
219
- </div>
220
- </div>
221
- <?php
222
- }
223
-
224
- /**
225
- * Output litespeed form info
226
- *
227
- * @since 1.1.0
228
- * @access public
229
- * @param string $action
230
- */
231
- public function form_action( $action, $type = false )
232
- {
233
- echo '<input type="hidden" name="' . LiteSpeed_Cache::ACTION_KEY . '" value="' . $action . '" />' ;
234
- if ( $type ) {
235
- echo '<input type="hidden" name="type" value="' . $type . '" />' ;
236
- }
237
- wp_nonce_field($action, LiteSpeed_Cache::NONCE_NAME) ;
238
- }
239
-
240
-
241
- /**
242
- * Register the admin menu display.
243
- *
244
- * @since 1.0.0
245
- * @access public
246
- */
247
- public function register_admin_menu()
248
- {
249
- $capability = is_network_admin() ? 'manage_network_options' : 'manage_options' ;
250
- if ( current_user_can($capability) ) {
251
- // root menu
252
- add_menu_page('LiteSpeed Cache', 'LiteSpeed Cache', 'manage_options', 'lscache-settings') ;
253
-
254
- // sub menus
255
- $this->add_submenu(__('Settings', 'litespeed-cache'), 'lscache-settings', 'show_menu_settings') ;
256
-
257
- $this->add_submenu(__('Manage', 'litespeed-cache'), 'lscache-dash', 'show_menu_manage') ;
258
-
259
- if ( ! is_multisite() || is_network_admin() ) {
260
- $this->add_submenu(__('Edit .htaccess', 'litespeed-cache'), LiteSpeed_Cache::PAGE_EDIT_HTACCESS, 'show_menu_edit_htaccess') ;
261
- }
262
-
263
- if ( ! is_network_admin() ) {
264
- $this->add_submenu(__('Image Optimization', 'litespeed-cache'), 'lscache-optimization', 'show_optimization') ;
265
- $this->add_submenu(__('Crawler', 'litespeed-cache'), 'lscache-crawler', 'show_crawler') ;
266
- $this->add_submenu(__('Report', 'litespeed-cache'), 'lscache-report', 'show_report') ;
267
- $this->add_submenu(__('Import / Export', 'litespeed-cache'), 'lscache-import', 'show_import_export') ;
268
- }
269
-
270
- defined( 'LSCWP_LOG' ) && $this->add_submenu(__('Debug Log', 'litespeed-cache'), 'lscache-debug', 'show_debug_log') ;
271
-
272
- // sub menus under options
273
- add_options_page('LiteSpeed Cache', 'LiteSpeed Cache', $capability, 'litespeedcache', array($this, 'show_menu_settings')) ;
274
- }
275
- }
276
-
277
- /**
278
- * Helper function to set up a submenu page.
279
- *
280
- * @since 1.0.4
281
- * @access private
282
- * @param string $menu_title The title that appears on the menu.
283
- * @param string $menu_slug The slug of the page.
284
- * @param string $callback The callback to call if selected.
285
- */
286
- private function add_submenu($menu_title, $menu_slug, $callback)
287
- {
288
- add_submenu_page('lscache-settings', $menu_title, $menu_title, 'manage_options', $menu_slug, array($this, $callback)) ;
289
- }
290
-
291
- /**
292
- * Register the stylesheets for the admin area.
293
- *
294
- * @since 1.0.14
295
- * @access public
296
- */
297
- public function enqueue_style()
298
- {
299
- wp_enqueue_style(LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'css/litespeed.css', array(), LiteSpeed_Cache::PLUGIN_VERSION, 'all') ;
300
- }
301
-
302
- /**
303
- * Register the JavaScript for the admin area.
304
- *
305
- * @since 1.0.0
306
- * @access public
307
- */
308
- public function enqueue_scripts()
309
- {
310
- wp_register_script( LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'js/litespeed-cache-admin.js', array(), LiteSpeed_Cache::PLUGIN_VERSION, false ) ;
311
-
312
- $localize_data = array() ;
313
- if ( LiteSpeed_Cache_GUI::has_whm_msg() ) {
314
- $ajax_url_dismiss_whm = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_WHM, true ) ;
315
- $localize_data[ 'ajax_url_dismiss_whm' ] = $ajax_url_dismiss_whm ;
316
- }
317
-
318
- if ( LiteSpeed_Cache_GUI::has_msg_ruleconflict() ) {
319
- $ajax_url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_EXPIRESDEFAULT, true ) ;
320
- $localize_data[ 'ajax_url_dismiss_ruleconflict' ] = $ajax_url ;
321
- }
322
-
323
- $promo_tag = LiteSpeed_Cache_GUI::get_instance()->show_promo( true ) ;
324
- if ( $promo_tag ) {
325
- $ajax_url_promo = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, true, null, array( 'promo_tag' => $promo_tag ) ) ;
326
- $localize_data[ 'ajax_url_promo' ] = $ajax_url_promo ;
327
- }
328
-
329
- if ( $localize_data ) {
330
- wp_localize_script(LiteSpeed_Cache::PLUGIN_NAME, 'litespeed_data', $localize_data ) ;
331
- }
332
-
333
- wp_enqueue_script( LiteSpeed_Cache::PLUGIN_NAME ) ;
334
- }
335
-
336
- /**
337
- * Callback that adds LiteSpeed Cache's action links.
338
- *
339
- * @since 1.0.0
340
- * @access public
341
- * @param array $links Previously added links from other plugins.
342
- * @return array Links array with the litespeed cache one appended.
343
- */
344
- public function add_plugin_links($links)
345
- {
346
- //$links[] = '<a href="' . admin_url('admin.php?page=litespeedcache') .'">Settings</a>';
347
- $links[] = '<a href="' . admin_url('options-general.php?page=litespeedcache') . '">' . __('Settings', 'litespeed-cache') . '</a>' ;
348
-
349
- return $links ;
350
- }
351
-
352
- /**
353
- * Add text to recommend updating upon update success.
354
- *
355
- * @since 1.0.8.1
356
- * @access public
357
- * @param string $translations
358
- * @param string $text
359
- * @return string
360
- */
361
- public function add_update_text($translations, $text)
362
- {
363
- if ( $text !== 'Updated!' ) {
364
- return $translations ;
365
- }
366
-
367
- return $translations . ' ' . __('It is recommended that LiteSpeed Cache be purged after updating a plugin.', 'litespeed-cache') ;
368
- }
369
-
370
- /**
371
- * Add the filter to update plugin update text.
372
- *
373
- * @since 1.0.8.1
374
- * @access public
375
- */
376
- public function set_update_text()
377
- {
378
- add_filter('gettext', array($this, 'add_update_text'), 10, 2) ;
379
- }
380
-
381
- /**
382
- * Remove the filter to update plugin update text.
383
- *
384
- * @since 1.0.8.1
385
- * @access public
386
- */
387
- public function unset_update_text()
388
- {
389
- remove_filter('gettext', array($this, 'add_update_text')) ;
390
- }
391
-
392
- /**
393
- * Change the admin footer text on LiteSpeed Cache admin pages.
394
- *
395
- * @since 1.0.13
396
- * @param string $footer_text
397
- * @return string
398
- */
399
- public function admin_footer_text($footer_text)
400
- {
401
- require_once LSCWP_DIR . 'admin/tpl/inc/admin_footer.php' ;
402
-
403
- return $footer_text ;
404
- }
405
-
406
- /**
407
- * Whether to disable all settings or not.
408
- *
409
- * Currently used for 'use primary subsite settings'
410
- *
411
- * @since 1.0.13
412
- * @access public
413
- * @return bool True to disable all settings, false otherwise.
414
- */
415
- public function get_disable_all()
416
- {
417
- return $this->disable_all ;
418
- }
419
-
420
- /**
421
- * Set to disable all settings.
422
- *
423
- * @since 1.0.13
424
- * @access public
425
- */
426
- public function set_disable_all()
427
- {
428
- $this->disable_all = true ;
429
- }
430
-
431
- /**
432
- * If show compatibility tab in settings
433
- * @since 1.1.0
434
- * @return bool True if shows
435
- */
436
- public function show_compatibility_tab()
437
- {
438
- return function_exists('the_views') ;
439
- }
440
-
441
- /**
442
- * Displays the help tab in the admin pages.
443
- *
444
- * @since 1.0.0
445
- * @access public
446
- */
447
- public function add_help_tabs()
448
- {
449
- require_once LSCWP_DIR . 'admin/tpl/inc/help_tabs.php' ;
450
- }
451
-
452
- /**
453
- * Builds the html for a single notice.
454
- *
455
- * @since 1.0.7
456
- * @access public
457
- * @param string $color The color to use for the notice.
458
- * @param string $str The notice message.
459
- * @return string The built notice html.
460
- */
461
- public static function build_notice($color, $str)
462
- {
463
- return '<div class="' . $color . ' is-dismissible"><p>'. $str . '</p></div>' ;
464
- }
465
-
466
- /**
467
- * Get the error description
468
- *
469
- * @since 1.1.0
470
- * @param init $err_code
471
- * @param mixed $args
472
- * @return mixed String or false
473
- */
474
- public static function get_error($err_code, $args = null)
475
- {
476
- $error = LiteSpeed_Cache_Admin_Error::get_instance()->convert_code_to_error($err_code) ;
477
- if ( empty($error) ) {
478
- return false ;
479
- }
480
- $error = 'ERROR ' . $err_code . ': ' . $error ;
481
- if ( ! is_null($args) ) {
482
- if ( is_array($args) ) {
483
- $error = vsprintf($error, $args) ;
484
- }
485
- else {
486
- $error = sprintf($error, $args) ;
487
- }
488
- }
489
- return $error ;
490
- }
491
-
492
- /**
493
- * Adds an error to the admin notice system.
494
- *
495
- * This function will get the error message by error code and arguments
496
- * and append it to the list of outgoing errors.
497
- *
498
- * @access public
499
- * @since 1.1.0
500
- * @param int $err_code The error code to retrieve.
501
- * @param mixed $args Null if no arguments, an array if multiple arguments,
502
- * else a single argument.
503
- */
504
- public static function add_error($err_code, $args = null)
505
- {
506
- $error = self::get_error($err_code, $args) ;
507
- if( ! $error ) {
508
- return false ;
509
- }
510
- self::add_notice(self::NOTICE_RED, $error) ;
511
- }
512
-
513
- /**
514
- * Display info notice
515
- *
516
- * @since 1.6.5
517
- * @access public
518
- */
519
- public static function info( $msg )
520
- {
521
- self::add_notice( self::NOTICE_BLUE, $msg ) ;
522
- }
523
-
524
- /**
525
- * Display note notice
526
- *
527
- * @since 1.6.5
528
- * @access public
529
- */
530
- public static function note( $msg )
531
- {
532
- self::add_notice( self::NOTICE_YELLOW, $msg ) ;
533
- }
534
-
535
- /**
536
- * Display success notice
537
- *
538
- * @since 1.6
539
- * @access public
540
- */
541
- public static function succeed( $msg )
542
- {
543
- self::add_notice( self::NOTICE_GREEN, $msg ) ;
544
- }
545
-
546
- /**
547
- * Display error notice
548
- *
549
- * @since 1.6
550
- * @access public
551
- */
552
- public static function error( $msg )
553
- {
554
- self::add_notice( self::NOTICE_RED, $msg ) ;
555
- }
556
-
557
- /**
558
- * Adds a notice to display on the admin page. Multiple messages of the
559
- * same color may be added in a single call. If the list is empty, this
560
- * method will add the action to display notices.
561
- *
562
- * @since 1.0.7
563
- * @access public
564
- * @param string $color One of the available constants provided by this
565
- * class.
566
- * @param mixed $msg May be a string for a single message or an array for
567
- * multiple.
568
- */
569
- public static function add_notice($color, $msg)
570
- {
571
- // Bypass adding for CLI or cron
572
- if ( defined( 'LITESPEED_CLI' ) || defined( 'DOING_CRON' ) ) {
573
- // WP CLI will show the info directly
574
- if ( defined( 'WP_CLI' ) && WP_CLI ) {
575
- $msg = strip_tags( $msg ) ;
576
- if ( $color == self::NOTICE_RED ) {
577
- WP_CLI::error( $msg ) ;
578
- }
579
- else {
580
- WP_CLI::success( $msg ) ;
581
- }
582
- }
583
- return ;
584
- }
585
-
586
- $messages = (array)get_option( self::LITESPEED_MSG ) ;
587
- if( ! $messages ) {
588
- $messages = array() ;
589
- }
590
- if ( is_array($msg) ) {
591
- foreach ($msg as $str) {
592
- $messages[] = self::build_notice($color, $str) ;
593
- }
594
- }
595
- else {
596
- $messages[] = self::build_notice($color, $msg) ;
597
- }
598
- update_option( self::LITESPEED_MSG, $messages ) ;
599
- }
600
-
601
- /**
602
- * Display notices and errors in dashboard
603
- *
604
- * @since 1.1.0
605
- * @access public
606
- */
607
- public function display_messages()
608
- {
609
- // One time msg
610
- $messages = get_option( self::LITESPEED_MSG ) ;
611
- if( is_array($messages) ) {
612
- $messages = array_unique($messages) ;
613
-
614
- $added_thickbox = false ;
615
- foreach ($messages as $msg) {
616
- // Added for popup links
617
- if ( strpos( $msg, 'TB_iframe' ) && ! $added_thickbox ) {
618
- add_thickbox();
619
- $added_thickbox = true ;
620
- }
621
- echo $msg ;
622
- }
623
- }
624
- delete_option( self::LITESPEED_MSG ) ;
625
-
626
- if( empty($_GET['page']) || (substr($_GET['page'], 0, 8) !== 'lscache-' && $_GET['page'] !== 'litespeedcache') ) {
627
- global $pagenow;
628
- if ( $pagenow != 'plugins.php' ) { // && $pagenow != 'index.php'
629
- return;
630
- }
631
- }
632
-
633
- if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_NEWS ) ) {
634
- return;
635
- }
636
-
637
- /**
638
- * Check promo msg first
639
- * @since 2.9
640
- */
641
- LiteSpeed_Cache_GUI::get_instance()->show_promo() ;
642
-
643
- // Show version news
644
- $this->_show_recommended();
645
- }
646
-
647
- /**
648
- * Hooked to the in_widget_form action.
649
- * Appends LiteSpeed Cache settings to the widget edit settings screen.
650
- * This will append the esi on/off selector and ttl text.
651
- *
652
- * @access public
653
- * @since 1.1.0
654
- * @param type $widget
655
- * @param type $return
656
- * @param type $instance
657
- */
658
- public function show_widget_edit($widget, $return, $instance)
659
- {
660
- require LSCWP_DIR . 'admin/tpl/esi_widget_edit.php' ;
661
- }
662
-
663
- /**
664
- * Displays the cache management page.
665
- *
666
- * @since 1.0.0
667
- * @access public
668
- */
669
- public function show_menu_manage()
670
- {
671
- require_once LSCWP_DIR . 'admin/tpl/manage.php' ;
672
- }
673
-
674
- /**
675
- * Outputs the LiteSpeed Cache settings page.
676
- *
677
- * @since 1.0.0
678
- * @access public
679
- */
680
- public function show_menu_settings()
681
- {
682
- if ( is_network_admin() ) {
683
- require_once LSCWP_DIR . 'admin/tpl/network_settings.php' ;
684
- }
685
- else {
686
- if ( $_GET['page'] != 'litespeedcache' ) {// ls settings msg need to display manually
687
- settings_errors() ;
688
- }
689
- require_once LSCWP_DIR . 'admin/tpl/settings.php' ;
690
- }
691
- }
692
-
693
- /**
694
- * Displays the edit_htaccess admin page.
695
- *
696
- * This function will try to load the .htaccess file contents.
697
- * If it fails, it will echo the error message.
698
- *
699
- * @since 1.0.4
700
- * @access public
701
- */
702
- public function show_menu_edit_htaccess()
703
- {
704
- require_once LSCWP_DIR . 'admin/tpl/edit_htaccess.php' ;
705
- }
706
-
707
- /**
708
- * Outputs the html for the Environment Report page.
709
- *
710
- * @since 1.0.12
711
- * @access public
712
- */
713
- public function show_report()
714
- {
715
- require_once LSCWP_DIR . 'admin/tpl/report.php' ;
716
- }
717
-
718
- /**
719
- * Outputs the html for the Import/Export page.
720
- *
721
- * @since 1.8.2
722
- * @access public
723
- */
724
- public function show_import_export()
725
- {
726
- require_once LSCWP_DIR . 'admin/tpl/import_export.php' ;
727
- }
728
-
729
- /**
730
- * Outputs the crawler operation page.
731
- *
732
- * @since 1.1.0
733
- * @access public
734
- */
735
- public function show_crawler()
736
- {
737
- require_once LSCWP_DIR . 'admin/tpl/crawler.php' ;
738
- }
739
-
740
- /**
741
- * Outputs the optimization operation page.
742
- *
743
- * @since 1.6
744
- * @access public
745
- */
746
- public function show_optimization()
747
- {
748
- require_once LSCWP_DIR . 'admin/tpl/image_optimization.php' ;
749
- }
750
-
751
- /**
752
- * Outputs the debug log.
753
- *
754
- * @since 1.1.5
755
- * @access public
756
- */
757
- public function show_debug_log()
758
- {
759
- require_once LSCWP_DIR . 'admin/tpl/debug_log.php' ;
760
- }
761
-
762
- /**
763
- * Outputs a notice to the admin panel when the plugin is installed
764
- * via the WHM plugin.
765
- *
766
- * @since 1.0.12
767
- * @access public
768
- */
769
- public function show_display_installed()
770
- {
771
- require_once LSCWP_DIR . 'admin/tpl/inc/show_display_installed.php' ;
772
- }
773
-
774
- /**
775
- * Display error cookie msg.
776
- *
777
- * @since 1.0.12
778
- * @access public
779
- */
780
- public static function show_error_cookie()
781
- {
782
- require_once LSCWP_DIR . 'admin/tpl/inc/show_error_cookie.php' ;
783
- }
784
-
785
- /**
786
- * Display warning if lscache is disabled
787
- *
788
- * @since 2.1
789
- * @access public
790
- */
791
- public function cache_disabled_warning()
792
- {
793
- include LSCWP_DIR . "admin/tpl/inc/check_cache_disabled.php" ;
794
- }
795
-
796
- /**
797
- * Build a textarea
798
- *
799
- * @since 1.1.0
800
- * @since 1.7 Changed cols param order to be the 2nd from 4th
801
- * @access public
802
- * @param string $id
803
- * @param string $val Value of input
804
- * @param boolean $disabled If this input is disabled or not
805
- * @param int $cols The width of textarea
806
- */
807
- public function build_textarea( $id, $cols = false, $val = null, $disabled = false, $cls = '' )
808
- {
809
- if ( strpos( $id, '[' ) === false ) {
810
- if ( $val === null ) {
811
- global $_options ;
812
- $val = $_options[$id] ;
813
- }
814
-
815
- $id = "[$id]" ;
816
- }
817
-
818
- $disabled = $disabled ? ' disabled ' : '' ;
819
-
820
- if ( ! $cols ) {
821
- $cols = 80 ;
822
- }
823
-
824
- if ( $cls ) {
825
- $cls = " class='$cls' " ;
826
- }
827
-
828
- echo "<textarea name='" . LiteSpeed_Cache_Config::OPTION_NAME . "$id' rows='5' cols='$cols' $cls $disabled>" . esc_textarea($val) . "</textarea>" ;
829
- }
830
-
831
- /**
832
- * Build a textarea based on separate stored option data
833
- *
834
- * @since 1.5
835
- * @since 1.7 Changed cols param order to be the 2nd from 4th
836
- * @access public
837
- * @param string $id
838
- * @param int $cols The width of textarea
839
- */
840
- public function build_textarea2( $id, $cols = false )
841
- {
842
- // Get default val for separate item
843
- $val = $this->config->get_item( $id, true ) ;
844
-
845
- $this->build_textarea( $id, $cols, $val, false, 'litespeed-textarea-success' ) ;
846
- }
847
-
848
- /**
849
- * Build a text input field
850
- *
851
- * @since 1.1.0
852
- * @since 1.7 Added [] check and wrapper to $id, moved $readonly/$id_attr
853
- * @access public
854
- * @param string $id
855
- * @param string $style Appending styles
856
- * @param boolean $readonly If is readonly
857
- * @param string $id_attr ID for this field
858
- * @param string $val Field value
859
- * @param string $attrs Additional attributes
860
- * @param string $type Input type
861
- */
862
- public function build_input( $id, $style = false, $val = null, $id_attr = null, $attrs = '', $type = 'text', $readonly = false )
863
- {
864
- if ( strpos( $id, '[' ) === false ) {
865
- if ( $val === null ) {
866
- global $_options ;
867
- $val = $_options[ $id ] ;
868
- }
869
-
870
- $id = "[$id]" ;
871
- }
872
-
873
- $readonly = $readonly ? ' readonly ' : '' ;
874
- if ( $id_attr !== null ) {
875
- $id_attr = " id='$id_attr' " ;
876
- }
877
-
878
- if ( $type == 'text' ) {
879
- $style = "litespeed-regular-text $style" ;
880
- }
881
-
882
- echo "<input type='$type' class='$style' name='" . LiteSpeed_Cache_Config::OPTION_NAME . "$id' value='" . esc_textarea( $val ) ."' $readonly $id_attr $attrs /> " ;
883
- }
884
-
885
- /**
886
- * Build a checkbox html snippet
887
- *
888
- * @since 1.1.0
889
- * @access public
890
- * @param string $id
891
- * @param string $title
892
- * @param bool $checked
893
- */
894
- public function build_checkbox($id, $title, $checked, $value = 1 )
895
- {
896
- $checked = $checked ? ' checked ' : '' ;
897
-
898
- $label_id = str_replace( array( '[', ']' ), '_', $id ) ;
899
-
900
- if ( $value !== 1 ) {
901
- $label_id .= '_' . $value ;
902
- }
903
-
904
- echo "<div class='litespeed-tick'>
905
- <label for='conf_$label_id'>$title</label>
906
- <input type='checkbox' name='" . LiteSpeed_Cache_Config::OPTION_NAME . "[$id]' id='conf_$label_id' value='$value' $checked />
907
- </div>" ;
908
- }
909
-
910
- /**
911
- * Build a toggle checkbox html snippet
912
- *
913
- * @since 1.7
914
- */
915
- public function build_toggle( $id, $checked = null, $title_on = null, $title_off = null )
916
- {
917
- if ( strpos( $id, '[' ) === false ) {
918
- if ( $checked === null ) {
919
- global $_options ;
920
- $to_be_checked = null ;
921
- if ( isset( $_options[ $id ] ) ) {
922
- $to_be_checked = $_options[ $id ] ;
923
- }
924
- $checked = $to_be_checked ? true : false ;
925
- }
926
- $id = "[$id]" ;
927
- }
928
- $checked = $checked ? 1 : 0 ;
929
-
930
- if ( $title_on === null ) {
931
- $title_on = __( 'ON', 'litespeed-cache' ) ;
932
- $title_off = __( 'OFF', 'litespeed-cache' ) ;
933
- }
934
-
935
- if ( $checked ) {
936
- $cls = 'primary' ;
937
- }
938
- else {
939
- $cls = 'default litespeed-toggleoff' ;
940
- }
941
-
942
- echo "<div class='litespeed-toggle litespeed-toggle-btn litespeed-toggle-btn-$cls' data-litespeed-toggle-on='primary' data-litespeed-toggle-off='default'>
943
- <input name='" . LiteSpeed_Cache_Config::OPTION_NAME . "$id' type='hidden' value='$checked' />
944
- <div class='litespeed-toggle-group'>
945
- <label class='litespeed-toggle-btn litespeed-toggle-btn-primary litespeed-toggle-on'>$title_on</label>
946
- <label class='litespeed-toggle-btn litespeed-toggle-btn-default litespeed-toggle-active litespeed-toggle-off'>$title_off</label>
947
- <span class='litespeed-toggle-handle litespeed-toggle-btn litespeed-toggle-btn-default'></span>
948
- </div>
949
- </div>" ;
950
- }
951
-
952
- /**
953
- * Build a switch div html snippet
954
- *
955
- * @since 1.1.0
956
- * @since 1.7 removed param $disable
957
- * @access public
958
- * @param string $id
959
- * @param boolean $return Return the html or echo it
960
- * @param boolean $checked If the value is on
961
- * @param string $id_attr ID for this field, set to true if want to use a not specified unique value
962
- */
963
- public function build_switch($id, $checked = null, $return = false, $id_attr = null)
964
- {
965
- $id_attr_on = $id_attr === null ? null : $id_attr . '_' . LiteSpeed_Cache_Config::VAL_ON ;
966
- $id_attr_off = $id_attr === null ? null : $id_attr . '_' . LiteSpeed_Cache_Config::VAL_OFF ;
967
- $html = '<div class="litespeed-switch">' ;
968
- $html .= $this->build_radio($id, LiteSpeed_Cache_Config::VAL_OFF, null, $checked === null ? null : !$checked, $id_attr_off) ;
969
- $html .= $this->build_radio($id, LiteSpeed_Cache_Config::VAL_ON, null, $checked, $id_attr_on) ;
970
- $html .= '</div>' ;
971
-
972
- if ( $return ) {
973
- return $html ;
974
- }
975
- else {
976
- echo $html ;
977
- }
978
- }
979
-
980
- /**
981
- * Build a radio input html codes and output
982
- *
983
- * @since 1.1.0
984
- * @access public
985
- * @param string $id
986
- * @param string $val Default value of this input
987
- * @param string $txt Title of this input
988
- * @param bool $checked If checked or not
989
- * @param string $id_attr ID for this field, set to true if want to use a not specified unique value
990
- */
991
- public function build_radio($id, $val, $txt = null, $checked = null, $id_attr = null)
992
- {
993
- if ( strpos( $id, '[' ) === false ) {
994
- if ( $checked === null ) {
995
- global $_options ;
996
- $to_be_checked = null ;
997
- if ( isset( $_options[ $id ] ) ) {
998
- $to_be_checked = is_int( $val ) ? (int)$_options[ $id ] : $_options[ $id ] ;
999
- }
1000
-
1001
- $checked = $to_be_checked === $val ? true : false ;
1002
- }
1003
-
1004
- $id = "[$id]" ;
1005
- }
1006
-
1007
- if ( $id_attr === null ) {
1008
- $id_attr = is_int($val) ? "conf_" . str_replace( array( '[', ']' ), '_', $id ) . "_$val" : md5($val) ;
1009
- }
1010
- elseif ( $id_attr === true ) {
1011
- $id_attr = md5($val) ;
1012
- }
1013
-
1014
- if ( $txt === null ){
1015
- if ( $val === LiteSpeed_Cache_Config::VAL_ON ){
1016
- $txt = __( 'ON', 'litespeed-cache' ) ;
1017
- }
1018
-
1019
- if ( $val === LiteSpeed_Cache_Config::VAL_OFF ){
1020
- $txt = __( 'OFF', 'litespeed-cache' ) ;
1021
- }
1022
- }
1023
-
1024
- $checked = $checked ? ' checked ' : '' ;
1025
-
1026
- return "<input type='radio' autocomplete='off' name='". LiteSpeed_Cache_Config::OPTION_NAME . "$id' id='$id_attr' value='$val' $checked /> <label for='$id_attr'>$txt</label>" ;
1027
- }
1028
-
1029
- /**
1030
- * Display default value
1031
- *
1032
- * @since 1.1.1
1033
- * @access public
1034
- * @param string $id The setting tag
1035
- */
1036
- public function recommended( $id, $is_item = false )
1037
- {
1038
- $val = '' ;
1039
- if ( ! $is_item ) {
1040
- if ( isset( $this->default_settings[ $id ] ) ) {
1041
- $val = $this->default_settings[ $id ] ;
1042
- }
1043
- }
1044
- else {
1045
- $val = $this->config->default_item( $id ) ;
1046
- }
1047
-
1048
- if ( $val ) {
1049
- if ( ! is_numeric( $val ) && strpos( $val, "\n" ) !== false ) {
1050
- $val = "<textarea readonly rows='5' class='litespeed-left10'>$val</textarea>" ;
1051
- }
1052
- else {
1053
- $val = "<code>$val</code>" ;
1054
- }
1055
- echo sprintf( __( 'Recommended value: %s', 'litespeed-cache' ), $val ) ;
1056
- }
1057
- }
1058
-
1059
- /**
1060
- * Display API environment variable support
1061
- *
1062
- * @since 1.8.3
1063
- * @access private
1064
- */
1065
- private function _api_env_var()
1066
- {
1067
- $args = func_get_args() ;
1068
- $s = '<code>' . implode( '</code>, <code>', $args ) . '</code>' ;
1069
-
1070
- echo '<font class="litespeed-success"> '
1071
- . __( 'API', 'litespeed-cache' ) . ': '
1072
- . sprintf( __( 'Server variable(s) %s available to override this setting.', 'litespeed-cache' ), $s ) ;
1073
-
1074
- $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:server_variables' ) ;
1075
- }
1076
-
1077
- /**
1078
- * Display learn more link
1079
- *
1080
- * @since 2.6.1
1081
- * @access public
1082
- */
1083
- public function learn_more( $link, $title = false, $class = false )
1084
- {
1085
- if ( $class ) {
1086
- $class = " class='$class' " ;
1087
- }
1088
-
1089
- if ( ! $title ) {
1090
- $title = __( 'Learn More', 'litespeed-cache' ) ;
1091
- }
1092
-
1093
- echo " <a href='$link' target='_blank' $class>$title</a>" ;
1094
- }
1095
-
1096
- /**
1097
- * Display URI setting example
1098
- *
1099
- * @since 2.6.1
1100
- * @access private
1101
- */
1102
- private function _uri_usage_example()
1103
- {
1104
- echo __( 'The URLs will be compared to the REQUEST_URI server variable.', 'litespeed-cache' ) ;
1105
- echo ' ' . sprintf( __( 'For example, for %s, %s can be used here.', 'litespeed-cache' ), '<code>/mypath/mypage?aa=bb</code>', '<code>mypage?aa=</code>' ) ;
1106
- echo '<br /><i>' ;
1107
- echo sprintf( __( 'To match the beginning, add %s to the beginning of the item.', 'litespeed-cache' ), '<code>^</code>' ) ;
1108
- echo ' ' . sprintf( __( 'To do an exact match, add %s to the end of the URL.', 'litespeed-cache' ), '<code>lt;/code>' ) ;
1109
- echo ' ' . __( 'One per line.', 'litespeed-cache' ) ;
1110
- echo '</i>' ;
1111
- }
1112
-
1113
- /**
1114
- * Return groups string
1115
- *
1116
- * @since 2.0
1117
- * @access public
1118
- */
1119
- public static function print_plural( $num, $kind = 'group' )
1120
- {
1121
- if ( $num > 1 ) {
1122
- switch ( $kind ) {
1123
- case 'group' :
1124
- return sprintf( __( '%s groups', 'litespeed-cache' ), $num ) ;
1125
-
1126
- case 'image' :
1127
- return sprintf( __( '%s images', 'litespeed-cache' ), $num ) ;
1128
-
1129
- default:
1130
- return $num ;
1131
- }
1132
-
1133
- }
1134
-
1135
- switch ( $kind ) {
1136
- case 'group' :
1137
- return sprintf( __( '%s group', 'litespeed-cache' ), $num ) ;
1138
-
1139
- case 'image' :
1140
- return sprintf( __( '%s image', 'litespeed-cache' ), $num ) ;
1141
-
1142
- default:
1143
- return $num ;
1144
- }
1145
- }
1146
-
1147
- /**
1148
- * Return guidance html
1149
- *
1150
- * @since 2.0
1151
- * @access public
1152
- */
1153
- public static function guidance( $title, $steps, $current_step )
1154
- {
1155
- if ( $current_step === 'done' ) {
1156
- $current_step = count( $steps ) + 1 ;
1157
- }
1158
-
1159
- $percentage = ' (' . floor( ( $current_step - 1 ) * 100 / count( $steps ) ) . '%)' ;
1160
-
1161
- $html = '<div class="litespeed-guide">'
1162
- . '<h2>' . $title . $percentage . '</h2>'
1163
- . '<ol>' ;
1164
- foreach ( $steps as $k => $v ) {
1165
- $step = $k + 1 ;
1166
- if ( $current_step > $step ) {
1167
- $html .= '<li class="litespeed-guide-done">' ;
1168
- }
1169
- else {
1170
- $html .= '<li>' ;
1171
- }
1172
- $html .= $v . '</li>' ;
1173
- }
1174
-
1175
- $html .= '</ol></div>' ;
1176
-
1177
- return $html ;
1178
- }
1179
-
1180
- /**
1181
- * Get the current instance object.
1182
- *
1183
- * @since 1.1.0
1184
- * @access public
1185
- * @return Current class instance.
1186
- */
1187
- public static function get_instance()
1188
- {
1189
- if ( ! isset(self::$_instance) ) {
1190
- self::$_instance = new self() ;
1191
- }
1192
-
1193
- return self::$_instance ;
1194
- }
1195
- }