Skip to:
Content

BuddyPress.org

Changeset 12228


Ignore:
Timestamp:
09/07/2018 03:06:03 PM (7 years ago)
Author:
djpaul
Message:

Templates, Nouveau: fix group type default selection during group creation.

Nouveau shares the group settings options output with the create output. This
change moves the checked logic out of that relevant template, into a function,
to correct handle the default value for group creation vs. later group editing.

Fixes #7919

Props wbcomdesigns, r-a-y

Location:
trunk/src/bp-templates/bp-nouveau
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/buddypress/groups/single/admin/group-settings.php

    r12156 r12228  
    7272            <div class="checkbox">
    7373                <label for="<?php printf( 'group-type-%s', $type->name ); ?>">
    74                     <input type="checkbox" name="group-types[]" id="<?php printf( 'group-type-%s', $type->name ); ?>" value="<?php echo esc_attr( $type->name ); ?>" <?php checked( bp_groups_has_group_type( bp_get_current_group_id(), $type->name ) ); ?>/> <?php echo esc_html( $type->labels['name'] ); ?>
     74                    <input type="checkbox" name="group-types[]" id="<?php printf( 'group-type-%s', $type->name ); ?>" value="<?php echo esc_attr( $type->name ); ?>" <?php bp_nouveau_group_type_checked( $type ); ?>/> <?php echo esc_html( $type->labels['name'] ); ?>
    7575                    <?php
    7676                    if ( ! empty( $type->description ) ) {
  • trunk/src/bp-templates/bp-nouveau/includes/groups/template-tags.php

    r12215 r12228  
    13691369    return apply_filters( 'bp_nouveau_get_group_description_excerpt', bp_create_excerpt( $group->description, $length ), $group );
    13701370}
     1371
     1372/**
     1373 * Output "checked" attribute to determine if the group type should be checked.
     1374 *
     1375 * @since 3.2.0
     1376 *
     1377 * @param object $type Group type object. See bp_groups_get_group_type_object().
     1378 */
     1379function bp_nouveau_group_type_checked( $type = null ) {
     1380    if ( ! is_object( $type ) ) {
     1381        return;
     1382    }
     1383
     1384    // Group creation screen requires a different check.
     1385    if ( bp_is_group_create() ) {
     1386        checked( true, ! empty( $type->create_screen_checked ) );
     1387    } elseif ( bp_is_group() ) {
     1388        checked( bp_groups_has_group_type( bp_get_current_group_id(), $type->name ) );
     1389    }
     1390}
Note: See TracChangeset for help on using the changeset viewer.