Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/10/2013 07:17:14 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Introduce bbp_repair_forum_visibility() and use it:

  • when creating a new BuddyPress Group Forum
  • in the bbp_admin_repair_forum_visibility() tool

Fixes issues with new group forums not bumping the private/hidden forum ID's. Props r-a-y. Fixes #2349.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/tools.php

    r5002 r5017  
    9191
    9292    foreach ( (array) bbp_admin_repair_list() as $item ) {
    93         if ( isset( $item[2] ) && isset( $_POST[$item[0]] ) && 1 === $_POST[$item[0]] && is_callable( $item[2] ) ) {
     93        if ( isset( $item[2] ) && isset( $_POST[$item[0]] ) && 1 === absint( $_POST[$item[0]] ) && is_callable( $item[2] ) ) {
    9494            $messages[] = call_user_func( $item[2] );
    9595        }
     
    938938 */
    939939function bbp_admin_repair_forum_visibility() {
    940 
    941940    $statement = __( 'Recalculating forum visibility … %s', 'bbpress' );
    942     $result    = __( 'Failed!', 'bbpress' );
    943 
    944     // First, delete everything.
    945     delete_option( '_bbp_private_forums' );
    946     delete_option( '_bbp_hidden_forums'  );
    947 
    948     // Next, get all the private and hidden forums
    949     $private_forums = new WP_Query( array(
    950         'suppress_filters' => true,
    951         'nopaging'         => true,
    952         'post_type'        => bbp_get_forum_post_type(),
    953         'post_status'      => bbp_get_private_status_id(),
    954         'fields'           => 'ids'
    955     ) );
    956     $hidden_forums = new WP_Query( array(
    957         'suppress_filters' => true,
    958         'nopaging'         => true,
    959         'post_type'        => bbp_get_forum_post_type(),
    960         'post_status'      => bbp_get_hidden_status_id(),
    961         'fields'           => 'ids'
    962     ) );
    963941
    964942    // Bail if queries returned errors
    965     if ( is_wp_error( $private_forums ) || is_wp_error( $hidden_forums ) )
    966         return array( 2, sprintf( $statement, $result ) );
    967 
    968     update_option( '_bbp_private_forums', $private_forums->posts ); // Private forums
    969     update_option( '_bbp_hidden_forums',  $hidden_forums->posts  ); // Hidden forums
    970 
    971     // Reset the $post global
    972     wp_reset_postdata();
     943    if ( ! bbp_repair_forum_visibility() ) {
     944        return array( 2, sprintf( $statement, __( 'Failed!',   'bbpress' ) ) );
    973945
    974946    // Complete results
    975     return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );
     947    } else {
     948        return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );
     949    }
    976950}
    977951
Note: See TracChangeset for help on using the changeset viewer.