Skip to:
Content

BuddyPress.org

Changeset 5564


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

Location:
trunk
Files:
2 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>
  • 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.