BP_Groups_Widget::form( array $instance )

Extends our form method.

Description

Parameters

$instance

(Required) Current instance.

Return

(mixed)

Source

File: bp-groups/classes/class-bp-groups-widget.php

217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
public function form( $instance ) {
    $defaults = array(
        'title'         => __( 'Groups', 'buddyboss' ),
        'max_groups'    => 5,
        'group_default' => 'active',
        'link_title'    => false
    );
    $instance = bp_parse_args( (array) $instance, $defaults, 'groups_widget_form' );
 
    $title         = strip_tags( $instance['title'] );
    $max_groups    = strip_tags( $instance['max_groups'] );
    $group_default = strip_tags( $instance['group_default'] );
    $link_title    = (bool) $instance['link_title'];
    ?>
 
    <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'buddyboss'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" style="width: 100%" /></label></p>
 
    <p><label for="<?php echo $this->get_field_id('link_title') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('link_title') ?>" id="<?php echo $this->get_field_id('link_title') ?>" value="1" <?php checked( $link_title ) ?> /> <?php _e( 'Link widget title to Groups directory', 'buddyboss' ) ?></label></p>
 
    <p><label for="<?php echo $this->get_field_id( 'max_groups' ); ?>"><?php _e('Max groups to show:', 'buddyboss'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="text" value="<?php echo esc_attr( $max_groups ); ?>" style="width: 30%" /></label></p>
 
    <p>
        <label for="<?php echo $this->get_field_id( 'group_default' ); ?>"><?php _e('Default groups to show:', 'buddyboss'); ?></label>
        <select name="<?php echo $this->get_field_name( 'group_default' ); ?>" id="<?php echo $this->get_field_id( 'group_default' ); ?>">
            <option value="newest" <?php selected( $group_default, 'newest' ); ?>><?php _e( 'Newest', 'buddyboss' ) ?></option>
            <option value="active" <?php selected( $group_default, 'active' ); ?>><?php _e( 'Active', 'buddyboss' ) ?></option>
            <option value="popular"  <?php selected( $group_default, 'popular' ); ?>><?php _e( 'Popular', 'buddyboss' ) ?></option>
        </select>
    </p>
<?php
}

Changelog

Changelog
Version Description
BuddyPress 1.0.3 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.