Switch language

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




check_comment [ WordPress Function ]

check_comment ( $author, $email, $url, $comment, $user_ip, $user_agent, $comment_type )
Parameters:
  • (string) $author Comment Author's name
  • (string) $email Comment Author's email
  • (string) $url Comment Author's URL
  • (string) $comment Comment contents
  • (string) $user_ip Comment Author's IP address
  • (string) $user_agent Comment Author's User Agent
  • (string) $comment_type Comment type, either user submitted comment, trackback, or pingback
Uses:
  • $wpdb
Returns:
  • (bool) Whether the checks passed (true) and the comments should be displayed or set to moderated
Defined at:



Checks whether a comment passes internal checks to be allowed to add.

If comment moderation is set in the administration, then all comments, regardless of their type and whitelist will be set to false. If the number of links exceeds the amount in the administration, then the check fails. If any of the parameter contents match the blacklist of words, then the check fails.

If the number of links exceeds the amount in the administration, then the check fails. If any of the parameter contents match the blacklist of words, then the check fails.

If the comment author was approved before, then the comment is automatically whitelisted.

If none of the checks fail, then the failback is to set the check to pass (return true).

Source


<?php
function check_comment($author$email$url$comment$user_ip$user_agent$comment_type) {
    global 
$wpdb;

    if ( 
== get_option('comment_moderation') )
        return 
false// If moderation is set to manual

    
$comment apply_filters'comment_text'$comment );

    
// Check # of external links
    
if ( $max_links get_option'comment_max_links' ) ) {
        
$num_links preg_match_all'/<a [^>]*href/i'$comment$out );
        
$num_links apply_filters'comment_max_links_url'$num_links$url ); // provide for counting of $url as a link
        
if ( $num_links >= $max_links )
            return 
false;
    }

    
$mod_keys trim(get_option('moderation_keys'));
    if ( !empty(
$mod_keys) ) {
        
$words explode("\n"$mod_keys );

        foreach ( (array) 
$words as $word) {
            
$word trim($word);

            
// Skip empty lines
            
if ( empty($word) )
                continue;

            
// Do some escaping magic so that '#' chars in the
            // spam words don't break things:
            
$word preg_quote($word'#');

            
$pattern "#$word#i";
            if ( 
preg_match($pattern$author) ) return false;
            if ( 
preg_match($pattern$email) ) return false;
            if ( 
preg_match($pattern$url) ) return false;
            if ( 
preg_match($pattern$comment) ) return false;
            if ( 
preg_match($pattern$user_ip) ) return false;
            if ( 
preg_match($pattern$user_agent) ) return false;
        }
    }

    
// Comment whitelisting:
    
if ( == get_option('comment_whitelist')) {
        if ( 
'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) {
            
// expected_slashed ($author, $email)
            
$ok_to_comment $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
            if ( ( 
== $ok_to_comment ) &&
                ( empty(
$mod_keys) || false === strpos$email$mod_keys) ) )
                    return 
true;
            else
                return 
false;
        } else {
            return 
false;
        }
    }
    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