WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 2 times in this file.
| Line | Code |
|---|---|
| 2656 | return $posts; |
| 2657 | |
| 2658 | /** |
| 2659 | * Filters the list of post types to automatically close comments for. |
| 2660 | * |
| 2661 | * @since 3.2.0 |
| 2662 | * |
| 2663 | * @param array $post_types An array of registered post types. Default array with 'post'. |
| 2664 | */ |
| 2665 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
| 2666 | if ( ! in_array( $posts[0]->post_type, $post_types ) ) |
| 2667 | return $posts; |
| 2668 | |
| 2669 | $days_old = (int) get_option( 'close_comments_days_old' ); |
| 2670 | if ( ! $days_old ) |
| 2671 | return $posts; |
| 2672 | |
| 2673 | if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { |
| 2674 | $posts[0]->comment_status = 'closed'; |
| Line | Code |
| 2696 | return $open; |
| 2697 | |
| 2698 | $days_old = (int) get_option('close_comments_days_old'); |
| 2699 | if ( !$days_old ) |
| 2700 | return $open; |
| 2701 | |
| 2702 | $post = get_post($post_id); |
| 2703 | |
| 2704 | /** This filter is documented in wp-includes/comment.php */ |
| 2705 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
| 2706 | if ( ! in_array( $post->post_type, $post_types ) ) |
| 2707 | return $open; |
| 2708 | |
| 2709 | // Undated drafts should not show up as comments closed. |
| 2710 | if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { |
| 2711 | return $open; |
| 2712 | } |
| 2713 | |
| 2714 | if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) |