Skip to:
Content

bbPress.org

Changeset 7057


Ignore:
Timestamp:
01/27/2020 11:36:04 PM (23 months ago)
Author:
johnjamesjacoby
Message:

BuddyPress: explicitly query for Group forum IDs, for topic parent dropdown.

This commit fixes an ambiguity regarding which forum IDs should/may appear when editing a Forum Topic inside a Group Forum. By being explicit here, a possible bug can be avoided where incorrect forum IDs could be listed.

Props imath. For 2.7, trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/extend/buddypress/groups.php

    r7006 r7057  
    716716        $forum_ids = bbp_get_group_forum_ids( $group_id );
    717717
    718         // Use the first forum ID
     718        // Bail if no forum IDs available
    719719        if ( empty( $forum_ids ) ) {
    720720            return;
     
    11641164
    11651165    /**
    1166      * Prevent Forum Parent from appearing
     1166     * Make Forum Parent a hidden field instead of a selectable one.
    11671167     *
    11681168     * @since 2.1.0 bbPress (r3746)
     
    11771177
    11781178    /**
    1179      * Prevent Topic Parent from appearing
     1179     * Output a dropdown for picking which group forum this topic is for.
    11801180     *
    11811181     * @since 2.1.0 bbPress (r3746)
     
    11831183    public function topic_parent() {
    11841184
    1185         $forum_ids = bbp_get_group_forum_ids( bp_get_current_group_id() ); ?>
     1185        // Get the group ID
     1186        $gid       = bp_get_current_group_id();
     1187
     1188        // Get the forum IDs for this group
     1189        $forum_ids = bbp_get_group_forum_ids( $gid );
     1190
     1191        // Attempt to get the current topic forum ID
     1192        $topic_id  = bbp_get_topic_id();
     1193        $forum_id  = bbp_get_topic_forum_id( $topic_id );
     1194
     1195        // Setup the query arguments - note that these may be overridden later
     1196        // by various bbPress visibility and capability filters.
     1197        $args = array(
     1198            'post_type'   => bbp_get_forum_post_type(),
     1199            'post_status' => bbp_get_public_status_id(),
     1200            'include'     => $forum_ids,
     1201            'numberposts' => -1,
     1202            'orderby'     => 'menu_order',
     1203            'order'       => 'ASC',
     1204        );
     1205
     1206        // Get the forum objects for these forum IDs
     1207        $forums = get_posts( $args );
     1208
     1209        // Setup the dropdown arguments
     1210        $dd_args = array(
     1211            'posts'    => $forums,
     1212            'selected' => $forum_id,
     1213        ); ?>
    11861214
    11871215        <p>
    11881216            <label for="bbp_forum_id"><?php esc_html_e( 'Forum:', 'bbpress' ); ?></label><br />
    1189             <?php bbp_dropdown( array( 'include' => $forum_ids, 'selected' => bbp_get_form_topic_forum() ) ); ?>
     1217            <?php bbp_dropdown( $dd_args ); ?>
    11901218        </p>
    11911219
Note: See TracChangeset for help on using the changeset viewer.