Skip to content

Instantly share code, notes, and snippets.

@Alimir

Alimir/wp-ulike.php

Last active Dec 12, 2020
Embed
What would you like to do?
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