Ticket #1464: login-widget.diff
| File login-widget.diff, 9.1 KB (added by , 15 years ago) |
|---|
-
bbp-includes/bbp-general-template.php
323 323 * 324 324 * @since bbPress (r2815) 325 325 * 326 * @param str $url Pass a URL to redirect to326 * @param string $url Pass a URL to redirect to 327 327 * @uses add_query_arg() To add a arg to the url 328 328 * @uses site_url() Toget the site url 329 329 * @uses apply_filters() Calls 'bbp_wp_login_action' with the url and args … … 1061 1061 <?php endif; 1062 1062 } 1063 1063 1064 /** Login/logout/register/lost pass *******************************************/ 1065 1066 /** 1067 * Output the logout link 1068 * 1069 * @since bbPress (r) 1070 * 1071 * @param string $redirect_to Redirect to url 1072 * @uses bbp_get_logout_link() To get the logout link 1073 */ 1074 function bbp_logout_link( $redirect_to = '' ) { 1075 echo bbp_get_logout_link( $redirect_to ); 1076 } 1077 /** 1078 * Return the logout link 1079 * 1080 * @since bbPress (r) 1081 * 1082 * @param string $redirect_to Redirect to url 1083 * @uses wp_logout_url() To get the logout url 1084 * @uses apply_filters() Calls 'bbp_get_logout_link' with the logout link and 1085 * redirect to url 1086 * @return string The logout link 1087 */ 1088 function bbp_get_logout_link( $redirect_to = '' ) { 1089 return apply_filters( 'bbp_get_logout_link', '<a href="' . wp_logout_url() . '">' . __( 'Logout', 'bbpress' ) . '</a>', $redirect_to ); 1090 } 1091 1064 1092 ?> -
bbp-includes/bbp-hooks.php
68 68 } 69 69 70 70 // Widgets 71 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Login_Widget");' ) ); 71 72 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Forums_Widget");' ) ); 72 73 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Topics_Widget");' ) ); 73 74 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Replies_Widget");' ) ); -
bbp-includes/bbp-user-template.php
363 363 364 364 } 365 365 366 /** 367 * Output the link to the admin section 368 * 369 * @since bbPress (r) 370 * 371 * @param mixed $args Optional. See {@link bbp_get_admin_link()} 372 * @uses bbp_get_admin_link() To get the admin link 373 */ 374 function bbp_admin_link( $args = '' ) { 375 echo bbp_get_admin_link( $args ); 376 } 377 /** 378 * Return the link to the admin section 379 * 380 * @since bbPress (r) 381 * 382 * @param mixed $args Optional. This function supports these arguments: 383 * - text: The text 384 * - before: Before the lnk 385 * - after: After the link 386 * @uses current_user_can() To check if the current user can moderate 387 * @uses admin_url() To get the admin url 388 * @uses apply_filters() Calls 'bbp_get_admin_link' with the link & args 389 * @return The link 390 */ 391 function bbp_get_admin_link( $args = '' ) { 392 if ( !current_user_can( 'moderate' ) ) 393 return; 394 395 if ( $args && is_string( $args ) && false === strpos( $args, '=' ) ) 396 $args = array( 'text' => $args ); 397 398 $defaults = array( 'text' => __( 'Admin', 'bbpress' ), 'before' => '', 'after' => '' ); 399 $args = wp_parse_args( $args, $defaults ); 400 extract( $args, EXTR_SKIP ); 401 402 $uri = admin_url(); 403 404 return apply_filters( 'bbp_get_admin_link', $before . '<a href="' . $uri . '">' . $text . '</a>' . $after, $args ); 405 } 406 366 407 /** Favorites *****************************************************************/ 367 408 368 409 /** … … 742 783 * @uses bbp_get_current_user_id() To get the current user id 743 784 */ 744 785 function bbp_logged_in_redirect( $url = '' ) { 745 if ( is_user_logged_in() ) { 746 $redirect_to = !empty( $url ) ? $url : bbp_get_user_profile_url( bbp_get_current_user_id() ); 747 wp_safe_redirect( $redirect_to ); 748 exit; 749 } 786 if ( !is_user_logged_in() ) 787 return; 788 789 $redirect_to = !empty( $url ) ? $url : bbp_get_user_profile_url( bbp_get_current_user_id() ); 790 wp_safe_redirect( $redirect_to ); 791 exit; 750 792 } 751 793 752 794 /** -
bbp-includes/bbp-widgets.php
3 3 /** 4 4 * bbPress Widgets 5 5 * 6 * Contains the forum list, topic list, reply list and login form widgets. 7 * 6 8 * @package bbPress 7 9 * @subpackage Widgets 8 10 */ 9 11 10 12 /** 13 * bbPress Login Widget 14 * 15 * Adds a widget which displays the login form 16 * 17 * @since bbPress (r) 18 * 19 * @uses WP_Widget 20 */ 21 class BBP_Login_Widget extends WP_Widget { 22 23 /** 24 * bbPress Login Widget 25 * 26 * Registers the login widget 27 * 28 * @since bbPress (r) 29 * 30 * @uses apply_filters() Calls 'bbp_login_widget_options' with the 31 * widget options 32 */ 33 function BBP_Login_Widget() { 34 $widget_ops = apply_filters( 'bbp_login_widget_options', array( 35 'classname' => 'widget_display_forums', 36 'description' => __( 'The login widget.', 'bbpress' ) 37 ) ); 38 39 parent::WP_Widget( false, __( 'bbPress Login Widget', 'bbpress' ), $widget_ops ); 40 } 41 42 /** 43 * Displays the output, the login form 44 * 45 * @since bbPress (r) 46 * 47 * @param mixed $args Arguments 48 * @param array $instance Instance 49 * @uses apply_filters() Calls 'bbp_login_widget_title' with the title 50 * @uses get_template_part() To get the login/logged in form 51 */ 52 function widget( $args, $instance ) { 53 extract( $args ); 54 55 $title = apply_filters( 'bbp_login_widget_title', $instance['title'] ); 56 57 echo $before_widget; 58 echo $before_title . $title . $after_title; 59 60 get_template_part( 'form', is_user_logged_in() ? 'bbp_user_logged_in' : 'bbp_user_login' ); 61 62 echo $after_widget; 63 } 64 65 /** 66 * Update the login widget options 67 * 68 * @since bbPress (r) 69 * 70 * @param array $new_instance The new instance options 71 * @param array $old_instance The old instance options 72 */ 73 function update( $new_instance, $old_instance ) { 74 $instance = $old_instance; 75 $instance['title'] = strip_tags( $new_instance['title'] ); 76 77 return $instance; 78 } 79 80 /** 81 * Output the login widget options form 82 * 83 * @since bbPress (r) 84 * 85 * @param $instance Instance 86 * @uses BBP_Login_Widget::get_field_id() To output the field id 87 * @uses BBP_Login_Widget::get_field_name() To output the field name 88 */ 89 function form( $instance ) { 90 $title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; ?> 91 92 <p> 93 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?> 94 <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; ?>" /></label> 95 </p> 96 97 <?php 98 } 99 } 100 101 /** 11 102 * bbPress Forum Widget 12 103 * 13 104 * Adds a widget which displays the forum list … … 82 173 83 174 <?php echo $after_widget; 84 175 85 endif; 176 endif; 86 177 } 87 178 88 179 /** … … 278 369 * @uses BBP_Topics_Widget::get_field_name() To output the field name 279 370 */ 280 371 function form( $instance ) { 281 $title = !empty( $instance['title'] )? esc_attr( $instance['title'] ) : '';372 $title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; 282 373 $max_shown = !empty( $instance['max_shown'] ) ? esc_attr( $instance['max_shown'] ) : ''; 283 374 $show_date = !empty( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : ''; 284 375 $pop_check = !empty( $instance['pop_check'] ) ? esc_attr( $instance['pop_check'] ) : ''; ?> -
bbp-themes/bbp-twentyten/css/bbpress.css
365 365 font-size: 11px; 366 366 color: #aaa; 367 367 } 368 369 /* =Widgets 370 -------------------------------------------------------------- */ 371 372 .widget-area .bbp-login-form fieldset legend { 373 display: none; 374 } 375 376 .widget-area .bbp-login-form .bbp-username, 377 .widget-area .bbp-login-form .bbp-password, 378 .widget-area .bbp-login-form .bbp-remember-me, 379 .widget-area .bbp-login-form .bbp-submit-wrapper { 380 margin-top: 10px; 381 } 382 383 .widget-area .bbp-login-form .bbp-remember-me { 384 float: left; 385 } 386 387 .widget-area .bbp-login-form .bbp-submit-wrapper { 388 float: right; 389 } -
bbp-themes/bbp-twentyten/form-bbp_user_logged_in.php
1 <?php 2 3 /** 4 * User Logged in Form 5 * 6 * @package bbPress 7 * @subpackage Theme 8 */ 9 10 ?> 11 12 <div class="bbp-logged-in"> 13 <?php printf( __( 'Welcome, %1$s', 'bbpress' ), bbp_get_user_profile_link( bbp_get_current_user_id() ) ); ?> 14 <?php bbp_admin_link( array( 'before' => ' | ' ) );?> 15 | <?php bbp_logout_link(); ?> 16 </div>