Making WordPress.org


Ignore:
Timestamp:
10/27/2018 08:58:39 PM (8 years ago)
Author:
drewapicture
Message:

Developer: Allow moderators to selectively reset the vote counts on contributed notes.

Props keesiemeijer.
Fixes #3886.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-voting.php

    r7276 r7797  
    455455
    456456    /**
     457     * Resets the votes for a note..
     458     *
     459     * The current user needs to have the edit_comment capability for the votes to be deleted.
     460     *
     461     * @access public
     462     *
     463     * @param int $comment_id The comment ID to reset votes for
     464     */
     465    public static function reset_votes( $comment_id ) {
     466        $comment_id = absint( $comment_id );
     467        if ( ! $comment_id || ! current_user_can( 'edit_comment', $comment_id ) ) {
     468            return;
     469        }
     470
     471        delete_comment_meta( $comment_id, self::$meta_upvotes );
     472        delete_comment_meta( $comment_id, self::$meta_downvotes );
     473    }
     474
     475    /**
    457476     * Handles abstraction between an up or down vote.
    458477     *
Note: See TracChangeset for help on using the changeset viewer.