Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Popup Maker Plugin: A basic example of scheduling a popup to display during a certain timeframe.
<?php // Ignore this first line when copying to your child theme's functions.php file.
function schedule_my_popup( $is_loadable, $popup_id ) {
if( $popup_id == 14 ) { // Change to your popup ID.
date_default_timezone_set('Asia/Singapore'); // Change to your time zone.
$now = strtotime( 'now' );
$start = strtotime( 'September 8, 2021 12:00PM' ); // Change to your local start time.
$end = strtotime( 'September 8, 2021 2:00PM' ); // Change to your local end time.
$is_loadable = ( ( $now >= $start ) && ( $now <= $end ) ) ? 1 : 0;
}
return $is_loadable;
}
add_filter( 'pum_popup_is_loadable', 'schedule_my_popup', 2, 1000 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment