コード例 #1
0
ファイル: functions.php プロジェクト: dcavins/buddypress-svn
 /**
  * @group xprofile_update_field_group_position
  * @group bp_profile_get_field_groups
  */
 public function test_bp_profile_get_field_groups_update_position()
 {
     $g1 = $this->factory->xprofile_group->create();
     $g2 = $this->factory->xprofile_group->create();
     $g3 = $this->factory->xprofile_group->create();
     // prime the cache
     bp_profile_get_field_groups();
     // switch the field group positions for the last two groups
     xprofile_update_field_group_position($g2, 3);
     xprofile_update_field_group_position($g3, 2);
     // now refetch field groups
     $field_groups = bp_profile_get_field_groups();
     // assert!
     $this->assertEquals(array(1, $g1, $g3, $g2), wp_list_pluck($field_groups, 'id'));
 }
コード例 #2
0
ファイル: bp-xprofile-template.php プロジェクト: eresyyl/mk
/**
 * Output the tabs to switch between profile field groups.
 *
 * @return string Field group tabs markup.
 */
function bp_profile_group_tabs()
{
    global $bp, $group_name;
    $groups = bp_profile_get_field_groups();
    if (empty($group_name)) {
        $group_name = bp_profile_group_name(false);
    }
    $tabs = array();
    for ($i = 0, $count = count($groups); $i < $count; ++$i) {
        if ($group_name == $groups[$i]->name) {
            $selected = ' class="current"';
        } else {
            $selected = '';
        }
        if (!empty($groups[$i]->fields)) {
            $link = trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . $groups[$i]->id);
            $tabs[] = sprintf('<li %1$s><a href="%2$s">%3$s</a></li>', $selected, $link, esc_html($groups[$i]->name));
        }
    }
    $tabs = apply_filters('xprofile_filter_profile_group_tabs', $tabs, $groups, $group_name);
    foreach ((array) $tabs as $tab) {
        echo $tab;
    }
    do_action('xprofile_profile_group_tabs');
}
コード例 #3
0
/**
 * Return the XProfile group tabs.
 *
 * @since 2.3.0
 *
 * @return string
 */
function bp_get_profile_group_tabs()
{
    // Get field group data.
    $groups = bp_profile_get_field_groups();
    $group_name = bp_get_profile_group_name();
    $tabs = array();
    // Loop through field groups and put a tab-lst together.
    for ($i = 0, $count = count($groups); $i < $count; ++$i) {
        // Setup the selected class.
        $selected = '';
        if ($group_name === $groups[$i]->name) {
            $selected = ' class="current"';
        }
        // Skip if group has no fields.
        if (empty($groups[$i]->fields)) {
            continue;
        }
        // Build the profile field group link.
        $link = trailingslashit(bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . $groups[$i]->id);
        // Add tab to end of tabs array.
        $tabs[] = sprintf('<li %1$s><a href="%2$s">%3$s</a></li>', $selected, esc_url($link), esc_html(apply_filters('bp_get_the_profile_group_name', $groups[$i]->name)));
    }
    /**
     * Filters the tabs to display for profile field groups.
     *
     * @since 1.5.0
     *
     * @param array  $tabs       Array of tabs to display.
     * @param array  $groups     Array of profile groups.
     * @param string $group_name Name of the current group displayed.
     */
    $tabs = apply_filters('xprofile_filter_profile_group_tabs', $tabs, $groups, $group_name);
    return join('', $tabs);
}
コード例 #4
0
/**
 * Output the tabs to switch between profile field groups.
 *
 * @return string Field group tabs markup.
 */
function bp_profile_group_tabs()
{
    global $bp, $group_name;
    $groups = bp_profile_get_field_groups();
    if (empty($group_name)) {
        $group_name = bp_profile_group_name(false);
    }
    $tabs = array();
    for ($i = 0, $count = count($groups); $i < $count; ++$i) {
        if ($group_name == $groups[$i]->name) {
            $selected = ' class="current"';
        } else {
            $selected = '';
        }
        if (!empty($groups[$i]->fields)) {
            $link = trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . $groups[$i]->id);
            $tabs[] = sprintf('<li %1$s><a href="%2$s">%3$s</a></li>', $selected, $link, esc_html($groups[$i]->name));
        }
    }
    /**
     * Filters the tabs to display for profile field groups.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param array  $tabs       Array of tabs to display.
     * @param array  $groups     Array of profile groups.
     * @param string $group_name Name of the current group displayed.
     */
    $tabs = apply_filters('xprofile_filter_profile_group_tabs', $tabs, $groups, $group_name);
    foreach ((array) $tabs as $tab) {
        echo $tab;
    }
    /**
     * Fires at the end of the tab output for switching between profile field groups.
     *
     * @since BuddyPress (1.0.0)
     */
    do_action('xprofile_profile_group_tabs');
}