WordPress.org

Support

Support » Plugins and Hacks » Displet Pop » [Resolved] Pop Up Showing Multiple Times

[Resolved] Pop Up Showing Multiple Times

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Displet

    @displetdev

    You either have your settings wrong, there’s a conflict with another plugin, or your browser’s cache is turned off.

    Hello. I was getting this same problem today with the popup showing multiple times. I even rewrote your code to try and find out why :

    var show_pop_up = false;
    	if('<?php echo get_option("displetpop_testmode"); ?>' == '1')
    	{
    		// we are in test mode.  we want to show popup no matter what;
    		show_pop_up = true;
    
    	}
    	else
    	{
    		// if the cookie has not been set let's go and check if we are to show it
    		if( $.cookie('displetpop_recentpop') != 'yes' && <?php echo $_SESSION["views"]; ?> >= <?php echo get_option("displetpop_pageviews"); ?>)
    		{
    
    			// cookie not set but the user has seen enough pages
    
    			// move the below logic into this "if" statement as we only need to run it, if the popup hasn't already shown
    			var displetpoppathhome = '<?php echo get_option('displetpop_homepage_path'); ?>';
    			var displetpoppath1 = '<?php echo get_option('displetpop_path'); ?>';
    			var displetpoppath2 = '<?php echo get_option('displetpop_path2'); ?>';
    			var displetpoppath3 = '<?php echo get_option('displetpop_path3'); ?>';
    
    			if(displetpoppathhome == '' &&
    				displetpoppath1 == '' &&
    				displetpoppath2 == '' &&
    				displetpoppath3 == '')
    			{
    				show_pop_up = true; //  show pop up as admin says 'Leave blank to apply to all pages & posts'
    			}
    
    			if (displetpoppathhome == '1'){
    				if('<?php echo is_front_page(); ?>' == '1') {
    					show_pop_up = true; // we want to show the popup on the homepage, and we are on the homepage
    				}
    			}
    			if (displetpoppath1 != ''){
    				if(window.location.href.indexOf(displetpoppath1) > -1) {
    					show_pop_up = true;
    				}
    			}
    			if (displetpoppath2 != ''){
    				if(window.location.href.indexOf(displetpoppath2) > -1) {
    					show_pop_up = true;
    				}
    			}
    			if (displetpoppath3 != ''){
    				if(window.location.href.indexOf(displetpoppath3) > -1) {
    					show_pop_up = true;
    				}
    			}
    
    			// this logic '<?php echo current_user_can("manage_options"); ?>' == '1'
    			// To be honest I don't know what his is doing so removed it in my version of your code.
    		}
    	}
    
    	if (show_pop_up){
    		window.setTimeout(displetPop, <?php echo 1000*get_option('displetpop_seconds'); ?>);
    	}

    That code works. But it turns out that I didn’t need to rewrite the code 😀 You were overwriting the cookie in the if statement. You had

    if ((($.cookie('displetpop_recentpop', {path:'/'}) != 'yes'

    which would always be true thus the popup would always appear. My code above is slightly better (cause I have a big head) as it doesn’t need to do a lot of the logic all the time, and is easier to read 😀 But changing the if statement to

    if ((($.cookie('displetpop_recentpop') != 'yes'

    would also make the pop not appear more than once in the cookie life time.

    Plugin Author Displet

    @displetdev

    Hi guys

    I’m not able to replicate the issue, but suspect that it is server-specific and related to the jQuery cookie script we are using. If you can link me to a site that has the plugin installed that’s having the error, I can check it out. http://www.simplesavingsavvy.net no longer has the plugin installed.

    colinwiseman – I’ve been wanting to re-write quite a few things about the plugin when I have the free time, and may decide to make the logic more readable at that time, but my priority will likely be to ditch the jQuery cookie script in favor of AJAXing the cookie in WP and additionally enqueueing the styles and namespacing/better organizing the PHP functions. FYI, current_user_can("manage_options") checks if the current user is an admin, so that test mode is only visible to the admin (i.e. if you’re still configuring the popup, you don’t want it to popup on every page load for your visitors, but you do for yourself), and if ($.cookie('displetpop_recentpop', {path:'/'}) != 'yes' does not set a cookie – the additional parameter specifies the path as this jQuery cookie plugin by default checks the path of the current page only and not the entire domain.

    janjan32

    @janjan32

    The popup always shows for me, I am trying to modify the code, but i’m not really a programmer….

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Pop Up Showing Multiple Times’ is closed to new replies.
Skip to toolbar