WordPress.org

Make WordPress Core

Ticket #41228: 41228.2.diff

File 41228.2.diff, 4.2 KB (added by henry.wright, 2 years ago)

41288.2.diff addresses the related actions. Thanks @SergeyBiryukov for mentioning transition_comment_status that will come in useful :)

  • src/wp-includes/comment.php

    diff --git src/wp-includes/comment.php src/wp-includes/comment.php
    index 7055db7..d62fb0a 100644
    function wp_delete_comment($comment_id, $force_delete = false) { 
    12871287         * @since 1.2.0
    12881288         *
    12891289         * @param int $comment_id The comment ID.
     1290         * @param WP_Comment $comment The comment to be deleted.
    12901291         */
    1291         do_action( 'delete_comment', $comment->comment_ID );
     1292        do_action( 'delete_comment', $comment->comment_ID, $comment );
    12921293
    12931294        // Move children up a level.
    12941295        $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment->comment_ID) );
    function wp_delete_comment($comment_id, $force_delete = false) { 
    13111312         * @since 2.9.0
    13121313         *
    13131314         * @param int $comment_id The comment ID.
     1315         * @param WP_Comment $comment The deleted comment.
    13141316         */
    1315         do_action( 'deleted_comment', $comment->comment_ID );
     1317        do_action( 'deleted_comment', $comment->comment_ID, $comment );
    13161318
    13171319        $post_id = $comment->comment_post_ID;
    13181320        if ( $post_id && $comment->comment_approved == 1 )
    function wp_trash_comment($comment_id) { 
    13501352         * @since 2.9.0
    13511353         *
    13521354         * @param int $comment_id The comment ID.
     1355         * @param WP_Comment $comment The comment to be trashed.
    13531356         */
    1354         do_action( 'trash_comment', $comment->comment_ID );
     1357        do_action( 'trash_comment', $comment->comment_ID, $comment );
    13551358
    13561359        if ( wp_set_comment_status( $comment, 'trash' ) ) {
    13571360                delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
    function wp_trash_comment($comment_id) { 
    13651368                 * @since 2.9.0
    13661369                 *
    13671370                 * @param int $comment_id The comment ID.
     1371                 * @param WP_Comment $comment The trashed comment.
    13681372                 */
    1369                 do_action( 'trashed_comment', $comment->comment_ID );
     1373                do_action( 'trashed_comment', $comment->comment_ID, $comment );
    13701374                return true;
    13711375        }
    13721376
    function wp_untrash_comment($comment_id) { 
    13931397         * @since 2.9.0
    13941398         *
    13951399         * @param int $comment_id The comment ID.
     1400         * @param WP_Comment $comment The comment to be untrashed.
    13961401         */
    1397         do_action( 'untrash_comment', $comment->comment_ID );
     1402        do_action( 'untrash_comment', $comment->comment_ID, $comment );
    13981403
    13991404        $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
    14001405        if ( empty($status) )
    function wp_untrash_comment($comment_id) { 
    14091414                 * @since 2.9.0
    14101415                 *
    14111416                 * @param int $comment_id The comment ID.
     1417                 * @param WP_Comment $comment The untrashed comment.
    14121418                 */
    1413                 do_action( 'untrashed_comment', $comment->comment_ID );
     1419                do_action( 'untrashed_comment', $comment->comment_ID, $comment );
    14141420                return true;
    14151421        }
    14161422
    function wp_spam_comment( $comment_id ) { 
    14371443         * @since 2.9.0
    14381444         *
    14391445         * @param int $comment_id The comment ID.
     1446         * @param WP_Comment $comment The comment to be marked as spam.
    14401447         */
    1441         do_action( 'spam_comment', $comment->comment_ID );
     1448        do_action( 'spam_comment', $comment->comment_ID, $comment );
    14421449
    14431450        if ( wp_set_comment_status( $comment, 'spam' ) ) {
    14441451                delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
    function wp_spam_comment( $comment_id ) { 
    14511458                 * @since 2.9.0
    14521459                 *
    14531460                 * @param int $comment_id The comment ID.
     1461                 * @param WP_Comment $comment The comment marked as spam.
    14541462                 */
    1455                 do_action( 'spammed_comment', $comment->comment_ID );
     1463                do_action( 'spammed_comment', $comment->comment_ID, $comment );
    14561464                return true;
    14571465        }
    14581466
    function wp_unspam_comment( $comment_id ) { 
    14791487         * @since 2.9.0
    14801488         *
    14811489         * @param int $comment_id The comment ID.
     1490         * @param WP_Comment $comment The comment to be unmarked as spam.
    14821491         */
    1483         do_action( 'unspam_comment', $comment->comment_ID );
     1492        do_action( 'unspam_comment', $comment->comment_ID, $comment );
    14841493
    14851494        $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
    14861495        if ( empty($status) )
    function wp_unspam_comment( $comment_id ) { 
    14951504                 * @since 2.9.0
    14961505                 *
    14971506                 * @param int $comment_id The comment ID.
     1507                 * @param WP_Comment $comment The comment unmarked as spam.
    14981508                 */
    1499                 do_action( 'unspammed_comment', $comment->comment_ID );
     1509                do_action( 'unspammed_comment', $comment->comment_ID, $comment );
    15001510                return true;
    15011511        }
    15021512