Make WordPress Core


Ignore:
Timestamp:
10/02/2017 10:13:29 PM (9 years ago)
Author:
SergeyBiryukov
Message:

Comments: Pass $comment object to comment actions:

  • delete_comment
  • deleted_comment
  • trash_comment
  • trashed_comment
  • untrash_comment
  • untrashed_comment
  • spam_comment
  • spammed_comment
  • unspam_comment
  • unspammed_comment

Props henry.wright.
Fixes #41228.

File:
1 edited

Legend:

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

    r41686 r41689  
    12861286         *
    12871287         * @since 1.2.0
    1288          *
    1289          * @param int $comment_id The comment ID.
    1290          */
    1291         do_action( 'delete_comment', $comment->comment_ID );
     1288         * @since 4.9.0 Added the `$comment` parameter.
     1289         *
     1290         * @param int        $comment_id The comment ID.
     1291         * @param WP_Comment $comment    The comment to be deleted.
     1292         */
     1293        do_action( 'delete_comment', $comment->comment_ID, $comment );
    12921294
    12931295        // Move children up a level.
     
    13101312         *
    13111313         * @since 2.9.0
    1312          *
    1313          * @param int $comment_id The comment ID.
    1314          */
    1315         do_action( 'deleted_comment', $comment->comment_ID );
     1314         * @since 4.9.0 Added the `$comment` parameter.
     1315         *
     1316         * @param int        $comment_id The comment ID.
     1317         * @param WP_Comment $comment    The deleted comment.
     1318         */
     1319        do_action( 'deleted_comment', $comment->comment_ID, $comment );
    13161320
    13171321        $post_id = $comment->comment_post_ID;
     
    13491353         *
    13501354         * @since 2.9.0
    1351          *
    1352          * @param int $comment_id The comment ID.
    1353          */
    1354         do_action( 'trash_comment', $comment->comment_ID );
     1355         * @since 4.9.0 Added the `$comment` parameter.
     1356         *
     1357         * @param int        $comment_id The comment ID.
     1358         * @param WP_Comment $comment    The comment to be trashed.
     1359         */
     1360        do_action( 'trash_comment', $comment->comment_ID, $comment );
    13551361
    13561362        if ( wp_set_comment_status( $comment, 'trash' ) ) {
     
    13641370                 *
    13651371                 * @since 2.9.0
    1366                  *
    1367                  * @param int $comment_id The comment ID.
     1372                 * @since 4.9.0 Added the `$comment` parameter.
     1373                 *
     1374                 * @param int        $comment_id The comment ID.
     1375                 * @param WP_Comment $comment    The trashed comment.
    13681376                 */
    1369                 do_action( 'trashed_comment', $comment->comment_ID );
     1377                do_action( 'trashed_comment', $comment->comment_ID, $comment );
    13701378                return true;
    13711379        }
     
    13921400         *
    13931401         * @since 2.9.0
    1394          *
    1395          * @param int $comment_id The comment ID.
    1396          */
    1397         do_action( 'untrash_comment', $comment->comment_ID );
     1402         * @since 4.9.0 Added the `$comment` parameter.
     1403         *
     1404         * @param int        $comment_id The comment ID.
     1405         * @param WP_Comment $comment    The comment to be untrashed.
     1406         */
     1407        do_action( 'untrash_comment', $comment->comment_ID, $comment );
    13981408
    13991409        $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
     
    14081418                 *
    14091419                 * @since 2.9.0
    1410                  *
    1411                  * @param int $comment_id The comment ID.
     1420                 * @since 4.9.0 Added the `$comment` parameter.
     1421                 *
     1422                 * @param int        $comment_id The comment ID.
     1423                 * @param WP_Comment $comment    The untrashed comment.
    14121424                 */
    1413                 do_action( 'untrashed_comment', $comment->comment_ID );
     1425                do_action( 'untrashed_comment', $comment->comment_ID, $comment );
    14141426                return true;
    14151427        }
     
    14361448         *
    14371449         * @since 2.9.0
    1438          *
    1439          * @param int $comment_id The comment ID.
    1440          */
    1441         do_action( 'spam_comment', $comment->comment_ID );
     1450         * @since 4.9.0 Added the `$comment` parameter.
     1451         *
     1452         * @param int        $comment_id The comment ID.
     1453         * @param WP_Comment $comment    The comment to be marked as spam.
     1454         */
     1455        do_action( 'spam_comment', $comment->comment_ID, $comment );
    14421456
    14431457        if ( wp_set_comment_status( $comment, 'spam' ) ) {
     
    14501464                 *
    14511465                 * @since 2.9.0
    1452                  *
    1453                  * @param int $comment_id The comment ID.
     1466                 * @since 4.9.0 Added the `$comment` parameter.
     1467                 *
     1468                 * @param int        $comment_id The comment ID.
     1469                 * @param WP_Comment $comment    The comment marked as spam.
    14541470                 */
    1455                 do_action( 'spammed_comment', $comment->comment_ID );
     1471                do_action( 'spammed_comment', $comment->comment_ID, $comment );
    14561472                return true;
    14571473        }
     
    14781494         *
    14791495         * @since 2.9.0
    1480          *
    1481          * @param int $comment_id The comment ID.
    1482          */
    1483         do_action( 'unspam_comment', $comment->comment_ID );
     1496         * @since 4.9.0 Added the `$comment` parameter.
     1497         *
     1498         * @param int        $comment_id The comment ID.
     1499         * @param WP_Comment $comment    The comment to be unmarked as spam.
     1500         */
     1501        do_action( 'unspam_comment', $comment->comment_ID, $comment );
    14841502
    14851503        $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
     
    14941512                 *
    14951513                 * @since 2.9.0
    1496                  *
    1497                  * @param int $comment_id The comment ID.
     1514                 * @since 4.9.0 Added the `$comment` parameter.
     1515                 *
     1516                 * @param int        $comment_id The comment ID.
     1517                 * @param WP_Comment $comment    The comment unmarked as spam.
    14981518                 */
    1499                 do_action( 'unspammed_comment', $comment->comment_ID );
     1519                do_action( 'unspammed_comment', $comment->comment_ID, $comment );
    15001520                return true;
    15011521        }
Note: See TracChangeset for help on using the changeset viewer.