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-core/bp-core-widgets.php

    r5199 r5564  
    4040
    4141        echo $before_widget;
     42       
     43        $title = $instance['link_title'] ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) . '">' . $instance['title'] . '</a>' : $instance['title'];
     44       
    4245        echo $before_title
    43            . $instance['title']
     46           . $title
    4447           . $after_title; ?>
    4548
     
    99102    function update( $new_instance, $old_instance ) {
    100103        $instance = $old_instance;
    101         $instance['title'] = strip_tags( $new_instance['title'] );
    102         $instance['max_members'] = strip_tags( $new_instance['max_members'] );
     104       
     105        $instance['title']      = strip_tags( $new_instance['title'] );
     106        $instance['max_members']    = strip_tags( $new_instance['max_members'] );
    103107        $instance['member_default'] = strip_tags( $new_instance['member_default'] );
     108        $instance['link_title']     = (bool)$new_instance['link_title'];
    104109
    105110        return $instance;
     
    108113    function form( $instance ) {
    109114        $defaults = array(
    110             'title' => __( 'Members', 'buddypress' ),
    111             'max_members' => 5,
    112             'member_default' => 'active'
     115            'title'      => __( 'Members', 'buddypress' ),
     116            'max_members'    => 5,
     117            'member_default' => 'active',
     118            'link_title'     => false
    113119        );
    114120        $instance = wp_parse_args( (array) $instance, $defaults );
    115121
    116         $title = strip_tags( $instance['title'] );
    117         $max_members = strip_tags( $instance['max_members'] );
     122        $title      = strip_tags( $instance['title'] );
     123        $max_members    = strip_tags( $instance['max_members'] );
    118124        $member_default = strip_tags( $instance['member_default'] );
     125        $link_title = (bool)$instance['link_title'];
    119126        ?>
    120127
    121128        <p><label for="bp-core-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>
     129       
     130        <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 Members directory', 'buddypress' ) ?></label></p>
    122131
    123132        <p><label for="bp-core-widget-members-max"><?php _e('Max members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
Note: See TracChangeset for help on using the changeset viewer.