WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/14/2015 09:46:40 PM (6 years ago)
Author:
wonderboymusic
Message:

wp_unspam_comment() can accept a full object instead of comment_ID to reduce cache/db lookups..

See #33638.

File:
1 edited

Legend:

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

    r34129 r34130  
    11651165 * @since 2.9.0
    11661166 *
    1167  * @param int $comment_id Comment ID.
     1167 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
    11681168 * @return bool True on success, false on failure.
    11691169 */
    1170 function wp_unspam_comment($comment_id) {
    1171     if ( ! (int)$comment_id )
    1172         return false;
    1173 
     1170function wp_unspam_comment( $comment_id ) {
    11741171    $comment = get_comment( $comment_id );
    11751172    if ( ! $comment ) {
     
    11841181     * @param int $comment_id The comment ID.
    11851182     */
    1186     do_action( 'unspam_comment', $comment_id );
    1187 
    1188     $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
     1183    do_action( 'unspam_comment', $comment->comment_ID );
     1184
     1185    $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
    11891186    if ( empty($status) )
    11901187        $status = '0';
    11911188
    11921189    if ( wp_set_comment_status( $comment, $status ) ) {
    1193         delete_comment_meta( $comment_id, '_wp_trash_meta_status' );
    1194         delete_comment_meta( $comment_id, '_wp_trash_meta_time' );
     1190        delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
     1191        delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
    11951192        /**
    11961193         * Fires immediately after a comment is unmarked as Spam.
     
    12001197         * @param int $comment_id The comment ID.
    12011198         */
    1202         do_action( 'unspammed_comment', $comment_id );
     1199        do_action( 'unspammed_comment', $comment->comment_ID );
    12031200        return true;
    12041201    }
Note: See TracChangeset for help on using the changeset viewer.