Skip to content

Instantly share code, notes, and snippets.

@Alimir
Created April 30, 2021 10:45
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/755db5680a464fc6469c377016cf9531 to your computer and use it in GitHub Desktop.
Save Alimir/755db5680a464fc6469c377016cf9531 to your computer and use it in GitHub Desktop.
Restrict like/dislike based on period time for 10 days after post publish
<?php
/**
* Restrict period time for 10 days after post publish
*
* @param integer $id
* @param string $type
* @return void
*/
function wp_ulike_pro_custom_restrict_period_time( $id, $type ){
if( ! empty($id ) && $type == 'post' ){
if( get_post_type( $id ) && strtotime(' +10 day') > get_post_time( 'U', false, $id ) ){
throw new \Exception( 'Time over message!' );
}
}
}
add_action( 'wp_ulike_before_process', 'wp_ulike_pro_custom_restrict_period_time', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment