[wp-trac] [WordPress Trac] #27018: pre_get_comments doesn't trigger when calling comments_template() for logged in users
WordPress Trac
noreply at wordpress.org
Wed Feb 5 02:38:29 UTC 2014
#27018: pre_get_comments doesn't trigger when calling comments_template() for
logged in users
--------------------------+-----------------------------
Reporter: flynsarmy | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: 3.8.1
Severity: normal | Keywords:
Focuses: template |
--------------------------+-----------------------------
When comments_template() function is called for a logged in user, the
''pre_get_comments'' action doesn't trigger. This is caused by the calling
of $wpdb->get_results() directly in the comments_template() function so
WP_Comments_Query (where the action is defined) is never reached:
{{{
/** @todo Use API instead of SELECTs. */
if ( $user_ID) {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM
$wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR
( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt",
$post->ID, $user_ID));
} else if ( empty($comment_author) ) {
$comments = get_comments( array('post_id' => $post->ID, 'status'
=> 'approve', 'order' => 'ASC') );
} else {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM
$wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR
( comment_author = %s AND comment_author_email = %s AND comment_approved =
'0' ) ) ORDER BY comment_date_gmt", $post->ID,
wp_specialchars_decode($comment_author,ENT_QUOTES),
$comment_author_email));
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27018>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list