Skip to:
Content

BuddyPress.org

Changeset 9323


Ignore:
Timestamp:
01/09/2015 01:37:37 AM (6 years ago)
Author:
r-a-y
Message:

Members: Move member-related widgets over from Core.

Also adds PHPDoc @since tag to related classes and functions.

Props dcavins.

See #5953.

Location:
trunk/src
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-widgets.php

    r8680 r9323  
    1212/**
    1313 * Register bp-core widgets.
     14 *
     15 * @since BuddyPress (1.0.0)
    1416 */
    1517function bp_core_register_widgets() {
    1618    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Login_Widget");') );
    17     add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
    18     add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
    19     add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
    2019}
    2120add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
     
    138137    }
    139138}
    140 
    141 /**
    142  * Members Widget.
    143  */
    144 class BP_Core_Members_Widget extends WP_Widget {
    145 
    146     /**
    147      * Constructor method.
    148      */
    149     function __construct() {
    150         $widget_ops = array(
    151             'description' => __( 'A dynamic list of recently active, popular, and newest members', 'buddypress' ),
    152             'classname' => 'widget_bp_core_members_widget buddypress widget',
    153         );
    154         parent::__construct( false, $name = _x( '(BuddyPress) Members', 'widget name', 'buddypress' ), $widget_ops );
    155 
    156         if ( is_active_widget( false, false, $this->id_base ) && !is_admin() && !is_network_admin() ) {
    157             wp_enqueue_script( 'bp-widget-members' );
    158         }
    159     }
    160 
    161     /**
    162      * Display the Members widget.
    163      *
    164      * @see WP_Widget::widget() for description of parameters.
    165      *
    166      * @param array $args Widget arguments.
    167      * @param array $instance Widget settings, as saved by the user.
    168      */
    169     function widget( $args, $instance ) {
    170 
    171         extract( $args );
    172 
    173         if ( !$instance['member_default'] )
    174             $instance['member_default'] = 'active';
    175 
    176         $title = apply_filters( 'widget_title', $instance['title'] );
    177 
    178         echo $before_widget;
    179 
    180         $title = $instance['link_title'] ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) . '">' . $title . '</a>' : $title;
    181 
    182         echo $before_title
    183            . $title
    184            . $after_title;
    185 
    186         $members_args = array(
    187             'user_id'         => 0,
    188             'type'            => $instance['member_default'],
    189             'per_page'        => $instance['max_members'],
    190             'max'             => $instance['max_members'],
    191             'populate_extras' => true,
    192             'search_terms'    => false,
    193         );
    194 
    195         ?>
    196 
    197         <?php if ( bp_has_members( $members_args ) ) : ?>
    198             <div class="item-options" id="members-list-options">
    199                 <a href="<?php bp_members_directory_permalink(); ?>" id="newest-members" <?php if ( $instance['member_default'] == 'newest' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Newest', 'buddypress' ) ?></a>
    200                 |  <a href="<?php bp_members_directory_permalink(); ?>" id="recently-active-members" <?php if ( $instance['member_default'] == 'active' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Active', 'buddypress' ) ?></a>
    201 
    202                 <?php if ( bp_is_active( 'friends' ) ) : ?>
    203 
    204                     | <a href="<?php bp_members_directory_permalink(); ?>" id="popular-members" <?php if ( $instance['member_default'] == 'popular' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Popular', 'buddypress' ) ?></a>
    205 
    206                 <?php endif; ?>
    207             </div>
    208 
    209             <ul id="members-list" class="item-list">
    210                 <?php while ( bp_members() ) : bp_the_member(); ?>
    211                     <li class="vcard">
    212                         <div class="item-avatar">
    213                             <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
    214                         </div>
    215 
    216                         <div class="item">
    217                             <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
    218                             <div class="item-meta">
    219                                 <span class="activity">
    220                                 <?php
    221                                     if ( 'newest' == $instance['member_default'] )
    222                                         bp_member_registered();
    223                                     if ( 'active' == $instance['member_default'] )
    224                                         bp_member_last_active();
    225                                     if ( 'popular' == $instance['member_default'] )
    226                                         bp_member_total_friend_count();
    227                                 ?>
    228                                 </span>
    229                             </div>
    230                         </div>
    231                     </li>
    232 
    233                 <?php endwhile; ?>
    234             </ul>
    235             <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?>
    236             <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr( $instance['max_members'] ); ?>" />
    237 
    238         <?php else: ?>
    239 
    240             <div class="widget-error">
    241                 <?php _e('No one has signed up yet!', 'buddypress') ?>
    242             </div>
    243 
    244         <?php endif; ?>
    245 
    246         <?php echo $after_widget; ?>
    247     <?php
    248     }
    249 
    250     /**
    251      * Update the Members widget options.
    252      *
    253      * @param array $new_instance The new instance options.
    254      * @param array $old_instance The old instance options.
    255      * @return array $instance The parsed options to be saved.
    256      */
    257     function update( $new_instance, $old_instance ) {
    258         $instance = $old_instance;
    259 
    260         $instance['title']      = strip_tags( $new_instance['title'] );
    261         $instance['max_members']    = strip_tags( $new_instance['max_members'] );
    262         $instance['member_default'] = strip_tags( $new_instance['member_default'] );
    263         $instance['link_title']     = (bool)$new_instance['link_title'];
    264 
    265         return $instance;
    266     }
    267 
    268     /**
    269      * Output the Members widget options form.
    270      *
    271      * @param $instance Settings for this widget.
    272      */
    273     function form( $instance ) {
    274         $defaults = array(
    275             'title'      => __( 'Members', 'buddypress' ),
    276             'max_members'    => 5,
    277             'member_default' => 'active',
    278             'link_title'     => false
    279         );
    280         $instance = wp_parse_args( (array) $instance, $defaults );
    281 
    282         $title      = strip_tags( $instance['title'] );
    283         $max_members    = strip_tags( $instance['max_members'] );
    284         $member_default = strip_tags( $instance['member_default'] );
    285         $link_title = (bool)$instance['link_title'];
    286         ?>
    287 
    288         <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>
    289 
    290         <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>
    291 
    292         <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>
    293 
    294         <p>
    295             <label for="bp-core-widget-groups-default"><?php _e('Default members to show:', 'buddypress'); ?>
    296             <select name="<?php echo $this->get_field_name( 'member_default' ) ?>">
    297                 <option value="newest" <?php if ( $member_default == 'newest' ) : ?>selected="selected"<?php endif; ?>><?php _e( 'Newest', 'buddypress' ) ?></option>
    298                 <option value="active" <?php if ( $member_default == 'active' ) : ?>selected="selected"<?php endif; ?>><?php _e( 'Active', 'buddypress' ) ?></option>
    299                 <option value="popular"  <?php if ( $member_default == 'popular' ) : ?>selected="selected"<?php endif; ?>><?php _e( 'Popular', 'buddypress' ) ?></option>
    300             </select>
    301             </label>
    302         </p>
    303 
    304     <?php
    305     }
    306 }
    307 
    308 /*** WHO'S ONLINE WIDGET *****************/
    309 
    310 class BP_Core_Whos_Online_Widget extends WP_Widget {
    311 
    312     /**
    313      * Constructor method.
    314      */
    315     function __construct() {
    316         $widget_ops = array(
    317             'description' => __( 'Profile photos of online users', 'buddypress' ),
    318             'classname' => 'widget_bp_core_whos_online_widget buddypress widget',
    319         );
    320         parent::__construct( false, $name = _x( "(BuddyPress) Who's Online", 'widget name', 'buddypress' ), $widget_ops );
    321     }
    322 
    323     /**
    324      * Display the Who's Online widget.
    325      *
    326      * @see WP_Widget::widget() for description of parameters.
    327      *
    328      * @param array $args Widget arguments.
    329      * @param array $instance Widget settings, as saved by the user.
    330      */
    331     function widget($args, $instance) {
    332 
    333         extract( $args );
    334 
    335         $title = apply_filters( 'widget_title', $instance['title'] );
    336 
    337         echo $before_widget;
    338         echo $before_title
    339            . $title
    340            . $after_title;
    341 
    342         $members_args = array(
    343             'user_id'         => 0,
    344             'type'            => 'online',
    345             'per_page'        => $instance['max_members'],
    346             'max'             => $instance['max_members'],
    347             'populate_extras' => true,
    348             'search_terms'    => false,
    349         );
    350 
    351         ?>
    352 
    353         <?php if ( bp_has_members( $members_args ) ) : ?>
    354             <div class="avatar-block">
    355                 <?php while ( bp_members() ) : bp_the_member(); ?>
    356                     <div class="item-avatar">
    357                         <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
    358                     </div>
    359                 <?php endwhile; ?>
    360             </div>
    361         <?php else: ?>
    362 
    363             <div class="widget-error">
    364                 <?php _e( 'There are no users currently online', 'buddypress' ) ?>
    365             </div>
    366 
    367         <?php endif; ?>
    368 
    369         <?php echo $after_widget; ?>
    370     <?php
    371     }
    372 
    373     /**
    374      * Update the Who's Online widget options.
    375      *
    376      * @param array $new_instance The new instance options.
    377      * @param array $old_instance The old instance options.
    378      * @return array $instance The parsed options to be saved.
    379      */
    380     function update( $new_instance, $old_instance ) {
    381         $instance = $old_instance;
    382         $instance['title'] = strip_tags( $new_instance['title'] );
    383         $instance['max_members'] = strip_tags( $new_instance['max_members'] );
    384 
    385         return $instance;
    386     }
    387 
    388     /**
    389      * Output the Who's Online widget options form.
    390      *
    391      * @param $instance Settings for this widget.
    392      */
    393     function form( $instance ) {
    394         $defaults = array(
    395             'title' => __( "Who's Online", 'buddypress' ),
    396             'max_members' => 15
    397         );
    398         $instance = wp_parse_args( (array) $instance, $defaults );
    399 
    400         $title = strip_tags( $instance['title'] );
    401         $max_members = strip_tags( $instance['max_members'] );
    402         ?>
    403 
    404         <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>
    405 
    406         <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>
    407     <?php
    408     }
    409 }
    410 
    411 /*** RECENTLY ACTIVE WIDGET *****************/
    412 
    413 class BP_Core_Recently_Active_Widget extends WP_Widget {
    414 
    415     /**
    416      * Constructor method.
    417      */
    418     function __construct() {
    419         $widget_ops = array(
    420             'description' => __( 'Profile photos of recently active members', 'buddypress' ),
    421             'classname' => 'widget_bp_core_recently_active_widget buddypress widget',
    422         );
    423         parent::__construct( false, $name = _x( '(BuddyPress) Recently Active Members', 'widget name', 'buddypress' ), $widget_ops );
    424     }
    425 
    426     /**
    427      * Display the Recently Active widget.
    428      *
    429      * @see WP_Widget::widget() for description of parameters.
    430      *
    431      * @param array $args Widget arguments.
    432      * @param array $instance Widget settings, as saved by the user.
    433      */
    434     function widget( $args, $instance ) {
    435 
    436         extract( $args );
    437 
    438         $title = apply_filters( 'widget_title', $instance['title'] );
    439 
    440         echo $before_widget;
    441         echo $before_title
    442            . $title
    443            . $after_title;
    444 
    445         $members_args = array(
    446             'user_id'         => 0,
    447             'type'            => 'active',
    448             'per_page'        => $instance['max_members'],
    449             'max'             => $instance['max_members'],
    450             'populate_extras' => true,
    451             'search_terms'    => false,
    452         );
    453 
    454         ?>
    455 
    456         <?php if ( bp_has_members( $members_args ) ) : ?>
    457             <div class="avatar-block">
    458                 <?php while ( bp_members() ) : bp_the_member(); ?>
    459                     <div class="item-avatar">
    460                         <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
    461                     </div>
    462                 <?php endwhile; ?>
    463             </div>
    464         <?php else: ?>
    465 
    466             <div class="widget-error">
    467                 <?php _e( 'There are no recently active members', 'buddypress' ) ?>
    468             </div>
    469 
    470         <?php endif; ?>
    471 
    472         <?php echo $after_widget; ?>
    473     <?php
    474     }
    475 
    476     /**
    477      * Update the Recently Active widget options.
    478      *
    479      * @param array $new_instance The new instance options.
    480      * @param array $old_instance The old instance options.
    481      * @return array $instance The parsed options to be saved.
    482      */
    483     function update( $new_instance, $old_instance ) {
    484         $instance = $old_instance;
    485         $instance['title'] = strip_tags( $new_instance['title'] );
    486         $instance['max_members'] = strip_tags( $new_instance['max_members'] );
    487 
    488         return $instance;
    489     }
    490 
    491     /**
    492      * Output the Recently Active widget options form.
    493      *
    494      * @param $instance Settings for this widget.
    495      */
    496     function form( $instance ) {
    497         $defaults = array(
    498             'title' => __( 'Recently Active Members', 'buddypress' ),
    499             'max_members' => 15
    500         );
    501         $instance = wp_parse_args( (array) $instance, $defaults );
    502 
    503         $title = strip_tags( $instance['title'] );
    504         $max_members = strip_tags( $instance['max_members'] );
    505         ?>
    506 
    507         <p><label for="bp-core-widget-members-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>
    508 
    509         <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>
    510     <?php
    511     }
    512 }
    513 
    514 /**
    515  * AJAX request handler for Members widgets.
    516  */
    517 function bp_core_ajax_widget_members() {
    518 
    519     check_ajax_referer( 'bp_core_widget_members' );
    520 
    521     switch ( $_POST['filter'] ) {
    522         case 'newest-members':
    523             $type = 'newest';
    524             break;
    525 
    526         case 'recently-active-members':
    527             $type = 'active';
    528             break;
    529 
    530         case 'popular-members':
    531             if ( bp_is_active( 'friends' ) )
    532                 $type = 'popular';
    533             else
    534                 $type = 'active';
    535 
    536             break;
    537     }
    538 
    539     $members_args = array(
    540         'user_id'         => 0,
    541         'type'            => $type,
    542         'per_page'        => $_POST['max-members'],
    543         'max'             => $_POST['max-members'],
    544         'populate_extras' => 1,
    545         'search_terms'    => false,
    546     );
    547 
    548     if ( bp_has_members( $members_args ) ) : ?>
    549         <?php echo '0[[SPLIT]]'; // return valid result. TODO: remove this. ?>
    550         <?php while ( bp_members() ) : bp_the_member(); ?>
    551             <li class="vcard">
    552                 <div class="item-avatar">
    553                     <a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
    554                 </div>
    555 
    556                 <div class="item">
    557                     <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
    558                     <?php if ( 'active' == $type ) : ?>
    559                         <div class="item-meta"><span class="activity"><?php bp_member_last_active() ?></span></div>
    560                     <?php elseif ( 'newest' == $type ) : ?>
    561                         <div class="item-meta"><span class="activity"><?php bp_member_registered() ?></span></div>
    562                     <?php elseif ( bp_is_active( 'friends' ) ) : ?>
    563                         <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count() ?></span></div>
    564                     <?php endif; ?>
    565                 </div>
    566             </li>
    567         <?php endwhile; ?>
    568 
    569     <?php else: ?>
    570         <?php echo "-1[[SPLIT]]<li>"; ?>
    571         <?php _e( 'There were no members found, please try another filter.', 'buddypress' ) ?>
    572         <?php echo "</li>"; ?>
    573     <?php endif;
    574 }
    575 add_action( 'wp_ajax_widget_members', 'bp_core_ajax_widget_members' );
    576 add_action( 'wp_ajax_nopriv_widget_members', 'bp_core_ajax_widget_members' );
  • trunk/src/bp-members/bp-members-loader.php

    r9273 r9323  
    5757            'adminbar',
    5858            'functions',
     59            'widgets',
    5960            'cache',
    6061        );
  • trunk/src/bp-members/bp-members-widgets.php

    r9322 r9323  
    11<?php
    22/**
    3  * BuddyPress Core Component Widgets.
     3 * BuddyPress Members Widgets
    44 *
    55 * @package BuddyPress
    6  * @subpackage Core
    76 */
    87
     
    1110
    1211/**
    13  * Register bp-core widgets.
    14  */
    15 function bp_core_register_widgets() {
    16     add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Login_Widget");') );
     12 * Register bp-members widgets.
     13 *
     14 * Previously, these widgets were registered in bp-core.
     15 *
     16 * @since BuddyPress (2.2.0)
     17 */
     18function bp_members_register_widgets() {
    1719    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
    1820    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
    1921    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
    2022}
    21 add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
    22 
    23 /**
    24  * BuddyPress Login Widget.
    25  *
    26  * @since BuddyPress (1.9.0)
    27  */
    28 class BP_Core_Login_Widget extends WP_Widget {
    29 
    30     /**
    31      * Constructor method.
    32      */
    33     public function __construct() {
    34         parent::__construct(
    35             false,
    36             _x( '(BuddyPress) Log In', 'Title of the login widget', 'buddypress' ),
    37             array(
    38                 'description' => __( 'Show a Log In form to logged-out visitors, and a Log Out link to those who are logged in.', 'buddypress' ),
    39                 'classname' => 'widget_bp_core_login_widget buddypress widget',
    40             )
    41         );
    42     }
    43 
    44     /**
    45      * Display the login widget.
    46      *
    47      * @see WP_Widget::widget() for description of parameters.
    48      *
    49      * @param array $args Widget arguments.
    50      * @param array $instance Widget settings, as saved by the user.
    51      */
    52     public function widget( $args, $instance ) {
    53         $title = isset( $instance['title'] ) ? $instance['title'] : '';
    54         $title = apply_filters( 'widget_title', $title );
    55 
    56         echo $args['before_widget'];
    57 
    58         echo $args['before_title'] . esc_html( $title ) . $args['after_title']; ?>
    59 
    60         <?php if ( is_user_logged_in() ) : ?>
    61 
    62             <?php do_action( 'bp_before_login_widget_loggedin' ); ?>
    63 
    64             <div class="bp-login-widget-user-avatar">
    65                 <a href="<?php echo bp_loggedin_user_domain(); ?>">
    66                     <?php bp_loggedin_user_avatar( 'type=thumb&width=50&height=50' ); ?>
    67                 </a>
    68             </div>
    69 
    70             <div class="bp-login-widget-user-links">
    71                 <div class="bp-login-widget-user-link"><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></div>
    72                 <div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url( bp_get_requested_url() ); ?>"><?php _e( 'Log Out', 'buddypress' ); ?></a></div>
    73             </div>
    74 
    75             <?php do_action( 'bp_after_login_widget_loggedin' ); ?>
    76 
    77         <?php else : ?>
    78 
    79             <?php do_action( 'bp_before_login_widget_loggedout' ); ?>
    80 
    81             <form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
    82                 <label for="bp-login-widget-user-login"><?php _e( 'Username', 'buddypress' ); ?></label>
    83                 <input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
    84 
    85                 <label for="bp-login-widget-user-pass"><?php _e( 'Password', 'buddypress' ); ?></label>
    86                 <input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value=""  />
    87 
    88                 <div class="forgetmenot"><label><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ); ?></label></div>
    89 
    90                 <input type="submit" name="wp-submit" id="bp-login-widget-submit" value="<?php esc_attr_e( 'Log In', 'buddypress' ); ?>" />
    91 
    92                 <?php if ( bp_get_signup_allowed() ) : ?>
    93 
    94                     <span class="bp-login-widget-register-link"><?php printf( __( '<a href="%s" title="Register for a new account">Register</a>', 'buddypress' ), bp_get_signup_page() ); ?></span>
    95 
    96                 <?php endif; ?>
    97 
    98             </form>
    99 
    100             <?php do_action( 'bp_after_login_widget_loggedout' ); ?>
    101 
    102         <?php endif;
    103 
    104         echo $args['after_widget'];
    105     }
    106 
    107     /**
    108      * Update the login widget options.
    109      *
    110      * @param array $new_instance The new instance options.
    111      * @param array $old_instance The old instance options.
    112      * @return array $instance The parsed options to be saved.
    113      */
    114     public function update( $new_instance, $old_instance ) {
    115         $instance             = $old_instance;
    116         $instance['title']    = isset( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
    117 
    118         return $instance;
    119     }
    120 
    121     /**
    122      * Output the login widget options form.
    123      *
    124      * @param $instance Settings for this widget.
    125      */
    126     public function form( $instance = array() ) {
    127 
    128         $settings = wp_parse_args( $instance, array(
    129             'title' => '',
    130         ) ); ?>
    131 
    132         <p>
    133             <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'buddypress' ); ?>
    134             <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( $settings['title'] ); ?>" /></label>
    135         </p>
    136 
    137         <?php
    138     }
    139 }
     23add_action( 'bp_register_widgets', 'bp_members_register_widgets' );
    14024
    14125/**
    14226 * Members Widget.
     27 *
     28 * @since BuddyPress (1.0.3)
    14329 */
    14430class BP_Core_Members_Widget extends WP_Widget {
     
    306192}
    307193
    308 /*** WHO'S ONLINE WIDGET *****************/
    309 
     194/**
     195 * Who's Online Widget.
     196 *
     197 * @since BuddyPress (1.0.3)
     198 */
    310199class BP_Core_Whos_Online_Widget extends WP_Widget {
    311200
     
    409298}
    410299
    411 /*** RECENTLY ACTIVE WIDGET *****************/
    412 
     300/**
     301 * Recently Active Members Widget.
     302 *
     303 * @since BuddyPress (1.0.3)
     304 */
    413305class BP_Core_Recently_Active_Widget extends WP_Widget {
    414306
     
    514406/**
    515407 * AJAX request handler for Members widgets.
     408 *
     409 * @since BuddyPress (1.0.0)
    516410 */
    517411function bp_core_ajax_widget_members() {
Note: See TracChangeset for help on using the changeset viewer.