WordPress.org

Make WordPress Core

Changeset 9015


Ignore:
Timestamp:
09/28/08 03:31:26 (6 years ago)
Author:
ryan
Message:

Make pings_open() and comments_open() aware of old post settings. see #7741

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r9012 r9015  
    13881388 
    13891389/** 
    1390  * Close comments on old posts on the fly, without any extra DB queries. 
     1390 * Close comments on old posts on the fly, without any extra DB queries.  Hooked to the_posts. 
    13911391 * 
    13921392 * @access private 
     
    14121412} 
    14131413 
     1414/** 
     1415 * Close comments on an old post.  Hooked to comments_open. 
     1416 * 
     1417 * @access private 
     1418 * @since 2.7.0 
     1419 * 
     1420 * @param bool $open Comments open or closed 
     1421 * @param int $post_id Post ID 
     1422 * @return bool $open 
     1423 */ 
     1424function _close_comments_for_old_post( $open, $post_id ) { 
     1425    if ( ! $open ) 
     1426        return $open; 
     1427 
     1428    if ( !get_option('close_comments_for_old_posts') ) 
     1429        return $open; 
     1430 
     1431    $days_old = (int) get_option('close_comments_days_old'); 
     1432    if ( !$days_old ) 
     1433        return $open; 
     1434 
     1435    $post = get_post($post_id); 
     1436 
     1437    if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) 
     1438        return false; 
     1439 
     1440    return $open; 
     1441} 
     1442 
    14141443?> 
  • trunk/wp-includes/default-filters.php

    r8892 r9015  
    157157add_filter('option_category_base', '_wp_filter_taxonomy_base'); 
    158158add_filter( 'the_posts', '_close_comments_for_old_posts' ); 
    159  
    160 //Atom SSL support 
     159add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 ); 
     160add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); 
     161 
     162// Atom SSL support 
    161163add_filter('atom_service_url','atom_service_url_filter'); 
    162164 
Note: See TracChangeset for help on using the changeset viewer.