WordPress.org

Making WordPress.org

Changeset 5673


Ignore:
Timestamp:
07/15/2017 11:11:22 PM (12 months ago)
Author:
SergeyBiryukov
Message:

Support Forums: Update topic meta on trashing/untrashing, deleting, spamming/unspamming, and approving/unapproving a reply.

See #2043.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-dropin.php

    r3914 r5673  
    2626        remove_action( 'bbp_unapproved_reply', 'bbp_update_reply_walker' );
    2727
     28        add_action( 'bbp_trashed_reply',       array( $this, 'bbp_update_reply_walker' ) );
     29        add_action( 'bbp_untrashed_reply',     array( $this, 'bbp_update_reply_walker' ) );
     30        add_action( 'bbp_deleted_reply',       array( $this, 'bbp_update_reply_walker' ) );
     31        add_action( 'bbp_spammed_reply',       array( $this, 'bbp_update_reply_walker' ) );
     32        add_action( 'bbp_unspammed_reply',     array( $this, 'bbp_update_reply_walker' ) );
     33        add_action( 'bbp_approved_reply',      array( $this, 'bbp_update_reply_walker' ) );
     34        add_action( 'bbp_unapproved_reply',    array( $this, 'bbp_update_reply_walker' ) );
     35
    2836        // Avoid bbp_update_topic_walker().
    2937        remove_action( 'bbp_new_topic',  'bbp_update_topic' );
     
    4149            remove_filter( 'the_title', 'bbp_get_reply_title_fallback', 2 );
    4250        }
     51    }
     52
     53    /**
     54     * Handle only the necessary meta stuff from trashing/untrashing, deleting,
     55     * spamming/unspamming, and approving/unapproving a reply.
     56     *
     57     * @param int $reply_id Reply ID.
     58     */
     59    function bbp_update_reply_walker( $reply_id ) {
     60        // Get the topic ID
     61        $topic_id = bbp_get_reply_topic_id( $reply_id );
     62
     63        // Make every effort to get topic id
     64        // https://bbpress.trac.wordpress.org/ticket/2529
     65        if ( empty( $topic_id ) && ( current_filter() === 'bbp_deleted_reply' ) ) {
     66            $topic_id = get_post_field( 'post_parent', $reply_id );
     67        }
     68
     69        // Last reply and active ID's
     70        bbp_update_topic_last_reply_id( $topic_id );
     71        bbp_update_topic_last_active_id( $topic_id );
     72
     73        // Get the last active time
     74        bbp_update_topic_last_active_time( $topic_id );
     75
     76        // Counts
     77        bbp_update_topic_voice_count( $topic_id );
    4378    }
    4479
Note: See TracChangeset for help on using the changeset viewer.