Created
April 30, 2021 10:45
-
-
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
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 | |
/** | |
* 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