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
3280      }
3281
3282      /**
3283       * Filters the list of post types to automatically close comments for.
3284       *
3285       * @since 3.2.0
3286       *
3287       * @param string[] $post_types An array of post type names.
3288       */
3289      $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
3290      if ( ! in_array( $posts[0]->post_type, $post_types, true ) ) {
3291           return $posts;
3292      }
3293
3294      $days_old = (int) get_option( 'close_comments_days_old' );
3295      if ( ! $days_old ) {
3296           return $posts;
3297      }
3298
 
Line Code
3325
3326      $days_old = (int) get_option( 'close_comments_days_old' );
3327      if ( ! $days_old ) {
3328           return $open;
3329      }
3330
3331      $post = get_post( $post_id );
3332
3333      /** This filter is documented in wp-includes/comment.php */
3334      $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
3335      if ( ! in_array( $post->post_type, $post_types, true ) ) {
3336           return $open;
3337      }
3338
3339      // Undated drafts should not show up as comments closed.
3340      if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) {
3341           return $open;
3342      }
3343