Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/03/2011 08:00:34 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Login widget, and various supporting styles and functions for a smarter redirect. Fixes #1464, #1465. Props GautamGupta for original patches.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-general-template.php

    r2823 r2827  
    324324 * @since bbPress (r2815)
    325325 *
    326  * @param str $url Pass a URL to redirect to
     326 * @param string $url Pass a URL to redirect to
    327327 * @uses add_query_arg() To add a arg to the url
    328328 * @uses site_url() Toget the site url
     
    356356 *
    357357 * @param string $url Pass a URL to redirect to
    358  * @uses home_url() To get the url
     358 * @uses wp_get_referer() To get the referer
     359 * @uses esc_attr() To escape the url
    359360 * @uses apply_filters() Calls 'bbp_redirect_to_field' with the referer field
    360361 *                        and url
    361362 */
    362363function bbp_redirect_to_field( $url = '' ) {
    363     // If no URL is passed, use request
    364     if ( empty( $url ) && !empty( $_SERVER['HTTP_REFERER'] ) )
    365         $url = esc_url( $_SERVER['HTTP_REFERER'] );
     364    // If no URL is passed, try to get the referer and then the request uri
     365    if ( empty( $url ) && ( !$url = wp_get_referer() ) && ( !empty( $_SERVER['REQUEST_URI'] ) ) )
     366        $url = $_SERVER['REQUEST_URI'];
     367
     368    $url = (string) esc_attr( $url );
    366369
    367370    $referer_field = '<input type="hidden" name="redirect_to" value="' . $url . '" />';
     
    411414        // Treat different kinds of fields in different ways
    412415        switch ( $input_type ) {
    413             case 'text' :
     416            case 'text'     :
    414417            case 'textarea' :
    415418                $retval = esc_attr( stripslashes( $pre_ret_val ) );
     
    417420
    418421            case 'password' :
    419             case 'select' :
    420             case 'radio' :
     422            case 'select'   :
     423            case 'radio'    :
    421424            case 'checkbox' :
    422425            default :
     
    10621065}
    10631066
     1067/** Login/logout/register/lost pass *******************************************/
     1068
     1069/**
     1070 * Output the logout link
     1071 *
     1072 * @since bbPress (r)
     1073 *
     1074 * @param string $redirect_to Redirect to url
     1075 * @uses bbp_get_logout_link() To get the logout link
     1076 */
     1077function bbp_logout_link( $redirect_to = '' ) {
     1078    echo bbp_get_logout_link( $redirect_to );
     1079}
     1080    /**
     1081     * Return the logout link
     1082     *
     1083     * @since bbPress (r)
     1084     *
     1085     * @param string $redirect_to Redirect to url
     1086     * @uses wp_logout_url() To get the logout url
     1087     * @uses apply_filters() Calls 'bbp_get_logout_link' with the logout link and
     1088     *                        redirect to url
     1089     * @return string The logout link
     1090     */
     1091    function bbp_get_logout_link( $redirect_to = '' ) {
     1092        return apply_filters( 'bbp_get_logout_link', '<a href="' . wp_logout_url() . '" class="button logout-link">' . __( 'Log Out', 'bbpress' ) . '</a>', $redirect_to );
     1093    }
     1094
    10641095?>
Note: See TracChangeset for help on using the changeset viewer.