I made 2 tweaks to the code to accomplish what I needed. It might not be the cleanest solution, but it works for now.
In class.yith-newsletter-popup-frontend.php, I added the following bold code:
/**
* Constructor
*
* @return YITH_Newsletter_Popup_Frontend
* @since 1.0.0
*/
public function __construct( $version ) {
$this->version = $version;
global $yith_newsletter_popup_base;
$yith_newsletter_popup_base = “yith-newsletter-popup-” . basename( get_template_directory() ) . “-hide-popup-” . get_option(‘yith_newsletter_popup_cookie_var’);
if (
( ! yith_newsletter_popup_is_enabled())
||(isset($_COOKIE[$yith_newsletter_popup_base]))
||(isset($_COOKIE[‘visited’]))
// ||(wp_is_mobile())
) return $this;
add_action( ‘wp_enqueue_scripts’, array( $this, ‘newsletter_popup_in_place_inserter_master’), 99 );
add_action(‘wp_head’, array( $this, ‘newsletter_popup_style_to_the_head’));
add_action(‘init’, array( $this, ‘add_google_fonts’));
add_action(‘wp_footer’, array( $this, ‘newsletter_popup_in_place_inserter’), 999);
return $this;
}
This checks to see if a cookie named “visited” exists. If it does, then it hides the popup.
In yith-newsletter-popup.php, I added the bold code:
<?php
/**
* Newsletter Popup page
*
* @author Your Inspiration Themes
* @package YITH Newsletter Popup
* @version 1.0.0
*/
;?>
<!– yith-newsletter-popup –>
<?php
setcookie(‘visited’, true, time() + 3600 * 2); // Save a cookie for 2 hours
$yith_use_woocommerce = yit_is_woocommerce_active()
&& get_option(‘yith_newsletter_popup_woocommerce_integration’) == ‘1’
&& get_option(‘yith_newsletter_popup_woocommerce_product_id’);
if ( $yith_use_woocommerce ){
When the popup displays, it will set a cookie named visited. In this case I set it to 2 hours, but you can change it to whatever you need.
Now the popup will only display once every 2 hours, instead of on each pageview.
If there’s a better way to accomplish this, please let me know.