arie_cristianD

auto block post on premium-post category for 5 days

Aug 3rd, 2025
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1.  
  2. add_filter( 'jeg_metabox', 'j_override_paywall_block', 99, 2 );
  3.  
  4. function j_override_paywall_block( $default, $name ) {
  5.     if ( 'jnews_paywall_metabox.enable_premium_post' === $name ) {
  6.         if ( has_category( 'premium-post' ) && is_post_older_than_5_days() ) { /* change premium-post with your Premium Post category slug */
  7.             return true;
  8.         }
  9.     }
  10.     return $default;
  11. }
  12.  
  13. function is_post_older_than_5_days() {
  14.     $published_date = get_the_date( 'U', get_the_ID() );
  15.     $current_date   = current_time( 'timestamp' );
  16.     $diff_in_days   = ( $current_date - $published_date ) / DAY_IN_SECONDS;
  17.     return $diff_in_days > 5; /*  check if more than 5 day published */
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment