diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 47627d0a7..43e3edcf4 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -5,7 +5,7 @@ on:
branches:
- master
- dev
- - "v*.*"
+ - 'v*.*'
pull_request:
jobs:
@@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-node@v3
with:
- node-version: "20"
+ node-version: '20'
check-latest: true
cache: npm
cache-dependency-path: package-lock.json
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 000000000..c5ec21291
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,16 @@
+**/*.min.*
+**/*.ori.*
+**/*.tpl.php
+assets/js/css_async.js
+assets/js/webfontloader.js
+lib
+tpl/banner
+tpl/esi_widget_edit.php
+tpl/inc/api_key.php
+tpl/inc/check_cache_disabled.php
+tpl/inc/check_if_network_disable_all.php
+tpl/inc/modal.header.php
+!tpl/cache/network_settings-browser.tpl.php
+!tpl/cache/network_settings-object.tpl.php
+!tpl/cache/settings-browser.tpl.php
+!tpl/cache/settings-object.tpl.php
diff --git a/.prettierrc b/.prettierrc
index 946a3dd0e..09fdb315e 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -1,7 +1,15 @@
{
- "plugins": [
- "@prettier/plugin-php"
+ "overrides": [
+ {
+ "files": ".prettierrc",
+ "options": { "parser": "json" }
+ },
+ {
+ "files": "**/*.{yml,yaml}",
+ "options": { "tabWidth": 2 }
+ }
],
+ "plugins": ["@prettier/plugin-php"],
"arrowParens": "avoid",
"braceStyle": "per-cs",
"endOfLine": "auto",
@@ -11,6 +19,6 @@
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "all",
- "trailingCommaPHP": false,
+ "trailingCommaPHP": true,
"useTabs": true
}
diff --git a/assets/css/litespeed-legacy.css b/assets/css/litespeed-legacy.css
index af1e5d2a1..2e71731ae 100644
--- a/assets/css/litespeed-legacy.css
+++ b/assets/css/litespeed-legacy.css
@@ -1,20 +1,18 @@
-.litespeed-wrap h2.nav-tab-wrapper, .litespeed-wrap h3.nav-tab-wrapper{
- margin-bottom:0;
+.litespeed-wrap h2.nav-tab-wrapper,
+.litespeed-wrap h3.nav-tab-wrapper {
+ margin-bottom: 0;
}
-.litespeed-wrap h2 .nav-tab{
- font-size:14px;
+.litespeed-wrap h2 .nav-tab {
+ font-size: 14px;
}
-
.litespeed-wrap .striped > tbody > :nth-child(odd),
.litespeed-wrap ul.striped > :nth-child(odd),
.litespeed-wrap .alternate {
background-color: #f9f9f9;
}
-
-
.litespeed-wrap .notice,
.litespeed-wrap div.updated,
.litespeed-wrap div.error {
@@ -55,4 +53,4 @@
.litespeed-wrap .notice-info.notice-alt {
background-color: #e5f5fa;
-}
\ No newline at end of file
+}
diff --git a/assets/css/litespeed.css b/assets/css/litespeed.css
index 239530f87..cbdde6786 100644
--- a/assets/css/litespeed.css
+++ b/assets/css/litespeed.css
@@ -1,7 +1,8 @@
@font-face {
font-family: 'litespeedfont';
src: url('fonts/litespeedfont.eot?rs8ttq');
- src: url('fonts/litespeedfont.eot?rs8ttq#iefix') format('embedded-opentype'),
+ src:
+ url('fonts/litespeedfont.eot?rs8ttq#iefix') format('embedded-opentype'),
url('fonts/litespeedfont.ttf?rs8ttq') format('truetype'),
url('fonts/litespeedfont.woff?rs8ttq') format('woff'),
url('fonts/litespeedfont.svg?rs8ttq#litespeedfont') format('svg');
@@ -12,7 +13,7 @@
#adminmenu #toplevel_page_lscache-settings .menu-icon-generic div.wp-menu-image:before,
#adminmenu #toplevel_page_litespeed .menu-icon-generic div.wp-menu-image:before,
.litespeed-top-toolbar .ab-icon::before {
- content: "\e900";
+ content: '\e900';
font-family: 'litespeedfont' !important;
speak: none;
font-style: normal;
@@ -24,92 +25,90 @@
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-
}
*[litespeed-accesskey]:before {
- content: '['attr(litespeed-accesskey) '] ';
+ content: '[' attr(litespeed-accesskey) '] ';
}
-
/* =======================================
UTILITIES - toggle UI
======================================= */
-input[type="checkbox"].litespeed-tiny-toggle {
- -webkit-appearance: none;
- -moz-appearance: none;
- appearance: none;
-
- -webkit-tap-highlight-color: transparent;
-
- width: auto;
- height: auto;
- vertical-align: middle;
- position: relative;
- border: 0;
- outline: 0;
- cursor: pointer;
- margin: 0 4px;
- background: none;
- box-shadow: none;
-}
-input[type="checkbox"].litespeed-tiny-toggle:focus {
- box-shadow: none;
-}
-input[type="checkbox"].litespeed-tiny-toggle:after {
- content: '';
- font-size: 8px;
- font-weight: 400;
- line-height: 18px;
- text-indent: -14px;
- color: #ffffff;
- width: 36px;
- height: 18px;
- display: inline-block;
- background-color: #a7aaad;
- border-radius: 72px;
- box-shadow: 0 0 12px rgb(0 0 0 / 15%) inset;
-}
-input[type="checkbox"].litespeed-tiny-toggle:before {
- content: '';
- width: 14px;
- height: 14px;
- display: block;
- position: absolute;
- top: 2px;
- left: 2px;
- margin: 0;
- border-radius: 50%;
- background-color: #ffffff;
-}
-
-input[type="checkbox"].litespeed-tiny-toggle:checked:before {
- left: 20px;
- margin: 0;
- background-color: #ffffff;
-}
-
-input[type="checkbox"].litespeed-tiny-toggle,
-input[type="checkbox"].litespeed-tiny-toggle:before,
-input[type="checkbox"].litespeed-tiny-toggle:after,
-input[type="checkbox"].litespeed-tiny-toggle:checked:before,
-input[type="checkbox"].litespeed-tiny-toggle:checked:after {
- transition: ease .15s;
-}
-input[type="checkbox"].litespeed-tiny-toggle:checked:after {
- /*content: 'ON';*/
- background-color: #2271b1;
-}
-
-.block-editor__container input[type="checkbox"].litespeed-tiny-toggle {
+input[type='checkbox'].litespeed-tiny-toggle {
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+
+ -webkit-tap-highlight-color: transparent;
+
+ width: auto;
+ height: auto;
+ vertical-align: middle;
+ position: relative;
+ border: 0;
+ outline: 0;
+ cursor: pointer;
+ margin: 0 4px;
+ background: none;
+ box-shadow: none;
+}
+input[type='checkbox'].litespeed-tiny-toggle:focus {
+ box-shadow: none;
+}
+input[type='checkbox'].litespeed-tiny-toggle:after {
+ content: '';
+ font-size: 8px;
+ font-weight: 400;
+ line-height: 18px;
+ text-indent: -14px;
+ color: #ffffff;
+ width: 36px;
+ height: 18px;
+ display: inline-block;
+ background-color: #a7aaad;
+ border-radius: 72px;
+ box-shadow: 0 0 12px rgb(0 0 0 / 15%) inset;
+}
+input[type='checkbox'].litespeed-tiny-toggle:before {
+ content: '';
+ width: 14px;
+ height: 14px;
+ display: block;
+ position: absolute;
+ top: 2px;
+ left: 2px;
+ margin: 0;
+ border-radius: 50%;
+ background-color: #ffffff;
+}
+
+input[type='checkbox'].litespeed-tiny-toggle:checked:before {
+ left: 20px;
+ margin: 0;
+ background-color: #ffffff;
+}
+
+input[type='checkbox'].litespeed-tiny-toggle,
+input[type='checkbox'].litespeed-tiny-toggle:before,
+input[type='checkbox'].litespeed-tiny-toggle:after,
+input[type='checkbox'].litespeed-tiny-toggle:checked:before,
+input[type='checkbox'].litespeed-tiny-toggle:checked:after {
+ transition: ease 0.15s;
+}
+input[type='checkbox'].litespeed-tiny-toggle:checked:after {
+ /*content: 'ON';*/
+ background-color: #2271b1;
+}
+
+.block-editor__container input[type='checkbox'].litespeed-tiny-toggle {
border: 0 !important;
}
-.block-editor__container input[type="checkbox"].litespeed-tiny-toggle:before {
+.block-editor__container input[type='checkbox'].litespeed-tiny-toggle:before {
top: 5px;
left: 7px;
}
-.block-editor__container input[type="checkbox"].litespeed-tiny-toggle:checked:before {
+.block-editor__container input[type='checkbox'].litespeed-tiny-toggle:checked:before {
left: 23px;
}
@@ -121,7 +120,7 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
/* content: "\e900";
font-family: 'litespeedfont' !important; */
content: '';
- background-image:url('../img/lscwp_grayscale_font-icon_22px.svg');
+ background-image: url('../img/lscwp_grayscale_font-icon_22px.svg');
/* filter: grayscale(1); */
background-size: 22px;
background-repeat: no-repeat;
@@ -130,8 +129,8 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
vertical-align: middle;
display: inline-block;
position: absolute;
- left:5px;
- top:8px;
+ left: 5px;
+ top: 8px;
}
.rtl .litespeed_icon:before {
@@ -157,7 +156,6 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
display: inline-block;
}
-
.litespeed-row {
margin-top: 5px;
}
@@ -177,7 +175,7 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
height: auto;
}
-.litespeed-flex-container>* {
+.litespeed-flex-container > * {
box-sizing: border-box;
}
@@ -300,7 +298,7 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
}
.litespeed-wrap .litespeed-bg-quic-cloud {
- background: linear-gradient(rgba(230,242,242,1) 10%, rgba(250,255,255,1) 30%);
+ background: linear-gradient(rgba(230, 242, 242, 1) 10%, rgba(250, 255, 255, 1) 30%);
}
.litespeed-left50 {
@@ -336,7 +334,6 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
margin-bottom: 0px !important;
}
-
.litespeed-empty-space-xlarge {
margin-top: 8em;
}
@@ -357,7 +354,6 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
margin-top: 1em;
}
-
/* =======================================
UTILITIES - typography
======================================= */
@@ -367,7 +363,7 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
}
.litespeed-text-large {
- font-size: .75em !important;
+ font-size: 0.75em !important;
}
.litespeed-text-md {
@@ -395,11 +391,11 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
}
.litespeed-primary {
- color: #3366CC !important;
+ color: #3366cc !important;
}
.litespeed-info {
- color: #3FBFBF !important;
+ color: #3fbfbf !important;
}
.litespeed-success {
@@ -407,7 +403,7 @@ input[type="checkbox"].litespeed-tiny-toggle:checked:after {
}
.litespeed-warning {
- color: #FF8C00 !important;
+ color: #ff8c00 !important;
}
.litespeed-danger {
@@ -437,7 +433,7 @@ button.litespeed-form-action:hover {
}
.litespeed-bg-primary {
- background-color: #3366CC !important;
+ background-color: #3366cc !important;
}
.litespeed-bg-info {
@@ -449,7 +445,7 @@ button.litespeed-form-action:hover {
}
.litespeed-bg-warning {
- background-color: #FF8C00 !important;
+ background-color: #ff8c00 !important;
}
.litespeed-bg-danger {
@@ -494,11 +490,11 @@ button.litespeed-form-action:hover {
.litespeed-body {
background: #fff;
border: 1px solid #e5e5e5;
- box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
padding: 1px 20px 20px 20px;
}
-.litespeed-header+.litespeed-body {
+.litespeed-header + .litespeed-body {
border-top: none;
}
@@ -529,11 +525,11 @@ button.litespeed-form-action:hover {
/*max-width: 840px;*/
}
-.litespeed-desc+.litespeed-desc {
- margin-top: -5px
+.litespeed-desc + .litespeed-desc {
+ margin-top: -5px;
}
-td>.litespeed-desc:first-child {
+td > .litespeed-desc:first-child {
margin-top: 0px;
line-height: 2.24;
}
@@ -609,7 +605,6 @@ h3 .litespeed-learn-more {
padding-right: 50px;
padding-left: 3px;
padding-bottom: 3px;
-
}
.litespeed-title .button {
@@ -661,7 +656,6 @@ h3 .litespeed-learn-more {
color: #72777c;
}
-
/* =======================================
LAYOUT - table
======================================= */
@@ -670,7 +664,7 @@ h3 .litespeed-learn-more {
font-size: 14px;
}
-.litespeed-body tbody>tr>th {
+.litespeed-body tbody > tr > th {
padding-left: 20px;
}
@@ -688,20 +682,19 @@ h3 .litespeed-learn-more {
vertical-align: middle;
}
-.litespeed-body .widefat td input+p {
- margin-top: .8em;
+.litespeed-body .widefat td input + p {
+ margin-top: 0.8em;
}
-.litespeed-body .striped>tbody>:nth-child(even) .notice {
+.litespeed-body .striped > tbody > :nth-child(even) .notice {
background-color: #f9f9f9;
- box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .05);
+ box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.05);
border-top: 1px solid #e5e5e5;
border-bottom: 1px solid #e5e5e5;
border-right: 1px solid #e5e5e5;
-
}
-.litespeed-body .striped>tbody>:nth-child(even) .notice:first-child {
+.litespeed-body .striped > tbody > :nth-child(even) .notice:first-child {
margin-top: 0;
}
@@ -801,7 +794,7 @@ h3 .litespeed-learn-more {
min-height: 75px;
box-sizing: border-box;
background: #f9fafc;
- transition: .25s;
+ transition: 0.25s;
}
.litespeed-panel:hover {
@@ -814,7 +807,7 @@ h3 .litespeed-learn-more {
height: 100%;
}
-[class*="litespeed-panel-icon-"] {
+[class*='litespeed-panel-icon-'] {
background-size: contain;
width: 60px;
height: 60px;
@@ -824,91 +817,91 @@ h3 .litespeed-learn-more {
}
.litespeed-panel-icon-all {
- background-image: url("../img/icons/all.svg");
+ background-image: url('../img/icons/all.svg');
}
.litespeed-panel-icon-revision {
- background-image: url("../img/icons/revision.svg");
+ background-image: url('../img/icons/revision.svg');
}
.litespeed-panel-icon-auto_draft {
- background-image: url("../img/icons/auto_draft.svg");
+ background-image: url('../img/icons/auto_draft.svg');
}
.litespeed-panel-icon-trash_post {
- background-image: url("../img/icons/trash_post.svg");
+ background-image: url('../img/icons/trash_post.svg');
}
.litespeed-panel-icon-spam_comment {
- background-image: url("../img/icons/spam_comment.svg");
+ background-image: url('../img/icons/spam_comment.svg');
}
.litespeed-panel-icon-trash_comment {
- background-image: url("../img/icons/trash_comment.svg");
+ background-image: url('../img/icons/trash_comment.svg');
}
.litespeed-panel-icon-trackback-pingback {
- background-image: url("../img/icons/trackback-pingback.svg");
+ background-image: url('../img/icons/trackback-pingback.svg');
}
.litespeed-panel-icon-expired_transient {
- background-image: url("../img/icons/expired_transient.svg");
+ background-image: url('../img/icons/expired_transient.svg');
}
.litespeed-panel-icon-all_transients {
- background-image: url("../img/icons/all_transients.svg");
+ background-image: url('../img/icons/all_transients.svg');
}
.litespeed-panel-icon-optimize_tables {
- background-image: url("../img/icons/optimize_tables.svg");
+ background-image: url('../img/icons/optimize_tables.svg');
}
.litespeed-panel-icon-purge-front {
- background-image: url("../img/icons/purge-front.svg");
+ background-image: url('../img/icons/purge-front.svg');
}
.litespeed-panel-icon-purge-pages {
- background-image: url("../img/icons/purge-pages.svg");
+ background-image: url('../img/icons/purge-pages.svg');
}
.litespeed-panel-icon-purge-cssjs {
- background-image: url("../img/icons/purge-cssjs.svg");
+ background-image: url('../img/icons/purge-cssjs.svg');
}
.litespeed-panel-icon-purge-object {
- background-image: url("../img/icons/purge-object.svg");
+ background-image: url('../img/icons/purge-object.svg');
}
.litespeed-panel-icon-purge-opcache {
- background-image: url("../img/icons/purge-opcache.svg");
+ background-image: url('../img/icons/purge-opcache.svg');
}
.litespeed-panel-icon-purge-all {
- background-image: url("../img/icons/purge-all.svg");
+ background-image: url('../img/icons/purge-all.svg');
}
.litespeed-panel-icon-empty-cache {
- background-image: url("../img/icons/empty-cache.svg");
+ background-image: url('../img/icons/empty-cache.svg');
}
.litespeed-panel-icon-purge-403 {
- background-image: url("../img/icons/purge-403.svg");
+ background-image: url('../img/icons/purge-403.svg');
}
.litespeed-panel-icon-purge-404 {
- background-image: url("../img/icons/purge-404.svg");
+ background-image: url('../img/icons/purge-404.svg');
}
.litespeed-panel-icon-purge-500 {
- background-image: url("../img/icons/purge-500.svg");
+ background-image: url('../img/icons/purge-500.svg');
}
.litespeed-panel-top-right-icon-cross {
- background-image: url("../img/icons/cross_icon.svg");
+ background-image: url('../img/icons/cross_icon.svg');
}
.litespeed-panel-top-right-icon-tick {
- background-image: url("../img/icons/success_icon.svg");
+ background-image: url('../img/icons/success_icon.svg');
}
.litespeed-panel-content {
@@ -1036,7 +1029,11 @@ h3 .litespeed-learn-more {
border-color: #538ac6 #2264ad #2264ad;
color: #fff;
box-shadow: 0 1px 0 #2264ad;
- text-shadow: 0 -1px 1px #2264ad, 1px 0 1px #2264ad, 0 1px 1px #2264ad, -1px 0 1px #2264ad;
+ text-shadow:
+ 0 -1px 1px #2264ad,
+ 1px 0 1px #2264ad,
+ 0 1px 1px #2264ad,
+ -1px 0 1px #2264ad;
}
.litespeed-wrap .button-primary:focus,
@@ -1054,7 +1051,9 @@ h3 .litespeed-learn-more {
background: #5891ce;
border-color: #2264ad;
color: #fff;
- box-shadow: 0 1px 0 #0073aa, 0 0 2px 1px #33b3db;
+ box-shadow:
+ 0 1px 0 #0073aa,
+ 0 0 2px 1px #33b3db;
}
.litespeed .litespeed-btn-primary,
@@ -1084,7 +1083,7 @@ h3 .litespeed-learn-more {
margin-left: 5px;
}
-.litespeed-wrap .button+.button {
+.litespeed-wrap .button + .button {
margin-left: 10px;
}
@@ -1143,8 +1142,8 @@ h3 .litespeed-learn-more {
.litespeed-wrap .litespeed-btn-large {
font-size: 1.5em;
- padding: .75em 1.5em;
- margin: 0 .25em;
+ padding: 0.75em 1.5em;
+ margin: 0 0.25em;
height: auto;
}
@@ -1153,7 +1152,6 @@ h3 .litespeed-learn-more {
width: auto;
}
-
/* =======================================
SWITCH
======================================= */
@@ -1166,17 +1164,23 @@ h3 .litespeed-learn-more {
position: relative;
}
-.litespeed-switch input:checked:active+label {
- box-shadow: 0 2px 0 rgba(27, 146, 146, 0.7), inset 0 2px 5px -3px rgba(0, 0, 0, .5);
+.litespeed-switch input:checked:active + label {
+ box-shadow:
+ 0 2px 0 rgba(27, 146, 146, 0.7),
+ inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
}
-.litespeed-switch input:checked+label {
+.litespeed-switch input:checked + label {
background-color: #36b0b0;
color: #fff;
border: 1px solid #36b0b0;
box-shadow: 0 2px 0 #1b9292;
z-index: 2;
- text-shadow: 0 -1px 1px #1b9292, 1px 0 1px #1b9292, 0 1px 1px #1b9292, -1px 0 1px #1b9292;
+ text-shadow:
+ 0 -1px 1px #1b9292,
+ 1px 0 1px #1b9292,
+ 0 1px 1px #1b9292,
+ -1px 0 1px #1b9292;
}
.litespeed-switch label {
@@ -1208,37 +1212,35 @@ h3 .litespeed-learn-more {
border-bottom-left-radius: 3px;
}
-.litespeed-switch input:hover+label {
+.litespeed-switch input:hover + label {
border-color: #1a9292;
box-shadow: 0 2px 0 #1a9292;
z-index: 2;
color: #117171;
-
}
-.litespeed-switch input:focus+label {
+.litespeed-switch input:focus + label {
color: #117171;
box-shadow: 0 0px 0px 2px rgba(28, 138, 128, 0.85);
border-color: transparent;
z-index: 2;
-
}
-.litespeed-switch input:focus+label+input+input:hover+label,
-.litespeed-switch input:focus+label+input:hover+label {
+.litespeed-switch input:focus + label + input + input:hover + label,
+.litespeed-switch input:focus + label + input:hover + label {
z-index: 1;
}
-.litespeed-switch input:active+label {
- box-shadow: 0 2px 0 #1b9292, inset 0 2px 5px -3px rgba(0, 0, 0, .5);
+.litespeed-switch input:active + label {
+ box-shadow:
+ 0 2px 0 #1b9292,
+ inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
}
-.litespeed-switch input:checked:hover+label,
-.litespeed-switch input:checked:focus+label {
+.litespeed-switch input:checked:hover + label,
+.litespeed-switch input:checked:focus + label {
background-color: #36b0b0;
color: #fff;
-
-
}
.litespeed-switch input {
@@ -1271,7 +1273,7 @@ h3 .litespeed-learn-more {
align-items: center;
}
-.litespeed-toggle-wrapper+.litespeed-toggle-wrapper {
+.litespeed-toggle-wrapper + .litespeed-toggle-wrapper {
margin-top: 0.75rem;
}
@@ -1393,8 +1395,8 @@ h3 .litespeed-learn-more {
.litespeed-toggle-btn.litespeed-toggle-active {
background-image: none;
outline: 0;
- -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
- box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
+ -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
+ box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
}
.litespeed-toggle-btn-default:active,
@@ -1405,9 +1407,9 @@ h3 .litespeed-learn-more {
/* =======================================
LABEL/TAG
======================================= */
-[class*="litespeed-label-"] {
+[class*='litespeed-label-'] {
display: inline;
- padding: .2em .6em .3em;
+ padding: 0.2em 0.6em 0.3em;
font-size: 75%;
font-weight: bold;
line-height: 1;
@@ -1415,17 +1417,17 @@ h3 .litespeed-learn-more {
text-align: center;
white-space: nowrap;
vertical-align: baseline;
- border-radius: .25em;
+ border-radius: 0.25em;
}
-[class*="litespeed-label-"]:hover,
-[class*="litespeed-label-"]:focus {
+[class*='litespeed-label-']:hover,
+[class*='litespeed-label-']:focus {
color: #fff;
text-decoration: none;
cursor: pointer;
}
-[class*="litespeed-label-"]:empty {
+[class*='litespeed-label-']:empty {
display: none;
}
@@ -1514,7 +1516,7 @@ h3 .litespeed-learn-more {
.litespeed-shell-header-bg {
opacity: 0.4;
- background-color: #CCCCCC;
+ background-color: #cccccc;
position: absolute;
top: 0;
bottom: 0;
@@ -1532,7 +1534,7 @@ h3 .litespeed-learn-more {
left: 0;
z-index: 10;
height: 2px;
- background-color: #F48024;
+ background-color: #f48024;
}
.litespeed-shell-header-icon-container {
@@ -1555,8 +1557,11 @@ ul.litespeed-shell-body {
padding: 5px;
list-style: none;
background: #141414;
- color: #45D40C;
- font: 0.8em 'Andale Mono', Consolas, 'Courier New';
+ color: #45d40c;
+ font:
+ 0.8em 'Andale Mono',
+ Consolas,
+ 'Courier New';
line-height: 1.6em;
-webkit-border-bottom-right-radius: 3px;
@@ -1565,7 +1570,6 @@ ul.litespeed-shell-body {
-moz-border-radius-bottomleft: 3px;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
-
}
.litespeed-shell-body li:before {
@@ -1588,7 +1592,6 @@ ul.litespeed-shell-body {
margin: 5px -15px;
}
-
/* =======================================
CALLOUT / NOTICE
======================================= */
@@ -1657,7 +1660,7 @@ ul.litespeed-shell-body {
background: none;
}
-.litespeed-tick-list .litespeed-tick input[type="checkbox"] {
+.litespeed-tick-list .litespeed-tick input[type='checkbox'] {
margin-left: 0;
}
@@ -1665,8 +1668,7 @@ ul.litespeed-shell-body {
color: inherit;
}
-
-.litespeed-tick input[type="checkbox"] {
+.litespeed-tick input[type='checkbox'] {
height: 18px;
width: 18px;
vertical-align: middle;
@@ -1680,20 +1682,19 @@ ul.litespeed-shell-body {
cursor: pointer;
}
-.litespeed-tick input[type="checkbox"]:not(:disabled):hover {
+.litespeed-tick input[type='checkbox']:not(:disabled):hover {
border-color: #538ac6;
-
}
-.litespeed-tick input[type="checkbox"]:active:not(:disabled) {
+.litespeed-tick input[type='checkbox']:active:not(:disabled) {
border-color: #538ac6;
}
-.litespeed-tick input[type="checkbox"]:focus {
+.litespeed-tick input[type='checkbox']:focus {
outline: none;
}
-.litespeed-tick input[type="checkbox"]:checked {
+.litespeed-tick input[type='checkbox']:checked {
border-color: #538ac6;
background-color: #538ac6;
-moz-box-shadow: none;
@@ -1701,7 +1702,7 @@ ul.litespeed-shell-body {
box-shadow: none;
}
-.litespeed-tick input[type="checkbox"]:checked:before {
+.litespeed-tick input[type='checkbox']:checked:before {
content: '';
display: block;
width: 5px;
@@ -1736,7 +1737,7 @@ ul.litespeed-shell-body {
padding-left: 1.5rem;
}
-.litespeed-radio-row input[type=radio] {
+.litespeed-radio-row input[type='radio'] {
margin-top: 0;
margin-bottom: 0;
position: absolute;
@@ -1815,11 +1816,11 @@ ul.litespeed-shell-body {
min-width: 110px;
}
-input.litespeed-input[type="file"] {
+input.litespeed-input[type='file'] {
padding: 9px;
min-width: 500px;
border: 1px solid #ddd;
- box-shadow: inset 0 1px 2px rgba(0, 0, 0, .07);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
background-color: #fff;
color: #32373c;
outline: 0;
@@ -1851,7 +1852,7 @@ input.litespeed-input-warning {
margin: 0;
}
-.litespeed-textarea-recommended>div:first-child {
+.litespeed-textarea-recommended > div:first-child {
margin-top: 1.7em;
font-size: 12px;
margin-right: 25px;
@@ -1863,7 +1864,7 @@ input.litespeed-input-warning {
text-align: center;
}
-.litespeed-collection-button[data-action="add"] {
+.litespeed-collection-button[data-action='add'] {
margin-top: -5px;
margin-left: -5px;
}
@@ -1879,8 +1880,7 @@ input.litespeed-input-warning {
}
@media screen and (max-width: 680px) {
-
- .litespeed-body tbody>tr>th {
+ .litespeed-body tbody > tr > th {
display: block;
padding: 18px 0 5px 12px;
}
@@ -1901,7 +1901,7 @@ input.litespeed-input-warning {
flex-direction: column;
}
- .litespeed-textarea-recommended>div:first-child {
+ .litespeed-textarea-recommended > div:first-child {
margin-bottom: 1.7em;
margin-top: 0;
}
@@ -1981,7 +1981,7 @@ input.litespeed-input-warning {
}
.litespeed-banner-promo-slacklogo {
- background-image: url("../img/slack-logo.png");
+ background-image: url('../img/slack-logo.png');
background-size: contain;
width: 75px;
height: 75px;
@@ -2009,7 +2009,7 @@ input.litespeed-input-warning {
.litespeed-banner-promo-slack-line2 {
font-size: 15px;
margin: 0px;
- line-height: .75em;
+ line-height: 0.75em;
}
.litespeed-banner-promo-slack-link {
@@ -2080,7 +2080,15 @@ a.litespeed-btn-xs.litespeed-banner-promo-slack-btn {
}
.litespeed-tweet-text {
- font: 14px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
+ font:
+ 14px system-ui,
+ -apple-system,
+ BlinkMacSystemFont,
+ 'Segoe UI',
+ Roboto,
+ Ubuntu,
+ 'Helvetica Neue',
+ sans-serif;
line-height: 1.3125;
}
@@ -2089,9 +2097,8 @@ a.litespeed-btn-xs.litespeed-banner-promo-slack-btn {
margin-top: 1em;
}
-
.litespeed-tweet-cta a {
- background-color: #1DA1F2;
+ background-color: #1da1f2;
line-height: 1.3125;
color: #fff;
font-weight: bold;
@@ -2103,7 +2110,7 @@ a.litespeed-btn-xs.litespeed-banner-promo-slack-btn {
}
.litespeed-tweet-cta a:hover {
- background-color: #1E98E1;
+ background-color: #1e98e1;
}
.litespeed-tweet-cta a svg {
@@ -2127,7 +2134,7 @@ a.litespeed-btn-xs.litespeed-banner-promo-slack-btn {
vertical-align: middle;
}
-.litespeed-tweet-img+p {
+.litespeed-tweet-img + p {
margin-top: 0;
}
@@ -2139,7 +2146,7 @@ a.litespeed-btn-xs.litespeed-banner-promo-slack-btn {
display: inline-table;
}
-[class*="litespeed-icon-media-"] {
+[class*='litespeed-icon-media-'] {
background-size: contain;
width: 25px;
height: 25px;
@@ -2149,24 +2156,24 @@ a.litespeed-btn-xs.litespeed-banner-promo-slack-btn {
display: inline-block;
}
-[class*="litespeed-icon-media-"]:hover {
+[class*='litespeed-icon-media-']:hover {
opacity: 0.7;
}
.litespeed-icon-media-webp {
- background-image: url("../img/icons/img_webp.svg");
+ background-image: url('../img/icons/img_webp.svg');
}
.litespeed-icon-media-webp-disabled {
- background-image: url("../img/icons/img_webp_disabled.svg");
+ background-image: url('../img/icons/img_webp_disabled.svg');
}
.litespeed-icon-media-optm {
- background-image: url("../img/icons/img_optm.svg");
+ background-image: url('../img/icons/img_optm.svg');
}
.litespeed-icon-media-optm-disabled {
- background-image: url("../img/icons/img_optm_disabled.svg");
+ background-image: url('../img/icons/img_optm_disabled.svg');
}
p.litespeed-media-p {
@@ -2207,7 +2214,6 @@ p.litespeed-txt-disabled {
margin: 5px 5px 5px 0;
}
-
circle.litespeed-pie_bg {
stroke: #efefef;
stroke-width: 2;
@@ -2227,7 +2233,6 @@ circle.litespeed-pie_circle {
fill: none;
}
-
.litespeed-pie.litespeed-pie-tiny {
margin: 0 2px 0 0;
}
@@ -2235,7 +2240,6 @@ circle.litespeed-pie_circle {
.litespeed-pie.litespeed-pie-tiny text {
font-weight: bold;
fill: #828282;
-
}
.litespeed-pie.litespeed-pie-tiny circle {
@@ -2332,7 +2336,7 @@ g.litespeed-pie_info .litespeed-pie-done {
margin-left: 10px;
}
-#cookie_crawler>p:first-child {
+#cookie_crawler > p:first-child {
margin-top: 5px;
}
@@ -2354,7 +2358,7 @@ g.litespeed-pie_info .litespeed-pie-done {
color: #fff;
text-align: center;
background-color: #007bff;
- transition: width .6s ease;
+ transition: width 0.6s ease;
}
.litespeed-progress-bar-yellow {
@@ -2367,7 +2371,7 @@ g.litespeed-pie_info .litespeed-pie-done {
display: flex;
height: 12px;
overflow: hidden;
- font-size: .75rem;
+ font-size: 0.75rem;
background-color: #e9ecef;
border: 1px solid #dddddd;
border-radius: 8px;
@@ -2423,10 +2427,9 @@ g.litespeed-pie_info .litespeed-pie-done {
}
.litespeed-guide li.litespeed-guide-done {
- opacity: .9;
+ opacity: 0.9;
}
-
/* =======================================
VIEW - image optimization
======================================= */
@@ -2435,7 +2438,6 @@ g.litespeed-pie_info .litespeed-pie-done {
padding: 0;
}
-
.litespeed-cache_page_litespeed-img_optm .nav-tab-wrapper {
border-bottom: none;
position: relative;
@@ -2452,7 +2454,7 @@ g.litespeed-pie_info .litespeed-pie-done {
.litespeed-cache_page_litespeed-img_optm [data-litespeed-layout]:not([data-litespeed-layout='summary']) {
background: #fff;
border: 1px solid #e5e5e5;
- box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
padding: 1px 20px 20px 20px;
}
@@ -2460,23 +2462,23 @@ g.litespeed-pie_info .litespeed-pie-done {
background: #f9fafc;
}
-.litespeed-column-with-boxes>div:first-child {
+.litespeed-column-with-boxes > div:first-child {
padding-right: 25px;
}
-.litespeed-column-with-boxes>div:last-child {
+.litespeed-column-with-boxes > div:last-child {
background: #f1f1f1;
padding-top: 0;
padding-right: 0;
padding-left: 0;
}
-.litespeed-column-with-boxes>div:last-child .litespeed-postbox:last-child {
+.litespeed-column-with-boxes > div:last-child .litespeed-postbox:last-child {
margin-bottom: 0;
}
.litespeed-image-optim-summary {
- box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
position: relative;
padding: 1px 20px 20px 20px;
background: #fff;
@@ -2508,12 +2510,12 @@ g.litespeed-pie_info .litespeed-pie-done {
margin-top: 0;
}
-.litespeed-image-optim-summary>h3:first-child {
+.litespeed-image-optim-summary > h3:first-child {
margin-top: 1.6em;
font-size: 1.2em;
}
-.litespeed-image-optim-summary>h3:first-child .litespeed-quic-icon {
+.litespeed-image-optim-summary > h3:first-child .litespeed-quic-icon {
width: 1.2em;
height: 1.4em;
background-size: contain;
@@ -2542,7 +2544,7 @@ g.litespeed-pie_info .litespeed-pie-done {
}
@media screen and (max-width: 814px) {
- .litespeed-column-with-boxes>div:first-child {
+ .litespeed-column-with-boxes > div:first-child {
padding-right: 0;
margin-bottom: 1rem;
}
@@ -2561,7 +2563,7 @@ g.litespeed-pie_info .litespeed-pie-done {
margin-top: 0;
}
-.imgoptm.column-imgoptm p+.row-actions {
+.imgoptm.column-imgoptm p + .row-actions {
margin-top: 0.5em;
}
@@ -2594,7 +2596,7 @@ g.litespeed-pie_info .litespeed-pie-done {
margin-bottom: 1rem;
}
-.litespeed-dashboard-group>.litespeed-flex-container {
+.litespeed-dashboard-group > .litespeed-flex-container {
margin: 0 -10px;
min-width: 100%;
width: auto;
@@ -2602,7 +2604,6 @@ g.litespeed-pie_info .litespeed-pie-done {
.litespeed-dashboard .litespeed-postbox {
margin: 10px;
-
}
.litespeed-dashboard-title a {
@@ -2646,7 +2647,7 @@ g.litespeed-pie_info .litespeed-pie-done {
color: #777;
}
-.litespeed-dashboard-stats h3+p {
+.litespeed-dashboard-stats h3 + p {
margin-top: 0;
margin-bottom: 0;
}
@@ -2692,7 +2693,7 @@ g.litespeed-pie_info .litespeed-pie-done {
height: 60px;
}
-.litespeed-dashboard-stats-wrapper .litespeed-flex-container+p:not(:last-child) {
+.litespeed-dashboard-stats-wrapper .litespeed-flex-container + p:not(:last-child) {
margin-bottom: 0.55em;
}
@@ -2704,12 +2705,11 @@ g.litespeed-pie_info .litespeed-pie-done {
color: #444;
}
-.postbox .inside>p.litespeed-dashboard-stats-payg {
+.postbox .inside > p.litespeed-dashboard-stats-payg {
margin-top: 1.35em;
}
-.postbox .inside>p.litespeed-dashboard-stats-payg:last-child {
-
+.postbox .inside > p.litespeed-dashboard-stats-payg:last-child {
margin-bottom: -5px !important;
}
@@ -2800,16 +2800,16 @@ g.litespeed-pie_info .litespeed-pie-done {
.litespeed-label-dashboard {
font-size: 0.92em;
- padding: .3em .6em .35em .6em;
+ padding: 0.3em 0.6em 0.35em 0.6em;
font-weight: normal;
display: inline-block;
- margin-left: .2em;
+ margin-left: 0.2em;
min-width: 2em;
}
.litespeed-label-dashboard:first-child {
margin-left: 0;
- margin-right: .35em;
+ margin-right: 0.35em;
}
.litespeed-postbox .inside {
@@ -2831,7 +2831,8 @@ g.litespeed-pie_info .litespeed-pie-done {
margin-top: 0;
}
-.litespeed-postbox-footer a, a.litespeed-redetect {
+.litespeed-postbox-footer a,
+a.litespeed-redetect {
text-decoration: none;
}
@@ -2840,7 +2841,6 @@ g.litespeed-pie_info .litespeed-pie-done {
font-size: 12px;
}
-
.litespeed-postbox-imgopt .litespeed-pie {
width: 55px;
height: 55px;
@@ -2851,15 +2851,15 @@ g.litespeed-pie_info .litespeed-pie-done {
margin-bottom: 10px;
}
-.litespeed-postbox-imgopt .litespeed-flex-container .litespeed-icon-vertical-middle+div h3 {
+.litespeed-postbox-imgopt .litespeed-flex-container .litespeed-icon-vertical-middle + div h3 {
margin-top: 0;
}
-.litespeed-postbox-imgopt .litespeed-flex-container .litespeed-icon-vertical-middle+div p {
+.litespeed-postbox-imgopt .litespeed-flex-container .litespeed-icon-vertical-middle + div p {
line-height: 1.2;
}
-.litespeed-postbox-imgopt .litespeed-postbox-double-col:last-child>*:first-child {
+.litespeed-postbox-imgopt .litespeed-postbox-double-col:last-child > *:first-child {
margin-top: 7px;
}
@@ -2903,7 +2903,7 @@ g.litespeed-pie_info .litespeed-pie-done {
margin-bottom: 1em;
}
-.litespeed-links-group>span:not(:last-child):after {
+.litespeed-links-group > span:not(:last-child):after {
content: '|';
margin: 0 10px;
color: #ddd;
@@ -2964,7 +2964,6 @@ g.litespeed-pie_info .litespeed-pie-done {
}
@media screen and (max-width: 1023px) {
-
.litespeed-dashboard-stats-wrapper {
flex-wrap: wrap;
}
@@ -3018,12 +3017,10 @@ g.litespeed-pie_info .litespeed-pie-done {
/********************************* todo *******************************/
-
/* image optimize page */
-
.litespeed-column-java {
- background: #5CADAD !important;
+ background: #5cadad !important;
}
.litespeed-text-shipgrey {
@@ -3039,19 +3036,19 @@ g.litespeed-pie_info .litespeed-pie-done {
}
.litespeed-text-whisper {
- color: #E6E6E6 !important;
+ color: #e6e6e6 !important;
}
.litespeed-text-malibu {
- color: #5CBDDE !important;
+ color: #5cbdde !important;
}
.litespeed-text-morningglory {
- color: #99CCCC !important;
+ color: #99cccc !important;
}
.litespeed-text-fern {
- color: #66CC66 !important;
+ color: #66cc66 !important;
}
.litespeed-text-persiangreen {
@@ -3081,7 +3078,7 @@ g.litespeed-pie_info .litespeed-pie-done {
.litespeed-hr {
padding-bottom: 1.5em;
- border-bottom: .5px solid #97CACA;
+ border-bottom: 0.5px solid #97caca;
}
.litespeed-hr-with-space {
@@ -3096,7 +3093,6 @@ g.litespeed-pie_info .litespeed-pie-done {
margin: 0px 10px 0px 10px;
}
-
.litespeed-column-java .litespeed-danger {
color: #c1c53a !important;
}
@@ -3119,7 +3115,7 @@ g.litespeed-pie_info .litespeed-pie-done {
}
.litespeed-refresh:after {
- content: "⟳";
+ content: '⟳';
width: 20px;
height: 20px;
color: #40ad3a;
@@ -3140,7 +3136,7 @@ g.litespeed-pie_info .litespeed-pie-done {
}
.litespeed-silence {
- color: #B1B1B1;
+ color: #b1b1b1;
}
.litespeed-column-java .litespeed-congratulate {
@@ -3166,11 +3162,11 @@ g.litespeed-pie_info .litespeed-pie-done {
}
.litespeed-column-java svg.litespeed-pie circle.litespeed-pie_circle {
- stroke: #97CACA;
+ stroke: #97caca;
}
.litespeed-column-java svg .litespeed-pie_info text {
- fill: #F5FFEB;
+ fill: #f5ffeb;
}
.litespeed-column-java svg g.litespeed-pie_info .litespeed-pie-done {
@@ -3186,12 +3182,12 @@ g.litespeed-pie_info .litespeed-pie-done {
}
.litespeed-progress-bar-blue {
- background-color: #33ADFF;
+ background-color: #33adff;
}
.litespeed-status-current {
font-size: 3.5em;
- margin: 1.25em 0em .75em 0em;
+ margin: 1.25em 0em 0.75em 0em;
}
/* .litespeed-title, .litespeed-title-short {
@@ -3201,71 +3197,70 @@ g.litespeed-pie_info .litespeed-pie-done {
} */
.litespeed-column-java .litespeed-desc {
- color: #CAE4E4;
+ color: #cae4e4;
}
.litespeed-column-java .litespeed-warning {
- color: #FFD597 !important;
+ color: #ffd597 !important;
}
.litespeed-column-java .litespeed-btn-success {
- color: #DDF1E4;
- border: 1px solid #33AD5C;
- background: #33AD5C;
+ color: #ddf1e4;
+ border: 1px solid #33ad5c;
+ background: #33ad5c;
}
.litespeed-column-java .litespeed-btn-success:hover {
- color: #FFFFFF;
- border: 1px solid #7DCA97;
+ color: #ffffff;
+ border: 1px solid #7dca97;
background: #009933;
}
.litespeed-column-java .litespeed-btn-warning {
- color: #FFF1DD;
- border: 1px solid #FF9933;
- background-color: #FF9933;
+ color: #fff1dd;
+ border: 1px solid #ff9933;
+ background-color: #ff9933;
}
.litespeed-column-java .litespeed-btn-warning:hover {
- color: #FFFFFF;
- border-color: #FFCA7D;
- background: #FF9900;
+ color: #ffffff;
+ border-color: #ffca7d;
+ background: #ff9900;
}
.litespeed-column-java .litespeed-btn-danger {
- color: #FFEADD !important;
- border: 1px solid #FF6600 !important;
- background: #FF5C5C;
+ color: #ffeadd !important;
+ border: 1px solid #ff6600 !important;
+ background: #ff5c5c;
}
.litespeed-column-java .litespeed-btn-danger:hover {
- color: #FFFFFF;
- border: 1px solid #FF9797 !important;
- background: #FF0000;
+ color: #ffffff;
+ border: 1px solid #ff9797 !important;
+ background: #ff0000;
}
.litespeed-column-java .litepseed-dash-icon-success,
.litepseed-dash-icon-success {
- color: #5CDEDE;
+ color: #5cdede;
font-size: 2em;
- margin-top: -.25em;
+ margin-top: -0.25em;
}
.litespeed-column-java .litepseed-dash-icon-success:hover,
.litepseed-dash-icon-success:hover {
- color: #7DE5E5;
+ color: #7de5e5;
}
.litespeed-dashicons-large {
font-size: 2em;
}
-
.litespeed-column-java p {
- color: #FFFFFF;
+ color: #ffffff;
}
-.litespeed-body tbody>tr>th.litespeed-padding-left {
+.litespeed-body tbody > tr > th.litespeed-padding-left {
padding-left: 3em;
}
@@ -3291,9 +3286,9 @@ g.litespeed-pie_info .litespeed-pie-done {
a.litespeed-media-href svg:hover {
border-radius: 50%;
- background: #F1FCFF;
- fill: #5CCAD7;
- box-shadow: 0 0 5px 1px #7DD5DF;
+ background: #f1fcff;
+ fill: #5ccad7;
+ box-shadow: 0 0 5px 1px #7dd5df;
transition: all 0.2s ease-out;
transform: scale(1.05);
}
@@ -3307,21 +3302,21 @@ a.litespeed-media-href svg:hover {
}
.litespeed-media-p a .dashicons-trash:hover {
- transition: all .2s ease-out;
- color: #FFA500 !important;
- background: #FFF5E6;
- box-shadow: 0 0 10px 1px #FF8C00;
+ transition: all 0.2s ease-out;
+ color: #ffa500 !important;
+ background: #fff5e6;
+ box-shadow: 0 0 10px 1px #ff8c00;
}
-.litespeed-media-p div>svg circle.litespeed-pie_bg {
+.litespeed-media-p div > svg circle.litespeed-pie_bg {
stroke: #ecf2f9;
}
-.litespeed-media-p div>svg circle.litespeed-pie_circle {
+.litespeed-media-p div > svg circle.litespeed-pie_circle {
stroke: #9fbfdf;
}
-.litespeed-media-p div>svg {
+.litespeed-media-p div > svg {
fill: #538cc6;
background: rgba(236, 242, 249, 0.1);
border-radius: 50%;
@@ -3369,16 +3364,9 @@ a.litespeed-media-href svg:hover {
.litespeed-notice-dismiss:hover,
.litespeed-notice-dismiss:active,
.litespeed-notice-dismiss:focus {
- color: #CC2929;
+ color: #cc2929;
}
-
-
-
-
-
-
-
.litespeed-dot {
display: inline-block;
border-radius: 50%;
@@ -3397,7 +3385,6 @@ a.litespeed-media-href svg:hover {
text-align: center;
}
-
/* =======================================
Comparison Cards - Presets
======================================= */
@@ -3406,7 +3393,7 @@ a.litespeed-media-href svg:hover {
box-sizing: border-box;
}
-.litespeed-comparison-card-rec .litespeed-card-content>div.litespeed-card-body {
+.litespeed-comparison-card-rec .litespeed-card-content > div.litespeed-card-body {
font-size: 14px;
}
@@ -3418,7 +3405,7 @@ a.litespeed-media-href svg:hover {
font-size: 20px;
}
-.litespeed-card-content>div,
+.litespeed-card-content > div,
.litespeed-card-action {
padding: 0.85rem 1.25rem;
}
@@ -3428,7 +3415,7 @@ a.litespeed-media-href svg:hover {
background: #f9fafc;
}
-.litespeed-card-content>div.litespeed-card-body {
+.litespeed-card-content > div.litespeed-card-body {
align-self: stretch;
justify-content: flex-end;
font-size: 15px;
@@ -3436,12 +3423,11 @@ a.litespeed-media-href svg:hover {
padding-top: 1rem;
}
-.litespeed-card-content>div.litespeed-card-footer {
+.litespeed-card-content > div.litespeed-card-footer {
align-self: stretch;
justify-content: flex-end;
padding-bottom: 0;
padding-top: 0.25rem;
-
}
.litespeed-card-action {
@@ -3467,7 +3453,7 @@ a.litespeed-media-href svg:hover {
.litespeed-comparison-card ul li:before {
content: '✓';
margin-left: -1em;
- margin-right: .350em;
+ margin-right: 0.35em;
color: #329c74;
}
@@ -3491,19 +3477,19 @@ a.litespeed-media-href svg:hover {
width: 100%;
}
- .litespeed-card-content>div.litespeed-card-body {
+ .litespeed-card-content > div.litespeed-card-body {
align-self: initial;
width: 50%;
box-sizing: border-box;
}
- .litespeed-card-content>div.litespeed-card-footer {
+ .litespeed-card-content > div.litespeed-card-footer {
width: 50%;
align-self: initial;
box-sizing: border-box;
}
- .litespeed-card-content>div.litespeed-card-footer h4 {
+ .litespeed-card-content > div.litespeed-card-footer h4 {
margin-top: 1rem;
}
}
@@ -3539,7 +3525,7 @@ a.litespeed-media-href svg:hover {
.litespeed-comparison-card-rec {
width: 23%;
padding-top: 1rem;
- padding-bottom: .75rem;
+ padding-bottom: 0.75rem;
margin-top: -1rem;
margin-bottom: 0.25rem;
border-radius: 5px;
@@ -3575,7 +3561,7 @@ a.litespeed-media-href svg:hover {
.litespeed-wrap [aria-label][data-balloon-pos]:after {
opacity: 0;
pointer-events: none;
- transition: all .2s ease .05s;
+ transition: all 0.2s ease 0.05s;
text-indent: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: normal;
@@ -3586,7 +3572,7 @@ a.litespeed-media-href svg:hover {
border-radius: 2px;
color: #fff;
content: attr(aria-label);
- padding: .5em 1em;
+ padding: 0.5em 1em;
position: absolute;
white-space: nowrap;
z-index: 10;
@@ -3600,8 +3586,8 @@ a.litespeed-media-href svg:hover {
border-top-color: var(--balloon-color);
opacity: 0;
pointer-events: none;
- transition: all .2s ease .05s;
- content: "";
+ transition: all 0.2s ease 0.05s;
+ content: '';
position: absolute;
z-index: 10;
}
@@ -3617,7 +3603,18 @@ a.litespeed-media-href svg:hover {
}
.litespeed-wrap [aria-label][data-balloon-pos].font-awesome:after {
- font-family: FontAwesome, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
+ font-family:
+ FontAwesome,
+ -apple-system,
+ BlinkMacSystemFont,
+ 'Segoe UI',
+ Roboto,
+ Oxygen,
+ Ubuntu,
+ Cantarell,
+ 'Open Sans',
+ 'Helvetica Neue',
+ sans-serif;
}
.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-break]:after {
@@ -3634,7 +3631,7 @@ a.litespeed-media-href svg:hover {
transition: none;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up']:after {
bottom: 100%;
left: 50%;
margin-bottom: 10px;
@@ -3642,24 +3639,24 @@ a.litespeed-media-href svg:hover {
transform-origin: top;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up"]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up']:before {
bottom: 100%;
left: 50%;
transform: translate(-50%, var(--balloon-move));
transform-origin: top;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up"]:hover:after,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up"][data-balloon-visible]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up']:hover:after,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up'][data-balloon-visible]:after {
transform: translate(-50%, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up"]:hover:before,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up"][data-balloon-visible]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up']:hover:before,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up'][data-balloon-visible]:before {
transform: translate(-50%, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-left"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-left']:after {
bottom: 100%;
left: 0;
margin-bottom: 10px;
@@ -3667,24 +3664,24 @@ a.litespeed-media-href svg:hover {
transform-origin: top;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-left"]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-left']:before {
bottom: 100%;
left: 5px;
transform: translate(0, var(--balloon-move));
transform-origin: top;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-left"]:hover:after,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-left"][data-balloon-visible]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-left']:hover:after,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-left'][data-balloon-visible]:after {
transform: translate(0, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-left"]:hover:before,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-left"][data-balloon-visible]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-left']:hover:before,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-left'][data-balloon-visible]:before {
transform: translate(0, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-right"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-right']:after {
bottom: 100%;
right: 0;
margin-bottom: 10px;
@@ -3692,31 +3689,31 @@ a.litespeed-media-href svg:hover {
transform-origin: top;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-right"]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-right']:before {
bottom: 100%;
right: 5px;
transform: translate(0, var(--balloon-move));
transform-origin: top;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-right"]:hover:after,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-right"][data-balloon-visible]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-right']:hover:after,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-right'][data-balloon-visible]:after {
transform: translate(0, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-right"]:hover:before,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="up-right"][data-balloon-visible]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-right']:hover:before,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='up-right'][data-balloon-visible]:before {
transform: translate(0, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down']:after {
left: 50%;
margin-top: 10px;
top: 100%;
transform: translate(-50%, calc(var(--balloon-move) * -1));
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down"]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down']:before {
width: 0;
height: 0;
border: 5px solid transparent;
@@ -3726,24 +3723,24 @@ a.litespeed-media-href svg:hover {
transform: translate(-50%, calc(var(--balloon-move) * -1));
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down"]:hover:after,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down"][data-balloon-visible]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down']:hover:after,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down'][data-balloon-visible]:after {
transform: translate(-50%, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down"]:hover:before,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down"][data-balloon-visible]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down']:hover:before,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down'][data-balloon-visible]:before {
transform: translate(-50%, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-left"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-left']:after {
left: 0;
margin-top: 10px;
top: 100%;
transform: translate(0, calc(var(--balloon-move) * -1));
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-left"]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-left']:before {
width: 0;
height: 0;
border: 5px solid transparent;
@@ -3753,24 +3750,24 @@ a.litespeed-media-href svg:hover {
transform: translate(0, calc(var(--balloon-move) * -1));
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-left"]:hover:after,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-left"][data-balloon-visible]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-left']:hover:after,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-left'][data-balloon-visible]:after {
transform: translate(0, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-left"]:hover:before,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-left"][data-balloon-visible]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-left']:hover:before,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-left'][data-balloon-visible]:before {
transform: translate(0, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-right"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-right']:after {
right: 0;
margin-top: 10px;
top: 100%;
transform: translate(0, calc(var(--balloon-move) * -1));
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-right"]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-right']:before {
width: 0;
height: 0;
border: 5px solid transparent;
@@ -3780,24 +3777,24 @@ a.litespeed-media-href svg:hover {
transform: translate(0, calc(var(--balloon-move) * -1));
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-right"]:hover:after,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-right"][data-balloon-visible]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-right']:hover:after,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-right'][data-balloon-visible]:after {
transform: translate(0, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-right"]:hover:before,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="down-right"][data-balloon-visible]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-right']:hover:before,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='down-right'][data-balloon-visible]:before {
transform: translate(0, 0);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="left"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='left']:after {
margin-right: 10px;
right: 100%;
top: 50%;
transform: translate(var(--balloon-move), -50%);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="left"]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='left']:before {
width: 0;
height: 0;
border: 5px solid transparent;
@@ -3807,24 +3804,24 @@ a.litespeed-media-href svg:hover {
transform: translate(var(--balloon-move), -50%);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="left"]:hover:after,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="left"][data-balloon-visible]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='left']:hover:after,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='left'][data-balloon-visible]:after {
transform: translate(0, -50%);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="left"]:hover:before,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="left"][data-balloon-visible]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='left']:hover:before,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='left'][data-balloon-visible]:before {
transform: translate(0, -50%);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="right"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='right']:after {
left: 100%;
margin-left: 10px;
top: 50%;
transform: translate(calc(var(--balloon-move) * -1), -50%);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="right"]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='right']:before {
width: 0;
height: 0;
border: 5px solid transparent;
@@ -3834,44 +3831,44 @@ a.litespeed-media-href svg:hover {
transform: translate(calc(var(--balloon-move) * -1), -50%);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="right"]:hover:after,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="right"][data-balloon-visible]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='right']:hover:after,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='right'][data-balloon-visible]:after {
transform: translate(0, -50%);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="right"]:hover:before,
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos="right"][data-balloon-visible]:before {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='right']:hover:before,
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-pos='right'][data-balloon-visible]:before {
transform: translate(0, -50%);
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length="small"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length='small']:after {
white-space: normal;
width: 80px;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length="medium"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length='medium']:after {
white-space: normal;
width: 150px;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length="large"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length='large']:after {
white-space: normal;
width: 260px;
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length="xlarge"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length='xlarge']:after {
white-space: normal;
width: 380px;
}
@media screen and (max-width: 768px) {
- .litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length="xlarge"]:after {
+ .litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length='xlarge']:after {
white-space: normal;
width: 90vw;
}
}
-.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length="fit"]:after {
+.litespeed-wrap [aria-label][data-balloon-pos][data-balloon-length='fit']:after {
white-space: normal;
width: 100%;
}
diff --git a/assets/js/component.cdn.js b/assets/js/component.cdn.js
index 36f275f8d..d186dc407 100644
--- a/assets/js/component.cdn.js
+++ b/assets/js/component.cdn.js
@@ -3,50 +3,51 @@
* @author Hai Zheng
*/
class CDNMapping extends React.Component {
- constructor( props ) {
- super( props );
+ constructor(props) {
+ super(props);
this.state = {
- list: props.list
+ list: props.list,
};
- this.onChange = this.onChange.bind( this );
- this.delRow = this.delRow.bind( this );
- this.addNew = this.addNew.bind( this );
+ this.onChange = this.onChange.bind(this);
+ this.delRow = this.delRow.bind(this);
+ this.addNew = this.addNew.bind(this);
}
- onChange( e, index ) {
+ onChange(e, index) {
const target = e.currentTarget;
- const value = target.dataset.hasOwnProperty('value') ? Boolean(target.dataset.value*1) : target.value;
+ const value = target.dataset.hasOwnProperty('value') ? Boolean(target.dataset.value * 1) : target.value;
const list = this.state.list;
- list[ index ][ target.dataset.type ] = value;
+ list[index][target.dataset.type] = value;
- this.setState( {
- list: list
- } );
+ this.setState({
+ list: list,
+ });
}
- delRow( index ) {
+ delRow(index) {
const data = this.state.list;
- data.splice( index, 1 );
- this.setState( { list: data } );
+ data.splice(index, 1);
+ this.setState({ list: data });
}
addNew() {
const list = this.state.list;
- list.push( { url: '' } );
- this.setState( { list: list } );
+ list.push({ url: '' });
+ this.setState({ list: list });
}
render() {
return (
$val
";
$val = __('Default value', 'litespeed-cache') . ': ' . $val;
}
- echo $val;
+ echo $val;
}
}
@@ -1215,9 +1225,10 @@ protected function _api_env_var()
$args = func_get_args();
$s = '' . implode('
, ', $args) . '
';
- echo ' '
- . __('API', 'litespeed-cache') . ': '
- . sprintf(__('Server variable(s) %s available to override this setting.', 'litespeed-cache'), $s);
+ echo ' ' .
+ __('API', 'litespeed-cache') .
+ ': ' .
+ sprintf(__('Server variable(s) %s available to override this setting.', 'litespeed-cache'), $s);
Doc::learn_more('https://docs.litespeedtech.com/lscache/lscwp/admin/#limiting-the-crawler');
}
@@ -1284,11 +1295,9 @@ public static function guidance($title, $steps, $current_step)
$current_step = count($steps) + 1;
}
- $percentage = ' (' . floor(($current_step - 1) * 100 / count($steps)) . '%)';
+ $percentage = ' (' . floor((($current_step - 1) * 100) / count($steps)) . '%)';
- $html = '' . $service_tag . '
');
+ $msg =
+ __('Cloud Error', 'litespeed-cache') .
+ ': ' .
+ sprintf(__('Please try after %1$s for service %2$s.', 'litespeed-cache'), Utility::readable_time($expired, 0, true), '' . $service_tag . '
');
Admin_Display::error(array('cloud_trylater' => $msg));
}
@@ -687,11 +684,11 @@ private function _post($service, $data = false, $time_out = false)
}
$param = array(
- 'site_url' => home_url(),
- 'domain_key' => $this->_api_key(),
- 'main_domain' => !empty($this->_summary['main_domain']) ? $this->_summary['main_domain'] : '',
- 'ver' => Core::VER,
- 'data' => $data,
+ 'site_url' => home_url(),
+ 'domain_key' => $this->_api_key(),
+ 'main_domain' => !empty($this->_summary['main_domain']) ? $this->_summary['main_domain'] : '',
+ 'ver' => Core::VER,
+ 'data' => $data,
);
self::save_summary(array('curr_request.' . $service_tag => time()));
@@ -718,7 +715,9 @@ private function _parse_response($response, $service, $service_tag, $server)
Admin_Display::error($msg);
// Tmp disabled this node from reusing in 1 day
- if (empty($this->_summary['disabled_node'])) $this->_summary['disabled_node'] = array();
+ if (empty($this->_summary['disabled_node'])) {
+ $this->_summary['disabled_node'] = array();
+ }
$this->_summary['disabled_node'][$server] = time();
self::save_summary();
@@ -739,7 +738,9 @@ private function _parse_response($response, $service, $service_tag, $server)
Admin_Display::error($msg);
// Tmp disabled this node from reusing in 1 day
- if (empty($this->_summary['disabled_node'])) $this->_summary['disabled_node'] = array();
+ if (empty($this->_summary['disabled_node'])) {
+ $this->_summary['disabled_node'] = array();
+ }
$this->_summary['disabled_node'][$server] = time();
self::save_summary();
@@ -782,7 +783,10 @@ private function _parse_response($response, $service, $service_tag, $server)
if (!empty($json['_503'])) {
self::debug('service 503 unavailable temporarily. ' . $json['_503']);
- $msg = __('We are working hard to improve your online service experience. The service will be unavailable while we work. We apologize for any inconvenience.', 'litespeed-cache');
+ $msg = __(
+ 'We are working hard to improve your online service experience. The service will be unavailable while we work. We apologize for any inconvenience.',
+ 'litespeed-cache'
+ );
$msg .= ' ' . $json['_503'] . " [server] $server [service] $service";
Admin_Display::error($msg);
@@ -794,11 +798,13 @@ private function _parse_response($response, $service, $service_tag, $server)
}
list($json, $return) = $this->extract_msg($json, $service, $server);
- if ($return) return;
+ if ($return) {
+ return;
+ }
self::save_summary(array(
'last_request.' . $service_tag => $this->_summary['curr_request.' . $service_tag],
- 'curr_request.' . $service_tag => 0
+ 'curr_request.' . $service_tag => 0,
));
if ($json) {
@@ -844,7 +850,9 @@ public function extract_msg($json, $service, $server = false, $is_callback = fal
// Upgrade is required
if (!empty($json['_err_req_v'])) {
self::debug('_err_req_v: ' . $json['_err_req_v']);
- $msg = sprintf(__('%1$s plugin version %2$s required for this action.', 'litespeed-cache'), Core::NAME, 'v' . $json['_err_req_v'] . '+') . " [server] $server [service] $service";
+ $msg =
+ sprintf(__('%1$s plugin version %2$s required for this action.', 'litespeed-cache'), Core::NAME, 'v' . $json['_err_req_v'] . '+') .
+ " [server] $server [service] $service";
// Append upgrade link
$msg2 = ' ' . GUI::plugin_upgrade_link(Core::NAME, Core::PLUGIN_NAME, $json['_err_req_v']);
@@ -968,7 +976,9 @@ public function rest_err_domains()
list($post_data) = $this->extract_msg($_POST, 'Quic.cloud', false, true);
if ($this->_is_err_domain($_POST['alias'])) {
- if ($_POST['alias'] == home_url()) $this->_remove_domain_from_err_list($_POST['alias']);
+ if ($_POST['alias'] == home_url()) {
+ $this->_remove_domain_from_err_list($_POST['alias']);
+ }
$res_hash = substr($this->_api_key(), 2, 4);
@@ -996,23 +1006,27 @@ private function _remove_domain_from_err_list($url)
*/
private function _is_err_domain($home_url)
{
- if (empty($this->_summary['err_domains'])) return false;
- if (!array_key_exists($home_url, $this->_summary['err_domains'])) return false;
+ if (empty($this->_summary['err_domains'])) {
+ return false;
+ }
+ if (!array_key_exists($home_url, $this->_summary['err_domains'])) {
+ return false;
+ }
// Auto delete if too long ago
if (time() - $this->_summary['err_domains'][$home_url] > 86400 * 10) {
$this->_remove_domain_from_err_list($home_url);
}
- if (time() - $this->_summary['err_domains'][$home_url] > 86400) return false;
+ if (time() - $this->_summary['err_domains'][$home_url] > 86400) {
+ return false;
+ }
return true;
}
public function req_rest_api($api, $body = array())
{
-
$token = $this->_setup_token;
if (empty($token)) {
-
Admin_Display::error(__('Cannot request REST API, no token saved.', 'litespeed-cache'));
return;
}
@@ -1036,12 +1050,11 @@ public function req_rest_api($api, $body = array())
private function _parse_rest_response($response)
{
if (is_wp_error($response)) {
-
$error_message = $response->get_error_message();
self::debug('failed to request REST API: ' . $error_message);
Admin_Display::error(__('Cloud REST Error', 'litespeed-cache') . ': ' . $error_message);
return $error_message;
- } else if (wp_remote_retrieve_response_code($response) == '401') {
+ } elseif (wp_remote_retrieve_response_code($response) == '401') {
return 'unauthorized access to REST API.';
}
@@ -1191,9 +1204,9 @@ public function set_keygen_token($token)
public function gen_key()
{
$data = array(
- 'site_url' => home_url(),
- 'rest' => function_exists('rest_get_url_prefix') ? rest_get_url_prefix() : apply_filters('rest_url_prefix', 'wp-json'),
- 'server_ip' => $this->conf(self::O_SERVER_IP),
+ 'site_url' => home_url(),
+ 'rest' => function_exists('rest_get_url_prefix') ? rest_get_url_prefix() : apply_filters('rest_url_prefix', 'wp-json'),
+ 'server_ip' => $this->conf(self::O_SERVER_IP),
);
if (!empty($this->_summary['token'])) {
$data['token'] = $this->_summary['token'];
@@ -1348,21 +1361,21 @@ private function _link_to_qc()
}
$data = array(
- 'site_url' => home_url(),
- 'domain_hash' => md5(substr($this->_api_key(), 0, 8)),
- 'ref' => get_admin_url(null, 'admin.php?page=litespeed-general'),
+ 'site_url' => home_url(),
+ 'domain_hash' => md5(substr($this->_api_key(), 0, 8)),
+ 'ref' => get_admin_url(null, 'admin.php?page=litespeed-general'),
);
wp_redirect(self::CLOUD_SERVER_DASH . '/u/wp?data=' . Utility::arr2str($data));
- exit;
+ exit();
}
public function qc_link()
{
$data = array(
- 'site_url' => home_url(),
- 'domain_hash' => md5(substr($this->_api_key(), 0, 8)),
- 'ver' => LSCWP_V,
+ 'site_url' => home_url(),
+ 'domain_hash' => md5(substr($this->_api_key(), 0, 8)),
+ 'ver' => LSCWP_V,
);
return self::CLOUD_SERVER_DASH . '/u/wp?data=' . Utility::arr2str($data); // . (!empty($this->_summary['is_linked']) ? '?wplogin=1' : '');
}
@@ -1384,7 +1397,6 @@ public function set_linked()
*/
public function parse_qc_redir($extra = array())
{
-
$extraRet = array();
$qsDrop = array();
if (!$this->_api_key() && !empty($this->_summary['is_linked'])) {
@@ -1397,14 +1409,16 @@ public function parse_qc_redir($extra = array())
}
if ($_GET['qc_res'] == 'registered') {
- if (!empty($_GET['qc_new'])) Admin_Display::succeed(__('QUIC.cloud account has been created and successfully linked.', 'litespeed-cache'), true);
- else Admin_Display::succeed(__('QUIC.cloud account has been successfully linked.', 'litespeed-cache'), true);
+ if (!empty($_GET['qc_new'])) {
+ Admin_Display::succeed(__('QUIC.cloud account has been created and successfully linked.', 'litespeed-cache'), true);
+ } else {
+ Admin_Display::succeed(__('QUIC.cloud account has been successfully linked.', 'litespeed-cache'), true);
+ }
}
$qsDrop[] = ".replace( '&qc_res=" . sanitize_key($_GET['qc_res']) . ', \'\' )';
if (!empty($_GET['domain_hash'])) {
-
if (md5(substr($this->_api_key(), 2, 8)) !== $_GET['domain_hash']) {
Admin_Display::error(__('Domain Key hash mismatch', 'litespeed-cache'), true);
return $extraRet;
@@ -1426,7 +1440,7 @@ public function parse_qc_redir($extra = array())
$replaceStr = implode('', $qsDrop);
// Drop QS
- echo "";
+ echo "';
return $extraRet;
}
diff --git a/src/conf.cls.php b/src/conf.cls.php
index 3e6653e59..897b6fcce 100644
--- a/src/conf.cls.php
+++ b/src/conf.cls.php
@@ -14,8 +14,7 @@
namespace LiteSpeed;
-defined('WPINC') || exit;
-
+defined('WPINC') || exit();
class Conf extends Base
{
@@ -41,7 +40,7 @@ public function init()
* @since 2.9.7
*/
if ($this->conf(self::O_CDN_QUIC)) {
- !defined('LITESPEED_ALLOWED') && define('LITESPEED_ALLOWED', true);
+ !defined('LITESPEED_ALLOWED') && define('LITESPEED_ALLOWED', true);
}
add_action('litespeed_conf_append', array($this, 'option_append'), 10, 2);
@@ -73,7 +72,8 @@ private function _conf_db_init()
*/
$has_delay_conf_tag = self::get_option('__activation');
if (!$ver || $ver != Core::VER) {
- if ((!is_admin() && !defined('LITESPEED_CLI')) || (!$has_delay_conf_tag || $has_delay_conf_tag == -1)) { // Reuse __activation to control the delay conf update
+ if ((!is_admin() && !defined('LITESPEED_CLI')) || (!$has_delay_conf_tag || $has_delay_conf_tag == -1)) {
+ // Reuse __activation to control the delay conf update
if (!$has_delay_conf_tag || $has_delay_conf_tag == -1) {
self::update_option('__activation', Core::VER);
}
@@ -114,7 +114,8 @@ private function _conf_db_init()
if (!$ver || $ver != Core::VER) {
// Load default values
$this->load_default_vals();
- if (!$ver) { // New install
+ if (!$ver) {
+ // New install
$this->set_conf(self::$_default_options);
}
@@ -180,7 +181,8 @@ public function load_options($blog_id = null, $dry_run = false)
}
// Bypass site special settings
- if ($blog_id !== null) { // This is to load the primary settings ONLY
+ if ($blog_id !== null) {
+ // This is to load the primary settings ONLY
// These options are the ones that can be overwritten by primary
$options = array_diff_key($options, array_flip(self::$SINGLE_SITE_OPTIONS));
@@ -189,7 +191,6 @@ public function load_options($blog_id = null, $dry_run = false)
$this->set_conf($options);
}
-
// Append const options
if (defined('LITESPEED_CONF') && LITESPEED_CONF) {
foreach (self::$_default_options as $k => $v) {
@@ -218,7 +219,8 @@ private function _try_load_site_options()
$this->_is_primary = get_current_blog_id() == BLOG_ID_CURRENT_SITE;
// If network set to use primary setting
- if ($this->network_conf(self::NETWORK_O_USE_PRIMARY) && !$this->_is_primary) { // subsites or network admin
+ if ($this->network_conf(self::NETWORK_O_USE_PRIMARY) && !$this->_is_primary) {
+ // subsites or network admin
// Get the primary site settings
// If it's just upgraded, 2nd blog is being visited before primary blog, can just load default config (won't hurt as this could only happen shortly)
$this->load_options(BLOG_ID_CURRENT_SITE);
@@ -241,7 +243,8 @@ private function _try_load_site_options()
}
} else {
if ($this->network_conf(self::NETWORK_O_USE_PRIMARY)) {
- if ($this->has_primary_conf($k) && $this->primary_conf($k) != self::VAL_ON2) { // This case will use primary_options override always
+ if ($this->has_primary_conf($k) && $this->primary_conf($k) != self::VAL_ON2) {
+ // This case will use primary_options override always
continue;
}
} else {
@@ -279,11 +282,12 @@ private function _if_need_site_options()
* @since 2.0
*/
if (!function_exists('is_plugin_active_for_network')) {
- require_once(ABSPATH . '/wp-admin/includes/plugin.php');
+ require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
// If is not activated on network, it will not have site options
if (!is_plugin_active_for_network(Core::PLUGIN_FILE)) {
- if ((int)$this->conf(self::O_CACHE) == self::VAL_ON2) { // Default to cache on
+ if ((int) $this->conf(self::O_CACHE) == self::VAL_ON2) {
+ // Default to cache on
$this->set_conf(self::_CACHE, true);
}
return false;
@@ -651,7 +655,6 @@ public function network_update($id, $val)
// No need to update cron here, Cron will register in each init
-
if ($this->has_conf($id)) {
$this->set_conf($id, $val);
}
diff --git a/src/control.cls.php b/src/control.cls.php
index 170f9d42c..323475fe0 100644
--- a/src/control.cls.php
+++ b/src/control.cls.php
@@ -9,9 +9,10 @@
*/
namespace LiteSpeed;
-defined( 'WPINC' ) || exit;
+defined('WPINC') || exit();
-class Control extends Root {
+class Control extends Root
+{
const LOG_TAG = '💵';
const BM_CACHEABLE = 1;
@@ -35,27 +36,28 @@ class Control extends Root {
*
* @since 1.6.2
*/
- public function init() {
+ public function init()
+ {
/**
* Add vary filter for Role Excludes
* @since 1.6.2
*/
- add_filter( 'litespeed_vary', array( $this, 'vary_add_role_exclude' ) );
+ add_filter('litespeed_vary', array($this, 'vary_add_role_exclude'));
// 301 redirect hook
- add_filter( 'wp_redirect', array( $this, 'check_redirect' ), 10, 2 );
+ add_filter('wp_redirect', array($this, 'check_redirect'), 10, 2);
// Load response header conf
- $this->_response_header_ttls = $this->conf( Base::O_CACHE_TTL_STATUS );
- foreach ( $this->_response_header_ttls as $k => $v ) {
- $v = explode( ' ', $v );
- if ( empty( $v[ 0 ] ) || empty( $v[ 1 ] ) ) {
+ $this->_response_header_ttls = $this->conf(Base::O_CACHE_TTL_STATUS);
+ foreach ($this->_response_header_ttls as $k => $v) {
+ $v = explode(' ', $v);
+ if (empty($v[0]) || empty($v[1])) {
continue;
}
- $this->_response_header_ttls[ $v[ 0 ] ] = $v[ 1 ];
+ $this->_response_header_ttls[$v[0]] = $v[1];
}
- if ( $this->conf( Base::O_PURGE_STALE ) ) {
+ if ($this->conf(Base::O_PURGE_STALE)) {
$this->set_stale();
}
}
@@ -66,9 +68,10 @@ public function init() {
* @since 1.6.2
* @access public
*/
- public function vary_add_role_exclude( $vary ) {
- if ( $this->in_cache_exc_roles() ) {
- $vary[ 'role_exclude_cache' ] = 1;
+ public function vary_add_role_exclude($vary)
+ {
+ if ($this->in_cache_exc_roles()) {
+ $vary['role_exclude_cache'] = 1;
}
return $vary;
@@ -83,20 +86,21 @@ public function vary_add_role_exclude( $vary ) {
* @param string $role The user role
* @return int The set value if already set
*/
- public function in_cache_exc_roles( $role = null ) {
+ public function in_cache_exc_roles($role = null)
+ {
// Get user role
- if ( $role === null ) {
+ if ($role === null) {
$role = Router::get_role();
}
- if ( ! $role ) {
+ if (!$role) {
return false;
}
- $roles = explode( ',', $role );
- $found = array_intersect( $roles, $this->conf( Base::O_CACHE_EXC_ROLES ) );
+ $roles = explode(',', $role);
+ $found = array_intersect($roles, $this->conf(Base::O_CACHE_EXC_ROLES));
- return $found ? implode( ',', $found ) : false;
+ return $found ? implode(',', $found) : false;
}
/**
@@ -106,32 +110,32 @@ public function in_cache_exc_roles( $role = null ) {
* @since 1.1.3
* @access public
*/
- public function init_cacheable() {
+ public function init_cacheable()
+ {
// Hook `wp` to mark default cacheable status
// NOTE: Any process that does NOT run into `wp` hook will not get cacheable by default
- add_action( 'wp', array( $this, 'set_cacheable' ), 5 );
+ add_action('wp', array($this, 'set_cacheable'), 5);
// Hook WP REST to be cacheable
- if ( $this->conf( Base::O_CACHE_REST ) ) {
- add_action( 'rest_api_init', array( $this, 'set_cacheable' ), 5 );
+ if ($this->conf(Base::O_CACHE_REST)) {
+ add_action('rest_api_init', array($this, 'set_cacheable'), 5);
}
// Cache resources
// NOTE: If any strange resource doesn't use normal WP logic `wp_loaded` hook, rewrite rule can handle it
- $cache_res = $this->conf( Base::O_CACHE_RES );
- if ( $cache_res ) {
- $uri = esc_url( $_SERVER["REQUEST_URI"] );// todo: check if need esc_url()
+ $cache_res = $this->conf(Base::O_CACHE_RES);
+ if ($cache_res) {
+ $uri = esc_url($_SERVER['REQUEST_URI']); // todo: check if need esc_url()
$pattern = '!' . LSCWP_CONTENT_FOLDER . Htaccess::RW_PATTERN_RES . '!';
- if ( preg_match( $pattern, $uri ) ) {
- add_action( 'wp_loaded', array( $this, 'set_cacheable' ), 5 );
+ if (preg_match($pattern, $uri)) {
+ add_action('wp_loaded', array($this, 'set_cacheable'), 5);
}
}
// Check error page
- add_filter( 'status_header', array( $this, 'check_error_codes' ), 10, 2 );
+ add_filter('status_header', array($this, 'check_error_codes'), 10, 2);
}
-
/**
* Check if the page returns any error code.
*
@@ -141,23 +145,23 @@ public function init_cacheable() {
* @param $code
* @return $eror_status
*/
- public function check_error_codes( $status_header, $code ) {
- if ( array_key_exists( $code, $this->_response_header_ttls ) ) {
- if ( self::is_cacheable() && ! $this->_response_header_ttls[ $code ] ) {
- self::set_nocache( '[Ctrl] TTL is set to no cache [status_header] ' . $code );
+ public function check_error_codes($status_header, $code)
+ {
+ if (array_key_exists($code, $this->_response_header_ttls)) {
+ if (self::is_cacheable() && !$this->_response_header_ttls[$code]) {
+ self::set_nocache('[Ctrl] TTL is set to no cache [status_header] ' . $code);
}
// Set TTL
- self::set_custom_ttl( $this->_response_header_ttls[ $code ] );
- }
- elseif (self::is_cacheable()) {
- if ( substr($code, 0, 1)==4 || substr($code, 0, 1)==5 ) {
- self::set_nocache( '[Ctrl] 4xx/5xx default to no cache [status_header] ' . $code );
+ self::set_custom_ttl($this->_response_header_ttls[$code]);
+ } elseif (self::is_cacheable()) {
+ if (substr($code, 0, 1) == 4 || substr($code, 0, 1) == 5) {
+ self::set_nocache('[Ctrl] 4xx/5xx default to no cache [status_header] ' . $code);
}
}
// Set cache tag
- Tag::add( Tag::TYPE_HTTP . $code );
+ Tag::add(Tag::TYPE_HTTP . $code);
// Give the default status_header back
return $status_header;
@@ -169,12 +173,13 @@ public function check_error_codes( $status_header, $code ) {
* @access public
* @since 1.1.3
*/
- public static function set_no_vary() {
- if ( self::is_no_vary() ) {
+ public static function set_no_vary()
+ {
+ if (self::is_no_vary()) {
return;
}
self::$_control |= self::BM_NO_VARY;
- Debug2::debug( '[Ctrl] X Cache_control -> no-vary', 3 );
+ Debug2::debug('[Ctrl] X Cache_control -> no-vary', 3);
}
/**
@@ -183,7 +188,8 @@ public static function set_no_vary() {
* @access public
* @since 1.1.3
*/
- public static function is_no_vary() {
+ public static function is_no_vary()
+ {
return self::$_control & self::BM_NO_VARY;
}
@@ -193,8 +199,9 @@ public static function is_no_vary() {
* @access public
* @since 1.1.3
*/
- public function set_stale() {
- if ( self::is_stale() ) {
+ public function set_stale()
+ {
+ if (self::is_stale()) {
return;
}
self::$_control |= self::BM_STALE;
@@ -207,7 +214,8 @@ public function set_stale() {
* @access public
* @since 1.1.3
*/
- public static function is_stale() {
+ public static function is_stale()
+ {
return self::$_control & self::BM_STALE;
}
@@ -218,21 +226,22 @@ public static function is_stale() {
* @since 1.1.3
* @param string $reason The reason to no cache
*/
- public static function set_shared( $reason = false ) {
- if ( self::is_shared() ) {
+ public static function set_shared($reason = false)
+ {
+ if (self::is_shared()) {
return;
}
self::$_control |= self::BM_SHARED;
self::set_private();
- if ( ! is_string( $reason ) ) {
+ if (!is_string($reason)) {
$reason = false;
}
- if ( $reason ) {
+ if ($reason) {
$reason = "( $reason )";
}
- Debug2::debug( '[Ctrl] X Cache_control -> shared ' . $reason );
+ Debug2::debug('[Ctrl] X Cache_control -> shared ' . $reason);
}
/**
@@ -241,8 +250,9 @@ public static function set_shared( $reason = false ) {
* @access public
* @since 1.1.3
*/
- public static function is_shared() {
- return (self::$_control & self::BM_SHARED) && self::is_private();
+ public static function is_shared()
+ {
+ return self::$_control & self::BM_SHARED && self::is_private();
}
/**
@@ -251,20 +261,21 @@ public static function is_shared() {
* @access public
* @since 1.7.1
*/
- public static function set_public_forced( $reason = false ) {
- if ( self::is_public_forced() ) {
+ public static function set_public_forced($reason = false)
+ {
+ if (self::is_public_forced()) {
return;
}
self::$_control |= self::BM_PUBLIC_FORCED;
- if ( ! is_string( $reason ) ) {
+ if (!is_string($reason)) {
$reason = false;
}
- if ( $reason ) {
+ if ($reason) {
$reason = "( $reason )";
}
- Debug2::debug( '[Ctrl] X Cache_control -> public forced ' . $reason );
+ Debug2::debug('[Ctrl] X Cache_control -> public forced ' . $reason);
}
/**
@@ -273,7 +284,8 @@ public static function set_public_forced( $reason = false ) {
* @access public
* @since 1.7.1
*/
- public static function is_public_forced() {
+ public static function is_public_forced()
+ {
return self::$_control & self::BM_PUBLIC_FORCED;
}
@@ -284,20 +296,21 @@ public static function is_public_forced() {
* @since 1.1.3
* @param string $reason The reason to no cache
*/
- public static function set_private( $reason = false ) {
- if ( self::is_private() ) {
+ public static function set_private($reason = false)
+ {
+ if (self::is_private()) {
return;
}
self::$_control |= self::BM_PRIVATE;
- if ( ! is_string( $reason ) ) {
+ if (!is_string($reason)) {
$reason = false;
}
- if ( $reason ) {
+ if ($reason) {
$reason = "( $reason )";
}
- Debug2::debug( '[Ctrl] X Cache_control -> private ' . $reason );
+ Debug2::debug('[Ctrl] X Cache_control -> private ' . $reason);
}
/**
@@ -306,12 +319,13 @@ public static function set_private( $reason = false ) {
* @access public
* @since 1.1.3
*/
- public static function is_private() {
- if ( defined( 'LITESPEED_GUEST' ) && LITESPEED_GUEST ) {
+ public static function is_private()
+ {
+ if (defined('LITESPEED_GUEST') && LITESPEED_GUEST) {
// return false;
}
- return self::$_control & self::BM_PRIVATE && ! self::is_public_forced();
+ return self::$_control & self::BM_PRIVATE && !self::is_public_forced();
}
/**
@@ -320,17 +334,18 @@ public static function is_private() {
* @access public
* @since 1.1.3
*/
- public function set_cacheable( $reason = false ) {
+ public function set_cacheable($reason = false)
+ {
self::$_control |= self::BM_CACHEABLE;
- if ( ! is_string( $reason ) ) {
+ if (!is_string($reason)) {
$reason = false;
}
- if ( $reason ) {
+ if ($reason) {
$reason = ' [reason] ' . $reason;
}
- Debug2::debug( '[Ctrl] X Cache_control init on' . $reason );
+ Debug2::debug('[Ctrl] X Cache_control init on' . $reason);
}
/**
@@ -339,17 +354,18 @@ public function set_cacheable( $reason = false ) {
* @access public
* @since 2.2
*/
- public static function force_cacheable( $reason = false ) {
+ public static function force_cacheable($reason = false)
+ {
self::$_control |= self::BM_FORCED_CACHEABLE;
- if ( ! is_string( $reason ) ) {
+ if (!is_string($reason)) {
$reason = false;
}
- if ( $reason ) {
+ if ($reason) {
$reason = ' [reason] ' . $reason;
}
- Debug2::debug( '[Ctrl] Forced cacheable' . $reason );
+ Debug2::debug('[Ctrl] Forced cacheable' . $reason);
}
/**
@@ -359,17 +375,18 @@ public static function force_cacheable( $reason = false ) {
* @since 1.1.3
* @param string $reason The reason to no cache
*/
- public static function set_nocache( $reason = false ) {
+ public static function set_nocache($reason = false)
+ {
self::$_control |= self::BM_NOTCACHEABLE;
- if ( ! is_string( $reason ) ) {
+ if (!is_string($reason)) {
$reason = false;
}
- if ( $reason ) {
+ if ($reason) {
$reason = "( $reason )";
}
- Debug2::debug( '[Ctrl] X Cache_control -> no Cache ' . $reason, 5 );
+ Debug2::debug('[Ctrl] X Cache_control -> no Cache ' . $reason, 5);
}
/**
@@ -379,7 +396,8 @@ public static function set_nocache( $reason = false ) {
* @since 1.1.3
* @return bool True if notcacheable bit is set, otherwise false.
*/
- public static function isset_notcacheable() {
+ public static function isset_notcacheable()
+ {
return self::$_control & self::BM_NOTCACHEABLE;
}
@@ -389,7 +407,8 @@ public static function isset_notcacheable() {
* @access public
* @since 2.2
*/
- public static function is_forced_cacheable() {
+ public static function is_forced_cacheable()
+ {
return self::$_control & self::BM_FORCED_CACHEABLE;
}
@@ -400,28 +419,29 @@ public static function is_forced_cacheable() {
* @since 1.1.3
* @return bool True if is still cacheable, otherwise false.
*/
- public static function is_cacheable() {
- if ( defined( 'LSCACHE_NO_CACHE' ) && LSCACHE_NO_CACHE ) {
- Debug2::debug( '[Ctrl] LSCACHE_NO_CACHE constant defined' );
+ public static function is_cacheable()
+ {
+ if (defined('LSCACHE_NO_CACHE') && LSCACHE_NO_CACHE) {
+ Debug2::debug('[Ctrl] LSCACHE_NO_CACHE constant defined');
return false;
}
// Guest mode always cacheable
- if ( defined( 'LITESPEED_GUEST' ) && LITESPEED_GUEST ) {
+ if (defined('LITESPEED_GUEST') && LITESPEED_GUEST) {
// return true;
}
// If its forced public cacheable
- if ( self::is_public_forced() ) {
+ if (self::is_public_forced()) {
return true;
}
// If its forced cacheable
- if ( self::is_forced_cacheable() ) {
+ if (self::is_forced_cacheable()) {
return true;
}
- return ! self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE;
+ return !self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE;
}
/**
@@ -431,10 +451,11 @@ public static function is_cacheable() {
* @since 1.1.3
* @param mixed $ttl An integer or string to use as the TTL. Must be numeric.
*/
- public static function set_custom_ttl( $ttl, $reason = false ) {
- if ( is_numeric( $ttl ) ) {
+ public static function set_custom_ttl($ttl, $reason = false)
+ {
+ if (is_numeric($ttl)) {
self::$_custom_ttl = $ttl;
- Debug2::debug( '[Ctrl] X Cache_control TTL -> ' . $ttl . ( $reason ? ' [reason] ' . $ttl : '' ) );
+ Debug2::debug('[Ctrl] X Cache_control TTL -> ' . $ttl . ($reason ? ' [reason] ' . $ttl : ''));
}
}
@@ -444,32 +465,32 @@ public static function set_custom_ttl( $ttl, $reason = false ) {
* @access public
* @since 1.1.3
*/
- public function get_ttl() {
- if ( self::$_custom_ttl != 0 ) {
+ public function get_ttl()
+ {
+ if (self::$_custom_ttl != 0) {
return self::$_custom_ttl;
}
// Check if is in timed url list or not
- $timed_urls = Utility::wildcard2regex( $this->conf( Base::O_PURGE_TIMED_URLS ) );
- $timed_urls_time = $this->conf( Base::O_PURGE_TIMED_URLS_TIME );
- if ( $timed_urls && $timed_urls_time ) {
- $current_url = Tag::build_uri_tag( true );
+ $timed_urls = Utility::wildcard2regex($this->conf(Base::O_PURGE_TIMED_URLS));
+ $timed_urls_time = $this->conf(Base::O_PURGE_TIMED_URLS_TIME);
+ if ($timed_urls && $timed_urls_time) {
+ $current_url = Tag::build_uri_tag(true);
// Use time limit ttl
- $scheduled_time = strtotime( $timed_urls_time );
+ $scheduled_time = strtotime($timed_urls_time);
$ttl = $scheduled_time - time();
- if ( $ttl < 0 ) {
- $ttl += 86400;// add one day
+ if ($ttl < 0) {
+ $ttl += 86400; // add one day
}
- foreach ( $timed_urls as $v ) {
- if ( strpos( $v, '*' ) !== false ) {
- if( preg_match( '#' . $v . '#iU', $current_url ) ) {
- Debug2::debug( '[Ctrl] X Cache_control TTL is limited to ' . $ttl . ' due to scheduled purge regex ' . $v );
+ foreach ($timed_urls as $v) {
+ if (strpos($v, '*') !== false) {
+ if (preg_match('#' . $v . '#iU', $current_url)) {
+ Debug2::debug('[Ctrl] X Cache_control TTL is limited to ' . $ttl . ' due to scheduled purge regex ' . $v);
return $ttl;
}
- }
- else {
- if ( $v == $current_url ) {
- Debug2::debug( '[Ctrl] X Cache_control TTL is limited to ' . $ttl . ' due to scheduled purge rule ' . $v );
+ } else {
+ if ($v == $current_url) {
+ Debug2::debug('[Ctrl] X Cache_control TTL is limited to ' . $ttl . ' due to scheduled purge rule ' . $v);
return $ttl;
}
}
@@ -477,24 +498,24 @@ public function get_ttl() {
}
// Private cache uses private ttl setting
- if ( self::is_private() ) {
- return $this->conf( Base::O_CACHE_TTL_PRIV );
+ if (self::is_private()) {
+ return $this->conf(Base::O_CACHE_TTL_PRIV);
}
- if ( is_front_page() ){
- return $this->conf( Base::O_CACHE_TTL_FRONTPAGE );
+ if (is_front_page()) {
+ return $this->conf(Base::O_CACHE_TTL_FRONTPAGE);
}
- $feed_ttl = $this->conf( Base::O_CACHE_TTL_FEED );
- if ( is_feed() && $feed_ttl > 0 ) {
+ $feed_ttl = $this->conf(Base::O_CACHE_TTL_FEED);
+ if (is_feed() && $feed_ttl > 0) {
return $feed_ttl;
}
- if ( $this->cls( 'REST' )->is_rest() || $this->cls( 'REST' )->is_internal_rest() ) {
- return $this->conf( Base::O_CACHE_TTL_REST );
+ if ($this->cls('REST')->is_rest() || $this->cls('REST')->is_internal_rest()) {
+ return $this->conf(Base::O_CACHE_TTL_REST);
}
- return $this->conf( Base::O_CACHE_TTL_PUB );
+ return $this->conf(Base::O_CACHE_TTL_PUB);
}
/**
@@ -503,40 +524,38 @@ public function get_ttl() {
* @access public
* @since 1.1.3
*/
- public function check_redirect( $location, $status ) { // TODO: some env don't have SCRIPT_URI but only REQUEST_URI, need to be compatible
- if ( ! empty( $_SERVER[ 'SCRIPT_URI' ] ) ) { // dont check $status == '301' anymore
- self::debug( "301 from " . $_SERVER[ 'SCRIPT_URI' ] );
- self::debug( "301 to $location" );
-
- $to_check = array(
- PHP_URL_SCHEME,
- PHP_URL_HOST,
- PHP_URL_PATH,
- PHP_URL_QUERY,
- );
+ public function check_redirect($location, $status)
+ {
+ // TODO: some env don't have SCRIPT_URI but only REQUEST_URI, need to be compatible
+ if (!empty($_SERVER['SCRIPT_URI'])) {
+ // dont check $status == '301' anymore
+ self::debug('301 from ' . $_SERVER['SCRIPT_URI']);
+ self::debug("301 to $location");
+
+ $to_check = array(PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PATH, PHP_URL_QUERY);
$is_same_redirect = true;
- foreach ( $to_check as $v ) {
- $url_parsed = $v == PHP_URL_QUERY ? $_SERVER[ 'QUERY_STRING' ] : parse_url( $_SERVER[ 'SCRIPT_URI' ], $v );
- $target = parse_url( $location, $v );
+ foreach ($to_check as $v) {
+ $url_parsed = $v == PHP_URL_QUERY ? $_SERVER['QUERY_STRING'] : parse_url($_SERVER['SCRIPT_URI'], $v);
+ $target = parse_url($location, $v);
self::debug("Compare [from] $url_parsed [to] $target");
- if($v==PHP_URL_QUERY) {
+ if ($v == PHP_URL_QUERY) {
$url_parsed = urldecode($url_parsed);
$target = urldecode($target);
}
- if ( $url_parsed != $target ) {
+ if ($url_parsed != $target) {
$is_same_redirect = false;
- self::debug( "301 different redirection" );
+ self::debug('301 different redirection');
break;
}
}
- if ( $is_same_redirect ) {
- self::set_nocache( '301 to same url' );
+ if ($is_same_redirect) {
+ self::set_nocache('301 to same url');
}
}
@@ -550,16 +569,17 @@ public function check_redirect( $location, $status ) { // TODO: some env don't h
* @access public
* @return string empty string if empty, otherwise the cache control header.
*/
- public function output() {
+ public function output()
+ {
$esi_hdr = '';
- if ( ESI::has_esi() ) {
+ if (ESI::has_esi()) {
$esi_hdr = ',esi=on';
}
$hdr = self::X_HEADER . ': ';
- if ( defined( 'DONOTCACHEPAGE' ) && apply_filters( 'litespeed_const_DONOTCACHEPAGE', DONOTCACHEPAGE ) ) {
- Debug2::debug( "[Ctrl] ❌ forced no cache [reason] DONOTCACHEPAGE const" );
+ if (defined('DONOTCACHEPAGE') && apply_filters('litespeed_const_DONOTCACHEPAGE', DONOTCACHEPAGE)) {
+ Debug2::debug('[Ctrl] ❌ forced no cache [reason] DONOTCACHEPAGE const');
$hdr .= 'no-cache' . $esi_hdr;
return $hdr;
}
@@ -587,22 +607,20 @@ public function output() {
// Fix cli `uninstall --deactivate` fatal err
- if ( ! self::is_cacheable() ) {
+ if (!self::is_cacheable()) {
$hdr .= 'no-cache' . $esi_hdr;
return $hdr;
}
- if ( self::is_shared() ) {
+ if (self::is_shared()) {
$hdr .= 'shared,private';
- }
- elseif ( self::is_private() ) {
+ } elseif (self::is_private()) {
$hdr .= 'private';
- }
- else {
+ } else {
$hdr .= 'public';
}
- if ( self::is_no_vary() ) {
+ if (self::is_no_vary()) {
$hdr .= ',no-vary';
}
@@ -616,105 +634,104 @@ public function output() {
* @access public
* @since 1.1.3
*/
- public function finalize() {
- if ( defined( 'LITESPEED_GUEST' ) && LITESPEED_GUEST ) {
+ public function finalize()
+ {
+ if (defined('LITESPEED_GUEST') && LITESPEED_GUEST) {
// return;
}
- if ( is_preview() ) {
- self::set_nocache( 'preview page' );
+ if (is_preview()) {
+ self::set_nocache('preview page');
return;
}
// Check if has metabox non-cacheable setting or not
- if ( file_exists( LSCWP_DIR . 'src/metabox.cls.php' ) && $this->cls( 'Metabox' )->setting( 'litespeed_no_cache' ) ) {
- self::set_nocache( 'per post metabox setting' );
+ if (file_exists(LSCWP_DIR . 'src/metabox.cls.php') && $this->cls('Metabox')->setting('litespeed_no_cache')) {
+ self::set_nocache('per post metabox setting');
return;
}
// Check if URI is forced public cache
- $excludes = $this->conf( Base::O_CACHE_FORCE_PUB_URI );
- $hit = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes, true );
- if ( $hit ) {
- list( $result, $this_ttl ) = $hit;
- self::set_public_forced( 'Setting: ' . $result );
- Debug2::debug( '[Ctrl] Forced public cacheable due to setting: ' . $result );
- if ( $this_ttl ) {
- self::set_custom_ttl( $this_ttl );
+ $excludes = $this->conf(Base::O_CACHE_FORCE_PUB_URI);
+ $hit = Utility::str_hit_array($_SERVER['REQUEST_URI'], $excludes, true);
+ if ($hit) {
+ list($result, $this_ttl) = $hit;
+ self::set_public_forced('Setting: ' . $result);
+ Debug2::debug('[Ctrl] Forced public cacheable due to setting: ' . $result);
+ if ($this_ttl) {
+ self::set_custom_ttl($this_ttl);
}
}
- if ( self::is_public_forced() ) {
+ if (self::is_public_forced()) {
return;
}
// Check if URI is forced cache
- $excludes = $this->conf( Base::O_CACHE_FORCE_URI );
- $hit = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes, true );
- if ( $hit ) {
- list( $result, $this_ttl ) = $hit;
+ $excludes = $this->conf(Base::O_CACHE_FORCE_URI);
+ $hit = Utility::str_hit_array($_SERVER['REQUEST_URI'], $excludes, true);
+ if ($hit) {
+ list($result, $this_ttl) = $hit;
self::force_cacheable();
- Debug2::debug( '[Ctrl] Forced cacheable due to setting: ' . $result );
- if ( $this_ttl ) {
- self::set_custom_ttl( $this_ttl );
+ Debug2::debug('[Ctrl] Forced cacheable due to setting: ' . $result);
+ if ($this_ttl) {
+ self::set_custom_ttl($this_ttl);
}
}
// if is not cacheable, terminate check
// Even no need to run 3rd party hook
- if ( ! self::is_cacheable() ) {
- Debug2::debug( '[Ctrl] not cacheable before ctrl finalize' );
+ if (!self::is_cacheable()) {
+ Debug2::debug('[Ctrl] not cacheable before ctrl finalize');
return;
}
// Apply 3rd party filter
// NOTE: Hook always needs to run asap because some 3rd party set is_mobile in this hook
- do_action('litespeed_control_finalize', defined( 'LSCACHE_IS_ESI' ) ? LSCACHE_IS_ESI : false ); // Pass ESI block id
+ do_action('litespeed_control_finalize', defined('LSCACHE_IS_ESI') ? LSCACHE_IS_ESI : false); // Pass ESI block id
// if is not cacheable, terminate check
- if ( ! self::is_cacheable() ) {
- Debug2::debug( '[Ctrl] not cacheable after api_control' );
+ if (!self::is_cacheable()) {
+ Debug2::debug('[Ctrl] not cacheable after api_control');
return;
}
// Check litespeed setting to set cacheable status
- if ( ! $this->_setting_cacheable() ) {
+ if (!$this->_setting_cacheable()) {
self::set_nocache();
return;
}
// If user has password cookie, do not cache (moved from vary)
global $post;
- if ( ! empty($post->post_password) && isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
+ if (!empty($post->post_password) && isset($_COOKIE['wp-postpass_' . COOKIEHASH])) {
// If user has password cookie, do not cache
self::set_nocache('pswd cookie');
return;
}
// The following check to the end is ONLY for mobile
- $is_mobile = apply_filters( 'litespeed_is_mobile', false );
- if ( ! $this->conf( Base::O_CACHE_MOBILE ) ) {
- if ( $is_mobile ) {
- self::set_nocache( 'mobile' );
+ $is_mobile = apply_filters('litespeed_is_mobile', false);
+ if (!$this->conf(Base::O_CACHE_MOBILE)) {
+ if ($is_mobile) {
+ self::set_nocache('mobile');
}
return;
}
- $env_vary = isset( $_SERVER[ 'LSCACHE_VARY_VALUE' ] ) ? $_SERVER[ 'LSCACHE_VARY_VALUE' ] : false;
- if ( ! $env_vary ) {
- $env_vary = isset( $_SERVER[ 'HTTP_X_LSCACHE_VARY_VALUE' ] ) ? $_SERVER[ 'HTTP_X_LSCACHE_VARY_VALUE' ] : false;
+ $env_vary = isset($_SERVER['LSCACHE_VARY_VALUE']) ? $_SERVER['LSCACHE_VARY_VALUE'] : false;
+ if (!$env_vary) {
+ $env_vary = isset($_SERVER['HTTP_X_LSCACHE_VARY_VALUE']) ? $_SERVER['HTTP_X_LSCACHE_VARY_VALUE'] : false;
}
- if ( $env_vary && strpos( $env_vary, 'ismobile' ) !== false ) {
- if ( ! wp_is_mobile() && ! $is_mobile ) {
- self::set_nocache( 'is not mobile' ); // todo: no need to uncache, it will correct vary value in vary finalize anyways
+ if ($env_vary && strpos($env_vary, 'ismobile') !== false) {
+ if (!wp_is_mobile() && !$is_mobile) {
+ self::set_nocache('is not mobile'); // todo: no need to uncache, it will correct vary value in vary finalize anyways
return;
}
- }
- elseif ( wp_is_mobile() || $is_mobile ) {
- self::set_nocache( 'is mobile' );
+ } elseif (wp_is_mobile() || $is_mobile) {
+ self::set_nocache('is mobile');
return;
}
-
}
/**
@@ -723,7 +740,8 @@ public function finalize() {
* @since 3.0
* @access public
*/
- public static function is_mobile() {
+ public static function is_mobile()
+ {
return wp_is_mobile();
}
@@ -734,85 +752,85 @@ public static function is_mobile() {
* @access private
* @return boolean True if cacheable, false otherwise.
*/
- private function _setting_cacheable() {
+ private function _setting_cacheable()
+ {
// logged_in users already excluded, no hook added
- if( ! empty( $_REQUEST[ Router::ACTION ] ) ) {
- return $this->_no_cache_for( 'Query String Action' );
+ if (!empty($_REQUEST[Router::ACTION])) {
+ return $this->_no_cache_for('Query String Action');
}
- $method = isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : 'unknown';
- if ( 'GET' !== $method && 'HEAD' !== $method ) {
+ $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'unknown';
+ if ('GET' !== $method && 'HEAD' !== $method) {
return $this->_no_cache_for('Not GET method: ' . $method);
}
- if ( is_feed() && $this->conf( Base::O_CACHE_TTL_FEED ) == 0 ) {
+ if (is_feed() && $this->conf(Base::O_CACHE_TTL_FEED) == 0) {
return $this->_no_cache_for('feed');
}
- if ( is_trackback() ) {
+ if (is_trackback()) {
return $this->_no_cache_for('trackback');
}
- if ( is_search() ) {
+ if (is_search()) {
return $this->_no_cache_for('search');
}
-// if ( !defined('WP_USE_THEMES') || !WP_USE_THEMES ) {
-// return $this->_no_cache_for('no theme used');
-// }
+ // if ( !defined('WP_USE_THEMES') || !WP_USE_THEMES ) {
+ // return $this->_no_cache_for('no theme used');
+ // }
// Check private cache URI setting
- $excludes = $this->conf( Base::O_CACHE_PRIV_URI );
- $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes );
- if ( $result ) {
- self::set_private( 'Admin cfg Private Cached URI: ' . $result );
+ $excludes = $this->conf(Base::O_CACHE_PRIV_URI);
+ $result = Utility::str_hit_array($_SERVER['REQUEST_URI'], $excludes);
+ if ($result) {
+ self::set_private('Admin cfg Private Cached URI: ' . $result);
}
- if ( ! self::is_forced_cacheable() ) {
-
+ if (!self::is_forced_cacheable()) {
// Check if URI is excluded from cache
- $excludes = $this->conf( Base::O_CACHE_EXC );
- $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes );
- if ( $result ) {
- return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result );
+ $excludes = $this->conf(Base::O_CACHE_EXC);
+ $result = Utility::str_hit_array($_SERVER['REQUEST_URI'], $excludes);
+ if ($result) {
+ return $this->_no_cache_for('Admin configured URI Do not cache: ' . $result);
}
// Check QS excluded setting
- $excludes = $this->conf( Base::O_CACHE_EXC_QS );
- if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( $excludes ) ) {
- return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs );
+ $excludes = $this->conf(Base::O_CACHE_EXC_QS);
+ if (!empty($excludes) && ($qs = $this->_is_qs_excluded($excludes))) {
+ return $this->_no_cache_for('Admin configured QS Do not cache: ' . $qs);
}
- $excludes = $this->conf( Base::O_CACHE_EXC_CAT );
- if ( ! empty( $excludes ) && has_category( $excludes ) ) {
- return $this->_no_cache_for( 'Admin configured Category Do not cache.' );
+ $excludes = $this->conf(Base::O_CACHE_EXC_CAT);
+ if (!empty($excludes) && has_category($excludes)) {
+ return $this->_no_cache_for('Admin configured Category Do not cache.');
}
- $excludes = $this->conf( Base::O_CACHE_EXC_TAG );
- if ( ! empty( $excludes ) && has_tag( $excludes ) ) {
- return $this->_no_cache_for( 'Admin configured Tag Do not cache.' );
+ $excludes = $this->conf(Base::O_CACHE_EXC_TAG);
+ if (!empty($excludes) && has_tag($excludes)) {
+ return $this->_no_cache_for('Admin configured Tag Do not cache.');
}
- $excludes = $this->conf( Base::O_CACHE_EXC_COOKIES );
- if ( ! empty( $excludes ) && ! empty( $_COOKIE ) ) {
- $cookie_hit = array_intersect( array_keys( $_COOKIE ), $excludes );
- if ( $cookie_hit ) {
- return $this->_no_cache_for( 'Admin configured Cookie Do not cache.' );
+ $excludes = $this->conf(Base::O_CACHE_EXC_COOKIES);
+ if (!empty($excludes) && !empty($_COOKIE)) {
+ $cookie_hit = array_intersect(array_keys($_COOKIE), $excludes);
+ if ($cookie_hit) {
+ return $this->_no_cache_for('Admin configured Cookie Do not cache.');
}
}
- $excludes = $this->conf( Base::O_CACHE_EXC_USERAGENTS );
- if ( ! empty( $excludes ) && isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
- $nummatches = preg_match( Utility::arr2regex( $excludes ), $_SERVER[ 'HTTP_USER_AGENT' ] );
- if ( $nummatches ) {
- return $this->_no_cache_for('Admin configured User Agent Do not cache.');
+ $excludes = $this->conf(Base::O_CACHE_EXC_USERAGENTS);
+ if (!empty($excludes) && isset($_SERVER['HTTP_USER_AGENT'])) {
+ $nummatches = preg_match(Utility::arr2regex($excludes), $_SERVER['HTTP_USER_AGENT']);
+ if ($nummatches) {
+ return $this->_no_cache_for('Admin configured User Agent Do not cache.');
}
}
// Check if is exclude roles ( Need to set Vary too )
- if ( $result = $this->in_cache_exc_roles() ) {
- return $this->_no_cache_for( 'Role Excludes setting ' . $result );
+ if ($result = $this->in_cache_exc_roles()) {
+ return $this->_no_cache_for('Role Excludes setting ' . $result);
}
}
@@ -827,7 +845,8 @@ private function _setting_cacheable() {
* @param string $reason An explanation for why the page is not cacheable.
* @return boolean Return false.
*/
- private function _no_cache_for( $reason ) {
+ private function _no_cache_for($reason)
+ {
Debug2::debug('[Ctrl] X Cache_control off - ' . $reason);
return false;
}
@@ -840,11 +859,11 @@ private function _no_cache_for( $reason ) {
* @param array $excludes QS excludes setting
* @return boolean|string False if not excluded, otherwise the hit qs list
*/
- private function _is_qs_excluded( $excludes ) {
- if ( ! empty( $_GET ) && $intersect = array_intersect( array_keys( $_GET ), $excludes ) ) {
- return implode( ',', $intersect );
+ private function _is_qs_excluded($excludes)
+ {
+ if (!empty($_GET) && ($intersect = array_intersect(array_keys($_GET), $excludes))) {
+ return implode(',', $intersect);
}
return false;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/core.cls.php b/src/core.cls.php
index 69f39f69b..905289c5a 100644
--- a/src/core.cls.php
+++ b/src/core.cls.php
@@ -10,7 +10,7 @@
namespace LiteSpeed;
-defined('WPINC') || exit;
+defined('WPINC') || exit();
class Core extends Root
{
@@ -239,7 +239,6 @@ public function init()
// test: Simulate a purge all
// if (defined( 'LITESPEED_CLI' )) Purge::add('test'.date('Ymd.His'));
-
}
/**
@@ -262,7 +261,7 @@ public function after_user_init()
*/
$this->cls('ESI')->init();
- if (!is_admin() && !defined('LITESPEED_GUEST_OPTM') && $result = $this->cls('Conf')->in_optm_exc_roles()) {
+ if (!is_admin() && !defined('LITESPEED_GUEST_OPTM') && ($result = $this->cls('Conf')->in_optm_exc_roles())) {
Debug2::debug('[Core] ⛑️ bypass_optm: hit Role Excludes setting: ' . $result);
!defined('LITESPEED_NO_OPTM') && define('LITESPEED_NO_OPTM', true);
}
@@ -362,7 +361,7 @@ public function proceed_action($action)
}
if (Router::is_ajax()) {
- exit;
+ exit();
}
}
@@ -486,7 +485,6 @@ public function send_headers_force($buffer)
$this->send_headers(true);
-
// Init comment info
$running_info_showing = defined('LITESPEED_IS_HTML') || defined('LSCACHE_IS_ESI');
if (defined('LSCACHE_ESI_SILENCE')) {
@@ -525,7 +523,7 @@ public function send_headers_force($buffer)
}
if (apply_filters('litespeed_is_json', false)) {
- if (json_decode($buffer, true) == NULL) {
+ if (json_decode($buffer, true) == null) {
Debug2::debug('[Core] Buffer converting to JSON');
$buffer = json_encode($buffer);
$buffer = trim($buffer, '"');
@@ -595,13 +593,15 @@ public function send_headers($is_forced = false)
$cache_support = Control::is_cacheable() ? 'cached' : 'uncached';
}
- $this->_comment(sprintf(
- '%1$s %2$s by LiteSpeed Cache %4$s on %3$s',
- defined('LSCACHE_IS_ESI') ? 'Block' : 'Page',
- $cache_support,
- date('Y-m-d H:i:s', time() + LITESPEED_TIME_OFFSET),
- self::VER
- ));
+ $this->_comment(
+ sprintf(
+ '%1$s %2$s by LiteSpeed Cache %4$s on %3$s',
+ defined('LSCACHE_IS_ESI') ? 'Block' : 'Page',
+ $cache_support,
+ date('Y-m-d H:i:s', time() + LITESPEED_TIME_OFFSET),
+ self::VER
+ )
+ );
// send Control header
if (defined('LITESPEED_ON') && $control_header) {
@@ -629,7 +629,9 @@ public function send_headers($is_forced = false)
if (defined('LITESPEED_ON') && defined('LSCWP_LOG')) {
$vary = $this->cls('Vary')->finalize_full_varies();
- if ($vary) $this->_comment('Full varies: ' . $vary);
+ if ($vary) {
+ $this->_comment('Full varies: ' . $vary);
+ }
}
// Admin QS show header action
@@ -707,7 +709,7 @@ public static function comment($data)
private function _comment($data)
{
- $this->_footer_comment .= "\n";
+ $this->_footer_comment .= "\n';
}
/**
@@ -716,11 +718,15 @@ private function _comment($data)
*/
private function _http_header($header)
{
- if (defined('LITESPEED_CLI')) return;
+ if (defined('LITESPEED_CLI')) {
+ return;
+ }
@header($header);
- if (!defined('LSCWP_LOG')) return;
+ if (!defined('LSCWP_LOG')) {
+ return;
+ }
Debug2::debug('💰 ' . $header);
}
}
diff --git a/src/crawler-map.cls.php b/src/crawler-map.cls.php
index bb519e81d..633b10088 100644
--- a/src/crawler-map.cls.php
+++ b/src/crawler-map.cls.php
@@ -8,7 +8,7 @@
namespace LiteSpeed;
-defined('WPINC') || exit;
+defined('WPINC') || exit();
class Crawler_Map extends Root
{
@@ -55,7 +55,8 @@ public function save_map_status($list, $curr_crawler)
// Replace current crawler's position
$curr_crawler = (int) $curr_crawler;
- foreach ($list as $bit => $ids) { // $ids = [ id => [ url, code ], ... ]
+ foreach ($list as $bit => $ids) {
+ // $ids = [ id => [ url, code ], ... ]
if (!$ids) {
continue;
}
@@ -75,7 +76,7 @@ public function save_map_status($list, $curr_crawler)
$existing = $wpdb->get_results($q, ARRAY_A);
// Update current crawler status tag in existing blacklist
if ($existing) {
- $count = $wpdb->query("UPDATE `$this->_tb_blacklist` SET res = $sql_res WHERE id IN ( " . implode(',', array_column($existing, 'id')) . " )");
+ $count = $wpdb->query("UPDATE `$this->_tb_blacklist` SET res = $sql_res WHERE id IN ( " . implode(',', array_column($existing, 'id')) . ' )');
self::debug('Update blacklist [count] ' . $count);
}
@@ -103,11 +104,11 @@ public function save_map_status($list, $curr_crawler)
// Update sitemap reason w/ HTTP code
$reason_array = array();
foreach ($ids as $id => $v2) {
- $code = (int)$v2['code'];
+ $code = (int) $v2['code'];
if (empty($reason_array[$code])) {
$reason_array[$code] = array();
}
- $reason_array[$code][] = (int)$id;
+ $reason_array[$code][] = (int) $id;
}
foreach ($reason_array as $code => $v2) {
@@ -119,13 +120,21 @@ public function save_map_status($list, $curr_crawler)
$code .= ',';
}
- $count = $wpdb->query("UPDATE `$this->_tb` SET reason=CONCAT(SUBSTRING_INDEX(reason, ',', $curr_crawler), '$code', SUBSTRING_INDEX(reason, ',', -$right_pos)) WHERE id IN (" . implode(',', $v2) . ")");
+ $count = $wpdb->query(
+ "UPDATE `$this->_tb` SET reason=CONCAT(SUBSTRING_INDEX(reason, ',', $curr_crawler), '$code', SUBSTRING_INDEX(reason, ',', -$right_pos)) WHERE id IN (" .
+ implode(',', $v2) .
+ ')'
+ );
self::debug("Update map reason [code] $code [pos] left $curr_crawler right -$right_pos [count] $count");
// Update blacklist reason
if ($bit == 'B' || $bit == 'N') {
- $count = $wpdb->query("UPDATE `$this->_tb_blacklist` a LEFT JOIN `$this->_tb` b ON b.url = a.url SET a.reason=CONCAT(SUBSTRING_INDEX(a.reason, ',', $curr_crawler), '$code', SUBSTRING_INDEX(a.reason, ',', -$right_pos)) WHERE b.id IN (" . implode(',', $v2) . ")");
+ $count = $wpdb->query(
+ "UPDATE `$this->_tb_blacklist` a LEFT JOIN `$this->_tb` b ON b.url = a.url SET a.reason=CONCAT(SUBSTRING_INDEX(a.reason, ',', $curr_crawler), '$code', SUBSTRING_INDEX(a.reason, ',', -$right_pos)) WHERE b.id IN (" .
+ implode(',', $v2) .
+ ')'
+ );
self::debug("Update blacklist [code] $code [pos] left $curr_crawler right -$right_pos [count] $count");
}
@@ -148,7 +157,7 @@ public function blacklist_add($id)
{
global $wpdb;
- $id = (int)$id;
+ $id = (int) $id;
// Build res&reason
$total_crawler = count(Crawler::cls()->list_crawlers());
@@ -188,7 +197,7 @@ public function blacklist_del($id)
return;
}
- $id = (int)$id;
+ $id = (int) $id;
self::debug('blacklist delete [id] ' . $id);
$wpdb->query("UPDATE `$this->_tb` SET res=REPLACE(REPLACE(res, 'N', '-'), 'B', '-') WHERE url=(SELECT url FROM `$this->_tb_blacklist` WHERE id='$id')");
@@ -235,7 +244,7 @@ public function list_blacklist($limit = false, $offset = false)
$total = $this->count_blacklist();
$offset = Utility::pagination($total, $limit, true);
}
- $q .= " LIMIT %d, %d";
+ $q .= ' LIMIT %d, %d';
$q = $wpdb->prepare($q, $offset, $limit);
}
return $wpdb->get_results($q, ARRAY_A);
@@ -356,7 +365,7 @@ private function _gen()
}
// use custom sitemap
- if (!$sitemap = $this->conf(Base::O_CRAWLER_SITEMAP)) {
+ if (!($sitemap = $this->conf(Base::O_CRAWLER_SITEMAP))) {
return false;
}
@@ -396,7 +405,8 @@ private function _gen()
$full_blacklisted = array();
$partial_blacklisted = array();
foreach ($blacklist as $v) {
- if (strpos($v['res'], '-') === false) { // Full blacklisted
+ if (strpos($v['res'], '-') === false) {
+ // Full blacklisted
$full_blacklisted[] = $v['url'];
} else {
// Replace existing reason
@@ -488,13 +498,15 @@ private function _parse($sitemap)
}
// start parsing
- $xml_array = (array)$xml_object;
- if (!empty($xml_array['sitemap'])) { // parse sitemap set
+ $xml_array = (array) $xml_object;
+ if (!empty($xml_array['sitemap'])) {
+ // parse sitemap set
if (is_object($xml_array['sitemap'])) {
- $xml_array['sitemap'] = (array)$xml_array['sitemap'];
+ $xml_array['sitemap'] = (array) $xml_array['sitemap'];
}
- if (!empty($xml_array['sitemap']['loc'])) { // is single sitemap
+ if (!empty($xml_array['sitemap']['loc'])) {
+ // is single sitemap
$this->_parse($xml_array['sitemap']['loc']);
} else {
// parse multiple sitemaps
@@ -505,7 +517,8 @@ private function _parse($sitemap)
}
}
}
- } elseif (!empty($xml_array['url'])) { // parse url set
+ } elseif (!empty($xml_array['url'])) {
+ // parse url set
if (is_object($xml_array['url'])) {
$xml_array['url'] = (array) $xml_array['url'];
}
diff --git a/src/crawler.cls.php b/src/crawler.cls.php
index babdea7d0..5d79c00f2 100644
--- a/src/crawler.cls.php
+++ b/src/crawler.cls.php
@@ -8,7 +8,7 @@
namespace LiteSpeed;
-defined('WPINC') || exit;
+defined('WPINC') || exit();
class Crawler extends Root
{
@@ -34,17 +34,17 @@ class Crawler extends Root
private $_crawler_conf = array(
'cookies' => array(),
'headers' => array(),
- 'ua' => '',
+ 'ua' => '',
);
private $_crawlers = array();
private $_cur_threads = -1;
private $_max_run_time;
private $_cur_thread_time;
private $_map_status_list = array(
- 'H' => array(),
- 'M' => array(),
- 'B' => array(),
- 'N' => array(),
+ 'H' => array(),
+ 'M' => array(),
+ 'B' => array(),
+ 'N' => array(),
);
protected $_summary;
@@ -76,10 +76,14 @@ private function _get_server_cpu()
{
$cpuinfo_file = '/proc/cpuinfo';
$setting_open_dir = ini_get('open_basedir');
- if ($setting_open_dir) return 1; // Server has limit
+ if ($setting_open_dir) {
+ return 1;
+ } // Server has limit
try {
- if (!@is_file($cpuinfo_file)) return 1;
+ if (!@is_file($cpuinfo_file)) {
+ return 1;
+ }
} catch (\Exception $e) {
return 1;
}
@@ -106,14 +110,17 @@ public function is_active($curr)
* @since 4.3
*/
public function toggle_activeness($curr)
- { // param type: int
+ {
+ // param type: int
$bypass_list = self::get_option('bypass_list', array());
- if (in_array($curr, $bypass_list)) { // when the ith opt was off / in the bypassed list, turn it on / remove it from the list
+ if (in_array($curr, $bypass_list)) {
+ // when the ith opt was off / in the bypassed list, turn it on / remove it from the list
unset($bypass_list[array_search($curr, $bypass_list)]);
$bypass_list = array_values($bypass_list);
self::update_option('bypass_list', $bypass_list);
return true;
- } else { // when the ith opt was on / not in the bypassed list, turn it off / add it to the list
+ } else {
+ // when the ith opt was on / not in the bypassed list, turn it off / add it to the list
$bypass_list[] = (int) $curr;
self::update_option('bypass_list', $bypass_list);
return false;
@@ -145,24 +152,24 @@ public function clear_disabled_list()
public static function get_summary($field = false)
{
$_default = array(
- 'list_size' => 0,
- 'last_update_time' => 0,
- 'curr_crawler' => 0,
- 'curr_crawler_beginning_time' => 0,
- 'last_pos' => 0,
- 'last_count' => 0,
- 'last_crawled' => 0,
- 'last_start_time' => 0,
- 'last_status' => '',
- 'is_running' => 0,
- 'end_reason' => '',
- 'meta_save_time' => 0,
- 'pos_reset_check' => 0,
- 'done' => 0,
- 'this_full_beginning_time' => 0,
- 'last_full_time_cost' => 0,
- 'last_crawler_total_cost' => 0,
- 'crawler_stats' => array(), // this will store all crawlers hit/miss crawl status
+ 'list_size' => 0,
+ 'last_update_time' => 0,
+ 'curr_crawler' => 0,
+ 'curr_crawler_beginning_time' => 0,
+ 'last_pos' => 0,
+ 'last_count' => 0,
+ 'last_crawled' => 0,
+ 'last_start_time' => 0,
+ 'last_status' => '',
+ 'is_running' => 0,
+ 'end_reason' => '',
+ 'meta_save_time' => 0,
+ 'pos_reset_check' => 0,
+ 'done' => 0,
+ 'this_full_beginning_time' => 0,
+ 'last_full_time_cost' => 0,
+ 'last_crawler_total_cost' => 0,
+ 'crawler_stats' => array(), // this will store all crawlers hit/miss crawl status
);
wp_cache_delete('alloptions', 'options'); // ensure the summary is current
@@ -486,7 +493,7 @@ private function _adjust_current_threads()
// init
if ($curload > $this->_crawler_conf['load_limit']) {
$curthreads = 0;
- } elseif ($curload >= ($this->_crawler_conf['load_limit'] - 1)) {
+ } elseif ($curload >= $this->_crawler_conf['load_limit'] - 1) {
$curthreads = 1;
} else {
$curthreads = intval($this->_crawler_conf['load_limit'] - $curload);
@@ -498,7 +505,7 @@ private function _adjust_current_threads()
// adjust
$curthreads = $this->_cur_threads;
if ($curload >= $this->_crawler_conf['load_limit'] + 1) {
- sleep(5); // sleep 5 secs
+ sleep(5); // sleep 5 secs
if ($curthreads >= 1) {
$curthreads--;
}
@@ -506,7 +513,7 @@ private function _adjust_current_threads()
// if ( $curthreads > 1 ) {// if already 1, keep
$curthreads--;
// }
- } elseif (($curload + 1) < $this->_crawler_conf['load_limit']) {
+ } elseif ($curload + 1 < $this->_crawler_conf['load_limit']) {
if ($curthreads < $this->conf(Base::O_CRAWLER_THREADS)) {
$curthreads++;
}
@@ -573,12 +580,14 @@ private function _do_running()
// check result headers
foreach ($rows as $row) {
// self::debug('chunk fetching 553');
- if (empty($rets[$row['id']])) { // If already in blacklist, no curl happened, no corresponding record
+ if (empty($rets[$row['id']])) {
+ // If already in blacklist, no curl happened, no corresponding record
continue;
}
// self::debug('chunk fetching 557');
// check response
- if ($rets[$row['id']]['code'] == 428) { // HTTP/1.1 428 Precondition Required (need to test)
+ if ($rets[$row['id']]['code'] == 428) {
+ // HTTP/1.1 428 Precondition Required (need to test)
$this->_end_reason = 'crawler_disabled';
self::debug('crawler_disabled');
return;
@@ -586,8 +595,8 @@ private function _do_running()
$status = $this->_status_parse($rets[$row['id']]['header'], $rets[$row['id']]['code'], $row['url']); // B or H or M or N(nocache)
$this->_map_status_list[$status][$row['id']] = array(
- 'url' => $row['url'],
- 'code' => $rets[$row['id']]['code'], // 201 or 200 or 404
+ 'url' => $row['url'],
+ 'code' => $rets[$row['id']]['code'], // 201 or 200 or 404
);
if (empty($this->_summary['crawler_stats'][$this->_summary['curr_crawler']][$status])) {
$this->_summary['crawler_stats'][$this->_summary['curr_crawler']][$status] = 0;
@@ -668,7 +677,9 @@ private function _do_running()
*/
private function _multi_request($rows, $options)
{
- if (!function_exists('curl_multi_init')) exit('curl_multi_init disabled');
+ if (!function_exists('curl_multi_init')) {
+ exit('curl_multi_init disabled');
+ }
$mh = curl_multi_init();
$curls = array();
foreach ($rows as $row) {
@@ -679,7 +690,9 @@ private function _multi_request($rows, $options)
continue;
}
- if (!function_exists('curl_init')) exit('curl_init disabled');
+ if (!function_exists('curl_init')) {
+ exit('curl_init disabled');
+ }
$curls[$row['id']] = curl_init();
@@ -725,7 +738,7 @@ private function _multi_request($rows, $options)
$ret[$row['id']] = array(
'header' => $header,
- 'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
+ 'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
);
// self::debug('-----debug4');
curl_multi_remove_handle($mh, $ch);
@@ -756,18 +769,17 @@ private function _status_parse($header, $code, $url)
}
// If blacklist is disabled
- if ((defined('LITESPEED_CRAWLER_DISABLE_BLOCKLIST') && LITESPEED_CRAWLER_DISABLE_BLOCKLIST) || apply_filters('litespeed_crawler_disable_blocklist', '__return_false', $url)) {
+ if (
+ (defined('LITESPEED_CRAWLER_DISABLE_BLOCKLIST') && LITESPEED_CRAWLER_DISABLE_BLOCKLIST) ||
+ apply_filters('litespeed_crawler_disable_blocklist', '__return_false', $url)
+ ) {
return 'M';
}
return 'N'; // Blacklist
}
- $_cache_headers = array(
- 'x-litespeed-cache',
- 'x-lsadc-cache',
- 'x-qc-cache',
- );
+ $_cache_headers = array('x-litespeed-cache', 'x-lsadc-cache', 'x-qc-cache');
foreach ($_cache_headers as $_header) {
if (stripos($header, $_header) !== false) {
@@ -779,7 +791,10 @@ private function _status_parse($header, $code, $url)
}
// If blacklist is disabled
- if ((defined('LITESPEED_CRAWLER_DISABLE_BLOCKLIST') && LITESPEED_CRAWLER_DISABLE_BLOCKLIST) || apply_filters('litespeed_crawler_disable_blocklist', '__return_false', $url)) {
+ if (
+ (defined('LITESPEED_CRAWLER_DISABLE_BLOCKLIST') && LITESPEED_CRAWLER_DISABLE_BLOCKLIST) ||
+ apply_filters('litespeed_crawler_disable_blocklist', '__return_false', $url)
+ ) {
return 'M';
}
@@ -881,7 +896,8 @@ private function _get_curl_options($crawler_only = false)
* @since 3.3
*/
public function self_curl($url, $ua, $uid = false, $accept = false)
- { // $accept not in use yet
+ {
+ // $accept not in use yet
$this->_crawler_conf['base'] = home_url();
$this->_crawler_conf['ua'] = $ua;
if ($accept) {
@@ -921,7 +937,8 @@ private function _terminate_running()
{
$this->_map_status_list = $this->cls('Crawler_Map')->save_map_status($this->_map_status_list, $this->_summary['curr_crawler']);
- if ($this->_end_reason == 'end') { // Current crawler is fully done
+ if ($this->_end_reason == 'end') {
+ // Current crawler is fully done
// $end_reason = sprintf( __( 'Crawler %s reached end of sitemap file.', 'litespeed-cache' ), '#' . ( $this->_summary['curr_crawler'] + 1 ) );
$this->_summary['curr_crawler']++; // Jump to next cralwer
// $this->_summary[ 'crawler_stats' ][ $this->_summary[ 'curr_crawler' ] ] = array(); // reset this at next crawl time
@@ -1006,7 +1023,8 @@ public function list_crawlers()
$crawler_factors[$this_cookie_key] = array();
foreach ($v['vals'] as $v2) {
- $crawler_factors[$this_cookie_key][$v2] = $v2 == '_null' ? '' : '🍪' . esc_html($v['name']) . '=' . esc_html($v2);
+ $crawler_factors[$this_cookie_key][$v2] =
+ $v2 == '_null' ? '' : '🍪' . esc_html($v['name']) . '=' . esc_html($v2);
}
}
@@ -1032,7 +1050,6 @@ private function _recursive_build_crawler($crawler_factors, $group = array(), $i
$final_list = array();
foreach ($crawler_factors[$current_factor] as $k => $v) {
-
// Don't alter $group bcos of loop usage
$item = $group;
$item['title'] = !empty($group['title']) ? $group['title'] : '';
@@ -1070,7 +1087,6 @@ public function json_path()
return LITESPEED_STATIC_URL . '/crawler/' . $this->_sitemeta;
}
-
/**
* Create reset pos file
*
@@ -1177,7 +1193,7 @@ public function handler()
}
break;
- // Handle the ajax request to proceed crawler manually by admin
+ // Handle the ajax request to proceed crawler manually by admin
case self::TYPE_START:
self::start_async();
break;
diff --git a/src/css.cls.php b/src/css.cls.php
index c4d259d1a..fa2957b6c 100644
--- a/src/css.cls.php
+++ b/src/css.cls.php
@@ -8,7 +8,7 @@
namespace LiteSpeed;
-defined('WPINC') || exit;
+defined('WPINC') || exit();
class CSS extends Base
{
@@ -82,7 +82,7 @@ private function _gen_ccss_file_tag($request_url)
}
$sep_uri = $this->conf(self::O_OPTM_CCSS_SEP_URI);
- if ($sep_uri && $hit = Utility::str_hit_array($request_url, $sep_uri)) {
+ if ($sep_uri && ($hit = Utility::str_hit_array($request_url, $sep_uri))) {
Debug2::debug('[CCSS] Separate CCSS due to separate URI setting: ' . $hit);
return $request_url;
}
@@ -127,7 +127,6 @@ private function _ccss()
$ua = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
-
// Store it to prepare for cron
Core::comment('QUIC.cloud CCSS in queue');
$this->_queue = $this->load_queue('ccss');
@@ -139,16 +138,16 @@ private function _ccss()
$queue_k = (strlen($vary) > 32 ? md5($vary) : $vary) . ' ' . $url_tag;
$this->_queue[$queue_k] = array(
- 'url' => apply_filters('litespeed_ccss_url', $request_url),
- 'user_agent' => substr($ua, 0, 200),
- 'is_mobile' => $this->_separate_mobile(),
- 'is_webp' => $this->cls('Media')->webp_support() ? 1 : 0,
- 'uid' => $uid,
- 'vary' => $vary,
- 'url_tag' => $url_tag,
+ 'url' => apply_filters('litespeed_ccss_url', $request_url),
+ 'user_agent' => substr($ua, 0, 200),
+ 'is_mobile' => $this->_separate_mobile(),
+ 'is_webp' => $this->cls('Media')->webp_support() ? 1 : 0,
+ 'uid' => $uid,
+ 'vary' => $vary,
+ 'url_tag' => $url_tag,
); // Current UA will be used to request
$this->save_queue('ccss', $this->_queue);
- self::debug('Added queue_ccss [url_tag] ' . $url_tag . ' [UA] ' . $ua . ' [vary] ' . $vary . ' [uid] ' . $uid);
+ self::debug('Added queue_ccss [url_tag] ' . $url_tag . ' [UA] ' . $ua . ' [vary] ' . $vary . ' [uid] ' . $uid);
// Prepare cache tag for later purge
Tag::add('CCSS.' . md5($queue_k));
@@ -226,7 +225,8 @@ private function _cron_handler($type, $continue)
$i++;
$res = $this->_send_req($v['url'], $k, $v['uid'], $v['user_agent'], $v['vary'], $v['url_tag'], $type, $v['is_mobile'], $v['is_webp']);
- if (!$res) { // Status is wrong, drop this this->_queue
+ if (!$res) {
+ // Status is wrong, drop this this->_queue
unset($this->_queue[$k]);
$this->save_queue($type, $this->_queue);
@@ -302,13 +302,13 @@ private function _send_req($request_url, $queue_k, $uid, $user_agent, $vary, $ur
// Generate critical css
$data = array(
- 'url' => $request_url,
- 'queue_k' => $queue_k,
- 'user_agent' => $user_agent,
- 'is_mobile' => $is_mobile ? 1 : 0, // todo:compatible w/ tablet
- 'is_webp' => $is_webp ? 1 : 0,
- 'html' => $html,
- 'css' => $css,
+ 'url' => $request_url,
+ 'queue_k' => $queue_k,
+ 'user_agent' => $user_agent,
+ 'is_mobile' => $is_mobile ? 1 : 0, // todo:compatible w/ tablet
+ 'is_webp' => $is_webp ? 1 : 0,
+ 'html' => $html,
+ 'css' => $css,
);
self::debug('Generating: ', $data);
@@ -394,13 +394,13 @@ public function test_url($request_url)
// EOT;
$data = array(
- 'url' => $request_url,
- 'ccss_type' => 'test',
- 'user_agent' => $user_agent,
- 'is_mobile' => 0,
- 'html' => $html,
- 'css' => $css,
- 'type' => 'CCSS',
+ 'url' => $request_url,
+ 'ccss_type' => 'test',
+ 'user_agent' => $user_agent,
+ 'is_mobile' => 0,
+ 'html' => $html,
+ 'css' => $css,
+ 'type' => 'CCSS',
);
// self::debug( 'Generating: ', $data );
@@ -420,7 +420,7 @@ public function prepare_html($request_url, $user_agent, $uid = false)
$html = $this->cls('Crawler')->self_curl(add_query_arg('LSCWP_CTRL', 'before_optm', $request_url), $user_agent, $uid);
Debug2::debug2('[CSS] self_curl result....', $html);
- if ( ! $html ) {
+ if (!$html) {
return false;
}
@@ -473,7 +473,8 @@ public function prepare_css($html, $is_webp = false, $dryrun = false)
$debug_info = $attrs['href'];
// Load CSS content
- if (!$dryrun) { // Dryrun will not load CSS but just drop them
+ if (!$dryrun) {
+ // Dryrun will not load CSS but just drop them
$con = $this->cls('Optimizer')->load_file($attrs['href']);
if (!$con) {
continue;
@@ -481,7 +482,8 @@ public function prepare_css($html, $is_webp = false, $dryrun = false)
} else {
$con = '';
}
- } else { // Inline style
+ } else {
+ // Inline style
$attrs = Utility::parse_attr($match[2]);
if (!empty($attrs['media']) && strpos($attrs['media'], 'print') !== false) {
diff --git a/src/data.cls.php b/src/data.cls.php
index a9a653fbf..6b6afbe90 100644
--- a/src/data.cls.php
+++ b/src/data.cls.php
@@ -8,30 +8,19 @@
* @author LiteSpeed Technologies ' . Utility::readable_time( $is_upgrading ) . '
' ) . ' [LiteSpeed]', true );
+ Admin_Display::info(
+ sprintf(
+ __('The database has been upgrading in the background since %s. This message will disappear once upgrade is complete.', 'litespeed-cache'),
+ '' . Utility::readable_time($is_upgrading) . '
'
+ ) . ' [LiteSpeed]',
+ true
+ );
}
/**
@@ -229,12 +230,12 @@ public function check_upgrading_msg() {
*
* @since 3.0.1
*/
- private function _set_upgrade_lock( $lock ) {
- if ( ! $lock ) {
- update_option( 'litespeed.data.upgrading', -1 );
- }
- else {
- update_option( 'litespeed.data.upgrading', time() );
+ private function _set_upgrade_lock($lock)
+ {
+ if (!$lock) {
+ update_option('litespeed.data.upgrading', -1);
+ } else {
+ update_option('litespeed.data.upgrading', time());
}
}
@@ -246,53 +247,53 @@ private function _set_upgrade_lock( $lock ) {
* @since 3.0
* @access public
*/
- public function try_upgrade_conf_3_0() {
- $previous_options = get_option( 'litespeed-cache-conf' );
- if ( ! $previous_options ) {
- Cloud::version_check( 'new' );
+ public function try_upgrade_conf_3_0()
+ {
+ $previous_options = get_option('litespeed-cache-conf');
+ if (!$previous_options) {
+ Cloud::version_check('new');
return;
}
- $ver = $previous_options[ 'version' ];
+ $ver = $previous_options['version'];
- ! defined( 'LSCWP_CUR_V' ) && define( 'LSCWP_CUR_V', $ver );
+ !defined('LSCWP_CUR_V') && define('LSCWP_CUR_V', $ver);
// Init log manually
- if ( $this->conf( Base::O_DEBUG ) ) {
- $this->cls( 'Debug2' )->init();
+ if ($this->conf(Base::O_DEBUG)) {
+ $this->cls('Debug2')->init();
}
- Debug2::debug( '[Data] Upgrading previous settings [from] ' . $ver . ' [to] v3.0' );
+ Debug2::debug('[Data] Upgrading previous settings [from] ' . $ver . ' [to] v3.0');
- if ( $this->_get_upgrade_lock() ) {
+ if ($this->_get_upgrade_lock()) {
return;
}
- $this->_set_upgrade_lock( true );
+ $this->_set_upgrade_lock(true);
require_once LSCWP_DIR . 'src/data.upgrade.func.php';
// Here inside will update the version to v3.0
- litespeed_update_3_0( $ver );
+ litespeed_update_3_0($ver);
- $this->_set_upgrade_lock( false );
+ $this->_set_upgrade_lock(false);
- Debug2::debug( '[Data] Upgraded to v3.0' );
+ Debug2::debug('[Data] Upgraded to v3.0');
// Upgrade from 3.0 to latest version
$ver = '3.0';
- if ( Core::VER != $ver ) {
- $this->conf_upgrade( $ver );
- }
- else {
+ if (Core::VER != $ver) {
+ $this->conf_upgrade($ver);
+ } else {
// Reload options
- $this->cls( 'Conf' )->load_options();
+ $this->cls('Conf')->load_options();
$this->correct_tb_existance();
- ! defined( 'LSWCP_EMPTYCACHE') && define( 'LSWCP_EMPTYCACHE', true );// clear all sites caches
+ !defined('LSWCP_EMPTYCACHE') && define('LSWCP_EMPTYCACHE', true); // clear all sites caches
Purge::purge_all();
- Cloud::version_check( 'upgrade' );
+ Cloud::version_check('upgrade');
}
}
@@ -302,10 +303,11 @@ public function try_upgrade_conf_3_0() {
* @since 3.0
* @access public
*/
- public function tb( $tb ) {
+ public function tb($tb)
+ {
global $wpdb;
- switch ( $tb ) {
+ switch ($tb) {
case 'img_optm':
return $wpdb->prefix . self::TB_IMG_OPTM;
break;
@@ -337,7 +339,6 @@ public function tb( $tb ) {
default:
break;
}
-
}
/**
@@ -346,9 +347,10 @@ public function tb( $tb ) {
* @since 3.0
* @access public
*/
- public function tb_exist( $tb ) {
+ public function tb_exist($tb)
+ {
global $wpdb;
- return $wpdb->get_var( "SHOW TABLES LIKE '" . $this->tb( $tb ) . "'" );
+ return $wpdb->get_var("SHOW TABLES LIKE '" . $this->tb($tb) . "'");
}
/**
@@ -357,8 +359,9 @@ public function tb_exist( $tb ) {
* @since 2.0
* @access private
*/
- private function _tb_structure( $tb ) {
- return File::read( LSCWP_DIR . 'src/data_structure/' . $tb . '.sql' );
+ private function _tb_structure($tb)
+ {
+ return File::read(LSCWP_DIR . 'src/data_structure/' . $tb . '.sql');
}
/**
@@ -367,29 +370,30 @@ private function _tb_structure( $tb ) {
* @since 3.0
* @access public
*/
- public function tb_create( $tb ) {
+ public function tb_create($tb)
+ {
global $wpdb;
- Debug2::debug2( '[Data] Checking table ' . $tb );
+ Debug2::debug2('[Data] Checking table ' . $tb);
// Check if table exists first
- if ( $this->tb_exist( $tb ) ) {
- Debug2::debug2( '[Data] Existed' );
+ if ($this->tb_exist($tb)) {
+ Debug2::debug2('[Data] Existed');
return;
}
- Debug2::debug( '[Data] Creating ' . $tb );
+ Debug2::debug('[Data] Creating ' . $tb);
$sql = sprintf(
- 'CREATE TABLE IF NOT EXISTS `%1$s` (' . $this->_tb_structure( $tb ) . ') %2$s;',
- $this->tb( $tb ),
+ 'CREATE TABLE IF NOT EXISTS `%1$s` (' . $this->_tb_structure($tb) . ') %2$s;',
+ $this->tb($tb),
$wpdb->get_charset_collate() // 'DEFAULT CHARSET=utf8'
);
- $res = $wpdb->query( $sql );
- if ( $res !== true ) {
- Debug2::debug( '[Data] Warning! Creating table failed!', $sql );
- Admin_Display::error( Error::msg( 'failed_tb_creation', array( '' . $tb . '
', '' . $sql . '
' ) ) );
+ $res = $wpdb->query($sql);
+ if ($res !== true) {
+ Debug2::debug('[Data] Warning! Creating table failed!', $sql);
+ Admin_Display::error(Error::msg('failed_tb_creation', array('' . $tb . '
', '' . $sql . '
')));
}
}
@@ -399,17 +403,18 @@ public function tb_create( $tb ) {
* @since 3.0
* @access public
*/
- public function tb_del( $tb ) {
+ public function tb_del($tb)
+ {
global $wpdb;
- if ( ! $this->tb_exist( $tb ) ) {
+ if (!$this->tb_exist($tb)) {
return;
}
- Debug2::debug( '[Data] Deleting table ' . $tb );
+ Debug2::debug('[Data] Deleting table ' . $tb);
- $q = 'DROP TABLE IF EXISTS ' . $this->tb( $tb );
- $wpdb->query( $q );
+ $q = 'DROP TABLE IF EXISTS ' . $this->tb($tb);
+ $wpdb->query($q);
}
/**
@@ -418,12 +423,13 @@ public function tb_del( $tb ) {
* @since 3.0
* @access public
*/
- public function tables_del() {
- $this->tb_del( 'avatar' );
- $this->tb_del( 'crawler' );
- $this->tb_del( 'crawler_blacklist' );
- $this->tb_del( 'url' );
- $this->tb_del( 'url_file' );
+ public function tables_del()
+ {
+ $this->tb_del('avatar');
+ $this->tb_del('crawler');
+ $this->tb_del('crawler_blacklist');
+ $this->tb_del('url');
+ $this->tb_del('url_file');
// Deleting img_optm only can be done when destroy all optm images
}
@@ -433,10 +439,11 @@ public function tables_del() {
*
* @since 4.0
*/
- public function table_truncate( $tb ) {
+ public function table_truncate($tb)
+ {
global $wpdb;
- $q = 'TRUNCATE TABLE ' . $this->tb( $tb );
- $wpdb->query( $q );
+ $q = 'TRUNCATE TABLE ' . $this->tb($tb);
+ $wpdb->query($q);
}
/**
@@ -444,88 +451,89 @@ public function table_truncate( $tb ) {
*
* @since 4.0
*/
- public function url_file_clean( $file_type ) {
+ public function url_file_clean($file_type)
+ {
global $wpdb;
- $type = $this->_url_file_types[ $file_type ];
- $q = 'DELETE FROM ' . $this->tb( 'url_file' ) . ' WHERE `type` = %d';
- $wpdb->query( $wpdb->prepare( $q, $type ) );
+ $type = $this->_url_file_types[$file_type];
+ $q = 'DELETE FROM ' . $this->tb('url_file') . ' WHERE `type` = %d';
+ $wpdb->query($wpdb->prepare($q, $type));
}
/**
* Generate filename based on URL, if content md5 existed, reuse existing file.
* @since 4.0
*/
- public function save_url( $request_url, $vary, $file_type, $filecon_md5, $path, $mobile = false, $webp = false ) {
+ public function save_url($request_url, $vary, $file_type, $filecon_md5, $path, $mobile = false, $webp = false)
+ {
global $wpdb;
- if ( strlen( $vary ) > 32 ) {
- $vary = md5( $vary );
+ if (strlen($vary) > 32) {
+ $vary = md5($vary);
}
- $type = $this->_url_file_types[ $file_type ];
+ $type = $this->_url_file_types[$file_type];
- $tb_url = $this->tb( 'url' );
- $tb_url_file = $this->tb( 'url_file' );
+ $tb_url = $this->tb('url');
+ $tb_url_file = $this->tb('url_file');
$q = "SELECT * FROM `$tb_url` WHERE url=%s";
- $url_row = $wpdb->get_row( $wpdb->prepare( $q, $request_url ), ARRAY_A );
- if ( ! $url_row ) {
+ $url_row = $wpdb->get_row($wpdb->prepare($q, $request_url), ARRAY_A);
+ if (!$url_row) {
$q = "INSERT INTO `$tb_url` SET url=%s";
- $wpdb->query( $wpdb->prepare( $q, $request_url ) );
+ $wpdb->query($wpdb->prepare($q, $request_url));
$url_id = $wpdb->insert_id;
- }
- else {
- $url_id = $url_row[ 'id' ];
+ } else {
+ $url_id = $url_row['id'];
}
$q = "SELECT * FROM `$tb_url_file` WHERE url_id=%d AND vary=%s AND type=%d AND expired=0";
- $file_row = $wpdb->get_row( $wpdb->prepare( $q, array( $url_id, $vary, $type ) ), ARRAY_A );
+ $file_row = $wpdb->get_row($wpdb->prepare($q, array($url_id, $vary, $type)), ARRAY_A);
// Check if has previous file or not
- if ( $file_row && $file_row[ 'filename' ] == $filecon_md5 ) {
+ if ($file_row && $file_row['filename'] == $filecon_md5) {
return;
}
// If the new $filecon_md5 is marked as expired by previous records, clear those records
$q = "DELETE FROM `$tb_url_file` WHERE filename = %s AND expired > 0";
- $wpdb->query( $wpdb->prepare( $q, $filecon_md5 ) );
+ $wpdb->query($wpdb->prepare($q, $filecon_md5));
// Check if there is any other record used the same filename or not
$q = "SELECT id FROM `$tb_url_file` WHERE filename = %s AND expired = 0 AND id != %d LIMIT 1";
- if ( $file_row && $wpdb->get_var( $wpdb->prepare( $q, array( $file_row[ 'filename' ], $file_row[ 'id' ] ) ) ) ) {
+ if ($file_row && $wpdb->get_var($wpdb->prepare($q, array($file_row['filename'], $file_row['id'])))) {
$q = "UPDATE `$tb_url_file` SET filename=%s WHERE id=%d";
- $wpdb->query( $wpdb->prepare( $q, array( $filecon_md5, $file_row[ 'id' ] ) ) );
+ $wpdb->query($wpdb->prepare($q, array($filecon_md5, $file_row['id'])));
return;
}
// New record needed
$q = "INSERT INTO `$tb_url_file` SET url_id=%d, vary=%s, filename=%s, type=%d, mobile=%d, webp=%d, expired=0";
- $wpdb->query( $wpdb->prepare( $q, array( $url_id, $vary, $filecon_md5, $type, $mobile?1:0, $webp?1:0 ) ) );
+ $wpdb->query($wpdb->prepare($q, array($url_id, $vary, $filecon_md5, $type, $mobile ? 1 : 0, $webp ? 1 : 0)));
// Mark existing rows as expired
- if ( $file_row ) {
+ if ($file_row) {
$q = "UPDATE `$tb_url_file` SET expired=%d WHERE id=%d";
- $expired = time() + 86400 * apply_filters( 'litespeed_url_file_expired_days', 20 );
- $wpdb->query( $wpdb->prepare( $q, array( $expired, $file_row[ 'id' ] ) ) );
+ $expired = time() + 86400 * apply_filters('litespeed_url_file_expired_days', 20);
+ $wpdb->query($wpdb->prepare($q, array($expired, $file_row['id'])));
// Also check if has other files expired already to be deleted
$q = "SELECT * FROM `$tb_url_file` WHERE url_id = %d AND expired BETWEEN 1 AND %d";
- $q = $wpdb->prepare( $q, array( $url_id, time() ) );
- $list = $wpdb->get_results( $q, ARRAY_A );
- if ( $list ) {
- foreach ( $list as $v ) {
- $file_to_del = $path . '/' . $v[ 'filename' ] . '.' . ( $file_type == 'js' ? 'js' : 'css' );
- if ( file_exists( $file_to_del ) ) {
+ $q = $wpdb->prepare($q, array($url_id, time()));
+ $list = $wpdb->get_results($q, ARRAY_A);
+ if ($list) {
+ foreach ($list as $v) {
+ $file_to_del = $path . '/' . $v['filename'] . '.' . ($file_type == 'js' ? 'js' : 'css');
+ if (file_exists($file_to_del)) {
// Safe to delete
- Debug2::debug( '[Data] Delete expired unused file: ' . $file_to_del );
+ Debug2::debug('[Data] Delete expired unused file: ' . $file_to_del);
// Clear related lscache first to avoid cache copy of same URL w/ diff QS
// Purge::add( Tag::TYPE_MIN . '.' . $file_row[ 'filename' ] . '.' . $file_type );
- unlink( $file_to_del );
+ unlink($file_to_del);
}
}
$q = "DELETE FROM `$tb_url_file` WHERE url_id = %d AND expired BETWEEN 1 AND %d";
- $wpdb->query( $wpdb->prepare( $q, array( $url_id, time() ) ) );
+ $wpdb->query($wpdb->prepare($q, array($url_id, time())));
}
}
@@ -537,65 +545,67 @@ public function save_url( $request_url, $vary, $file_type, $filecon_md5, $path,
* Load CCSS related file
* @since 4.0
*/
- public function load_url_file( $request_url, $vary, $file_type ) {
+ public function load_url_file($request_url, $vary, $file_type)
+ {
global $wpdb;
- if ( strlen( $vary ) > 32 ) {
- $vary = md5( $vary );
+ if (strlen($vary) > 32) {
+ $vary = md5($vary);
}
- $type = $this->_url_file_types[ $file_type ];
+ $type = $this->_url_file_types[$file_type];
- self::debug2( 'load url file: ' . $request_url );
+ self::debug2('load url file: ' . $request_url);
- $tb_url = $this->tb( 'url' );
+ $tb_url = $this->tb('url');
$q = "SELECT * FROM `$tb_url` WHERE url=%s";
- $url_row = $wpdb->get_row( $wpdb->prepare( $q, $request_url ), ARRAY_A );
- if ( ! $url_row ) {
+ $url_row = $wpdb->get_row($wpdb->prepare($q, $request_url), ARRAY_A);
+ if (!$url_row) {
return false;
}
- $url_id = $url_row[ 'id' ];
+ $url_id = $url_row['id'];
- $tb_url_file = $this->tb( 'url_file' );
+ $tb_url_file = $this->tb('url_file');
$q = "SELECT * FROM `$tb_url_file` WHERE url_id=%d AND vary=%s AND type=%d AND expired=0";
- $file_row = $wpdb->get_row( $wpdb->prepare( $q, array( $url_id, $vary, $type ) ), ARRAY_A );
- if ( ! $file_row ) {
+ $file_row = $wpdb->get_row($wpdb->prepare($q, array($url_id, $vary, $type)), ARRAY_A);
+ if (!$file_row) {
return false;
}
- return $file_row[ 'filename' ];
+ return $file_row['filename'];
}
/**
* Mark all entries of one URL to expired
* @since 4.5
*/
- public function mark_as_expired( $request_url, $auto_q = false ) {
+ public function mark_as_expired($request_url, $auto_q = false)
+ {
global $wpdb;
- Debug2::debug( '[Data] Try to mark as expired: ' . $request_url );
- $tb_url = $this->tb( 'url' );
+ Debug2::debug('[Data] Try to mark as expired: ' . $request_url);
+ $tb_url = $this->tb('url');
$q = "SELECT * FROM `$tb_url` WHERE url=%s";
- $url_row = $wpdb->get_row( $wpdb->prepare( $q, $request_url ), ARRAY_A );
- if ( ! $url_row ) {
+ $url_row = $wpdb->get_row($wpdb->prepare($q, $request_url), ARRAY_A);
+ if (!$url_row) {
return;
}
- Debug2::debug( '[Data] Mark url_id=' . $url_row[ 'id' ] . ' as expired' );
+ Debug2::debug('[Data] Mark url_id=' . $url_row['id'] . ' as expired');
- $tb_url = $this->tb( 'url' );
- $tb_url_file = $this->tb( 'url_file' );
+ $tb_url = $this->tb('url');
+ $tb_url_file = $this->tb('url_file');
$existing_url_files = array();
- if ( $auto_q ) {
+ if ($auto_q) {
$q = "SELECT a.*, b.url FROM `$tb_url_file` a LEFT JOIN `$tb_url` b ON b.id=a.url_id WHERE a.url_id=%d AND a.type=4 AND a.expired=0";
- $q = $wpdb->prepare( $q, $url_row[ 'id' ] );
- $existing_url_files = $wpdb->get_results( $q, ARRAY_A );
+ $q = $wpdb->prepare($q, $url_row['id']);
+ $existing_url_files = $wpdb->get_results($q, ARRAY_A);
}
$q = "UPDATE `$tb_url_file` SET expired=%d WHERE url_id=%d AND type=4 AND expired=0";
- $expired = time() + 86400 * apply_filters( 'litespeed_url_file_expired_days', 20 );
- $wpdb->query( $wpdb->prepare( $q, array( $expired, $url_row[ 'id' ] ) ) );
+ $expired = time() + 86400 * apply_filters('litespeed_url_file_expired_days', 20);
+ $wpdb->query($wpdb->prepare($q, array($expired, $url_row['id'])));
return $existing_url_files;
}
@@ -605,10 +615,11 @@ public function mark_as_expired( $request_url, $auto_q = false ) {
*
* @since 3.6
*/
- public function load_css_exc( $list ) {
- $data = $this->_load_per_line( 'css_excludes.txt' );
- if ( $data ) {
- $list = array_unique( array_filter( array_merge( $list, $data ) ) );
+ public function load_css_exc($list)
+ {
+ $data = $this->_load_per_line('css_excludes.txt');
+ if ($data) {
+ $list = array_unique(array_filter(array_merge($list, $data)));
}
return $list;
@@ -619,10 +630,11 @@ public function load_css_exc( $list ) {
*
* @since 4.0
*/
- public function load_ucss_whitelist( $list ) {
- $data = $this->_load_per_line( 'ucss_whitelist.txt' );
- if ( $data ) {
- $list = array_unique( array_filter( array_merge( $list, $data ) ) );
+ public function load_ucss_whitelist($list)
+ {
+ $data = $this->_load_per_line('ucss_whitelist.txt');
+ if ($data) {
+ $list = array_unique(array_filter(array_merge($list, $data)));
}
return $list;
@@ -633,10 +645,11 @@ public function load_ucss_whitelist( $list ) {
*
* @since 3.5
*/
- public function load_js_exc( $list ) {
- $data = $this->_load_per_line( 'js_excludes.txt' );
- if ( $data ) {
- $list = array_unique( array_filter( array_merge( $list, $data ) ) );
+ public function load_js_exc($list)
+ {
+ $data = $this->_load_per_line('js_excludes.txt');
+ if ($data) {
+ $list = array_unique(array_filter(array_merge($list, $data)));
}
return $list;
@@ -647,10 +660,11 @@ public function load_js_exc( $list ) {
*
* @since 3.6
*/
- public function load_js_defer_exc( $list ) {
- $data = $this->_load_per_line( 'js_defer_excludes.txt' );
- if ( $data ) {
- $list = array_unique( array_filter( array_merge( $list, $data ) ) );
+ public function load_js_defer_exc($list)
+ {
+ $data = $this->_load_per_line('js_defer_excludes.txt');
+ if ($data) {
+ $list = array_unique(array_filter(array_merge($list, $data)));
}
return $list;
@@ -661,10 +675,11 @@ public function load_js_defer_exc( $list ) {
*
* @since 5.4
*/
- public function load_optm_uri_exc( $list ) {
- $data = $this->_load_per_line( 'optm_uri_exc.txt' );
- if ( $data ) {
- $list = array_unique( array_filter( array_merge( $list, $data ) ) );
+ public function load_optm_uri_exc($list)
+ {
+ $data = $this->_load_per_line('optm_uri_exc.txt');
+ if ($data) {
+ $list = array_unique(array_filter(array_merge($list, $data)));
}
return $list;
@@ -675,10 +690,11 @@ public function load_optm_uri_exc( $list ) {
*
* @since 3.5
*/
- public function load_esi_nonces( $list ) {
- $data = $this->_load_per_line( 'esi.nonces.txt' );
- if ( $data ) {
- $list = array_unique( array_filter( array_merge( $list, $data ) ) );
+ public function load_esi_nonces($list)
+ {
+ $data = $this->_load_per_line('esi.nonces.txt');
+ if ($data) {
+ $list = array_unique(array_filter(array_merge($list, $data)));
}
return $list;
@@ -693,20 +709,21 @@ public function load_esi_nonces( $list ) {
*
* @since 3.5
*/
- private function _load_per_line( $file ) {
- $data = File::read( LSCWP_DIR . 'data/' . $file );
- $data = explode( PHP_EOL, $data );
+ private function _load_per_line($file)
+ {
+ $data = File::read(LSCWP_DIR . 'data/' . $file);
+ $data = explode(PHP_EOL, $data);
$list = array();
- foreach ( $data as $v ) {
+ foreach ($data as $v) {
// Drop two kinds of comments
- if ( strpos( $v, '##' ) !== false ) {
- $v = trim( substr( $v, 0, strpos( $v, '##' ) ) );
+ if (strpos($v, '##') !== false) {
+ $v = trim(substr($v, 0, strpos($v, '##')));
}
- if ( strpos( $v, '# ' ) !== false ) {
- $v = trim( substr( $v, 0, strpos( $v, '# ' ) ) );
+ if (strpos($v, '# ') !== false) {
+ $v = trim(substr($v, 0, strpos($v, '# ')));
}
- if ( ! $v ) {
+ if (!$v) {
continue;
}
@@ -715,5 +732,4 @@ private function _load_per_line( $file ) {
return $list;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/data.upgrade.func.php b/src/data.upgrade.func.php
index 0d79ecde3..60cff570a 100644
--- a/src/data.upgrade.func.php
+++ b/src/data.upgrade.func.php
@@ -6,7 +6,7 @@
*
* @since 3.0
*/
-defined( 'WPINC' ) || exit;
+defined('WPINC') || exit();
use LiteSpeed\Debug2;
use LiteSpeed\Conf;
@@ -17,16 +17,20 @@
* Append webp/mobile to url_file
* @since 5.3
*/
-function litespeed_update_5_3() {
+function litespeed_update_5_3()
+{
global $wpdb;
- Debug2::debug( "[Data] Upgrade url_file table" );
- $tb_exists = $wpdb->get_var( 'SHOW TABLES LIKE "' . $wpdb->prefix . 'litespeed_url_file"' );
- if ( $tb_exists ) {
- $q = 'ALTER TABLE `' . $wpdb->prefix . 'litespeed_url_file`
+ Debug2::debug('[Data] Upgrade url_file table');
+ $tb_exists = $wpdb->get_var('SHOW TABLES LIKE "' . $wpdb->prefix . 'litespeed_url_file"');
+ if ($tb_exists) {
+ $q =
+ 'ALTER TABLE `' .
+ $wpdb->prefix .
+ 'litespeed_url_file`
ADD COLUMN `mobile` tinyint(4) NOT NULL COMMENT "mobile=1",
ADD COLUMN `webp` tinyint(4) NOT NULL COMMENT "webp=1"
';
- $wpdb->query( $q );
+ $wpdb->query($q);
}
}
@@ -34,17 +38,21 @@ function litespeed_update_5_3() {
* Add expired to url_file table
* @since 4.4.4
*/
-function litespeed_update_4_4_4() {
+function litespeed_update_4_4_4()
+{
global $wpdb;
- Debug2::debug( "[Data] Upgrade url_file table" );
- $tb_exists = $wpdb->get_var( 'SHOW TABLES LIKE "' . $wpdb->prefix . 'litespeed_url_file"' );
- if ( $tb_exists ) {
- $q = 'ALTER TABLE `' . $wpdb->prefix . 'litespeed_url_file`
+ Debug2::debug('[Data] Upgrade url_file table');
+ $tb_exists = $wpdb->get_var('SHOW TABLES LIKE "' . $wpdb->prefix . 'litespeed_url_file"');
+ if ($tb_exists) {
+ $q =
+ 'ALTER TABLE `' .
+ $wpdb->prefix .
+ 'litespeed_url_file`
ADD COLUMN `expired` int(11) NOT NULL DEFAULT 0,
ADD KEY `filename_2` (`filename`,`expired`),
ADD KEY `url_id` (`url_id`,`expired`)
';
- $wpdb->query( $q );
+ $wpdb->query($q);
}
}
@@ -52,9 +60,10 @@ function litespeed_update_4_4_4() {
* Drop cssjs table and rm cssjs folder
* @since 4.3
*/
-function litespeed_update_4_3() {
- if ( file_exists( LITESPEED_STATIC_DIR . '/ccsjs' ) ) {
- File::rrmdir( LITESPEED_STATIC_DIR . '/ccsjs' );
+function litespeed_update_4_3()
+{
+ if (file_exists(LITESPEED_STATIC_DIR . '/ccsjs')) {
+ File::rrmdir(LITESPEED_STATIC_DIR . '/ccsjs');
}
}
@@ -62,9 +71,10 @@ function litespeed_update_4_3() {
* Drop object cache data file
* @since 4.1
*/
-function litespeed_update_4_1() {
- if ( file_exists( WP_CONTENT_DIR . '/.object-cache.ini' ) ) {
- unlink( WP_CONTENT_DIR . '/.object-cache.ini' );
+function litespeed_update_4_1()
+{
+ if (file_exists(WP_CONTENT_DIR . '/.object-cache.ini')) {
+ unlink(WP_CONTENT_DIR . '/.object-cache.ini');
}
}
@@ -72,19 +82,20 @@ function litespeed_update_4_1() {
* Drop cssjs table and rm cssjs folder
* @since 4.0
*/
-function litespeed_update_4() {
+function litespeed_update_4()
+{
global $wpdb;
$tb = $wpdb->prefix . 'litespeed_cssjs';
- $existed = $wpdb->get_var( "SHOW TABLES LIKE '$tb'" );
- if ( ! $existed ) {
+ $existed = $wpdb->get_var("SHOW TABLES LIKE '$tb'");
+ if (!$existed) {
return;
}
$q = 'DROP TABLE IF EXISTS ' . $tb;
- $wpdb->query( $q );
+ $wpdb->query($q);
- if ( file_exists( LITESPEED_STATIC_DIR . '/ccsjs' ) ) {
- File::rrmdir( LITESPEED_STATIC_DIR . '/ccsjs' );
+ if (file_exists(LITESPEED_STATIC_DIR . '/ccsjs')) {
+ File::rrmdir(LITESPEED_STATIC_DIR . '/ccsjs');
}
}
@@ -94,30 +105,38 @@ function litespeed_update_4() {
*
* @since 3.5.1
*/
-function litespeed_update_3_5() {
+function litespeed_update_3_5()
+{
$__conf = Conf::cls();
// Excludes jQuery
- foreach ( array( 'optm-js_exc', 'optm-js_defer_exc' ) as $v ) {
- $curr_setting = $__conf->conf( $v );
+ foreach (array('optm-js_exc', 'optm-js_defer_exc') as $v) {
+ $curr_setting = $__conf->conf($v);
$curr_setting[] = 'jquery.js';
$curr_setting[] = 'jquery.min.js';
- $__conf->update( $v, $curr_setting );
+ $__conf->update($v, $curr_setting);
}
// Turn off JS Combine and defer
$show_msg = false;
- foreach ( array( 'optm-js_comb', 'optm-js_defer', 'optm-js_inline_defer' ) as $v ) {
- $curr_setting = $__conf->conf( $v );
- if ( ! $curr_setting ) {
+ foreach (array('optm-js_comb', 'optm-js_defer', 'optm-js_inline_defer') as $v) {
+ $curr_setting = $__conf->conf($v);
+ if (!$curr_setting) {
continue;
}
$show_msg = true;
- $__conf->update( $v, false );
+ $__conf->update($v, false);
}
- if ( $show_msg ) {
- $msg = sprintf( __( 'LiteSpeed Cache upgraded successfully. NOTE: Due to changes in this version, the settings %1$s and %2$s have been turned OFF. Please turn them back on manually and verify that your site layout is correct, and you have no JS errors.', 'litespeed-cache' ), '' . __( 'JS Combine', 'litespeed-cache' ) . '
', '' . __( 'JS Defer', 'litespeed-cache' ) . '
' );
- $msg .= sprintf( ' %s.', __( 'Click here to settings', 'litespeed-cache' ) );
- Admin_Display::info( $msg, false, true );
+ if ($show_msg) {
+ $msg = sprintf(
+ __(
+ 'LiteSpeed Cache upgraded successfully. NOTE: Due to changes in this version, the settings %1$s and %2$s have been turned OFF. Please turn them back on manually and verify that your site layout is correct, and you have no JS errors.',
+ 'litespeed-cache'
+ ),
+ '' . __('JS Combine', 'litespeed-cache') . '
',
+ '' . __('JS Defer', 'litespeed-cache') . '
'
+ );
+ $msg .= sprintf(' %s.', __('Click here to settings', 'litespeed-cache'));
+ Admin_Display::info($msg, false, true);
}
}
@@ -126,327 +145,318 @@ function litespeed_update_3_5() {
*
* @since 3.0
*/
-function litespeed_update_2_0( $ver ) {
- global $wpdb ;
+function litespeed_update_2_0($ver)
+{
+ global $wpdb;
// Table version only exists after all old data migrated
// Last modified is v2.4.2
- if ( version_compare( $ver, '2.4.2', '<' ) ) {
+ if (version_compare($ver, '2.4.2', '<')) {
/**
* Convert old data from postmeta to img_optm table
* @since 2.0
*/
// Migrate data from `wp_postmeta` to `wp_litespeed_img_optm`
- $mids_to_del = array() ;
- $q = "SELECT * FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_id" ;
- $meta_value_list = $wpdb->get_results( $wpdb->prepare( $q, 'litespeed-optimize-data' ) ) ;
- if ( $meta_value_list ) {
- $max_k = count( $meta_value_list ) - 1 ;
- foreach ( $meta_value_list as $k => $v ) {
- $md52src_list = maybe_unserialize( $v->meta_value ) ;
- foreach ( $md52src_list as $md5 => $v2 ) {
+ $mids_to_del = array();
+ $q = "SELECT * FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_id";
+ $meta_value_list = $wpdb->get_results($wpdb->prepare($q, 'litespeed-optimize-data'));
+ if ($meta_value_list) {
+ $max_k = count($meta_value_list) - 1;
+ foreach ($meta_value_list as $k => $v) {
+ $md52src_list = maybe_unserialize($v->meta_value);
+ foreach ($md52src_list as $md5 => $v2) {
$f = array(
- 'post_id' => $v->post_id,
- 'optm_status' => $v2[ 1 ],
- 'src' => $v2[ 0 ],
- 'srcpath_md5' => md5( $v2[ 0 ] ),
- 'src_md5' => $md5,
- 'server' => $v2[ 2 ],
- ) ;
- $wpdb->replace( $wpdb->prefix . 'litespeed_img_optm', $f ) ;
+ 'post_id' => $v->post_id,
+ 'optm_status' => $v2[1],
+ 'src' => $v2[0],
+ 'srcpath_md5' => md5($v2[0]),
+ 'src_md5' => $md5,
+ 'server' => $v2[2],
+ );
+ $wpdb->replace($wpdb->prefix . 'litespeed_img_optm', $f);
}
- $mids_to_del[] = $v->meta_id ;
+ $mids_to_del[] = $v->meta_id;
// Delete from postmeta
- if ( count( $mids_to_del ) > 100 || $k == $max_k ) {
- $q = "DELETE FROM $wpdb->postmeta WHERE meta_id IN ( " . implode( ',', array_fill( 0, count( $mids_to_del ), '%s' ) ) . " ) " ;
- $wpdb->query( $wpdb->prepare( $q, $mids_to_del ) ) ;
+ if (count($mids_to_del) > 100 || $k == $max_k) {
+ $q = "DELETE FROM $wpdb->postmeta WHERE meta_id IN ( " . implode(',', array_fill(0, count($mids_to_del), '%s')) . ' ) ';
+ $wpdb->query($wpdb->prepare($q, $mids_to_del));
- $mids_to_del = array() ;
+ $mids_to_del = array();
}
}
- Debug2::debug( '[Data] img_optm inserted records: ' . $k ) ;
+ Debug2::debug('[Data] img_optm inserted records: ' . $k);
}
- $q = "DELETE FROM $wpdb->postmeta WHERE meta_key = %s" ;
- $rows = $wpdb->query( $wpdb->prepare( $q, 'litespeed-optimize-status' ) ) ;
- Debug2::debug( '[Data] img_optm delete optm_status records: ' . $rows ) ;
-
+ $q = "DELETE FROM $wpdb->postmeta WHERE meta_key = %s";
+ $rows = $wpdb->query($wpdb->prepare($q, 'litespeed-optimize-status'));
+ Debug2::debug('[Data] img_optm delete optm_status records: ' . $rows);
}
/**
* Add target_md5 field to table
* @since 2.4.2
*/
- if ( version_compare( $ver, '2.4.2', '<' ) && version_compare( $ver, '2.0', '>=' ) ) {// NOTE: For new users, need to bypass this section
- $sql = sprintf(
- 'ALTER TABLE `%1$s` ADD `server_info` text NOT NULL, DROP COLUMN `server`',
- $wpdb->prefix . 'litespeed_img_optm'
- ) ;
-
- $res = $wpdb->query( $sql ) ;
- if ( $res !== true ) {
- Debug2::debug( '[Data] Warning: Alter table img_optm failed!', $sql ) ;
+ if (version_compare($ver, '2.4.2', '<') && version_compare($ver, '2.0', '>=')) {
+ // NOTE: For new users, need to bypass this section
+ $sql = sprintf('ALTER TABLE `%1$s` ADD `server_info` text NOT NULL, DROP COLUMN `server`', $wpdb->prefix . 'litespeed_img_optm');
+
+ $res = $wpdb->query($sql);
+ if ($res !== true) {
+ Debug2::debug('[Data] Warning: Alter table img_optm failed!', $sql);
+ } else {
+ Debug2::debug('[Data] Successfully upgraded table img_optm.');
}
- else {
- Debug2::debug( '[Data] Successfully upgraded table img_optm.' ) ;
- }
-
}
// Delete img optm tb version
- delete_option( $wpdb->prefix . 'litespeed_img_optm' ) ;
-
+ delete_option($wpdb->prefix . 'litespeed_img_optm');
// Delete possible HTML optm data from wp_options
- delete_option( 'litespeed-cache-optimized' ) ;
+ delete_option('litespeed-cache-optimized');
// Delete HTML optm tb version
- delete_option( $wpdb->prefix . 'litespeed_optimizer' ) ;
-
+ delete_option($wpdb->prefix . 'litespeed_optimizer');
}
-
-
/**
* Move all options in litespeed-cache-conf from v3.0- to separate records
*
* @since 3.0
*/
-function litespeed_update_3_0( $ver ) {
+function litespeed_update_3_0($ver)
+{
global $wpdb;
// Upgrade v2.0- to v2.0 first
- if ( version_compare( $ver, '2.0', '<' ) ) {
- litespeed_update_2_0( $ver ) ;
+ if (version_compare($ver, '2.0', '<')) {
+ litespeed_update_2_0($ver);
}
- set_time_limit( 86400 );
+ set_time_limit(86400);
// conv items to litespeed.conf.*
- Debug2::debug( "[Data] Conv items to litespeed.conf.*" );
+ Debug2::debug('[Data] Conv items to litespeed.conf.*');
$data = array(
- 'litespeed-cache-exclude-cache-roles' => 'cache-exc_roles',
- 'litespeed-cache-drop_qs' => 'cache-drop_qs',
- 'litespeed-forced_cache_uri' => 'cache-force_uri',
- 'litespeed-cache_uri_priv' => 'cache-priv_uri',
- 'litespeed-excludes_uri' => 'cache-exc',
- 'litespeed-cache-vary-group' => 'cache-vary_group',
- 'litespeed-adv-purge_all_hooks' => 'purge-hook_all',
- 'litespeed-object_global_groups' => 'object-global_groups',
- 'litespeed-object_non_persistent_groups' => 'object-non_persistent_groups',
- 'litespeed-media-lazy-img-excludes' => 'media-lazy_exc',
- 'litespeed-media-lazy-img-cls-excludes' => 'media-lazy_cls_exc',
- 'litespeed-media-webp_attribute' => 'img_optm-webp_attr',
- 'litespeed-optm-css' => 'optm-ccss_con',
- 'litespeed-optm_excludes' => 'optm-exc',
- 'litespeed-optm-ccss-separate_posttype' => 'optm-ccss_sep_posttype',
- 'litespeed-optm-css-separate_uri' => 'optm-ccss_sep_uri',
- 'litespeed-optm-js-defer-excludes' => 'optm-js_defer_exc',
- 'litespeed-cache-dns_prefetch' => 'optm-dns_prefetch',
+ 'litespeed-cache-exclude-cache-roles' => 'cache-exc_roles',
+ 'litespeed-cache-drop_qs' => 'cache-drop_qs',
+ 'litespeed-forced_cache_uri' => 'cache-force_uri',
+ 'litespeed-cache_uri_priv' => 'cache-priv_uri',
+ 'litespeed-excludes_uri' => 'cache-exc',
+ 'litespeed-cache-vary-group' => 'cache-vary_group',
+ 'litespeed-adv-purge_all_hooks' => 'purge-hook_all',
+ 'litespeed-object_global_groups' => 'object-global_groups',
+ 'litespeed-object_non_persistent_groups' => 'object-non_persistent_groups',
+ 'litespeed-media-lazy-img-excludes' => 'media-lazy_exc',
+ 'litespeed-media-lazy-img-cls-excludes' => 'media-lazy_cls_exc',
+ 'litespeed-media-webp_attribute' => 'img_optm-webp_attr',
+ 'litespeed-optm-css' => 'optm-ccss_con',
+ 'litespeed-optm_excludes' => 'optm-exc',
+ 'litespeed-optm-ccss-separate_posttype' => 'optm-ccss_sep_posttype',
+ 'litespeed-optm-css-separate_uri' => 'optm-ccss_sep_uri',
+ 'litespeed-optm-js-defer-excludes' => 'optm-js_defer_exc',
+ 'litespeed-cache-dns_prefetch' => 'optm-dns_prefetch',
'litespeed-cache-exclude-optimization-roles' => 'optm-exc_roles',
- 'litespeed-log_ignore_filters' => 'debug-log_no_filters', // depreciated
- 'litespeed-log_ignore_part_filters' => 'debug-log_no_part_filters', // depreciated
- 'litespeed-cdn-ori_dir' => 'cdn-ori_dir',
- 'litespeed-cache-cdn_mapping' => 'cdn-mapping',
- 'litespeed-crawler-as-uids' => 'crawler-roles',
- 'litespeed-crawler-cookies' => 'crawler-cookies',
- ) ;
- foreach ( $data as $k => $v ) {
- $old_data = get_option( $k ) ;
- if ( $old_data ) {
- Debug2::debug( "[Data] Convert $k" );
+ 'litespeed-log_ignore_filters' => 'debug-log_no_filters', // depreciated
+ 'litespeed-log_ignore_part_filters' => 'debug-log_no_part_filters', // depreciated
+ 'litespeed-cdn-ori_dir' => 'cdn-ori_dir',
+ 'litespeed-cache-cdn_mapping' => 'cdn-mapping',
+ 'litespeed-crawler-as-uids' => 'crawler-roles',
+ 'litespeed-crawler-cookies' => 'crawler-cookies',
+ );
+ foreach ($data as $k => $v) {
+ $old_data = get_option($k);
+ if ($old_data) {
+ Debug2::debug("[Data] Convert $k");
// They must be an array
- if ( ! is_array( $old_data ) && $v != 'optm-ccss_con' ) {
- $old_data = explode( "\n", $old_data ) ;
+ if (!is_array($old_data) && $v != 'optm-ccss_con') {
+ $old_data = explode("\n", $old_data);
}
- if ( $v == 'crawler-cookies' ) {
- $tmp = array() ;
- $i = 0 ;
- foreach ( $old_data as $k2 => $v2 ) {
- $tmp[ $i ][ 'name' ] = $k2 ;
- $tmp[ $i ][ 'vals' ] = explode( "\n", $v2 ) ;
- $i ++ ;
+ if ($v == 'crawler-cookies') {
+ $tmp = array();
+ $i = 0;
+ foreach ($old_data as $k2 => $v2) {
+ $tmp[$i]['name'] = $k2;
+ $tmp[$i]['vals'] = explode("\n", $v2);
+ $i++;
}
- $old_data = $tmp ;
+ $old_data = $tmp;
}
- add_option( 'litespeed.conf.' . $v, $old_data ) ;
+ add_option('litespeed.conf.' . $v, $old_data);
}
- Debug2::debug( "[Data] Delete $k" );
- delete_option( $k ) ;
+ Debug2::debug("[Data] Delete $k");
+ delete_option($k);
}
// conv other items
$data = array(
- 'litespeed-setting-mode' => 'litespeed.setting.mode',
- 'litespeed-media-need-pull' => 'litespeed.img_optm.need_pull',
- 'litespeed-env-ref' => 'litespeed.env.ref',
+ 'litespeed-setting-mode' => 'litespeed.setting.mode',
+ 'litespeed-media-need-pull' => 'litespeed.img_optm.need_pull',
+ 'litespeed-env-ref' => 'litespeed.env.ref',
'litespeed-cache-cloudflare_status' => 'litespeed.cdn.cloudflare.status',
-
- ) ;
- foreach ( $data as $k => $v ) {
- $old_data = get_option( $k ) ;
- if ( $old_data ) {
- add_option( $v, $old_data ) ;
+ );
+ foreach ($data as $k => $v) {
+ $old_data = get_option($k);
+ if ($old_data) {
+ add_option($v, $old_data);
}
- delete_option( $k ) ;
+ delete_option($k);
}
// Conv conf from litespeed-cache-conf child to litespeed.conf.*
- Debug2::debug( "[Data] Conv conf from litespeed-cache-conf child to litespeed.conf.*" );
- $previous_options = get_option( 'litespeed-cache-conf' ) ;
+ Debug2::debug('[Data] Conv conf from litespeed-cache-conf child to litespeed.conf.*');
+ $previous_options = get_option('litespeed-cache-conf');
$data = array(
- 'radio_select' => 'cache',
- 'hash' => 'hash',
- 'auto_upgrade' => 'auto_upgrade',
- 'news' => 'news',
- 'crawler_domain_ip' => 'server_ip',
-
- 'esi_enabled' => 'esi',
- 'esi_cached_admbar' => 'esi-cache_admbar',
- 'esi_cached_commform' => 'esi-cache_commform',
-
- 'heartbeat' => 'misc-heartbeat_front',
-
- 'cache_browser' => 'cache-browser',
- 'cache_browser_ttl' => 'cache-ttl_browser',
- 'instant_click' => 'util-instant_click',
- 'use_http_for_https_vary' => 'util-no_https_vary',
-
- 'purge_upgrade' => 'purge-upgrade',
- 'timed_urls' => 'purge-timed_urls',
- 'timed_urls_time' => 'purge-timed_urls_time',
-
- 'cache_priv' => 'cache-priv',
- 'cache_commenter' => 'cache-commenter',
- 'cache_rest' => 'cache-rest',
- 'cache_page_login' => 'cache-page_login',
- 'cache_favicon' => 'cache-favicon',
- 'cache_resources' => 'cache-resources',
- 'mobileview_enabled' => 'cache-mobile',
- 'mobileview_rules' => 'cache-mobile_rules',
- 'nocache_useragents' => 'cache-exc_useragents',
- 'nocache_cookies' => 'cache-exc_cookies',
- 'excludes_qs' => 'cache-exc_qs',
- 'excludes_cat' => 'cache-exc_cat',
- 'excludes_tag' => 'cache-exc_tag',
- 'public_ttl' => 'cache-ttl_pub',
- 'private_ttl' => 'cache-ttl_priv',
- 'front_page_ttl' => 'cache-ttl_frontpage',
- 'feed_ttl' => 'cache-ttl_feed',
- 'login_cookie' => 'cache-login_cookie',
-
- 'debug_disable_all' => 'debug-disable_all',
- 'debug' => 'debug',
- 'admin_ips' => 'debug-ips',
- 'debug_level' => 'debug-level',
- 'log_file_size' => 'debug-filesize',
- 'debug_cookie' => 'debug-cookie',
- 'collaps_qs' => 'debug-collaps_qs',
+ 'radio_select' => 'cache',
+ 'hash' => 'hash',
+ 'auto_upgrade' => 'auto_upgrade',
+ 'news' => 'news',
+ 'crawler_domain_ip' => 'server_ip',
+
+ 'esi_enabled' => 'esi',
+ 'esi_cached_admbar' => 'esi-cache_admbar',
+ 'esi_cached_commform' => 'esi-cache_commform',
+
+ 'heartbeat' => 'misc-heartbeat_front',
+
+ 'cache_browser' => 'cache-browser',
+ 'cache_browser_ttl' => 'cache-ttl_browser',
+ 'instant_click' => 'util-instant_click',
+ 'use_http_for_https_vary' => 'util-no_https_vary',
+
+ 'purge_upgrade' => 'purge-upgrade',
+ 'timed_urls' => 'purge-timed_urls',
+ 'timed_urls_time' => 'purge-timed_urls_time',
+
+ 'cache_priv' => 'cache-priv',
+ 'cache_commenter' => 'cache-commenter',
+ 'cache_rest' => 'cache-rest',
+ 'cache_page_login' => 'cache-page_login',
+ 'cache_favicon' => 'cache-favicon',
+ 'cache_resources' => 'cache-resources',
+ 'mobileview_enabled' => 'cache-mobile',
+ 'mobileview_rules' => 'cache-mobile_rules',
+ 'nocache_useragents' => 'cache-exc_useragents',
+ 'nocache_cookies' => 'cache-exc_cookies',
+ 'excludes_qs' => 'cache-exc_qs',
+ 'excludes_cat' => 'cache-exc_cat',
+ 'excludes_tag' => 'cache-exc_tag',
+ 'public_ttl' => 'cache-ttl_pub',
+ 'private_ttl' => 'cache-ttl_priv',
+ 'front_page_ttl' => 'cache-ttl_frontpage',
+ 'feed_ttl' => 'cache-ttl_feed',
+ 'login_cookie' => 'cache-login_cookie',
+
+ 'debug_disable_all' => 'debug-disable_all',
+ 'debug' => 'debug',
+ 'admin_ips' => 'debug-ips',
+ 'debug_level' => 'debug-level',
+ 'log_file_size' => 'debug-filesize',
+ 'debug_cookie' => 'debug-cookie',
+ 'collaps_qs' => 'debug-collaps_qs',
// 'log_filters' => 'debug-log_filters',
- 'crawler_cron_active' => 'crawler',
+ 'crawler_cron_active' => 'crawler',
// 'crawler_include_posts' => 'crawler-inc_posts',
// 'crawler_include_pages' => 'crawler-inc_pages',
// 'crawler_include_cats' => 'crawler-inc_cats',
// 'crawler_include_tags' => 'crawler-inc_tags',
// 'crawler_excludes_cpt' => 'crawler-exc_cpt',
// 'crawler_order_links' => 'crawler-order_links',
- 'crawler_usleep' => 'crawler-usleep',
- 'crawler_run_duration' => 'crawler-run_duration',
- 'crawler_run_interval' => 'crawler-run_interval',
- 'crawler_crawl_interval' => 'crawler-crawl_interval',
- 'crawler_threads' => 'crawler-threads',
- 'crawler_load_limit' => 'crawler-load_limit',
- 'crawler_custom_sitemap' => 'crawler-sitemap',
-
- 'cache_object' => 'object',
- 'cache_object_kind' => 'object-kind',
- 'cache_object_host' => 'object-host',
- 'cache_object_port' => 'object-port',
- 'cache_object_life' => 'object-life',
- 'cache_object_persistent' => 'object-persistent',
- 'cache_object_admin' => 'object-admin',
- 'cache_object_transients' => 'object-transients',
- 'cache_object_db_id' => 'object-db_id',
- 'cache_object_user' => 'object-user',
- 'cache_object_pswd' => 'object-psw',
-
- 'cdn' => 'cdn',
- 'cdn_ori' => 'cdn-ori',
- 'cdn_exclude' => 'cdn-exc',
+ 'crawler_usleep' => 'crawler-usleep',
+ 'crawler_run_duration' => 'crawler-run_duration',
+ 'crawler_run_interval' => 'crawler-run_interval',
+ 'crawler_crawl_interval' => 'crawler-crawl_interval',
+ 'crawler_threads' => 'crawler-threads',
+ 'crawler_load_limit' => 'crawler-load_limit',
+ 'crawler_custom_sitemap' => 'crawler-sitemap',
+
+ 'cache_object' => 'object',
+ 'cache_object_kind' => 'object-kind',
+ 'cache_object_host' => 'object-host',
+ 'cache_object_port' => 'object-port',
+ 'cache_object_life' => 'object-life',
+ 'cache_object_persistent' => 'object-persistent',
+ 'cache_object_admin' => 'object-admin',
+ 'cache_object_transients' => 'object-transients',
+ 'cache_object_db_id' => 'object-db_id',
+ 'cache_object_user' => 'object-user',
+ 'cache_object_pswd' => 'object-psw',
+
+ 'cdn' => 'cdn',
+ 'cdn_ori' => 'cdn-ori',
+ 'cdn_exclude' => 'cdn-exc',
// 'cdn_remote_jquery' => 'cdn-remote_jq',
- 'cdn_quic' => 'cdn-quic',
- 'cdn_cloudflare' => 'cdn-cloudflare',
- 'cdn_cloudflare_email' => 'cdn-cloudflare_email',
- 'cdn_cloudflare_key' => 'cdn-cloudflare_key',
- 'cdn_cloudflare_name' => 'cdn-cloudflare_name',
- 'cdn_cloudflare_zone' => 'cdn-cloudflare_zone',
-
- 'media_img_lazy' => 'media-lazy',
- 'media_img_lazy_placeholder' => 'media-lazy_placeholder',
- 'media_placeholder_resp' => 'media-placeholder_resp',
- 'media_placeholder_resp_color' => 'media-placeholder_resp_color',
- 'media_placeholder_resp_async' => 'media-placeholder_resp_async',
- 'media_iframe_lazy' => 'media-iframe_lazy',
+ 'cdn_quic' => 'cdn-quic',
+ 'cdn_cloudflare' => 'cdn-cloudflare',
+ 'cdn_cloudflare_email' => 'cdn-cloudflare_email',
+ 'cdn_cloudflare_key' => 'cdn-cloudflare_key',
+ 'cdn_cloudflare_name' => 'cdn-cloudflare_name',
+ 'cdn_cloudflare_zone' => 'cdn-cloudflare_zone',
+
+ 'media_img_lazy' => 'media-lazy',
+ 'media_img_lazy_placeholder' => 'media-lazy_placeholder',
+ 'media_placeholder_resp' => 'media-placeholder_resp',
+ 'media_placeholder_resp_color' => 'media-placeholder_resp_color',
+ 'media_placeholder_resp_async' => 'media-placeholder_resp_async',
+ 'media_iframe_lazy' => 'media-iframe_lazy',
// 'media_img_lazyjs_inline' => 'media-lazyjs_inline',
- 'media_optm_auto' => 'img_optm-auto',
- 'media_optm_cron' => 'img_optm-cron',
- 'media_optm_ori' => 'img_optm-ori',
- 'media_rm_ori_bkup' => 'img_optm-rm_bkup',
+ 'media_optm_auto' => 'img_optm-auto',
+ 'media_optm_cron' => 'img_optm-cron',
+ 'media_optm_ori' => 'img_optm-ori',
+ 'media_rm_ori_bkup' => 'img_optm-rm_bkup',
// 'media_optm_webp' => 'img_optm-webp',
- 'media_webp_replace' => 'img_optm-webp',
- 'media_optm_lossless' => 'img_optm-lossless',
- 'media_optm_exif' => 'img_optm-exif',
- 'media_webp_replace_srcset' => 'img_optm-webp_replace_srcset',
+ 'media_webp_replace' => 'img_optm-webp',
+ 'media_optm_lossless' => 'img_optm-lossless',
+ 'media_optm_exif' => 'img_optm-exif',
+ 'media_webp_replace_srcset' => 'img_optm-webp_replace_srcset',
- 'css_minify' => 'optm-css_min',
+ 'css_minify' => 'optm-css_min',
// 'css_inline_minify' => 'optm-css_inline_min',
- 'css_combine' => 'optm-css_comb',
+ 'css_combine' => 'optm-css_comb',
// 'css_combined_priority' => 'optm-css_comb_priority',
// 'css_http2' => 'optm-css_http2',
- 'css_exclude' => 'optm-css_exc',
- 'js_minify' => 'optm-js_min',
+ 'css_exclude' => 'optm-css_exc',
+ 'js_minify' => 'optm-js_min',
// 'js_inline_minify' => 'optm-js_inline_min',
- 'js_combine' => 'optm-js_comb',
+ 'js_combine' => 'optm-js_comb',
// 'js_combined_priority' => 'optm-js_comb_priority',
// 'js_http2' => 'optm-js_http2',
- 'js_exclude' => 'optm-js_exc',
+ 'js_exclude' => 'optm-js_exc',
// 'optimize_ttl' => 'optm-ttl',
- 'html_minify' => 'optm-html_min',
- 'optm_qs_rm' => 'optm-qs_rm',
- 'optm_ggfonts_rm' => 'optm-ggfonts_rm',
- 'optm_css_async' => 'optm-css_async',
+ 'html_minify' => 'optm-html_min',
+ 'optm_qs_rm' => 'optm-qs_rm',
+ 'optm_ggfonts_rm' => 'optm-ggfonts_rm',
+ 'optm_css_async' => 'optm-css_async',
// 'optm_ccss_gen' => 'optm-ccss_gen',
// 'optm_ccss_async' => 'optm-ccss_async',
- 'optm_css_async_inline' => 'optm-css_async_inline',
- 'optm_js_defer' => 'optm-js_defer',
- 'optm_emoji_rm' => 'optm-emoji_rm',
+ 'optm_css_async_inline' => 'optm-css_async_inline',
+ 'optm_js_defer' => 'optm-js_defer',
+ 'optm_emoji_rm' => 'optm-emoji_rm',
// 'optm_exclude_jquery' => 'optm-exc_jq',
- 'optm_ggfonts_async' => 'optm-ggfonts_async',
+ 'optm_ggfonts_async' => 'optm-ggfonts_async',
// 'optm_max_size' => 'optm-max_size',
// 'optm_rm_comment' => 'optm-rm_comment',
- ) ;
- foreach ( $data as $k => $v ) {
- if ( ! isset( $previous_options[ $k ] ) ) {
- continue ;
+ );
+ foreach ($data as $k => $v) {
+ if (!isset($previous_options[$k])) {
+ continue;
}
// The folllowing values must be array
- if ( ! is_array( $previous_options[ $k ] ) ) {
- if ( in_array( $v, array( 'cdn-ori', 'cache-exc_cat', 'cache-exc_tag' ) ) ) {
- $previous_options[ $k ] = explode( ',', $previous_options[ $k ] ) ;
- $previous_options[ $k ] = array_filter( $previous_options[ $k ] ) ;
- }
- elseif ( in_array( $v, array( 'cache-mobile_rules', 'cache-exc_useragents', 'cache-exc_cookies' ) ) ) {
- $previous_options[ $k ] = explode( '|', str_replace( '\\ ', ' ', $previous_options[ $k ] ) ) ;
- $previous_options[ $k ] = array_filter( $previous_options[ $k ] ) ;
- }
- elseif ( in_array( $v, array(
+ if (!is_array($previous_options[$k])) {
+ if (in_array($v, array('cdn-ori', 'cache-exc_cat', 'cache-exc_tag'))) {
+ $previous_options[$k] = explode(',', $previous_options[$k]);
+ $previous_options[$k] = array_filter($previous_options[$k]);
+ } elseif (in_array($v, array('cache-mobile_rules', 'cache-exc_useragents', 'cache-exc_cookies'))) {
+ $previous_options[$k] = explode('|', str_replace('\\ ', ' ', $previous_options[$k]));
+ $previous_options[$k] = array_filter($previous_options[$k]);
+ } elseif (
+ in_array($v, array(
'purge-timed_urls',
'cache-exc_qs',
'debug-ips',
@@ -454,59 +464,60 @@ function litespeed_update_3_0( $ver ) {
'cdn-exc',
'optm-css_exc',
'optm-js_exc',
- ) ) ) {
- $previous_options[ $k ] = explode( "\n", $previous_options[ $k ] ) ;
- $previous_options[ $k ] = array_filter( $previous_options[ $k ] ) ;
+ ))
+ ) {
+ $previous_options[$k] = explode("\n", $previous_options[$k]);
+ $previous_options[$k] = array_filter($previous_options[$k]);
}
}
// Special handler for heartbeat
- if ( $v == 'misc-heartbeat_front' ) {
- if ( ! $previous_options[ $k ] ) {
- add_option( 'litespeed.conf.misc-heartbeat_front', true ) ;
- add_option( 'litespeed.conf.misc-heartbeat_back', true ) ;
- add_option( 'litespeed.conf.misc-heartbeat_editor', true ) ;
- add_option( 'litespeed.conf.misc-heartbeat_front_ttl', 0 ) ;
- add_option( 'litespeed.conf.misc-heartbeat_back_ttl', 0 ) ;
- add_option( 'litespeed.conf.misc-heartbeat_editor_ttl', 0 ) ;
+ if ($v == 'misc-heartbeat_front') {
+ if (!$previous_options[$k]) {
+ add_option('litespeed.conf.misc-heartbeat_front', true);
+ add_option('litespeed.conf.misc-heartbeat_back', true);
+ add_option('litespeed.conf.misc-heartbeat_editor', true);
+ add_option('litespeed.conf.misc-heartbeat_front_ttl', 0);
+ add_option('litespeed.conf.misc-heartbeat_back_ttl', 0);
+ add_option('litespeed.conf.misc-heartbeat_editor_ttl', 0);
}
- continue ;
+ continue;
}
- add_option( 'litespeed.conf.' . $v, $previous_options[ $k ] ) ;
+ add_option('litespeed.conf.' . $v, $previous_options[$k]);
}
// Conv purge_by_post
$data = array(
- '-' => 'purge-post_all',
- 'F' => 'purge-post_f',
- 'H' => 'purge-post_h',
- 'PGS' => 'purge-post_p',
- 'PGSRP' => 'purge-post_pwrp',
- 'A' => 'purge-post_a',
- 'Y' => 'purge-post_y',
- 'M' => 'purge-post_m',
- 'D' => 'purge-post_d',
- 'T' => 'purge-post_t',
- 'PT' => 'purge-post_pt',
- ) ;
- if ( isset( $previous_options[ 'purge_by_post' ] ) ) {
- $purge_by_post = explode( '.', $previous_options[ 'purge_by_post' ] ) ;
- foreach ( $data as $k => $v ) {
- add_option( 'litespeed.conf.' . $v, in_array( $k, $purge_by_post ) ) ;
+ '-' => 'purge-post_all',
+ 'F' => 'purge-post_f',
+ 'H' => 'purge-post_h',
+ 'PGS' => 'purge-post_p',
+ 'PGSRP' => 'purge-post_pwrp',
+ 'A' => 'purge-post_a',
+ 'Y' => 'purge-post_y',
+ 'M' => 'purge-post_m',
+ 'D' => 'purge-post_d',
+ 'T' => 'purge-post_t',
+ 'PT' => 'purge-post_pt',
+ );
+ if (isset($previous_options['purge_by_post'])) {
+ $purge_by_post = explode('.', $previous_options['purge_by_post']);
+ foreach ($data as $k => $v) {
+ add_option('litespeed.conf.' . $v, in_array($k, $purge_by_post));
}
}
// Conv 404/403/500 TTL
- $ttl_status = array() ;
- if ( isset( $previous_options[ '403_ttl' ] ) ) {
- $ttl_status[] = '403 ' . $previous_options[ '403_ttl' ] ;
+ $ttl_status = array();
+ if (isset($previous_options['403_ttl'])) {
+ $ttl_status[] = '403 ' . $previous_options['403_ttl'];
}
- if ( isset( $previous_options[ '404_ttl' ] ) ) {
- $ttl_status[] = '404 ' . $previous_options[ '404_ttl' ] ;
+ if (isset($previous_options['404_ttl'])) {
+ $ttl_status[] = '404 ' . $previous_options['404_ttl'];
}
- if ( isset( $previous_options[ '500_ttl' ] ) ) {
- $ttl_status[] = '500 ' . $previous_options[ '500_ttl' ] ;
+ if (isset($previous_options['500_ttl'])) {
+ $ttl_status[] = '500 ' . $previous_options['500_ttl'];
}
- add_option( 'litespeed.conf.cache-ttl_status', $ttl_status ) ;
+ add_option('litespeed.conf.cache-ttl_status', $ttl_status);
/**
* Resave cdn cfg from lscfg to separate cfg when upgrade to v1.7
@@ -515,16 +526,16 @@ function litespeed_update_3_0( $ver ) {
*
* @since 1.7
*/
- if ( isset( $previous_options[ 'cdn_url' ] ) ) {
+ if (isset($previous_options['cdn_url'])) {
$cdn_mapping = array(
- 'url' => $previous_options[ 'cdn_url' ],
- 'inc_img' => $previous_options[ 'cdn_inc_img' ],
- 'inc_css' => $previous_options[ 'cdn_inc_css' ],
- 'inc_js' => $previous_options[ 'cdn_inc_js' ],
- 'filetype' => $previous_options[ 'cdn_filetype' ],
- ) ;
- add_option( 'litespeed.conf.cdn-mapping', array( $cdn_mapping ) ) ;
- Debug2::debug( "[Data] plugin_upgrade option adding CDN map" ) ;
+ 'url' => $previous_options['cdn_url'],
+ 'inc_img' => $previous_options['cdn_inc_img'],
+ 'inc_css' => $previous_options['cdn_inc_css'],
+ 'inc_js' => $previous_options['cdn_inc_js'],
+ 'filetype' => $previous_options['cdn_filetype'],
+ );
+ add_option('litespeed.conf.cdn-mapping', array($cdn_mapping));
+ Debug2::debug('[Data] plugin_upgrade option adding CDN map');
}
/**
@@ -534,122 +545,121 @@ function litespeed_update_3_0( $ver ) {
*
* @since 2.3
*/
- if ( isset( $previous_options[ 'forced_cache_uri' ] ) ) {
- add_option( 'litespeed.conf.cache-force_uri', $previous_options[ 'forced_cache_uri' ] ) ;
+ if (isset($previous_options['forced_cache_uri'])) {
+ add_option('litespeed.conf.cache-force_uri', $previous_options['forced_cache_uri']);
}
- if ( isset( $previous_options[ 'cache_uri_priv' ] ) ) {
- add_option( 'litespeed.conf.cache-priv_uri', $previous_options[ 'cache_uri_priv' ] ) ;
+ if (isset($previous_options['cache_uri_priv'])) {
+ add_option('litespeed.conf.cache-priv_uri', $previous_options['cache_uri_priv']);
}
- if ( isset( $previous_options[ 'optm_excludes' ] ) ) {
- add_option( 'litespeed.conf.optm-exc', $previous_options[ 'optm_excludes' ] ) ;
+ if (isset($previous_options['optm_excludes'])) {
+ add_option('litespeed.conf.optm-exc', $previous_options['optm_excludes']);
}
- if ( isset( $previous_options[ 'excludes_uri' ] ) ) {
- add_option( 'litespeed.conf.cache-exc', $previous_options[ 'excludes_uri' ] ) ;
+ if (isset($previous_options['excludes_uri'])) {
+ add_option('litespeed.conf.cache-exc', $previous_options['excludes_uri']);
}
// Backup stale conf
- Debug2::debug( "[Data] Backup stale conf" );
- delete_option( 'litespeed-cache-conf' );
- add_option( 'litespeed-cache-conf.bk', $previous_options );
+ Debug2::debug('[Data] Backup stale conf');
+ delete_option('litespeed-cache-conf');
+ add_option('litespeed-cache-conf.bk', $previous_options);
// Upgrade site_options if is network
- if ( is_multisite() ) {
- $ver = get_site_option( 'litespeed.conf._version' ) ;
- if ( ! $ver ) {
- Debug2::debug( "[Data] Conv multisite" );
- $previous_site_options = get_site_option( 'litespeed-cache-conf' ) ;
+ if (is_multisite()) {
+ $ver = get_site_option('litespeed.conf._version');
+ if (!$ver) {
+ Debug2::debug('[Data] Conv multisite');
+ $previous_site_options = get_site_option('litespeed-cache-conf');
$data = array(
- 'network_enabled' => 'cache',
- 'use_primary_settings' => 'use_primary_settings',
- 'auto_upgrade' => 'auto_upgrade',
- 'purge_upgrade' => 'purge-upgrade',
-
- 'cache_favicon' => 'cache-favicon',
- 'cache_resources' => 'cache-resources',
- 'mobileview_enabled' => 'cache-mobile',
- 'mobileview_rules' => 'cache-mobile_rules',
- 'login_cookie' => 'cache-login_cookie',
- 'nocache_cookies' => 'cache-exc_cookies',
- 'nocache_useragents' => 'cache-exc_useragents',
-
- 'cache_object' => 'object',
- 'cache_object_kind' => 'object-kind',
- 'cache_object_host' => 'object-host',
- 'cache_object_port' => 'object-port',
- 'cache_object_life' => 'object-life',
- 'cache_object_persistent' => 'object-persistent',
- 'cache_object_admin' => 'object-admin',
- 'cache_object_transients' => 'object-transients',
- 'cache_object_db_id' => 'object-db_id',
- 'cache_object_user' => 'object-user',
- 'cache_object_pswd' => 'object-psw',
-
- 'cache_browser' => 'cache-browser',
- 'cache_browser_ttl' => 'cache-ttl_browser',
-
- 'media_webp_replace' => 'img_optm-webp',
- ) ;
- foreach ( $data as $k => $v ) {
- if ( ! isset( $previous_site_options[ $k ] ) ) {
- continue ;
+ 'network_enabled' => 'cache',
+ 'use_primary_settings' => 'use_primary_settings',
+ 'auto_upgrade' => 'auto_upgrade',
+ 'purge_upgrade' => 'purge-upgrade',
+
+ 'cache_favicon' => 'cache-favicon',
+ 'cache_resources' => 'cache-resources',
+ 'mobileview_enabled' => 'cache-mobile',
+ 'mobileview_rules' => 'cache-mobile_rules',
+ 'login_cookie' => 'cache-login_cookie',
+ 'nocache_cookies' => 'cache-exc_cookies',
+ 'nocache_useragents' => 'cache-exc_useragents',
+
+ 'cache_object' => 'object',
+ 'cache_object_kind' => 'object-kind',
+ 'cache_object_host' => 'object-host',
+ 'cache_object_port' => 'object-port',
+ 'cache_object_life' => 'object-life',
+ 'cache_object_persistent' => 'object-persistent',
+ 'cache_object_admin' => 'object-admin',
+ 'cache_object_transients' => 'object-transients',
+ 'cache_object_db_id' => 'object-db_id',
+ 'cache_object_user' => 'object-user',
+ 'cache_object_pswd' => 'object-psw',
+
+ 'cache_browser' => 'cache-browser',
+ 'cache_browser_ttl' => 'cache-ttl_browser',
+
+ 'media_webp_replace' => 'img_optm-webp',
+ );
+ foreach ($data as $k => $v) {
+ if (!isset($previous_site_options[$k])) {
+ continue;
}
// The folllowing values must be array
- if ( ! is_array( $previous_site_options[ $k ] ) ) {
- if ( in_array( $v, array( 'cache-mobile_rules', 'cache-exc_useragents', 'cache-exc_cookies' ) ) ) {
- $previous_site_options[ $k ] = explode( '|', str_replace( '\\ ', ' ', $previous_site_options[ $k ] ) ) ;
- $previous_site_options[ $k ] = array_filter( $previous_site_options[ $k ] ) ;
+ if (!is_array($previous_site_options[$k])) {
+ if (in_array($v, array('cache-mobile_rules', 'cache-exc_useragents', 'cache-exc_cookies'))) {
+ $previous_site_options[$k] = explode('|', str_replace('\\ ', ' ', $previous_site_options[$k]));
+ $previous_site_options[$k] = array_filter($previous_site_options[$k]);
}
}
- add_site_option( 'litespeed.conf.' . $v, $previous_site_options[ $k ] ) ;
+ add_site_option('litespeed.conf.' . $v, $previous_site_options[$k]);
}
// These are already converted to single record in single site
- $data = array(
- 'object-global_groups',
- 'object-non_persistent_groups',
- ) ;
- foreach ( $data as $v ) {
- $old_data = get_option( $v ) ;
- if ( $old_data ) {
- add_site_option( 'litespeed.conf.' . $v, $old_data ) ;
+ $data = array('object-global_groups', 'object-non_persistent_groups');
+ foreach ($data as $v) {
+ $old_data = get_option($v);
+ if ($old_data) {
+ add_site_option('litespeed.conf.' . $v, $old_data);
}
}
- delete_site_option( 'litespeed-cache-conf' ) ;
+ delete_site_option('litespeed-cache-conf');
- add_site_option( 'litespeed.conf._version', '3.0' ) ;
+ add_site_option('litespeed.conf._version', '3.0');
}
-
}
// delete tables
- Debug2::debug( "[Data] Drop litespeed_optimizer" );
- $q = 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'litespeed_optimizer' ;
- $wpdb->query( $q ) ;
+ Debug2::debug('[Data] Drop litespeed_optimizer');
+ $q = 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'litespeed_optimizer';
+ $wpdb->query($q);
// Update image optm table
- Debug2::debug( "[Data] Upgrade img_optm table" );
- $tb_exists = $wpdb->get_var( 'SHOW TABLES LIKE "' . $wpdb->prefix . 'litespeed_img_optm"' );
- if ( $tb_exists ) {
+ Debug2::debug('[Data] Upgrade img_optm table');
+ $tb_exists = $wpdb->get_var('SHOW TABLES LIKE "' . $wpdb->prefix . 'litespeed_img_optm"');
+ if ($tb_exists) {
$status_mapping = array(
- 'requested' => 3,
- 'notified' => 6,
- 'pulled' => 9,
- 'failed' => -1,
- 'miss' => -3,
- 'err' => -9,
- 'err_fetch' => -5,
- 'err_optm' => -7,
- 'xmeta' => -8,
+ 'requested' => 3,
+ 'notified' => 6,
+ 'pulled' => 9,
+ 'failed' => -1,
+ 'miss' => -3,
+ 'err' => -9,
+ 'err_fetch' => -5,
+ 'err_optm' => -7,
+ 'xmeta' => -8,
);
- foreach ( $status_mapping as $k => $v ) {
- $q = "UPDATE `" . $wpdb->prefix . "litespeed_img_optm` SET optm_status='$v' WHERE optm_status='$k'";
- $wpdb->query( $q ) ;
+ foreach ($status_mapping as $k => $v) {
+ $q = 'UPDATE `' . $wpdb->prefix . "litespeed_img_optm` SET optm_status='$v' WHERE optm_status='$k'";
+ $wpdb->query($q);
}
- $q = 'ALTER TABLE `' . $wpdb->prefix . 'litespeed_img_optm`
+ $q =
+ 'ALTER TABLE `' .
+ $wpdb->prefix .
+ 'litespeed_img_optm`
DROP INDEX `post_id_2`,
DROP INDEX `root_id`,
DROP INDEX `src_md5`,
@@ -664,36 +674,12 @@ function litespeed_update_3_0( $ver ) {
MODIFY COLUMN `optm_status` tinyint(4) NOT NULL DEFAULT 0,
MODIFY COLUMN `src` text COLLATE utf8mb4_unicode_ci NOT NULL
';
- $wpdb->query( $q ) ;
+ $wpdb->query($q);
}
- delete_option( 'litespeed-recommended' );
-
- Debug2::debug( "[Data] litespeed_update_3_0 done!" );
+ delete_option('litespeed-recommended');
- add_option( 'litespeed.conf._version', '3.0' ) ;
+ Debug2::debug('[Data] litespeed_update_3_0 done!');
+ add_option('litespeed.conf._version', '3.0');
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/db-optm.cls.php b/src/db-optm.cls.php
index 78788a2f5..87dd1eceb 100644
--- a/src/db-optm.cls.php
+++ b/src/db-optm.cls.php
@@ -10,12 +10,23 @@
*/
namespace LiteSpeed;
-defined( 'WPINC' ) || exit;
+defined('WPINC') || exit();
-class DB_Optm extends Root {
+class DB_Optm extends Root
+{
private static $_hide_more = false;
- private static $TYPES = array( 'revision', 'auto_draft', 'trash_post', 'spam_comment', 'trash_comment', 'trackback-pingback', 'expired_transient', 'all_transients', 'optimize_tables' );
+ private static $TYPES = array(
+ 'revision',
+ 'auto_draft',
+ 'trash_post',
+ 'spam_comment',
+ 'trash_comment',
+ 'trackback-pingback',
+ 'expired_transient',
+ 'all_transients',
+ 'optimize_tables',
+ );
const TYPE_CONV_TB = 'conv_innodb';
/**
@@ -23,7 +34,8 @@ class DB_Optm extends Root {
*
* @since 3.0
*/
- public static function hide_more() {
+ public static function hide_more()
+ {
return self::$_hide_more;
}
@@ -36,27 +48,28 @@ public static function hide_more() {
* @param bool $ignore_multisite If ignore multisite check
* @return int The rows that will be affected
*/
- public function db_count( $type, $ignore_multisite = false ) {
- if ( $type === 'all' ) {
+ public function db_count($type, $ignore_multisite = false)
+ {
+ if ($type === 'all') {
$num = 0;
- foreach ( self::$TYPES as $v ) {
- $num += $this->db_count( $v );
+ foreach (self::$TYPES as $v) {
+ $num += $this->db_count($v);
}
return $num;
}
- if ( ! $ignore_multisite ) {
- if ( is_multisite() && is_network_admin() ) {
+ if (!$ignore_multisite) {
+ if (is_multisite() && is_network_admin()) {
$num = 0;
$blogs = Activation::get_network_ids();
- foreach ( $blogs as $k => $blog_id ) {
- if ( $k > 3 ) {
+ foreach ($blogs as $k => $blog_id) {
+ if ($k > 3) {
self::$_hide_more = true;
break;
}
- switch_to_blog( $blog_id );
- $num += $this->db_count( $type, true );
+ switch_to_blog($blog_id);
+ $num += $this->db_count($type, true);
restore_current_blog();
}
return $num;
@@ -65,48 +78,48 @@ public function db_count( $type, $ignore_multisite = false ) {
global $wpdb;
- switch ( $type ) {
+ switch ($type) {
case 'revision':
- $rev_max = (int) $this->conf( Base::O_DB_OPTM_REVISIONS_MAX );
- $rev_age = (int) $this->conf( Base::O_DB_OPTM_REVISIONS_AGE );
+ $rev_max = (int) $this->conf(Base::O_DB_OPTM_REVISIONS_MAX);
+ $rev_age = (int) $this->conf(Base::O_DB_OPTM_REVISIONS_AGE);
$sql_add = '';
- if ( $rev_age ) {
+ if ($rev_age) {
$sql_add = " and post_modified < DATE_SUB( NOW(), INTERVAL $rev_age DAY ) ";
}
$sql = "SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_type = 'revision' $sql_add";
- if ( ! $rev_max ) {
- return $wpdb->get_var( $sql );
+ if (!$rev_max) {
+ return $wpdb->get_var($sql);
}
// Has count limit
$sql = "SELECT COUNT(*)-$rev_max FROM `$wpdb->posts` WHERE post_type = 'revision' $sql_add GROUP BY post_parent HAVING count(*)>$rev_max";
- $res = $wpdb->get_results( $sql, ARRAY_N );
+ $res = $wpdb->get_results($sql, ARRAY_N);
Utility::compatibility();
- return array_sum( array_column( $res, 0 ) );
+ return array_sum(array_column($res, 0));
case 'auto_draft':
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'auto-draft'" );
+ return $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'auto-draft'");
case 'trash_post':
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'trash'" );
+ return $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'trash'");
case 'spam_comment':
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'spam'" );
+ return $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'spam'");
case 'trash_comment':
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'trash'" );
+ return $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'trash'");
case 'trackback-pingback':
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback'" );
+ return $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback'");
case 'expired_transient':
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time() );
+ return $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time());
case 'all_transients':
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '%_transient_%'" );
+ return $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '%_transient_%'");
case 'optimize_tables':
- return $wpdb->get_var( "SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA = '" . DB_NAME . "' and ENGINE <> 'InnoDB' and DATA_FREE > 0" );
+ return $wpdb->get_var("SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA = '" . DB_NAME . "' and ENGINE <> 'InnoDB' and DATA_FREE > 0");
}
return '-';
@@ -119,19 +132,20 @@ public function db_count( $type, $ignore_multisite = false ) {
* @since 3.0 changed to private
* @access private
*/
- private function _db_clean( $type ) {
- if ( $type === 'all' ) {
- foreach ( self::$TYPES as $v ) {
- $this->_db_clean( $v );
+ private function _db_clean($type)
+ {
+ if ($type === 'all') {
+ foreach (self::$TYPES as $v) {
+ $this->_db_clean($v);
}
- return __( 'Clean all successfully.', 'litespeed-cache' );
+ return __('Clean all successfully.', 'litespeed-cache');
}
global $wpdb;
- switch ( $type ) {
+ switch ($type) {
case 'revision':
- $rev_max = (int) $this->conf( Base::O_DB_OPTM_REVISIONS_MAX );
- $rev_age = (int) $this->conf( Base::O_DB_OPTM_REVISIONS_AGE );
+ $rev_max = (int) $this->conf(Base::O_DB_OPTM_REVISIONS_MAX);
+ $rev_age = (int) $this->conf(Base::O_DB_OPTM_REVISIONS_AGE);
$postmeta = "`$wpdb->postmeta`";
$posts = "`$wpdb->posts`";
@@ -144,14 +158,12 @@ private function _db_clean( $type ) {
$sql_where = "WHERE $posts.post_type = 'revision'";
- $sql_add = $rev_age
- ? "AND $posts.post_modified < DATE_SUB( NOW(), INTERVAL $rev_age DAY )"
- : '';
+ $sql_add = $rev_age ? "AND $posts.post_modified < DATE_SUB( NOW(), INTERVAL $rev_age DAY )" : '';
- if ( ! $rev_max ) {
+ if (!$rev_max) {
$sql_where = "$sql_where $sql_add";
- $wpdb->query( "DELETE $postmeta FROM $sql_postmeta $sql_where" );
- $wpdb->query( "DELETE FROM $posts $sql_where" );
+ $wpdb->query("DELETE $postmeta FROM $sql_postmeta $sql_where");
+ $wpdb->query("DELETE FROM $posts $sql_where");
} else {
// Has count limit
$sql = "
@@ -163,63 +175,62 @@ private function _db_clean( $type ) {
GROUP BY post_parent
HAVING COUNT(*) > $rev_max
";
- $res = $wpdb->get_results( $sql );
+ $res = $wpdb->get_results($sql);
$sql_where = "
$sql_where
AND $posts.post_parent = %d
ORDER BY $posts.ID
LIMIT %d
";
- foreach ( $res as $v ) {
- $args = array( $v->post_parent, $v->del_max );
- $sql = $wpdb->prepare( "DELETE $postmeta FROM $sql_postmeta $sql_where", $args );
- $wpdb->query( $sql );
- $sql = $wpdb->prepare( "DELETE FROM $posts $sql_where", $args );
- $wpdb->query( $sql );
+ foreach ($res as $v) {
+ $args = array($v->post_parent, $v->del_max);
+ $sql = $wpdb->prepare("DELETE $postmeta FROM $sql_postmeta $sql_where", $args);
+ $wpdb->query($sql);
+ $sql = $wpdb->prepare("DELETE FROM $posts $sql_where", $args);
+ $wpdb->query($sql);
}
}
- return __( 'Clean post revisions successfully.', 'litespeed-cache' );
+ return __('Clean post revisions successfully.', 'litespeed-cache');
case 'auto_draft':
- $wpdb->query( "DELETE FROM `$wpdb->posts` WHERE post_status = 'auto-draft'" );
- return __( 'Clean auto drafts successfully.', 'litespeed-cache' );
+ $wpdb->query("DELETE FROM `$wpdb->posts` WHERE post_status = 'auto-draft'");
+ return __('Clean auto drafts successfully.', 'litespeed-cache');
case 'trash_post':
- $wpdb->query( "DELETE FROM `$wpdb->posts` WHERE post_status = 'trash'" );
- return __( 'Clean trashed posts and pages successfully.', 'litespeed-cache' );
+ $wpdb->query("DELETE FROM `$wpdb->posts` WHERE post_status = 'trash'");
+ return __('Clean trashed posts and pages successfully.', 'litespeed-cache');
case 'spam_comment':
- $wpdb->query( "DELETE FROM `$wpdb->comments` WHERE comment_approved = 'spam'" );
- return __( 'Clean spam comments successfully.', 'litespeed-cache' );
+ $wpdb->query("DELETE FROM `$wpdb->comments` WHERE comment_approved = 'spam'");
+ return __('Clean spam comments successfully.', 'litespeed-cache');
case 'trash_comment':
- $wpdb->query( "DELETE FROM `$wpdb->comments` WHERE comment_approved = 'trash'" );
- return __( 'Clean trashed comments successfully.', 'litespeed-cache' );
+ $wpdb->query("DELETE FROM `$wpdb->comments` WHERE comment_approved = 'trash'");
+ return __('Clean trashed comments successfully.', 'litespeed-cache');
case 'trackback-pingback':
- $wpdb->query( "DELETE FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback'" );
- return __( 'Clean trackbacks and pingbacks successfully.', 'litespeed-cache' );
+ $wpdb->query("DELETE FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback'");
+ return __('Clean trackbacks and pingbacks successfully.', 'litespeed-cache');
case 'expired_transient':
- $wpdb->query( "DELETE FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time() );
- return __( 'Clean expired transients successfully.', 'litespeed-cache' );
+ $wpdb->query("DELETE FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time());
+ return __('Clean expired transients successfully.', 'litespeed-cache');
case 'all_transients':
- $wpdb->query( "DELETE FROM `$wpdb->options` WHERE option_name LIKE '%\\_transient\\_%'" );
- return __( 'Clean all transients successfully.', 'litespeed-cache' );
+ $wpdb->query("DELETE FROM `$wpdb->options` WHERE option_name LIKE '%\\_transient\\_%'");
+ return __('Clean all transients successfully.', 'litespeed-cache');
case 'optimize_tables':
$sql = "SELECT table_name, DATA_FREE FROM information_schema.tables WHERE TABLE_SCHEMA = '" . DB_NAME . "' and ENGINE <> 'InnoDB' and DATA_FREE > 0";
- $result = $wpdb->get_results( $sql );
- if ( $result ) {
- foreach ( $result as $row ) {
- $wpdb->query( 'OPTIMIZE TABLE ' . $row->table_name );
+ $result = $wpdb->get_results($sql);
+ if ($result) {
+ foreach ($result as $row) {
+ $wpdb->query('OPTIMIZE TABLE ' . $row->table_name);
}
}
- return __( 'Optimized all tables.', 'litespeed-cache' );
+ return __('Optimized all tables.', 'litespeed-cache');
}
-
}
/**
@@ -228,10 +239,11 @@ private function _db_clean( $type ) {
* @since 3.0
* @access public
*/
- public function list_myisam() {
+ public function list_myisam()
+ {
global $wpdb;
$q = "SELECT * FROM information_schema.tables WHERE TABLE_SCHEMA = '" . DB_NAME . "' and ENGINE = 'myisam' AND TABLE_NAME LIKE '{$wpdb->prefix}%'";
- return $wpdb->get_results( $q );
+ return $wpdb->get_results($q);
}
/**
@@ -240,37 +252,37 @@ public function list_myisam() {
* @since 3.0
* @access private
*/
- private function _conv_innodb() {
+ private function _conv_innodb()
+ {
global $wpdb;
- if ( empty( $_GET[ 'tb' ] ) ) {
- Admin_Display::error( 'No table to convert' );
+ if (empty($_GET['tb'])) {
+ Admin_Display::error('No table to convert');
return;
}
$tb = false;
$list = $this->list_myisam();
- foreach ( $list as $v ) {
- if ( $v->TABLE_NAME == $_GET[ 'tb' ] ) {
+ foreach ($list as $v) {
+ if ($v->TABLE_NAME == $_GET['tb']) {
$tb = $v->TABLE_NAME;
break;
}
}
- if ( ! $tb ) {
- Admin_Display::error( 'No existing table' );
+ if (!$tb) {
+ Admin_Display::error('No existing table');
return;
}
$q = 'ALTER TABLE ' . DB_NAME . '.' . $tb . ' ENGINE = InnoDB';
- $wpdb->query( $q );
-
- Debug2::debug( "[DB] Converted $tb to InnoDB" );
+ $wpdb->query($q);
- $msg = __( 'Converted to InnoDB successfully.', 'litespeed-cache' );
- Admin_Display::succeed( $msg );
+ Debug2::debug("[DB] Converted $tb to InnoDB");
+ $msg = __('Converted to InnoDB successfully.', 'litespeed-cache');
+ Admin_Display::succeed($msg);
}
/**
@@ -279,12 +291,15 @@ private function _conv_innodb() {
* @since 3.0
* @access public
*/
- public function autoload_summary() {
+ public function autoload_summary()
+ {
global $wpdb;
- $summary = $wpdb->get_row( "SELECT SUM(LENGTH(option_value)) AS autoload_size,COUNT(*) AS autload_entries FROM `$wpdb->options` WHERE autoload='yes'" );
+ $summary = $wpdb->get_row("SELECT SUM(LENGTH(option_value)) AS autoload_size,COUNT(*) AS autload_entries FROM `$wpdb->options` WHERE autoload='yes'");
- $summary->autoload_toplist = $wpdb->get_results( "SELECT option_name, LENGTH(option_value) AS option_value_length FROM `$wpdb->options` WHERE autoload='yes' ORDER BY option_value_length DESC LIMIT 20" );
+ $summary->autoload_toplist = $wpdb->get_results(
+ "SELECT option_name, LENGTH(option_value) AS option_value_length FROM `$wpdb->options` WHERE autoload='yes' ORDER BY option_value_length DESC LIMIT 20"
+ );
return $summary;
}
@@ -295,27 +310,27 @@ public function autoload_summary() {
* @since 3.0
* @access public
*/
- public function handler() {
+ public function handler()
+ {
$type = Router::verify_type();
- switch ( $type ) {
+ switch ($type) {
case 'all':
- case in_array( $type, self::$TYPES ):
- if ( is_multisite() && is_network_admin() ) {
+ case in_array($type, self::$TYPES):
+ if (is_multisite() && is_network_admin()) {
$blogs = Activation::get_network_ids();
- foreach ( $blogs as $blog_id ) {
- switch_to_blog( $blog_id );
- $msg = $this->_db_clean( $type );
+ foreach ($blogs as $blog_id) {
+ switch_to_blog($blog_id);
+ $msg = $this->_db_clean($type);
restore_current_blog();
}
+ } else {
+ $msg = $this->_db_clean($type);
}
- else {
- $msg = $this->_db_clean( $type );
- }
- Admin_Display::succeed( $msg );
+ Admin_Display::succeed($msg);
break;
- case self::TYPE_CONV_TB :
+ case self::TYPE_CONV_TB:
$this->_conv_innodb();
break;
@@ -325,6 +340,4 @@ public function handler() {
Admin::redirect();
}
-
}
-
diff --git a/src/debug2.cls.php b/src/debug2.cls.php
index e9e8d34cf..d7a1b3c1b 100644
--- a/src/debug2.cls.php
+++ b/src/debug2.cls.php
@@ -6,7 +6,7 @@
namespace LiteSpeed;
-defined('WPINC') || exit;
+defined('WPINC') || exit();
class Debug2 extends Root
{
@@ -119,7 +119,7 @@ public function beta_test($zip = false)
private function _package_zip($commit)
{
$data = array(
- 'commit' => $commit,
+ 'commit' => $commit,
);
$res = Cloud::get(Cloud::API_BETA_TEST, $data);
@@ -189,7 +189,8 @@ public function init()
}
}
- if (!defined('LSCWP_LOG')) { // If not initialized, do it now
+ if (!defined('LSCWP_LOG')) {
+ // If not initialized, do it now
$this->_init_request();
define('LSCWP_LOG', true);
}
@@ -322,7 +323,7 @@ private static function format_message($msg)
}
// Generate a unique string per request
- self::$_prefix = sprintf(" [%s %s %s] ", $addr, LSCWP_LOG_TAG, Str::rrand(3));
+ self::$_prefix = sprintf(' [%s %s %s] ', $addr, LSCWP_LOG_TAG, Str::rrand(3));
}
list($usec, $sec) = explode(' ', microtime());
return date('m/d/y H:i:s', $sec + LITESPEED_TIME_OFFSET) . substr($usec, 1, 4) . self::$_prefix . $msg . "\n";
@@ -420,7 +421,8 @@ private static function _backtrace_info($backtrace_limit)
$msg = '';
$trace = version_compare(PHP_VERSION, '5.4.0', '<') ? debug_backtrace() : debug_backtrace(false, $backtrace_limit + 3);
- for ($i = 2; $i <= $backtrace_limit + 2; $i++) { // 0st => _backtrace_info(), 1st => push()
+ for ($i = 2; $i <= $backtrace_limit + 2; $i++) {
+ // 0st => _backtrace_info(), 1st => push()
if (empty($trace[$i]['class'])) {
if (empty($trace[$i]['file'])) {
break;
diff --git a/src/doc.cls.php b/src/doc.cls.php
index 44452d966..28d61ab38 100644
--- a/src/doc.cls.php
+++ b/src/doc.cls.php
@@ -11,7 +11,7 @@
namespace LiteSpeed;
-defined('WPINC') || exit;
+defined('WPINC') || exit();
class Doc
{
@@ -25,11 +25,22 @@ class Doc
*/
public static function maybe_on_by_gm($id)
{
- if (apply_filters('litespeed_conf', $id)) return;
- if (!apply_filters('litespeed_conf', Base::O_GUEST)) return;
- if (!apply_filters('litespeed_conf', Base::O_GUEST_OPTM)) return;
+ if (apply_filters('litespeed_conf', $id)) {
+ return;
+ }
+ if (!apply_filters('litespeed_conf', Base::O_GUEST)) {
+ return;
+ }
+ if (!apply_filters('litespeed_conf', Base::O_GUEST_OPTM)) {
+ return;
+ }
echo '';
- echo '⚠️ ' . sprintf(__('This setting is %1$s for certain qualifying requests due to %2$s!', 'litespeed-cache'), '' . __('ON', 'litespeed-cache') . '
', Lang::title(Base::O_GUEST_OPTM));
+ echo '⚠️ ' .
+ sprintf(
+ __('This setting is %1$s for certain qualifying requests due to %2$s!', 'litespeed-cache'),
+ '' . __('ON', 'litespeed-cache') . '
',
+ Lang::title(Base::O_GUEST_OPTM)
+ );
self::learn_more('https://docs.litespeedtech.com/lscache/lscwp/general/#guest-optimization');
echo '';
}
@@ -55,11 +66,16 @@ public static function crawler_affected()
*/
public static function privacy_policy()
{
- return __('This site utilizes caching in order to facilitate a faster response time and better user experience. Caching potentially stores a duplicate copy of every web page that is on display on this site. All cache files are temporary, and are never accessed by any third party, except as necessary to obtain technical support from the cache plugin vendor. Cache files expire on a schedule set by the site administrator, but may easily be purged by the admin before their natural expiration, if necessary. We may use QUIC.cloud services to process & cache your data temporarily.', 'litespeed-cache')
- . sprintf(__('Please see %s for more details.', 'litespeed-cache'), 'https://quic.cloud/privacy-policy/');
+ return __(
+ 'This site utilizes caching in order to facilitate a faster response time and better user experience. Caching potentially stores a duplicate copy of every web page that is on display on this site. All cache files are temporary, and are never accessed by any third party, except as necessary to obtain technical support from the cache plugin vendor. Cache files expire on a schedule set by the site administrator, but may easily be purged by the admin before their natural expiration, if necessary. We may use QUIC.cloud services to process & cache your data temporarily.',
+ 'litespeed-cache'
+ ) .
+ sprintf(
+ __('Please see %s for more details.', 'litespeed-cache'),
+ 'https://quic.cloud/privacy-policy/'
+ );
}
-
/**
* Learn more link
*
@@ -127,7 +143,9 @@ public static function notice_htaccess()
{
echo '';
echo '⚠️ ' . __('This setting will edit the .htaccess file.', 'litespeed-cache');
- echo ' ' . __('Learn More', 'litespeed-cache') . '';
+ echo ' ' .
+ __('Learn More', 'litespeed-cache') .
+ '';
echo '';
}
@@ -154,10 +172,11 @@ public static function notice_ips()
*/
public static function queue_issues($return = false)
{
- $str = '' . substr($code, strlen('unfinished_queue ')) . '
');
+ $msg = sprintf(
+ __('There is proceeding queue not pulled yet. Queue info: %s.', 'litespeed-cache'),
+ '' . substr($code, strlen('unfinished_queue ')) . '
'
+ );
break;
case 'err_alias':
@@ -149,13 +159,16 @@ public static function msg($code, $args = null)
$msg = __('Crawler disabled by the server admin.', 'litespeed-cache');
break;
- /*** QC error code ***/
+ /*** QC error code ***/
case 'try_later':
$msg = __('Previous request too recent. Please try again later.', 'litespeed-cache');
break;
case strpos($code, 'try_later ') === 0:
- $msg = sprintf(__('Previous request too recent. Please try again after %s.', 'litespeed-cache'), '' . Utility::readable_time(substr($code, strlen('try_later ')), 3600, true) . '
');
+ $msg = sprintf(
+ __('Previous request too recent. Please try again after %s.', 'litespeed-cache'),
+ '' . Utility::readable_time(substr($code, strlen('try_later ')), 3600, true) . '
'
+ );
break;
case 'waiting_for_approval':
@@ -171,7 +184,9 @@ public static function msg($code, $args = null)
break;
case substr($code, 0, 14) === 'callback_fail ':
- $msg = __('The callback validation to your domain failed. Please make sure there is no firewall blocking our servers. Response code: ', 'litespeed-cache') . substr($code, 14);
+ $msg =
+ __('The callback validation to your domain failed. Please make sure there is no firewall blocking our servers. Response code: ', 'litespeed-cache') .
+ substr($code, 14);
break;
case 'forbidden':
@@ -179,7 +194,10 @@ public static function msg($code, $args = null)
break;
case 'err_dns_active':
- $msg = __('You cannot remove this DNS zone, because it is still in use. Please update the domain\'s nameservers, then try to delete this zone again, otherwise your site will become inaccessible.', 'litespeed-cache');
+ $msg = __(
+ 'You cannot remove this DNS zone, because it is still in use. Please update the domain\'s nameservers, then try to delete this zone again, otherwise your site will become inaccessible.',
+ 'litespeed-cache'
+ );
break;
default:
diff --git a/src/esi.cls.php b/src/esi.cls.php
index 841de03c1..55333dba2 100644
--- a/src/esi.cls.php
+++ b/src/esi.cls.php
@@ -13,7 +13,7 @@
namespace LiteSpeed;
-defined('WPINC') || exit;
+defined('WPINC') || exit();
class ESI extends Root
{
@@ -277,8 +277,12 @@ private function _register_esi_actions()
*/
if (!empty($_SERVER['ESI_REFERER']) && !$this->cls('REST')->is_rest($_SERVER['ESI_REFERER'])) {
self::debug('overwrite REQUEST_URI to ESI_REFERER [from] ' . $_SERVER['REQUEST_URI'] . ' [to] ' . $_SERVER['ESI_REFERER']);
- if (!empty($_SERVER['ESI_REFERER']))
- $_SERVER['REQUEST_URI'] = substr(get_option('permalink_structure'), -1) === '/' && strpos($_SERVER['ESI_REFERER'], '?') === false ? trailingslashit($_SERVER['ESI_REFERER']) : $_SERVER['ESI_REFERER'];
+ if (!empty($_SERVER['ESI_REFERER'])) {
+ $_SERVER['REQUEST_URI'] =
+ substr(get_option('permalink_structure'), -1) === '/' && strpos($_SERVER['ESI_REFERER'], '?') === false
+ ? trailingslashit($_SERVER['ESI_REFERER'])
+ : $_SERVER['ESI_REFERER'];
+ }
# Prevent from 301 redirecting
if (!empty($_SERVER['SCRIPT_URI'])) {
$SCRIPT_URI = parse_url($_SERVER['SCRIPT_URI']);
@@ -433,7 +437,7 @@ private static function _build_inline($url, $inline_param)
$control = esc_attr($inline_param['control']);
$tag = esc_attr($inline_param['tag']);
- return "