Changeset 2815
- Timestamp:
- 01/18/2011 08:35:34 AM (14 years ago)
- Location:
- branches/plugin
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-general-functions.php
r2810 r2815 996 996 } 997 997 998 /** Login *********************************************************************/ 999 1000 /** 1001 * Change the login URL to /login 1002 * 1003 * This assumes that your login page is 'domain.com/login' 1004 * 1005 * @todo Make this less janky 1006 * 1007 * @uses apply_filters() 1008 * @uses trailingslashit() 1009 * @uses home_url() 1010 * @return str 1011 */ 1012 function bbp_login_url( $url = '', $redirect_to = '' ) { 1013 return apply_filters( 'bbp_login_url', trailingslashit( home_url( 'login' ) ) ); 1014 } 1015 1016 /** 1017 * Change the logout URL to /login and add smart redirect 1018 * 1019 * This assumes that your login page is 'domain.com/login' 1020 * 1021 * @todo Make this less janky 1022 * 1023 * @uses apply_filters() 1024 * @uses add_query_arg() 1025 * @uses trailingslashit() 1026 * @uses esc_url() 1027 * @uses home_url() 1028 * @return str 1029 */ 1030 function bbp_logout_url( $url = '', $redirect_to = '' ) { 1031 if ( !$redirect_to = home_url( $_SERVER['REDIRECT_URL'] ) ) 1032 $redirect_to = $_SERVER['HTTP_REFERER']; 1033 1034 if ( empty( $redirect_to ) ) 1035 $redirect_to = home_url( $_SERVER['REQUEST_URI'] ); 1036 1037 $url = add_query_arg( array( 'redirect_to' => esc_url( $redirect_to ) ), $url ); 1038 1039 return apply_filters( 'bbp_logout_url', $url ); 1040 } 1041 998 1042 ?> -
branches/plugin/bbp-includes/bbp-general-template.php
r2812 r2815 318 318 319 319 /** Forms *********************************************************************/ 320 321 function bbp_wp_login_action( $args = '' ) { 322 $defaults = array ( 323 'action' => '', 324 'context' => '' 325 ); 326 $r = wp_parse_args( $args, $defaults ); 327 extract( $r ); 328 329 if ( !empty( $action ) ) 330 $login_url = add_query_arg( array( 'action' => $action ), 'wp-login.php' ); 331 else 332 $login_url = 'wp-login.php'; 333 334 $login_url = site_url( $login_url, $context ); 335 336 echo apply_filters( 'bbp_wp_login_action', $login_url, $args ); 337 } 338 339 /** 340 * Output hidden request URI field for user forms. 341 * 342 * The referer link is the current Request URI from the server super global. The 343 * input name is '_wp_http_referer', in case you wanted to check manually. 344 * 345 * @since bbPress (r2815) 346 * 347 * @uses esc_attr() 348 * @uses home_url() 349 * @uses apply_filters() 350 * @param str $url Pass a URL to redirect to 351 * @return str Hidden input to help process redirection. 352 */ 353 function bbp_redirect_to_field( $url = '' ) { 354 // If no URL is passed, use request 355 if ( empty( $url ) ) 356 $url = esc_url( $_SERVER['HTTP_REFERER'] ); 357 358 $referer_field = '<input type="hidden" name="redirect_to" value="' . $url . '" />'; 359 360 echo apply_filters( 'bbp_redirect_to_field', $referer_field ); 361 } 362 363 /** 364 * Echo sanitized $_REQUEST value. 365 * 366 * Use the $input_type parameter to properly process the value. This 367 * ensures correct sanitization of the value for the receiving input. 368 * 369 * @since bbPress (r2815) 370 * 371 * @uses bbp_get_sanitize_val() 372 * @param str $request Name of $_REQUEST to look for 373 * @param str $input_type Type of input the value is for 374 */ 375 function bbp_sanitize_val( $request = '', $input_type = 'text' ) { 376 echo bbp_get_sanitize_val( $request, $input_type ); 377 } 378 /** 379 * Return sanitized $_REQUEST value. 380 * 381 * Use the $input_type parameter to properly process the value. This 382 * ensures correct sanitization of the value for the receiving input. 383 * 384 * @since bbPress (r2815) 385 * 386 * @uses esc_attr() 387 * @uses stripslashes() 388 * @uses apply_filters() 389 * @param str $request Name of $_REQUEST to look for 390 * @param str $input_type Type of input the value is for 391 * @return str Sanitized value ready for screen display 392 */ 393 function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) { 394 395 // Check that requested 396 if ( !isset( $_REQUEST[$request] ) || empty( $request ) ) 397 return false; 398 399 // Set request varaible 400 $pre_ret_val = $_REQUEST[$request]; 401 402 // Treat different kinds of fields in different ways 403 switch ( $input_type ) { 404 case 'text' : 405 case 'textarea' : 406 $retval = esc_attr( stripslashes( $pre_ret_val ) ); 407 break; 408 409 case 'password' : 410 case 'select' : 411 case 'radio' : 412 case 'checkbox' : 413 default : 414 $retval = esc_attr( $pre_ret_val ); 415 break; 416 } 417 418 return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type ); 419 } 320 420 321 421 /** … … 614 714 <input type="hidden" name="user_id" id="user_id" value="<?php bbp_displayed_user_id(); ?>" /> 615 715 616 <?php wp_referer_field(); ?>617 618 716 <?php wp_nonce_field( 'update-user_' . bbp_get_displayed_user_id() ); 619 717 } -
branches/plugin/bbp-includes/bbp-hooks.php
r2806 r2815 253 253 254 254 // Canonical 255 add_filter( 'redirect_canonical', 'bbp_redirect_canonical' ); 255 add_filter( 'redirect_canonical', 'bbp_redirect_canonical' ); 256 257 // Login/Register/Lost Password 258 add_filter( 'login_redirect', 'bbp_redirect_login', 2, 3 ); 259 add_filter( 'login_url', 'bbp_login_url', 2, 2 ); 260 add_filter( 'logout_url', 'bbp_logout_url', 2, 2 ); 256 261 257 262 // Fix post author id for anonymous posts (set it back to 0) when the post status is changed 258 add_filter( 'wp_insert_post_data', 'bbp_fix_post_author', 30, 2 );263 add_filter( 'wp_insert_post_data', 'bbp_fix_post_author', 30, 2 ); 259 264 260 265 /** -
branches/plugin/bbp-includes/bbp-user-functions.php
r2790 r2815 1 1 <?php 2 2 3 /** 3 4 * bbPress User Functions … … 6 7 * @subpackage Functions 7 8 */ 9 10 /** 11 * Redirect back to $url when attempting to use the login page 12 * 13 * @since bbPress (r2815) 14 * 15 * @uses wp_safe_redirect() 16 * @uses esc_url() 17 * @param str $url 18 * @param str $raw_url 19 * @param obj $user 20 */ 21 function bbp_redirect_login( $url = '', $raw_url = '', $user = '' ) { 22 if ( !empty( $url ) || !empty( $raw_url ) || is_wp_error( $user ) ) { 23 if ( empty( $url ) && !empty( $raw_url ) ) 24 $url = $raw_url; 25 26 if ( $url == admin_url() ) 27 $url = home_url(); 28 29 wp_safe_redirect( esc_url( $url ) ); 30 exit; 31 } 32 } 8 33 9 34 /** … … 97 122 } 98 123 99 /** START - Favorites*********************************************************/124 /** Favorites *****************************************************************/ 100 125 101 126 /** … … 359 384 } 360 385 361 /** END - Favorites ***********************************************************/ 362 363 /** START - Subscriptions *****************************************************/ 386 /** Subscriptions *************************************************************/ 364 387 365 388 /** … … 632 655 } 633 656 634 /** END - Subscriptions *******************************************************/ 635 636 /** START - Edit User *********************************************************/ 657 /** Edit **********************************************************************/ 637 658 638 659 /** -
branches/plugin/bbp-includes/bbp-user-template.php
r2812 r2815 726 726 } 727 727 728 /** Login *********************************************************************/ 729 730 /** 731 * Redirect a user back to their profile if they are already logged in. 732 * 733 * This should be used before get_header() is called in template files where 734 * the user should never have access to the contents of that file. 735 * 736 * @since bbPress (r2815) 737 * 738 * @param str $url The URL to redirect to 739 * 740 * @uses is_user_logged_in() Check if user is logged in 741 * @uses wp_safe_redirect() Safely redirect 742 * @uses bbp_get_user_profile_url() Get URL of user 743 * @uses bbp_get_current_user_id() Get current user ID 744 */ 745 function bbp_logged_in_redirect( $url = '' ) { 746 if ( is_user_logged_in() ) { 747 $redirect_to = !empty( $url ) ? $url : bbp_get_user_profile_url( bbp_get_current_user_id() ); 748 wp_safe_redirect( $redirect_to ); 749 exit; 750 } 751 } 752 753 /** 754 * Output the required hidden fields when logging in 755 * 756 * @since bbPress (r2815) 757 * 758 * @uses wp_referer_field() Set referer 759 * @uses wp_nonce_field() To generate hidden nonce fields 760 */ 761 function bbp_user_login_fields() { 728 762 ?> 763 764 <input type="hidden" name="action" id="bbp_user_login" value="bbp-user-login" /> 765 <input type="hidden" name="user-cookie" value="1" /> 766 767 <?php bbp_redirect_to_field(); ?> 768 769 <?php wp_nonce_field( 'bbp-user-login' ); 770 } 771 772 /** Register *********************************************************************/ 773 774 /** 775 * Output the required hidden fields when registering 776 * 777 * @since bbPress (r2815) 778 * 779 * @uses wp_referer_field() Set referer 780 * @uses wp_nonce_field() To generate hidden nonce fields 781 */ 782 function bbp_user_register_fields() { 783 ?> 784 785 <input type="hidden" name="action" id="bbp_user_register" value="bbp-user-register" /> 786 <input type="hidden" name="user-cookie" value="1" /> 787 788 <?php wp_nonce_field( 'bbp-user-register' ); 789 } 790 791 /** Lost Password *********************************************************************/ 792 793 /** 794 * Output the required hidden fields when user lost password 795 * 796 * @since bbPress (r2815) 797 * 798 * @uses wp_referer_field() Set referer 799 * @uses wp_nonce_field() To generate hidden nonce fields 800 */ 801 function bbp_user_lost_pass_fields() { 802 ?> 803 804 <input type="hidden" name="action" id="bbp_user_lost_pass" value="bbp-user-lost-pass" /> 805 <input type="hidden" name="user-cookie" value="1" /> 806 807 <?php wp_nonce_field( 'bbp-user-lost-pass' ); 808 } 809 810 ?> -
branches/plugin/bbp-themes/bbp-twentyten/css/bbpress.css
r2810 r2815 226 226 } 227 227 228 p#bbp_topic_submit_container, 229 p#bbp_reply_submit_container { 228 div.bbp-submit-wrapper { 230 229 float: right; 231 230 } -
branches/plugin/bbp-themes/bbp-twentyten/form-bbp_merge.php
r2810 r2815 69 69 </fieldset> 70 70 71 < p id="bbp_topic_submit_container">71 <div class="bbp-submit-wrapper"> 72 72 <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_merge_topic_submit" name="bbp_merge_topic_submit"><?php _e( 'Submit', 'bbpress' ); ?></button> 73 </ p>73 </div> 74 74 </div> 75 75 -
branches/plugin/bbp-themes/bbp-twentyten/form-bbp_reply.php
r2810 r2815 94 94 <?php endif; ?> 95 95 96 < p id="bbp_reply_submit_container">96 <div class="bbp-submit-wrapper"> 97 97 <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_reply_submit" name="bbp_reply_submit"><?php _e( 'Submit', 'bbpress' ); ?></button> 98 </ p>98 </div> 99 99 </div> 100 100 -
branches/plugin/bbp-themes/bbp-twentyten/form-bbp_split.php
r2810 r2815 79 79 </fieldset> 80 80 81 < p id="bbp_topic_submit_container">81 <div class="bbp-submit-wrapper"> 82 82 <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_merge_topic_submit" name="bbp_merge_topic_submit"><?php _e( 'Submit', 'bbpress' ); ?></button> 83 </ p>83 </div> 84 84 </div> 85 85 -
branches/plugin/bbp-themes/bbp-twentyten/form-bbp_topic.php
r2810 r2815 129 129 <?php endif; ?> 130 130 131 < p id="bbp_topic_submit_container">131 <div class="bbp-submit-wrapper"> 132 132 <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_topic_submit" name="bbp_topic_submit"><?php _e( 'Submit', 'bbpress' ); ?></button> 133 </ p>133 </div> 134 134 </div> 135 135 -
branches/plugin/bbp-themes/bbp-twentyten/form-bbp_user_register.php
r2814 r2815 9 9 10 10 ?> 11 12 <form method="post" action="<?php bbp_wp_login_action( array( 'action' => 'register', 'context' => 'login_post' ) ); ?>" class="bbp-login-form"> 13 <fieldset> 14 <legend><?php _e( 'Register', 'bbpress' ); ?></legend> 15 16 <?php do_action( 'bbp_template_notices' ); ?> 17 18 <div class="bbp-username"> 19 <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label> 20 <input type="text" name="log" value="<?php bbp_sanitize_val( 'user_login' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" /> 21 </div> 22 23 <div class="bbp-email"> 24 <label for="user_email"><?php _e( 'Email Address', 'bbpress' ); ?>: </label> 25 <input type="text" name="user_email" value="<?php bbp_sanitize_val( 'user_email' ); ?>" size="20" id="user_email" tabindex="<?php bbp_tab_index(); ?>" /> 26 </div> 27 28 <div class="bbp-submit-wrapper"> 29 30 <?php do_action( 'register_form' ); ?> 31 32 <button type="submit" name="user-submit" tabindex="<?php bbp_tab_index(); ?>" class="user-submit"><?php _e( 'Register', 'bbpress' ); ?></button> 33 34 <?php bbp_user_register_fields(); ?> 35 36 </div> 37 </fieldset> 38 </form> -
branches/plugin/bbp-themes/bbp-twentyten/page-bbp_login.php
r2810 r2815 8 8 */ 9 9 10 ?> 10 // No logged in users 11 bbp_logged_in_redirect(); 11 12 12 <?php get_header(); ?> 13 // Begin Template 14 get_header(); ?> 13 15 14 16 <div id="container"> … … 25 27 <?php the_content(); ?> 26 28 27 <?php if ( !is_user_logged_in() ) : ?>29 <?php //if ( !is_user_logged_in() ) : ?> 28 30 29 <fieldset> 30 <legend><?php _e( 'Login', 'bbpress' ); ?></legend> 31 <?php get_template_part( 'form', 'bbp_user_login' ); ?> 31 32 32 <?php do_action( 'bbp_template_notices' );?>33 <?php //else : ?> 33 34 34 <?php wp_login_form( array( 'redirect' => $_SERVER['HTTP_REFERER'] ) ); ?> 35 36 </fieldset> 37 38 <?php else : ?> 39 40 41 42 <?php endif; ?> 35 <?php //endif; ?> 43 36 44 37 </div> -
branches/plugin/bbp-themes/bbp-twentyten/page-bbp_register.php
r2813 r2815 8 8 */ 9 9 10 ?> 10 // No logged in users 11 bbp_logged_in_redirect(); 11 12 12 <?php get_header(); ?> 13 // Begin Template 14 get_header(); ?> 13 15 14 16 <div id="container"> … … 25 27 <?php the_content(); ?> 26 28 27 <?php if ( !is_user_logged_in() ) : ?> 28 29 <?php get_template_part( 'form', 'bbp_user_register' ); ?> 30 31 <?php else : ?> 32 33 <p><?php _e( 'You’re already logged in, why do you need to register?', 'bbpress' ); ?></p> 34 35 <?php endif; ?> 29 <?php get_template_part( 'form', 'bbp_user_register' ); ?> 36 30 37 31 </div>
Note: See TracChangeset
for help on using the changeset viewer.