Make WordPress Core

Ticket #5761: comments-open-filter-r6692-3.patch

File comments-open-filter-r6692-3.patch, 2.4 KB (added by tellyworth, 17 years ago)
  • wordpress/wp-includes/comment-template.php

     
    562562 * @since 1.5
    563563 * @uses $post
    564564 *
     565 * @param int $post_id An optional post ID to check instead of the current post.
    565566 * @return bool True if the comments are open
    566567 */
    567 function comments_open() {
    568         global $post;
    569         if ( 'open' == $post->comment_status )
    570                 return true;
    571         else
    572                 return false;
     568function comments_open( $post_id=NULL ) {
     569
     570        $_post = get_post($post_id);
     571       
     572        $open = ( 'open' == $_post->comment_status );
     573        return apply_filters( 'comments_open', $open, $post_id );
    573574}
    574575
    575576/**
     
    578579 * @since 1.5
    579580 * @uses $post
    580581 *
     582 * @param int $post_id An optional post ID to check instead of the current post.
    581583 * @return bool True if pings are accepted
    582584 */
    583 function pings_open() {
    584         global $post;
    585         if ( 'open' == $post->ping_status )
    586                 return true;
    587         else
    588                 return false;
     585function pings_open( $post_id=NULL ) {
     586
     587        $_post = get_post($post_id);
     588
     589        $open = ( 'open' == $post->ping_status );
     590        return apply_filters( 'pings_open', $open, $post_id );
    589591}
    590592
    591593/**
  • wordpress/wp-trackback.php

     
    6969if ( !empty($tb_url) && !empty($title) ) {
    7070        header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
    7171
    72         $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
    73 
    74         if ( 'open' != $pingstatus )
     72        if ( !pings_open($tb_id) )
    7573                trackback_response(1, 'Sorry, trackbacks are closed for this item.');
    7674
    7775        $title =  wp_specialchars( strip_tags( $title ) );
  • wordpress/wp-comments-post.php

     
    1616if ( empty($status->comment_status) ) {
    1717        do_action('comment_id_not_found', $comment_post_ID);
    1818        exit;
    19 } elseif ( 'closed' ==  $status->comment_status ) {
     19} elseif ( !comments_open($comment_post_ID) ) {
    2020        do_action('comment_closed', $comment_post_ID);
    2121        wp_die( __('Sorry, comments are closed for this item.') );
    2222} elseif ( in_array($status->post_status, array('draft', 'pending') ) ) {