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 |
---|---|
2006 | * |
2007 | * @param object $posts Post data object. |
2008 | * @param object $query Query object. |
2009 | * @return object |
2010 | */ |
2011 | function _close_comments_for_old_posts( $posts, $query ) { |
2012 | if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) |
2013 | return $posts; |
2014 |
|
2015 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
2016 | if ( ! in_array( $posts[0]->post_type, $post_types ) ) |
2017 | return $posts; |
2018 |
|
2019 | $days_old = (int) get_option( 'close_comments_days_old' ); |
2020 | if ( ! $days_old ) |
2021 | return $posts; |
2022 |
|
2023 | if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { |
2024 | $posts[0]->comment_status = 'closed'; |
Line | Code |
2045 | if ( !get_option('close_comments_for_old_posts') ) |
2046 | return $open; |
2047 |
|
2048 | $days_old = (int) get_option('close_comments_days_old'); |
2049 | if ( !$days_old ) |
2050 | return $open; |
2051 |
|
2052 | $post = get_post($post_id); |
2053 |
|
2054 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
2055 | if ( ! in_array( $post->post_type, $post_types ) ) |
2056 | return $open; |
2057 |
|
2058 | if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) |
2059 | return false; |
2060 |
|
2061 | return $open; |
2062 | } |
2063 |
|