-
-
Save marklchaves/da70d3af15c3bd372788a029562fa38c to your computer and use it in GitHub Desktop.
Popup Maker Plugin: A basic example of scheduling a popup to display during a certain timeframe.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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