Skip to:
Content

bbPress.org

Changeset 2812


Ignore:
Timestamp:
01/17/2011 06:57:34 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Normalize bbp-includes directory. Mostly documentation fixes. Introduce bbp-shortcodes placeholder.

Location:
branches/plugin/bbp-includes
Files:
1 added
10 edited

Legend:

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

    r2783 r2812  
    77 * @subpackage Capabilities
    88 */
     9
    910/**
    1011 * Adds bbPress-specific user roles.
  • branches/plugin/bbp-includes/bbp-forum-template.php

    r2808 r2812  
    88 */
    99
    10 /** START - Forum Loop Functions **********************************************/
     10/** Forum Loop ****************************************************************/
    1111
    1212/**
     
    7878}
    7979
    80 /** FORUM *********************************************************************/
     80/** Forum *********************************************************************/
    8181
    8282/**
     
    517517}
    518518
    519 /** FORUM LAST TOPIC **********************************************************/
     519/** Forum Last Topic **********************************************************/
    520520
    521521/**
     
    660660    }
    661661
    662 /** FORUM LAST REPLY **********************************************************/
     662/** Forum Last Reply **********************************************************/
    663663
    664664/**
     
    862862    }
    863863
    864 /** FORUM COUNTS **************************************************************/
     864/** Forum Counts **************************************************************/
    865865
    866866/**
  • branches/plugin/bbp-includes/bbp-general-template.php

    r2811 r2812  
    88 */
    99
    10 /** START - WordPress Add-on Actions ******************************************/
     10/** Add-on Actions ************************************************************/
    1111
    1212/**
     
    3232}
    3333
    34 /** END - WordPress Add-on Actions ********************************************/
    35 
    36 /** START is_ Functions *******************************************************/
     34/** is_ ***********************************************************************/
    3735
    3836/**
     
    319317}
    320318
    321 /** END is_ Functions *********************************************************/
    322 
    323 /** START Form Functions ******************************************************/
     319/** Forms *********************************************************************/
    324320
    325321/**
     
    619615
    620616    <?php wp_referer_field(); ?>
     617
    621618    <?php wp_nonce_field( 'update-user_' . bbp_get_displayed_user_id() );
    622619}
     
    659656}
    660657
    661 /** END Form Functions ********************************************************/
    662 
    663 /** Start Views ***************************************************************/
     658/** Views *********************************************************************/
    664659
    665660/**
     
    772767    }
    773768
    774 /** End Views *****************************************************************/
    775 
    776 /** Start General Functions ***************************************************/
    777 
    778 /**
    779  * Display possible error messages inside a template file
    780  *
    781  * @since bbPress (r2688)
    782  *
    783  * @uses WP_Error bbPress::errors::get_error_codes() To get the error codes
    784  * @uses WP_Error bbPress::errors::get_error_messages() To get the error
    785  *                                                       messages
    786  * @uses is_wp_error() To check if it's a {@link WP_Error}
    787  */
    788 function bbp_error_messages() {
    789     global $bbp;
    790 
    791     if ( isset( $bbp->errors ) && is_wp_error( $bbp->errors ) && $bbp->errors->get_error_codes() ) : ?>
    792 
    793         <div class="bbp-template-notice error">
    794             <p>
    795                 <?php echo implode( "</p>\n<p>", $bbp->errors->get_error_messages() ); ?>
    796             </p>
    797         </div>
    798 
    799 <?php endif;
    800 }
     769/** Query *********************************************************************/
     770
     771/**
     772 * Get the '_bbp_query_name' setting
     773 *
     774 * @since bbPress (r2695)
     775 *
     776 * @uses get_query_var() To get the query var '_bbp_query_name'
     777 * @return string To return the query var value
     778 */
     779function bbp_get_query_name()  {
     780    return get_query_var( '_bbp_query_name' );
     781}
     782
     783/**
     784 * Set the '_bbp_query_name' setting to $name
     785 *
     786 * @since bbPress (r2692)
     787 *
     788 * @param string $name What to set the query var to
     789 * @uses set_query_var() To set the query var '_bbp_query_name'
     790 */
     791function bbp_set_query_name( $name = '' )  {
     792    set_query_var( '_bbp_query_name', $name );
     793}
     794
     795/**
     796 * Used to clear the '_bbp_query_name' setting
     797 *
     798 * @since bbPress (r2692)
     799 *
     800 * @uses bbp_set_query_name() To set the query var '_bbp_query_name' to ''
     801 */
     802function bbp_reset_query_name() {
     803    bbp_set_query_name();
     804}
     805
     806/** Breadcrumbs ***************************************************************/
    801807
    802808/**
     
    890896    }
    891897
     898/** Topic Tags ***************************************************************/
     899
    892900/**
    893901 * Output all of the allowed tags in HTML format with attributes.
     
    919927    }
    920928
    921 /** Start Query Functions *****************************************************/
    922 
    923 /**
    924  * Get the '_bbp_query_name' setting
    925  *
    926  * @since bbPress (r2695)
    927  *
    928  * @uses get_query_var() To get the query var '_bbp_query_name'
    929  * @return string To return the query var value
    930  */
    931 function bbp_get_query_name()  {
    932     return get_query_var( '_bbp_query_name' );
    933 }
    934 
    935 /**
    936  * Set the '_bbp_query_name' setting to $name
    937  *
    938  * @since bbPress (r2692)
    939  *
    940  * @param string $name What to set the query var to
    941  * @uses set_query_var() To set the query var '_bbp_query_name'
    942  */
    943 function bbp_set_query_name( $name = '' )  {
    944     set_query_var( '_bbp_query_name', $name );
    945 }
    946 
    947 /**
    948  * Used to clear the '_bbp_query_name' setting
    949  *
    950  * @since bbPress (r2692)
    951  *
    952  * @uses bbp_set_query_name() To set the query var '_bbp_query_name' to ''
    953  */
    954 function bbp_reset_query_name() {
    955     bbp_set_query_name();
     929/** Errors ********************************************************************/
     930
     931/**
     932 * Display possible error messages inside a template file
     933 *
     934 * @since bbPress (r2688)
     935 *
     936 * @uses WP_Error bbPress::errors::get_error_codes() To get the error codes
     937 * @uses WP_Error bbPress::errors::get_error_messages() To get the error
     938 *                                                       messages
     939 * @uses is_wp_error() To check if it's a {@link WP_Error}
     940 */
     941function bbp_error_messages() {
     942    global $bbp;
     943
     944    if ( isset( $bbp->errors ) && is_wp_error( $bbp->errors ) && $bbp->errors->get_error_codes() ) : ?>
     945
     946        <div class="bbp-template-notice error">
     947            <p>
     948                <?php echo implode( "</p>\n<p>", $bbp->errors->get_error_messages() ); ?>
     949            </p>
     950        </div>
     951
     952<?php endif;
    956953}
    957954
  • branches/plugin/bbp-includes/bbp-loader.php

    r2789 r2812  
    22
    33/**
    4  * The main bbPress loader.
     4 * bbPress Loader Actions
    55 *
    66 * @package bbPress
     
    99
    1010/** Main Actions **************************************************************/
     11
     12/**
     13 * Main action responsible for constants, globals, and includes
     14 *
     15 * @since bbPress (r2599)
     16 *
     17 * @uses do_action() Calls 'bbp_loaded'
     18 */
     19function bbp_loaded() {
     20    do_action( 'bbp_loaded' );
     21}
    1122
    1223/**
     
    5263function bbp_setup_globals() {
    5364    do_action( 'bbp_setup_globals' );
    54 }
    55 
    56 /**
    57  * Main action responsible for constants, globals, and includes
    58  *
    59  * @since bbPress (r2599)
    60  *
    61  * @uses do_action() Calls 'bbp_loaded'
    62  */
    63 function bbp_loaded() {
    64     do_action( 'bbp_loaded' );
    6565}
    6666
  • branches/plugin/bbp-includes/bbp-options.php

    r2790 r2812  
    2424    $options = array (
    2525
    26         /** SETTINGS **********************************************************/
     26        /** Settings **********************************************************/
    2727
    2828        // Lock post editing after 5 minutes
     
    4747        '_bbp_replies_per_page'     => '15',
    4848
    49         /** SLUGS *************************************************************/
     49        /** Slugs *************************************************************/
    5050
    5151        // Root slug
     
    9494 */
    9595function bbp_is_favorites_active() {
    96     return (bool) get_option( '_bbp_enable_favorites', true );
     96    return apply_filters( 'bbp_is_favorites_active', (bool) get_option( '_bbp_enable_favorites', true ) );
    9797}
    9898
     
    106106 */
    107107function bbp_is_subscriptions_active() {
    108     return (bool) get_option( '_bbp_enable_subscriptions' );
     108    return apply_filters( 'bbp_is_subscriptions_active', (bool) get_option( '_bbp_enable_subscriptions' ) );
    109109}
    110110
  • branches/plugin/bbp-includes/bbp-reply-template.php

    r2809 r2812  
    88 */
    99
    10 /** START - Reply Loop Functions **********************************************/
     10/** Reply Loop Functions ******************************************************/
    1111
    1212/**
     
    15121512    }
    15131513
    1514 /** END Reply Loop Functions **************************************************/
    1515 
    15161514?>
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r2806 r2812  
    12001200        }
    12011201    }
    1202 }/** Topic Updaters ************************************************************/
     1202}
     1203
     1204/** Topic Updaters ************************************************************/
    12031205
    12041206/**
  • branches/plugin/bbp-includes/bbp-topic-template.php

    r2810 r2812  
    88 */
    99
    10 /** START - Topic Loop Functions **********************************************/
     10/** Topic Loop ****************************************************************/
    1111
    1212/**
     
    11481148    }
    11491149
    1150 /** TOPIC LAST REPLY **********************************************************/
     1150/** Topic Last Reply **********************************************************/
    11511151
    11521152/**
  • branches/plugin/bbp-includes/bbp-user-template.php

    r2803 r2812  
    22
    33/**
    4  * bbPress User Functions
     4 * bbPress User Template Tags
    55 *
    66 * @package bbPress
     
    88 */
    99
    10 /** START User Functions ******************************************************/
     10/** Users *********************************************************************/
    1111
    1212/**
     
    5757    }
    5858
    59 /** START Favorites Functions *************************************************/
     59
     60/**
     61 * Output ID of current user
     62 *
     63 * @since bbPress (r2574)
     64 *
     65 * @uses bbp_get_current_user_id() To get the current user id
     66 */
     67function bbp_current_user_id() {
     68    echo bbp_get_current_user_id();
     69}
     70    /**
     71     * Return ID of current user
     72     *
     73     * @since bbPress (r2574)
     74     *
     75     * @uses bbp_get_user_id() To get the current user id
     76     * @uses apply_filters() Calls 'bbp_get_current_user_id' with the id
     77     * @return int Current user id
     78     */
     79    function bbp_get_current_user_id() {
     80        return apply_filters( 'bbp_get_current_user_id', bbp_get_user_id( 0, false, true ) );
     81    }
     82
     83/**
     84 * Output ID of displayed user
     85 *
     86 * @since bbPress (r2688)
     87 *
     88 * @uses bbp_get_displayed_user_id() To get the displayed user id
     89 */
     90function bbp_displayed_user_id() {
     91    echo bbp_get_displayed_user_id();
     92}
     93    /**
     94     * Return ID of displayed user
     95     *
     96     * @since bbPress (r2688)
     97     *
     98     * @uses bbp_get_user_id() To get the displayed user id
     99     * @uses apply_filters() Calls 'bbp_get_displayed_user_id' with the id
     100     * @return int Displayed user id
     101     */
     102    function bbp_get_displayed_user_id() {
     103        return apply_filters( 'bbp_get_displayed_user_id', bbp_get_user_id( 0, true, false ) );
     104    }
     105
     106/**
     107 * Return a sanitized user field value
     108 *
     109 * @since bbPress (r2688)
     110 *
     111 * @param string $field Field to get
     112 * @uses sanitize_text_field() To sanitize the field
     113 * @uses esc_attr() To sanitize the field
     114 * @return string|bool Value of the field if it exists, else false
     115 */
     116function bbp_get_displayed_user_field( $field = '' ) {
     117    global $bbp;
     118
     119    // Return field if exists
     120    if ( isset( $bbp->displayed_user->$field ) )
     121        return esc_attr( sanitize_text_field( $bbp->displayed_user->$field ) );
     122
     123    // Return empty
     124    return false;
     125}
     126
     127/**
     128 * Output name of current user
     129 *
     130 * @since bbPress (r2574)
     131 *
     132 * @uses bbp_get_current_user_name() To get the current user name
     133 */
     134function bbp_current_user_name() {
     135    echo bbp_get_current_user_name();
     136}
     137    /**
     138     * Return name of current user
     139     *
     140     * @since bbPress (r2574)
     141     *
     142     * @uses apply_filters() Calls 'bbp_get_current_user_name' with the
     143     *                        current user name
     144     * @return string
     145     */
     146    function bbp_get_current_user_name() {
     147        global $user_identity;
     148
     149        if ( is_user_logged_in() )
     150            $current_user_name = $user_identity;
     151        else
     152            $current_user_name = __( 'Anonymous', 'bbpress' );
     153
     154        return apply_filters( 'bbp_get_current_user_name', $current_user_name );
     155    }
     156
     157/**
     158 * Output avatar of current user
     159 *
     160 * @since bbPress (r2574)
     161 *
     162 * @param int $size Size of the avatar. Defaults to 40
     163 * @uses bbp_get_current_user_avatar() To get the current user avatar
     164 */
     165function bbp_current_user_avatar( $size = 40 ) {
     166    echo bbp_get_current_user_avatar( $size );
     167}
     168
     169    /**
     170     * Return avatar of current user
     171     *
     172     * @since bbPress (r2574)
     173     *
     174     * @param int $size Size of the avatar. Defaults to 40
     175     * @uses bbp_get_current_user_id() To get the current user id
     176     * @uses bbp_get_current_anonymous_user_data() To get the current
     177     *                                              anonymous user's email
     178     * @uses get_avatar() To get the avatar
     179     * @uses apply_filters() Calls 'bbp_get_current_user_avatar' with the
     180     *                        avatar and size
     181     * @return string Current user avatar
     182     */
     183    function bbp_get_current_user_avatar( $size = 40 ) {
     184
     185        if ( !$user = bbp_get_current_user_id() )
     186            $user = bbp_get_current_anonymous_user_data( 'email' );
     187
     188        return apply_filters( 'bbp_get_current_user_avatar', get_avatar( $user, $size ), $size );
     189    }
     190
     191/**
     192 * Output link to the profile page of a user
     193 *
     194 * @since bbPress (r2688)
     195 *
     196 * @param int $user_id Optional. User id
     197 * @uses bbp_get_user_profile_link() To get user profile link
     198 */
     199function bbp_user_profile_link( $user_id = 0 ) {
     200    echo bbp_get_user_profile_link( $user_id );
     201}
     202    /**
     203     * Return link to the profile page of a user
     204     *
     205     * @since bbPress (r2688)
     206     *
     207     * @param int $user_id Optional. User id
     208     * @uses bbp_get_user_id() To get user id
     209     * @uses get_userdata() To get user data
     210     * @uses bbp_get_user_profile_url() To get user profile url
     211     * @uses apply_filters() Calls 'bbp_get_user_profile_link' with the user
     212     *                        profile link and user id
     213     * @return string User profile link
     214     */
     215    function bbp_get_user_profile_link( $user_id = 0 ) {
     216        if ( !$user_id = bbp_get_user_id( $user_id ) )
     217            return false;
     218
     219        $user      = get_userdata( $user_id );
     220        $name      = esc_attr( $user->display_name );
     221        $user_link = '<a href="' . bbp_get_user_profile_url( $user_id ) . '" title="' . $name . '">' . $name . '</a>';
     222
     223        return apply_filters( 'bbp_get_user_profile_link', $user_link, $user_id );
     224    }
     225
     226/**
     227 * Output URL to the profile page of a user
     228 *
     229 * @since bbPress (r2688)
     230 *
     231 * @param int $user_id Optional. User id
     232 * @param string $user_nicename Optional. User nicename
     233 * @uses bbp_get_user_profile_url() To get user profile url
     234 */
     235function bbp_user_profile_url( $user_id = 0, $user_nicename = '' ) {
     236    echo bbp_get_user_profile_url( $user_id );
     237}
     238    /**
     239     * Return URL to the profile page of a user
     240     *
     241     * @since bbPress (r2688)
     242     *
     243     * @param int $user_id Optional. User id
     244     * @param string $user_nicename Optional. User nicename
     245     * @uses bbp_get_user_id() To get user id
     246     * @uses add_query_arg() To add custom args to the url
     247     * @uses home_url() To get blog home url
     248     * @uses apply_filters() Calls 'bbp_get_user_profile_url' with the user
     249     *                        profile url, user id and user nicename
     250     * @return string User profile url
     251     */
     252    function bbp_get_user_profile_url( $user_id = 0, $user_nicename = '' ) {
     253        global $wp_rewrite, $bbp;
     254
     255        // Use displayed user ID if there is one, and one isn't requested
     256        if ( !$user_id = bbp_get_user_id( $user_id ) )
     257            return false;
     258
     259        // No pretty permalinks
     260        if ( empty( $wp_rewrite->permalink_structure ) ) {
     261            $url = add_query_arg( array( 'bbp_user' => $user_id ), home_url( '/' ) );
     262
     263        // Get URL safe user slug
     264        } else {
     265            $url = $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%';
     266
     267            if ( empty( $user_nicename ) ) {
     268                $user = get_userdata( $user_id );
     269                if ( !empty( $user->user_nicename ) )
     270                    $user_nicename = $user->user_nicename;
     271            }
     272
     273            $url = str_replace( '%bbp_user%', $user_nicename, $url );
     274            $url = home_url( user_trailingslashit( $url ) );
     275        }
     276
     277        return apply_filters( 'bbp_get_user_profile_url', $url, $user_id, $user_nicename );
     278
     279    }
     280
     281/**
     282 * Output link to the profile edit page of a user
     283 *
     284 * @since bbPress (r2688)
     285 *
     286 * @param int $user_id Optional. User id
     287 * @uses bbp_get_user_profile_edit_link() To get user profile edit link
     288 */
     289function bbp_user_profile_edit_link( $user_id = 0 ) {
     290    echo bbp_get_user_profile_edit_link( $user_id );
     291}
     292    /**
     293     * Return link to the profile edit page of a user
     294     *
     295     * @since bbPress (r2688)
     296     *
     297     * @param int $user_id Optional. User id
     298     * @uses bbp_get_user_id() To get user id
     299     * @uses get_userdata() To get user data
     300     * @uses bbp_get_user_profile_edit_url() To get user profile edit url
     301     * @uses apply_filters() Calls 'bbp_get_user_profile_link' with the edit
     302     *                        link and user id
     303     * @return string User profile edit link
     304     */
     305    function bbp_get_user_profile_edit_link( $user_id = 0 ) {
     306        if ( !$user_id = bbp_get_user_id( $user_id ) )
     307            return false;
     308
     309        $user      = get_userdata( $user_id );
     310        $name      = $user->display_name;
     311        $edit_link = '<a href="' . bbp_get_user_profile_url( $user_id ) . '" title="' . esc_attr( $name ) . '">' . $name . '</a>';
     312        return apply_filters( 'bbp_get_user_profile_link', $edit_link, $user_id );
     313    }
     314
     315/**
     316 * Output URL to the profile edit page of a user
     317 *
     318 * @since bbPress (r2688)
     319 *
     320 * @param int $user_id Optional. User id
     321 * @param string $user_nicename Optional. User nicename
     322 * @uses bbp_get_user_profile_edit_url() To get user profile edit url
     323 */
     324function bbp_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) {
     325    echo bbp_get_user_profile_edit_url( $user_id );
     326}
     327    /**
     328     * Return URL to the profile edit page of a user
     329     *
     330     * @since bbPress (r2688)
     331     *
     332     * @param int $user_id Optional. User id
     333     * @param string $user_nicename Optional. User nicename
     334     * @uses bbp_get_user_id() To get user id
     335     * @uses add_query_arg() To add custom args to the url
     336     * @uses home_url() To get blog home url
     337     * @uses apply_filters() Calls 'bbp_get_user_edit_profile_url' with the
     338     *                        edit profile url, user id and user nicename
     339     * @return string
     340     */
     341    function bbp_get_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) {
     342        global $wp_rewrite, $bbp;
     343
     344        if ( !$user_id = bbp_get_user_id( $user_id ) )
     345            return;
     346
     347        if ( empty( $wp_rewrite->permalink_structure ) ) {
     348            $url = add_query_arg( array( 'bbp_user' => $user_id, 'edit' => '1' ), home_url( '/' ) );
     349        } else {
     350            $url = $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%/edit';
     351
     352            if ( empty( $user_nicename ) ) {
     353                $user = get_userdata( $user_id );
     354                if ( !empty( $user->user_nicename ) )
     355                    $user_nicename = $user->user_nicename;
     356            }
     357
     358            $url = str_replace( '%bbp_user%', $user_nicename, $url );
     359            $url = home_url( user_trailingslashit( $url ) );
     360        }
     361
     362        return apply_filters( 'bbp_get_user_edit_profile_url', $url, $user_id, $user_nicename );
     363
     364    }
     365
     366/** Favorites *****************************************************************/
    60367
    61368/**
     
    173480    }
    174481
    175 /** END Favorites Functions ***************************************************/
    176 
    177 /** START Subscriptions Functions *********************************************/
     482/** Subscriptions *************************************************************/
    178483
    179484/**
     
    287592    }
    288593
    289 /** END Subscriptions Functions ***********************************************/
    290 
    291 /**
    292  * Output ID of current user
    293  *
    294  * @since bbPress (r2574)
    295  *
    296  * @uses bbp_get_current_user_id() To get the current user id
    297  */
    298 function bbp_current_user_id() {
    299     echo bbp_get_current_user_id();
    300 }
    301     /**
    302      * Return ID of current user
    303      *
    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 /**
    315  * Output ID of displayed user
    316  *
    317  * @since bbPress (r2688)
    318  *
    319  * @uses bbp_get_displayed_user_id() To get the displayed user id
    320  */
    321 function bbp_displayed_user_id() {
    322     echo bbp_get_displayed_user_id();
    323 }
    324     /**
    325      * Return ID of displayed user
    326      *
    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 /**
    338  * Return a sanitized user field value
    339  *
    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  */
    347 function bbp_get_displayed_user_field( $field = '' ) {
    348     global $bbp;
    349 
    350     // Return field if exists
    351     if ( isset( $bbp->displayed_user->$field ) )
    352         return esc_attr( sanitize_text_field( $bbp->displayed_user->$field ) );
    353 
    354     // Return empty
    355     return false;
    356 }
    357 
    358 /**
    359  * Output name of current user
    360  *
    361  * @since bbPress (r2574)
    362  *
    363  * @uses bbp_get_current_user_name() To get the current user name
    364  */
    365 function bbp_current_user_name() {
    366     echo bbp_get_current_user_name();
    367 }
    368     /**
    369      * Return name of current user
    370      *
    371      * @since bbPress (r2574)
    372      *
    373      * @uses apply_filters() Calls 'bbp_get_current_user_name' with the
    374      *                        current user name
    375      * @return string
    376      */
    377     function bbp_get_current_user_name() {
    378         global $user_identity;
    379 
    380         if ( is_user_logged_in() )
    381             $current_user_name = $user_identity;
    382         else
    383             $current_user_name = __( 'Anonymous', 'bbpress' );
    384 
    385         return apply_filters( 'bbp_get_current_user_name', $current_user_name );
    386     }
    387 
    388 /**
    389  * Output avatar of current user
    390  *
    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  */
    396 function bbp_current_user_avatar( $size = 40 ) {
    397     echo bbp_get_current_user_avatar( $size );
    398 }
    399 
    400     /**
    401      * Return avatar of current user
    402      *
    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 bbp_get_current_anonymous_user_data() To get the current
    408      *                                              anonymous user's email
    409      * @uses get_avatar() To get the avatar
    410      * @uses apply_filters() Calls 'bbp_get_current_user_avatar' with the
    411      *                        avatar and size
    412      * @return string Current user avatar
    413      */
    414     function bbp_get_current_user_avatar( $size = 40 ) {
    415 
    416         if ( !$user = bbp_get_current_user_id() )
    417             $user = bbp_get_current_anonymous_user_data( 'email' );
    418 
    419         return apply_filters( 'bbp_get_current_user_avatar', get_avatar( $user, $size ), $size );
    420     }
    421 
    422 /**
    423  * Output link to the profile page of a user
    424  *
    425  * @since bbPress (r2688)
    426  *
    427  * @param int $user_id Optional. User id
    428  * @uses bbp_get_user_profile_link() To get user profile link
    429  */
    430 function bbp_user_profile_link( $user_id = 0 ) {
    431     echo bbp_get_user_profile_link( $user_id );
    432 }
    433     /**
    434      * Return link to the profile page of a user
    435      *
    436      * @since bbPress (r2688)
    437      *
    438      * @param int $user_id Optional. User id
    439      * @uses bbp_get_user_id() To get user id
    440      * @uses get_userdata() To get user data
    441      * @uses bbp_get_user_profile_url() To get user profile url
    442      * @uses apply_filters() Calls 'bbp_get_user_profile_link' with the user
    443      *                        profile link and user id
    444      * @return string User profile link
    445      */
    446     function bbp_get_user_profile_link( $user_id = 0 ) {
    447         if ( !$user_id = bbp_get_user_id( $user_id ) )
    448             return false;
    449 
    450         $user      = get_userdata( $user_id );
    451         $name      = esc_attr( $user->display_name );
    452         $user_link = '<a href="' . bbp_get_user_profile_url( $user_id ) . '" title="' . $name . '">' . $name . '</a>';
    453 
    454         return apply_filters( 'bbp_get_user_profile_link', $user_link, $user_id );
    455     }
    456 
    457 /**
    458  * Output URL to the profile page of a user
    459  *
    460  * @since bbPress (r2688)
    461  *
    462  * @param int $user_id Optional. User id
    463  * @param string $user_nicename Optional. User nicename
    464  * @uses bbp_get_user_profile_url() To get user profile url
    465  */
    466 function bbp_user_profile_url( $user_id = 0, $user_nicename = '' ) {
    467     echo bbp_get_user_profile_url( $user_id );
    468 }
    469     /**
    470      * Return URL to the profile page of a user
    471      *
    472      * @since bbPress (r2688)
    473      *
    474      * @param int $user_id Optional. User id
    475      * @param string $user_nicename Optional. User nicename
    476      * @uses bbp_get_user_id() To get user id
    477      * @uses add_query_arg() To add custom args to the url
    478      * @uses home_url() To get blog home url
    479      * @uses apply_filters() Calls 'bbp_get_user_profile_url' with the user
    480      *                        profile url, user id and user nicename
    481      * @return string User profile url
    482      */
    483     function bbp_get_user_profile_url( $user_id = 0, $user_nicename = '' ) {
    484         global $wp_rewrite, $bbp;
    485 
    486         // Use displayed user ID if there is one, and one isn't requested
    487         if ( !$user_id = bbp_get_user_id( $user_id ) )
    488             return false;
    489 
    490         // No pretty permalinks
    491         if ( empty( $wp_rewrite->permalink_structure ) ) {
    492             $url = add_query_arg( array( 'bbp_user' => $user_id ), home_url( '/' ) );
    493 
    494         // Get URL safe user slug
    495         } else {
    496             $url = $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%';
    497 
    498             if ( empty( $user_nicename ) ) {
    499                 $user = get_userdata( $user_id );
    500                 if ( !empty( $user->user_nicename ) )
    501                     $user_nicename = $user->user_nicename;
    502             }
    503 
    504             $url = str_replace( '%bbp_user%', $user_nicename, $url );
    505             $url = home_url( user_trailingslashit( $url ) );
    506         }
    507 
    508         return apply_filters( 'bbp_get_user_profile_url', $url, $user_id, $user_nicename );
    509 
    510     }
    511 
    512 /**
    513  * Output link to the profile edit page of a user
    514  *
    515  * @since bbPress (r2688)
    516  *
    517  * @param int $user_id Optional. User id
    518  * @uses bbp_get_user_profile_edit_link() To get user profile edit link
    519  */
    520 function bbp_user_profile_edit_link( $user_id = 0 ) {
    521     echo bbp_get_user_profile_edit_link( $user_id );
    522 }
    523     /**
    524      * Return link to the profile edit page of a user
    525      *
    526      * @since bbPress (r2688)
    527      *
    528      * @param int $user_id Optional. User id
    529      * @uses bbp_get_user_id() To get user id
    530      * @uses get_userdata() To get user data
    531      * @uses bbp_get_user_profile_edit_url() To get user profile edit url
    532      * @uses apply_filters() Calls 'bbp_get_user_profile_link' with the edit
    533      *                        link and user id
    534      * @return string User profile edit link
    535      */
    536     function bbp_get_user_profile_edit_link( $user_id = 0 ) {
    537         if ( !$user_id = bbp_get_user_id( $user_id ) )
    538             return false;
    539 
    540         $user      = get_userdata( $user_id );
    541         $name      = $user->display_name;
    542         $edit_link = '<a href="' . bbp_get_user_profile_url( $user_id ) . '" title="' . esc_attr( $name ) . '">' . $name . '</a>';
    543         return apply_filters( 'bbp_get_user_profile_link', $edit_link, $user_id );
    544     }
    545 
    546 /**
    547  * Output URL to the profile edit page of a user
    548  *
    549  * @since bbPress (r2688)
    550  *
    551  * @param int $user_id Optional. User id
    552  * @param string $user_nicename Optional. User nicename
    553  * @uses bbp_get_user_profile_edit_url() To get user profile edit url
    554  */
    555 function bbp_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) {
    556     echo bbp_get_user_profile_edit_url( $user_id );
    557 }
    558     /**
    559      * Return URL to the profile edit page of a user
    560      *
    561      * @since bbPress (r2688)
    562      *
    563      * @param int $user_id Optional. User id
    564      * @param string $user_nicename Optional. User nicename
    565      * @uses bbp_get_user_id() To get user id
    566      * @uses add_query_arg() To add custom args to the url
    567      * @uses home_url() To get blog home url
    568      * @uses apply_filters() Calls 'bbp_get_user_edit_profile_url' with the
    569      *                        edit profile url, user id and user nicename
    570      * @return string
    571      */
    572     function bbp_get_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) {
    573         global $wp_rewrite, $bbp;
    574 
    575         if ( !$user_id = bbp_get_user_id( $user_id ) )
    576             return;
    577 
    578         if ( empty( $wp_rewrite->permalink_structure ) ) {
    579             $url = add_query_arg( array( 'bbp_user' => $user_id, 'edit' => '1' ), home_url( '/' ) );
    580         } else {
    581             $url = $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%/edit';
    582 
    583             if ( empty( $user_nicename ) ) {
    584                 $user = get_userdata( $user_id );
    585                 if ( !empty( $user->user_nicename ) )
    586                     $user_nicename = $user->user_nicename;
    587             }
    588 
    589             $url = str_replace( '%bbp_user%', $user_nicename, $url );
    590             $url = home_url( user_trailingslashit( $url ) );
    591         }
    592 
    593         return apply_filters( 'bbp_get_user_edit_profile_url', $url, $user_id, $user_nicename );
    594 
    595     }
    596594
    597595/** Edit User *****************************************************************/
     
    728726}
    729727
    730 /** END User Functions ********************************************************/
    731 
    732728?>
  • branches/plugin/bbp-includes/bbp-widgets.php

    r2773 r2812  
    9898        $instance['title']        = strip_tags( $new_instance['title']        );
    9999        $instance['parent_forum'] = absint    ( $new_instance['parent_forum'] );
     100
    100101        return $instance;
    101102    }
     
    112113    function form( $instance ) {
    113114        $title        = !empty( $instance['title']        ) ? esc_attr( $instance['title']        ) : '';
    114         $parent_forum = !empty( $instance['parent_forum'] ) ? esc_attr( $instance['parent_forum'] ) : '';
    115 
    116         ?>
     115        $parent_forum = !empty( $instance['parent_forum'] ) ? esc_attr( $instance['parent_forum'] ) : ''; ?>
    117116
    118117        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
     
    129128        <?php
    130129    }
    131 
    132130}
    133131
     
    200198
    201199            <ul>
     200
    202201                <?php while ( bbp_topics() ) : bbp_the_topic(); ?>
    203202
     
    231230            <ul>
    232231
     232                <?php foreach ( $topics as $topic_id => $topic_reply_count ) : ?>
     233
     234                    <li><a class="bbp-topic-title" href="<?php bbp_topic_permalink( $topic_id ); ?>" title="<?php bbp_topic_title( $topic_id ); ?>"><?php bbp_topic_title( $topic_id ); ?></a><?php if ( $show_date == 'on' ) _e( ', ' . bbp_get_topic_last_active( $topic_id ) . ' ago' ); ?></li>
     235
    233236                <?php
    234 
    235                 foreach ( $topics as $topic_id => $topic_reply_count ) :
    236 
    237                     ?>
    238 
    239                     <li><a class="bbp-topic-title" href="<?php bbp_topic_permalink( $topic_id ); ?>" title="<?php bbp_topic_title( $topic_id ); ?>"><?php bbp_topic_title( $topic_id ); ?></a><?php if ( $show_date == 'on' ) _e( ', ' . bbp_get_topic_last_active( $topic_id ) . ' ago' ); ?></li>
    240 
    241                     <?php
    242237
    243238                    $topic_count++;
     
    246241                        break;
    247242
    248                 endforeach;
    249 
    250                 ?>
     243                endforeach; ?>
    251244
    252245            </ul>
     
    272265        $instance['show_date'] = strip_tags( $new_instance['show_date'] );
    273266        $instance['pop_check'] = strip_tags( $new_instance['pop_check'] );
     267
    274268        return $instance;
    275269    }
     
    288282        $max_shown = !empty( $instance['max_shown'] ) ? esc_attr( $instance['max_shown'] ) : '';
    289283        $show_date = !empty( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
    290         $pop_check = !empty( $instance['pop_check'] ) ? esc_attr( $instance['pop_check'] ) : '';
    291 
    292         ?>
     284        $pop_check = !empty( $instance['pop_check'] ) ? esc_attr( $instance['pop_check'] ) : ''; ?>
    293285
    294286        <p><label for="<?php echo $this->get_field_id( 'title'     ); ?>"><?php _e( 'Title:',                  'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title'     ); ?>" name="<?php echo $this->get_field_name( 'title'     ); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
     
    405397        $instance['max_shown'] = strip_tags( $new_instance['max_shown'] );
    406398        $instance['show_date'] = strip_tags( $new_instance['show_date'] );
     399
    407400        return $instance;
    408401    }
     
    420413        $title     = !empty( $instance['title']     ) ? esc_attr( $instance['title']     ) : '';
    421414        $max_shown = !empty( $instance['max_shown'] ) ? esc_attr( $instance['max_shown'] ) : '';
    422         $show_date = !empty( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
    423 
    424         ?>
     415        $show_date = !empty( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : ''; ?>
    425416
    426417        <p><label for="<?php echo $this->get_field_id( 'title'     ); ?>"><?php _e( 'Title:',                   'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title'     ); ?>" name="<?php echo $this->get_field_name( 'title'     ); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
     
    430421        <?php
    431422    }
    432 
    433423}
    434424
Note: See TracChangeset for help on using the changeset viewer.