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 |
---|---|
1954 | * |
1955 | * @param object $posts Post data object. |
1956 | * @param object $query Query object. |
1957 | * @return object |
1958 | */ |
1959 | function _close_comments_for_old_posts( $posts, $query ) { |
1960 | if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) |
1961 | return $posts; |
1962 |
|
1963 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
1964 | if ( ! in_array( $posts[0]->post_type, $post_types ) ) |
1965 | return $posts; |
1966 |
|
1967 | $days_old = (int) get_option( 'close_comments_days_old' ); |
1968 | if ( ! $days_old ) |
1969 | return $posts; |
1970 |
|
1971 | if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) { |
1972 | $posts[0]->comment_status = 'closed'; |
Line | Code |
1993 | if ( !get_option('close_comments_for_old_posts') ) |
1994 | return $open; |
1995 |
|
1996 | $days_old = (int) get_option('close_comments_days_old'); |
1997 | if ( !$days_old ) |
1998 | return $open; |
1999 |
|
2000 | $post = get_post($post_id); |
2001 |
|
2002 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
2003 | if ( ! in_array( $post->post_type, $post_types ) ) |
2004 | return $open; |
2005 |
|
2006 | if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) |
2007 | return false; |
2008 |
|
2009 | return $open; |
2010 | } |
2011 |
|