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 |
---|---|
1959 | * @since 2.7.0 |
1960 | * |
1961 | * @param object $posts Post data object. |
1962 | * @return object |
1963 | */ |
1964 | function _close_comments_for_old_posts( $posts ) { |
1965 | if ( empty($posts) || !is_singular() || !get_option('close_comments_for_old_posts') ) |
1966 | return $posts; |
1967 |
|
1968 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
1969 | if ( ! in_array( $posts[0]->post_type, $post_types ) ) |
1970 | return $posts; |
1971 |
|
1972 | $days_old = (int) get_option('close_comments_days_old'); |
1973 | if ( !$days_old ) |
1974 | return $posts; |
1975 |
|
1976 | if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) { |
1977 | $posts[0]->comment_status = 'closed'; |
Line | Code |
1998 | if ( !get_option('close_comments_for_old_posts') ) |
1999 | return $open; |
2000 |
|
2001 | $days_old = (int) get_option('close_comments_days_old'); |
2002 | if ( !$days_old ) |
2003 | return $open; |
2004 |
|
2005 | $post = get_post($post_id); |
2006 |
|
2007 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
2008 | if ( ! in_array( $post->post_type, $post_types ) ) |
2009 | return $open; |
2010 |
|
2011 | if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) |
2012 | return false; |
2013 |
|
2014 | return $open; |
2015 | } |
2016 |
|