Changeset 13995
- Timestamp:
- 04/04/2010 12:20:19 PM (15 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment.php
r13937 r13995 857 857 858 858 /** 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. 860 863 * 861 864 * The post comment count will be updated if the comment was approved and has a … … 870 873 * 871 874 * @param int $comment_id Comment ID 875 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false. 872 876 * @return bool False if delete comment query failure, true on success. 873 877 */ 874 function wp_delete_comment($comment_id ) {878 function wp_delete_comment($comment_id, $force_delete = false) { 875 879 global $wpdb; 876 880 if (!$comment = get_comment($comment_id)) 877 881 return false; 878 882 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' ) ) ) 880 884 return wp_trash_comment($comment_id); 881 885 … … 916 920 * Moves a comment to the Trash 917 921 * 922 * If trash is disabled, comment is permanently deleted. 923 * 918 924 * @since 2.9.0 919 925 * @uses do_action() on 'trash_comment' before trashing 920 926 * @uses do_action() on 'trashed_comment' after trashing 927 * @uses wp_delete_comment() if trash is disabled 921 928 * 922 929 * @param int $comment_id Comment ID. … … 924 931 */ 925 932 function 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); 928 935 929 936 if ( !$comment = get_comment($comment_id) ) -
trunk/wp-includes/post.php
r13985 r13995 1593 1593 1594 1594 /** 1595 * Removes a post, attachment,or page.1596 * 1597 * When the post and page goes, everything that is tied to it is deleted also.1595 * Trashes or deletes a post or page. 1596 * 1597 * When the post and page is permanently deleted, everything that is tied to it is deleted also. 1598 1598 * This includes comments, post meta fields, and terms associated with the post. 1599 * 1600 * The post or page is moved to trash instead of permanently deleted unless trash is 1601 * disabled, item is already in the trash, or $force_delete is true. 1599 1602 * 1600 1603 * @since 1.0.0 … … 1602 1605 * @uses do_action() on 'deleted_post' after deletion unless post type is 'attachment'. 1603 1606 * @uses wp_delete_attachment() if post type is 'attachment'. 1607 * @uses wp_trash_post() if item should be trashed. 1604 1608 * 1605 1609 * @param int $postid Post ID. 1606 * @param bool $force_delete Whether to bypass trash and force deletion 1610 * @param bool $force_delete Whether to bypass trash and force deletion. Defaults to false. 1607 1611 * @return mixed False on failure 1608 1612 */ … … 1613 1617 return $post; 1614 1618 1615 if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS > 0)1619 if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS ) 1616 1620 return wp_trash_post($postid); 1617 1621 … … 1699 1703 * Moves a post or page to the Trash 1700 1704 * 1705 * If trash is disabled, the post or page is permanently deleted. 1706 * 1701 1707 * @since 2.9.0 1702 1708 * @uses do_action() on 'trash_post' before trashing 1703 1709 * @uses do_action() on 'trashed_post' after trashing 1710 * @uses wp_delete_post() if trash is disabled 1704 1711 * 1705 1712 * @param int $postid Post ID. … … 1707 1714 */ 1708 1715 function wp_trash_post($post_id = 0) { 1709 if ( EMPTY_TRASH_DAYS == 0)1710 return wp_delete_post($post_id );1716 if ( !EMPTY_TRASH_DAYS ) 1717 return wp_delete_post($post_id, true); 1711 1718 1712 1719 if ( !$post = wp_get_single_post($post_id, ARRAY_A) ) … … 3297 3304 3298 3305 /** 3299 * Delete an attachment. 3300 * 3301 * Will remove the file also, when the attachment is removed. Removes all post 3302 * meta fields, taxonomy, comments, etc associated with the attachment (except 3303 * the main post). 3306 * Trashes or deletes an attachment. 3307 * 3308 * When an attachment is permanently deleted, the file will also be removed. 3309 * Deletion removes all post meta fields, taxonomy, comments, etc. associated 3310 * with the attachment (except the main post). 3311 * 3312 * The attachment is moved to the trash instead of permanently deleted unless trash 3313 * for media is disabled, item is already in the trash, or $force_delete is true. 3304 3314 * 3305 3315 * @since 2.0.0 … … 3308 3318 * 3309 3319 * @param int $postid Attachment ID. 3310 * @param bool $force_delete Whether to bypass trash and force deletion 3320 * @param bool $force_delete Whether to bypass trash and force deletion. Defaults to false. 3311 3321 * @return mixed False on failure. Post data on success. 3312 3322 */
Note: See TracChangeset
for help on using the changeset viewer.