[Hustle Pro] Hide shortcode text/button if popup module trigger isn't active

0

I have a popup module that is triggered off of a shortcode icon click. I have the popup to only trigger once per day. However, the shortcode/icon remains visible even if the popup trigger is disabled (eg. the visitor has already clicked to view the popup in a given day).

The reason I am going this route is because mobile exit intent popups are non existent so I decided a fixed email icon in the bottom right of the screen would be more successful/less annoying than triggering off of time or scroll %.

Support recommended a script to check if the module ID selector isn't :visible and then hide the shortcode/icon selector. This seemed to work initially. However, upon further testing, the script was hiding the shortcode/icon regardless of if the trigger is active or not.

  • Nithin Ramdas
    • Support Wizard

    Hi Brandon,

    I’m afraid, I’m not fully sure whether I understand the workflow you are currently utilising. Just to be sure, you are using the “Click“Pop-up Triggers with the following example shortcode:

    [wd_hustle id='popup-one' type='popup']Click here[/wd_hustle]

    And the shortcode should be hidden once it’s triggered for a day etc, right?

    Looking forward to your response, so that I could bring this into our team’s attention for a feature request. Have a nice day ahead. :slight_smile:

    Regards,

    Nithin

  • Brandon
    • WPMU DEV Initiate

    Hi Nithin,

    You are correct. I am using the “Click” Pop-up trigger with the shortcode but instead of “Click here” I have an email icon button. If the pop-up is set to only show once per X days (I have it set to once per day) the text/button continues to show even though the click pop up trigger is no longer active.

    I have a support ticket open but I figured this would be a good feature to have built into the plugin. The text/button shouldn’t show if the popup trigger is not active.

    Thanks!

  • Brandon
    • WPMU DEV Initiate

    Dev support has helped to achieve this functionality on a per module basis. They were able to tie it into the cookies set by the “no longer show this popup across the site for 1 day” setting. See the response below:

    I’ve made some changes to the code in the functions.php file.

    The code you’ll find now will be like so:

    add_action(
    'wp_footer',
    function() {
    ?>
    <script>
    ( function( $ ) {
    function wpmudev_sls_getCookie( cname ) {
    var name = cname + '=',
    decodedCookie = decodeURIComponent(document.cookie),
    ca = decodedCookie.split( ';' );

    for( var i = 0; i < ca.length; i++ ) {
    var c = ca;

    while ( c.charAt( 0 ) == ' ' ) {
    c = c.substring( 1 );
    }

    if ( c.indexOf( name ) == 0 ) {
    return c.substring( name.length, c.length );
    }
    }

    return '';
    }

    function wpmudev_sls_checkCookie() {
    var popupCookie = wpmudev_sls_getCookie( 'inc_optin_popup_long_hidden-11' );

    if ( popupCookie != '' ) {
    $( '.hustle_module_shortcode_trigger.hustle_module_11').css( 'display', 'none' );
    }
    }

    wpmudev_sls_checkCookie();
    } ( jQuery ) )
    </script>
    <?php
    },
    999
    );

    Everything is about the popup with id 11, as that’s the one that is triggered by the button. As mentioned above the button will be visible during the 1st visit of the site but on a refresh / re-visit it will be hidden until the timer passes.

    So if you find this to be useful for your own use case, you will need to change the module IDs to your own module ID.

    Since this is how the shortcode button trigger should operate, I would love to see this functionality built into the plugin. From a UX perspective, the button should not be visible if the popup trigger is no longer active.

    Thank you for your hard work support!

  • Adam
    • Support Gorilla

    Hi Brandon

    I hope you’re fine today!

    I can tell you that we already have some related improvements to how the “trigger elements” are handled on our to do list. We’re going to make it possible to e.g. “automatically” show trigger elements only there where they are actually usable (so only on posts/pages that are allowed in display conditions – even if the element/shortocode itself is added “everywhere) – so that’s the main one. But we’re also already looking into integrating the “hide trigger” feature discussed in this ticket.

    While I don’t have an ETA, I hope that it’s still a good news for you :slight_smile:

    Best regards,

    Adam