Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/17/2011 02:24:08 PM (13 years ago)
Author:
boonebgorges
Message:

Adds option to Groups and Members widgets allowing widget title to be linked to corresponding component directories. Fixes #3862

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-widgets.php

    r5199 r5564  
    4242
    4343        echo $before_widget;
     44       
     45        $title = $instance['link_title'] ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() ) . '">' . $instance['title'] . '</a>' : $instance['title'];
     46       
    4447        echo $before_title
    45            . $instance['title']
     48           . $title
    4649           . $after_title; ?>
    4750
     
    9699    function update( $new_instance, $old_instance ) {
    97100        $instance = $old_instance;
    98         $instance['title'] = strip_tags( $new_instance['title'] );
    99         $instance['max_groups'] = strip_tags( $new_instance['max_groups'] );
     101       
     102        $instance['title']         = strip_tags( $new_instance['title'] );
     103        $instance['max_groups']    = strip_tags( $new_instance['max_groups'] );
    100104        $instance['group_default'] = strip_tags( $new_instance['group_default'] );
     105        $instance['link_title']    = (bool)$new_instance['link_title'];
    101106
    102107        return $instance;
     
    107112            'title'         => __( 'Groups', 'buddypress' ),
    108113            'max_groups'    => 5,
    109             'group_default' => 'active'
     114            'group_default' => 'active',
     115            'link_title'    => false
    110116        );
    111117        $instance = wp_parse_args( (array) $instance, $defaults );
    112118
    113         $title = strip_tags( $instance['title'] );
    114         $max_groups = strip_tags( $instance['max_groups'] );
     119        $title         = strip_tags( $instance['title'] );
     120        $max_groups    = strip_tags( $instance['max_groups'] );
    115121        $group_default = strip_tags( $instance['group_default'] );
     122        $link_title    = (bool)$instance['link_title'];
    116123        ?>
    117124
    118125        <p><label for="bp-groups-widget-title"><?php _e('Title:', 'buddypress'); ?> <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>
     126       
     127        <p><label for="<?php echo $this->get_field_name('link_title') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('link_title') ?>" value="1" <?php checked( $link_title ) ?> /> <?php _e( 'Link widget title to Groups directory', 'buddypress' ) ?></label></p>
    119128
    120129        <p><label for="bp-groups-widget-groups-max"><?php _e('Max groups to show:', 'buddypress'); ?> <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>
Note: See TracChangeset for help on using the changeset viewer.