Skip to:
Content

BuddyPress.org

Changeset 8688


Ignore:
Timestamp:
07/24/2014 01:29:00 AM (10 years ago)
Author:
boonebgorges
Message:

Only show the xprofile field group tabs in edit mode if there is more than one field group.

Fixes #5714

Props imath, jreeve

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-legacy/buddypress/members/single/profile/edit.php

    r8178 r8688  
    1010        <h4><?php printf( __( "Editing '%s' Profile Group", "buddypress" ), bp_get_the_profile_group_name() ); ?></h4>
    1111
    12         <ul class="button-nav">
     12        <?php if ( bp_profile_has_multiple_groups() ) : ?>
     13            <ul class="button-nav">
    1314
    14             <?php bp_profile_group_tabs(); ?>
     15                <?php bp_profile_group_tabs(); ?>
    1516
    16         </ul>
     17            </ul>
     18        <?php endif ;?>
    1719
    1820        <div class="clear"></div>
  • trunk/src/bp-xprofile/bp-xprofile-template.php

    r8677 r8688  
    590590    }
    591591
     592/**
     593 * Get all profile field groups.
     594 *
     595 * @since  BuddyPress (2.1.0)
     596 *
     597 * @return object $groups
     598 */
     599function bp_profile_get_field_groups() {
     600    $groups = wp_cache_get( 'xprofile_groups_inc_empty', 'bp' );
     601
     602    if ( empty( $groups ) ) {
     603        $groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
     604        wp_cache_set( 'xprofile_groups_inc_empty', $groups, 'bp' );
     605    }
     606
     607    return apply_filters( 'bp_profile_get_field_groups', $groups );
     608}
     609
     610/**
     611 * Check if there is more than one group of fields for the profile being edited.
     612 *
     613 * @since  BuddyPress (2.1.0)
     614 *
     615 * @return bool True if there is more than one profile field group.
     616 */
     617function bp_profile_has_multiple_groups() {
     618    $has_multiple_groups = count( (array) bp_profile_get_field_groups() ) > 1;
     619    return (bool) apply_filters( 'bp_profile_has_multiple_groups', $has_multiple_groups );
     620}
     621
     622/**
     623 * Output the tabs to switch between profile field groups.
     624 *
     625 * @return string Field group tabs markup.
     626 */
    592627function bp_profile_group_tabs() {
    593628    global $bp, $group_name;
    594629
    595     if ( !$groups = wp_cache_get( 'xprofile_groups_inc_empty', 'bp' ) ) {
    596         $groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
    597         wp_cache_set( 'xprofile_groups_inc_empty', $groups, 'bp' );
    598     }
     630    $groups = bp_profile_get_field_groups();
    599631
    600632    if ( empty( $group_name ) )
Note: See TracChangeset for help on using the changeset viewer.