Skip to content
Browse files

Add filters to comments_open() and pings_open(). Props tellyworth. fi…

…xes #5761

git-svn-id: http://svn.automattic.com/wordpress/trunk@6716 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent b9316d1 commit 25788ba179f5d63fcc2572bd0c241297f2c15132 ryan committed Feb 4, 2008
Showing with 16 additions and 16 deletions.
  1. +1 −1 wp-comments-post.php
  2. +14 −12 wp-includes/comment-template.php
  3. +1 −3 wp-trackback.php
View
2 wp-comments-post.php
@@ -16,7 +16,7 @@
if ( empty($status->comment_status) ) {
do_action('comment_id_not_found', $comment_post_ID);
exit;
-} elseif ( 'closed' == $status->comment_status ) {
+} elseif ( !comments_open($comment_post_ID) ) {
do_action('comment_closed', $comment_post_ID);
wp_die( __('Sorry, comments are closed for this item.') );
} elseif ( in_array($status->post_status, array('draft', 'pending') ) ) {
View
26 wp-includes/comment-template.php
@@ -562,14 +562,15 @@ function trackback_rdf($deprecated = '') {
* @since 1.5
* @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
*/
-function comments_open() {
- global $post;
- if ( 'open' == $post->comment_status )
- return true;
- else
- return false;
+function comments_open( $post_id=NULL ) {
+
+ $_post = get_post($post_id);
+
+ $open = ( 'open' == $_post->comment_status );
+ return apply_filters( 'comments_open', $open, $post_id );
}
/**
@@ -578,14 +579,15 @@ function comments_open() {
* @since 1.5
* @uses $post
*
+ * @param int $post_id An optional post ID to check instead of the current post.
* @return bool True if pings are accepted
*/
-function pings_open() {
- global $post;
- if ( 'open' == $post->ping_status )
- return true;
- else
- return false;
+function pings_open( $post_id=NULL ) {
+
+ $_post = get_post($post_id);
+
+ $open = ( 'open' == $post->ping_status );
+ return apply_filters( 'pings_open', $open, $post_id );
}
/**
View
4 wp-trackback.php
@@ -69,9 +69,7 @@ function trackback_response($error = 0, $error_message = '') {
if ( !empty($tb_url) && !empty($title) ) {
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 ( 'open' != $pingstatus )
+ if ( !pings_open($tb_id) )
trackback_response(1, 'Sorry, trackbacks are closed for this item.');
$title = wp_specialchars( strip_tags( $title ) );

0 comments on commit 25788ba

Please sign in to comment.
Something went wrong with that request. Please try again.