• Resolved hitty

    (@hitty)


    Hello.
    You have a great plugin. But there is 1 problem.

    On our site, using PHP, we determine the type of operating system. Then we write it on the button and give the corresponding link to download the product. If we use your plugin, it remembers the operating system once (for example, MacOS) and then if we go under Windows or Linux, the site still gives us MacOS. Tell me, are there caching settings for different operating systems or maybe another ways to avoid this problem?

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor Pete (a11n)

    (@dilirity)

    Hey!

    WP Super Cache has a feature called “dynamic caching”. You can find it under the “Advanced” section in the “Advanced” tab.

    So I imagine you could look into that to make the button a dynamic fragment. That should exclude it from the cache and show the correct button to people loading the page (depending on their OS).

    Thread Starter hitty

    (@hitty)

    Thank you very much for your answer.

    I set it up as in the example, but it only works when the cache is disabled (authorized on the site) or when the checkbox is checked “Late init”.
    The images show examples of authorized, incognito (with disabled “Late init” ), code.

    A Google search of this problem did not give an answer ((

    Tell me what I’m doing wrong?

    https://ibb.co/sF3HJHh
    https://ibb.co/k3XQgP8
    https://ibb.co/QFVpJBD
    https://ibb.co/wQrj4fj

    Plugin Contributor Pete (a11n)

    (@dilirity)

    Hey!

    The code you’ve provided in the screenshot should work! Though I see the button is in the top of the page – how are you adding it there? You should just be echoing your equivalent of DYNAMIC_CACHE_BUTTON_TAG that’s defined in the plugins directory of your WP Super Cache. As long as your code can find the string on the page, it should replace it with what’s necessary.

    Can you give me a screenshot of the settings above the advanced section? A note – you shouldn’t need late init for this to work.

    I tested this locally with the following script and the page gets cached, and the button text updates on each refresh (It’s in a separate file in wp-content/plugins/wp-super-cache/plugins/dynamic-button.php:

    <?php

    define( 'DYNAMIC_CACHE_BUTTON_TAG', '<span>OS BUTTON VERIFICATION</span>' );
    if ( '' !== DYNAMIC_CACHE_BUTTON_TAG ) {
    function dynamic_cache_button_tag_safety( $safety ) {
    return 1;
    }
    add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_cache_button_tag_safety' );

    function dynamic_cache_button_tag_filter( $cachedata ) {
    $button = '<button>Time now is ' . date( 'H:i:s' ) . '</button>';
    return str_replace( DYNAMIC_CACHE_BUTTON_TAG, $button, $cachedata );
    }
    add_cacheaction( 'wpsc_cachedata', 'dynamic_cache_button_tag_filter' );

    function dynamic_cache_button_tag_template_tag() {
    echo DYNAMIC_CACHE_BUTTON_TAG; // This is the template tag.
    }

    function dynamic_cache_button_tag_init() {
    add_action( 'wp_footer', 'dynamic_cache_button_tag_template_tag' );
    }
    add_cacheaction( 'add_cacheaction', 'dynamic_cache_button_tag_init' );
    }

    https://share.cleanshot.com/yz8JX472

    https://share.cleanshot.com/g9qmCKjV

    These are the settings I used – https://share.cleanshot.com/vGmCRMwZ

    • This reply was modified 2 months, 3 weeks ago by Pete (a11n). Reason: clarify super cache plugin's plugin
    • This reply was modified 2 months, 3 weeks ago by Pete (a11n). Reason: add screenshots
    Thread Starter hitty

    (@hitty)

    Thank you very much for your help.
    The problem is that the first time the page is loaded, the tag is replaced, and the second time, the old text appears again.
    I checked your code locally, and the same problem.
    If it’s not too much trouble, I can provide you with access to the control panel and FTP to your email.
    The site is corporate, and it is very important for them to implement this function.
    Thank you very much again.

    URL: https://dolphin-anty.site

    Screenshots:
    https://ibb.co/N76tx7R
    https://ibb.co/CpywdV3
    https://ibb.co/2P3RVV0
    https://ibb.co/cbFcyq4

    define( 'DYNAMIC_CACHE_TEST_TAG_DOLPHIN', '<span>OS BUTTON VERIFICATION</span>' ); // Change this to a secret placeholder tag.
    if ( '' !== DYNAMIC_CACHE_TEST_TAG_DOLPHIN ) {
    function dynamic_cache_button_os_test_safety( $safety ) {
    return 1;
    }
    add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_cache_button_os_test_safety' );

    function dynamic_cache_button_os_test_filter( $cachedata ) {
    $os = getOs();
    $replace = '<a href="/download/" class="btn btn--outline ms-lg-1 d-none d-lg-inline-block" title="Download for ' . $os[0] . '">';
    $replace .= ' Download for ' . $os[0];
    $replace .= '</a>';
    return str_replace( DYNAMIC_CACHE_TEST_TAG_DOLPHIN, $replace , $cachedata );
    }
    add_cacheaction( 'wpsc_cachedata', 'dynamic_cache_button_os_test_filter' );

    function dynamic_cache_button_os_test_template_tag() {
    echo DYNAMIC_CACHE_TEST_TAG_DOLPHIN; // This is the template tag.
    }

    function dynamic_cache_button_os_test_init() {
    add_action( 'wp_footer', 'dynamic_cache_button_os_test_template_tag' );
    }
    add_cacheaction( 'add_cacheaction', 'dynamic_cache_button_os_test_init' );
    }
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    @hitty

     Please don’t offer to send or post logon credentials on these forums: https://www.ads-software.com/support/guidelines#the-bad-stuff

    It is not OK to offer, enter, or send site credentials on these forums. Thanks for your cooperation.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    @dilirity

    I’ve deleted your offer to login to your user’s site. I’m am 100% sure you mean well but please never ask for credentials on these forums.

    Now for the why: The internet is a wonderful place full of very nice people and a few very bad ones. I’m sure everyone here is very nice however, by giving some ones keys to your house you are trusting they wont steal anything. Likewise the person who takes the keys is now responsible for the house FOREVER.

    If something was to go wrong, then you the author may well legally become liable for damages, which they would not normally have been as their software is provided without warranty.

    Please be aware that repeatedly asking for credentials will result in us escalating this to the plugins team.

    It’s never necessary to do that. Here’s why.

    There are many ways to get information you need and accessing the user’s site is not one of them. That’s going too far.

    • Ask for a link to the https://pastebin.com/ or https://gist.github.com log of the user’s web server error log.
    • Ask the user to create and post a link to their phpinfo(); output.
    • Ask the user to install the Health Check plugin and get the data that way.
    • Walk the user through enabling WP_DEBUG and how to log that output to a file and how to share that file.
    • Walk the user through basic troubleshooting steps such and disabling all other plugins, clear their cache and cookies and try again.
    • Ask the user for the step-by-step on how they can reproduce the problem.

    You get the idea.

    Volunteer support is not easy. But these forums need to a safe place for all users, experienced or new. Accessing their system that way is a short cut that will get you into real trouble in these forums.

    Plugin Contributor Pete (a11n)

    (@dilirity)

    Hey @sterndata!

    The way I asked for the credentials is a standard procedure for the way we offer support at Automattic. I’m not sure anything “bad” was done in the way I asked.

    Please correct me if I’m wrong.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    You may not discuss asking for credentials here.

    Thread Starter hitty

    (@hitty)

    @sterndata

    The process of credentials transfer was started by me, the owner of the site. We have already discussed everything, everything will be via a jetpack. Therefore, I do not see any point in discussing this issue of transfer in the future. Thanks.

    Plugin Contributor Pete (a11n)

    (@dilirity)

    For reference, the guidelines state:

    Posting or accepting offers or requests for login information to a site. While plugin and theme authors may ask for this on their own support systems, they may not do so on www.ads-software.com for liability reasons.

    So I did do bad. My bad.

    • This reply was modified 2 months, 3 weeks ago by Pete (a11n). Reason: wrong paragraph
    Thread Starter hitty

    (@hitty)

    @dilirity Hi. What we should to do next? I have already sent the details to Jetpack support but have not received any response yet.

    Plugin Support Stef (a11n)

    (@erania-pinnera)

    Hello @hitty,

    We have received your email, and the support team will get back to you as soon as possible.
    I am closing this thread for now.

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