Categories
php tecnologia

wordpress: rss per commenti moderati

sulla mailing list hacker di wordpress ho scoperto un interessante hack su come far visualizzare al feed RSS i commenti moderati, in questo modo sarà più semplice controllare che ce ne siano senza dover intasare la propria casella di posta elettronica o dover andare sul pannello di amministrazione del blog.

[php]
if (is_single()) {
$comments = $wpdb->get_results(“SELECT comment_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_content, comment_post_ID, $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = ‘$id’ AND $wpdb->comments.comment_approved = ‘1’ AND $wpdb->posts.post_status = ‘publish’ AND post_date < '".date("Y-m-d H:i:59")."' ORDER BY comment_date LIMIT " . get_settings('posts_per_rss') ); } else if (isset($_GET["view"]) && $_GET["view"] == 'moderated_comments') { $comments = $wpdb->get_results(“SELECT comment_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_content, comment_post_ID, $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->comments.comment_approved = ‘0’ AND $wpdb->posts.post_status = ‘publish’ AND post_date < '".date("Y-m-d H:i:59")."' ORDER BY comment_date LIMIT " . get_settings('posts_per_rss') ); } else { // if no post id passed in, we'll just ue the last 10 comments. $comments = $wpdb->get_results(“SELECT comment_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_content, comment_post_ID, $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = ‘publish’ AND $wpdb->comments.comment_approved = ‘1’ AND post_date < '".date("Y-m-d H:i:s")."' ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') ); } [/php]

Find the SQL queries in wp-commentsrss2.php and replace with this code.
Then subscribe to:
http://www.example./com/wp-commentsrss2.php?view=moderated_comments
This is from a recent nightly build, it will be slightly different in 1.2.1 or previous versions.

Cheers,
–Alex
http://www.alexking.org/

ciuaz