Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/06/2011 08:25:58 AM (15 years ago)
Author:
johnjamesjacoby
Message:

"...pursuing a career in the custodial arts." phpDoc fixes and code clean-up. Props GautamGupta via Google Code-in

File:
1 edited

Legend:

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

    r2734 r2758  
    11<?php
    22
     3/**
     4 * bbPress User Functions
     5 *
     6 * @package bbPress
     7 * @subpackage TemplateTags
     8 */
     9
    310/** START User Functions ******************************************************/
    411
    512/**
    6  * bbp_user_id ()
    7  *
    8  * Output a validated user_id
    9  *
    10  * @param int $user_id
    11  * @param bool $current_user_fallback
    12  */
    13 function bbp_user_id ( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) {
     13 * Output a validated user id
     14 *
     15 * @since bbPress (r2729)
     16 *
     17 * @param int $user_id Optional. User id
     18 * @param bool $displayed_user_fallback Fallback on displayed user?
     19 * @param bool $current_user_fallback Fallback on current user?
     20 * @uses bbp_get_user_id() To get the user id
     21 */
     22function bbp_user_id( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) {
    1423    echo bbp_get_user_id( $user_id, $displayed_user_fallback, $current_user_fallback );
    1524}
    1625    /**
    17      * bbp_get_user_id ()
    18      *
    19      * Return a validated user_id
    20      *
    21      * @global bbPress $bbp
    22      * @param int $user_id
    23      * @param bool $displayed_user_fallback
    24      * @param bool $current_user_fallback
    25      * @return int
    26      */
    27     function bbp_get_user_id ( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) {
     26     * Return a validated user id
     27     *
     28     * @since bbPress (r2729)
     29     *
     30     * @param int $user_id Optional. User id
     31     * @param bool $displayed_user_fallback Fallback on displayed user?
     32     * @param bool $current_user_fallback Fallback on current user?
     33     * @uses get_query_var() To get the 'bbp_user_id' query var
     34     * @uses apply_filters() Calls 'bbp_get_user_id' with the user id
     35     * @return int Validated user id
     36     */
     37    function bbp_get_user_id( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) {
    2838        global $bbp;
    2939
     
    3141        if ( !empty( $user_id ) && is_numeric( $user_id ) )
    3242            $bbp_user_id = $user_id;
    33    
     43
    3444        // Currently viewing or editing a user
    3545        elseif ( ( true == $displayed_user_fallback ) && !empty( $bbp->displayed_user->ID ) && isset( $bbp->displayed_user->ID ) )
     
    5060
    5161/**
    52  * bbp_favorites_permalink ()
    53  *
    5462 * Output the link to the user's favorites page (profile page)
    5563 *
    56  * @package bbPress
    57  * @subpackage Template Tags
    5864 * @since bbPress (r2652)
    5965 *
    60  * @param int $user_id optional
    61  * @uses bbp_get_favorites_permalink()
    62  */
    63 function bbp_favorites_permalink ( $user_id = 0 ) {
     66 * @param int $user_id Optional. User id
     67 * @uses bbp_get_favorites_permalink() To get the favorites permalink
     68 */
     69function bbp_favorites_permalink( $user_id = 0 ) {
    6470    echo bbp_get_favorites_permalink( $user_id );
    6571}
    6672    /**
    67      * bbp_get_favorites_permalink ()
    68      *
    6973     * Return the link to the user's favorites page (profile page)
    7074     *
    71      * @package bbPress
    72      * @subpackage Template Tags
    7375     * @since bbPress (r2652)
    7476     *
    75      * @param int $user_id optional
    76      * @uses apply_filters
    77      * @uses bbp_get_user_profile_url
     77     * @param int $user_id Optional. User id
     78     * @uses bbp_get_user_profile_url() To get the user profile url
     79     * @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the
     80     *                        user profile url and user id
    7881     * @return string Permanent link to user profile page
    7982     */
    80     function bbp_get_favorites_permalink ( $user_id = 0 ) {
    81         return apply_filters( 'bbp_get_favorites_permalink', bbp_get_user_profile_url( $user_id ) );
    82     }
    83 
    84 /**
    85  * bbp_user_favorites_link ()
    86  *
     83    function bbp_get_favorites_permalink( $user_id = 0 ) {
     84        return apply_filters( 'bbp_get_favorites_permalink', bbp_get_user_profile_url( $user_id ), $user_id );
     85    }
     86
     87/**
    8788 * Output the link to make a topic favorite/remove a topic from favorites
    8889 *
    89  * @package bbPress
    90  * @subpackage Template Tags
    9190 * @since bbPress (r2652)
    9291 *
    93  * @param array $add optional
    94  * @param array $rem optional
    95  * @param int $user_id optional
    96  *
    97  * @uses bbp_get_user_favorites_link()
    98  */
    99 function bbp_user_favorites_link ( $add = array(), $rem = array(), $user_id = 0 ) {
     92 * @param array $add Optional. Add to favorites args
     93 * @param array $rem Optional. Remove from favorites args
     94 * @param int $user_id Optional. User id
     95 * @uses bbp_get_user_favorites_link() To get the user favorites link
     96 */
     97function bbp_user_favorites_link( $add = array(), $rem = array(), $user_id = 0 ) {
    10098    echo bbp_get_user_favorites_link( $add, $rem, $user_id );
    10199}
    102100    /**
    103      * bbp_get_user_favorites_link ()
    104      *
    105      * Return the link to make a topic favorite/remove a topic from favorites
    106      *
    107      * @package bbPress
    108      * @subpackage Template Tags
     101     * User favorites link
     102     *
     103     * Return the link to make a topic favorite/remove a topic from
     104     * favorites
     105     *
    109106     * @since bbPress (r2652)
    110107     *
    111      * @param array $add optional
    112      * @param array $rem optional
    113      * @param int $user_id optional
    114      *
    115      * @uses apply_filters
    116      * @return string Permanent link to topic
    117      */
    118     function bbp_get_user_favorites_link ( $add = array(), $rem = array(), $user_id = 0 ) {
     108     * @param array $add Optional. Add to favorites args
     109     * @param array $rem Optional. Remove from favorites args
     110     * @param int $user_id Optional. User id
     111     * @uses bbp_get_user_id() To get the user id
     112     * @uses current_user_can() If the current user can edit the user
     113     * @uses bbp_get_topic_id() To get the topic id
     114     * @uses bbp_is_user_favorite() To check if the topic is user's favorite
     115     * @uses bbp_get_favorites_permalink() To get the favorites permalink
     116     * @uses bbp_get_topic_permalink() To get the topic permalink
     117     * @uses bbp_is_favorites() Is it the favorites page?
     118     * @uses apply_filters() Calls 'bbp_get_user_favorites_link' with the
     119     *                        html, add args, remove args, user & topic id
     120     * @return string User favorites link
     121     */
     122    function bbp_get_user_favorites_link( $add = array(), $rem = array(), $user_id = 0 ) {
    119123        global $bbp;
    120124
     
    174178
    175179/**
    176  * bbp_subscriptions_permalink ()
    177  *
    178180 * Output the link to the user's subscriptions page (profile page)
    179181 *
    180  * @package bbPress
    181  * @subpackage Template Tags
    182  * @since bbPress (r2688)
    183  *
    184  * @param int $user_id optional
    185  * @uses bbp_get_subscriptions_permalink()
    186  */
    187 function bbp_subscriptions_permalink ( $user_id = 0 ) {
     182 * @since bbPress (r2688)
     183 *
     184 * @param int $user_id Optional. User id
     185 * @uses bbp_get_subscriptions_permalink() To get the subscriptions link
     186 */
     187function bbp_subscriptions_permalink( $user_id = 0 ) {
    188188    echo bbp_get_subscriptions_permalink( $user_id );
    189189}
    190190    /**
    191      * bbp_get_subscriptions_permalink ()
    192      *
    193191     * Return the link to the user's subscriptions page (profile page)
    194192     *
    195      * @package bbPress
    196      * @subpackage Template Tags
    197193     * @since bbPress (r2688)
    198194     *
    199      * @param int $user_id optional
    200      * @uses apply_filters
    201      * @uses bbp_get_user_profile_url
    202      * @return string Permanent link to user profile page
    203      */
    204     function bbp_get_subscriptions_permalink ( $user_id = 0 ) {
    205         return apply_filters( 'bbp_get_favorites_permalink', bbp_get_user_profile_url( $user_id ) );
    206     }
    207 
    208 /**
    209  * bbp_user_subscribe_link ()
    210  *
     195     * @param int $user_id Optional. User id
     196     * @uses bbp_get_user_profile_url() To get the user profile url
     197     * @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the
     198     *                        user profile url and user id
     199     * @return string Permanent link to user subscriptions page
     200     */
     201    function bbp_get_subscriptions_permalink( $user_id = 0 ) {
     202        return apply_filters( 'bbp_get_favorites_permalink', bbp_get_user_profile_url( $user_id ), $user_id );
     203    }
     204
     205/**
    211206 * Output the link to subscribe/unsubscribe from a topic
    212207 *
    213  * @package bbPress
    214  * @subpackage Template Tags
    215208 * @since bbPress (r2668)
    216209 *
    217  * @param mixed $args
    218  *
    219  * @uses bbp_get_user_subscribe_link()
    220  */
    221 function bbp_user_subscribe_link ( $args = '' ) {
     210 * @param mixed $args See {@link bbp_get_user_subscribe_link()}
     211 * @uses bbp_get_user_subscribe_link() To get the subscribe link
     212 */
     213function bbp_user_subscribe_link( $args = '' ) {
    222214    echo bbp_get_user_subscribe_link( $args );
    223215}
    224216    /**
    225      * bbp_get_user_subscribe_link ()
    226      *
    227217     * Return the link to subscribe/unsubscribe from a topic
    228218     *
    229      * @package bbPress
    230      * @subpackage Template Tags
    231219     * @since bbPress (r2668)
    232220     *
    233      * @param mixed $args
    234      *
    235      * @uses apply_filters
     221     * @param mixed $args This function supports these arguments:
     222     *  - subscribe: Subscribe text
     223     *  - unsubscribe: Unsubscribe text
     224     *  - user_id: User id
     225     *  - topic_id: Topic id
     226     *  - before: Before the link
     227     *  - after: After the link
     228     * @param int $user_id Optional. User id
     229     * @uses bbp_get_user_id() To get the user id
     230     * @uses current_user_can() To check if the current user can edit user
     231     * @uses bbp_get_topic_id() To get the topic id
     232     * @uses bbp_is_user_subscribed() To check if the user is subscribed
     233     * @uses bbp_is_subscriptions() To check if it's the subscriptions page
     234     * @uses bbp_get_subscriptions_permalink() To get subscriptions link
     235     * @uses bbp_get_topic_permalink() To get topic link
     236     * @uses apply_filters() Calls 'bbp_get_user_subscribe_link' with the
     237     *                        link, args, user id & topic id
    236238     * @return string Permanent link to topic
    237239     */
    238     function bbp_get_user_subscribe_link ( $args = '', $user_id = 0 ) {
     240    function bbp_get_user_subscribe_link( $args = '', $user_id = 0 ) {
    239241        global $bbp;
    240242
     
    257259        if ( !$user_id = bbp_get_user_id( $user_id, true, true ) )
    258260            return false;
    259        
     261
    260262        // No link if you can't edit yourself
    261263        if ( !current_user_can( 'edit_user', (int) $user_id ) )
     
    282284
    283285        // Return the link
    284         return apply_filters( 'bbp_get_user_subscribe_link', $html, $subscribe, $unsubscribe, $user_id, $topic_id );
     286        return apply_filters( 'bbp_get_user_subscribe_link', $html, $args, $user_id, $topic_id );
    285287    }
    286288
     
    288290
    289291/**
    290  * bbp_current_user_id ()
    291  *
    292292 * Output ID of current user
    293293 *
    294  * @uses bbp_get_current_user_id()
    295  */
    296 function bbp_current_user_id () {
     294 * @since bbPress (r2574)
     295 *
     296 * @uses bbp_get_current_user_id() To get the current user id
     297 */
     298function bbp_current_user_id() {
    297299    echo bbp_get_current_user_id();
    298300}
    299301    /**
    300      * bbp_get_current_user_id ()
    301      *
    302302     * Return ID of current user
    303303     *
    304      * @global object $current_user
    305      * @global string $user_identity
    306      * @return int
    307      */
    308     function bbp_get_current_user_id () {
    309         global $bbp;
    310 
    311         $retval = isset( $bbp->current_user ) ? $bbp->current_user->ID : 0;
    312 
    313         return apply_filters( 'bbp_get_current_user_id', $retval );
    314     }
    315 
    316 /**
    317  * bbp_displayed_user_id ()
    318  *
     304     * @since bbPress (r2574)
     305     *
     306     * @uses bbp_get_user_id() To get the current user id
     307     * @uses apply_filters() Calls 'bbp_get_current_user_id' with the id
     308     * @return int Current user id
     309     */
     310    function bbp_get_current_user_id() {
     311        return apply_filters( 'bbp_get_current_user_id', bbp_get_user_id( 0, false, true ) );
     312    }
     313
     314/**
    319315 * Output ID of displayed user
    320316 *
    321  * @uses bbp_get_displayed_user_id()
    322  */
    323 function bbp_displayed_user_id () {
     317 * @since bbPress (r2688)
     318 *
     319 * @uses bbp_get_displayed_user_id() To get the displayed user id
     320 */
     321function bbp_displayed_user_id() {
    324322    echo bbp_get_displayed_user_id();
    325323}
    326324    /**
    327      * bbp_get_displayed_user_id ()
    328      *
    329325     * Return ID of displayed user
    330326     *
    331      * @global object $displayed_user
    332      * @global string $user_identity
    333      * @return int
    334      */
    335     function bbp_get_displayed_user_id () {
    336         global $bbp;
    337 
    338         $retval = isset( $bbp->displayed_user ) ? $bbp->displayed_user->ID : 0;
    339 
    340         return apply_filters( 'bbp_get_displayed_user_id', $retval );
    341     }
    342 
    343 /**
    344  * bbp_get_displayed_user_field ()
    345  *
     327     * @since bbPress (r2688)
     328     *
     329     * @uses bbp_get_user_id() To get the displayed user id
     330     * @uses apply_filters() Calls 'bbp_get_displayed_user_id' with the id
     331     * @return int Displayed user id
     332     */
     333    function bbp_get_displayed_user_id() {
     334        return apply_filters( 'bbp_get_displayed_user_id', bbp_get_user_id( 0, true, false ) );
     335    }
     336
     337/**
    346338 * Return a sanitized user field value
    347339 *
    348  * @global bbPress $bbp
    349  * @param string $field
    350  * @return string
    351  */
    352 function bbp_get_displayed_user_field ( $field = '' ) {
     340 * @since bbPress (r2688)
     341 *
     342 * @param string $field Field to get
     343 * @uses sanitize_text_field() To sanitize the field
     344 * @uses esc_attr() To sanitize the field
     345 * @return string|bool Value of the field if it exists, else false
     346 */
     347function bbp_get_displayed_user_field( $field = '' ) {
    353348    global $bbp;
    354349
    355350    // Return field if exists
    356351    if ( isset( $bbp->displayed_user->$field ) )
    357         return esc_attr( sanitize_text_field ( $bbp->displayed_user->$field ) );
     352        return esc_attr( sanitize_text_field( $bbp->displayed_user->$field ) );
    358353
    359354    // Return empty
     
    362357
    363358/**
    364  * bbp_current_user_name ()
    365  *
    366359 * Output name of current user
    367360 *
    368  * @uses bbp_get_current_user_name()
    369  */
    370 function bbp_current_user_name () {
     361 * @since bbPress (r2574)
     362 *
     363 * @uses bbp_get_current_user_name() To get the current user name
     364 */
     365function bbp_current_user_name() {
    371366    echo bbp_get_current_user_name();
    372367}
    373368    /**
    374      * bbp_get_current_user_name ()
    375      *
    376369     * Return name of current user
    377370     *
    378      * @global object $current_user
    379      * @global string $user_identity
     371     * @since bbPress (r2574)
     372     *
     373     * @uses apply_filters() Calls 'bbp_get_current_user_name' with the
     374     *                        current user name
    380375     * @return string
    381376     */
    382     function bbp_get_current_user_name () {
    383         global $current_user, $user_identity;
     377    function bbp_get_current_user_name() {
     378        global $user_identity;
    384379
    385380        if ( is_user_logged_in() )
     
    392387
    393388/**
    394  * bbp_current_user_avatar ()
    395  *
    396389 * Output avatar of current user
    397390 *
    398  * @uses bbp_get_current_user_avatar()
    399  */
    400 function bbp_current_user_avatar ( $size = 40 ) {
     391 * @since bbPress (r2574)
     392 *
     393 * @param int $size Size of the avatar. Defaults to 40
     394 * @uses bbp_get_current_user_avatar() To get the current user avatar
     395 */
     396function bbp_current_user_avatar( $size = 40 ) {
    401397    echo bbp_get_current_user_avatar( $size );
    402398}
    403399
    404400    /**
    405      * bbp_get_current_user_avatar ( $size = 40 )
    406      *
    407401     * Return avatar of current user
    408402     *
    409      * @global object $current_user
    410      * @param int $size
    411      * @return string
    412      */
    413     function bbp_get_current_user_avatar ( $size = 40 ) {
    414         global $current_user;
    415 
    416         return apply_filters( 'bbp_get_current_user_avatar', get_avatar( bbp_get_current_user_id(), $size ) );
    417     }
    418 
    419 /**
    420  * bbp_user_profile_link ()
    421  *
     403     * @since bbPress (r2574)
     404     *
     405     * @param int $size Size of the avatar. Defaults to 40
     406     * @uses bbp_get_current_user_id() To get the current user id
     407     * @uses get_avatar() To get the avatar
     408     * @uses apply_filters() Calls 'bbp_get_current_user_avatar' with the
     409     *                        avatar and size
     410     * @return string Current user avatar
     411     */
     412    function bbp_get_current_user_avatar( $size = 40 ) {
     413        return apply_filters( 'bbp_get_current_user_avatar', get_avatar( bbp_get_current_user_id(), $size ), $size );
     414    }
     415
     416/**
    422417 * Output link to the profile page of a user
    423418 *
    424  * @package bbPress
    425  * @subpackage Template Tags
    426  * @since bbPress (r2688)
    427  *
    428  * @uses bbp_get_user_profile_link ()
    429  *
    430  * @param int $user_id
    431  */
    432 function bbp_user_profile_link ( $user_id = 0 ) {
     419 * @since bbPress (r2688)
     420 *
     421 * @param int $user_id Optional. User id
     422 * @uses bbp_get_user_profile_link() To get user profile link
     423 */
     424function bbp_user_profile_link( $user_id = 0 ) {
    433425    echo bbp_get_user_profile_link( $user_id );
    434426}
    435427    /**
    436      * bbp_get_user_profile_link ()
    437      *
    438428     * Return link to the profile page of a user
    439429     *
    440      * @package bbPress
    441      * @subpackage Template Tags
    442430     * @since bbPress (r2688)
    443431     *
    444      * @uses bbp_get_user_profile_url ()
    445      *
    446      * @param int $user_id
    447      * @return string
    448      */
    449     function bbp_get_user_profile_link ( $user_id = 0 ) {
     432     * @param int $user_id Optional. User id
     433     * @uses bbp_get_user_id() To get user id
     434     * @uses get_userdata() To get user data
     435     * @uses bbp_get_user_profile_url() To get user profile url
     436     * @uses apply_filters() Calls 'bbp_get_user_profile_link' with the user
     437     *                        profile link and user id
     438     * @return string User profile link
     439     */
     440    function bbp_get_user_profile_link( $user_id = 0 ) {
    450441        if ( !$user_id = bbp_get_user_id( $user_id ) )
    451442            return false;
     
    459450
    460451/**
    461  * bbp_user_profile_url ()
    462  *
    463452 * Output URL to the profile page of a user
    464453 *
    465  * @package bbPress
    466  * @subpackage Template Tags
    467  * @since bbPress (r2688)
    468  *
    469  * @uses bbp_get_user_profile_url ()
    470  *
    471  * @param int $user_id
    472  */
    473 function bbp_user_profile_url ( $user_id = 0, $user_nicename = '' ) {
     454 * @since bbPress (r2688)
     455 *
     456 * @param int $user_id Optional. User id
     457 * @param string $user_nicename Optional. User nicename
     458 * @uses bbp_get_user_profile_url() To get user profile url
     459 */
     460function bbp_user_profile_url( $user_id = 0, $user_nicename = '' ) {
    474461    echo bbp_get_user_profile_url( $user_id );
    475462}
    476463    /**
    477      * bbp_get_user_profile_url ()
    478      *
    479464     * Return URL to the profile page of a user
    480465     *
    481      * @package bbPress
    482      * @subpackage Template Tags
    483466     * @since bbPress (r2688)
    484467     *
    485      * @param int $user_id
    486      * @param string $user_nicename
    487      *
    488      * @return string
    489      */
    490     function bbp_get_user_profile_url ( $user_id = 0, $user_nicename = '' ) {
     468     * @param int $user_id Optional. User id
     469     * @param string $user_nicename Optional. User nicename
     470     * @uses bbp_get_user_id() To get user id
     471     * @uses add_query_arg() To add custom args to the url
     472     * @uses home_url() To get blog home url
     473     * @uses apply_filters() Calls 'bbp_get_user_profile_url' with the user
     474     *                        profile url, user id and user nicename
     475     * @return string User profile url
     476     */
     477    function bbp_get_user_profile_url( $user_id = 0, $user_nicename = '' ) {
    491478        global $wp_rewrite, $bbp;
    492479
     
    494481        if ( !$user_id = bbp_get_user_id( $user_id ) )
    495482            return false;
    496        
    497         // URL for pretty permalinks
    498         $url = !empty( $wp_rewrite->permalink_structure ) ? $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%' : '';
    499483
    500484        // No pretty permalinks
    501         if ( empty( $url ) ) {
    502             $file = home_url( '/' );
    503             $url  = $file . '?bbp_user=' . $user_id;
     485        if ( empty( $wp_rewrite->permalink_structure ) ) {
     486            $url = add_query_arg( array( 'bbp_user' => $user_id ), home_url( '/' ) );
    504487
    505488        // Get URL safe user slug
    506489        } else {
     490            $url = $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%';
     491
    507492            if ( empty( $user_nicename ) ) {
    508493                $user = get_userdata( $user_id );
     
    510495                    $user_nicename = $user->user_nicename;
    511496            }
     497
    512498            $url = str_replace( '%bbp_user%', $user_nicename, $url );
    513499            $url = home_url( user_trailingslashit( $url ) );
     
    519505
    520506/**
    521  * bbp_user_profile_edit_link ()
    522  *
    523507 * Output link to the profile edit page of a user
    524508 *
    525  * @package bbPress
    526  * @subpackage Template Tags
    527  * @since bbPress (r2688)
    528  *
    529  * @uses bbp_get_user_profile_edit_link ()
    530  *
    531  * @param int $user_id
    532  */
    533 function bbp_user_profile_edit_link ( $user_id = 0 ) {
     509 * @since bbPress (r2688)
     510 *
     511 * @param int $user_id Optional. User id
     512 * @uses bbp_get_user_profile_edit_link() To get user profile edit link
     513 */
     514function bbp_user_profile_edit_link( $user_id = 0 ) {
    534515    echo bbp_get_user_profile_edit_link( $user_id );
    535516}
    536517    /**
    537      * bbp_get_user_profile_edit_link ()
    538      *
    539518     * Return link to the profile edit page of a user
    540519     *
    541      * @package bbPress
    542      * @subpackage Template Tags
    543520     * @since bbPress (r2688)
    544521     *
    545      * @uses bbp_get_user_profile_edit_url ()
    546      *
    547      * @param int $user_id
    548      * @return string
    549      */
    550     function bbp_get_user_profile_edit_link ( $user_id = 0 ) {
     522     * @param int $user_id Optional. User id
     523     * @uses bbp_get_user_id() To get user id
     524     * @uses get_userdata() To get user data
     525     * @uses bbp_get_user_profile_edit_url() To get user profile edit url
     526     * @uses apply_filters() Calls 'bbp_get_user_profile_link' with the edit
     527     *                        link and user id
     528     * @return string User profile edit link
     529     */
     530    function bbp_get_user_profile_edit_link( $user_id = 0 ) {
    551531        if ( !$user_id = bbp_get_user_id( $user_id ) )
    552532            return false;
     
    559539
    560540/**
    561  * bbp_user_profile_edit_url ()
    562  *
    563541 * Output URL to the profile edit page of a user
    564542 *
    565  * @package bbPress
    566  * @subpackage Template Tags
    567  * @since bbPress (r2688)
    568  *
    569  * @uses bbp_get_user_edit_profile_url ()
    570  *
    571  * @param int $user_id
    572  */
    573 function bbp_user_profile_edit_url ( $user_id = 0, $user_nicename = '' ) {
     543 * @since bbPress (r2688)
     544 *
     545 * @param int $user_id Optional. User id
     546 * @param string $user_nicename Optional. User nicename
     547 * @uses bbp_get_user_profile_edit_url() To get user profile edit url
     548 */
     549function bbp_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) {
    574550    echo bbp_get_user_profile_edit_url( $user_id );
    575551}
    576552    /**
    577      * bbp_get_user_profile_edit_url ()
    578      *
    579553     * Return URL to the profile edit page of a user
    580554     *
    581      * @package bbPress
    582      * @subpackage Template Tags
    583555     * @since bbPress (r2688)
    584556     *
    585      * @param int $user_id
    586      * @param string $user_nicename
    587      *
     557     * @param int $user_id Optional. User id
     558     * @param string $user_nicename Optional. User nicename
     559     * @uses bbp_get_user_id() To get user id
     560     * @uses add_query_arg() To add custom args to the url
     561     * @uses home_url() To get blog home url
     562     * @uses apply_filters() Calls 'bbp_get_user_edit_profile_url' with the
     563     *                        edit profile url, user id and user nicename
    588564     * @return string
    589565     */
    590     function bbp_get_user_profile_edit_url ( $user_id = 0, $user_nicename = '' ) {
     566    function bbp_get_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) {
    591567        global $wp_rewrite, $bbp;
    592568
     
    594570            return;
    595571
    596         $url = !empty( $wp_rewrite->permalink_structure ) ? $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%/edit' : '';
    597 
    598         if ( empty( $url ) ) {
    599             $url  = add_query_arg( array( 'bbp_user' => $user_id, 'bbp_edit_profile' => '1' ), home_url( '/' ) );
     572        if ( empty( $wp_rewrite->permalink_structure ) ) {
     573            $url = add_query_arg( array( 'bbp_user' => $user_id, 'edit' => '1' ), home_url( '/' ) );
    600574        } else {
     575            $url = $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%/edit';
     576
    601577            if ( empty( $user_nicename ) ) {
    602578                $user = get_userdata( $user_id );
     
    604580                    $user_nicename = $user->user_nicename;
    605581            }
     582
    606583            $url = str_replace( '%bbp_user%', $user_nicename, $url );
    607584            $url = home_url( user_trailingslashit( $url ) );
     
    615592
    616593/**
    617  * bbp_edit_user_success ()
    618  */
    619 function bbp_notice_edit_user_success () {
     594 * Edit profile success message
     595 *
     596 * @since bbPress (r2688)
     597 *
     598 * @uses bbp_is_user_profile_page() To check if it's the profile page
     599 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page
     600 */
     601function bbp_notice_edit_user_success() {
    620602    if ( isset( $_GET['updated'] ) && ( bbp_is_user_profile_page() || bbp_is_user_profile_edit() ) ) : ?>
    621603
     
    626608    <?php endif;
    627609}
    628 add_action( 'bbp_template_notices', 'bbp_notice_edit_user_success' );
    629 
    630 function bbp_notice_edit_user_is_super_admin () {
     610
     611/**
     612 * Super admin privileges notice
     613 *
     614 * @since bbPress (r2688)
     615 *
     616 * @uses is_multisite() To check if the blog is multisite
     617 * @uses bbp_is_user_profile_page() To check if it's the profile page
     618 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page
     619 * @uses current_user_can() To check if the current user can manage network
     620 *                           options
     621 * @uses bbp_get_displayed_user_id() To get the displayed user id
     622 * @uses is_super_admin() To check if the user is super admin
     623 * @uses bbp_is_user_home() To check if it's the user home
     624 */
     625function bbp_notice_edit_user_is_super_admin() {
    631626    if ( is_multisite() && ( bbp_is_user_profile_page() || bbp_is_user_profile_edit() ) && current_user_can( 'manage_network_options' ) && is_super_admin( bbp_get_displayed_user_id() ) ) : ?>
    632627
     
    637632<?php endif;
    638633}
    639 add_action( 'bbp_template_notices', 'bbp_notice_edit_user_is_super_admin', 2 );
    640 
    641 /**
    642  * bbp_edit_user_display_name()
    643  *
     634
     635/**
    644636 * Drop down for selecting the user's display name
    645637 *
    646  * @global bbPress $bbp
    647  */
    648 function bbp_edit_user_display_name () {
     638 * @since bbPress (r2688)
     639 */
     640function bbp_edit_user_display_name() {
    649641    global $bbp;
    650642
     
    684676
    685677/**
    686  * bbp_edit_user_role ()
    687  *
    688678 * Output role selector (for user edit)
    689679 *
    690  * @package bbPress
    691  * @subpackage Template
    692  *
    693  * @param string $default slug for the role that should be already selected
    694  */
    695 function bbp_edit_user_role () {
     680 * @since bbPress (r2688)
     681 */
     682function bbp_edit_user_role() {
    696683    global $bbp;
    697684
     
    722709}
    723710
    724 function bbp_edit_user_contact_methods( $user_id = 0 ) {
     711/**
     712 * Return user contact methods Selectbox
     713 *
     714 * @since bbPress (r2688)
     715 *
     716 * @return string user contact methods
     717 */
     718function bbp_edit_user_contact_methods() {
    725719    global $bbp;
    726720
Note: See TracChangeset for help on using the changeset viewer.