Add filters to comments_open() and pings_open(). Props tellyworth. fixes #5761

git-svn-id: https://develop.svn.wordpress.org/trunk@6716 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-02-04 20:27:45 +00:00
parent 7c3373aae6
commit 40f80710a4
3 changed files with 16 additions and 16 deletions

View File

@ -16,7 +16,7 @@ $status = $wpdb->get_row("SELECT post_status, comment_status FROM $wpdb->posts W
if ( empty($status->comment_status) ) { if ( empty($status->comment_status) ) {
do_action('comment_id_not_found', $comment_post_ID); do_action('comment_id_not_found', $comment_post_ID);
exit; exit;
} elseif ( 'closed' == $status->comment_status ) { } elseif ( !comments_open($comment_post_ID) ) {
do_action('comment_closed', $comment_post_ID); do_action('comment_closed', $comment_post_ID);
wp_die( __('Sorry, comments are closed for this item.') ); wp_die( __('Sorry, comments are closed for this item.') );
} elseif ( in_array($status->post_status, array('draft', 'pending') ) ) { } elseif ( in_array($status->post_status, array('draft', 'pending') ) ) {

View File

@ -562,14 +562,15 @@ function trackback_rdf($deprecated = '') {
* @since 1.5 * @since 1.5
* @uses $post * @uses $post
* *
* @param int $post_id An optional post ID to check instead of the current post.
* @return bool True if the comments are open * @return bool True if the comments are open
*/ */
function comments_open() { function comments_open( $post_id=NULL ) {
global $post;
if ( 'open' == $post->comment_status ) $_post = get_post($post_id);
return true;
else $open = ( 'open' == $_post->comment_status );
return false; return apply_filters( 'comments_open', $open, $post_id );
} }
/** /**
@ -578,14 +579,15 @@ function comments_open() {
* @since 1.5 * @since 1.5
* @uses $post * @uses $post
* *
* @param int $post_id An optional post ID to check instead of the current post.
* @return bool True if pings are accepted * @return bool True if pings are accepted
*/ */
function pings_open() { function pings_open( $post_id=NULL ) {
global $post;
if ( 'open' == $post->ping_status ) $_post = get_post($post_id);
return true;
else $open = ( 'open' == $post->ping_status );
return false; return apply_filters( 'pings_open', $open, $post_id );
} }
/** /**

View File

@ -69,9 +69,7 @@ if (empty($title) && empty($tb_url) && empty($blog_name)) {
if ( !empty($tb_url) && !empty($title) ) { if ( !empty($tb_url) && !empty($title) ) {
header('Content-Type: text/xml; charset=' . get_option('blog_charset') ); header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id"); if ( !pings_open($tb_id) )
if ( 'open' != $pingstatus )
trackback_response(1, 'Sorry, trackbacks are closed for this item.'); trackback_response(1, 'Sorry, trackbacks are closed for this item.');
$title = wp_specialchars( strip_tags( $title ) ); $title = wp_specialchars( strip_tags( $title ) );