Changeset 9323 for trunk/src/bp-members/bp-members-widgets.php
- Timestamp:
- 01/09/2015 01:37:37 AM (10 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-widgets.php
r9322 r9323 1 1 <?php 2 2 /** 3 * BuddyPress Core Component Widgets.3 * BuddyPress Members Widgets 4 4 * 5 5 * @package BuddyPress 6 * @subpackage Core7 6 */ 8 7 … … 11 10 12 11 /** 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 */ 18 function bp_members_register_widgets() { 17 19 add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') ); 18 20 add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') ); 19 21 add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') ); 20 22 } 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 } 23 add_action( 'bp_register_widgets', 'bp_members_register_widgets' ); 140 24 141 25 /** 142 26 * Members Widget. 27 * 28 * @since BuddyPress (1.0.3) 143 29 */ 144 30 class BP_Core_Members_Widget extends WP_Widget { … … 306 192 } 307 193 308 /*** WHO'S ONLINE WIDGET *****************/ 309 194 /** 195 * Who's Online Widget. 196 * 197 * @since BuddyPress (1.0.3) 198 */ 310 199 class BP_Core_Whos_Online_Widget extends WP_Widget { 311 200 … … 409 298 } 410 299 411 /*** RECENTLY ACTIVE WIDGET *****************/ 412 300 /** 301 * Recently Active Members Widget. 302 * 303 * @since BuddyPress (1.0.3) 304 */ 413 305 class BP_Core_Recently_Active_Widget extends WP_Widget { 414 306 … … 514 406 /** 515 407 * AJAX request handler for Members widgets. 408 * 409 * @since BuddyPress (1.0.0) 516 410 */ 517 411 function bp_core_ajax_widget_members() {
Note: See TracChangeset
for help on using the changeset viewer.