Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_notify_moderator [ WordPress Function ]

wp_notify_moderator ( $comment_id )
Parameters:
Uses:
  • $wpdb
Returns:
  • (bool) Always returns true
Defined at:



Notifies the moderator of the blog about a new comment that is awaiting approval.

Source


<?php
function wp_notify_moderator($comment_id) {
    global 
$wpdb;

    if ( 
== get_option'moderation_notify' ) )
        return 
true;

    
$comment get_comment($comment_id);
    
$post get_post($comment->comment_post_ID);
    
$user get_userdata$post->post_author );
    
// Send to the administration and to the post author if the author can modify the comment.
    
$email_to = array( get_option('admin_email') );
    if ( 
user_can($user->ID'edit_comment'$comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) )
        
$email_to[] = $user->user_email;

    
$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
    
$comments_waiting $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");

    
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
    // we want to reverse this for the plain text arena of emails.
    
$blogname wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

    switch (
$comment->comment_type)
    {
        case 
'trackback':
            
$notify_message  sprintf__('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
            
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
            
$notify_message .= sprintf__('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author$comment->comment_author_IP$comment_author_domain ) . "\r\n";
            
$notify_message .= sprintf__('URL    : %s'), $comment->comment_author_url ) . "\r\n";
            
$notify_message .= __('Trackback excerpt: ') . "\r\n" $comment->comment_content "\r\n\r\n";
            break;
        case 
'pingback':
            
$notify_message  sprintf__('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
            
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
            
$notify_message .= sprintf__('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author$comment->comment_author_IP$comment_author_domain ) . "\r\n";
            
$notify_message .= sprintf__('URL    : %s'), $comment->comment_author_url ) . "\r\n";
            
$notify_message .= __('Pingback excerpt: ') . "\r\n" $comment->comment_content "\r\n\r\n";
            break;
        default: 
//Comments
            
$notify_message  sprintf__('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
            
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
            
$notify_message .= sprintf__('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author$comment->comment_author_IP$comment_author_domain ) . "\r\n";
            
$notify_message .= sprintf__('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
            
$notify_message .= sprintf__('URL    : %s'), $comment->comment_author_url ) . "\r\n";
            
$notify_message .= sprintf__('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
            
$notify_message .= __('Comment: ') . "\r\n" $comment->comment_content "\r\n\r\n";
            break;
    }

    
$notify_message .= sprintf__('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
    if ( 
EMPTY_TRASH_DAYS )
        
$notify_message .= sprintf__('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
    else
        
$notify_message .= sprintf__('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
    
$notify_message .= sprintf__('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";

    
$notify_message .= sprintf_n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
         
'Currently %s comments are waiting for approval. Please visit the moderation panel:'$comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
    
$notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n";

    
$subject sprintf__('[%1$s] Please moderate: "%2$s"'), $blogname$post->post_title );
    
$message_headers '';

    
$notify_message apply_filters('comment_moderation_text'$notify_message$comment_id);
    
$subject apply_filters('comment_moderation_subject'$subject$comment_id);
    
$message_headers apply_filters('comment_moderation_headers'$message_headers);

    foreach ( 
$email_to as $email )
        @
wp_mail($email$subject$notify_message$message_headers);

    return 
true;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics