Skip to:
Content

bbPress.org

Changeset 6792


Ignore:
Timestamp:
03/29/2018 07:14:02 PM (4 years ago)
Author:
johnjamesjacoby
Message:

Counts: introduce sub-action for post status transitions.

We'll use this for micro-managing child post counts on a per-type, per-status basis.

See #1799.

Location:
trunk/src/includes/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/actions.php

    r6780 r6792  
    5454add_action( 'wp_head',                  'bbp_head',                   10    );
    5555add_action( 'wp_footer',                'bbp_footer',                 10    );
     56add_action( 'transition_post_status',   'bbp_transition_post_status', 10, 3 );
    5657
    5758/**
  • trunk/src/includes/core/sub-actions.php

    r6757 r6792  
    255255function bbp_login_form_login() {
    256256    do_action( 'bbp_login_form_login' );
     257}
     258
     259
     260/**
     261 * Add the bbPress-specific post status transition action
     262 *
     263 * @since 2.6.0 bbPress (r6792)
     264 *
     265 * @param string  $new_status New post status
     266 * @param string  $old_status Old post status
     267 * @param WP_Post $post       Post object
     268 */
     269function bbp_transition_post_status( $new_status = '', $old_status = '', $post = false ) {
     270
     271    // Get bbPress post types
     272    $post_type = get_post_type( $post );
     273    $types     = get_post_types( array( 'source' => 'bbpress' ) );
     274
     275    // Bail if post is not a bbPress post type
     276    if ( ! in_array( $post_type, $types, true ) ) {
     277        return;
     278    }
     279
     280    // Do the action
     281    do_action( 'bbp_transition_post_status', $new_status, $old_status, $post );
    257282}
    258283
Note: See TracChangeset for help on using the changeset viewer.