kreamweb
2/21/2017 - 11:16 AM

function to hide show popup in mobile / desktop

function to hide show popup in mobile / desktop

<?php


function ywpop_hide_popup(){

	if ( ! class_exists( 'YITH_Popup_Frontend' ) ) {
		return;
	}

	$current_popup = YITH_Popup_Frontend()->get_current_popup();

	//popup da nascondere in desktop
	$popups_hidden_mobile = array( 106, 105 ); //da personalizzare

	//popup da nascondere in desktop
	$popups_hidden_desktop = array( 106, 109 ); //da personalizzare

	if ( wp_is_mobile() && in_array( $current_popup, $popups_hidden_mobile ) ) {
		add_filter( 'enable_yit_popup', '__return_false' );
	}


	if ( ! wp_is_mobile() && in_array( $current_popup, $popups_hidden_desktop ) ) {
	
		add_filter( 'enable_yit_popup', '__return_false' );
	}
}

add_action( 'template_redirect', 'ywpop_hide_popup', 9);