Skip to content

Instantly share code, notes, and snippets.

@kreamweb
Created February 21, 2017 11:16
Show Gist options
  • Select an option

  • Save kreamweb/04ff732a4bf8ce027c8a87ea8c211a3e to your computer and use it in GitHub Desktop.

Select an option

Save kreamweb/04ff732a4bf8ce027c8a87ea8c211a3e to your computer and use it in GitHub 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment