Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: close_comments_for_post_types

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
3009           return $posts;
3010
3011      /**
3012       * Filter the list of post types to automatically close comments for.
3013       *
3014       * @since 3.2.0
3015       *
3016       * @param array $post_types An array of registered post types. Default array with 'post'.
3017       */
3018      $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
3019      if ( ! in_array( $posts[0]->post_type, $post_types ) )
3020           return $posts;
3021
3022      $days_old = (int) get_option( 'close_comments_days_old' );
3023      if ( ! $days_old )
3024           return $posts;
3025
3026      if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
3027           $posts[0]->comment_status = 'closed';
 
Line Code
3049           return $open;
3050
3051      $days_old = (int) get_option('close_comments_days_old');
3052      if ( !$days_old )
3053           return $open;
3054
3055      $post = get_post($post_id);
3056
3057      /** This filter is documented in wp-includes/comment.php */
3058      $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
3059      if ( ! in_array( $post->post_type, $post_types ) )
3060           return $open;
3061
3062      if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) )
3063           return false;
3064
3065      return $open;
3066 }
3067