Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/01/2011 04:01:31 AM (16 years ago)
Author:
johnjamesjacoby
Message:

Full audit of user/topic/reply/view permalinks. Use $wp_rewrite->using_permalinks() method in place of $wp_rewrite->permalink_structure. See r2973

File:
1 edited

Legend:

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

    r2973 r2974  
    247247         */
    248248        function bbp_get_user_profile_url( $user_id = 0, $user_nicename = '' ) {
    249                 global $bbp;
     249                global $wp_rewrite, $bbp;
    250250
    251251                // Use displayed user ID if there is one, and one isn't requested
    … …  
    253253                        return false;
    254254
    255                 // No pretty permalinks
    256                 if ( empty( $wp_rewrite->permalink_structure ) ) {
    257                         $url = add_query_arg( array( 'bbp_user' => $user_id ), home_url( '/' ) );
    258 
    259                 // Get URL safe user slug
    260                 } else {
    261                         $url = $bbp->user_slug . '/%bbp_user%';
    262 
     255                // Pretty permalinks
     256                if ( $wp_rewrite->using_permalinks() ) {
     257                        $url = $wp_rewrite->root . $bbp->user_slug . '/%bbp_user%';
     258
     259                        // Get username if not passed
    263260                        if ( empty( $user_nicename ) ) {
    264261                                $user = get_userdata( $user_id );
    265                                 if ( !empty( $user->user_nicename ) )
     262                                if ( !empty( $user->user_nicename ) ) {
    266263                                        $user_nicename = $user->user_nicename;
     264                                }
    267265                        }
    268266
    269267                        $url = str_replace( '%bbp_user%', $user_nicename, $url );
    270268                        $url = home_url( user_trailingslashit( $url ) );
     269
     270                // Unpretty permalinks
     271                } else {
     272                        $url = add_query_arg( array( 'bbp_user' => $user_id ), home_url( '/' ) );
    271273                }
    272274
    … …  
    341343                        return;
    342344
    343                 if ( empty( $wp_rewrite->permalink_structure ) ) {
    344                         $url = add_query_arg( array( 'bbp_user' => $user_id, 'edit' => '1' ), home_url( '/' ) );
    345                 } else {
    346                         $url = $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%/edit';
    347 
     345                // Pretty permalinks
     346                if ( $wp_rewrite->using_permalinks() ) {
     347                        $url = $wp_rewrite->root . $bbp->user_slug . '/%bbp_user%/edit';
     348
     349                        // Get username if not passed
    348350                        if ( empty( $user_nicename ) ) {
    349351                                $user = get_userdata( $user_id );
    350                                 if ( !empty( $user->user_nicename ) )
     352                                if ( !empty( $user->user_nicename ) ) {
    351353                                        $user_nicename = $user->user_nicename;
     354                                }
    352355                        }
    353356
    354357                        $url = str_replace( '%bbp_user%', $user_nicename, $url );
    355358                        $url = home_url( user_trailingslashit( $url ) );
     359
     360                // Unpretty permalinks
     361                } else {
     362                        $url = add_query_arg( array( 'bbp_user' => $user_id, 'edit' => '1' ), home_url( '/' ) );
    356363                }
    357364
Note: See TracChangeset for help on using the changeset viewer.