WordPress.org

Ready to get started?Download WordPress

Forums

Displet Pop
[resolved] Pop Up Showing Multiple Times (5 posts)

  1. savingsavvy
    Member
    Posted 1 year ago #

    I have the setting set to show pop up after 15 seconds after visiting 2 pages with a cookie of 3 days, however, it keeps popping up numerous times in the same day.

    http://www.simplesavingsavvy.net

    http://wordpress.org/extend/plugins/displet-pop/

  2. displetdev
    Member
    Plugin Author

    Posted 1 year ago #

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

  3. colinwiseman
    Member
    Posted 1 year ago #

    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 :D 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 :D 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.

  4. displetdev
    Member
    Plugin Author

    Posted 12 months ago #

    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.

  5. janjan32
    Member
    Posted 4 months ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags