Plugin Directory

Changeset 2977143


Ignore:
Timestamp:
10/10/2023 05:02:18 PM (2 years ago)
Author:
LiteSpeedTech
Message:

Release v5.7

Location:
litespeed-cache
Files:
334 added
25 edited

Legend:

Unmodified
Added
Removed
  • litespeed-cache/trunk/assets/css/litespeed.css

    r2954001 r2977143  
    298298.litespeed-left20 {
    299299    margin-left: 20px;
     300}
     301
     302.litespeed-wrap .litespeed-bg-quic-cloud {
     303    background: linear-gradient(rgba(230,242,242,1) 10%, rgba(250,255,255,1) 30%);
    300304}
    301305
  • litespeed-cache/trunk/data/const.default.ini

    r2846360 r2977143  
    3535Pingdom
    3636bot
     37spider
    3738PTST
    3839HeadlessChrome'
     
    391392optm-dns_prefetch_ctrl = false
    392393
     394; O_OPTM_DNS_PRECONNECT
     395optm-dns_preconnect = ''
     396
    393397optm-exc = ''
    394398
  • litespeed-cache/trunk/lang/litespeed-cache.pot

    r2954001 r2977143  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: LiteSpeed Cache 5.6\n"
     5"Project-Id-Version: LiteSpeed Cache 5.7\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
    7 "POT-Creation-Date: 2023-07-26 13:52:36+00:00\n"
     7"POT-Creation-Date: 2023-10-10 13:10:37+00:00\n"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=UTF-8\n"
     
    7272msgstr ""
    7373
    74 #: src/admin-display.cls.php:135 src/lang.cls.php:243
     74#: src/admin-display.cls.php:135 src/lang.cls.php:244
    7575msgid "Crawler"
    7676msgstr ""
     
    110110#: src/admin-display.cls.php:238 src/admin-display.cls.php:900
    111111#: src/admin-display.cls.php:929 src/admin-display.cls.php:980
    112 #: src/doc.cls.php:31 tpl/cache/settings-cache.tpl.php:19
     112#: src/doc.cls.php:32 tpl/cache/settings-cache.tpl.php:19
    113113#: tpl/cache/settings_inc.cache_mobile.tpl.php:71 tpl/cdn/settings.tpl.php:49
    114114#: tpl/page_optm/settings_css.tpl.php:189
     
    206206#: src/admin-display.cls.php:1180 tpl/cache/settings-esi.tpl.php:95
    207207#: tpl/page_optm/settings_css.tpl.php:192
    208 #: tpl/page_optm/settings_html.tpl.php:85
     208#: tpl/page_optm/settings_html.tpl.php:106
    209209#: tpl/page_optm/settings_media.tpl.php:245
    210210#: tpl/page_optm/settings_media_exc.tpl.php:26
     
    240240msgstr ""
    241241
    242 #: src/admin-display.cls.php:1198 src/doc.cls.php:96
     242#: src/admin-display.cls.php:1198 src/doc.cls.php:98
    243243msgid "One per line."
    244244msgstr ""
     
    260260msgstr ""
    261261
    262 #: src/admin-settings.cls.php:245 src/admin-settings.cls.php:279
     262#: src/admin-settings.cls.php:270 src/admin-settings.cls.php:305
    263263msgid "Options saved."
    264264msgstr ""
     
    327327msgstr ""
    328328
    329 #: src/cdn-setup.cls.php:322 src/cloud.cls.php:820 src/cloud.cls.php:828
    330 #: src/cloud.cls.php:1235
     329#: src/cdn-setup.cls.php:322 src/cloud.cls.php:822 src/cloud.cls.php:830
     330#: src/cloud.cls.php:1237
    331331msgid "Message from QUIC.cloud server"
    332332msgstr ""
    333333
    334334#: src/cloud.cls.php:394 src/cloud.cls.php:407 src/cloud.cls.php:452
    335 #: src/cloud.cls.php:477 src/cloud.cls.php:625 src/cloud.cls.php:1204
     335#: src/cloud.cls.php:477 src/cloud.cls.php:627 src/cloud.cls.php:1206
    336336msgid "Cloud Error"
    337337msgstr ""
     
    345345msgstr ""
    346346
    347 #: src/cloud.cls.php:584
     347#: src/cloud.cls.php:585
    348348msgid "In order to use QC services, need a real domain name, cannot use an IP."
    349349msgstr ""
    350350
    351 #: src/cloud.cls.php:625
     351#: src/cloud.cls.php:627
    352352msgid "Please try after %1$s for service %2$s."
    353353msgstr ""
    354354
    355 #: src/cloud.cls.php:715 src/cloud.cls.php:736
     355#: src/cloud.cls.php:717 src/cloud.cls.php:738
    356356msgid "Failed to request via WordPress"
    357357msgstr ""
    358358
    359 #: src/cloud.cls.php:755
     359#: src/cloud.cls.php:757
    360360msgid ""
    361361"Cloud server refused the current request due to unpulled images. Please pull "
     
    363363msgstr ""
    364364
    365 #: src/cloud.cls.php:760
     365#: src/cloud.cls.php:762
    366366msgid ""
    367367"Your domain_key has been temporarily blocklisted to prevent abuse. You may "
     
    369369msgstr ""
    370370
    371 #: src/cloud.cls.php:767
     371#: src/cloud.cls.php:769
    372372msgid ""
    373373"Cloud server refused the current request due to rate limiting. Please try "
     
    375375msgstr ""
    376376
    377 #: src/cloud.cls.php:775
     377#: src/cloud.cls.php:777
    378378msgid "Redetected node"
    379379msgstr ""
    380380
    381 #: src/cloud.cls.php:783
     381#: src/cloud.cls.php:785
    382382msgid ""
    383383"We are working hard to improve your online service experience. The service "
     
    385385msgstr ""
    386386
    387 #: src/cloud.cls.php:836
     387#: src/cloud.cls.php:838
    388388msgid "Good news from QUIC.cloud server"
    389389msgstr ""
    390390
    391 #: src/cloud.cls.php:845
     391#: src/cloud.cls.php:847
    392392msgid "%1$s plugin version %2$s required for this action."
    393393msgstr ""
    394394
    395 #: src/cloud.cls.php:902 src/cloud.cls.php:1224
     395#: src/cloud.cls.php:904 src/cloud.cls.php:1226
    396396msgid "Failed to communicate with QUIC.cloud server"
    397397msgstr ""
    398398
    399 #: src/cloud.cls.php:945
     399#: src/cloud.cls.php:947
    400400msgid ""
    401401"Site not recognized. Domain Key has been automatically removed. Please "
     
    403403msgstr ""
    404404
    405 #: src/cloud.cls.php:946 src/error.cls.php:48
     405#: src/cloud.cls.php:948 src/error.cls.php:48
    406406msgid "Click here to set."
    407407msgstr ""
    408408
    409 #: src/cloud.cls.php:1014
     409#: src/cloud.cls.php:1016
    410410msgid "Cannot request REST API, no token saved."
    411411msgstr ""
    412412
    413 #: src/cloud.cls.php:1040
     413#: src/cloud.cls.php:1042
    414414msgid "Cloud REST Error"
    415415msgstr ""
    416416
    417 #: src/cloud.cls.php:1060
     417#: src/cloud.cls.php:1062
    418418msgid "Unknown error."
    419419msgstr ""
    420420
    421 #: src/cloud.cls.php:1064
     421#: src/cloud.cls.php:1066
    422422msgid "Contact QUIC.cloud support"
    423423msgstr ""
    424424
    425 #: src/cloud.cls.php:1066
     425#: src/cloud.cls.php:1068
    426426msgid "Cloud REST API returned error: "
    427427msgstr ""
    428428
    429 #: src/cloud.cls.php:1243
     429#: src/cloud.cls.php:1245
    430430msgid ""
    431431"Applied for Domain Key successfully. Please wait for result. Domain Key will "
     
    433433msgstr ""
    434434
    435 #: src/cloud.cls.php:1299
     435#: src/cloud.cls.php:1301
    436436msgid ""
    437437"Congratulations, your Domain Key has been approved! The setting has been "
     
    439439msgstr ""
    440440
    441 #: src/cloud.cls.php:1395
     441#: src/cloud.cls.php:1400
    442442msgid "QUIC.cloud account has been created and successfully linked."
    443443msgstr ""
    444444
    445 #: src/cloud.cls.php:1396
     445#: src/cloud.cls.php:1401
    446446msgid "QUIC.cloud account has been successfully linked."
    447447msgstr ""
    448448
    449 #: src/cloud.cls.php:1404
     449#: src/cloud.cls.php:1409
    450450msgid "Domain Key hash mismatch"
    451451msgstr ""
    452452
    453 #: src/cloud.cls.php:1530
     453#: src/cloud.cls.php:1535
    454454msgid "Sync credit allowance with Cloud Server successfully."
    455455msgstr ""
     
    573573msgstr ""
    574574
    575 #: src/doc.cls.php:31
    576 msgid "This setting is passively %1$s due to %2$s!"
    577 msgstr ""
    578 
    579 #: src/doc.cls.php:44
     575#: src/doc.cls.php:32
     576msgid "This setting is %1$s for certain qualifying requests due to %2$s!"
     577msgstr ""
     578
     579#: src/doc.cls.php:46
    580580msgid "This setting will regenerate crawler list and clear the disabled list!"
    581581msgstr ""
    582582
    583 #: src/doc.cls.php:56
     583#: src/doc.cls.php:58
    584584msgid ""
    585585"This site utilizes caching in order to facilitate a faster response time and "
     
    593593msgstr ""
    594594
    595 #: src/doc.cls.php:57
     595#: src/doc.cls.php:59
    596596msgid "Please see %s for more details."
    597597msgstr ""
    598598
    599 #: src/doc.cls.php:74 src/doc.cls.php:128 tpl/cdn/manage.tpl.php:67
     599#: src/doc.cls.php:76 src/doc.cls.php:130 tpl/cdn/manage.tpl.php:67
    600600#: tpl/dash/dashboard.tpl.php:46 tpl/img_optm/summary.tpl.php:48
    601601#: tpl/inc/check_cache_disabled.php:42
     
    603603msgstr ""
    604604
    605 #: src/doc.cls.php:112
     605#: src/doc.cls.php:114
    606606msgid "Both full and partial strings can be used."
    607607msgstr ""
    608608
    609 #: src/doc.cls.php:114
     609#: src/doc.cls.php:116
    610610msgid "Both full URLs and partial strings can be used."
    611611msgstr ""
    612612
    613 #: src/doc.cls.php:127
     613#: src/doc.cls.php:129
    614614msgid "This setting will edit the .htaccess file."
    615615msgstr ""
    616616
    617 #: src/doc.cls.php:141
     617#: src/doc.cls.php:143
    618618msgid ""
    619619"For online services to work correctly, you must allowlist all %s server IPs."
    620620msgstr ""
    621621
    622 #: src/doc.cls.php:142
     622#: src/doc.cls.php:144
    623623msgid ""
    624624"Before generating key, please verify all IPs on this list are allowlisted"
    625625msgstr ""
    626626
    627 #: src/doc.cls.php:143 tpl/general/settings.tpl.php:89
     627#: src/doc.cls.php:145 tpl/general/settings.tpl.php:89
    628628msgid "Current Online Server IPs"
    629629msgstr ""
    630630
    631 #: src/doc.cls.php:156
     631#: src/doc.cls.php:158
    632632msgid "The queue is processed asynchronously. It may take time."
    633633msgstr ""
     
    878878msgstr ""
    879879
    880 #: src/gui.cls.php:556 src/gui.cls.php:716 src/lang.cls.php:175
     880#: src/gui.cls.php:556 src/gui.cls.php:716 src/lang.cls.php:176
    881881#: tpl/presets/standard.tpl.php:42 tpl/toolbox/purge.tpl.php:106
    882882msgid "Gravatar Cache"
     
    980980msgstr ""
    981981
    982 #: src/img-optm.cls.php:1209
     982#: src/img-optm.cls.php:1215
    983983msgid "Destroy all optimization data successfully."
    984984msgstr ""
    985985
    986 #: src/img-optm.cls.php:1270 src/img-optm.cls.php:1332
     986#: src/img-optm.cls.php:1278 src/img-optm.cls.php:1340
    987987msgid "Rescanned successfully."
    988988msgstr ""
    989989
    990 #: src/img-optm.cls.php:1332
     990#: src/img-optm.cls.php:1340
    991991msgid "Rescanned %d images successfully."
    992992msgstr ""
    993993
    994 #: src/img-optm.cls.php:1397
     994#: src/img-optm.cls.php:1405
    995995msgid "Calculated backups successfully."
    996996msgstr ""
    997997
    998 #: src/img-optm.cls.php:1489
     998#: src/img-optm.cls.php:1497
    999999msgid "Removed backups successfully."
    10001000msgstr ""
    10011001
    1002 #: src/img-optm.cls.php:1674
     1002#: src/img-optm.cls.php:1682
    10031003msgid "Switched images successfully."
    10041004msgstr ""
    10051005
    1006 #: src/img-optm.cls.php:1719 src/img-optm.cls.php:1765
     1006#: src/img-optm.cls.php:1727 src/img-optm.cls.php:1773
    10071007msgid "Switched to optimized file successfully."
    10081008msgstr ""
    10091009
    1010 #: src/img-optm.cls.php:1738
     1010#: src/img-optm.cls.php:1746
    10111011msgid "Disabled WebP file successfully."
    10121012msgstr ""
    10131013
    1014 #: src/img-optm.cls.php:1743
     1014#: src/img-optm.cls.php:1751
    10151015msgid "Enabled WebP file successfully."
    10161016msgstr ""
    10171017
    1018 #: src/img-optm.cls.php:1759
     1018#: src/img-optm.cls.php:1767
    10191019msgid "Restored original file successfully."
    10201020msgstr ""
    10211021
    1022 #: src/img-optm.cls.php:1816
     1022#: src/img-optm.cls.php:1824
    10231023msgid "Reset the optimized data successfully."
    10241024msgstr ""
     
    13571357
    13581358#: src/lang.cls.php:158
     1359msgid "DNS Preconnect"
     1360msgstr ""
     1361
     1362#: src/lang.cls.php:159
    13591363msgid "CSS Excludes"
    13601364msgstr ""
    13611365
    1362 #: src/lang.cls.php:159
     1366#: src/lang.cls.php:160
    13631367msgid "JS Delayed Includes"
    13641368msgstr ""
    13651369
    1366 #: src/lang.cls.php:160
     1370#: src/lang.cls.php:161
    13671371msgid "JS Excludes"
    13681372msgstr ""
    13691373
    1370 #: src/lang.cls.php:161
     1374#: src/lang.cls.php:162
    13711375msgid "Remove Query Strings"
    13721376msgstr ""
    13731377
    1374 #: src/lang.cls.php:162
     1378#: src/lang.cls.php:163
    13751379msgid "Load Google Fonts Asynchronously"
    13761380msgstr ""
    13771381
    1378 #: src/lang.cls.php:163
     1382#: src/lang.cls.php:164
    13791383msgid "Remove Google Fonts"
    13801384msgstr ""
    13811385
    1382 #: src/lang.cls.php:164
     1386#: src/lang.cls.php:165
    13831387msgid "Critical CSS Rules"
    13841388msgstr ""
    13851389
    1386 #: src/lang.cls.php:165
     1390#: src/lang.cls.php:166
    13871391msgid "Separate CCSS Cache Post Types"
    13881392msgstr ""
    13891393
    1390 #: src/lang.cls.php:166
     1394#: src/lang.cls.php:167
    13911395msgid "Separate CCSS Cache URIs"
    13921396msgstr ""
    13931397
    1394 #: src/lang.cls.php:167
     1398#: src/lang.cls.php:168
    13951399msgid "JS Deferred / Delayed Excludes"
    13961400msgstr ""
    13971401
    1398 #: src/lang.cls.php:168
     1402#: src/lang.cls.php:169
    13991403msgid "Guest Mode JS Excludes"
    14001404msgstr ""
    14011405
    1402 #: src/lang.cls.php:169 tpl/presets/standard.tpl.php:44
     1406#: src/lang.cls.php:170 tpl/presets/standard.tpl.php:44
    14031407msgid "Remove WordPress Emoji"
    14041408msgstr ""
    14051409
    1406 #: src/lang.cls.php:170 tpl/presets/standard.tpl.php:45
     1410#: src/lang.cls.php:171 tpl/presets/standard.tpl.php:45
    14071411msgid "Remove Noscript Tags"
    14081412msgstr ""
    14091413
    1410 #: src/lang.cls.php:171
     1414#: src/lang.cls.php:172
    14111415msgid "URI Excludes"
    14121416msgstr ""
    14131417
    1414 #: src/lang.cls.php:172
     1418#: src/lang.cls.php:173
    14151419msgid "Optimize for Guests Only"
    14161420msgstr ""
    14171421
    1418 #: src/lang.cls.php:173
     1422#: src/lang.cls.php:174
    14191423msgid "Role Excludes"
    14201424msgstr ""
    14211425
    1422 #: src/lang.cls.php:176
     1426#: src/lang.cls.php:177
    14231427msgid "Gravatar Cache Cron"
    14241428msgstr ""
    14251429
    1426 #: src/lang.cls.php:177
     1430#: src/lang.cls.php:178
    14271431msgid "Gravatar Cache TTL"
    14281432msgstr ""
    14291433
    1430 #: src/lang.cls.php:179
     1434#: src/lang.cls.php:180
    14311435msgid "Lazy Load Images"
    14321436msgstr ""
    14331437
    1434 #: src/lang.cls.php:180
     1438#: src/lang.cls.php:181
    14351439msgid "Lazy Load Image Excludes"
    14361440msgstr ""
    14371441
    1438 #: src/lang.cls.php:181
     1442#: src/lang.cls.php:182
    14391443msgid "Lazy Load Image Class Name Excludes"
    14401444msgstr ""
    14411445
    1442 #: src/lang.cls.php:182
     1446#: src/lang.cls.php:183
    14431447msgid "Lazy Load Image Parent Class Name Excludes"
    14441448msgstr ""
    14451449
    1446 #: src/lang.cls.php:183
     1450#: src/lang.cls.php:184
    14471451msgid "Lazy Load Iframe Class Name Excludes"
    14481452msgstr ""
    14491453
    1450 #: src/lang.cls.php:184
     1454#: src/lang.cls.php:185
    14511455msgid "Lazy Load Iframe Parent Class Name Excludes"
    14521456msgstr ""
    14531457
    1454 #: src/lang.cls.php:185
     1458#: src/lang.cls.php:186
    14551459msgid "Lazy Load URI Excludes"
    14561460msgstr ""
    14571461
    1458 #: src/lang.cls.php:186
     1462#: src/lang.cls.php:187
    14591463msgid "LQIP Excludes"
    14601464msgstr ""
    14611465
    1462 #: src/lang.cls.php:187
     1466#: src/lang.cls.php:188
    14631467msgid "Basic Image Placeholder"
    14641468msgstr ""
    14651469
    1466 #: src/lang.cls.php:188
     1470#: src/lang.cls.php:189
    14671471msgid "Responsive Placeholder"
    14681472msgstr ""
    14691473
    1470 #: src/lang.cls.php:189
     1474#: src/lang.cls.php:190
    14711475msgid "Responsive Placeholder Color"
    14721476msgstr ""
    14731477
    1474 #: src/lang.cls.php:190
     1478#: src/lang.cls.php:191
    14751479msgid "Responsive Placeholder SVG"
    14761480msgstr ""
    14771481
    1478 #: src/lang.cls.php:191
     1482#: src/lang.cls.php:192
    14791483msgid "LQIP Cloud Generator"
    14801484msgstr ""
    14811485
    1482 #: src/lang.cls.php:192
     1486#: src/lang.cls.php:193
    14831487msgid "LQIP Quality"
    14841488msgstr ""
    14851489
    1486 #: src/lang.cls.php:193
     1490#: src/lang.cls.php:194
    14871491msgid "LQIP Minimum Dimensions"
    14881492msgstr ""
    14891493
    1490 #: src/lang.cls.php:195
     1494#: src/lang.cls.php:196
    14911495msgid "Generate LQIP In Background"
    14921496msgstr ""
    14931497
    1494 #: src/lang.cls.php:196
     1498#: src/lang.cls.php:197
    14951499msgid "Lazy Load Iframes"
    14961500msgstr ""
    14971501
    1498 #: src/lang.cls.php:197
     1502#: src/lang.cls.php:198
    14991503msgid "Add Missing Sizes"
    15001504msgstr ""
    15011505
    1502 #: src/lang.cls.php:198 src/metabox.cls.php:31 src/metabox.cls.php:32
     1506#: src/lang.cls.php:199 src/metabox.cls.php:31 src/metabox.cls.php:32
    15031507#: tpl/page_optm/settings_vpi.tpl.php:12
    15041508msgid "Viewport Images"
    15051509msgstr ""
    15061510
    1507 #: src/lang.cls.php:199
     1511#: src/lang.cls.php:200
    15081512msgid "Viewport Images Cron"
    15091513msgstr ""
    15101514
    1511 #: src/lang.cls.php:201
     1515#: src/lang.cls.php:202
    15121516msgid "Auto Request Cron"
    15131517msgstr ""
    15141518
    1515 #: src/lang.cls.php:202
     1519#: src/lang.cls.php:203
    15161520msgid "Auto Pull Cron"
    15171521msgstr ""
    15181522
    1519 #: src/lang.cls.php:203
     1523#: src/lang.cls.php:204
    15201524msgid "Optimize Original Images"
    15211525msgstr ""
    15221526
    1523 #: src/lang.cls.php:204
     1527#: src/lang.cls.php:205
    15241528msgid "Remove Original Backups"
    15251529msgstr ""
    15261530
    1527 #: src/lang.cls.php:205
     1531#: src/lang.cls.php:206
    15281532msgid "Image WebP Replacement"
    15291533msgstr ""
    15301534
    1531 #: src/lang.cls.php:206
     1535#: src/lang.cls.php:207
    15321536msgid "Optimize Losslessly"
    15331537msgstr ""
    15341538
    1535 #: src/lang.cls.php:207
     1539#: src/lang.cls.php:208
    15361540msgid "Preserve EXIF/XMP data"
    15371541msgstr ""
    15381542
    1539 #: src/lang.cls.php:208
     1543#: src/lang.cls.php:209
    15401544msgid "WebP Attribute To Replace"
    15411545msgstr ""
    15421546
    1543 #: src/lang.cls.php:209
     1547#: src/lang.cls.php:210
    15441548msgid "WebP For Extra srcset"
    15451549msgstr ""
    15461550
    1547 #: src/lang.cls.php:210
     1551#: src/lang.cls.php:211
    15481552msgid "WordPress Image Quality Control"
    15491553msgstr ""
    15501554
    1551 #: src/lang.cls.php:211 tpl/esi_widget_edit.php:36
     1555#: src/lang.cls.php:212 tpl/esi_widget_edit.php:36
    15521556msgid "Enable ESI"
    15531557msgstr ""
    15541558
    1555 #: src/lang.cls.php:212
     1559#: src/lang.cls.php:213
    15561560msgid "Cache Admin Bar"
    15571561msgstr ""
    15581562
    1559 #: src/lang.cls.php:213
     1563#: src/lang.cls.php:214
    15601564msgid "Cache Comment Form"
    15611565msgstr ""
    15621566
    1563 #: src/lang.cls.php:214
     1567#: src/lang.cls.php:215
    15641568msgid "ESI Nonces"
    15651569msgstr ""
    15661570
    1567 #: src/lang.cls.php:215 tpl/page_optm/settings_css.tpl.php:121
     1571#: src/lang.cls.php:216 tpl/page_optm/settings_css.tpl.php:121
    15681572#: tpl/page_optm/settings_css.tpl.php:238 tpl/page_optm/settings_vpi.tpl.php:67
    15691573msgid "Vary Group"
    15701574msgstr ""
    15711575
    1572 #: src/lang.cls.php:216
     1576#: src/lang.cls.php:217
    15731577msgid "Purge All Hooks"
    15741578msgstr ""
    15751579
    1576 #: src/lang.cls.php:217
     1580#: src/lang.cls.php:218
    15771581msgid "Improve HTTP/HTTPS Compatibility"
    15781582msgstr ""
    15791583
    1580 #: src/lang.cls.php:218
     1584#: src/lang.cls.php:219
    15811585msgid "Instant Click"
    15821586msgstr ""
    15831587
    1584 #: src/lang.cls.php:219
     1588#: src/lang.cls.php:220
    15851589msgid "Do Not Cache Cookies"
    15861590msgstr ""
    15871591
    1588 #: src/lang.cls.php:220
     1592#: src/lang.cls.php:221
    15891593msgid "Do Not Cache User Agents"
    15901594msgstr ""
    15911595
    1592 #: src/lang.cls.php:221
     1596#: src/lang.cls.php:222
    15931597msgid "Login Cookie"
    15941598msgstr ""
    15951599
    1596 #: src/lang.cls.php:223
     1600#: src/lang.cls.php:224
    15971601msgid "Frontend Heartbeat Control"
    15981602msgstr ""
    15991603
    1600 #: src/lang.cls.php:224
     1604#: src/lang.cls.php:225
    16011605msgid "Frontend Heartbeat TTL"
    16021606msgstr ""
    16031607
    1604 #: src/lang.cls.php:225
     1608#: src/lang.cls.php:226
    16051609msgid "Backend Heartbeat Control"
    16061610msgstr ""
    16071611
    1608 #: src/lang.cls.php:226
     1612#: src/lang.cls.php:227
    16091613msgid "Backend Heartbeat TTL"
    16101614msgstr ""
    16111615
    1612 #: src/lang.cls.php:227
     1616#: src/lang.cls.php:228
    16131617msgid "Editor Heartbeat"
    16141618msgstr ""
    16151619
    1616 #: src/lang.cls.php:228
     1620#: src/lang.cls.php:229
    16171621msgid "Editor Heartbeat TTL"
    16181622msgstr ""
    16191623
    1620 #: src/lang.cls.php:230
     1624#: src/lang.cls.php:231
    16211625msgid "QUIC.cloud CDN"
    16221626msgstr ""
    16231627
    1624 #: src/lang.cls.php:231
     1628#: src/lang.cls.php:232
    16251629msgid "Use CDN Mapping"
    16261630msgstr ""
    16271631
    1628 #: src/lang.cls.php:232
     1632#: src/lang.cls.php:233
    16291633msgid "CDN URL"
    16301634msgstr ""
    16311635
    1632 #: src/lang.cls.php:233
     1636#: src/lang.cls.php:234
    16331637msgid "Include Images"
    16341638msgstr ""
    16351639
    1636 #: src/lang.cls.php:234
     1640#: src/lang.cls.php:235
    16371641msgid "Include CSS"
    16381642msgstr ""
    16391643
    1640 #: src/lang.cls.php:235
     1644#: src/lang.cls.php:236
    16411645msgid "Include JS"
    16421646msgstr ""
    16431647
    1644 #: src/lang.cls.php:236 tpl/cdn/settings.tpl.php:102
     1648#: src/lang.cls.php:237 tpl/cdn/settings.tpl.php:102
    16451649msgid "Include File Types"
    16461650msgstr ""
    16471651
    1648 #: src/lang.cls.php:237
     1652#: src/lang.cls.php:238
    16491653msgid "HTML Attribute To Replace"
    16501654msgstr ""
    16511655
    1652 #: src/lang.cls.php:238
     1656#: src/lang.cls.php:239
    16531657msgid "Original URLs"
    16541658msgstr ""
    16551659
    1656 #: src/lang.cls.php:239
     1660#: src/lang.cls.php:240
    16571661msgid "Included Directories"
    16581662msgstr ""
    16591663
    1660 #: src/lang.cls.php:240
     1664#: src/lang.cls.php:241
    16611665msgid "Exclude Path"
    16621666msgstr ""
    16631667
    1664 #: src/lang.cls.php:241
     1668#: src/lang.cls.php:242
    16651669msgid "Cloudflare API"
    16661670msgstr ""
    16671671
    1668 #: src/lang.cls.php:244
     1672#: src/lang.cls.php:245
    16691673msgid "Delay"
    16701674msgstr ""
    16711675
    1672 #: src/lang.cls.php:245
     1676#: src/lang.cls.php:246
    16731677msgid "Run Duration"
    16741678msgstr ""
    16751679
    1676 #: src/lang.cls.php:246
     1680#: src/lang.cls.php:247
    16771681msgid "Interval Between Runs"
    16781682msgstr ""
    16791683
    1680 #: src/lang.cls.php:247
     1684#: src/lang.cls.php:248
    16811685msgid "Crawl Interval"
    16821686msgstr ""
    16831687
    1684 #: src/lang.cls.php:248
     1688#: src/lang.cls.php:249
    16851689msgid "Threads"
    16861690msgstr ""
    16871691
    1688 #: src/lang.cls.php:249
     1692#: src/lang.cls.php:250
    16891693msgid "Timeout"
    16901694msgstr ""
    16911695
    1692 #: src/lang.cls.php:250
     1696#: src/lang.cls.php:251
    16931697msgid "Server Load Limit"
    16941698msgstr ""
    16951699
    1696 #: src/lang.cls.php:251
     1700#: src/lang.cls.php:252
    16971701msgid "Role Simulation"
    16981702msgstr ""
    16991703
    1700 #: src/lang.cls.php:252
     1704#: src/lang.cls.php:253
    17011705msgid "Cookie Simulation"
    17021706msgstr ""
    17031707
    1704 #: src/lang.cls.php:253
     1708#: src/lang.cls.php:254
    17051709msgid "Custom Sitemap"
    17061710msgstr ""
    17071711
    1708 #: src/lang.cls.php:254
     1712#: src/lang.cls.php:255
    17091713msgid "Drop Domain from Sitemap"
    17101714msgstr ""
    17111715
    1712 #: src/lang.cls.php:255
     1716#: src/lang.cls.php:256
    17131717msgid "Sitemap Timeout"
    17141718msgstr ""
    17151719
    1716 #: src/lang.cls.php:257 tpl/inc/disabled_all.php:5
     1720#: src/lang.cls.php:258 tpl/inc/disabled_all.php:5
    17171721msgid "Disable All Features"
    17181722msgstr ""
    17191723
    1720 #: src/lang.cls.php:258 tpl/toolbox/log_viewer.tpl.php:11
     1724#: src/lang.cls.php:259 tpl/toolbox/log_viewer.tpl.php:11
    17211725msgid "Debug Log"
    17221726msgstr ""
    17231727
    1724 #: src/lang.cls.php:259
     1728#: src/lang.cls.php:260
    17251729msgid "Admin IPs"
    17261730msgstr ""
    17271731
    1728 #: src/lang.cls.php:260
     1732#: src/lang.cls.php:261
    17291733msgid "Debug Level"
    17301734msgstr ""
    17311735
    1732 #: src/lang.cls.php:261
     1736#: src/lang.cls.php:262
    17331737msgid "Log File Size Limit"
    17341738msgstr ""
    17351739
    1736 #: src/lang.cls.php:262
     1740#: src/lang.cls.php:263
    17371741msgid "Log Cookies"
    17381742msgstr ""
    17391743
    1740 #: src/lang.cls.php:263
     1744#: src/lang.cls.php:264
    17411745msgid "Collapse Query Strings"
    17421746msgstr ""
    17431747
    1744 #: src/lang.cls.php:264
     1748#: src/lang.cls.php:265
    17451749msgid "Debug URI Includes"
    17461750msgstr ""
    17471751
    1748 #: src/lang.cls.php:265
     1752#: src/lang.cls.php:266
    17491753msgid "Debug URI Excludes"
    17501754msgstr ""
    17511755
    1752 #: src/lang.cls.php:266
     1756#: src/lang.cls.php:267
    17531757msgid "Debug String Excludes"
    17541758msgstr ""
    17551759
    1756 #: src/lang.cls.php:268
     1760#: src/lang.cls.php:269
    17571761msgid "Revisions Max Number"
    17581762msgstr ""
    17591763
    1760 #: src/lang.cls.php:269
     1764#: src/lang.cls.php:270
    17611765msgid "Revisions Max Age"
    17621766msgstr ""
     
    19881992msgstr ""
    19891993
    1990 #: thirdparty/litespeed-check.cls.php:111
     1994#: thirdparty/litespeed-check.cls.php:74 thirdparty/litespeed-check.cls.php:136
    19911995msgid ""
    19921996"Please consider disabling the following detected plugins, as they may "
     
    19941998msgstr ""
    19951999
    1996 #: thirdparty/woocommerce.content.tpl.php:16
     2000#: thirdparty/woocommerce.content.tpl.php:17
    19972001msgid "WooCommerce Settings"
    19982002msgstr ""
    19992003
    2000 #: thirdparty/woocommerce.content.tpl.php:21
     2004#: thirdparty/woocommerce.content.tpl.php:22
    20012005#: tpl/cache/settings-advanced.tpl.php:12
    20022006#: tpl/cache/settings_inc.browser.tpl.php:12 tpl/toolbox/heartbeat.tpl.php:14
     
    20052009msgstr ""
    20062010
    2007 #: thirdparty/woocommerce.content.tpl.php:22
     2011#: thirdparty/woocommerce.content.tpl.php:23
    20082012msgid "After verifying that the cache works in general, please test the cart."
    20092013msgstr ""
    20102014
    2011 #: thirdparty/woocommerce.content.tpl.php:23
     2015#: thirdparty/woocommerce.content.tpl.php:24
    20122016msgid "To test the cart, visit the <a %s>FAQ</a>."
    20132017msgstr ""
    20142018
    2015 #: thirdparty/woocommerce.content.tpl.php:24
     2019#: thirdparty/woocommerce.content.tpl.php:25
    20162020msgid ""
    20172021"By default, the My Account, Checkout, and Cart pages are automatically "
     
    20202024msgstr ""
    20212025
    2022 #: thirdparty/woocommerce.content.tpl.php:31
     2026#: thirdparty/woocommerce.content.tpl.php:33
    20232027msgid "Product Update Interval"
    20242028msgstr ""
    20252029
    2026 #: thirdparty/woocommerce.content.tpl.php:36
     2030#: thirdparty/woocommerce.content.tpl.php:38
    20272031msgid "Purge product on changes to the quantity or stock status."
    20282032msgstr ""
    20292033
    2030 #: thirdparty/woocommerce.content.tpl.php:36
     2034#: thirdparty/woocommerce.content.tpl.php:38
    20312035msgid "Purge categories only when stock status changes."
    20322036msgstr ""
    20332037
    2034 #: thirdparty/woocommerce.content.tpl.php:37
     2038#: thirdparty/woocommerce.content.tpl.php:39
    20352039msgid "Purge product and categories only when the stock status changes."
    20362040msgstr ""
    20372041
    2038 #: thirdparty/woocommerce.content.tpl.php:38
     2042#: thirdparty/woocommerce.content.tpl.php:40
    20392043msgid "Purge product only when the stock status changes."
    20402044msgstr ""
    20412045
    2042 #: thirdparty/woocommerce.content.tpl.php:38
     2046#: thirdparty/woocommerce.content.tpl.php:40
    20432047msgid "Do not purge categories on changes to the quantity or stock status."
    20442048msgstr ""
    20452049
    2046 #: thirdparty/woocommerce.content.tpl.php:39
     2050#: thirdparty/woocommerce.content.tpl.php:41
    20472051msgid ""
    20482052"Always purge both product and categories on changes to the quantity or stock "
     
    20502054msgstr ""
    20512055
    2052 #: thirdparty/woocommerce.content.tpl.php:52
     2056#: thirdparty/woocommerce.content.tpl.php:54
    20532057msgid ""
    20542058"Determines how changes in product quantity and product stock status affect "
     
    20562060msgstr ""
    20572061
     2062#: thirdparty/woocommerce.content.tpl.php:62
     2063msgid "Vary for Mini Cart"
     2064msgstr ""
     2065
     2066#: thirdparty/woocommerce.content.tpl.php:69
     2067msgid ""
     2068"Generate a separate vary cache copy for the mini cart when the cart is not "
     2069"empty."
     2070msgstr ""
     2071
     2072#: thirdparty/woocommerce.content.tpl.php:70
     2073msgid ""
     2074"If your theme does not use JS to update the mini cart, you must enable this "
     2075"option to display the correct cart contents."
     2076msgstr ""
     2077
    20582078#: thirdparty/woocommerce.tab.tpl.php:3
    20592079msgid "WooCommerce"
     
    20842104msgstr ""
    20852105
    2086 #. #-#-#-#-#  litespeed-cache.pot (LiteSpeed Cache 5.6)  #-#-#-#-#
     2106#. #-#-#-#-#  litespeed-cache.pot (LiteSpeed Cache 5.7)  #-#-#-#-#
    20872107#. Plugin Name of the plugin/theme
    20882108#: tpl/banner/new_version.php:57 tpl/banner/new_version_dev.tpl.php:12
     
    48534873msgstr ""
    48544874
    4855 #: tpl/page_optm/entry.tpl.php:8 tpl/page_optm/settings_html.tpl.php:7
     4875#: tpl/page_optm/entry.tpl.php:8 tpl/page_optm/settings_html.tpl.php:9
    48564876msgid "HTML Settings"
    48574877msgstr ""
     
    49544974
    49554975#: tpl/page_optm/settings_css.tpl.php:185
    4956 #: tpl/page_optm/settings_html.tpl.php:129 tpl/page_optm/settings_js.tpl.php:73
     4976#: tpl/page_optm/settings_html.tpl.php:150 tpl/page_optm/settings_js.tpl.php:73
    49574977msgid ""
    49584978"This can improve your speed score in services like Pingdom, GTmetrix and "
     
    50145034msgstr ""
    50155035
    5016 #: tpl/page_optm/settings_html.tpl.php:20
     5036#: tpl/page_optm/settings_html.tpl.php:23
    50175037msgid "Minify HTML content."
    50185038msgstr ""
    50195039
    5020 #: tpl/page_optm/settings_html.tpl.php:33
     5040#: tpl/page_optm/settings_html.tpl.php:36
    50215041msgid "Prefetching DNS can reduce latency for visitors."
    50225042msgstr ""
    50235043
    5024 #: tpl/page_optm/settings_html.tpl.php:34
     5044#: tpl/page_optm/settings_html.tpl.php:37
     5045#: tpl/page_optm/settings_html.tpl.php:68
    50255046msgid "For example"
    50265047msgstr ""
    50275048
    5028 #: tpl/page_optm/settings_html.tpl.php:49
     5049#: tpl/page_optm/settings_html.tpl.php:52
    50295050msgid ""
    50305051"Automatically enable DNS prefetching for all URLs in the document, including "
     
    50325053msgstr ""
    50335054
    5034 #: tpl/page_optm/settings_html.tpl.php:50
     5055#: tpl/page_optm/settings_html.tpl.php:53
    50355056msgid "This can improve the page loading speed."
    50365057msgstr ""
    50375058
    5038 #: tpl/page_optm/settings_html.tpl.php:64
     5059#: tpl/page_optm/settings_html.tpl.php:67
     5060msgid "Preconnecting speeds up future loads from a given origin."
     5061msgstr ""
     5062
     5063#: tpl/page_optm/settings_html.tpl.php:83
    50395064msgid "Delay rendering off-screen HTML elements by its selector."
    50405065msgstr ""
    50415066
    5042 #: tpl/page_optm/settings_html.tpl.php:79
     5067#: tpl/page_optm/settings_html.tpl.php:98
    50435068msgid "Remove query strings from internal static resources."
    50445069msgstr ""
    50455070
    5046 #: tpl/page_optm/settings_html.tpl.php:82
     5071#: tpl/page_optm/settings_html.tpl.php:102
    50475072msgid "Google reCAPTCHA will be bypassed automatically."
    50485073msgstr ""
    50495074
    5050 #: tpl/page_optm/settings_html.tpl.php:86
     5075#: tpl/page_optm/settings_html.tpl.php:107
    50515076msgid "Append query string %s to the resources to bypass this action."
    50525077msgstr ""
    50535078
    5054 #: tpl/page_optm/settings_html.tpl.php:100
     5079#: tpl/page_optm/settings_html.tpl.php:121
    50555080msgid ""
    50565081"Use Web Font Loader library to load Google Fonts asynchronously while "
     
    50585083msgstr ""
    50595084
    5060 #: tpl/page_optm/settings_html.tpl.php:101
     5085#: tpl/page_optm/settings_html.tpl.php:122
    50615086msgid ""
    50625087"This will also add a preconnect to Google Fonts to establish a connection "
     
    50645089msgstr ""
    50655090
    5066 #: tpl/page_optm/settings_html.tpl.php:115
     5091#: tpl/page_optm/settings_html.tpl.php:136
    50675092msgid "Prevent Google Fonts from loading on all pages."
    50685093msgstr ""
    50695094
    5070 #: tpl/page_optm/settings_html.tpl.php:128
     5095#: tpl/page_optm/settings_html.tpl.php:149
    50715096msgid ""
    50725097"Stop loading WordPress.org emoji. Browser default emoji will be displayed "
     
    50745099msgstr ""
    50755100
    5076 #: tpl/page_optm/settings_html.tpl.php:142
     5101#: tpl/page_optm/settings_html.tpl.php:163
    50775102msgid "This option will remove all %s tags from HTML."
    50785103msgstr ""
  • litespeed-cache/trunk/lib/guest.cls.php

    r2574982 r2977143  
    11<?php
     2
    23namespace LiteSpeed\Lib;
    34
     
    78 * @since 4.1
    89 */
    9 class Guest {
     10class Guest
     11{
    1012    const CONF_FILE = '.litespeed_conf.dat';
    1113    const HASH                  = 'hash'; // Not set-able
     
    2628     * @since 4.1
    2729     */
    28     public function __construct() {
    29         ! defined( 'LSCWP_CONTENT_FOLDER' ) && define( 'LSCWP_CONTENT_FOLDER', dirname( dirname( dirname( __DIR__ ) ) ) );
     30    public function __construct()
     31    {
     32        !defined('LSCWP_CONTENT_FOLDER') && define('LSCWP_CONTENT_FOLDER', dirname(dirname(dirname(__DIR__))));
    3033        // Load config
    31         $this->_conf = file_get_contents( LSCWP_CONTENT_FOLDER . '/' . self::CONF_FILE );
    32         if ( $this->_conf ) {
    33             $this->_conf = json_decode( $this->_conf, true );
     34        $this->_conf = file_get_contents(LSCWP_CONTENT_FOLDER . '/' . self::CONF_FILE);
     35        if ($this->_conf) {
     36            $this->_conf = json_decode($this->_conf, true);
    3437        }
    3538
    36         if ( ! empty( $this->_conf[ self::O_CACHE_LOGIN_COOKIE ] ) ) {
    37             self::$_vary_name = $this->_conf[ self::O_CACHE_LOGIN_COOKIE ];
     39        if (!empty($this->_conf[self::O_CACHE_LOGIN_COOKIE])) {
     40            self::$_vary_name = $this->_conf[self::O_CACHE_LOGIN_COOKIE];
    3841        }
    3942    }
     
    4447     * @since  4.0
    4548     */
    46     public function update_guest_vary() {
     49    public function update_guest_vary()
     50    {
    4751        // This process must not be cached
    48         header( 'X-LiteSpeed-Cache-Control: no-cache' );
     52        /**
     53         * @reference https://wordpress.org/support/topic/soft-404-from-google-search-on-litespeed-cache-guest-vary-php/#post-16838583
     54         */
     55        header('X-Robots-Tag: noindex');
     56        header('X-LiteSpeed-Cache-Control: no-cache');
    4957
    50         if ( $this->always_guest() ) {
     58        if ($this->always_guest()) {
    5159            echo '[]';
    5260            exit;
     
    5462
    5563        // If contains vary already, don't reload to avoid infinite loop when parent page having browser cache
    56         if ( $this->_conf && self::has_vary() ) {
     64        if ($this->_conf && self::has_vary()) {
    5765            echo '[]';
    5866            exit;
     
    6169        // Send vary cookie
    6270        $vary = 'guest_mode:1';
    63         if ( $this->_conf && empty( $this->_conf[ self::O_DEBUG ] ) ) {
    64             $vary = md5( $this->_conf[ self::HASH ] . $vary );
     71        if ($this->_conf && empty($this->_conf[self::O_DEBUG])) {
     72            $vary = md5($this->_conf[self::HASH] . $vary);
    6573        }
    6674
    6775        $expire = time() + 2 * 86400;
    68         $is_ssl = ! empty( $this->_conf[ self::O_UTIL_NO_HTTPS_VARY ] ) ? false : $this->is_ssl();
    69         setcookie( self::$_vary_name, $vary, $expire, '/', false, $is_ssl, true );
     76        $is_ssl = !empty($this->_conf[self::O_UTIL_NO_HTTPS_VARY]) ? false : $this->is_ssl();
     77        setcookie(self::$_vary_name, $vary, $expire, '/', false, $is_ssl, true);
    7078
    7179        // return json
    72         echo json_encode( array( 'reload' => 'yes' ) );
     80        echo json_encode(array('reload' => 'yes'));
    7381        exit;
    7482    }
     
    7987     * @since 4.1
    8088     */
    81     private function is_ssl() {
    82         if ( isset( $_SERVER['HTTPS'] ) ) {
    83             if ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) {
     89    private function is_ssl()
     90    {
     91        if (isset($_SERVER['HTTPS'])) {
     92            if ('on' === strtolower($_SERVER['HTTPS'])) {
    8493                return true;
    8594            }
    8695
    87             if ( '1' == $_SERVER['HTTPS'] ) {
     96            if ('1' == $_SERVER['HTTPS']) {
    8897                return true;
    8998            }
    90         } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
     99        } elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) {
    91100            return true;
    92101        }
     
    100109     * @access public
    101110     */
    102     public static function has_vary() {
    103         if ( empty( $_COOKIE[ self::$_vary_name ] ) ) {
     111    public static function has_vary()
     112    {
     113        if (empty($_COOKIE[self::$_vary_name])) {
    104114            return false;
    105115        }
    106         return $_COOKIE[ self::$_vary_name ];
     116        return $_COOKIE[self::$_vary_name];
    107117    }
    108118
     
    112122     * @since  4.0
    113123     */
    114     public function always_guest() {
    115         if ( empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
     124    public function always_guest()
     125    {
     126        if (empty($_SERVER['HTTP_USER_AGENT'])) {
    116127            return false;
    117128        }
    118129
    119         if ( $this->_conf[ self::O_GUEST_UAS ] ) {
     130        if ($this->_conf[self::O_GUEST_UAS]) {
    120131            $quoted_uas = array();
    121             foreach ( $this->_conf[ self::O_GUEST_UAS ] as $v ) {
    122                 $quoted_uas[] = preg_quote( $v, '#' );
     132            foreach ($this->_conf[self::O_GUEST_UAS] as $v) {
     133                $quoted_uas[] = preg_quote($v, '#');
    123134            }
    124             $match = preg_match( '#' . implode( '|', $quoted_uas ) . '#i', $_SERVER[ 'HTTP_USER_AGENT' ] );
    125             if ( $match ) {
     135            $match = preg_match('#' . implode('|', $quoted_uas) . '#i', $_SERVER['HTTP_USER_AGENT']);
     136            if ($match) {
    126137                return true;
    127138            }
    128139        }
    129140
    130         if ( $this->ip_access( $this->_conf[ self::O_GUEST_IPS ] ) ) {
     141        if ($this->ip_access($this->_conf[self::O_GUEST_IPS])) {
    131142            return true;
    132143        }
     
    141152     * @access public
    142153     */
    143     public function ip_access( $ip_list ) {
    144         if ( ! $ip_list ) {
     154    public function ip_access($ip_list)
     155    {
     156        if (!$ip_list) {
    145157            return false;
    146158        }
    147         if ( ! isset( self::$_ip ) ) {
     159        if (!isset(self::$_ip)) {
    148160            self::$_ip = self::get_ip();
    149161        }
     
    155167        //  for($i = 0; $i <= 3; $i++) if($ip[$i] == '*') $ip_list[$key][$i] = $uip[$i];
    156168        // }
    157         return in_array( self::$_ip, $ip_list );
     169        return in_array(self::$_ip, $ip_list);
    158170    }
    159171
     
    166178     * @return string
    167179     */
    168     public static function get_ip() {
     180    public static function get_ip()
     181    {
    169182        $_ip = '';
    170         if ( function_exists( 'apache_request_headers' ) ) {
     183        if (function_exists('apache_request_headers')) {
    171184            $apache_headers = apache_request_headers();
    172             $_ip = ! empty( $apache_headers['True-Client-IP'] ) ? $apache_headers['True-Client-IP'] : false;
    173             if ( ! $_ip ) {
    174                 $_ip = ! empty( $apache_headers['X-Forwarded-For'] ) ? $apache_headers['X-Forwarded-For'] : false;
    175                 $_ip = explode( ',', $_ip );
    176                 $_ip = $_ip[ 0 ];
     185            $_ip = !empty($apache_headers['True-Client-IP']) ? $apache_headers['True-Client-IP'] : false;
     186            if (!$_ip) {
     187                $_ip = !empty($apache_headers['X-Forwarded-For']) ? $apache_headers['X-Forwarded-For'] : false;
     188                $_ip = explode(',', $_ip);
     189                $_ip = $_ip[0];
    177190            }
    178 
    179191        }
    180192
    181         if ( ! $_ip ) {
    182             $_ip = ! empty( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : false;
     193        if (!$_ip) {
     194            $_ip = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : false;
    183195        }
    184196        return $_ip;
    185197    }
    186 
    187 
    188198}
  • litespeed-cache/trunk/litespeed-cache.php

    r2954001 r2977143  
    55 * Plugin URI:        https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
    66 * Description:       High-performance page caching and site optimization from LiteSpeed
    7  * Version:           5.6
     7 * Version:           5.7
    88 * Author:            LiteSpeed Technologies
    99 * Author URI:        https://www.litespeedtech.com
     
    3535}
    3636
    37 !defined('LSCWP_V') && define('LSCWP_V', '5.6');
     37!defined('LSCWP_V') && define('LSCWP_V', '5.7');
    3838
    3939!defined('LSCWP_CONTENT_DIR') && define('LSCWP_CONTENT_DIR', WP_CONTENT_DIR);
  • litespeed-cache/trunk/readme.txt

    r2954001 r2977143  
    33Tags: caching, optimize, performance, pagespeed, core web vitals, seo, speed, image optimize, compress, object cache, redis, memcached, database cleaner
    44Requires at least: 4.0
    5 Tested up to: 6.3
    6 Stable tag: 5.6
     5Tested up to: 6.3.1
     6Stable tag: 5.7
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl.html
     
    251251== Changelog ==
    252252
    253 = 5.6 - Aug 15 2023 =
     253= 5.7 - Oct 10 2023 =
     254* 🌱**Page Optimize** New option available: Preconnect. (xguiboy/Mukesh Patel)
     255* 🌱**3rd** New Vary for Mini Cart option for Woocommerce. (Ruikai)
     256* **Cloud** Force syncing the configuration to QUIC.cloud if CDN is reenabled.
     257* **Cloud** Force syncing the configuration to QUIC.cloud if domain key is readded.
     258* **Cloud** Limit multi-line fields when posting to QC.
     259* **Cache** Treat HEAD requests as cacheable as GET. (George Wang)
     260* 🐞**ESI** Patched a possible vulnerability issue. (István Márton@Wordfence #841011)
     261* 🐞**ESI** Overwrite SCRIPT_URI to prevent ESI sub request resulting in redirections. (Tobolo)
     262* 🐞**Image Optimize** Bypass unnecessary image processing when images were only partially optimized. (Ruikai)
     263* 🐞**Guest** Guest mode will not enable WebP directly anymore. (Michael Heymann)
     264* **CDN** Auto disable CDN if CDN URL is invalid. (Ruikai)
     265* **CDN** Fixed a null parameter warning for PHP v8.1 (#584)
     266* **API** Added `litespeed_media_add_missing_sizes` filter to allow bypassing Media's "add missing sizes" option (for Guest Optimization and otherwise). (PR #564)
     267* **Guest** Fixed soft 404 and robots.txt report for guest.vary.php.
     268* **Vary** Enabled `litespeed_vary_cookies` for LSWS Enterprise.
     269* **GUI** Stopped WebP tip from wrongly displaying when Guest Mode is off.
     270* **GUI** Added QUIC.cloud promotion postbox on dashboard page.
     271* **3rd** Added `pagespeed ninja` to blocklist due to its bad bahavior.
     272
     273= 5.6 - Aug 1 2023 =
    254274* 🌱**Page Optimize** New JS Delay Includes option. (Mitchell Krog/Gerard Reches/Ignacy Hołoga)
    255275* **Crawler** Sitemap can use search for URL now.
  • litespeed-cache/trunk/src/admin-settings.cls.php

    r2761310 r2977143  
    11<?php
     2
    23/**
    34 * The admin settings handler of the plugin.
     
    910 * @author     LiteSpeed Technologies <[email protected]>
    1011 */
     12
    1113namespace LiteSpeed;
    12 defined( 'WPINC' ) || exit;
    13 
    14 class Admin_Settings extends Base {
     14
     15defined('WPINC') || exit;
     16
     17class Admin_Settings extends Base
     18{
    1519    const ENROLL = '_settings-enroll';
    1620
     
    2529     * @access public
    2630     */
    27     public function save( $raw_data ) {
    28         Debug2::debug( '[Settings] saving' );
    29 
    30         if ( empty( $raw_data[ self::ENROLL ] ) ) {
    31             exit( 'No fields' );
    32         }
    33 
    34         $raw_data = Admin::cleanup_text( $raw_data );
     31    public function save($raw_data)
     32    {
     33        Debug2::debug('[Settings] saving');
     34
     35        if (empty($raw_data[self::ENROLL])) {
     36            exit('No fields');
     37        }
     38
     39        $raw_data = Admin::cleanup_text($raw_data);
    3540
    3641        // Convert data to config format
    3742        $the_matrix = array();
    38         foreach ( array_unique( $raw_data[ self::ENROLL ] ) as $id ) {
     43        foreach (array_unique($raw_data[self::ENROLL]) as $id) {
    3944            $child = false;
    4045            // Drop array format
    41             if ( strpos( $id, '[' ) !== false ) {
    42                 if ( strpos( $id, self::O_CDN_MAPPING ) === 0 || strpos( $id, self::O_CRAWLER_COOKIES ) === 0 ) { // CDN child | Cookie Crawler settings
    43                     $child = substr( $id, strpos( $id, '[' ) + 1, strpos( $id, ']' ) - strpos( $id, '[' ) - 1 );
    44                     $id = substr( $id, 0, strpos( $id, '[' ) ); // Drop ending []; Compatible with xx[0] way from CLI
    45                 }
    46                 else {
    47                     $id = substr( $id, 0, strpos( $id, '[' ) ); // Drop ending []
    48                 }
    49             }
    50 
    51             if ( ! array_key_exists( $id, self::$_default_options ) ) {
     46            if (strpos($id, '[') !== false) {
     47                if (strpos($id, self::O_CDN_MAPPING) === 0 || strpos($id, self::O_CRAWLER_COOKIES) === 0) { // CDN child | Cookie Crawler settings
     48                    $child = substr($id, strpos($id, '[') + 1, strpos($id, ']') - strpos($id, '[') - 1);
     49                    $id = substr($id, 0, strpos($id, '[')); // Drop ending []; Compatible with xx[0] way from CLI
     50                } else {
     51                    $id = substr($id, 0, strpos($id, '[')); // Drop ending []
     52                }
     53            }
     54
     55            if (!array_key_exists($id, self::$_default_options)) {
    5256                continue;
    5357            }
    5458
    5559            // Validate $child
    56             if ( $id == self::O_CDN_MAPPING ) {
    57                 if ( ! in_array( $child, array(
     60            if ($id == self::O_CDN_MAPPING) {
     61                if (!in_array($child, array(
    5862                    self::CDN_MAPPING_URL,
    5963                    self::CDN_MAPPING_INC_IMG,
     
    6165                    self::CDN_MAPPING_INC_JS,
    6266                    self::CDN_MAPPING_FILETYPE,
    63                 ) ) ) {
     67                ))) {
    6468                    continue;
    6569                }
    6670            }
    67             if ( $id == self::O_CRAWLER_COOKIES ) {
    68                 if ( ! in_array( $child, array(
     71            if ($id == self::O_CRAWLER_COOKIES) {
     72                if (!in_array($child, array(
    6973                    self::CRWL_COOKIE_NAME,
    7074                    self::CRWL_COOKIE_VALS,
    71                 ) ) ) {
     75                ))) {
    7276                    continue;
    7377                }
     
    7680            $data = false;
    7781
    78             if ( $child ) {
    79                 $data = ! empty( $raw_data[ $id ][ $child ] ) ? $raw_data[ $id ][ $child ] : false; // []=xxx or [0]=xxx
    80             }
    81             else {
    82                 $data = ! empty( $raw_data[ $id ] ) ? $raw_data[ $id ] : false;
     82            if ($child) {
     83                $data = !empty($raw_data[$id][$child]) ? $raw_data[$id][$child] : false; // []=xxx or [0]=xxx
     84            } else {
     85                $data = !empty($raw_data[$id]) ? $raw_data[$id] : false;
    8386            }
    8487
     
    8689             * Sanitize the value
    8790             */
    88             if ( $id == self::O_CDN_MAPPING || $id == self::O_CRAWLER_COOKIES ) {
     91            if ($id == self::O_CDN_MAPPING || $id == self::O_CRAWLER_COOKIES) {
    8992                // Use existing in queue data if existed (Only available when $child != false)
    90                 $data2 = array_key_exists( $id, $the_matrix ) ? $the_matrix[ $id ] : ( defined( 'WP_CLI' ) && WP_CLI ? $this->conf( $id ) : array() );
    91             }
    92             switch ( $id ) {
     93                $data2 = array_key_exists($id, $the_matrix) ? $the_matrix[$id] : (defined('WP_CLI') && WP_CLI ? $this->conf($id) : array());
     94            }
     95            switch ($id) {
    9396                case self::O_CDN_MAPPING:
    9497                    /**
     
    104107                     *      cdn-mapping[ 2 ][ url ] = 'xxx2'
    105108                     */
    106                     if ( $data ) foreach ( $data as $k => $v ) {
    107                         if ( $child == self::CDN_MAPPING_FILETYPE ) {
    108                             $v = Utility::sanitize_lines( $v );
    109                         }
    110                         if ( $child == self::CDN_MAPPING_URL ) {
    111                             $v = trailingslashit( $v );
    112                         }
    113                         if ( in_array( $child, array(
     109                    if ($data) foreach ($data as $k => $v) {
     110                        if ($child == self::CDN_MAPPING_FILETYPE) {
     111                            $v = Utility::sanitize_lines($v);
     112                        }
     113                        if ($child == self::CDN_MAPPING_URL) {
     114                            # If not a valid URL, turn off CDN
     115                            if (strpos($v, 'https://') !== 0) {
     116                                self::debug('❌ CDN mapping set to OFF due to invalid URL');
     117                                $the_matrix[self::O_CDN] = false;
     118                            }
     119                            $v = trailingslashit($v);
     120                        }
     121                        if (in_array($child, array(
    114122                            self::CDN_MAPPING_INC_IMG,
    115123                            self::CDN_MAPPING_INC_CSS,
    116124                            self::CDN_MAPPING_INC_JS,
    117                         ) ) ) {
     125                        ))) {
    118126                            // Because these can't be auto detected in `config->update()`, need to format here
    119127                            $v = $v === 'false' ? 0 : (bool) $v;
    120128                        }
    121129
    122                         if ( empty( $data2[ $k ] ) ) {
    123                             $data2[ $k ] = array();
    124                         }
    125 
    126                         $data2[ $k ][ $child ] = $v;
     130                        if (empty($data2[$k])) {
     131                            $data2[$k] = array();
     132                        }
     133
     134                        $data2[$k][$child] = $v;
    127135                    }
    128136
     
    147155                     * empty line for `vals` use literal `_null`
    148156                     */
    149                     if ( $data ) foreach ( $data as $k => $v ) {
    150                         if ( $child == self::CRWL_COOKIE_VALS ) {
    151                             $v = Utility::sanitize_lines( $v );
    152                         }
    153 
    154                         if ( empty( $data2[ $k ] ) ) {
    155                             $data2[ $k ] = array();
    156                         }
    157 
    158                         $data2[ $k ][ $child ] = $v;
     157                    if ($data) foreach ($data as $k => $v) {
     158                        if ($child == self::CRWL_COOKIE_VALS) {
     159                            $v = Utility::sanitize_lines($v);
     160                        }
     161
     162                        if (empty($data2[$k])) {
     163                            $data2[$k] = array();
     164                        }
     165
     166                        $data2[$k][$child] = $v;
    159167                    }
    160168
     
    162170                    break;
    163171
    164                 // Cache exclude cat
     172                    // Cache exclude cat
    165173                case self::O_CACHE_EXC_CAT:
    166174                    $data2 = array();
    167                     $data = Utility::sanitize_lines( $data );
    168                     foreach ( $data as $v ) {
    169                         $cat_id = get_cat_ID( $v );
    170                         if ( ! $cat_id ) {
     175                    $data = Utility::sanitize_lines($data);
     176                    foreach ($data as $v) {
     177                        $cat_id = get_cat_ID($v);
     178                        if (!$cat_id) {
    171179                            continue;
    172180                        }
     
    177185                    break;
    178186
    179                 // Cache exclude tag
    180                 case self::O_CACHE_EXC_TAG :
     187                    // Cache exclude tag
     188                case self::O_CACHE_EXC_TAG:
    181189                    $data2 = array();
    182                     $data = Utility::sanitize_lines( $data );
    183                     foreach ( $data as $v ) {
    184                         $term = get_term_by( 'name', $v, 'post_tag' );
    185                         if ( ! $term ) {
     190                    $data = Utility::sanitize_lines($data);
     191                    foreach ($data as $v) {
     192                        $term = get_term_by('name', $v, 'post_tag');
     193                        if (!$term) {
    186194                            // todo: can show the error in admin error msg
    187195                            continue;
     
    197205            }
    198206
    199             $the_matrix[ $id ] = $data;
     207            $the_matrix[$id] = $data;
    200208        }
    201209
    202210        // Special handler for CDN/Crawler 2d list to drop empty rows
    203         foreach ( $the_matrix as $id => $data ) {
     211        foreach ($the_matrix as $id => $data) {
    204212            /**
    205213             *      cdn-mapping[ 0 ][ url ] = 'xxx'
     
    210218             *      crawler-cookie[ 2 ][ name ] = 'xxx2'
    211219             */
    212             if ( $id == self::O_CDN_MAPPING || $id == self::O_CRAWLER_COOKIES ) {
     220            if ($id == self::O_CDN_MAPPING || $id == self::O_CRAWLER_COOKIES) {
    213221                // Drop this line if all children elements are empty
    214                 foreach ( $data as $k => $v ) {
    215                     foreach ( $v as $v2 ) {
    216                         if ( $v2 ) {
     222                foreach ($data as $k => $v) {
     223                    foreach ($v as $v2) {
     224                        if ($v2) {
    217225                            continue 2;
    218226                        }
    219227                    }
    220228                    // If hit here, means all empty
    221                     unset( $the_matrix[ $id ][ $k ] );
     229                    unset($the_matrix[$id][$k]);
    222230                }
    223231            }
    224232
    225233            // Don't allow repeated cookie name
    226             if ( $id == self::O_CRAWLER_COOKIES ) {
     234            if ($id == self::O_CRAWLER_COOKIES) {
    227235                $existed = array();
    228                 foreach ( $the_matrix[ $id ] as $k => $v ) {
    229                     if ( ! $v[ self::CRWL_COOKIE_NAME ] || in_array( $v[ self::CRWL_COOKIE_NAME ], $existed ) ) { // Filter repeated or empty name
    230                         unset( $the_matrix[ $id ][ $k ] );
     236                foreach ($the_matrix[$id] as $k => $v) {
     237                    if (!$v[self::CRWL_COOKIE_NAME] || in_array($v[self::CRWL_COOKIE_NAME], $existed)) { // Filter repeated or empty name
     238                        unset($the_matrix[$id][$k]);
    231239                        continue;
    232240                    }
    233241
    234                     $existed[] = $v[ self::CRWL_COOKIE_NAME ];
     242                    $existed[] = $v[self::CRWL_COOKIE_NAME];
    235243                }
    236244            }
     
    238246            // CDN mapping allow URL values repeated
    239247            // if ( $id == self::O_CDN_MAPPING ) {}
     248
     249            // tmp fix the 3rd part woo update hook issue when enabling vary cookie
     250            if ($id == 'wc_cart_vary') {
     251                if ($data)
     252                    add_filter('litespeed_vary_cookies', function ($list) {
     253                        $list[] = 'woocommerce_cart_hash';
     254                        return array_unique($list);
     255                    });
     256                else {
     257                    add_filter('litespeed_vary_cookies', function ($list) {
     258                        if (in_array('woocommerce_cart_hash', $list)) {
     259                            unset($list[array_search('woocommerce_cart_hash', $list)]);
     260                        }
     261                        return array_unique($list);
     262                    });
     263                }
     264            }
    240265        }
    241266
    242267        // id validation will be inside
    243         $this->cls( 'Conf' )->update_confs( $the_matrix );
    244 
    245         $msg = __( 'Options saved.', 'litespeed-cache' );
    246         Admin_Display::succeed( $msg );
     268        $this->cls('Conf')->update_confs($the_matrix);
     269
     270        $msg = __('Options saved.', 'litespeed-cache');
     271        Admin_Display::succeed($msg);
    247272    }
    248273
     
    253278     * @access public
    254279     */
    255     public function network_save( $raw_data ) {
    256         Debug2::debug( '[Settings] network saving' );
    257 
    258         if ( empty( $raw_data[ self::ENROLL ] ) ) {
    259             exit( 'No fields' );
    260         }
    261 
    262         $raw_data = Admin::cleanup_text( $raw_data );
    263 
    264         foreach ( array_unique( $raw_data[ self::ENROLL ] ) as $id ) {
     280    public function network_save($raw_data)
     281    {
     282        Debug2::debug('[Settings] network saving');
     283
     284        if (empty($raw_data[self::ENROLL])) {
     285            exit('No fields');
     286        }
     287
     288        $raw_data = Admin::cleanup_text($raw_data);
     289
     290        foreach (array_unique($raw_data[self::ENROLL]) as $id) {
    265291            // Append current field to setting save
    266             if ( ! array_key_exists( $id, self::$_default_site_options ) ) {
     292            if (!array_key_exists($id, self::$_default_site_options)) {
    267293                continue;
    268294            }
    269295
    270             $data = ! empty( $raw_data[ $id ] ) ? $raw_data[ $id ] : false;
     296            $data = !empty($raw_data[$id]) ? $raw_data[$id] : false;
    271297
    272298            // id validation will be inside
    273             $this->cls( 'Conf' )->network_update( $id, $data );
     299            $this->cls('Conf')->network_update($id, $data);
    274300        }
    275301
     
    277303        Activation::cls()->update_files();
    278304
    279         $msg = __( 'Options saved.', 'litespeed-cache' );
    280         Admin_Display::succeed( $msg );
     305        $msg = __('Options saved.', 'litespeed-cache');
     306        Admin_Display::succeed($msg);
    281307    }
    282308
     
    290316     * @return string the updated location string.
    291317     */
    292     public static function widget_save_err( $location ) {
    293         return str_replace( '?message=0', '?error=0', $location ) ;
     318    public static function widget_save_err($location)
     319    {
     320        return str_replace('?message=0', '?error=0', $location);
    294321    }
    295322
     
    306333     * @return mixed Updated settings on success, false on error.
    307334     */
    308     public static function validate_widget_save( $instance, $new_instance, $old_instance, $widget ) {
    309         if ( empty( $new_instance ) ) {
     335    public static function validate_widget_save($instance, $new_instance, $old_instance, $widget)
     336    {
     337        if (empty($new_instance)) {
    310338            return $instance;
    311339        }
    312340
    313         if ( ! isset( $new_instance[ ESI::WIDGET_O_ESIENABLE ] ) || ! isset( $new_instance[ ESI::WIDGET_O_TTL ] ) ) {
     341        if (!isset($new_instance[ESI::WIDGET_O_ESIENABLE]) || !isset($new_instance[ESI::WIDGET_O_TTL])) {
    314342            return $instance;
    315343        }
    316344
    317         $esi = intval( $new_instance[ ESI::WIDGET_O_ESIENABLE ] ) % 3;
    318         $ttl = (int) $new_instance[ ESI::WIDGET_O_TTL ];
    319 
    320         if ( $ttl != 0 && $ttl < 30 ) {
    321             add_filter( 'wp_redirect', __CLASS__ . '::widget_save_err' ) ;
    322             return false ; // invalid ttl.
    323         }
    324 
    325         if ( empty( $instance[ Conf::OPTION_NAME ] ) ) {// todo: to be removed
    326             $instance[ Conf::OPTION_NAME ] = array() ;
    327         }
    328         $instance[ Conf::OPTION_NAME ][ ESI::WIDGET_O_ESIENABLE ] = $esi ;
    329         $instance[ Conf::OPTION_NAME ][ ESI::WIDGET_O_TTL ] = $ttl ;
    330 
    331         $current = ! empty( $old_instance[ Conf::OPTION_NAME ] ) ? $old_instance[ Conf::OPTION_NAME ] : false ;
    332         if ( ! strpos( $_SERVER[ 'HTTP_REFERER' ], '/wp-admin/customize.php') ) {
    333             if ( ! $current || $esi != $current[ ESI::WIDGET_O_ESIENABLE ] ) {
    334                 Purge::purge_all( 'Wdiget ESI_enable changed' ) ;
    335             }
    336             elseif ( $ttl != 0 && $ttl != $current[ ESI::WIDGET_O_TTL ] ) {
    337                 Purge::add( Tag::TYPE_WIDGET . $widget->id ) ;
    338             }
    339 
    340             Purge::purge_all( 'Wdiget saved' ) ;
    341         }
    342         return $instance ;
     345        $esi = intval($new_instance[ESI::WIDGET_O_ESIENABLE]) % 3;
     346        $ttl = (int) $new_instance[ESI::WIDGET_O_TTL];
     347
     348        if ($ttl != 0 && $ttl < 30) {
     349            add_filter('wp_redirect', __CLASS__ . '::widget_save_err');
     350            return false; // invalid ttl.
     351        }
     352
     353        if (empty($instance[Conf::OPTION_NAME])) { // todo: to be removed
     354            $instance[Conf::OPTION_NAME] = array();
     355        }
     356        $instance[Conf::OPTION_NAME][ESI::WIDGET_O_ESIENABLE] = $esi;
     357        $instance[Conf::OPTION_NAME][ESI::WIDGET_O_TTL] = $ttl;
     358
     359        $current = !empty($old_instance[Conf::OPTION_NAME]) ? $old_instance[Conf::OPTION_NAME] : false;
     360        if (!strpos($_SERVER['HTTP_REFERER'], '/wp-admin/customize.php')) {
     361            if (!$current || $esi != $current[ESI::WIDGET_O_ESIENABLE]) {
     362                Purge::purge_all('Wdiget ESI_enable changed');
     363            } elseif ($ttl != 0 && $ttl != $current[ESI::WIDGET_O_TTL]) {
     364                Purge::add(Tag::TYPE_WIDGET . $widget->id);
     365            }
     366
     367            Purge::purge_all('Wdiget saved');
     368        }
     369        return $instance;
    343370    }
    344371}
  • litespeed-cache/trunk/src/base.cls.php

    r2954001 r2977143  
    160160    const O_OPTM_DNS_PREFETCH       = 'optm-dns_prefetch';
    161161    const O_OPTM_DNS_PREFETCH_CTRL  = 'optm-dns_prefetch_ctrl';
     162    const O_OPTM_DNS_PRECONNECT     = 'optm-dns_preconnect';
    162163    const O_OPTM_EXC                = 'optm-exc';
    163164    const O_OPTM_GUEST_ONLY         = 'optm-guest_only';
     
    447448        self::O_OPTM_DNS_PREFETCH       => array(),
    448449        self::O_OPTM_DNS_PREFETCH_CTRL  => false,
     450        self::O_OPTM_DNS_PRECONNECT     => array(),
    449451        self::O_OPTM_EXC                => array(),
    450452        self::O_OPTM_GUEST_ONLY         => false,
  • litespeed-cache/trunk/src/cdn.cls.php

    r2524344 r2977143  
    248248            foreach ( $matches[ $v[ 0 ] ? 3 : 2 ] as $k2 => $url ) {
    249249                // Debug2::debug2( '[CDN] check ' . $url );
    250                 $postfix = '.' . pathinfo( parse_url( $url, PHP_URL_PATH ), PATHINFO_EXTENSION );
     250                $postfix = '.' . pathinfo( (string) parse_url( $url, PHP_URL_PATH ), PATHINFO_EXTENSION );
    251251                if ( ! array_key_exists( $postfix, $this->_cfg_cdn_mapping ) ) {
    252252                    // Debug2::debug2( '[CDN] non-existed postfix ' . $postfix );
  • litespeed-cache/trunk/src/cdn/quic.cls.php

    r2771786 r2977143  
    11<?php
     2
    23/**
    34 * The quic.cloud class.
     
    89 * @author      LiteSpeed Technologies <[email protected]>
    910 */
     11
    1012namespace LiteSpeed\CDN;
    1113
     
    1315use LiteSpeed\Base;
    1416
    15 defined( 'WPINC' ) || exit;
     17defined('WPINC') || exit;
    1618
    17 class Quic extends Base {
     19class Quic extends Base
     20{
    1821    const LOG_TAG = '☁️';
    1922
     
    2124
    2225    protected $_summary;
    23     public function __construct() {
     26    public function __construct()
     27    {
    2428        $this->_summary = self::get_summary();
    2529    }
     
    3034     * @access public
    3135     */
    32     public static function try_sync_config() {
     36    public static function try_sync_config()
     37    {
    3338        self::cls()->try_sync_conf();
    3439    }
    3540
    36     public function try_sync_conf() {
     41    public function try_sync_conf($force = false)
     42    {
    3743        $options = $this->get_options();
    3844
    39         if ( ! $options[ self::O_CDN_QUIC ] ) {
     45        if (!$options[self::O_CDN_QUIC]) {
     46            if (!empty($this->_summary['conf_md5'])) self::save_summary(array('conf_md5' => ''));
    4047            return false;
    4148        }
     
    4653            self::O_OBJECT_PSWD,
    4754        );
    48         foreach ( $secure_fields as $v ) {
    49             if ( ! empty( $options[ $v ] ) ) {
    50                 $options[ $v ] = str_repeat( '*', strlen( $options[ $v ] ) );
     55        foreach ($secure_fields as $v) {
     56            if (!empty($options[$v])) {
     57                $options[$v] = str_repeat('*', strlen($options[$v]));
    5158            }
    5259        }
    53         unset( $options[ self::O_MEDIA_LQIP_EXC ] );
     60        unset($options[self::O_MEDIA_LQIP_EXC]);
     61
     62        // Remove overflow multi lines fields
     63        foreach ($options as $k => $v) {
     64            if (is_array($v) && count($v) > 30) {
     65                $v = array_slice($v, 0, 30);
     66                $options[$k] = $v;
     67            }
     68        }
    5469
    5570        // Rest url
    56         $options[ '_rest' ] = function_exists( 'rest_get_url_prefix' ) ? rest_get_url_prefix() : apply_filters( 'rest_url_prefix', 'wp-json' );
    57         $options[ '_home_url' ] = home_url( '/' );
     71        $options['_rest'] = function_exists('rest_get_url_prefix') ? rest_get_url_prefix() : apply_filters('rest_url_prefix', 'wp-json');
     72        $options['_home_url'] = home_url('/');
    5873
    5974        // Add server env vars
    60         $options[ '_server' ] = $this->server_vars();
     75        $options['_server'] = $this->server_vars();
    6176
    6277        // Append hooks
    63         $options[ '_tp_cookies' ] = apply_filters( 'litespeed_vary_cookies', array() );
     78        $options['_tp_cookies'] = apply_filters('litespeed_vary_cookies', array());
    6479
    65         $conf_md5 = md5( json_encode( $options ) );
    66         if ( ! empty( $this->_summary[ 'conf_md5' ] ) && $conf_md5 == $this->_summary[ 'conf_md5' ] ) {
    67             self::debug( 'Bypass sync conf to QC due to same md5', $conf_md5 );
    68             return;
     80        $conf_md5 = md5(json_encode($options));
     81        if (!empty($this->_summary['conf_md5']) && $conf_md5 == $this->_summary['conf_md5']) {
     82            if (!$force) {
     83                self::debug('Bypass sync conf to QC due to same md5', $conf_md5);
     84                return;
     85            }
     86            self::debug('!!!Force sync conf even same md5');
    6987        }
    7088
    71         self::save_summary( array( 'conf_md5' => $conf_md5 ) );
     89        self::save_summary(array('conf_md5' => $conf_md5));
    7290        self::debug('sync conf to QC', $options);
    7391
    74         Cloud::post( Cloud::SVC_D_SYNC_CONF, $options );
     92        Cloud::post(Cloud::SVC_D_SYNC_CONF, $options);
    7593    }
    76 
    7794}
  • litespeed-cache/trunk/src/cloud.cls.php

    r2940517 r2977143  
    576576        $home_url = home_url();
    577577        if (!wp_http_validate_url($home_url)) {
     578            self::debug('wp_http_validate_url failed: ' . $home_url);
    578579            return false;
    579580        }
     
    589590        /** @since 5.0 If in valid err_domains, bypass request */
    590591        if ($this->_is_err_domain($home_url)) {
     592            self::debug('home url is in err_domains, bypass request: ' . $home_url);
    591593            return false;
    592594        }
     
    13701372        $this->_summary['is_linked'] = 1;
    13711373        self::save_summary();
     1374
     1375        # Force resync qc conf
     1376        $this->cls('CDN\Quic')->try_sync_conf(true);
    13721377    }
    13731378
  • litespeed-cache/trunk/src/control.cls.php

    r2869601 r2977143  
    743743
    744744        $method = isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : 'unknown';
    745         if ( 'GET' !== $method ) {
     745        if ( 'GET' !== $method && 'HEAD' !== $method ) {
    746746            return $this->_no_cache_for('Not GET method: ' . $method);
    747747        }
  • litespeed-cache/trunk/src/crawler.cls.php

    r2928795 r2977143  
    961961
    962962        // WebP on/off
    963         if ($this->conf(Base::O_GUEST) || $this->conf(Base::O_IMG_OPTM_WEBP)) {
     963        if (($this->conf(Base::O_GUEST) && $this->conf(Base::O_GUEST_OPTM)) || $this->conf(Base::O_IMG_OPTM_WEBP)) {
    964964            $crawler_factors['webp'] = array(1 => 'WebP', 0 => '');
    965965        }
  • litespeed-cache/trunk/src/doc.cls.php

    r2928795 r2977143  
    2727    {
    2828        if (apply_filters('litespeed_conf', $id)) return;
     29        if (!apply_filters('litespeed_conf', Base::O_GUEST)) return;
    2930        if (!apply_filters('litespeed_conf', Base::O_GUEST_OPTM)) return;
    3031        echo '<font class="litespeed-warning">';
    31         echo '⚠️ ' . sprintf(__('This setting is passively %1$s due to %2$s!', 'litespeed-cache'), '<code>' . __('ON', 'litespeed-cache') . '</code>', Lang::title(Base::O_GUEST_OPTM));
     32        echo '⚠️ ' . sprintf(__('This setting is %1$s for certain qualifying requests due to %2$s!', 'litespeed-cache'), '<code>' . __('ON', 'litespeed-cache') . '</code>', Lang::title(Base::O_GUEST_OPTM));
     33        self::learn_more('https://docs.litespeedtech.com/lscache/lscwp/general/#guest-optimization');
    3234        echo '</font>';
    3335    }
  • litespeed-cache/trunk/src/esi.cls.php

    r2761310 r2977143  
    11<?php
     2
    23/**
    34 * The ESI class.
     
    1011 * @author      LiteSpeed Technologies <[email protected]>
    1112 */
     13
    1214namespace LiteSpeed;
    1315
    14 defined( 'WPINC' ) || exit;
    15 
    16 class ESI extends Root {
     16defined('WPINC') || exit;
     17
     18class ESI extends Root
     19{
     20    const LOG_TAG = '⏺';
     21
    1722    private static $has_esi = false;
    1823    private static $_combine_ids = array();
    1924    private $esi_args = null;
    2025    private $_esi_preserve_list = array();
    21     private $_nonce_actions = array( -1 => '' ); // val is cache control
     26    private $_nonce_actions = array(-1 => ''); // val is cache control
    2227
    2328    const QS_ACTION = 'lsesi';
     
    3944     * @since  4.0 Change to be after Vary init in hook 'after_setup_theme'
    4045     */
    41     public function init() {
     46    public function init()
     47    {
    4248        /**
    4349         * Bypass ESI related funcs if disabled ESI to fix potential DIVI compatibility issue
    4450         * @since  2.9.7.2
    4551         */
    46         if ( Router::is_ajax() || ! $this->cls( 'Router' )->esi_enabled() ) {
     52        if (Router::is_ajax() || !$this->cls('Router')->esi_enabled()) {
    4753            return;
    4854        }
    4955
    5056        // Guest mode, don't need to use ESI
    51         if ( defined( 'LITESPEED_GUEST' ) && LITESPEED_GUEST ) {
    52             return;
    53         }
    54 
    55         if ( defined( 'LITESPEED_ESI_OFF' ) ) {
     57        if (defined('LITESPEED_GUEST') && LITESPEED_GUEST) {
     58            return;
     59        }
     60
     61        if (defined('LITESPEED_ESI_OFF')) {
    5662            return;
    5763        }
     
    6672        $this->_transform_nonce();
    6773
    68         ! defined( 'LITESPEED_ESI_INITED' ) && define( 'LITESPEED_ESI_INITED', true );
     74        !defined('LITESPEED_ESI_INITED') && define('LITESPEED_ESI_INITED', true);
    6975    }
    7076
     
    7884     * @access private
    7985     */
    80     private function _hooks() {
    81         add_filter( 'template_include', array( $this, 'esi_template' ), 99999 );
    82 
    83         add_action( 'load-widgets.php', __NAMESPACE__ . '\Purge::purge_widget' );
    84         add_action( 'wp_update_comment_count', __NAMESPACE__ . '\Purge::purge_comment_widget' );
     86    private function _hooks()
     87    {
     88        add_filter('template_include', array($this, 'esi_template'), 99999);
     89
     90        add_action('load-widgets.php', __NAMESPACE__ . '\Purge::purge_widget');
     91        add_action('wp_update_comment_count', __NAMESPACE__ . '\Purge::purge_comment_widget');
    8592
    8693        /**
     
    8895         * @since  1.8.1
    8996         */
    90         if ( ! empty( $_GET[ self::QS_ACTION ] ) ) {
     97        if (!empty($_GET[self::QS_ACTION])) {
     98            self::debug('ESI req');
    9199            $this->_register_esi_actions();
    92100        }
     
    106114         * @since  2.8.1 Check is_admin for Elementor compatibility #726013
    107115         */
    108         if ( ! is_admin() ) {
    109             add_shortcode( 'esi', array( $this, 'shortcode' ) );
    110         }
    111 
     116        if (!is_admin()) {
     117            add_shortcode('esi', array($this, 'shortcode'));
     118        }
    112119    }
    113120
     
    117124     * @since  2.9.5
    118125     */
    119     private function _transform_nonce() {
    120         if ( is_admin() ) {
     126    private function _transform_nonce()
     127    {
     128        if (is_admin()) {
    121129            return;
    122130        }
    123131
    124132        // Load ESI nonces in conf
    125         $nonces = $this->conf( Base::O_ESI_NONCE );
    126         add_filter( 'litespeed_esi_nonces', array( $this->cls( 'Data' ), 'load_esi_nonces' ) );
    127         if ( $nonces = apply_filters( 'litespeed_esi_nonces', $nonces ) ) {
    128             foreach ( $nonces as $action ) {
    129                 $this->nonce_action( $action );
    130             }
    131         }
    132 
    133         add_action( 'litespeed_nonce', array( $this, 'nonce_action' ) );
     133        $nonces = $this->conf(Base::O_ESI_NONCE);
     134        add_filter('litespeed_esi_nonces', array($this->cls('Data'), 'load_esi_nonces'));
     135        if ($nonces = apply_filters('litespeed_esi_nonces', $nonces)) {
     136            foreach ($nonces as $action) {
     137                $this->nonce_action($action);
     138            }
     139        }
     140
     141        add_action('litespeed_nonce', array($this, 'nonce_action'));
    134142    }
    135143
     
    139147     * @since  2.9.5
    140148     */
    141     public function nonce_action( $action ) {
     149    public function nonce_action($action)
     150    {
    142151        // Split the Cache Control
    143         $action = explode( ' ', $action );
    144         $control = ! empty( $action[ 1 ] ) ? $action[ 1 ] : '';
    145         $action = $action[ 0 ];
     152        $action = explode(' ', $action);
     153        $control = !empty($action[1]) ? $action[1] : '';
     154        $action = $action[0];
    146155
    147156        // Wildcard supported
    148         $action = Utility::wildcard2regex( $action );
    149 
    150         if ( array_key_exists( $action, $this->_nonce_actions ) ) {
    151             return;
    152         }
    153 
    154         $this->_nonce_actions[ $action ] = $control;
    155 
    156         Debug2::debug( '[ESI] Appended nonce action to nonce list [action] ' . $action );
     157        $action = Utility::wildcard2regex($action);
     158
     159        if (array_key_exists($action, $this->_nonce_actions)) {
     160            return;
     161        }
     162
     163        $this->_nonce_actions[$action] = $control;
     164
     165        Debug2::debug('[ESI] Appended nonce action to nonce list [action] ' . $action);
    157166    }
    158167
     
    162171     * @since 2.9.5
    163172     */
    164     public function is_nonce_action( $action ) {
     173    public function is_nonce_action($action)
     174    {
    165175        // If GM not run yet, then ESI not init yet, then ESI nonce will not be allowed even nonce func replaced.
    166         if ( ! defined( 'LITESPEED_ESI_INITED' ) ) {
     176        if (!defined('LITESPEED_ESI_INITED')) {
    167177            return null;
    168178        }
    169179
    170         if ( is_admin() ) {
     180        if (is_admin()) {
    171181            return null;
    172182        }
    173183
    174         if ( defined( 'LITESPEED_ESI_OFF' ) ) {
     184        if (defined('LITESPEED_ESI_OFF')) {
    175185            return null;
    176186        }
    177187
    178         foreach ( $this->_nonce_actions as $k => $v ) {
    179             if ( strpos( $k, '*' ) !== false ) {
    180                 if( preg_match( '#' . $k . '#iU', $action ) ) {
     188        foreach ($this->_nonce_actions as $k => $v) {
     189            if (strpos($k, '*') !== false) {
     190                if (preg_match('#' . $k . '#iU', $action)) {
    181191                    return $v;
    182192                }
    183             }
    184             else {
    185                 if ( $k == $action ) {
     193            } else {
     194                if ($k == $action) {
    186195                    return $v;
    187196                }
     
    198207     * @access public
    199208     */
    200     public function shortcode( $atts ) {
    201         if ( empty( $atts[ 0 ] ) ) {
    202             Debug2::debug( '[ESI] ===shortcode wrong format', $atts );
     209    public function shortcode($atts)
     210    {
     211        if (empty($atts[0])) {
     212            Debug2::debug('[ESI] ===shortcode wrong format', $atts);
    203213            return 'Wrong shortcode esi format';
    204214        }
    205215
    206216        $cache = 'public,no-vary';
    207         if ( ! empty( $atts[ 'cache' ] ) ) {
    208             $cache = $atts[ 'cache' ];
    209             unset( $atts[ 'cache' ] );
     217        if (!empty($atts['cache'])) {
     218            $cache = $atts['cache'];
     219            unset($atts['cache']);
    210220        }
    211221
    212222        $silence = false;
    213         if ( ! empty( $atts[ '_ls_silence' ] ) ) {
     223        if (!empty($atts['_ls_silence'])) {
    214224            $silence = true;
    215225        }
    216226
    217         do_action( 'litespeed_esi_shortcode-' . $atts[ 0 ] );
     227        do_action('litespeed_esi_shortcode-' . $atts[0]);
    218228
    219229        // Show ESI link
    220         return $this->sub_esi_block( 'esi', 'esi-shortcode', $atts, $cache, $silence );
     230        return $this->sub_esi_block('esi', 'esi-shortcode', $atts, $cache, $silence);
    221231    }
    222232
     
    229239     * @return string Esi On header if request has esi, empty string otherwise.
    230240     */
    231     public static function has_esi() {
     241    public static function has_esi()
     242    {
    232243        return self::$has_esi;
    233244    }
     
    239250     * @access public
    240251     */
    241     public static function set_has_esi() {
     252    public static function set_has_esi()
     253    {
    242254        self::$has_esi = true;
    243255    }
     
    250262     * @access   private
    251263     */
    252     private function _register_esi_actions() {
    253         ! defined( 'LSCACHE_IS_ESI' ) && define( 'LSCACHE_IS_ESI', $_GET[ self::QS_ACTION ] );// Reused this to ESI block ID
    254 
    255         ! empty( $_SERVER[ 'ESI_REFERER' ] ) && defined( 'LSCWP_LOG' ) && Debug2::debug( '[ESI] ESI_REFERER: ' . $_SERVER[ 'ESI_REFERER' ] );
     264    private function _register_esi_actions()
     265    {
     266        /**
     267         * This hook is in `init`
     268         * For any plugin need to check if page is ESI, use `LSCACHE_IS_ESI` check after `init` hook
     269         */
     270        !defined('LSCACHE_IS_ESI') && define('LSCACHE_IS_ESI', $_GET[self::QS_ACTION]); // Reused this to ESI block ID
     271
     272        !empty($_SERVER['ESI_REFERER']) && defined('LSCWP_LOG') && Debug2::debug('[ESI] ESI_REFERER: ' . $_SERVER['ESI_REFERER']);
    256273
    257274        /**
     
    259276         * @since 2.9.3
    260277         */
    261         if ( ! empty( $_SERVER[ 'ESI_REFERER' ] ) && ! $this->cls( 'REST' )->is_rest( $_SERVER[ 'ESI_REFERER' ] ) ) {
    262             $_SERVER[ 'REQUEST_URI' ] = $_SERVER[ 'ESI_REFERER' ];
    263         }
    264 
    265         if ( ! empty( $_SERVER[ 'ESI_CONTENT_TYPE' ] ) && strpos( $_SERVER[ 'ESI_CONTENT_TYPE' ], 'application/json' ) === 0 ) {
    266             add_filter( 'litespeed_is_json', '__return_true' );
     278        if (!empty($_SERVER['ESI_REFERER']) && !$this->cls('REST')->is_rest($_SERVER['ESI_REFERER'])) {
     279            self::debug('overwrite REQUEST_URI to ESI_REFERER [from] ' . $_SERVER['REQUEST_URI'] . ' [to] ' . $_SERVER['ESI_REFERER']);
     280            $_SERVER['REQUEST_URI'] = trailingslashit($_SERVER['ESI_REFERER']);
     281            # Prevent from 301 redirecting
     282            if (!empty($_SERVER['SCRIPT_URI'])) {
     283                $SCRIPT_URI = parse_url($_SERVER['SCRIPT_URI']);
     284                $SCRIPT_URI['path'] = $_SERVER['REQUEST_URI'];
     285                Utility::compatibility();
     286                $_SERVER['SCRIPT_URI'] = http_build_url($SCRIPT_URI);
     287            }
     288        }
     289
     290        if (!empty($_SERVER['ESI_CONTENT_TYPE']) && strpos($_SERVER['ESI_CONTENT_TYPE'], 'application/json') === 0) {
     291            add_filter('litespeed_is_json', '__return_true');
    267292        }
    268293
     
    272297         * @since 2.9.4
    273298         */
    274         add_action( 'rest_api_init', array( $this, 'load_esi_block' ), 101 );
     299        add_action('rest_api_init', array($this, 'load_esi_block'), 101);
    275300
    276301        // Register ESI blocks
     
    279304        add_action('litespeed_esi_load-comment-form', array($this, 'load_comment_form_block'));
    280305
    281         add_action('litespeed_esi_load-nonce', array( $this, 'load_nonce_block' ) );
    282         add_action('litespeed_esi_load-esi', array( $this, 'load_esi_shortcode' ) );
    283 
    284         add_action('litespeed_esi_load-' . self::COMBO, array( $this, 'load_combo' ) );
     306        add_action('litespeed_esi_load-nonce', array($this, 'load_nonce_block'));
     307        add_action('litespeed_esi_load-esi', array($this, 'load_esi_shortcode'));
     308
     309        add_action('litespeed_esi_load-' . self::COMBO, array($this, 'load_combo'));
    285310    }
    286311
     
    294319     * @return string The new template path.
    295320     */
    296     public function esi_template( $template ) {
     321    public function esi_template($template)
     322    {
    297323        // Check if is an ESI request
    298         if ( defined( 'LSCACHE_IS_ESI' ) ) {
    299             Debug2::debug( '[ESI] calling template' );
     324        if (defined('LSCACHE_IS_ESI')) {
     325            self::debug('calling ESI template');
    300326
    301327            return LSCWP_DIR . 'tpl/esi.tpl.php';
    302328        }
     329        self::debug('calling default template');
    303330        $this->_register_not_esi_actions();
    304331        return $template;
     
    312339     * @access   private
    313340     */
    314     private function _register_not_esi_actions() {
    315         do_action( 'litespeed_tpl_normal' );
    316 
    317         if ( ! Control::is_cacheable() ) {
    318             return;
    319         }
    320 
    321         if ( Router::is_ajax() ) {
    322             return;
    323         }
    324 
    325         add_filter('widget_display_callback', array( $this, 'sub_widget_block' ), 0, 3);
     341    private function _register_not_esi_actions()
     342    {
     343        do_action('litespeed_tpl_normal');
     344
     345        if (!Control::is_cacheable()) {
     346            return;
     347        }
     348
     349        if (Router::is_ajax()) {
     350            return;
     351        }
     352
     353        add_filter('widget_display_callback', array($this, 'sub_widget_block'), 0, 3);
    326354
    327355        // Add admin_bar esi
    328         if ( Router::is_logged_in() ) {
     356        if (Router::is_logged_in()) {
    329357            remove_action('wp_footer', 'wp_admin_bar_render', 1000);
    330358            add_action('wp_footer', array($this, 'sub_admin_bar_block'), 1000);
     
    332360
    333361        // Add comment forum esi for logged-in user or commenter
    334         if ( ! Router::is_ajax() && Vary::has_vary() ) {
    335             add_filter( 'comment_form_defaults', array( $this, 'register_comment_form_actions' ) );
    336         }
    337 
     362        if (!Router::is_ajax() && Vary::has_vary()) {
     363            add_filter('comment_form_defaults', array($this, 'register_comment_form_actions'));
     364        }
    338365    }
    339366
     
    343370     * @since  3.4.2
    344371     */
    345     public static function combine( $block_id ) {
    346         if ( ! isset( $_SERVER[ 'X-LSCACHE' ] ) || strpos( $_SERVER[ 'X-LSCACHE' ], 'combine' ) === false ) {
    347             return;
    348         }
    349 
    350         if ( in_array( $block_id, self::$_combine_ids ) ) {
     372    public static function combine($block_id)
     373    {
     374        if (!isset($_SERVER['X-LSCACHE']) || strpos($_SERVER['X-LSCACHE'], 'combine') === false) {
     375            return;
     376        }
     377
     378        if (in_array($block_id, self::$_combine_ids)) {
    351379            return;
    352380        }
     
    360388     * @since  3.4.2
    361389     */
    362     public function load_combo() {
    363         Control::set_nocache( 'ESI combine request' );
    364 
    365         if ( empty( $_POST[ 'esi_include' ] ) ) {
     390    public function load_combo()
     391    {
     392        Control::set_nocache('ESI combine request');
     393
     394        if (empty($_POST['esi_include'])) {
    366395            return;
    367396        }
     
    369398        self::set_has_esi();
    370399
    371         Debug2::debug( '[ESI] 🍔 Load combo', $_POST[ 'esi_include' ] );
     400        Debug2::debug('[ESI] 🍔 Load combo', $_POST['esi_include']);
    372401
    373402        $output = '';
    374         foreach ( $_POST[ 'esi_include' ] as $url ) {
    375             $qs = parse_url( htmlspecialchars_decode( $url ), PHP_URL_QUERY );
    376             parse_str( $qs, $qs );
    377             if ( empty( $qs[ self::QS_ACTION ] ) ) {
     403        foreach ($_POST['esi_include'] as $url) {
     404            $qs = parse_url(htmlspecialchars_decode($url), PHP_URL_QUERY);
     405            parse_str($qs, $qs);
     406            if (empty($qs[self::QS_ACTION])) {
    378407                continue;
    379408            }
    380             $esi_id = $qs[ self::QS_ACTION ];
    381             $esi_param = ! empty( $qs[ self::QS_PARAMS ] ) ? $this->_parse_esi_param( $qs[ self::QS_PARAMS ] ) : false;
    382             $inline_param = apply_filters( 'litespeed_esi_inline-' . $esi_id, array(), $esi_param ); // Returned array need to be [ val, control, tag ]
    383             if ( $inline_param ) {
    384                 $output .= self::_build_inline( $url, $inline_param );
     409            $esi_id = $qs[self::QS_ACTION];
     410            $esi_param = !empty($qs[self::QS_PARAMS]) ? $this->_parse_esi_param($qs[self::QS_PARAMS]) : false;
     411            $inline_param = apply_filters('litespeed_esi_inline-' . $esi_id, array(), $esi_param); // Returned array need to be [ val, control, tag ]
     412            if ($inline_param) {
     413                $output .= self::_build_inline($url, $inline_param);
    385414            }
    386415        }
     
    394423     * @since  3.4.2
    395424     */
    396     private static function _build_inline( $url, $inline_param ) {
    397         if ( ! $url || empty( $inline_param[ 'val' ] ) || empty( $inline_param[ 'control' ] ) || empty( $inline_param[ 'tag' ] ) ) {
     425    private static function _build_inline($url, $inline_param)
     426    {
     427        if (!$url || empty($inline_param['val']) || empty($inline_param['control']) || empty($inline_param['tag'])) {
    398428            return '';
    399429        }
    400430
    401         return "<esi:inline name='$url' cache-control='" . $inline_param[ 'control' ] . "' cache-tag='" . $inline_param[ 'tag' ] . "'>" . $inline_param[ 'val' ] . "</esi:inline>";
     431        $url = esc_attr($url);
     432        $control = esc_attr($inline_param['control']);
     433        $tag = esc_attr($inline_param['tag']);
     434
     435        return "<esi:inline name='$url' cache-control='" . $control . "' cache-tag='" . $tag . "'>" . $inline_param['val'] . "</esi:inline>";
    402436    }
    403437
     
    418452     * @param array $inline_val     If show the current value for current request( this can avoid multiple esi requests in first time cache generating process )
    419453     */
    420     public function sub_esi_block( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false, $preserved = false, $svar = false, $inline_param = array() ) {
    421         if ( empty($block_id) || ! is_array($params) || preg_match('/[^\w-]/', $block_id) ) {
     454    public function sub_esi_block($block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false, $preserved = false, $svar = false, $inline_param = array())
     455    {
     456        if (empty($block_id) || !is_array($params) || preg_match('/[^\w-]/', $block_id)) {
    422457            return false;
    423458        }
    424459
    425         if ( defined( 'LITESPEED_ESI_OFF' ) ) {
    426             Debug2::debug( '[ESI] ESI OFF so force loading [block_id] ' . $block_id );
    427             do_action( 'litespeed_esi_load-' . $block_id, $params );
    428             return;
    429         }
    430 
    431         if ( $silence ) {
     460        if (defined('LITESPEED_ESI_OFF')) {
     461            Debug2::debug('[ESI] ESI OFF so force loading [block_id] ' . $block_id);
     462            do_action('litespeed_esi_load-' . $block_id, $params);
     463            return;
     464        }
     465
     466        if ($silence) {
    432467            // Don't add comment to esi block ( original for nonce used in tag property data-nonce='esi_block' )
    433             $params[ '_ls_silence' ] = true;
    434         }
    435 
    436         if ( $this->cls( 'REST' )->is_rest() || $this->cls( 'REST' )->is_internal_rest() ) {
    437             $params[ 'is_json' ] = 1;
    438         }
    439 
    440         $params = apply_filters( 'litespeed_esi_params', $params, $block_id );
    441         $control = apply_filters('litespeed_esi_control', $control, $block_id );
    442 
    443         if ( !is_array($params) || !is_string($control) ) {
    444             defined( 'LSCWP_LOG' ) && Debug2::debug( "[ESI] 🛑 Sub hooks returned Params: \n" . var_export($params, true) . "\ncache control: \n" . var_export($control, true) );
     468            $params['_ls_silence'] = true;
     469        }
     470
     471        if ($this->cls('REST')->is_rest() || $this->cls('REST')->is_internal_rest()) {
     472            $params['is_json'] = 1;
     473        }
     474
     475        $params = apply_filters('litespeed_esi_params', $params, $block_id);
     476        $control = apply_filters('litespeed_esi_control', $control, $block_id);
     477
     478        if (!is_array($params) || !is_string($control)) {
     479            defined('LSCWP_LOG') && Debug2::debug("[ESI] 🛑 Sub hooks returned Params: \n" . var_export($params, true) . "\ncache control: \n" . var_export($control, true));
    445480
    446481            return false;
     
    451486            self::QS_ACTION => $block_id,
    452487        );
    453         if ( ! empty( $control ) ) {
    454             $appended_params[ '_control' ] = $control;
    455         }
    456         if ( $params ) {
    457             $appended_params[ self::QS_PARAMS ] = base64_encode( json_encode( $params ) );
    458             Debug2::debug2( '[ESI] param ', $params );
     488        if (!empty($control)) {
     489            $appended_params['_control'] = $control;
     490        }
     491        if ($params) {
     492            $appended_params[self::QS_PARAMS] = base64_encode(json_encode($params));
     493            Debug2::debug2('[ESI] param ', $params);
    459494        }
    460495
    461496        // Append hash
    462         $appended_params[ '_hash' ] = $this->_gen_esi_md5( $appended_params );
     497        $appended_params['_hash'] = $this->_gen_esi_md5($appended_params);
    463498
    464499        /**
     
    466501         * @since 2.9.4
    467502         */
    468         $appended_params = array_map( 'urlencode', $appended_params );
     503        $appended_params = array_map('urlencode', $appended_params);
    469504
    470505        // Generate ESI URL
    471         $url = add_query_arg( $appended_params, trailingslashit( wp_make_link_relative( home_url() ) ) );
     506        $url = add_query_arg($appended_params, trailingslashit(wp_make_link_relative(home_url())));
    472507
    473508        $output = '';
    474         if ( $inline_param ) {
    475             $output .= self::_build_inline( $url, $inline_param );
     509        if ($inline_param) {
     510            $output .= self::_build_inline($url, $inline_param);
    476511        }
    477512
    478513        $output .= "<esi:include src='$url'";
    479         if ( ! empty( $control ) ) {
     514        if (!empty($control)) {
     515            $control = esc_attr($control);
    480516            $output .= " cache-control='$control'";
    481517        }
    482         if ( $svar ) {
     518        if ($svar) {
    483519            $output .= " as-var='1'";
    484520        }
    485         if ( in_array( $block_id, self::$_combine_ids ) ) {
     521        if (in_array($block_id, self::$_combine_ids)) {
    486522            $output .= " combine='sub'";
    487523        }
    488         if ( $block_id == self::COMBO && isset( $_SERVER[ 'X-LSCACHE' ] ) && strpos( $_SERVER[ 'X-LSCACHE' ], 'combine' ) !== false ) {
     524        if ($block_id == self::COMBO && isset($_SERVER['X-LSCACHE']) && strpos($_SERVER['X-LSCACHE'], 'combine') !== false) {
    489525            $output .= " combine='main'";
    490526        }
    491527        $output .= " />";
    492528
    493         if ( ! $silence ) {
     529        if (!$silence) {
    494530            $output = "<!-- lscwp $wrapper -->$output<!-- lscwp $wrapper esi end -->";
    495531        }
    496532
    497         Debug2::debug( "[ESI] 💕  [BLock_ID] $block_id \t[wrapper] $wrapper \t\t[Control] $control" );
    498         Debug2::debug2( $output );
     533        self::debug("💕  [BLock_ID] $block_id \t[wrapper] $wrapper \t\t[Control] $control");
     534        self::debug2($output);
    499535
    500536        self::set_has_esi();
     
    502538        // Convert to string to avoid html chars filter when using
    503539        // Will reverse the buffer when output in self::finalize()
    504         if ( $preserved ) {
    505             $hash = md5( $output );
    506             $this->_esi_preserve_list[ $hash ] = $output;
    507             Debug2::debug( "[ESI] Preserved to $hash" );
     540        if ($preserved) {
     541            $hash = md5($output);
     542            $this->_esi_preserve_list[$hash] = $output;
     543            self::debug("Preserved to $hash");
    508544
    509545            return $hash;
     
    519555     * @access private
    520556     */
    521     private function _gen_esi_md5( $params ) {
     557    private function _gen_esi_md5($params)
     558    {
    522559        $keys = array(
    523560            self::QS_ACTION,
     
    527564
    528565        $str = '';
    529         foreach ( $keys as $v ) {
    530             if ( isset( $params[ $v ] ) && is_string( $params[ $v ] ) ) {
    531                 $str .= $params[ $v ];
    532             }
    533         }
    534         Debug2::debug2( '[ESI] md5_string=' . $str );
    535 
    536         return md5( $this->conf( Base::HASH ) . $str );
     566        foreach ($keys as $v) {
     567            if (isset($params[$v]) && is_string($params[$v])) {
     568                $str .= $params[$v];
     569            }
     570        }
     571        Debug2::debug2('[ESI] md5_string=' . $str);
     572
     573        return md5($this->conf(Base::HASH) . $str);
    537574    }
    538575
     
    543580     * @access private
    544581     */
    545     private function _parse_esi_param( $qs_params = false ) {
     582    private function _parse_esi_param($qs_params = false)
     583    {
    546584        $req_params = false;
    547         if ( $qs_params ) {
     585        if ($qs_params) {
    548586            $req_params = $qs_params;
    549         }
    550         elseif ( isset( $_REQUEST[ self::QS_PARAMS ] ) ) {
    551             $req_params = $_REQUEST[ self::QS_PARAMS ];
    552         }
    553 
    554         if ( ! $req_params ) {
     587        } elseif (isset($_REQUEST[self::QS_PARAMS])) {
     588            $req_params = $_REQUEST[self::QS_PARAMS];
     589        }
     590
     591        if (!$req_params) {
    555592            return false;
    556593        }
    557594
    558         $unencrypted = base64_decode( $req_params );
    559         if ( $unencrypted === false ) {
     595        $unencrypted = base64_decode($req_params);
     596        if ($unencrypted === false) {
    560597            return false;
    561598        }
    562599
    563         Debug2::debug2( '[ESI] parms', $unencrypted );
     600        Debug2::debug2('[ESI] parms', $unencrypted);
    564601        // $unencoded = urldecode($unencrypted); no need to do this as $_GET is already parsed
    565         $params = json_decode( $unencrypted, true );
     602        $params = json_decode($unencrypted, true);
    566603
    567604        return $params;
     
    574611     * @access public
    575612     */
    576     public function load_esi_block() {
     613    public function load_esi_block()
     614    {
    577615        /**
    578616         * Validate if is a legal ESI req
    579617         * @since 2.9.6
    580618         */
    581         if ( empty( $_GET[ '_hash' ] ) || $this->_gen_esi_md5( $_GET ) != $_GET[ '_hash' ] ) {
    582             Debug2::debug( '[ESI] ❌ Failed to validate _hash' );
     619        if (empty($_GET['_hash']) || $this->_gen_esi_md5($_GET) != $_GET['_hash']) {
     620            Debug2::debug('[ESI] ❌ Failed to validate _hash');
    583621            return;
    584622        }
     
    586624        $params = $this->_parse_esi_param();
    587625
    588         if ( defined( 'LSCWP_LOG' ) ) {
     626        if (defined('LSCWP_LOG')) {
    589627            $logInfo = '[ESI] ⭕ ';
    590             if( ! empty( $params[ self::PARAM_NAME ] ) ) {
    591                 $logInfo .= ' Name: ' . $params[ self::PARAM_NAME ] . ' ----- ';
     628            if (!empty($params[self::PARAM_NAME])) {
     629                $logInfo .= ' Name: ' . $params[self::PARAM_NAME] . ' ----- ';
    592630            }
    593631            $logInfo .= ' [ID] ' . LSCACHE_IS_ESI;
    594             Debug2::debug( $logInfo );
    595         }
    596 
    597         if ( ! empty( $params[ '_ls_silence' ] ) ) {
    598             ! defined( 'LSCACHE_ESI_SILENCE' ) && define( 'LSCACHE_ESI_SILENCE', true );
     632            Debug2::debug($logInfo);
     633        }
     634
     635        if (!empty($params['_ls_silence'])) {
     636            !defined('LSCACHE_ESI_SILENCE') && define('LSCACHE_ESI_SILENCE', true);
    599637        }
    600638
     
    603641         * @since  2.9.4
    604642         */
    605         if ( ! empty( $params[ 'is_json' ] ) ) {
    606             add_filter( 'litespeed_is_json', '__return_true' );
    607         }
    608 
    609         Tag::add( rtrim( Tag::TYPE_ESI, '.' ) );
    610         Tag::add( Tag::TYPE_ESI . LSCACHE_IS_ESI );
     643        if (!empty($params['is_json'])) {
     644            add_filter('litespeed_is_json', '__return_true');
     645        }
     646
     647        Tag::add(rtrim(Tag::TYPE_ESI, '.'));
     648        Tag::add(Tag::TYPE_ESI . LSCACHE_IS_ESI);
    611649
    612650        // Debug2::debug(var_export($params, true ));
     
    617655         * @since  2.2.3
    618656         */
    619         if ( ! empty( $_GET[ '_control' ] ) ) {
    620             $control = explode( ',', $_GET[ '_control' ] );
    621             if ( in_array( 'private', $control ) ) {
     657        if (!empty($_GET['_control'])) {
     658            $control = explode(',', $_GET['_control']);
     659            if (in_array('private', $control)) {
    622660                Control::set_private();
    623661            }
    624662
    625             if ( in_array( 'no-vary', $control ) ) {
     663            if (in_array('no-vary', $control)) {
    626664                Control::set_no_vary();
    627665            }
     
    631669    }
    632670
    633 // The *_sub_* functions are helpers for the sub_* functions.
    634 // The *_load_* functions are helpers for the load_* functions.
     671    // The *_sub_* functions are helpers for the sub_* functions.
     672    // The *_load_* functions are helpers for the load_* functions.
    635673
    636674    /**
     
    640678     * @access public
    641679     */
    642     public static function widget_default_options($options, $widget) {
    643         if ( ! is_array($options) ) {
     680    public static function widget_default_options($options, $widget)
     681    {
     682        if (!is_array($options)) {
    644683            return $options;
    645684        }
     
    647686        $widget_name = get_class($widget);
    648687        switch ($widget_name) {
    649             case 'WP_Widget_Recent_Posts' :
    650             case 'WP_Widget_Recent_Comments' :
     688            case 'WP_Widget_Recent_Posts':
     689            case 'WP_Widget_Recent_Comments':
    651690                $options[self::WIDGET_O_ESIENABLE] = Base::VAL_OFF;
    652691                $options[self::WIDGET_O_TTL] = 86400;
    653692                break;
    654             default :
     693            default:
    655694                break;
    656695        }
     
    670709     * @return mixed Return false if display through esi, instance otherwise.
    671710     */
    672     public function sub_widget_block( $instance, $widget, $args ) {
     711    public function sub_widget_block($instance, $widget, $args)
     712    {
    673713        // #210407
    674         if ( ! is_array( $instance ) ) {
     714        if (!is_array($instance)) {
    675715            return $instance;
    676716        }
    677717
    678         $name = get_class( $widget );
    679         if ( ! isset( $instance[ Base::OPTION_NAME ] ) ) {
     718        $name = get_class($widget);
     719        if (!isset($instance[Base::OPTION_NAME])) {
    680720            return $instance;
    681721        }
    682         $options = $instance[ Base::OPTION_NAME ];
    683         if ( ! isset( $options ) || ! $options[ self::WIDGET_O_ESIENABLE ] ) {
    684             defined( 'LSCWP_LOG' ) && Debug2::debug( 'ESI 0 ' . $name . ': '. ( ! isset( $options ) ? 'not set' : 'set off' ) );
     722        $options = $instance[Base::OPTION_NAME];
     723        if (!isset($options) || !$options[self::WIDGET_O_ESIENABLE]) {
     724            defined('LSCWP_LOG') && Debug2::debug('ESI 0 ' . $name . ': ' . (!isset($options) ? 'not set' : 'set off'));
    685725
    686726            return $instance;
    687727        }
    688728
    689         $esi_private = $options[ self::WIDGET_O_ESIENABLE ] == Base::VAL_ON2 ? 'private,' : '';
     729        $esi_private = $options[self::WIDGET_O_ESIENABLE] == Base::VAL_ON2 ? 'private,' : '';
    690730
    691731        $params = array(
     
    696736        );
    697737
    698         echo $this->sub_esi_block( 'widget', 'widget ' . $name, $params, $esi_private . 'no-vary' );
     738        echo $this->sub_esi_block('widget', 'widget ' . $name, $params, $esi_private . 'no-vary');
    699739
    700740        return false;
     
    709749     * @global type $wp_admin_bar
    710750     */
    711     public function sub_admin_bar_block() {
     751    public function sub_admin_bar_block()
     752    {
    712753        global $wp_admin_bar;
    713754
    714         if ( ! is_admin_bar_showing() || ! is_object($wp_admin_bar) ) {
     755        if (!is_admin_bar_showing() || !is_object($wp_admin_bar)) {
    715756            return;
    716757        }
     
    718759        // To make each admin bar ESI request different for `Edit` button different link
    719760        $params = array(
    720             'ref' => $_SERVER[ 'REQUEST_URI' ],
     761            'ref' => $_SERVER['REQUEST_URI'],
    721762        );
    722763
    723         echo $this->sub_esi_block( 'admin-bar', 'adminbar', $params );
     764        echo $this->sub_esi_block('admin-bar', 'adminbar', $params);
    724765    }
    725766
     
    732773     * @param array $params Input parameters needed to correctly display widget
    733774     */
    734     public function load_widget_block( $params ) {
     775    public function load_widget_block($params)
     776    {
    735777        // global $wp_widget_factory;
    736778        // $widget = $wp_widget_factory->widgets[ $params[ self::PARAM_NAME ] ];
    737         $option = $params[ self::PARAM_INSTANCE ];
    738         $option = $option[ Base::OPTION_NAME ];
     779        $option = $params[self::PARAM_INSTANCE];
     780        $option = $option[Base::OPTION_NAME];
    739781
    740782        // Since we only reach here via esi, safe to assume setting exists.
    741         $ttl = $option[ self::WIDGET_O_TTL ];
    742         defined( 'LSCWP_LOG' ) && Debug2::debug( 'ESI widget render: name ' . $params[ self::PARAM_NAME ] . ', id ' . $params[ self::PARAM_ID ] . ', ttl ' . $ttl );
    743         if ( $ttl == 0 ) {
    744             Control::set_nocache( 'ESI Widget time to live set to 0' );
    745         }
    746         else {
    747             Control::set_custom_ttl( $ttl );
    748 
    749             if ( $option[ self::WIDGET_O_ESIENABLE ] == Base::VAL_ON2 ) {
     783        $ttl = $option[self::WIDGET_O_TTL];
     784        defined('LSCWP_LOG') && Debug2::debug('ESI widget render: name ' . $params[self::PARAM_NAME] . ', id ' . $params[self::PARAM_ID] . ', ttl ' . $ttl);
     785        if ($ttl == 0) {
     786            Control::set_nocache('ESI Widget time to live set to 0');
     787        } else {
     788            Control::set_custom_ttl($ttl);
     789
     790            if ($option[self::WIDGET_O_ESIENABLE] == Base::VAL_ON2) {
    750791                Control::set_private();
    751792            }
    752793            Control::set_no_vary();
    753             Tag::add( Tag::TYPE_WIDGET . $params[ self::PARAM_ID ] );
    754         }
    755         the_widget( $params[ self::PARAM_NAME ], $params[ self::PARAM_INSTANCE ], $params[ self::PARAM_ARGS ] );
     794            Tag::add(Tag::TYPE_WIDGET . $params[self::PARAM_ID]);
     795        }
     796        the_widget($params[self::PARAM_NAME], $params[self::PARAM_INSTANCE], $params[self::PARAM_ARGS]);
    756797    }
    757798
     
    762803     * @since 1.1.3
    763804     */
    764     public function load_admin_bar_block( $params ) {
    765 
    766         if ( ! empty( $params[ 'ref' ] ) ) {
    767             $ref_qs = parse_url( $params[ 'ref' ], PHP_URL_QUERY );
    768             if ( ! empty( $ref_qs ) ) {
    769                 parse_str( $ref_qs, $ref_qs_arr );
    770 
    771                 if ( ! empty( $ref_qs_arr ) ) {
    772                     foreach ( $ref_qs_arr as $k => $v ) {
    773                         $_GET[ $k ] = $v;
     805    public function load_admin_bar_block($params)
     806    {
     807
     808        if (!empty($params['ref'])) {
     809            $ref_qs = parse_url($params['ref'], PHP_URL_QUERY);
     810            if (!empty($ref_qs)) {
     811                parse_str($ref_qs, $ref_qs_arr);
     812
     813                if (!empty($ref_qs_arr)) {
     814                    foreach ($ref_qs_arr as $k => $v) {
     815                        $_GET[$k] = $v;
    774816                    }
    775817                }
     
    778820
    779821        wp_admin_bar_render();
    780         if ( ! $this->conf( Base::O_ESI_CACHE_ADMBAR ) ) {
    781             Control::set_nocache( 'build-in set to not cacheable' );
    782         }
    783         else {
     822        if (!$this->conf(Base::O_ESI_CACHE_ADMBAR)) {
     823            Control::set_nocache('build-in set to not cacheable');
     824        } else {
    784825            Control::set_private();
    785826            Control::set_no_vary();
    786827        }
    787828
    788         defined( 'LSCWP_LOG' ) && Debug2::debug( 'ESI: adminbar ref: ' . $_SERVER[ 'REQUEST_URI' ] );
     829        defined('LSCWP_LOG') && Debug2::debug('ESI: adminbar ref: ' . $_SERVER['REQUEST_URI']);
    789830    }
    790831
     
    797838     * @param array $params Input parameters needed to correctly display comment form
    798839     */
    799     public function load_comment_form_block( $params ) {
    800         comment_form( $params[ self::PARAM_ARGS ], $params[ self::PARAM_ID ] );
    801 
    802         if ( ! $this->conf( Base::O_ESI_CACHE_COMMFORM ) ) {
    803             Control::set_nocache( 'build-in set to not cacheable' );
    804         }
    805         else {
     840    public function load_comment_form_block($params)
     841    {
     842        comment_form($params[self::PARAM_ARGS], $params[self::PARAM_ID]);
     843
     844        if (!$this->conf(Base::O_ESI_CACHE_COMMFORM)) {
     845            Control::set_nocache('build-in set to not cacheable');
     846        } else {
    806847            // by default comment form is public
    807             if ( Vary::has_vary() ) {
     848            if (Vary::has_vary()) {
    808849                Control::set_private();
    809850                Control::set_no_vary();
     
    818859     * @since 2.6
    819860     */
    820     public function load_nonce_block( $params ) {
    821         $action = $params[ 'action' ];
    822 
    823         Debug2::debug( '[ESI] load_nonce_block [action] ' . $action );
     861    public function load_nonce_block($params)
     862    {
     863        $action = $params['action'];
     864
     865        Debug2::debug('[ESI] load_nonce_block [action] ' . $action);
    824866
    825867        // set nonce TTL to half day
    826         Control::set_custom_ttl( 43200 );
    827 
    828         if ( Router::is_logged_in() ) {
     868        Control::set_custom_ttl(43200);
     869
     870        if (Router::is_logged_in()) {
    829871            Control::set_private();
    830872        }
    831873
    832         if ( function_exists( 'wp_create_nonce_litespeed_esi' ) ) {
    833             echo wp_create_nonce_litespeed_esi( $action );
    834         }
    835         else {
    836             echo wp_create_nonce( $action );
     874        if (function_exists('wp_create_nonce_litespeed_esi')) {
     875            echo wp_create_nonce_litespeed_esi($action);
     876        } else {
     877            echo wp_create_nonce($action);
    837878        }
    838879    }
     
    844885     * @since 2.8
    845886     */
    846     public function load_esi_shortcode( $params ) {
    847         if ( isset( $params[ 'ttl' ] ) ) {
    848             if ( ! $params[ 'ttl' ] ) {
    849                 Control::set_nocache( 'ESI shortcode att ttl=0' );
    850             }
    851             else {
    852                 Control::set_custom_ttl( $params[ 'ttl' ] );
    853             }
    854             unset( $params[ 'ttl' ] );
     887    public function load_esi_shortcode($params)
     888    {
     889        if (isset($params['ttl'])) {
     890            if (!$params['ttl']) {
     891                Control::set_nocache('ESI shortcode att ttl=0');
     892            } else {
     893                Control::set_custom_ttl($params['ttl']);
     894            }
     895            unset($params['ttl']);
    855896        }
    856897
    857898        // Replace to original shortcode
    858         $shortcode = $params[ 0 ];
     899        $shortcode = $params[0];
    859900        $atts_ori = array();
    860         foreach ( $params as $k => $v ) {
    861             if ( $k === 0 ) {
     901        foreach ($params as $k => $v) {
     902            if ($k === 0) {
    862903                continue;
    863904            }
    864905
    865             $atts_ori[] = is_string( $k ) ? "$k='" . addslashes( $v ) . "'" : $v;
    866         }
    867 
    868         Tag::add( Tag::TYPE_ESI . "esi.$shortcode" );
     906            $atts_ori[] = is_string($k) ? "$k='" . addslashes($v) . "'" : $v;
     907        }
     908
     909        Tag::add(Tag::TYPE_ESI . "esi.$shortcode");
    869910
    870911        // Output original shortcode final content
    871         echo do_shortcode( "[$shortcode " . implode( ' ', $atts_ori ) . " ]" );
     912        echo do_shortcode("[$shortcode " . implode(' ', $atts_ori) . " ]");
    872913    }
    873914
     
    881922     * @access public
    882923     */
    883     public function register_comment_form_actions( $defaults ) {
     924    public function register_comment_form_actions($defaults)
     925    {
    884926        $this->esi_args = $defaults;
    885927        echo GUI::clean_wrapper_begin();
    886         add_filter( 'comment_form_submit_button', array( $this, 'sub_comment_form_btn' ), 1000, 2 ); // To save the params passed in
    887         add_action( 'comment_form', array( $this, 'sub_comment_form_block' ), 1000 );
     928        add_filter('comment_form_submit_button', array($this, 'sub_comment_form_btn'), 1000, 2); // To save the params passed in
     929        add_action('comment_form', array($this, 'sub_comment_form_block'), 1000);
    888930        return $defaults;
    889931    }
     
    895937     * @access public
    896938     */
    897     public function sub_comment_form_btn( $unused, $args ) {
    898         if ( empty( $args ) || empty( $this->esi_args ) ) {
    899             Debug2::debug( 'comment form args empty?' );
     939    public function sub_comment_form_btn($unused, $args)
     940    {
     941        if (empty($args) || empty($this->esi_args)) {
     942            Debug2::debug('comment form args empty?');
    900943            return $unused;
    901944        }
     
    903946
    904947        // compare current args with default ones
    905         foreach ( $args as $k => $v ) {
    906             if ( ! isset( $this->esi_args[ $k ] ) ) {
    907                 $esi_args[ $k ] = $v;
    908             }
    909             elseif ( is_array( $v ) ) {
    910                 $diff = array_diff_assoc( $v, $this->esi_args[ $k ] );
    911                 if ( ! empty( $diff ) ) {
    912                     $esi_args[ $k ] = $diff;
     948        foreach ($args as $k => $v) {
     949            if (!isset($this->esi_args[$k])) {
     950                $esi_args[$k] = $v;
     951            } elseif (is_array($v)) {
     952                $diff = array_diff_assoc($v, $this->esi_args[$k]);
     953                if (!empty($diff)) {
     954                    $esi_args[$k] = $diff;
    913955                }
    914             }
    915             elseif ( $v !== $this->esi_args[ $k ] ) {
    916                 $esi_args[ $k ] = $v;
     956            } elseif ($v !== $this->esi_args[$k]) {
     957                $esi_args[$k] = $v;
    917958            }
    918959        }
     
    931972     * @since 1.1.3
    932973     */
    933     public function sub_comment_form_block( $post_id ) {
     974    public function sub_comment_form_block($post_id)
     975    {
    934976        echo GUI::clean_wrapper_end();
    935977        $params = array(
     
    938980        );
    939981
    940         echo $this->sub_esi_block( 'comment-form', 'comment form', $params );
     982        echo $this->sub_esi_block('comment-form', 'comment form', $params);
    941983        echo GUI::clean_wrapper_begin();
    942         add_action( 'comment_form_after', array( $this, 'comment_form_sub_clean' ) );
     984        add_action('comment_form_after', array($this, 'comment_form_sub_clean'));
    943985    }
    944986
     
    950992     * @access public
    951993     */
    952     public function comment_form_sub_clean() {
     994    public function comment_form_sub_clean()
     995    {
    953996        echo GUI::clean_wrapper_end();
    954997    }
     
    9601003     * @access public
    9611004     */
    962     public function finalize( $buffer ) {
     1005    public function finalize($buffer)
     1006    {
    9631007        // Prepend combo esi block
    964         if ( self::$_combine_ids ) {
    965             Debug2::debug( '[ESI] 🍔 Enabled combo' );
    966             $esi_block = $this->sub_esi_block( self::COMBO, '__COMBINE_MAIN__', array(), 'no-cache', true );
     1008        if (self::$_combine_ids) {
     1009            Debug2::debug('[ESI] 🍔 Enabled combo');
     1010            $esi_block = $this->sub_esi_block(self::COMBO, '__COMBINE_MAIN__', array(), 'no-cache', true);
    9671011            $buffer = $esi_block . $buffer;
    9681012        }
    9691013
    9701014        // Bypass if no preserved list to be replaced
    971         if ( ! $this->_esi_preserve_list ) {
     1015        if (!$this->_esi_preserve_list) {
    9721016            return $buffer;
    9731017        }
    9741018
    975         $keys = array_keys( $this->_esi_preserve_list );
    976 
    977         Debug2::debug( '[ESI] replacing preserved blocks', $keys );
    978 
    979         $buffer = str_replace( $keys, $this->_esi_preserve_list, $buffer );
     1019        $keys = array_keys($this->_esi_preserve_list);
     1020
     1021        Debug2::debug('[ESI] replacing preserved blocks', $keys);
     1022
     1023        $buffer = str_replace($keys, $this->_esi_preserve_list, $buffer);
    9801024
    9811025        return $buffer;
     
    9871031     * @since  3.3
    9881032     */
    989     public function contain_preserve_esi( $content ) {
     1033    public function contain_preserve_esi($content)
     1034    {
    9901035        $hit_list = array();
    991         foreach ( $this->_esi_preserve_list as $k => $v ) {
    992             if ( strpos( $content, '"' . $k . '"' ) !== false ) {
     1036        foreach ($this->_esi_preserve_list as $k => $v) {
     1037            if (strpos($content, '"' . $k . '"') !== false) {
    9931038                $hit_list[] = '"' . $k . '"';
    9941039            }
    995             if ( strpos( $content, "'" . $k . "'" ) !== false ) {
     1040            if (strpos($content, "'" . $k . "'") !== false) {
    9961041                $hit_list[] = "'" . $k . "'";
    9971042            }
     
    9991044        return $hit_list;
    10001045    }
    1001 
    10021046}
  • litespeed-cache/trunk/src/htaccess.cls.php

    r2928795 r2977143  
    559559                $vary_cookies[] = ',wp-postpass_' . COOKIEHASH;
    560560            }
    561             $vary_cookies = apply_filters('litespeed_vary_cookies', $vary_cookies); // todo: test if response vary header can work in latest OLS, drop the above two lines
    562         }
     561        }
     562        $vary_cookies = apply_filters('litespeed_vary_cookies', $vary_cookies); // todo: test if response vary header can work in latest OLS, drop the above two lines
    563563        // frontend and backend
    564564        if ($vary_cookies) {
    565565            $env = 'Cache-Vary:' . implode(',', $vary_cookies);
    566             if (LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS') {
    567                 $env = '"' . $env . '"';
    568             }
     566            // if (LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS') {
     567            // }
     568            $env = '"' . $env . '"';
    569569            $new_rules[] = $new_rules_backend[] = self::MARKER_LOGIN_COOKIE . self::MARKER_START;
    570570            $new_rules[] = $new_rules_backend[] = 'RewriteRule .? - [E=' . $env . ']';
     
    594594        // webp support
    595595        $id = Base::O_IMG_OPTM_WEBP;
    596         if (!empty($cfg[$id]) || !empty($cfg[Base::O_GUEST])) {
     596        if (!empty($cfg[$id]) || (!empty($cfg[Base::O_GUEST]) && !empty($cfg[Base::O_GUEST_OPTM]))) {
    597597            $new_rules[] = self::MARKER_WEBP . self::MARKER_START;
    598598            $new_rules[] = 'RewriteCond %{HTTP_ACCEPT} "image/webp"';
  • litespeed-cache/trunk/src/img-optm.cls.php

    r2940517 r2977143  
    11911191        $to_be_continued = $wpdb->get_row($wpdb->prepare($img_q, array($offset * $limit, 1)));
    11921192        if ($to_be_continued) {
    1193             return Router::self_redirect(Router::ACTION_IMG_OPTM, self::TYPE_DESTROY);
     1193            # Check if post_id is beyond next_post_id
     1194            self::debug('[next_post_id] ' . $this->_summary['next_post_id'] . ' [cursor post id] ' . $to_be_continued->post_id);
     1195            if ($to_be_continued->post_id <= $this->_summary['next_post_id']) {
     1196                self::debug('redirecting to next');
     1197                return Router::self_redirect(Router::ACTION_IMG_OPTM, self::TYPE_DESTROY);
     1198            }
     1199            self::debug('🎊 Finished destroying');
    11941200        }
    11951201
     
    12201226            $short_file_path = $this->tmp_path . $short_file_path;
    12211227        }
     1228        self::debug('deleting ' . $short_file_path);
    12221229
    12231230        // del webp
     
    12321239        // del optimized ori
    12331240        if ($this->__media->info($bk_file, $this->tmp_pid)) {
     1241            self::debug('deleting optim ori');
    12341242            $this->__media->del($short_file_path, $this->tmp_pid);
    12351243            $this->__media->rename($bk_file, $short_file_path, $this->tmp_pid);
  • litespeed-cache/trunk/src/lang.cls.php

    r2954001 r2977143  
    156156            self::O_OPTM_DNS_PREFETCH           => __('DNS Prefetch', 'litespeed-cache'),
    157157            self::O_OPTM_DNS_PREFETCH_CTRL      => __('DNS Prefetch Control', 'litespeed-cache'),
     158            self::O_OPTM_DNS_PRECONNECT         => __('DNS Preconnect', 'litespeed-cache'),
    158159            self::O_OPTM_CSS_EXC                => __('CSS Excludes', 'litespeed-cache'),
    159160            self::O_OPTM_JS_DELAY_INC           => __('JS Delayed Includes', 'litespeed-cache'),
  • litespeed-cache/trunk/src/media.cls.php

    r2928795 r2977143  
    645645            // Add missing dimensions
    646646            if (defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_MEDIA_ADD_MISSING_SIZES)) {
    647                 if (empty($attrs['width']) || $attrs['width'] == 'auto' || empty($attrs['height']) || $attrs['height'] == 'auto') {
     647                if (!apply_filters('litespeed_media_add_missing_sizes', true)) {
     648                    Debug2::debug2('[Media] add_missing_sizes bypassed via litespeed_media_add_missing_sizes filter');
     649                } elseif (empty($attrs['width']) || $attrs['width'] == 'auto' || empty($attrs['height']) || $attrs['height'] == 'auto') {
    648650                    self::debug('⚠️ Missing sizes for image [src] ' . $attrs['src']);
    649651                    $dimensions = $this->_detect_dimensions($attrs['src']);
  • litespeed-cache/trunk/src/optimize.cls.php

    r2954001 r2977143  
    3535
    3636    private $dns_prefetch;
     37    private $dns_preconnect;
    3738    private $_ggfonts_urls = array();
    3839    private $_ccss;
     
    128129         */
    129130        $this->_dns_prefetch_init();
     131
     132        /**
     133         * Preconnect
     134         * @since 5.6.1
     135         */
     136        $this->_dns_preconnect_init();
    130137
    131138        add_filter('litespeed_buffer_finalize', array($this, 'finalize'), 20);
     
    659666
    660667    /**
     668     * Preconnect init
     669     *
     670     * @since 5.6.1
     671     */
     672    private function _dns_preconnect_init()
     673    {
     674
     675        $this->dns_preconnect = $this->conf(self::O_OPTM_DNS_PRECONNECT);
     676        if ($this->dns_preconnect) {
     677            add_action('litespeed_optm', array($this, 'dns_preconnect_output'));
     678        }
     679    }
     680
     681    /**
    661682     * Prefetch DNS hook for WP
    662683     *
     
    690711            if ($v) {
    691712                $this->html_head .= '<link rel="dns-prefetch" href="' . $v . '" />';
     713            }
     714        }
     715    }
     716
     717    /**
     718     * Preconnect
     719     *
     720     * @since 5.6.1
     721     * @access public
     722     */
     723    public function dns_preconnect_output()
     724    {
     725        foreach ($this->dns_preconnect as $v) {
     726            if ($v) {
     727                $this->html_head .= '<link rel="preconnect" href="' . $v . '" />';
    692728            }
    693729        }
     
    823859
    824860        $combine_ext_inl = $this->conf(self::O_OPTM_JS_COMB_EXT_INL);
     861        if (!apply_filters('litespeed_optm_js_comb_ext_inl', true)) {
     862            Debug2::debug2('[Optm] js_comb_ext_inl bypassed via litespeed_optm_js_comb_ext_inl filter');
     863            $combine_ext_inl = false;
     864        }
    825865
    826866        $src_list = array();
     
    9961036
    9971037        $combine_ext_inl = $this->conf(self::O_OPTM_CSS_COMB_EXT_INL);
     1038        if (!apply_filters('litespeed_optm_css_comb_ext_inl', true)) {
     1039            Debug2::debug2('[Optm] css_comb_ext_inl bypassed via litespeed_optm_css_comb_ext_inl filter');
     1040            $combine_ext_inl = false;
     1041        }
    9981042
    9991043        $css_to_be_removed = apply_filters('litespeed_optm_css_to_be_removed', array());
  • litespeed-cache/trunk/thirdparty/litespeed-check.cls.php

    r2771786 r2977143  
    11<?php
     2
    23/**
    34 * Check if any plugins that could conflict with LiteSpeed Cache are active.
     
    78namespace LiteSpeed\Thirdparty;
    89
    9 defined( 'WPINC' ) || exit;
     10defined('WPINC') || exit;
    1011
    11 class LiteSpeed_Check {
     12class LiteSpeed_Check
     13{
    1214
    1315    public static $_incompatible_plugins =
    14         array(
    15             // 'autoptimize/autoptimize.php',
    16             'breeze/breeze.php',
    17             'cache-enabler/cache-enabler.php',
    18             'cachify/cachify.php',
    19             'cloudflare/cloudflare.php',
    20             'comet-cache/comet-cache.php',
    21             'docket-cache/docket-cache.php',
    22             'fast-velocity-minify/fvm.php',
    23             'hummingbird-performance/wp-hummingbird.php',
    24             'nginx-cache/nginx-cache.php',
    25             'nitropack/main.php',
    26             'pantheon-advanced-page-cache/pantheon-advanced-page-cache.php',
    27             'powered-cache/powered-cache.php',
    28             'sg-cachepress/sg-cachepress.php',
    29             'simple-cache/simple-cache.php',
    30             // 'redis-cache/redis-cache.php',
    31             'w3-total-cache/w3-total-cache.php',
    32             'wp-cloudflare-page-cache/wp-cloudflare-page-cache.php',
    33             'wp-fastest-cache/wpFastestCache.php',
    34             'wp-meteor/wp-meteor.php',
    35             'wp-optimize/wp-optimize.php',
    36             'wp-performance-score-booster/wp-performance-score-booster.php',
    37             'wp-rocket/wp-rocket.php',
    38             'wp-super-cache/wp-cache.php',
    39         );
     16    array(
     17        // 'autoptimize/autoptimize.php',
     18        'breeze/breeze.php',
     19        'cache-enabler/cache-enabler.php',
     20        'cachify/cachify.php',
     21        'cloudflare/cloudflare.php',
     22        'comet-cache/comet-cache.php',
     23        'docket-cache/docket-cache.php',
     24        'fast-velocity-minify/fvm.php',
     25        'hummingbird-performance/wp-hummingbird.php',
     26        'nginx-cache/nginx-cache.php',
     27        'nitropack/main.php',
     28        'pantheon-advanced-page-cache/pantheon-advanced-page-cache.php',
     29        'powered-cache/powered-cache.php',
     30        'psn-pagespeed-ninja/pagespeedninja.php',
     31        'sg-cachepress/sg-cachepress.php',
     32        'simple-cache/simple-cache.php',
     33        // 'redis-cache/redis-cache.php',
     34        'w3-total-cache/w3-total-cache.php',
     35        'wp-cloudflare-page-cache/wp-cloudflare-page-cache.php',
     36        'wp-fastest-cache/wpFastestCache.php',
     37        'wp-meteor/wp-meteor.php',
     38        'wp-optimize/wp-optimize.php',
     39        'wp-performance-score-booster/wp-performance-score-booster.php',
     40        'wp-rocket/wp-rocket.php',
     41        'wp-super-cache/wp-cache.php',
     42    );
    4043
    4144    private static $_option = 'thirdparty_litespeed_check';
    4245    private static $_msg_id = 'id="lscwp-incompatible-plugin-notice"';
    4346
    44     public static function detect() {
    45         if ( ! is_admin() ) {
     47    public static function detect()
     48    {
     49        if (!is_admin()) {
    4650            return;
    4751        }
     
    5054         * Check for incompatible plugins when `litespeed-cache` is first activated.
    5155         */
    52         $plugin = basename( LSCWP_DIR ) . '/litespeed-cache.php';
    53         register_deactivation_hook( $plugin, function( $_network_wide ) {
    54             \LiteSpeed\Admin_Display::delete_option( self::$_option );
    55         } );
    56         if ( ! \LiteSpeed\Admin_Display::get_option( self::$_option ) ) {
    57             self::activated_plugin( $plugin, null );
    58             \LiteSpeed\Admin_Display::add_option( self::$_option, true );
     56        $plugin = basename(LSCWP_DIR) . '/litespeed-cache.php';
     57        register_deactivation_hook($plugin, function ($_network_wide) {
     58            \LiteSpeed\Admin_Display::delete_option(self::$_option);
     59        });
     60        if (!\LiteSpeed\Admin_Display::get_option(self::$_option)) {
     61            self::activated_plugin($plugin, null);
     62            \LiteSpeed\Admin_Display::add_option(self::$_option, true);
    5963        }
    6064
     
    6266         * Check for incompatible plugins when any plugin is (de)activated.
    6367         */
    64         add_action( 'activated_plugin', __CLASS__ . '::activated_plugin', 10, 2 );
    65         add_action( 'deactivated_plugin', __CLASS__ . '::deactivated_plugin', 10, 2 );
     68        add_action('activated_plugin', __CLASS__ . '::activated_plugin', 10, 2);
     69        add_action('deactivated_plugin', __CLASS__ . '::deactivated_plugin', 10, 2);
     70
     71        if (class_exists('PagespeedNinja')) {
     72            \LiteSpeed\Admin_Display::error(
     73                '<div ' . self::$_msg_id . '>'
     74                    . esc_html__(
     75                        'Please consider disabling the following detected plugins, as they may conflict with LiteSpeed Cache:',
     76                        'litespeed-cache'
     77                    )
     78                    . '<p style="color: red; font-weight: 700;">'
     79                    . 'PageSpeed Ninja'
     80                    . '</p>'
     81                    . '</div>',
     82                false,
     83                true
     84            );
     85        }
    6686    }
    6787
    68     public static function activated_plugin( $plugin, $network_wide ) {
    69         self::incompatible_plugin_notice( $plugin, $network_wide, 'activated' );
     88    public static function activated_plugin($plugin, $network_wide)
     89    {
     90        self::incompatible_plugin_notice($plugin, $network_wide, 'activated');
    7091    }
    7192
    72     public static function deactivated_plugin( $plugin, $network_wide ) {
    73         self::incompatible_plugin_notice( $plugin, $network_wide, 'deactivated' );
     93    public static function deactivated_plugin($plugin, $network_wide)
     94    {
     95        self::incompatible_plugin_notice($plugin, $network_wide, 'deactivated');
    7496    }
    7597
     
    78100     * Show a notification if there are any.
    79101     */
    80     public static function incompatible_plugin_notice( $plugin, $_network_wide, $action ) {
     102    public static function incompatible_plugin_notice($plugin, $_network_wide, $action)
     103    {
    81104        self::update_messages();
    82105
     
    86109         * remove `$plugin` from the list.
    87110         */
    88         $deactivated = 'deactivated' === $action ? array( $plugin ) : array();
     111        $deactivated = 'deactivated' === $action ? array($plugin) : array();
    89112
    90113        $incompatible_plugins =
    91114            array_map(
    92                 function( $plugin ) { return WP_PLUGIN_DIR . '/' . $plugin; },
    93                 array_diff( self::$_incompatible_plugins, $deactivated )
     115                function ($plugin) {
     116                    return WP_PLUGIN_DIR . '/' . $plugin;
     117                },
     118                array_diff(self::$_incompatible_plugins, $deactivated)
    94119            );
    95120
    96121        $active_incompatible_plugins =
    97122            array_map(
    98                 function( $plugin ) {
    99                     $plugin = get_plugin_data( $plugin, false, true );
     123                function ($plugin) {
     124                    $plugin = get_plugin_data($plugin, false, true);
    100125                    return $plugin['Name'];
    101126                },
    102                 array_intersect( $incompatible_plugins, wp_get_active_and_valid_plugins() )
     127                array_intersect($incompatible_plugins, wp_get_active_and_valid_plugins())
    103128            );
    104129
    105         if ( empty( $active_incompatible_plugins ) ) {
     130        if (empty($active_incompatible_plugins)) {
    106131            return;
    107132        }
     
    109134        \LiteSpeed\Admin_Display::error(
    110135            '<div ' . self::$_msg_id . '>'
    111             . esc_html__(
    112                 'Please consider disabling the following detected plugins, as they may conflict with LiteSpeed Cache:',
    113                 'litespeed-cache'
    114             )
    115             . '<p style="color: red; font-weight: 700;">'
    116             . implode( ', ', $active_incompatible_plugins )
    117             . '</p>'
    118             . '</div>',
     136                . esc_html__(
     137                    'Please consider disabling the following detected plugins, as they may conflict with LiteSpeed Cache:',
     138                    'litespeed-cache'
     139                )
     140                . '<p style="color: red; font-weight: 700;">'
     141                . implode(', ', $active_incompatible_plugins)
     142                . '</p>'
     143                . '</div>',
    119144            false,
    120145            true
     
    127152     * notice(s).
    128153     */
    129     private static function update_messages() {
     154    private static function update_messages()
     155    {
    130156        $messages =
    131157            \LiteSpeed\Admin_Display::get_option(
     
    133159                array()
    134160            );
    135         if ( is_array( $messages ) ) {
    136             foreach ( $messages as $index => $message ) {
    137                 if ( strpos( $message, self::$_msg_id ) !== false ) {
    138                     unset( $messages[ $index ] );
    139                     if ( ! $messages ) {
     161        if (is_array($messages)) {
     162            foreach ($messages as $index => $message) {
     163                if (strpos($message, self::$_msg_id) !== false) {
     164                    unset($messages[$index]);
     165                    if (!$messages) {
    140166                        $messages = -1;
    141167                    }
  • litespeed-cache/trunk/thirdparty/woocommerce.cls.php

    r2832517 r2977143  
    11<?php
     2
    23/**
    34 * The Third Party integration with the WooCommerce plugin.
     
    910 * @author        LiteSpeed Technologies <[email protected]>
    1011 */
     12
    1113namespace LiteSpeed\Thirdparty;
    1214
    13 defined( 'WPINC' ) || exit;
     15defined('WPINC') || exit;
    1416
    1517use \LiteSpeed\API;
    1618use \LiteSpeed\Base;
    1719
    18 class WooCommerce extends Base {
     20class WooCommerce extends Base
     21{
    1922    const O_CACHE_TTL_FRONTPAGE = Base::O_CACHE_TTL_FRONTPAGE;
    2023
    21     const CACHETAG_SHOP = 'WC_S' ;
    22     const CACHETAG_TERM = 'WC_T.' ;
    23     const O_UPDATE_INTERVAL = 'wc_update_interval' ;
    24     const O_PQS_CS = 0 ; // flush product on quantity + stock change, categories on stock change
    25     const O_PS_CS = 1 ; // flush product and categories on stock change
    26     const O_PS_CN = 2 ; // flush product on stock change, categories no flush
    27     const O_PQS_CQS = 3 ; // flush product and categories on quantity + stock change
    28 
    29     const ESI_PARAM_ARGS = 'wc_args' ;
    30     const ESI_PARAM_POSTID = 'wc_post_id' ;
    31     const ESI_PARAM_NAME = 'wc_name' ;
    32     const ESI_PARAM_PATH = 'wc_path' ;
    33     const ESI_PARAM_LOCATED = 'wc_located' ;
    34 
    35     private $esi_enabled ;
     24    const CACHETAG_SHOP = 'WC_S';
     25    const CACHETAG_TERM = 'WC_T.';
     26    const O_UPDATE_INTERVAL = 'wc_update_interval';
     27    const O_CART_VARY = 'wc_cart_vary';
     28    const O_PQS_CS = 0; // flush product on quantity + stock change, categories on stock change
     29    const O_PS_CS = 1; // flush product and categories on stock change
     30    const O_PS_CN = 2; // flush product on stock change, categories no flush
     31    const O_PQS_CQS = 3; // flush product and categories on quantity + stock change
     32
     33    const ESI_PARAM_ARGS = 'wc_args';
     34    const ESI_PARAM_POSTID = 'wc_post_id';
     35    const ESI_PARAM_NAME = 'wc_name';
     36    const ESI_PARAM_PATH = 'wc_path';
     37    const ESI_PARAM_LOCATED = 'wc_located';
     38
     39    private $esi_enabled;
    3640
    3741    /**
     
    4347    public static function detect()
    4448    {
    45         if ( ! defined( 'WOOCOMMERCE_VERSION' ) ) {
    46             return ;
    47         }
    48 
    49         self::cls()->add_hooks() ;
    50 
     49        if (!defined('WOOCOMMERCE_VERSION')) {
     50            return;
     51        }
     52
     53        self::cls()->add_hooks();
    5154    }
    5255
     
    5962    public function add_hooks()
    6063    {
    61         $this->_option_append() ;
    62 
    63         $this->esi_enabled = apply_filters( 'litespeed_esi_status', false );
    64 
    65         add_action( 'litespeed_control_finalize', array( $this, 'set_control' ) );
    66         add_action( 'litespeed_tag_finalize', array( $this, 'set_tag' ) );
     64        $this->_option_append();
     65
     66        $this->esi_enabled = apply_filters('litespeed_esi_status', false);
     67
     68        add_action('litespeed_control_finalize', array($this, 'set_control'));
     69        add_action('litespeed_tag_finalize', array($this, 'set_tag'));
    6770
    6871        // Purging a product on stock change should only occur during product purchase. This function will add the purging callback when an order is complete.
    69         add_action( 'woocommerce_product_set_stock', array( $this, 'purge_product' ) ) ;
    70         add_action( 'woocommerce_variation_set_stock', array( $this, 'purge_product' ) ) ; // #984479 Update variations stock
    71 
    72         add_action( 'comment_post', array( $this, 'add_review' ), 10, 3 ) ;
    73 
    74         if ( $this->esi_enabled ) {
    75             if ( function_exists( 'is_shop' ) && ! is_shop() ) {
    76                 add_action( 'litespeed_tpl_normal', array( $this, 'set_block_template' ) );
     72        add_action('woocommerce_product_set_stock', array($this, 'purge_product'));
     73        add_action('woocommerce_variation_set_stock', array($this, 'purge_product')); // #984479 Update variations stock
     74
     75        add_action('comment_post', array($this, 'add_review'), 10, 3);
     76
     77        if ($this->esi_enabled) {
     78            if (function_exists('is_shop') && !is_shop()) {
     79                add_action('litespeed_tpl_normal', array($this, 'set_block_template'));
    7780                // No need for add-to-cart button
    7881                // add_action( 'litespeed_esi_load-wc-add-to-cart-form', array( $this, 'load_add_to_cart_form_block' ) ) ;
    7982
    80                 add_action( 'litespeed_esi_load-storefront-cart-header', array( $this, 'load_cart_header' ) );
    81                 add_action( 'litespeed_esi_load-widget', array( $this, 'register_post_view' ) );
    82             }
    83 
    84             if ( function_exists( 'is_product' ) && is_product() ) {
    85                 add_filter( 'litespeed_esi_params', array( $this, 'add_post_id' ), 10, 2 );
    86             }
    87 
    88         }
    89 
    90         if ( is_admin() ) {
    91             add_action('litespeed_api_purge_post', array( $this, 'backend_purge' ) ) ;//todo
    92             add_action( 'delete_term_relationships', array( $this, 'delete_rel' ), 10, 2 ) ;
    93             add_action( 'litespeed_settings_tab', array( $this, 'settings_add_tab' ) );
    94             add_action( 'litespeed_settings_content', array( $this, 'settings_add_content' ) );
    95             add_filter( 'litespeed_widget_default_options', array( $this, 'wc_widget_default' ), 10, 2 );
    96         }
    97 
     83                add_action('litespeed_esi_load-storefront-cart-header', array($this, 'load_cart_header'));
     84                add_action('litespeed_esi_load-widget', array($this, 'register_post_view'));
     85            }
     86
     87            if (function_exists('is_product') && is_product()) {
     88                add_filter('litespeed_esi_params', array($this, 'add_post_id'), 10, 2);
     89            }
     90        }
     91
     92        if (is_admin()) {
     93            add_action('litespeed_api_purge_post', array($this, 'backend_purge')); //todo
     94            add_action('delete_term_relationships', array($this, 'delete_rel'), 10, 2);
     95            add_action('litespeed_settings_tab', array($this, 'settings_add_tab'));
     96            add_action('litespeed_settings_content', array($this, 'settings_add_content'));
     97            add_filter('litespeed_widget_default_options', array($this, 'wc_widget_default'), 10, 2);
     98        }
     99
     100        if (apply_filters('litespeed_conf', self::O_CART_VARY)) {
     101            add_filter('litespeed_vary_cookies', function ($list) {
     102                $list[] = 'woocommerce_cart_hash';
     103                return array_unique($list);
     104            });
     105        }
    98106    }
    99107
     
    106114    public function purge_esi()
    107115    {
    108         do_action( 'litespeed_debug', '3rd woo purge ESI in action: ' . current_filter() ) ;
    109         do_action( 'litespeed_purge_private_esi', 'storefront-cart-header' );
    110 
     116        do_action('litespeed_debug', '3rd woo purge ESI in action: ' . current_filter());
     117        do_action('litespeed_purge_private_esi', 'storefront-cart-header');
    111118    }
    112119
     
    119126    public function purge_private_all()
    120127    {
    121         do_action( 'litespeed_purge_private_all' );
     128        do_action('litespeed_purge_private_all');
    122129    }
    123130
     
    128135     * @access public
    129136     */
    130     public function check_if_need_esi( $template )
    131     {
    132         if (  $this->vary_needed() ) {
    133             do_action( 'litespeed_debug', 'API: 3rd woo added ESI' );
    134             add_action( 'litespeed_tpl_normal', array( $this, 'set_swap_header_cart' ) );
     137    public function check_if_need_esi($template)
     138    {
     139        if ($this->vary_needed()) {
     140            do_action('litespeed_debug', 'API: 3rd woo added ESI');
     141            add_action('litespeed_tpl_normal', array($this, 'set_swap_header_cart'));
    135142        }
    136143
    137144        return $template;
    138 
    139145    }
    140146
     
    145151     * @access public
    146152     */
    147     public function vary_maintain( $vary ) {
    148         if ( $this->vary_needed() ) {
    149             do_action( 'litespeed_debug', 'API: 3rd woo added vary due to cart not empty' );
    150             $vary[ 'woo_cart' ] = 1;
     153    public function vary_maintain($vary)
     154    {
     155        if ($this->vary_needed()) {
     156            do_action('litespeed_debug', 'API: 3rd woo added vary due to cart not empty');
     157            $vary['woo_cart'] = 1;
    151158        }
    152159
     
    162169    private function vary_needed()
    163170    {
    164         if ( ! function_exists( 'WC' ) ) {
    165             return false ;
    166         }
    167 
    168         $woocom = WC() ;
    169         if ( ! $woocom ) {
    170             return false ;
    171         }
    172 
    173         if ( is_null( $woocom->cart ) ) {
    174             return false ;
    175         }
    176         return $woocom->cart->get_cart_contents_count() > 0 ;
     171        if (!function_exists('WC')) {
     172            return false;
     173        }
     174
     175        $woocom = WC();
     176        if (!$woocom) {
     177            return false;
     178        }
     179
     180        if (is_null($woocom->cart)) {
     181            return false;
     182        }
     183        return $woocom->cart->get_cart_contents_count() > 0;
    177184    }
    178185
     
    186193    public function set_block_template()
    187194    {
    188         add_action('woocommerce_before_template_part', array( $this, 'block_template' ), 999, 4) ;
     195        add_action('woocommerce_before_template_part', array($this, 'block_template'), 999, 4);
    189196    }
    190197
     
    202209    public function set_swap_header_cart()
    203210    {
    204         $priority = has_action('storefront_header', 'storefront_header_cart') ;
    205         if ( $priority !== false ) {
    206             remove_action('storefront_header', 'storefront_header_cart', $priority) ;
    207             add_action('storefront_header', array( $this, 'esi_cart_header' ), $priority) ;
     211        $priority = has_action('storefront_header', 'storefront_header_cart');
     212        if ($priority !== false) {
     213            remove_action('storefront_header', 'storefront_header_cart', $priority);
     214            add_action('storefront_header', array($this, 'esi_cart_header'), $priority);
    208215        }
    209216    }
     
    220227    public function block_template($template_name, $template_path, $located, $args)
    221228    {
    222         if ( strpos($template_name, 'add-to-cart') === false ) {
    223             if ( strpos($template_name, 'related.php') !== false ) {
    224                 remove_action('woocommerce_before_template_part', array( $this, 'block_template' ), 999) ;
    225                 add_filter('woocommerce_related_products_args', array( $this, 'add_related_tags' ) ) ;
    226                 add_action('woocommerce_after_template_part', array( $this, 'end_template' ), 999) ;
    227             }
    228             return ;
    229         }
    230         return ;
    231 
    232 
    233 
    234 
    235                             // todo: wny not use?
    236 
    237         global $post ;
     229        if (strpos($template_name, 'add-to-cart') === false) {
     230            if (strpos($template_name, 'related.php') !== false) {
     231                remove_action('woocommerce_before_template_part', array($this, 'block_template'), 999);
     232                add_filter('woocommerce_related_products_args', array($this, 'add_related_tags'));
     233                add_action('woocommerce_after_template_part', array($this, 'end_template'), 999);
     234            }
     235            return;
     236        }
     237        return;
     238
     239
     240
     241
     242        // todo: wny not use?
     243
     244        global $post;
    238245        $params = array(
    239246            self::ESI_PARAM_ARGS => $args,
     
    242249            self::ESI_PARAM_PATH => $template_path,
    243250            self::ESI_PARAM_LOCATED => $located
    244         ) ;
    245         add_action('woocommerce_after_add_to_cart_form', array( $this, 'end_form' ) ) ;
    246         add_action('woocommerce_after_template_part', array( $this, 'end_form' ), 999) ;
    247         echo apply_filters( 'litespeed_esi_url', 'wc-add-to-cart-form', 'WC_CART_FORM', $params );
    248         echo apply_filters( 'litespeed_clean_wrapper_begin', '' );
     251        );
     252        add_action('woocommerce_after_add_to_cart_form', array($this, 'end_form'));
     253        add_action('woocommerce_after_template_part', array($this, 'end_form'), 999);
     254        echo apply_filters('litespeed_esi_url', 'wc-add-to-cart-form', 'WC_CART_FORM', $params);
     255        echo apply_filters('litespeed_clean_wrapper_begin', '');
    249256    }
    250257
     
    260267    public function end_form($template_name = '')
    261268    {
    262         if ( ! empty($template_name) && strpos($template_name, 'add-to-cart') === false ) {
    263             return ;
    264         }
    265         echo apply_filters( 'litespeed_clean_wrapper_end', '' );
    266         remove_action('woocommerce_after_add_to_cart_form', array( $this, 'end_form' ) ) ;
    267         remove_action('woocommerce_after_template_part', array( $this, 'end_form' ), 999) ;
     269        if (!empty($template_name) && strpos($template_name, 'add-to-cart') === false) {
     270            return;
     271        }
     272        echo apply_filters('litespeed_clean_wrapper_end', '');
     273        remove_action('woocommerce_after_add_to_cart_form', array($this, 'end_form'));
     274        remove_action('woocommerce_after_template_part', array($this, 'end_form'), 999);
    268275    }
    269276
     
    281288    public function add_related_tags($args)
    282289    {
    283         if ( empty($args) || ! isset($args['post__in']) ) {
    284             return $args ;
    285         }
    286         $related_posts = $args['post__in'] ;
    287         foreach ( $related_posts as $related ) {
    288             do_action( 'litespeed_tag_add_post', $related );
    289         }
    290         return $args ;
     290        if (empty($args) || !isset($args['post__in'])) {
     291            return $args;
     292        }
     293        $related_posts = $args['post__in'];
     294        foreach ($related_posts as $related) {
     295            do_action('litespeed_tag_add_post', $related);
     296        }
     297        return $args;
    291298    }
    292299
     
    302309    public function end_template($template_name)
    303310    {
    304         if ( strpos($template_name, 'related.php') !== false ) {
    305             remove_action('woocommerce_after_template_part', array( $this, 'end_template' ), 999) ;
    306             $this->set_block_template() ;
     311        if (strpos($template_name, 'related.php') !== false) {
     312            remove_action('woocommerce_after_template_part', array($this, 'end_template'), 999);
     313            $this->set_block_template();
    307314        }
    308315    }
     
    318325    public function esi_cart_header()
    319326    {
    320         echo apply_filters( 'litespeed_esi_url', 'storefront-cart-header', 'STOREFRONT_CART_HEADER' );
     327        echo apply_filters('litespeed_esi_url', 'storefront-cart-header', 'STOREFRONT_CART_HEADER');
    321328    }
    322329
     
    348355    public function load_add_to_cart_form_block($params)
    349356    {
    350         global $post, $wp_query ;
    351         $post = get_post($params[self::ESI_PARAM_POSTID]) ;
    352         $wp_query->setup_postdata($post) ;
    353         function_exists( 'wc_get_template' ) && wc_get_template($params[self::ESI_PARAM_NAME], $params[self::ESI_PARAM_ARGS], $params[self::ESI_PARAM_PATH]) ;
     357        global $post, $wp_query;
     358        $post = get_post($params[self::ESI_PARAM_POSTID]);
     359        $wp_query->setup_postdata($post);
     360        function_exists('wc_get_template') && wc_get_template($params[self::ESI_PARAM_NAME], $params[self::ESI_PARAM_ARGS], $params[self::ESI_PARAM_PATH]);
    354361    }
    355362
     
    367374    public function register_post_view($params)
    368375    {
    369         if ( $params[API::PARAM_NAME] !== 'WC_Widget_Recently_Viewed' ) {
    370             return ;
    371         }
    372         if ( ! isset($params[self::ESI_PARAM_POSTID]) ) {
    373             return ;
    374         }
    375         $id = $params[self::ESI_PARAM_POSTID] ;
    376         $esi_post = get_post($id) ;
    377         $product = function_exists( 'wc_get_product' ) ? wc_get_product($esi_post) : false ;
    378 
    379         if ( empty($product) ) {
    380             return ;
    381         }
    382 
    383         global $post ;
    384         $post = $esi_post ;
    385         function_exists( 'wc_track_product_view' ) && wc_track_product_view() ;
     376        if ($params[API::PARAM_NAME] !== 'WC_Widget_Recently_Viewed') {
     377            return;
     378        }
     379        if (!isset($params[self::ESI_PARAM_POSTID])) {
     380            return;
     381        }
     382        $id = $params[self::ESI_PARAM_POSTID];
     383        $esi_post = get_post($id);
     384        $product = function_exists('wc_get_product') ? wc_get_product($esi_post) : false;
     385
     386        if (empty($product)) {
     387            return;
     388        }
     389
     390        global $post;
     391        $post = $esi_post;
     392        function_exists('wc_track_product_view') && wc_track_product_view();
    386393    }
    387394
     
    394401     * @access public
    395402     */
    396     public function add_post_id( $params, $block_id )
    397     {
    398         if ( $block_id == 'widget' ) {
    399             if ( $params[ API::PARAM_NAME ] == 'WC_Widget_Recently_Viewed' ) {
    400                 $params[ self::ESI_PARAM_POSTID ] = get_the_ID();
     403    public function add_post_id($params, $block_id)
     404    {
     405        if ($block_id == 'widget') {
     406            if ($params[API::PARAM_NAME] == 'WC_Widget_Recently_Viewed') {
     407                $params[self::ESI_PARAM_POSTID] = get_the_ID();
    401408            }
    402409        }
     
    414421     * @access public
    415422     */
    416     public function wc_widget_default( $options, $widget )
    417     {
    418         if ( ! is_array( $options ) ) {
     423    public function wc_widget_default($options, $widget)
     424    {
     425        if (!is_array($options)) {
    419426            return $options;
    420427        }
    421         $widget_name = get_class( $widget ) ;
    422         if ( $widget_name === 'WC_Widget_Recently_Viewed' ) {
    423             $options[ API::WIDGET_O_ESIENABLE ] = API::VAL_ON2;
    424             $options[ API::WIDGET_O_TTL ] = 0;
    425         }
    426         elseif ( $widget_name === 'WC_Widget_Recent_Reviews' ) {
    427             $options[ API::WIDGET_O_ESIENABLE ] = API::VAL_ON;
    428             $options[ API::WIDGET_O_TTL ] = 86400;
     428        $widget_name = get_class($widget);
     429        if ($widget_name === 'WC_Widget_Recently_Viewed') {
     430            $options[API::WIDGET_O_ESIENABLE] = API::VAL_ON2;
     431            $options[API::WIDGET_O_TTL] = 0;
     432        } elseif ($widget_name === 'WC_Widget_Recent_Reviews') {
     433            $options[API::WIDGET_O_ESIENABLE] = API::VAL_ON;
     434            $options[API::WIDGET_O_TTL] = 86400;
    429435        }
    430436        return $options;
     
    440446    public function set_tag()
    441447    {
    442         $id = get_the_ID() ;
    443         if ( $id === false ) {
    444             return ;
     448        $id = get_the_ID();
     449        if ($id === false) {
     450            return;
    445451        }
    446452
    447453        // Check if product has a cache ttl limit or not
    448         $sale_from = (int) get_post_meta( $id, '_sale_price_dates_from', true ) ;
    449         $sale_to = (int) get_post_meta( $id, '_sale_price_dates_to', true ) ;
    450         $now = current_time( 'timestamp' ) ;
    451         $ttl = false ;
    452         if ( $sale_from && $now < $sale_from ) {
    453             $ttl = $sale_from - $now ;
    454         }
    455         elseif ( $sale_to && $now < $sale_to ) {
    456             $ttl = $sale_to - $now ;
    457         }
    458         if ( $ttl && $ttl < apply_filters( 'litespeed_control_ttl', 0 ) ) {
    459             do_action( 'litespeed_control_set_ttl', $ttl, "WooCommerce set scheduled TTL to $ttl" ) ;
    460         }
    461 
    462         if ( function_exists( 'is_shop' ) && is_shop() ) {
    463             do_action( 'litespeed_tag_add', self::CACHETAG_SHOP );
    464         }
    465         if ( function_exists( 'is_product_taxonomy' ) && ! is_product_taxonomy() ) {
    466             return ;
    467         }
    468         if ( isset($GLOBALS['product_cat']) && is_string( $GLOBALS['product_cat'] ) ) { // todo: need to check previous woo version to find if its from old woo versions or not!
    469             $term = get_term_by('slug', $GLOBALS['product_cat'], 'product_cat') ;
    470         }
    471         elseif ( isset($GLOBALS['product_tag']) && is_string( $GLOBALS['product_tag'] ) ) {
    472             $term = get_term_by('slug', $GLOBALS['product_tag'], 'product_tag') ;
    473         }
    474         else {
    475             $term = false ;
    476         }
    477 
    478         if ( $term === false ) {
    479             return ;
    480         }
    481         while ( isset($term) ) {
    482             do_action( 'litespeed_tag_add', self::CACHETAG_TERM . $term->term_id );
    483             if ( $term->parent == 0 ) {
    484                 break ;
    485             }
    486             $term = get_term($term->parent) ;
     454        $sale_from = (int) get_post_meta($id, '_sale_price_dates_from', true);
     455        $sale_to = (int) get_post_meta($id, '_sale_price_dates_to', true);
     456        $now = current_time('timestamp');
     457        $ttl = false;
     458        if ($sale_from && $now < $sale_from) {
     459            $ttl = $sale_from - $now;
     460        } elseif ($sale_to && $now < $sale_to) {
     461            $ttl = $sale_to - $now;
     462        }
     463        if ($ttl && $ttl < apply_filters('litespeed_control_ttl', 0)) {
     464            do_action('litespeed_control_set_ttl', $ttl, "WooCommerce set scheduled TTL to $ttl");
     465        }
     466
     467        if (function_exists('is_shop') && is_shop()) {
     468            do_action('litespeed_tag_add', self::CACHETAG_SHOP);
     469        }
     470        if (function_exists('is_product_taxonomy') && !is_product_taxonomy()) {
     471            return;
     472        }
     473        if (isset($GLOBALS['product_cat']) && is_string($GLOBALS['product_cat'])) { // todo: need to check previous woo version to find if its from old woo versions or not!
     474            $term = get_term_by('slug', $GLOBALS['product_cat'], 'product_cat');
     475        } elseif (isset($GLOBALS['product_tag']) && is_string($GLOBALS['product_tag'])) {
     476            $term = get_term_by('slug', $GLOBALS['product_tag'], 'product_tag');
     477        } else {
     478            $term = false;
     479        }
     480
     481        if ($term === false) {
     482            return;
     483        }
     484        while (isset($term)) {
     485            do_action('litespeed_tag_add', self::CACHETAG_TERM . $term->term_id);
     486            if ($term->parent == 0) {
     487                break;
     488            }
     489            $term = get_term($term->parent);
    487490        }
    488491    }
     
    494497     * @since 1.6.3 Removed static
    495498     * @access public
    496     * @param string $esi_id        The ESI block id if a request is an ESI request.
     499    * @param string $esi_id        The ESI block id if a request is an ESI request.
    497500     * @return boolean              True if cacheable, false if not.
    498501     */
    499502    public function set_control($esi_id)
    500503    {
    501         if ( ! apply_filters( 'litespeed_control_cacheable', false ) ) {
     504        if (!apply_filters('litespeed_control_cacheable', false)) {
    502505            return;
    503506        }
     
    507510         * @since 1.6.2.1
    508511         */
    509         if ( ! function_exists( 'WC' ) ) {
    510             return ;
    511         }
    512 
    513         $woocom = WC() ;
    514         if ( ! $woocom || empty( $woocom->session ) ) {
    515             return ;
     512        if (!function_exists('WC')) {
     513            return;
     514        }
     515
     516        $woocom = WC();
     517        if (!$woocom || empty($woocom->session)) {
     518            return;
    516519        }
    517520
    518521        // For later versions, DONOTCACHEPAGE should be set.
    519522        // No need to check uri/qs.
    520         if ( version_compare($woocom->version, '1.4.2', '>=') ) {
    521             if ( version_compare( $woocom->version, '3.2.0', '<' ) && defined('DONOTCACHEPAGE') && DONOTCACHEPAGE ) {
    522                 do_action( 'litespeed_control_set_nocache', '3rd party woocommerce not cache by constant' );
    523                 return ;
    524             }
    525             elseif ( version_compare($woocom->version, '2.1.0', '>=') ) {
    526                 $err = false ;
    527 
    528                 if ( ! function_exists( 'wc_get_page_id' ) ) {
    529                     return ;
     523        if (version_compare($woocom->version, '1.4.2', '>=')) {
     524            if (version_compare($woocom->version, '3.2.0', '<') && defined('DONOTCACHEPAGE') && DONOTCACHEPAGE) {
     525                do_action('litespeed_control_set_nocache', '3rd party woocommerce not cache by constant');
     526                return;
     527            } elseif (version_compare($woocom->version, '2.1.0', '>=')) {
     528                $err = false;
     529
     530                if (!function_exists('wc_get_page_id')) {
     531                    return;
    530532                }
    531533                /**
     
    533535                 * @since  1.4
    534536                 */
    535                 $page_ids = array_filter( array( wc_get_page_id( 'cart' ), wc_get_page_id( 'checkout' ), wc_get_page_id( 'myaccount' ) ) );
    536                 if ( isset( $_GET['download_file'] ) || isset( $_GET['add-to-cart'] ) || is_page( $page_ids ) ) {
    537                     $err = 'woo non cacheable pages' ;
     537                $page_ids = array_filter(array(wc_get_page_id('cart'), wc_get_page_id('checkout'), wc_get_page_id('myaccount')));
     538                if (isset($_GET['download_file']) || isset($_GET['add-to-cart']) || is_page($page_ids)) {
     539                    $err = 'woo non cacheable pages';
     540                } elseif (function_exists('wc_notice_count') && wc_notice_count() > 0) {
     541                    $err = 'has wc notice';
    538542                }
    539                 elseif ( function_exists( 'wc_notice_count' ) && wc_notice_count() > 0 ) {
    540                     $err = 'has wc notice' ;
     543
     544                if ($err) {
     545                    do_action('litespeed_control_set_nocache', '3rd party woocommerce not cache due to ' . $err);
     546                    return;
    541547                }
    542 
    543                 if ( $err ) {
    544                     do_action( 'litespeed_control_set_nocache', '3rd party woocommerce not cache due to ' . $err );
    545                     return ;
    546                 }
    547             }
    548             return ;
    549         }
    550 
    551         $uri = esc_url($_SERVER["REQUEST_URI"]) ;
    552         $uri_len = strlen($uri) ;
    553         if ( $uri_len < 5 ) {
    554             return ;
    555         }
    556 
    557         if ( in_array($uri, array('cart/', 'checkout/', 'my-account/', 'addons/', 'logout/', 'lost-password/', 'product/')) ) { // why contains `product`?
    558             do_action( 'litespeed_control_set_nocache', 'uri in cart/account/user pages' );
    559             return ;
    560         }
    561 
    562         $qs = sanitize_text_field($_SERVER["QUERY_STRING"]) ;
    563         $qs_len = strlen($qs) ;
    564         if ( ! empty($qs) && $qs_len >= 12 && strpos( $qs, 'add-to-cart=' ) === 0 ) {
    565             do_action( 'litespeed_control_set_nocache', 'qs contains add-to-cart' );
    566             return ;
     548            }
     549            return;
     550        }
     551
     552        $uri = esc_url($_SERVER["REQUEST_URI"]);
     553        $uri_len = strlen($uri);
     554        if ($uri_len < 5) {
     555            return;
     556        }
     557
     558        if (in_array($uri, array('cart/', 'checkout/', 'my-account/', 'addons/', 'logout/', 'lost-password/', 'product/'))) { // why contains `product`?
     559            do_action('litespeed_control_set_nocache', 'uri in cart/account/user pages');
     560            return;
     561        }
     562
     563        $qs = sanitize_text_field($_SERVER["QUERY_STRING"]);
     564        $qs_len = strlen($qs);
     565        if (!empty($qs) && $qs_len >= 12 && strpos($qs, 'add-to-cart=') === 0) {
     566            do_action('litespeed_control_set_nocache', 'qs contains add-to-cart');
     567            return;
    567568        }
    568569    }
     
    576577     * @param WC_Product $product
    577578     */
    578     public function purge_product($product) {
    579         do_action( 'litespeed_debug', '[3rd] Woo Purge [pid]' . $product->get_id() );
    580 
    581         $config = apply_filters( 'litespeed_conf', self::O_UPDATE_INTERVAL ) ;
    582         if ( is_null($config) ) {
    583             $config = self::O_PQS_CS ;
    584         }
    585 
    586         if ( $config === self::O_PQS_CQS ) {
    587             $this->backend_purge($product->get_id()) ;
    588         }
    589         elseif ( $config !== self::O_PQS_CS && $product->is_in_stock() ) {
    590             do_action( 'litespeed_debug', '[3rd] Woo No purge needed [option] ' . $config );
    591             return ;
    592         }
    593         elseif ( $config !== self::O_PS_CN && ! $product->is_in_stock() ) {
    594             $this->backend_purge($product->get_id()) ;
    595         }
    596 
    597         do_action( 'litespeed_purge_post', $product->get_id() );
     579    public function purge_product($product)
     580    {
     581        do_action('litespeed_debug', '[3rd] Woo Purge [pid]' . $product->get_id());
     582
     583        $config = apply_filters('litespeed_conf', self::O_UPDATE_INTERVAL);
     584        if (is_null($config)) {
     585            $config = self::O_PQS_CS;
     586        }
     587
     588        if ($config === self::O_PQS_CQS) {
     589            $this->backend_purge($product->get_id());
     590        } elseif ($config !== self::O_PQS_CS && $product->is_in_stock()) {
     591            do_action('litespeed_debug', '[3rd] Woo No purge needed [option] ' . $config);
     592            return;
     593        } elseif ($config !== self::O_PS_CN && !$product->is_in_stock()) {
     594            $this->backend_purge($product->get_id());
     595        }
     596
     597        do_action('litespeed_purge_post', $product->get_id());
    598598
    599599        // Check if is variation, purge stock too #984479
    600         if ( $product->is_type( 'variation' ) ) {
    601             do_action( 'litespeed_purge_post', $product->get_parent_id() );
     600        if ($product->is_type('variation')) {
     601            do_action('litespeed_purge_post', $product->get_parent_id());
     602        }
     603
     604        // Check if WPML is enabled ##972971
     605        if (  defined( 'WPML_PLUGIN_BASENAME' ) ) {
     606            // Check if it is a variable product and get post/parent ID
     607            $wpml_purge_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
     608            $type = apply_filters( 'wpml_element_type', get_post_type( $wpml_purge_id ) );
     609            $trid = apply_filters( 'wpml_element_trid', false, $wpml_purge_id, $type );
     610            $translations = apply_filters( 'wpml_get_element_translations', array(), $trid, $type );
     611            foreach ( $translations as $lang => $translation ) {
     612            do_action( 'litespeed_debug', '[3rd] Woo WPML purge language: ' . $translation->language_code . ' , post ID: ' . $translation->element_id);
     613            do_action( 'litespeed_purge_post', $translation->element_id );
     614            // use the $translation->element_id as it is post ID of other languages
     615            }
    602616        }
    603617    }
     
    616630    public function delete_rel($post_id, $term_ids)
    617631    {
    618         if ( ! function_exists( 'wc_get_product' ) ) {
    619             return ;
    620         }
    621 
    622         if ( empty($term_ids) || wc_get_product($post_id) === false ) {
    623             return ;
    624         }
    625         foreach ( $term_ids as $term_id ) {
    626             do_action( 'litespeed_purge', self::CACHETAG_TERM . $term_id );
     632        if (!function_exists('wc_get_product')) {
     633            return;
     634        }
     635
     636        if (empty($term_ids) || wc_get_product($post_id) === false) {
     637            return;
     638        }
     639        foreach ($term_ids as $term_id) {
     640            do_action('litespeed_purge', self::CACHETAG_TERM . $term_id);
    627641        }
    628642    }
     
    638652    public function backend_purge($post_id)
    639653    {
    640         if ( ! function_exists( 'wc_get_product' ) ) {
    641             return ;
    642         }
    643 
    644         if ( ! isset($post_id) || wc_get_product($post_id) === false ) {
    645             return ;
    646         }
    647 
    648         $cats = $this->get_cats($post_id) ;
    649         if ( ! empty($cats) ) {
    650             foreach ( $cats as $cat ) {
    651                 do_action( 'litespeed_purge', self::CACHETAG_TERM . $cat );
    652             }
    653         }
    654 
    655         if ( ! function_exists( 'wc_get_product_terms' ) ) {
    656             return ;
    657         }
    658 
    659         $tags = wc_get_product_terms($post_id, 'product_tag', array('fields' => 'ids')) ;
    660         if ( ! empty($tags) ) {
    661             foreach ( $tags as $tag ) {
    662                 do_action( 'litespeed_purge', self::CACHETAG_TERM . $tag );
     654        if (!function_exists('wc_get_product')) {
     655            return;
     656        }
     657
     658        if (!isset($post_id) || wc_get_product($post_id) === false) {
     659            return;
     660        }
     661
     662        $cats = $this->get_cats($post_id);
     663        if (!empty($cats)) {
     664            foreach ($cats as $cat) {
     665                do_action('litespeed_purge', self::CACHETAG_TERM . $cat);
     666            }
     667        }
     668
     669        if (!function_exists('wc_get_product_terms')) {
     670            return;
     671        }
     672
     673        $tags = wc_get_product_terms($post_id, 'product_tag', array('fields' => 'ids'));
     674        if (!empty($tags)) {
     675            foreach ($tags as $tag) {
     676                do_action('litespeed_purge', self::CACHETAG_TERM . $tag);
    663677            }
    664678        }
     
    677691    public function add_review($unused, $comment_approved, $commentdata)
    678692    {
    679         if ( ! function_exists( 'wc_get_product' ) ) {
    680             return ;
    681         }
    682 
    683         $post_id = $commentdata['comment_post_ID'] ;
    684         if ( $comment_approved !== 1 || ! isset($post_id) || wc_get_product($post_id) === false ) {
    685             return ;
    686         }
    687         global $wp_widget_factory ;
    688         $recent_reviews = $wp_widget_factory->widgets[ 'WC_Widget_Recent_Reviews' ] ;
    689         if ( ! is_null( $recent_reviews ) ) {
    690             do_action( 'litespeed_tag_add_widget', $recent_reviews->id );
     693        if (!function_exists('wc_get_product')) {
     694            return;
     695        }
     696
     697        $post_id = $commentdata['comment_post_ID'];
     698        if ($comment_approved !== 1 || !isset($post_id) || wc_get_product($post_id) === false) {
     699            return;
     700        }
     701        global $wp_widget_factory;
     702        $recent_reviews = $wp_widget_factory->widgets['WC_Widget_Recent_Reviews'];
     703        if (!is_null($recent_reviews)) {
     704            do_action('litespeed_tag_add_widget', $recent_reviews->id);
    691705        }
    692706    }
     
    698712     * @since  3.0 new API
    699713     */
    700     private function _option_append() {
     714    private function _option_append()
     715    {
    701716        // Append option save value filter
    702         do_action( 'litespeed_conf_multi_switch', self::O_UPDATE_INTERVAL, 3 ); // This need to be before conf_append
    703 
    704         do_action( 'litespeed_conf_append', self::O_UPDATE_INTERVAL, false );
     717        do_action('litespeed_conf_multi_switch', self::O_UPDATE_INTERVAL, 3); // This need to be before conf_append
     718
     719        do_action('litespeed_conf_append', self::O_UPDATE_INTERVAL, false);
     720        do_action('litespeed_conf_append', self::O_CART_VARY, false);
    705721    }
    706722
     
    711727     * @since 1.6.3 Removed static
    712728     */
    713     public function settings_add_tab( $setting_page )
    714     {
    715         if ( $setting_page != 'cache' ) {
    716             return ;
    717         }
    718 
    719         require 'woocommerce.tab.tpl.php' ;
     729    public function settings_add_tab($setting_page)
     730    {
     731        if ($setting_page != 'cache') {
     732            return;
     733        }
     734
     735        require 'woocommerce.tab.tpl.php';
    720736    }
    721737
     
    725741     * @since  3.0
    726742     */
    727     public function settings_add_content( $setting_page )
    728     {
    729         if ( $setting_page != 'cache' ) {
    730             return ;
    731         }
    732 
    733         require 'woocommerce.content.tpl.php' ;
     743    public function settings_add_content($setting_page)
     744    {
     745        if ($setting_page != 'cache') {
     746            return;
     747        }
     748
     749        require 'woocommerce.content.tpl.php';
    734750    }
    735751
     
    746762    private function get_cats($product_id)
    747763    {
    748         if ( ! function_exists( 'WC' ) ) {
    749             return ;
    750         }
    751 
    752         $woocom = WC() ;
    753         if ( isset($woocom) && version_compare($woocom->version, '2.5.0', '>=') && function_exists( 'wc_get_product_cat_ids' ) ) {
    754             return wc_get_product_cat_ids($product_id) ;
    755         }
    756         $product_cats = wp_get_post_terms($product_id, 'product_cat', array("fields" => "ids")) ;
    757         foreach ( $product_cats as $product_cat ) {
    758             $product_cats = array_merge($product_cats, get_ancestors($product_cat, 'product_cat')) ;
    759         }
    760 
    761         return $product_cats ;
     764        if (!function_exists('WC')) {
     765            return;
     766        }
     767
     768        $woocom = WC();
     769        if (isset($woocom) && version_compare($woocom->version, '2.5.0', '>=') && function_exists('wc_get_product_cat_ids')) {
     770            return wc_get_product_cat_ids($product_id);
     771        }
     772        $product_cats = wp_get_post_terms($product_id, 'product_cat', array("fields" => "ids"));
     773        foreach ($product_cats as $product_cat) {
     774            $product_cats = array_merge($product_cats, get_ancestors($product_cat, 'product_cat'));
     775        }
     776
     777        return $product_cats;
    762778    }
    763779
     
    773789         * Bulk edit hook need to add to preload as it will die before detect.
    774790         */
    775         add_action( 'wp_ajax_wpmelon_adv_bulk_edit', __CLASS__ . '::bulk_edit_purge', 1 ) ;
     791        add_action('wp_ajax_wpmelon_adv_bulk_edit', __CLASS__ . '::bulk_edit_purge', 1);
    776792    }
    777793
     
    783799    public static function bulk_edit_purge()
    784800    {
    785         if ( empty( $_POST[ 'type' ] ) || $_POST[ 'type' ] != 'saveproducts' || empty( $_POST[ 'data' ] ) ) return ;
     801        if (empty($_POST['type']) || $_POST['type'] != 'saveproducts' || empty($_POST['data'])) return;
    786802
    787803        /*
     
    795811        *   )
    796812        */
    797         $stock_string_arr = array() ;
    798         foreach ( $_POST[ 'data' ] as $stock_value ) {
    799             $stock_string_arr = array_merge( $stock_string_arr, explode( '#^#', $stock_value ) ) ;
    800         }
    801 
    802         $lscwp_3rd_woocommerce = new self() ;
    803 
    804         if ( count( $stock_string_arr ) < 1 ) {
    805             return ;
    806         }
    807 
    808         foreach ( $stock_string_arr as $edited_stock ) {
    809             $product_id = strtok( $edited_stock, '$' );
    810             $product = wc_get_product( $product_id ) ;
    811 
    812             if ( empty( $product ) ) {
    813                 do_action( 'litespeed_debug', '3rd woo purge: ' . $product_id . ' not found.' ) ;
    814                 continue ;
    815             }
    816 
    817             $lscwp_3rd_woocommerce->purge_product( $product );
     813        $stock_string_arr = array();
     814        foreach ($_POST['data'] as $stock_value) {
     815            $stock_string_arr = array_merge($stock_string_arr, explode('#^#', $stock_value));
     816        }
     817
     818        $lscwp_3rd_woocommerce = new self();
     819
     820        if (count($stock_string_arr) < 1) {
     821            return;
     822        }
     823
     824        foreach ($stock_string_arr as $edited_stock) {
     825            $product_id = strtok($edited_stock, '$');
     826            $product = wc_get_product($product_id);
     827
     828            if (empty($product)) {
     829                do_action('litespeed_debug', '3rd woo purge: ' . $product_id . ' not found.');
     830                continue;
     831            }
     832
     833            $lscwp_3rd_woocommerce->purge_product($product);
    818834        }
    819835    }
    820836}
    821 
  • litespeed-cache/trunk/thirdparty/woocommerce.content.tpl.php

    r2808204 r2977143  
    11<?php
     2
    23namespace LiteSpeed\Thirdparty;
    34
    4 defined( 'WPINC' ) || exit;
     5defined('WPINC') || exit;
    56
    67use \LiteSpeed\API;
     
    1314<div data-litespeed-layout='woocommerce'>
    1415
    15 <h3 class="litespeed-title-short">
    16     <?php echo __( 'WooCommerce Settings', 'litespeed-cache' ); ?>
    17     <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#woocommerce-tab' ); ?>
    18 </h3>
     16    <h3 class="litespeed-title-short">
     17        <?php echo __('WooCommerce Settings', 'litespeed-cache'); ?>
     18        <?php Doc::learn_more('https://docs.litespeedtech.com/lscache/lscwp/cache/#woocommerce-tab'); ?>
     19    </h3>
    1920
    20 <div class="litespeed-callout notice notice-warning inline">
    21     <h4><?php echo __( 'NOTICE:', 'litespeed-cache' ); ?></h4>
    22     <p><?php echo __( 'After verifying that the cache works in general, please test the cart.', 'litespeed-cache' ); ?></p>
    23     <p><?php echo sprintf( __( 'To test the cart, visit the <a %s>FAQ</a>.', 'litespeed-cache' ), 'href="https://docs.litespeedtech.com/lscache/lscwp/installation/#non-cacheable-pages" target="_blank"' ); ?></p>
    24     <p><?php echo __( 'By default, the My Account, Checkout, and Cart pages are automatically excluded from caching. Misconfiguration of page associations in WooCommerce settings may cause some pages to be erroneously excluded.', 'litespeed-cache' ); ?></p>
     21    <div class="litespeed-callout notice notice-warning inline">
     22        <h4><?php echo __('NOTICE:', 'litespeed-cache'); ?></h4>
     23        <p><?php echo __('After verifying that the cache works in general, please test the cart.', 'litespeed-cache'); ?></p>
     24        <p><?php echo sprintf(__('To test the cart, visit the <a %s>FAQ</a>.', 'litespeed-cache'), 'href="https://docs.litespeedtech.com/lscache/lscwp/installation/#non-cacheable-pages" target="_blank"'); ?></p>
     25        <p><?php echo __('By default, the My Account, Checkout, and Cart pages are automatically excluded from caching. Misconfiguration of page associations in WooCommerce settings may cause some pages to be erroneously excluded.', 'litespeed-cache'); ?></p>
     26    </div>
     27
     28    <table class="wp-list-table striped litespeed-table">
     29        <tbody>
     30            <tr>
     31                <th>
     32                    <?php $id = self::O_UPDATE_INTERVAL; ?>
     33                    <?php echo __('Product Update Interval', 'litespeed-cache'); ?>
     34                </th>
     35                <td>
     36                    <?php
     37                    $options = array(
     38                        self::O_PQS_CS  => __('Purge product on changes to the quantity or stock status.', 'litespeed-cache') . ' ' . __('Purge categories only when stock status changes.', 'litespeed-cache'),
     39                        self::O_PS_CS   => __('Purge product and categories only when the stock status changes.', 'litespeed-cache'),
     40                        self::O_PS_CN   => __('Purge product only when the stock status changes.', 'litespeed-cache') . ' ' . __('Do not purge categories on changes to the quantity or stock status.', 'litespeed-cache'),
     41                        self::O_PQS_CQS => __('Always purge both product and categories on changes to the quantity or stock status.', 'litespeed-cache'),
     42                    );
     43                    $conf = (int) apply_filters('litespeed_conf', $id);
     44                    foreach ($options as $k => $v) :
     45                        $checked = (int) $k === $conf ? ' checked ' : '';
     46                    ?>
     47                        <?php do_action('litespeed_setting_enroll', $id); ?>
     48                        <div class='litespeed-radio-row'>
     49                            <input type='radio' autocomplete='off' name='<?php echo $id; ?>' id='conf_<?php echo $id; ?>_<?php echo $k; ?>' value='<?php echo $k; ?>' <?php echo $checked; ?> />
     50                            <label for='conf_<?php echo $id; ?>_<?php echo $k; ?>'><?php echo $v; ?></label>
     51                        </div>
     52                    <?php endforeach; ?>
     53                    <div class="litespeed-desc">
     54                        <?php echo __('Determines how changes in product quantity and product stock status affect product pages and their associated category pages.', 'litespeed-cache'); ?>
     55                    </div>
     56                </td>
     57            </tr>
     58
     59            <tr>
     60                <th>
     61                    <?php $id = self::O_CART_VARY; ?>
     62                    <?php echo __('Vary for Mini Cart', 'litespeed-cache'); ?>
     63                </th>
     64                <td>
     65                    <?php
     66                    $conf = (int) apply_filters('litespeed_conf', $id);
     67                    $this->cls('Admin_Display')->build_switch($id); ?>
     68                    <div class="litespeed-desc">
     69                        <?php echo __('Generate a separate vary cache copy for the mini cart when the cart is not empty.', 'litespeed-cache'); ?>
     70                        <?php echo __('If your theme does not use JS to update the mini cart, you must enable this option to display the correct cart contents.', 'litespeed-cache'); ?>
     71                        <br /><?php Doc::notice_htaccess(); ?>
     72                    </div>
     73                </td>
     74            </tr>
     75
     76        </tbody>
     77    </table>
    2578</div>
    26 
    27 <table class="wp-list-table striped litespeed-table"><tbody>
    28     <tr>
    29         <th>
    30             <?php $id = self::O_UPDATE_INTERVAL; ?>
    31             <?php echo __( 'Product Update Interval', 'litespeed-cache' ); ?>
    32         </th>
    33         <td>
    34             <?php
    35             $options = array(
    36                 self::O_PQS_CS  => __( 'Purge product on changes to the quantity or stock status.', 'litespeed-cache' ) . ' ' . __( 'Purge categories only when stock status changes.', 'litespeed-cache' ),
    37                 self::O_PS_CS   => __( 'Purge product and categories only when the stock status changes.', 'litespeed-cache' ),
    38                 self::O_PS_CN   => __( 'Purge product only when the stock status changes.', 'litespeed-cache' ) . ' ' . __( 'Do not purge categories on changes to the quantity or stock status.', 'litespeed-cache' ),
    39                 self::O_PQS_CQS => __( 'Always purge both product and categories on changes to the quantity or stock status.', 'litespeed-cache' ),
    40             );
    41             $conf = (int) apply_filters( 'litespeed_conf', $id );
    42             foreach ( $options as $k => $v ) :
    43                 $checked = (int) $k === $conf ? ' checked ' : '';
    44             ?>
    45                 <?php do_action( 'litespeed_setting_enroll', $id ); ?>
    46                 <div class='litespeed-radio-row'>
    47                     <input type='radio' autocomplete='off' name='<?php echo $id; ?>' id='conf_<?php echo $id; ?>_<?php echo $k; ?>' value='<?php echo $k; ?>' <?php echo $checked; ?> />
    48                     <label for='conf_<?php echo $id; ?>_<?php echo $k; ?>'><?php echo $v; ?></label>
    49                 </div>
    50             <?php endforeach; ?>
    51             <div class="litespeed-desc">
    52                 <?php echo __( 'Determines how changes in product quantity and product stock status affect product pages and their associated category pages.', 'litespeed-cache' ); ?>
    53             </div>
    54         </td>
    55     </tr>
    56 
    57 </tbody></table>
    58 
    59 </div>
  • litespeed-cache/trunk/tpl/dash/dashboard.tpl.php

    r2928795 r2977143  
    607607            </div>
    608608
     609            <div class="postbox litespeed-postbox litespeed-postbox-quiccloud litespeed-bg-quic-cloud">
     610                <div class="inside litespeed-text-center">
     611                    <h3 class="litespeed-title">
     612                        QUIC.cloud
     613                        <a href="https://www.quic.cloud/quic-cloud-services-and-features/litespeed-cache-service/" class="litespeed-title-right-icon">Learn More</a>
     614                    </h3>
     615                    <p class="litespeed-top20 litespeed-text-bold litespeed-margin-bottom20">
     616                        <a href="https://www.quic.cloud/docs/onboarding/" class="">Try QUIC.cloud CDN!</a>
     617                    </p>
     618                    <p class="litespeed-margin-y5">
     619                        Best available WordPress performance
     620                    </p>
     621                    <p class="litespeed-margin-y5">
     622                        Globally fast TTFB, easy setup, and <a href="https://www.quic.cloud/quic-cloud-services-and-features/litespeed-cache-service/">more</a>!
     623                    </p>
     624                    <div class="litespeed-top10">
     625                        <img src="<?php echo LSWCP_PLUGIN_URL; ?>assets/img/quic-cloud-logo.svg" alt="QUIC.cloud" width="45%" height="auto">
     626                    </div>
     627                </div>
     628            </div>
     629
    609630        </div>
    610631
    611632    </div>
    612633
    613 
    614634</div>
  • litespeed-cache/trunk/tpl/page_optm/settings_html.tpl.php

    r2554181 r2977143  
    11<?php
     2
    23namespace LiteSpeed;
    3 defined( 'WPINC' ) || exit;
     4
     5defined('WPINC') || exit;
    46?>
    57
    68<h3 class="litespeed-title-short">
    7     <?php echo __( 'HTML Settings', 'litespeed-cache' ); ?>
    8     <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#html-settings-tab' ); ?>
     9    <?php echo __('HTML Settings', 'litespeed-cache'); ?>
     10    <?php Doc::learn_more('https://docs.litespeedtech.com/lscache/lscwp/pageopt/#html-settings-tab'); ?>
    911</h3>
    1012
    11 <table class="wp-list-table striped litespeed-table"><tbody>
    12     <tr>
    13         <th>
    14             <?php $id = Base::O_OPTM_HTML_MIN; ?>
    15             <?php $this->title( $id ); ?>
    16         </th>
    17         <td>
    18             <?php $this->build_switch( $id ); ?>
    19             <div class="litespeed-desc">
    20                 <?php echo __( 'Minify HTML content.', 'litespeed-cache' ); ?>
    21             </div>
    22         </td>
    23     </tr>
     13<table class="wp-list-table striped litespeed-table">
     14    <tbody>
     15        <tr>
     16            <th>
     17                <?php $id = Base::O_OPTM_HTML_MIN; ?>
     18                <?php $this->title($id); ?>
     19            </th>
     20            <td>
     21                <?php $this->build_switch($id); ?>
     22                <div class="litespeed-desc">
     23                    <?php echo __('Minify HTML content.', 'litespeed-cache'); ?>
     24                </div>
     25            </td>
     26        </tr>
    2427
    25     <tr>
    26         <th>
    27             <?php $id = Base::O_OPTM_DNS_PREFETCH; ?>
    28             <?php $this->title( $id ); ?>
    29         </th>
    30         <td>
    31             <?php $this->build_textarea( $id ); ?>
    32             <div class="litespeed-desc">
    33                 <?php echo __( 'Prefetching DNS can reduce latency for visitors.', 'litespeed-cache' ); ?>
    34                 <?php echo __( 'For example', 'litespeed-cache' ); ?>: <code>//www.example.com</code>
    35                 <?php Doc::one_per_line(); ?>
    36                 <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#dns-prefetch' ); ?>
    37             </div>
    38         </td>
    39     </tr>
     28        <tr>
     29            <th>
     30                <?php $id = Base::O_OPTM_DNS_PREFETCH; ?>
     31                <?php $this->title($id); ?>
     32            </th>
     33            <td>
     34                <?php $this->build_textarea($id); ?>
     35                <div class="litespeed-desc">
     36                    <?php echo __('Prefetching DNS can reduce latency for visitors.', 'litespeed-cache'); ?>
     37                    <?php echo __('For example', 'litespeed-cache'); ?>: <code>//www.example.com</code>
     38                    <?php Doc::one_per_line(); ?>
     39                    <?php Doc::learn_more('https://docs.litespeedtech.com/lscache/lscwp/pageopt/#dns-prefetch'); ?>
     40                </div>
     41            </td>
     42        </tr>
    4043
    41     <tr>
    42         <th>
    43             <?php $id = Base::O_OPTM_DNS_PREFETCH_CTRL; ?>
    44             <?php $this->title( $id ); ?>
    45         </th>
    46         <td>
    47             <?php $this->build_switch( $id ); ?>
    48             <div class="litespeed-desc">
    49                 <?php echo __( 'Automatically enable DNS prefetching for all URLs in the document, including images, CSS, JavaScript, and so forth.', 'litespeed-cache' ); ?>
    50                 <?php echo __( 'This can improve the page loading speed.', 'litespeed-cache' ); ?>
    51                 <?php Doc::learn_more( 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control' ); ?>
    52             </div>
    53         </td>
    54     </tr>
     44        <tr>
     45            <th>
     46                <?php $id = Base::O_OPTM_DNS_PREFETCH_CTRL; ?>
     47                <?php $this->title($id); ?>
     48            </th>
     49            <td>
     50                <?php $this->build_switch($id); ?>
     51                <div class="litespeed-desc">
     52                    <?php echo __('Automatically enable DNS prefetching for all URLs in the document, including images, CSS, JavaScript, and so forth.', 'litespeed-cache'); ?>
     53                    <?php echo __('This can improve the page loading speed.', 'litespeed-cache'); ?>
     54                    <?php Doc::learn_more('https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control'); ?>
     55                </div>
     56            </td>
     57        </tr>
    5558
    56     <tr>
    57         <th>
    58             <?php $id = Base::O_OPTM_HTML_LAZY; ?>
    59             <?php $this->title( $id ); ?>
    60         </th>
    61         <td>
    62             <?php $this->build_textarea( $id ); ?>
    63             <div class="litespeed-desc">
    64                 <?php echo __( 'Delay rendering off-screen HTML elements by its selector.', 'litespeed-cache' ); ?>
    65                 <?php Doc::one_per_line(); ?>
    66                 <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#html-lazyload-selectors' ); ?>
    67             </div>
    68         </td>
    69     </tr>
     59        <tr>
     60            <th>
     61                <?php $id = Base::O_OPTM_DNS_PRECONNECT; ?>
     62                <?php $this->title($id); ?>
     63            </th>
     64            <td>
     65                <?php $this->build_textarea($id); ?>
     66                <div class="litespeed-desc">
     67                    <?php echo __('Preconnecting speeds up future loads from a given origin.', 'litespeed-cache'); ?>
     68                    <?php echo __('For example', 'litespeed-cache'); ?>: <code>https://example.com</code>
     69                    <?php Doc::one_per_line(); ?>
     70                    <?php Doc::learn_more('https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preconnect'); ?>
     71                </div>
     72            </td>
     73        </tr>
    7074
    71     <tr>
    72         <th>
    73             <?php $id = Base::O_OPTM_QS_RM; ?>
    74             <?php $this->title( $id ); ?>
    75         </th>
    76         <td>
    77             <?php $this->build_switch( $id ); ?>
    78             <div class="litespeed-desc">
    79                 <?php echo __( 'Remove query strings from internal static resources.', 'litespeed-cache' ); ?>
    80                 <br /><font class="litespeed-warning">
    81                     ⚠️
    82                     <?php echo __( 'Google reCAPTCHA will be bypassed automatically.', 'litespeed-cache' ); ?>
    83                 </font>
    84                 <br /><font class="litespeed-success">
    85                     <?php echo __( 'API', 'litespeed-cache' ); ?>:
    86                     <?php echo sprintf( __( 'Append query string %s to the resources to bypass this action.', 'litespeed-cache' ), '<code>&_litespeed_rm_qs=0</code>' ); ?>
    87                 </font>
    88             </div>
    89         </td>
    90     </tr>
     75        <tr>
     76            <th>
     77                <?php $id = Base::O_OPTM_HTML_LAZY; ?>
     78                <?php $this->title($id); ?>
     79            </th>
     80            <td>
     81                <?php $this->build_textarea($id); ?>
     82                <div class="litespeed-desc">
     83                    <?php echo __('Delay rendering off-screen HTML elements by its selector.', 'litespeed-cache'); ?>
     84                    <?php Doc::one_per_line(); ?>
     85                    <?php Doc::learn_more('https://docs.litespeedtech.com/lscache/lscwp/pageopt/#html-lazyload-selectors'); ?>
     86                </div>
     87            </td>
     88        </tr>
    9189
    92     <tr>
    93         <th>
    94             <?php $id = Base::O_OPTM_GGFONTS_ASYNC; ?>
    95             <?php $this->title( $id ); ?>
    96         </th>
    97         <td>
    98             <?php $this->build_switch( $id ); ?>
    99             <div class="litespeed-desc">
    100                 <?php echo __( 'Use Web Font Loader library to load Google Fonts asynchronously while leaving other CSS intact.', 'litespeed-cache' ); ?>
    101                 <?php echo __( 'This will also add a preconnect to Google Fonts to establish a connection earlier.', 'litespeed-cache' ); ?>
    102                 <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#load-google-fonts-asynchronously' ); ?>
    103             </div>
    104         </td>
    105     </tr>
     90        <tr>
     91            <th>
     92                <?php $id = Base::O_OPTM_QS_RM; ?>
     93                <?php $this->title($id); ?>
     94            </th>
     95            <td>
     96                <?php $this->build_switch($id); ?>
     97                <div class="litespeed-desc">
     98                    <?php echo __('Remove query strings from internal static resources.', 'litespeed-cache'); ?>
     99                    <br />
     100                    <font class="litespeed-warning">
     101                        ⚠️
     102                        <?php echo __('Google reCAPTCHA will be bypassed automatically.', 'litespeed-cache'); ?>
     103                    </font>
     104                    <br />
     105                    <font class="litespeed-success">
     106                        <?php echo __('API', 'litespeed-cache'); ?>:
     107                        <?php echo sprintf(__('Append query string %s to the resources to bypass this action.', 'litespeed-cache'), '<code>&_litespeed_rm_qs=0</code>'); ?>
     108                    </font>
     109                </div>
     110            </td>
     111        </tr>
    106112
    107     <tr>
    108         <th>
    109             <?php $id = Base::O_OPTM_GGFONTS_RM; ?>
    110             <?php $this->title( $id ); ?>
    111         </th>
    112         <td>
    113             <?php $this->build_switch( $id ); ?>
    114             <div class="litespeed-desc">
    115                 <?php echo __( 'Prevent Google Fonts from loading on all pages.', 'litespeed-cache' ); ?>
    116             </div>
    117         </td>
    118     </tr>
     113        <tr>
     114            <th>
     115                <?php $id = Base::O_OPTM_GGFONTS_ASYNC; ?>
     116                <?php $this->title($id); ?>
     117            </th>
     118            <td>
     119                <?php $this->build_switch($id); ?>
     120                <div class="litespeed-desc">
     121                    <?php echo __('Use Web Font Loader library to load Google Fonts asynchronously while leaving other CSS intact.', 'litespeed-cache'); ?>
     122                    <?php echo __('This will also add a preconnect to Google Fonts to establish a connection earlier.', 'litespeed-cache'); ?>
     123                    <?php Doc::learn_more('https://docs.litespeedtech.com/lscache/lscwp/pageopt/#load-google-fonts-asynchronously'); ?>
     124                </div>
     125            </td>
     126        </tr>
    119127
    120     <tr>
    121         <th>
    122             <?php $id = Base::O_OPTM_EMOJI_RM; ?>
    123             <?php $this->title( $id ); ?>
    124         </th>
    125         <td>
    126             <?php $this->build_switch( $id ); ?>
    127             <div class="litespeed-desc">
    128                 <?php echo __( 'Stop loading WordPress.org emoji. Browser default emoji will be displayed instead.', 'litespeed-cache' ); ?>
    129                 <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ); ?>
    130             </div>
    131         </td>
    132     </tr>
     128        <tr>
     129            <th>
     130                <?php $id = Base::O_OPTM_GGFONTS_RM; ?>
     131                <?php $this->title($id); ?>
     132            </th>
     133            <td>
     134                <?php $this->build_switch($id); ?>
     135                <div class="litespeed-desc">
     136                    <?php echo __('Prevent Google Fonts from loading on all pages.', 'litespeed-cache'); ?>
     137                </div>
     138            </td>
     139        </tr>
    133140
    134     <tr>
    135         <th>
    136             <?php $id = Base::O_OPTM_NOSCRIPT_RM; ?>
    137             <?php $this->title( $id ); ?>
    138         </th>
    139         <td>
    140             <?php $this->build_switch( $id ); ?>
    141             <div class="litespeed-desc">
    142                 <?php echo sprintf( __( 'This option will remove all %s tags from HTML.', 'litespeed-cache' ), '<code>&lt;noscript&gt;</code>' ); ?>
    143                 <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#remove-noscript-tags' ); ?>
    144             </div>
    145         </td>
    146     </tr>
     141        <tr>
     142            <th>
     143                <?php $id = Base::O_OPTM_EMOJI_RM; ?>
     144                <?php $this->title($id); ?>
     145            </th>
     146            <td>
     147                <?php $this->build_switch($id); ?>
     148                <div class="litespeed-desc">
     149                    <?php echo __('Stop loading WordPress.org emoji. Browser default emoji will be displayed instead.', 'litespeed-cache'); ?>
     150                    <?php echo __('This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache'); ?>
     151                </div>
     152            </td>
     153        </tr>
    147154
    148 </tbody></table>
     155        <tr>
     156            <th>
     157                <?php $id = Base::O_OPTM_NOSCRIPT_RM; ?>
     158                <?php $this->title($id); ?>
     159            </th>
     160            <td>
     161                <?php $this->build_switch($id); ?>
     162                <div class="litespeed-desc">
     163                    <?php echo sprintf(__('This option will remove all %s tags from HTML.', 'litespeed-cache'), '<code>&lt;noscript&gt;</code>'); ?>
     164                    <?php Doc::learn_more('https://docs.litespeedtech.com/lscache/lscwp/pageopt/#remove-noscript-tags'); ?>
     165                </div>
     166            </td>
     167        </tr>
     168
     169    </tbody>
     170</table>
Note: See TracChangeset for help on using the changeset viewer.