Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/21/2016 10:40:12 PM (7 years ago)
Author:
r-a-y
Message:

Groups: In bp_groups_register_group_type(), introduce new arguments for frontend integration.

This commit introduces the following $args parameters:

  • 'has_directory'
  • 'show_in_create_screen'
  • 'show_in_list'
  • 'description'

Read the inline documentation for full information. The Group Types codex
article will be updated to outline these parameters.

See #7210.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-functions.php

    r11142 r11144  
    21162116 *
    21172117 * @since 2.6.0
     2118 * @since 2.7.0 Introduce $has_directory, $show_in_create_screen, $show_in_list, and
     2119 *              $description as $args parameters.
    21182120 *
    21192121 * @param string $group_type Unique string identifier for the group type.
     
    21212123 *     Array of arguments describing the group type.
    21222124 *
    2123  *     @type array $labels {
     2125 *     @type string|bool $has_directory         Set the slug to be used for custom group directory page. eg.
     2126 *                                              example.com/groups/type/MY_SLUG. Default: false.
     2127 *     @type bool        $show_in_create_screen Whether this group type is allowed to be selected on the group creation
     2128 *                                              page. Default: false.
     2129 *     @type bool|null   $show_in_list          Whether this group type should be shown in lists rendered by
     2130 *                                              bp_group_type_list(). Default: null. If $show_in_create_screen is true,
     2131 *                                              this will default to true, unless this is set explicitly to false.
     2132 *     @type string      $description           A short descriptive summary of what the group type is. Currently shown
     2133 *                                              on a group's "Manage > Settings" page when selecting group types.
     2134 *     @type array       $labels {
    21242135 *         Array of labels to use in various parts of the interface.
    21252136 *
     
    21382149
    21392150    $r = bp_parse_args( $args, array(
    2140         'labels'        => array(),
     2151        'has_directory'         => false,
     2152        'show_in_create_screen' => false,
     2153        'show_in_list'          => null,
     2154        'description'           => '',
     2155        'labels'                => array(),
    21412156    ), 'register_group_type' );
    21422157
     
    21682183        'singular_name' => $default_name,
    21692184    ), $r['labels'] );
     2185
     2186    // Directory slug.
     2187    if ( ! empty( $r['has_directory'] ) ) {
     2188        // A string value is intepreted as the directory slug.
     2189        if ( is_string( $r['has_directory'] ) ) {
     2190            $directory_slug = $r['has_directory'];
     2191
     2192        // Otherwise fall back on group type.
     2193        } else {
     2194            $directory_slug = $group_type;
     2195        }
     2196
     2197        // Sanitize for use in URLs.
     2198        $r['directory_slug'] = sanitize_title( $directory_slug );
     2199        $r['has_directory']  = true;
     2200    } else {
     2201        $r['directory_slug'] = '';
     2202        $r['has_directory']  = false;
     2203    }
     2204
     2205    // Type lists.
     2206    if ( true === $r['show_in_create_screen'] && is_null( $r['show_in_list'] ) ) {
     2207        $r['show_in_list'] = true;
     2208    } else {
     2209        $r['show_in_list'] = (bool) $r['show_in_list'];
     2210    }
    21702211
    21712212    $bp->groups->types[ $group_type ] = $type = (object) $r;
Note: See TracChangeset for help on using the changeset viewer.