git-svn-id: https://192.168.0.254/svn/Proyectos.ASong2U_Web/trunk@23 cd1a4ea2-8c7f-e448-aada-19d1fee9e1d6
93 lines
2.8 KiB
PHP
93 lines
2.8 KiB
PHP
<?php
|
|
/*
|
|
Plugin Name: My Groups Widget
|
|
Description:
|
|
Version:
|
|
Revision Date:
|
|
Requires at least: BuddyPress 1.1
|
|
Tested up to: BuddyPress 1.2.2.1
|
|
License:
|
|
Author:
|
|
Author URI:
|
|
*/
|
|
|
|
|
|
/* Register widgets for groups component */
|
|
function my_groups_register_widgets() {
|
|
add_action('widgets_init', create_function('', 'return register_widget("BP_My_Groups_Widget");') );
|
|
}
|
|
add_action( 'bp_register_widgets', 'my_groups_register_widgets' );
|
|
|
|
/*** GROUPS WIDGET *****************/
|
|
|
|
class BP_My_Groups_Widget extends WP_Widget {
|
|
function bp_my_groups_widget() {
|
|
parent::WP_Widget( false, $name = __( 'My Groups', 'buddypress' ) );
|
|
}
|
|
|
|
function widget($args, $instance) {
|
|
global $bp;
|
|
|
|
extract( $args );
|
|
$title = apply_filters('widget_title', empty($instance['title'])?__('My Groups','buddypress'):$instance['title']);
|
|
|
|
echo $before_widget;
|
|
echo $before_title
|
|
. $title
|
|
. $after_title; ?>
|
|
|
|
<?php if ( bp_has_groups( 'type=alphabetical&user_id=' . $bp->loggedin_user->id )&& is_user_logged_in()) : ?>
|
|
|
|
<ul class="my-groups-list item-list">
|
|
<?php while ( bp_groups() ) : bp_the_group(); ?>
|
|
<li>
|
|
<?php /*
|
|
<div class="item-avatar">
|
|
<a href="<?php bp_group_permalink(); ?>">< ? php bp_group_avatar_mini(); ? ></a>
|
|
</div>*/
|
|
?>
|
|
|
|
<div class="item">
|
|
<div class="item-title"><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></div>
|
|
<?php /*<div class="item-meta"><span class="activity">< ? php bp_group_member_count() ? ></span></div>*/ ?>
|
|
</div>
|
|
</li>
|
|
|
|
<?php endwhile; ?>
|
|
</ul>
|
|
<?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
|
|
<input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />
|
|
|
|
<?php else: ?>
|
|
|
|
<div class="widget-error">
|
|
<?php if( is_user_logged_in() ) {
|
|
_e('You have not joined any groups.','buddypress');
|
|
} else {
|
|
_e('Please log in to see your groups.', 'buddypress');
|
|
} ?>
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php echo $after_widget; ?>
|
|
<?php
|
|
}
|
|
|
|
function update( $new_instance, $old_instance ) {
|
|
$instance = $old_instance;
|
|
$instance['title'] = strip_tags( $new_instance['title'] );
|
|
|
|
return $instance;
|
|
}
|
|
|
|
function form( $instance ) {
|
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
|
|
$title = esc_attr( $instance['title'] );
|
|
?>
|
|
|
|
<p><label><?php _e('Title:','buddypress'); ?></label><input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
|
|
<?php
|
|
}
|
|
}
|