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-user-template.php

    r2823 r2827  
    362362        return apply_filters( 'bbp_get_user_edit_profile_url', $url, $user_id, $user_nicename );
    363363
     364    }
     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 */
     374function 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 );
    364405    }
    365406
     
    743784 */
    744785function 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;
    750792}
    751793
Note: See TracChangeset for help on using the changeset viewer.