Skip to content

Instantly share code, notes, and snippets.

@Alimir
Last active December 12, 2020 20:32
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 Alimir/9baaf3434ca4963c4c1e74b363f40f37 to your computer and use it in GitHub Desktop.
Save Alimir/9baaf3434ca4963c4c1e74b363f40f37 to your computer and use it in GitHub Desktop.
wp ulike midnight restrict
<?php
function wp_ulike_pro_custom_stop_listener(){
date_default_timezone_set('Europe/Berlin');
$current_time = date("h:i a");
$begin = "09:00 am";
$end = "11:00 pm";
$date1 = DateTime::createFromFormat('H:i a', $current_time);
$date2 = DateTime::createFromFormat('H:i a', $begin);
$date3 = DateTime::createFromFormat('H:i a', $end);
if ( $date1 > $date2 && $date1 < $date3 ) {
throw new \Exception( WP_Ulike_Pro_Options::getNoticeMessage( 'invalidtime', 'sample permission message' ) );
}
}
add_action( 'wp_ulike_before_process', 'wp_ulike_pro_custom_stop_listener' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment