Skip to:
Content

bbPress.org

Ticket #2653: 2653.diff

File 2653.diff, 1.9 KB (added by netweb, 11 years ago)
  • src/includes/topics/functions.php

     
    330330
    331331        if ( !empty( $topic_id ) && !is_wp_error( $topic_id ) ) {
    332332
     333                /** Close Check *******************************************************/
     334
     335                // If the topic is closed, close it properly
     336                if ( ( get_post_field( 'post_status', $topic_id ) === bbp_get_closed_status_id() ) || ( $topic_data['post_status'] === bbp_get_closed_status_id() ) ) {
     337
     338                        // Close the topic
     339                        bbp_close_topic( $topic_id );
     340                }
     341
    333342                /** Trash Check *******************************************************/
    334343
    335344                // If the forum is trash, or the topic_status is switched to
     
    27082717 *
    27092718 * @param int $topic_id Topic id
    27102719 * @uses bbp_get_topic() To get the topic
     2720 * @uses get_post_meta() To get the topic status meta
    27112721 * @uses do_action() Calls 'bbp_close_topic' with the topic id
    27122722 * @uses add_post_meta() To add the previous status to a meta
    27132723 * @uses wp_update_post() To update the topic with the new status
     
    27222732                return $topic;
    27232733        }
    27242734
    2725         // Bail if already closed
    2726         if ( bbp_get_closed_status_id() === $topic->post_status ) {
     2735        // Get previous topic status meta
     2736        $topic_status = get_post_meta( $topic_id, '_bbp_status', true );
     2737
     2738        // Bail if already closed and topic status meta exists
     2739        if ( bbp_get_closed_status_id() === $topic->post_status && ! empty( $topic_status ) ) {
    27272740                return false;
    27282741        }
    27292742
     2743        // Set status meta public
     2744        $topic_status = bbp_get_public_status_id();
     2745
    27302746        // Execute pre close code
    27312747        do_action( 'bbp_close_topic', $topic_id );
    27322748
    27332749        // Add pre close status
    2734         add_post_meta( $topic_id, '_bbp_status', $topic->post_status );
     2750        add_post_meta( $topic_id, '_bbp_status', $topic_status );
    27352751
    27362752        // Set closed status
    27372753        $topic->post_status = bbp_get_closed_status_id();