| 329 | |
| 330 | |
| 331 | /*** LOGIN WIDGET *****************/ |
| 332 | |
| 333 | class BP_Core_Login_Widget extends WP_Widget { |
| 334 | |
| 335 | function __construct() { |
| 336 | $widget_ops = array( 'description' => __( 'Log in/out form for BuddyPress, register link', 'buddypress' ) ); |
| 337 | parent::__construct( false, $name = __( 'BuddyPress Login', 'buddypress' ), $widget_ops ); |
| 338 | } |
| 339 | |
| 340 | function widget($args, $instance) { |
| 341 | global $bp; |
| 342 | |
| 343 | $args = apply_filters( 'bp_login_widget_args', $args ); |
| 344 | |
| 345 | extract( $args ); |
| 346 | |
| 347 | echo $before_widget; |
| 348 | echo $before_title |
| 349 | . $instance['title'] |
| 350 | . $after_title; ?> |
| 351 | |
| 352 | <?php if ( is_user_logged_in() ) : ?> |
| 353 | |
| 354 | <?php do_action( 'bp_before_sidebar_me' ) ?> |
| 355 | |
| 356 | <div id="sidebar-me" class="widget"> |
| 357 | <a href="<?php echo bp_loggedin_user_domain() ?>"> |
| 358 | <?php bp_loggedin_user_avatar( 'type=thumb&width=40&height=40' ) ?> |
| 359 | </a> |
| 360 | |
| 361 | <h4><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></h4> |
| 362 | <a class="button logout" href="<?php echo wp_logout_url( bp_get_root_domain() ) ?>"><?php _e( 'Log Out', 'buddypress' ) ?></a> |
| 363 | |
| 364 | <?php do_action( 'bp_sidebar_me' ) ?> |
| 365 | </div> |
| 366 | |
| 367 | <?php do_action( 'bp_after_sidebar_me' ) ?> |
| 368 | |
| 369 | <?php if ( function_exists( 'bp_message_get_notices' ) ) : ?> |
| 370 | <?php bp_message_get_notices(); /* Site wide notices to all users */ ?> |
| 371 | <?php endif; ?> |
| 372 | |
| 373 | <?php else : ?> |
| 374 | |
| 375 | <?php do_action( 'bp_before_sidebar_login_form' ) ?> |
| 376 | |
| 377 | <div id="sidebar-me" class="widget"> |
| 378 | <p id="login-text"> |
| 379 | <span><?php _e( 'To start connecting please log in first.', 'buddypress' ) ?></span> |
| 380 | <?php if ( bp_get_signup_allowed() ) : ?> |
| 381 | <span><?php printf( __( ' You can also <a href="%s" title="Create an account">create an account</a>.', 'buddypress' ), site_url( BP_REGISTER_SLUG . '/' ) ) ?></span> |
| 382 | <?php endif; ?> |
| 383 | </p> |
| 384 | |
| 385 | <form name="login-form" id="sidebar-login-form" class="standard-form" action="<?php echo site_url( 'wp-login.php', 'login_post' ) ?>" method="post"> |
| 386 | <label><?php _e( 'Username', 'buddypress' ) ?><br /> |
| 387 | <input type="text" name="log" id="sidebar-user-login" class="input" /></label> |
| 388 | |
| 389 | <label><?php _e( 'Password', 'buddypress' ) ?><br /> |
| 390 | <input type="password" name="pwd" id="sidebar-user-pass" class="input" /></label> |
| 391 | |
| 392 | <p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="sidebar-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ) ?></label></p> |
| 393 | |
| 394 | <?php do_action( 'bp_sidebar_login_form' ) ?> |
| 395 | <input type="submit" name="wp-submit" id="sidebar-wp-submit" value="<?php _e('Log In'); ?>" tabindex="100" /> |
| 396 | <input type="hidden" name="testcookie" value="1" /> |
| 397 | </form> |
| 398 | </div> |
| 399 | <?php do_action( 'bp_after_sidebar_login_form' ) ?> |
| 400 | |
| 401 | <?php endif; ?> |
| 402 | |
| 403 | <?php echo $after_widget; ?> |
| 404 | <?php |
| 405 | } |
| 406 | |
| 407 | function update( $new_instance, $old_instance ) { |
| 408 | $instance = $old_instance; |
| 409 | $instance['title'] = strip_tags( $new_instance['title'] ); |
| 410 | |
| 411 | return $instance; |
| 412 | } |
| 413 | |
| 414 | function form( $instance ) { |
| 415 | |
| 416 | $defaults = array( |
| 417 | 'title' => 'BuddyPress Login' |
| 418 | ); |
| 419 | $instance = wp_parse_args( (array) $instance, $defaults ); |
| 420 | |
| 421 | $title = strip_tags( $instance['title'] ); |
| 422 | ?> |
| 423 | |
| 424 | <p><label for="bp-core-widget-login-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> |
| 425 | |
| 426 | <p><?php _e( 'Log in/out form for BuddyPress. Adds a register link if registration is open.', 'buddypress' ) ?></p> |
| 427 | <?php |
| 428 | } |
| 429 | } |