Make WordPress Core


Ignore:
Timestamp:
06/26/2005 07:55:12 PM (21 years ago)
Author:
ryan
Message:

Comment updating cleanup. Add get_comment(), edit_comment(), get_comment_to_edit(), and wp_update_comment().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-post.php

    r2651 r2662  
    163163        }
    164164
    165         // Return insert_id if we got a good result, otherwise return zero.
    166         return $result ? $post_ID : 0;
     165        return $rval;
    167166}
    168167
    … …  
    587586
    588587        return $result;
     588}
     589
     590function wp_update_comment($commentarr) {
     591        global $wpdb;
     592
     593        // First, get all of the original fields
     594        $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
     595
     596        // Escape data pulled from DB.
     597        foreach ($comment as $key => $value)
     598                $comment[$key] = $wpdb->escape($value);
     599
     600        // Merge old and new fields with new fields overwriting old ones.
     601        $commentarr = array_merge($comment, $commentarr);
     602
     603        // Now extract the merged array.
     604        extract($commentarr);
     605
     606        $comment_content = apply_filters('comment_save_pre', $comment_content);
     607
     608        $result = $wpdb->query(
     609                "UPDATE $wpdb->comments SET
     610                        comment_content = '$comment_content',
     611                        comment_author = '$comment_author',
     612                        comment_author_email = '$comment_author_email',
     613                        comment_approved = '$comment_approved',
     614                        comment_author_url = '$comment_author_url',
     615                        comment_date = '$comment_date'
     616                WHERE comment_ID = $comment_ID" );
     617
     618        $rval = $wpdb->rows_affected;
     619
     620        do_action('edit_comment', $comment_ID);
     621
     622        return $rval;   
    589623}
    590624
Note: See TracChangeset for help on using the changeset viewer.