Make WordPress Core


Ignore:
Timestamp:
04/04/2010 12:20:19 PM (15 years ago)
Author:
nacin
Message:

Add $force_delete to wp_delete_comment(). see #12766, see #11470.

File:
1 edited

Legend:

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

    r13937 r13995  
    857857
    858858/**
    859  * Removes comment ID and maybe updates post comment count.
     859 * Trashes or deletes a comment.
     860 *
     861 * The comment is moved to trash instead of permanently deleted unless trash is
     862 * disabled, item is already in the trash, or $force_delete is true.
    860863 *
    861864 * The post comment count will be updated if the comment was approved and has a
     
    870873 *
    871874 * @param int $comment_id Comment ID
     875 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
    872876 * @return bool False if delete comment query failure, true on success.
    873877 */
    874 function wp_delete_comment($comment_id) {
     878function wp_delete_comment($comment_id, $force_delete = false) {
    875879    global $wpdb;
    876880    if (!$comment = get_comment($comment_id))
    877881        return false;
    878882
    879     if (wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0)
     883    if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) )
    880884        return wp_trash_comment($comment_id);
    881885
     
    916920 * Moves a comment to the Trash
    917921 *
     922 * If trash is disabled, comment is permanently deleted.
     923 *
    918924 * @since 2.9.0
    919925 * @uses do_action() on 'trash_comment' before trashing
    920926 * @uses do_action() on 'trashed_comment' after trashing
     927 * @uses wp_delete_comment() if trash is disabled
    921928 *
    922929 * @param int $comment_id Comment ID.
     
    924931 */
    925932function wp_trash_comment($comment_id) {
    926     if ( EMPTY_TRASH_DAYS == 0 )
    927         return wp_delete_comment($comment_id);
     933    if ( !EMPTY_TRASH_DAYS )
     934        return wp_delete_comment($comment_id, true);
    928935
    929936    if ( !$comment = get_comment($comment_id) )
Note: See TracChangeset for help on using the changeset viewer.