Make WordPress Core

Ticket #5578: comment.phpdoc.diff

File comment.phpdoc.diff, 6.1 KB (added by darkdragon, 18 years ago)

fixes and more documentation

  • comment.php

     
    88/**
    99 * check_comment() - Checks whether a comment passes internal checks to be allowed to add
    1010 *
    11  * {@internal Missing Long Description}}
     11 * If comment moderation is set in the administration, then all comments, regardless
     12 * of their type and whitelist will be set to false.
    1213 *
     14 * If the number of links exceeds the amount in the administration, then the check
     15 * fails.
     16 *
     17 * If any of the parameter contents match the blacklist of words, then the check
     18 * fails.
     19 *
     20 * If the comment is a trackback and part of the blogroll, then the trackback is
     21 * automatically whitelisted. If the comment author was approved before, then the
     22 * comment is automatically whitelisted.
     23 *
     24 * If none of the checks fail, then the failback is to set the check to pass (return
     25 * true).
     26 *
    1327 * @since 1.2
    1428 * @uses $wpdb
    1529 *
    16  * @param string $author {@internal Missing Description }}
    17  * @param string $email {@internal Missing Description }}
    18  * @param string $url {@internal Missing Description }}
    19  * @param string $comment {@internal Missing Description }}
    20  * @param string $user_ip {@internal Missing Description }}
    21  * @param string $user_agent {@internal Missing Description }}
    22  * @param string $comment_type {@internal Missing Description }}
    23  * @return bool {@internal Missing Description }}
     30 * @param string $author Comment Author's name
     31 * @param string $email Comment Author's email
     32 * @param string $url Comment Author's URL
     33 * @param string $comment Comment contents
     34 * @param string $user_ip Comment Author's IP address
     35 * @param string $user_agent Comment Author's User Agent
     36 * @param string $comment_type Comment type, either user submitted comment, trackback, or pingback
     37 * @return bool Whether the checks passed (true) and the comments should be displayed or set to moderated
    2438 */
    2539function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
    2640        global $wpdb;
     
    170184                        $query .= " AND comment_approved = '1'";
    171185                $myrow = $wpdb->get_row($query, ARRAY_A);
    172186        } else {
    173                 $myrow['comment_ID']           = $postc->comment_ID;
    174                 $myrow['comment_post_ID']      = $postc->comment_post_ID;
    175                 $myrow['comment_author']       = $postc->comment_author;
    176                 $myrow['comment_author_email'] = $postc->comment_author_email;
    177                 $myrow['comment_author_url']   = $postc->comment_author_url;
    178                 $myrow['comment_author_IP']    = $postc->comment_author_IP;
    179                 $myrow['comment_date']         = $postc->comment_date;
    180                 $myrow['comment_content']      = $postc->comment_content;
    181                 $myrow['comment_karma']        = $postc->comment_karma;
    182                 $myrow['comment_approved']     = $postc->comment_approved;
    183                 $myrow['comment_type']         = $postc->comment_type;
     187                $myrow['comment_ID']                    = $postc->comment_ID;
     188                $myrow['comment_post_ID']               = $postc->comment_post_ID;
     189                $myrow['comment_author']                = $postc->comment_author;
     190                $myrow['comment_author_email']  = $postc->comment_author_email;
     191                $myrow['comment_author_url']    = $postc->comment_author_url;
     192                $myrow['comment_author_IP']             = $postc->comment_author_IP;
     193                $myrow['comment_date']                  = $postc->comment_date;
     194                $myrow['comment_content']               = $postc->comment_content;
     195                $myrow['comment_karma']                 = $postc->comment_karma;
     196                $myrow['comment_approved']              = $postc->comment_approved;
     197                $myrow['comment_type']                  = $postc->comment_type;
    184198        }
    185199        return $myrow;
    186200}
     
    228242 * @since 2.0.0
    229243 * @uses $wpdb
    230244 *
    231  * @param int $post_id Optional. Comment amount in post if > 0, else total com
    232 ments blog wide
     245 * @param int $post_id Optional. Comment amount in post if > 0, else total comments blog wide
    233246 * @return array The amount of spam, approved, awaiting moderation, and total
    234247 */
    235248function get_comment_count( $post_id = 0 ) {
     
    249262                GROUP BY comment_approved
    250263        ", ARRAY_A);
    251264
    252         $comment_count = array(                         
    253                 "approved"              => 0,               
    254                 "awaiting_moderation"   => 0,
    255                 "spam"                  => 0,
    256                 "total_comments"        => 0
     265        $comment_count = array(
     266                "approved"                              => 0,
     267                "awaiting_moderation"   => 0,
     268                "spam"                                  => 0,
     269                "total_comments"                => 0
    257270        );
    258271
    259         foreach ( $totals as $row ) { 
    260                 switch ( $row['comment_approved'] ) { 
    261                         case 'spam': 
    262                                 $comment_count['spam'] = $row['total']; 
     272        foreach ( $totals as $row ) {
     273                switch ( $row['comment_approved'] ) {
     274                        case 'spam':
     275                                $comment_count['spam'] = $row['total'];
    263276                                $comment_count["total_comments"] += $row['total'];
    264                                 break; 
    265                         case 1: 
    266                                 $comment_count['approved'] = $row['total']; 
     277                                break;
     278                        case 1:
     279                                $comment_count['approved'] = $row['total'];
    267280                                $comment_count['total_comments'] += $row['total'];
    268                                 break; 
     281                                break;
    269282                        case 0:
    270283                                $comment_count['awaiting_moderation'] = $row['total'];
    271284                                $comment_count['total_comments'] += $row['total'];
     
    786799 */
    787800function wp_defer_comment_counting($defer=null) {
    788801        static $_defer = false;
    789        
     802
    790803        if ( is_bool($defer) ) {
    791804                $_defer = $defer;
    792805                // flush any deferred counts
    793806                if ( !$defer )
    794807                        wp_update_comment_count( null, true );
    795808        }
    796        
     809
    797810        return $_defer;
    798811}
    799812
     
    817830 */
    818831function wp_update_comment_count($post_id, $do_deferred=false) {
    819832        static $_deferred = array();
    820        
     833
    821834        if ( $do_deferred ) {
    822835                $_deferred = array_unique($_deferred);
    823836                foreach ( $_deferred as $i => $_post_id ) {
     
    825838                        unset( $_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */
    826839                }
    827840        }
    828        
     841
    829842        if ( wp_defer_comment_counting() ) {
    830843                $_deferred[] = $post_id;
    831844                return true;
     
    833846        elseif ( $post_id ) {
    834847                return wp_update_comment_count_now($post_id);
    835848        }
    836                
     849
    837850}
    838851
    839852/**
     
    10281041        $excerpt = str_replace(']]>', ']]>', $excerpt);
    10291042        $excerpt = strip_tags($excerpt);
    10301043        if ( function_exists('mb_strcut') ) // For international trackbacks
    1031         $excerpt = mb_strcut($excerpt, 0, 252, get_option('blog_charset')) . '...';
     1044                $excerpt = mb_strcut($excerpt, 0, 252, get_option('blog_charset')) . '...';
    10321045        else
    10331046                $excerpt = substr($excerpt, 0, 252) . '...';
    10341047