Skip to content

Instantly share code, notes, and snippets.

@marklchaves
Forked from waltermesser/schedule-a-popup.php
Last active September 8, 2021 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marklchaves/da70d3af15c3bd372788a029562fa38c to your computer and use it in GitHub Desktop.
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.
<?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