Skip to:
Content

bbPress.org

Ticket #2647: 2647.diff

File 2647.diff, 2.6 KB (added by netweb, 11 years ago)
  • src/includes/forums/functions.php

     
    631631
    632632        /** Forum Status ******************************************************/
    633633
    634         if ( !empty( $_POST['bbp_forum_status'] ) && in_array( $_POST['bbp_forum_status'], array( 'open', 'closed' ) ) ) {
    635                 if ( 'closed' === $_POST['bbp_forum_status'] && !bbp_is_forum_closed( $forum_id, false ) ) {
     634        if ( ! empty( $_POST['bbp_forum_status'] ) && in_array( $_POST['bbp_forum_status'], array( 'open', 'closed' ) ) ) {
     635                if ( 'closed' === $_POST['bbp_forum_status'] && ! bbp_is_forum_closed( $forum_id, false ) ) {
    636636                        bbp_close_forum( $forum_id );
     637                } elseif ( 'open' === $_POST['bbp_forum_status'] && bbp_is_forum_open( $forum_id, false ) ) {
     638                        bbp_open_forum( $forum_id );
    637639                } elseif ( 'open' === $_POST['bbp_forum_status'] && bbp_is_forum_closed( $forum_id, false ) ) {
    638640                        bbp_open_forum( $forum_id );
    639641                }
     
    641643
    642644        /** Forum Type ********************************************************/
    643645
    644         if ( !empty( $_POST['bbp_forum_type'] ) && in_array( $_POST['bbp_forum_type'], array( 'forum', 'category' ) ) ) {
    645                 if ( 'category' === $_POST['bbp_forum_type'] && !bbp_is_forum_category( $forum_id ) ) {
     646        if ( ! empty( $_POST['bbp_forum_type'] ) && in_array( $_POST['bbp_forum_type'], array( 'forum', 'category' ) ) ) {
     647                if ( 'category' === $_POST['bbp_forum_type'] && ! bbp_is_forum_category( $forum_id ) ) {
    646648                        bbp_categorize_forum( $forum_id );
     649                } elseif ( 'forum' === $_POST['bbp_forum_type'] && ! bbp_is_forum_category( $forum_id ) ) {
     650                        bbp_normalize_forum( $forum_id );
    647651                } elseif ( 'forum' === $_POST['bbp_forum_type'] && bbp_is_forum_category( $forum_id ) ) {
    648652                        bbp_normalize_forum( $forum_id );
    649653                }
     
    949953        // First, delete everything.
    950954        delete_option( '_bbp_private_forums' );
    951955        delete_option( '_bbp_hidden_forums'  );
    952        
     956
    953957        /**
    954958         * Don't search for both private/hidden statuses. Since 'pre_get_posts' is an
    955          * action, it's not removed by suppress_filters. We need to make sure that 
     959         * action, it's not removed by suppress_filters. We need to make sure that
    956960         * we're only searching for the supplied post_status.
    957961         *
    958962         * @see https://bbpress.trac.wordpress.org/ticket/2512
     
    974978                'post_status'      => bbp_get_hidden_status_id(),
    975979                'fields'           => 'ids'
    976980        ) );
    977        
     981
    978982        // Enable forum visibilty normalization
    979983        add_action( 'pre_get_posts', 'bbp_pre_get_posts_normalize_forum_visibility', 4 );
    980984