• Resolved advwebmaster777

    (@advwebmaster777)


    I created a shortcode like this.

    <?php
    
    function shortcode_today() {
         return date_i18n("Y/n/j(D) G:i s");
    }
    add_shortcode('today_date', 'shortcode_today');

    When pasted into the post, [today_date] works fine and displays the current time.

    but,
    [esi today_date]
    [esi today_date ttl=”0″]
    [esi today_date cache=”private” ttl=”0″]
    [esi today_date ttl=”1″]
    None of them work.

    @qtwrk answered on the forum,

    function test_shortcode($atts) {
         $atts = shortcode_atts(
             array(
                 'show_date' => 'false',
             ),
             $atts,
             'test_sc'
         );
    
         if ($atts['show_date'] === 'true') {
             $current_date = date('Y-m-d H:i:s');
             $message .= ' generation time: ' . $current_date . '.';
         }
    
         return $message;
    }
    add_shortcode('test_sc', 'test_shortcode');
    
    

    and

    <?php
    require( './wp-load.php' );
    echo do_shortcode('[esi test_sc show_date="true" ttl="0"]');

    worked. ESI itself seems to work.

    How should I debug it?

    I’m using Fastcomet server litespeed enterprise.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support qtwrk

    (@qtwrk)

    your code actually worked on my site

    https://prnt.sc/zp8Q_BsAP45D

    please try grab the plugin debug log , see what exactly going on with that shortcode

    Thread Starter advwebmaster777

    (@advwebmaster777)

    Hi,

    Report number: HWSKTHHP

    Report date: 03/16/2024 12:26:03

    The log is below.

    I replaced my real domain url to ‘mysite’.

    03/16/24 12:23:45.770 [180.15.71.129:38445 1 lsV] 💓 ------GET HTTP/1.1 (HTTPS) /
    03/16/24 12:23:45.770 [180.15.71.129:38445 1 lsV] Query String: lsesi=esi&_control=public%2Cno-vary&esi=eyIwIjoidG9kYXlfZGF0ZSIsInR0bCI6IjAifQ%3D%3D&_hash=b7a097962cb2fcf9e9d7051e99a5e4ae
    03/16/24 12:23:45.770 [180.15.71.129:38445 1 lsV] HTTP_REFERER: https://mysite/wp-admin/post.php?post=1863&action=edit
    03/16/24 12:23:45.770 [180.15.71.129:38445 1 lsV] Cookie _lscache_vary: admin_bar:1;guest_mode:1;logged-in:1;role:99
    03/16/24 12:23:45.770 [180.15.71.129:38445 1 lsV] ESI_CONTENT_TYPE: text/html; charset=UTF-8
    03/16/24 12:23:45.775 [180.15.71.129:38445 1 lsV] [ESI] Overwrite wp_create_nonce()
    03/16/24 12:23:45.796 [180.15.71.129:38445 1 lsV] ⏺ ESI req
    03/16/24 12:23:45.797 [180.15.71.129:38445 1 lsV] [ESI] ESI_REFERER: /1863
    03/16/24 12:23:45.797 [180.15.71.129:38445 1 lsV] ⏺ overwrite REQUEST_URI to ESI_REFERER [from] /?lsesi=esi&_control=public%2Cno-vary&esi=eyIwIjoidG9kYXlfZGF0ZSIsInR0bCI6IjAifQ%3D%3D&_hash=b7a097962cb2fcf9e9d7051e99a5e4ae [to] /1863
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] stats_nonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] subscribe_nonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] wp_rest
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] cmreg_registration_nonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] role_nonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] wdap-call-nonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] seopress_cookies_user_consent_nonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] swpmtxnonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] wdt.*
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] _vcnonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] data-vc-public-nonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] rating_nonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] timeline_nonce
    03/16/24 12:23:45.798 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] blog_feed_nonce
    03/16/24 12:23:45.799 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] wsf_post
    03/16/24 12:23:45.799 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] edd\-.*
    03/16/24 12:23:45.799 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] edd_.*
    03/16/24 12:23:45.799 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] wpmenucart
    03/16/24 12:23:45.799 [180.15.71.129:38445 1 lsV] [ESI] Appended nonce action to nonce list [action] woocommerce-login
    03/16/24 12:23:45.799 [180.15.71.129:38445 1 lsV] [Router] get_role: administrator
    03/16/24 12:23:45.817 [180.15.71.129:38445 1 lsV] ⏺ 💕 [BLock_ID] nonce [wrapper] wp_create_nonce wp_rest [Control]
    03/16/24 12:23:45.817 [180.15.71.129:38445 1 lsV] ⏺ Preserved to 3ca36566cb600e301da9bf67585c1d33
    03/16/24 12:23:45.818 [180.15.71.129:38445 1 lsV] ⏺ 💕 [BLock_ID] nonce [wrapper] wp_create_nonce wp_rest [Control]
    03/16/24 12:23:45.819 [180.15.71.129:38445 1 lsV] ⏺ Preserved to 3ca36566cb600e301da9bf67585c1d33
    03/16/24 12:23:45.843 [180.15.71.129:38445 1 lsV] 💰 [Tag] Add --- HTTP.200
    03/16/24 12:23:45.855 [180.15.71.129:38445 1 lsV] [Ctrl] X Cache_control init on
    03/16/24 12:23:45.863 [180.15.71.129:38445 1 lsV] ⏺ calling ESI template
    03/16/24 12:23:45.863 [180.15.71.129:38445 1 lsV] [ESI] ❌ Failed to validate _hash
    03/16/24 12:23:45.864 [180.15.71.129:38445 1 lsV] 💰 X-LiteSpeed-Cache-Control: public,max-age=604800,esi=on
    03/16/24 12:23:45.864 [180.15.71.129:38445 1 lsV] [Vary] uid: 1
    03/16/24 12:23:45.864 [180.15.71.129:38445 1 lsV] 💰 X-LiteSpeed-Tag: c8f_HTTP.200,c8f_
    03/16/24 12:23:45.864 [180.15.71.129:38445 1 lsV] [Core] run hook litespeed_buffer_finalize
    03/16/24 12:23:45.864 [180.15.71.129:38445 1 lsV] [ESI] replacing preserved blocks --- 3ca36566cb600e301da9bf67585c1d33
    03/16/24 12:23:45.864 [180.15.71.129:38445 1 lsV] [Core] ESI Start 👇
    03/16/24 12:23:45.864 [180.15.71.129:38445 1 lsV]
    <!-- Block cached by LiteSpeed Cache 6.1 on 2024-03-16 12:23:45 -->
    <!-- X-LiteSpeed-Cache-Control: public,max-age=604800,esi=on -->
    <!-- Full varies: admin_bar:1;guest_mode:1;logged-in:1;role:99 -->
    <!-- X-LiteSpeed-Tag: c8f_HTTP.200,c8f_ -->
    03/16/24 12:23:45.865 [180.15.71.129:38445 1 lsV] [Core] ESI End 👆
    03/16/24 12:23:45.865 [180.15.71.129:38445 1 lsV] Response headers --- array (
    0 => 'X-Powered-By: PHP/8.2.16',
    1 => 'Expires: Wed, 11 Jan 1984 05:00:00 GMT',
    2 => 'Cache-Control: no-cache, must-revalidate, max-age=0, no-store, private',
    3 => 'Content-Type: text/html; charset=UTF-8',
    4 => 'X-Pingback: https://mysite/xmlrpc.php',
    5 => 'Link: <https://mysite/wp-json/>; rel="https://api.w.org/"',
    6 => 'Link: <https://mysite/wp-json/wp/v2/posts/1863>; rel="alternate"; type="application/json"',
    7 => 'Link: <https://mysite/?p=1863>; rel=shortlink',
    8 => 'X-LiteSpeed-Cache-Control: public,max-age=604800,esi=on',
    9 => 'X-LiteSpeed-Tag: c8f_HTTP.200,c8f_',
    )
    03/16/24 12:23:45.865 [180.15.71.129:38445 1 lsV] End response

    Plugin Support qtwrk

    (@qtwrk)

    this is nonce esi , you should see something like , with your example shortcode from my site , by the main request URL log , not esi log

    03/16/24 12:34:16.435 [47.76.xx.xx:40122 1 TIY] [ESI] param --- array (
    0 => 'today_date',
    'ttl' => '0',
    )
    03/16/24 12:34:16.435 [47.76.xx.xx:40122 1 TIY] [ESI] md5_string=esipublic,no-varyeyIwIjoidG9kYXlfZGF0ZSIsInR0bCI6IjAifQ==
    03/16/24 12:34:16.435 [47.76.xx.xx:40122 1 TIY] ⏺ 💕 [BLock_ID] esi [wrapper] esi-shortcode [Control] public,no-vary
    03/16/24 12:34:16.435 [47.76.xx.xx:40122 1 TIY] ⏺ <!-- lscwp esi-shortcode --><esi:include src='/?lsesi=esi&_control=public%2Cno-vary&esi=eyIwIjoidG9kYXlfZGF0ZSIsInR0bCI6IjAifQ%3D%3D&_hash=2da2e1c8303ec3a525f3e4e90f621527' cache-control='public,no-vary' /><!-- lscwp esi-shortcode esi end -->
    Thread Starter advwebmaster777

    (@advwebmaster777)

    I cannot find the string “today_date” on the log page.

    Is the page I see correct?

    https://d.pr/i/TDkIWh

    I selected Debug Level Advanced.

    https://d.pr/i/oZEMde

    Plugin Support qtwrk

    (@qtwrk)

    try add test_log and lsesi into the debug include uri

    then purge all , clean existing log , open your page with /?test_log , refresh the log viewer

    Thread Starter advwebmaster777

    (@advwebmaster777)

    Thank you, the log appeared.

    03/17/24 10:49:28.194 [180.15.71.129:37830 1 VIj] [ESI] param --- array (
    0 => 'today_date',
    'ttl' => '0',
    )
    03/17/24 10:49:28.194 [180.15.71.129:37830 1 VIj] [ESI] md5_string=esipublic,no-varyeyIwIjoidG9kYXlfZGF0ZSIsInR0bCI6IjAifQ==
    03/17/24 10:49:28.194 [180.15.71.129:37830 1 VIj] ⏺ 💕 [BLock_ID] esi [wrapper] esi-shortcode [Control] public,no-vary
    03/17/24 10:49:28.194 [180.15.71.129:37830 1 VIj] ⏺ <!-- lscwp esi-shortcode --><esi:include src='/?lsesi=esi&_control=public%2Cno-vary&esi=eyIwIjoidG9kYXlfZGF0ZSIsInR0bCI6IjAifQ%3D%3D&_hash=b7a097962cb2fcf9e9d7051e99a5e4ae' cache-control='public,no-vary' /><!-- lscwp esi-shortcode esi end -->
    03/17/24 10:49:28.199 [180.15.71.129:37830 1 VIj] GUI clean wrapper 1 begin
    03/17/24 10:49:28.200 [180.15.71.129:37830 1 VIj] GUI clean wrapper 1 end
    Plugin Support qtwrk

    (@qtwrk)

    please share me the full log on main request and ESI request.

    you can use something like https://pastebin.ubuntu.com/

    Thread Starter advwebmaster777

    (@advwebmaster777)

    Plugin Support qtwrk

    (@qtwrk)

    /?lsesi=esi&_control=public%2Cno-vary&esi=eyIwIjoidG9kYXlfZGF0ZSIsInR0bCI6IjAifQ%3D%3D&_hash=b7a097962cb2fcf9e9d7051e99a5e4ae

    what does it show if you open this URI ?

    Thread Starter advwebmaster777

    (@advwebmaster777)

    It will display the current time like this.

    2024/3/18(Mon) 13:36 32
    Plugin Support qtwrk

    (@qtwrk)

    now that is weird , what do you see in HTML source code around the section where it should display the shortcode ?

    also please try with wordpress 2021 theme , see how it goes

    Thread Starter advwebmaster777

    (@advwebmaster777)

    Thank you, it appeared when I set it to the 2021 theme. Until now, I have been using representative block themes like Ollie or 2024, but it might not have been good for my environment. I will close the ticket, thank you very much.

    Plugin Support qtwrk

    (@qtwrk)

    recently we have found a bug with esi that shortcode works for theme like 2021, but not working on newer ones like 2023 or 2024 , we are working on fix

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.