Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/06/2011 08:25:58 AM (16 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-forum-template.php

    r2747 r2758  
    11<?php
    22
     3/**
     4 * bbPress Forum Template Tags
     5 *
     6 * @package bbPress
     7 * @subpackage TemplateTags
     8 */
     9
    310/** START - Forum Loop Functions **********************************************/
    411
    512/**
    6  * bbp_has_forums ()
    7  *
    8  * The main forum loop. WordPress makes this easy for us
    9  *
    10  * @package bbPress
    11  * @subpackage Template Tags
    12  * @since bbPress (r2464)
    13  *
    14  * @global WP_Query $bbp->forum_query
    15  * @param array $args Possible arguments to change returned forums
     13 * The main forum loop.
     14 *
     15 * WordPress makes this easy for us.
     16 *
     17 * @since bbPress (r2464)
     18 *
     19 * @param mixed $args All the arguments supported by {@link WP_Query}
     20 * @uses WP_Query To make query and get the forums
     21 * @uses current_user_can() To check if the current user is capable of editing
     22 *                           others' forums
     23 * @uses apply_filters() Calls 'bbp_has_forums' with
     24 *                        bbPres::forum_query::have_posts()
     25 *                        and bbPres::forum_query
    1626 * @return object Multidimensional array of forum information
    1727 */
    18 function bbp_has_forums ( $args = '' ) {
     28function bbp_has_forums( $args = '' ) {
    1929        global $wp_query, $bbp;
    2030
    … …  
    4252
    4353/**
    44  * bbp_forums ()
    45  *
    4654 * Whether there are more forums available in the loop
    4755 *
    48  * @package bbPress
    49  * @subpackage Template Tags
    50  * @since bbPress (r2464)
    51  *
    52  * @global WP_Query $bbp->forum_query
     56 * @since bbPress (r2464)
     57 *
     58 * @uses bbPress:forum_query::have_posts() To check if there are more forums
     59 *                                          available
    5360 * @return object Forum information
    5461 */
    55 function bbp_forums () {
     62function bbp_forums() {
    5663        global $bbp;
    5764        return $bbp->forum_query->have_posts();
    … …  
    5966
    6067/**
    61  * bbp_the_forum ()
    62  *
    6368 * Loads up the current forum in the loop
    6469 *
    65  * @package bbPress
    66  * @subpackage Template Tags
    67  * @since bbPress (r2464)
    68  *
    69  * @global WP_Query $bbp->forum_query
     70 * @since bbPress (r2464)
     71 *
     72 * @uses bbPress:forum_query::the_post() To get the current forum
    7073 * @return object Forum information
    7174 */
    72 function bbp_the_forum () {
     75function bbp_the_forum() {
    7376        global $bbp;
    7477        return $bbp->forum_query->the_post();
    … …  
    7881
    7982/**
    80  * bbp_forum_id ()
    81  *
    82  * Output id from bbp_forum_id()
    83  *
    84  * @package bbPress
    85  * @subpackage Template Tags
    86  * @since bbPress (r2464)
    87  *
    88  * @uses bbp_get_forum_id()
    89  */
    90 function bbp_forum_id () {
    91         echo bbp_get_forum_id();
    92 }
    93         /**
    94          * bbp_get_forum_id ()
    95          *
    96          * Return the forum ID
    97          *
    98          * @package bbPress
    99          * @subpackage Template Tags
     83 * Output forum id
     84 *
     85 * @since bbPress (r2464)
     86 *
     87 * @param $forum_id Optional. Used to check emptiness
     88 * @uses bbp_get_forum_id() To get the forum id
     89 */
     90function bbp_forum_id( $forum_id = 0 ) {
     91        echo bbp_get_forum_id( $forum_id );
     92}
     93        /**
     94         * Return the forum id
     95         *
    10096         * @since bbPress (r2464)
    10197         *
    102          * @param $forum_id Use to check emptiness
    103          * @global object $forums_template
    104          * @return string Forum id
    105          */
    106         function bbp_get_forum_id ( $forum_id = 0 ) {
     98         * @param $forum_id Optional. Used to check emptiness
     99         * @uses bbPress::forum_query::in_the_loop To check if we're in the loop
     100         * @uses bbPress::forum_query::post::ID To get the forum id
     101         * @uses WP_Query::post::ID To get the forum id
     102         * @uses bbp_is_forum() To check if it's a forum page
     103         * @uses bbp_is_topic() To check if it's a topic page
     104         * @uses bbp_get_topic_forum_id() To get the topic forum id
     105         * @uses apply_filters() Calls 'bbp_get_forum_id' with the forum id
     106         * @return int Forum id
     107         */
     108        function bbp_get_forum_id( $forum_id = 0 ) {
    107109                global $bbp, $wp_query;
    108110
    … …  
    130132                $bbp->current_forum_id = $bbp_forum_id;
    131133
    132                 return apply_filters( 'bbp_get_forum_id', (int)$bbp_forum_id );
    133         }
    134 
    135 /**
    136  * bbp_forum_permalink ()
    137  *
     134                return apply_filters( 'bbp_get_forum_id', (int) $bbp_forum_id );
     135        }
     136
     137/**
    138138 * Output the link to the forum
    139139 *
    140  * @package bbPress
    141  * @subpackage Template Tags
    142  * @since bbPress (r2464)
    143  *
    144  * @param int $forum_id optional
    145  * @uses bbp_get_forum_permalink()
    146  */
    147 function bbp_forum_permalink ( $forum_id = 0 ) {
     140 * @since bbPress (r2464)
     141 *
     142 * @param int $forum_id Optional. Forum id
     143 * @uses bbp_get_forum_permalink() To get the permalink
     144 */
     145function bbp_forum_permalink( $forum_id = 0 ) {
    148146        echo bbp_get_forum_permalink( $forum_id );
    149147}
    150148        /**
    151          * bbp_get_forum_permalink ()
    152          *
    153149         * Return the link to the forum
    154150         *
    155          * @package bbPress
    156          * @subpackage Template Tags
    157151         * @since bbPress (r2464)
    158152         *
    159          * @param int $forum_id optional
    160          * @uses apply_filters
    161          * @uses get_permalink
     153         * @param int $forum_id Optional. Forum id
     154         * @uses bbp_get_forum_id() To get the forum id
     155         * @uses get_permalink() Get the permalink of the forum
     156         * @uses apply_filters() Calls 'bbp_get_forum_permalink' with the forum
     157         *                        link
    162158         * @return string Permanent link to forum
    163159         */
    164         function bbp_get_forum_permalink ( $forum_id = 0 ) {
     160        function bbp_get_forum_permalink( $forum_id = 0 ) {
    165161                $forum_id = bbp_get_forum_id( $forum_id );
    166162                return apply_filters( 'bbp_get_forum_permalink', get_permalink( $forum_id ) );
    … …  
    168164
    169165/**
    170  * bbp_forum_title ()
    171  *
    172166 * Output the title of the forum in the loop
    173167 *
    174  * @package bbPress
    175  * @subpackage Template Tags
    176  * @since bbPress (r2464)
    177  *
    178  * @param int $forum_id optional
    179  * @uses bbp_get_forum_title()
    180  */
    181 function bbp_forum_title ( $forum_id = 0 ) {
     168 * @since bbPress (r2464)
     169 *
     170 * @param int $forum_id Optional. Forum id
     171 * @uses bbp_get_forum_title() To get the forum title
     172 */
     173function bbp_forum_title( $forum_id = 0 ) {
    182174        echo bbp_get_forum_title( $forum_id );
    183175}
    184176        /**
    185          * bbp_get_forum_title ()
    186          *
    187177         * Return the title of the forum in the loop
    188178         *
    189          * @package bbPress
    190          * @subpackage Template Tags
    191179         * @since bbPress (r2464)
    192180         *
    193          * @param int $forum_id optional
    194          * @uses apply_filters
    195          * @uses get_the_title()
     181         * @param int $forum_id Optional. Forum id
     182         * @uses bbp_get_forum_id() To get the forum id
     183         * @uses get_the_title() To get the forum title
     184         * @uses apply_filters() Calls 'bbp_get_forum_title' with the title
    196185         * @return string Title of forum
    197          *
    198          */
    199         function bbp_get_forum_title ( $forum_id = 0 ) {
     186         */
     187        function bbp_get_forum_title( $forum_id = 0 ) {
    200188                $forum_id = bbp_get_forum_id( $forum_id );
    201189
    … …  
    204192
    205193/**
    206  * bbp_forum_last_active ()
    207  *
    208194 * Output the forums last update date/time (aka freshness)
    209195 *
    210  * @package bbPress
    211  * @subpackage Template Tags
    212  * @since bbPress (r2464)
    213  *
    214  * @uses bbp_get_forum_last_active()
    215  * @param int $forum_id optional
    216  */
    217 function bbp_forum_last_active ( $forum_id = 0 ) {
     196 * @since bbPress (r2464)
     197 *
     198 * @uses bbp_get_forum_last_active() To get the forum freshness
     199 * @param int $forum_id Optional. Forum id
     200 */
     201function bbp_forum_last_active( $forum_id = 0 ) {
    218202        echo bbp_get_forum_last_active( $forum_id );
    219203}
    220204        /**
    221          * bbp_get_forum_last_active ()
    222          *
    223205         * Return the forums last update date/time (aka freshness)
    224206         *
    225          * @package bbPress
    226          * @subpackage Template Tags
    227207         * @since bbPress (r2464)
    228208         *
    229          * @return string
    230          * @param int $forum_id optional
    231          */
    232         function bbp_get_forum_last_active ( $forum_id = 0 ) {
     209         * @param int $forum_id Optional. Forum id
     210         * @uses bbp_get_forum_id() To get the forum id
     211         * @uses get_post_meta() To retrieve forum last active meta
     212         * @uses bbp_get_forum_last_reply_id() To get forum's last reply id
     213         * @uses get_post_field() To get the post date of the reply
     214         * @uses bbp_get_forum_last_topic_id() To get forum's last topic id
     215         * @uses bbp_get_topic_last_active() To get time when the topic was
     216         *                                    last active
     217         * @uses bbp_convert_date() To convert the date
     218         * @uses bbp_get_time_since() To get time in since format
     219         * @uses apply_filters() Calls 'bbp_get_forum_last_active' with last
     220         *                        active time and forum id
     221         * @return string Forum last update date/time (freshness)
     222         */
     223        function bbp_get_forum_last_active( $forum_id = 0 ) {
    233224                $forum_id = bbp_get_forum_id( $forum_id );
    234225
    … …  
    238229                        } else {
    239230                                if ( $topic_id = bbp_get_forum_last_topic_id( $forum_id ) ) {
    240                                         $last_active = bbp_get_topic_last_active( $forum_id, '_bbp_forum_last_active', true );
     231                                        $last_active = bbp_get_topic_last_active( $topic_id );
    241232                                }
    242233                        }
    … …  
    245236                $last_active = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
    246237
    247                 return apply_filters( 'bbp_get_forum_last_active', $last_active );
    248         }
    249 
    250 /**
    251  * bbp_get_forum_parent ()
    252  *
     238                return apply_filters( 'bbp_get_forum_last_active', $last_active, $forum_id );
     239        }
     240
     241/**
     242 * Output link to the most recent activity inside a forum.
     243 *
     244 * Outputs a complete link with attributes and content.
     245 *
     246 * @since bbPress (r2625)
     247 *
     248 * @param int $forum_id Optional. Forum id
     249 * @uses bbp_get_forum_freshness_link() To get the forum freshness link
     250 */
     251function bbp_forum_freshness_link( $forum_id = 0) {
     252        echo bbp_get_forum_freshness_link( $forum_id );
     253}
     254        /**
     255         * Returns link to the most recent activity inside a forum.
     256         *
     257         * Returns a complete link with attributes and content.
     258         *
     259         * @since bbPress (r2625)
     260         *
     261         * @param int $forum_id Optional. Forum id
     262         * @uses bbp_get_forum_id() To get the forum id
     263         * @uses bbp_get_forum_last_reply_url() To get the forum last reply url
     264         * @uses bbp_get_forum_last_reply_title() To get the forum last reply
     265         *                                         title
     266         * @uses bbp_get_forum_last_active() To get the time when the forum was
     267         *                                    last active
     268         * @uses apply_filters() Calls 'bbp_get_forum_freshness_link' with the
     269         *                        link and forum id
     270         */
     271        function bbp_get_forum_freshness_link( $forum_id = 0 ) {
     272                $forum_id   = bbp_get_forum_id( $forum_id );
     273                $link_url   = bbp_get_forum_last_reply_url( $forum_id );
     274                $title      = bbp_get_forum_last_reply_title( $forum_id );
     275                $time_since = bbp_get_forum_last_active( $forum_id );
     276
     277                if ( !empty( $time_since ) )
     278                        $anchor = '<a href="' . $link_url . '" title="' . esc_attr( $title ) . '">' . $time_since . '</a>';
     279                else
     280                        $anchor = __( 'No Topics', 'bbpress' );
     281
     282                return apply_filters( 'bbp_get_forum_freshness_link', $anchor, $forum_id );
     283        }
     284
     285/**
    253286 * Return ID of forum parent, if exists
    254287 *
    255  * @package bbPress
    256  * @subpackage Template Tags
    257288 * @since bbPress (r2625)
    258289 *
    259  * @param int $forum_id
    260  * @return int
    261  */
    262 function bbp_get_forum_parent ( $forum_id = 0 ) {
     290 * @param int $forum_id Optional. Forum id
     291 * @uses bbp_get_forum_id() To get the forum id
     292 * @uses get_post_field() To get the forum parent
     293 * @uses apply_filters() Calls 'bbp_get_forum_parent' with the parent & forum id
     294 * @return int Forum parent
     295 */
     296function bbp_get_forum_parent( $forum_id = 0 ) {
    263297        $forum_id = bbp_get_forum_id( $forum_id );
    264         return apply_filters( 'bbp_get_forum_parent', (int)get_post_field( 'post_parent', $forum_id ) );
    265 }
    266 
    267 /**
    268  * bbp_get_forum_ancestors ()
    269  *
     298        return apply_filters( 'bbp_get_forum_parent', (int) get_post_field( 'post_parent', $forum_id ), $forum_id );
     299}
     300
     301/**
    270302 * Return array of parent forums
    271303 *
    272  * @package bbPress
    273  * @subpackage Template Tags
    274304 * @since bbPress (r2625)
    275305 *
    276  * @param int $forum_id
    277  * @return array
    278  */
    279 function bbp_get_forum_ancestors ( $forum_id = 0 ) {
     306 * @param int $forum_id Optional. Forum id
     307 * @uses bbp_get_forum_id() To get the forum id
     308 * @uses get_post() To get the forum
     309 * @uses apply_filters() Calls 'bbp_get_forum_ancestors' with the ancestors
     310 *                        and forum id
     311 * @return array Forum ancestors
     312 */
     313function bbp_get_forum_ancestors( $forum_id = 0 ) {
    280314        $forum_id = bbp_get_forum_id( $forum_id );
    281315
    … …  
    292326
    293327/**
    294  * bbp_forum_has_sub_forums ()
    295  *
    296  * Return sub forums of given forum
    297  *
    298  * @package bbPress
    299  * @subpackage Template Tags
    300  * @since bbPress (r2705)
     328 * Return subforums of given forum
     329 *
     330 * @since bbPress (r2747)
    301331 *
    302332 * @param mixed $args All the arguments supported by {@link WP_Query}
    303  * @return false if none, array of subs if yes
    304  */
    305 function bbp_forum_has_sub_forums ( $args = '' ) {
     333 * @uses bbp_get_forum_id() To get the forum id
     334 * @uses current_user_can() To check if the current user is capable of
     335 *                           reading private forums
     336 * @uses get_posts() To get the subforums
     337 * @uses apply_filters() Calls 'bbp_forum_has_subforums' with the subforums
     338 *                        and the args
     339 * @return mixed false if none, array of subs if yes
     340 */
     341function bbp_forum_has_subforums( $args = '' ) {
    306342        global $bbp;
    307343
    … …  
    333369
    334370/**
    335  * bbp_list_forums ()
    336  *
    337  * Output a list of forums (can be used to list sub forums)
    338  *
    339  * @param int $forum_id
    340  */
    341 function bbp_list_forums ( $args = '' ) {
     371 * Output a list of forums (can be used to list subforums)
     372 *
     373 * @todo - Implement reply counts.
     374 *
     375 * @param mixed $args The function supports these args:
     376 *  - before: To put before the output. Defaults to '<ul class="bbp-forums">'
     377 *  - after: To put after the output. Defaults to '</ul>'
     378 *  - link_before: To put before every link. Defaults to '<li class="bbp-forum">'
     379 *  - link_after: To put after every link. Defaults to '</li>'
     380 *  - separator: Separator. Defaults to ', '
     381 *  - forum_id: Forum id. Defaults to ''
     382 *  - show_topic_count - To show forum topic count or not. Defaults to true
     383 *  - show_reply_count - To show forum reply count or not. Defaults to true
     384 * @uses bbp_forum_has_subforums() To check if the forum has subforums or not
     385 * @uses bbp_get_forum_permalink() To get forum permalink
     386 * @uses bbp_get_forum_title() To get forum title
     387 * @uses bbp_is_forum_category() To check if a forum is a category
     388 * @uses bbp_get_forum_topic_count() To get forum topic count
     389 * @uses bbp_get_forum_reply_count() To get forum reply count
     390 */
     391function bbp_list_forums( $args = '' ) {
    342392        global $bbp;
    343393
    … …  
    361411
    362412        // Loop through forums and create a list
    363         if ( $sub_forums = bbp_forum_has_sub_forums( $forum_id ) ) {
     413        if ( $sub_forums = bbp_forum_has_subforums( $forum_id ) ) {
    364414                // Total count (for separator)
    365415                $total_subs = count( $sub_forums );
    … …  
    373423
    374424                        // Show topic and reply counts
    375                         if ( !empty( $show_topic_count ) )
     425                        if ( !empty( $show_topic_count ) && !bbp_is_forum_category( $sub_forum->ID ) )
    376426                                $topic_count = ' (' . bbp_get_forum_topic_count( $sub_forum->ID ) . ')';
    377427
    378                         // @todo - Walk tree and update counts
    379                         //if ( !empty( $show_reply_count ) )
     428                        //if ( !empty( $show_reply_count ) && !bbp_is_forum_category( $sub_forum->ID ) )
    380429                        //      $reply_count = ' (' . bbp_get_forum_reply_count( $sub_forum->ID ) . ')';
    381430
    … …  
    391440
    392441/**
    393  * bbp_forum_last_topic_id ()
    394  *
    395  * Output the forums last topic id
    396  *
    397  * @package bbPress
    398  * @subpackage Template Tags
    399  * @since bbPress (r2464)
    400  *
    401  * @uses bbp_get_forum_last_active()
    402  * @param int $forum_id optional
    403  */
    404 function bbp_forum_last_topic_id ( $forum_id = 0 ) {
     442 * Output the forum's last topic id
     443 *
     444 * @since bbPress (r2464)
     445 *
     446 * @uses bbp_get_forum_last_active() To get the forum's last topic id
     447 * @param int $forum_id Optional. Forum id
     448 */
     449function bbp_forum_last_topic_id( $forum_id = 0 ) {
    405450        echo bbp_get_forum_last_topic_id( $forum_id );
    406451}
    407452        /**
    408          * bbp_get_forum_last_topic_id ()
    409          *
    410          * Return the forums last topic
    411          *
    412          * @package bbPress
    413          * @subpackage Template Tags
     453         * Return the forum's last topic id
     454         *
    414455         * @since bbPress (r2464)
    415456         *
    416          * @return string
    417          * @param int $forum_id optional
    418          */
    419         function bbp_get_forum_last_topic_id ( $forum_id = 0 ) {
     457         * @param int $forum_id Optional. Forum id
     458         * @uses bbp_get_forum_id() To get the forum id
     459         * @uses get_post_meta() To get the forum's last topic id
     460         * @uses apply_filters() Calls 'bbp_get_forum_last_topic_id' with the
     461         *                        forum and topic id
     462         * @return int Forum's last topic id
     463         */
     464        function bbp_get_forum_last_topic_id( $forum_id = 0 ) {
    420465                $forum_id = bbp_get_forum_id( $forum_id );
    421466                $topic_id = get_post_meta( $forum_id, '_bbp_forum_last_topic_id', true );
    422467
    423                 return apply_filters( 'bbp_get_forum_last_topic_id', $topic_id );
    424         }
    425 
    426 /**
    427  * bbp_forum_last_topic_title ()
    428  *
     468                return apply_filters( 'bbp_get_forum_last_topic_id', $topic_id, $forum_id );
     469        }
     470
     471/**
    429472 * Output the title of the last topic inside a forum
    430473 *
    431  * @package bbPress
    432  * @subpackage Template Tags
    433474 * @since bbPress (r2625)
    434475 *
    435  * @param int $forum_id
    436  */
    437 function bbp_forum_last_topic_title ( $forum_id = 0 ) {
     476 * @param int $forum_id Optional. Forum id
     477 * @uses bbp_get_forum_last_topic_title() To get the forum's last topic's title
     478 */
     479function bbp_forum_last_topic_title( $forum_id = 0 ) {
    438480        echo bbp_get_forum_last_topic_title( $forum_id );
    439481}
    440482        /**
    441          * bbp_get_forum_last_topic_title ()
    442          *
    443483         * Return the title of the last topic inside a forum
    444484         *
    445          * @package bbPress
    446          * @subpackage Template Tags
    447485         * @since bbPress (r2625)
    448486         *
    449          * @param int $forum_id
    450          * @return string
     487         * @param int $forum_id Optional. Forum id
     488         * @uses bbp_get_forum_id() To get the forum id
     489         * @uses bbp_get_forum_last_topic_id() To get the forum's last topic id
     490         * @uses bbp_get_topic_title() To get the topic's title
     491         * @uses apply_filters() Calls 'bbp_get_forum_last_topic_title' with the
     492         *                        topic title and forum id
     493         * @return string Forum's last topic's title
    451494         */
    452495        function bbp_get_forum_last_topic_title( $forum_id = 0 ) {
    453496                $forum_id = bbp_get_forum_id( $forum_id );
    454                 return apply_filters( 'bbp_get_forum_last_topic_title', bbp_get_topic_title( bbp_get_forum_last_topic_id( $forum_id ) ) );
    455         }
    456 
    457 /**
    458  * bbp_forum_last_topic_permalink ()
    459  *
     497                return apply_filters( 'bbp_get_forum_last_topic_title', bbp_get_topic_title( bbp_get_forum_last_topic_id( $forum_id ) ), $forum_id );
     498        }
     499
     500/**
    460501 * Output the link to the last topic in a forum
    461502 *
    462  * @package bbPress
    463  * @subpackage Template Tags
    464  * @since bbPress (r2464)
    465  *
    466  * @param int $forum_id optional
    467  * @uses bbp_get_forum_permalink()
    468  */
    469 function bbp_forum_last_topic_permalink ( $forum_id = 0 ) {
     503 * @since bbPress (r2464)
     504 *
     505 * @param int $forum_id Optional. Forum id
     506 * @uses bbp_get_forum_last_topic_permalink() To get the forum's last topic's
     507 *                                             permanent link
     508 */
     509function bbp_forum_last_topic_permalink( $forum_id = 0 ) {
    470510        echo bbp_get_forum_last_topic_permalink( $forum_id );
    471511}
    472512        /**
    473          * bbp_get_forum_last_topic_permalink ()
    474          *
    475513         * Return the link to the last topic in a forum
    476514         *
    477          * @package bbPress
    478          * @subpackage Template Tags
    479515         * @since bbPress (r2464)
    480516         *
    481          * @param int $forum_id optional
    482          * @uses apply_filters
    483          * @uses get_permalink
     517         * @param int $forum_id Optional. Forum id
     518         * @uses bbp_get_forum_id() To get the forum id
     519         * @uses bbp_get_forum_last_topic_id() To get the forum's last topic id
     520         * @uses bbp_get_topic_permalink() To get the topic's permalink
     521         * @uses apply_filters() Calls 'bbp_get_forum_last_topic_permalink' with
     522         *                        the topic link and forum id
    484523         * @return string Permanent link to topic
    485524         */
    486         function bbp_get_forum_last_topic_permalink ( $forum_id = 0 ) {
     525        function bbp_get_forum_last_topic_permalink( $forum_id = 0 ) {
    487526                $forum_id = bbp_get_forum_id( $forum_id );
    488                 return apply_filters( 'bbp_get_forum_last_topic_permalink', bbp_get_topic_permalink( bbp_get_forum_last_topic_id( $forum_id ) ) );
     527                return apply_filters( 'bbp_get_forum_last_topic_permalink', bbp_get_topic_permalink( bbp_get_forum_last_topic_id( $forum_id ) ), $forum_id );
     528        }
     529
     530/**
     531 * Return the author ID of the last topic of a forum
     532 *
     533 * @since bbPress (r2625)
     534 *
     535 * @param int $forum_id Optional. Forum id
     536 * @uses bbp_get_forum_id() To get the forum id
     537 * @uses bbp_get_forum_last_topic_id() To get the forum's last topic id
     538 * @uses bbp_get_topic_author_id() To get the topic's author id
     539 * @uses apply_filters() Calls 'bbp_get_forum_last_topic_author' with the author
     540 *                        id and forum id
     541 * @return int Forum's last topic's author id
     542 */
     543function bbp_get_forum_last_topic_author_id( $forum_id = 0 ) {
     544        $forum_id  = bbp_get_forum_id( $forum_id );
     545        $author_id = bbp_get_topic_author_id( bbp_get_forum_last_topic_id( $forum_id ) );
     546        return apply_filters( 'bbp_get_forum_last_topic_author_id', $author_id, $forum_id );
     547}
     548
     549/**
     550 * Output link to author of last topic of forum
     551 *
     552 * @since bbPress (r2625)
     553 *
     554 * @param int $forum_id Optional. Forum id
     555 * @uses bbp_get_forum_last_topic_author_link() To get the forum's last topic's
     556 *                                               author link
     557 */
     558function bbp_forum_last_topic_author_link( $forum_id = 0 ) {
     559        echo bbp_get_forum_last_topic_author_link( $forum_id );
     560}
     561        /**
     562         * Return link to author of last topic of forum
     563         *
     564         * @since bbPress (r2625)
     565         *
     566         * @param int $forum_id Optional. Forum id
     567         * @uses bbp_get_forum_id() To get the forum id
     568         * @uses bbp_get_forum_last_topic_author_id() To get the forum's last
     569         *                                             topic's author id
     570         * @uses bbp_get_user_profile_link() To get the author's profile link
     571         * @uses apply_filters() Calls 'bbp_get_forum_last_topic_author_link'
     572         *                        with the author link and forum id
     573         * @return string Forum's last topic's author link
     574         */
     575        function bbp_get_forum_last_topic_author_link( $forum_id = 0 ) {
     576                $forum_id    = bbp_get_forum_id( $forum_id );
     577                $author_id   = bbp_get_forum_last_topic_author_id( $forum_id );
     578                $author_link = bbp_get_user_profile_link( $author_id );
     579                return apply_filters( 'bbp_get_forum_last_topic_author_link', $author_link, $forum_id );
    489580        }
    490581
    … …  
    492583
    493584/**
    494  * bbp_forum_last_reply_id ()
    495  *
    496585 * Output the forums last reply id
    497586 *
    498  * @package bbPress
    499  * @subpackage Template Tags
    500  * @since bbPress (r2464)
    501  *
    502  * @uses bbp_get_forum_last_reply_id()
    503  * @param int $forum_id optional
    504  */
    505 function bbp_forum_last_reply_id ( $forum_id = 0 ) {
     587 * @since bbPress (r2464)
     588 *
     589 * @uses bbp_get_forum_last_reply_id() To get the forum's last reply id
     590 * @param int $forum_id Optional. Forum id
     591 */
     592function bbp_forum_last_reply_id( $forum_id = 0 ) {
    506593        echo bbp_get_forum_last_reply_id( $forum_id );
    507594}
    508595        /**
    509          * bbp_get_forum_last_reply_id ()
    510          *
    511596         * Return the forums last reply id
    512597         *
    513          * @package bbPress
    514          * @subpackage Template Tags
    515598         * @since bbPress (r2464)
    516599         *
    517          * @return string
    518          * @param int $forum_id optional
    519          */
    520         function bbp_get_forum_last_reply_id ( $forum_id = 0 ) {
     600         * @param int $forum_id Optional. Forum id
     601         * @uses bbp_get_forum_id() To get the forum id
     602         * @uses get_post_meta() To get the forum's last reply id
     603         * @uses bbp_update_forum_last_reply_id() To update and get the last
     604         *                                         reply id of the forum
     605         * @uses apply_filters() Calls 'bbp_get_forum_last_reply_id' with
     606         *                        the last reply id and forum id
     607         * @return int Forum's last reply id
     608         */
     609        function bbp_get_forum_last_reply_id( $forum_id = 0 ) {
    521610                $forum_id = bbp_get_forum_id( $forum_id );
    522611                $reply_id = get_post_meta( $forum_id, '_bbp_forum_last_reply_id', true );
    … …  
    525614                        $reply_id = bbp_update_forum_last_reply_id( $forum_id );
    526615
    527                 return apply_filters( 'bbp_get_forum_last_reply_id', $reply_id );
    528         }
    529 
    530 /**
    531  * bbp_forum_last_reply_title ()
    532  *
     616                return apply_filters( 'bbp_get_forum_last_reply_id', $reply_id, $forum_id );
     617        }
     618
     619/**
    533620 * Output the title of the last reply inside a forum
    534621 *
    535  * @param int $forum_id
    536  */
    537 function bbp_forum_last_reply_title ( $forum_id = 0 ) {
     622 * @param int $forum_id Optional. Forum id
     623 * @uses bbp_get_forum_last_reply_title() To get the forum's last reply's title
     624 */
     625function bbp_forum_last_reply_title( $forum_id = 0 ) {
    538626        echo bbp_get_forum_last_reply_title( $forum_id );
    539627}
    540628        /**
    541          * bbp_get_forum_last_reply_title ()
    542          *
    543629         * Return the title of the last reply inside a forum
    544630         *
    545          * @param int $forum_id
     631         * @param int $forum_id Optional. Forum id
     632         * @uses bbp_get_forum_id() To get the forum id
     633         * @uses bbp_get_forum_last_reply_id() To get the forum's last reply id
     634         * @uses bbp_get_reply_title() To get the reply title
     635         * @uses apply_filters() Calls 'bbp_get_forum_last_reply_title' with the
     636         *                        reply title and forum id
    546637         * @return string
    547638         */
    548639        function bbp_get_forum_last_reply_title( $forum_id = 0 ) {
    549640                $forum_id = bbp_get_forum_id( $forum_id );
    550                 return apply_filters( 'bbp_get_forum_last_topic_title', bbp_get_reply_title( bbp_get_forum_last_reply_id( $forum_id ) ) );
    551         }
    552 
    553 /**
    554  * bbp_forum_last_reply_permalink ()
    555  *
     641                return apply_filters( 'bbp_get_forum_last_reply_title', bbp_get_reply_title( bbp_get_forum_last_reply_id( $forum_id ) ), $forum_id );
     642        }
     643
     644/**
    556645 * Output the link to the last reply in a forum
    557646 *
    558  * @package bbPress
    559  * @subpackage Template Tags
    560  * @since bbPress (r2464)
    561  *
    562  * @param int $forum_id optional
    563  * @uses bbp_get_forum_permalink()
    564  */
    565 function bbp_forum_last_reply_permalink ( $forum_id = 0 ) {
     647 * @since bbPress (r2464)
     648 *
     649 * @param int $forum_id Optional. Forum id
     650 * @uses bbp_get_forum_last_reply_permalink() To get the forum last reply link
     651 */
     652function bbp_forum_last_reply_permalink( $forum_id = 0 ) {
    566653        echo bbp_get_forum_last_reply_permalink( $forum_id );
    567654}
    568655        /**
    569          * bbp_get_forum_last_reply_permalink ()
    570          *
    571656         * Return the link to the last reply in a forum
    572657         *
    573          * @package bbPress
    574          * @subpackage Template Tags
    575658         * @since bbPress (r2464)
    576659         *
    577          * @param int $forum_id optional
    578          * @uses apply_filters
    579          * @uses get_permalink
    580          * @return string Permanent link to topic
    581          */
    582         function bbp_get_forum_last_reply_permalink ( $forum_id = 0 ) {
     660         * @param int $forum_id Optional. Forum id
     661         * @uses bbp_get_forum_id() To get the forum id
     662         * @uses bbp_get_forum_last_reply_id() To get the forum's last reply id
     663         * @uses bbp_get_reply_permalink() To get the reply permalink
     664         * @uses apply_filters() Calls 'bbp_get_forum_last_reply_permalink' with
     665         *                        the reply link and forum id
     666         * @return string Permanent link to the forum's last reply
     667         */
     668        function bbp_get_forum_last_reply_permalink( $forum_id = 0 ) {
    583669                $forum_id = bbp_get_forum_id( $forum_id );
    584                 return apply_filters( 'bbp_get_forum_last_reply_permalink', bbp_get_reply_permalink( bbp_get_forum_last_reply_id( $forum_id ) ) );
    585         }
    586 
    587 /**
    588  * bbp_forum_last_reply_url ()
    589  *
    590  * Output the link to the last reply in a forum
    591  *
    592  * @package bbPress
    593  * @subpackage Template Tags
     670                return apply_filters( 'bbp_get_forum_last_reply_permalink', bbp_get_reply_permalink( bbp_get_forum_last_reply_id( $forum_id ) ), $forum_id );
     671        }
     672
     673/**
     674 * Output the url to the last reply in a forum
     675 *
    594676 * @since bbPress (r2683)
    595677 *
    596  * @param int $forum_id optional
    597  * @uses bbp_get_forum_url()
    598  */
    599 function bbp_forum_last_reply_url ( $forum_id = 0 ) {
     678 * @param int $forum_id Optional. Forum id
     679 * @uses bbp_get_forum_last_reply_url() To get the forum last reply url
     680 */
     681function bbp_forum_last_reply_url( $forum_id = 0 ) {
    600682        echo bbp_get_forum_last_reply_url( $forum_id );
    601683}
    602684        /**
    603          * bbp_get_forum_last_reply_url ()
    604          *
    605          * Return the link to the last reply in a forum
    606          *
    607          * @package bbPress
    608          * @subpackage Template Tags
     685         * Return the url to the last reply in a forum
     686         *
    609687         * @since bbPress (r2683)
    610688         *
    611          * @param int $forum_id optional
    612          * @uses apply_filters
    613          * @uses get_url
     689         * @param int $forum_id Optional. Forum id
     690         * @uses bbp_get_forum_id() To get the forum id
     691         * @uses bbp_get_forum_last_reply_id() To get the forum's last reply id
     692         * @uses bbp_get_reply_url() To get the reply url
     693         * @uses bbp_get_forum_last_topic_permalink() To get the forum's last
     694         *                                             topic's permalink
     695         * @uses apply_filters() Calls 'bbp_get_forum_last_reply_url' with the
     696         *                        reply url and forum id
    614697         * @return string Paginated URL to latest reply
    615698         */
    616         function bbp_get_forum_last_reply_url ( $forum_id = 0 ) {
    617                 $forum_id  = bbp_get_forum_id( $forum_id );
     699        function bbp_get_forum_last_reply_url( $forum_id = 0 ) {
     700                $forum_id = bbp_get_forum_id( $forum_id );
    618701
    619702                // If forum has replies, get the last reply and use its url
    620                 if ( $reply_id  = bbp_get_forum_last_reply_id( $forum_id ) ) {
     703                if ( $reply_id = bbp_get_forum_last_reply_id( $forum_id ) ) {
    621704                        $reply_url = bbp_get_reply_url( $reply_id );
    622705
    623706                // No replies, so look for topics and use last permalink
    624707                } else {
    625                         if ( $topic_id = bbp_get_forum_last_topic_id( $forum_id ) ) {
    626                                 $reply_url = bbp_get_topic_permalink( $topic_id );
    627 
    628                         // No topics either, so set $reply_url as empty
    629                         } else {
     708                        if ( !$reply_url = bbp_get_forum_last_topic_permalink( $forum_id ) ) {
     709                                // No topics either, so set $reply_url as empty
    630710                                $reply_url = '';
    631711                        }
    … …  
    633713
    634714                // Filter and return
    635                 return apply_filters( 'bbp_get_forum_last_reply_url', $reply_url );
    636         }
    637 
    638 /**
    639  * bbp_forum_freshness_link ()
    640  *
    641  * Output link to the most recent activity inside a forum, complete with
    642  * link attributes and content.
    643  *
    644  * @package bbPress
    645  * @subpackage Template Tags
     715                return apply_filters( 'bbp_get_forum_last_reply_url', $reply_url, $forum_id );
     716        }
     717
     718/**
     719 * Output author ID of last reply of forum
     720 *
    646721 * @since bbPress (r2625)
    647722 *
    648  * @param int $forum_id
    649  */
    650 function bbp_forum_freshness_link ( $forum_id = 0) {
    651         echo bbp_get_forum_freshness_link( $forum_id );
    652 }
    653         /**
    654          * bbp_get_forum_freshness_link ()
    655          *
    656          * Returns link to the most recent activity inside a forum, complete with
    657          * link attributes and content.
    658          *
    659          * @package bbPress
    660          * @subpackage Template Tags
     723 * @param int $forum_id Optional. Forum id
     724 * @uses bbp_get_forum_last_reply_author_id() To get the forum's last reply
     725 *                                             author id
     726 */
     727function bbp_forum_last_reply_author_id( $forum_id = 0 ) {
     728        echo bbp_get_forum_last_reply_author_id( $forum_id );
     729}
     730        /**
     731         * Return author ID of last reply of forum
     732         *
    661733         * @since bbPress (r2625)
    662734         *
    663          * @param int $forum_id
    664          */
    665         function bbp_get_forum_freshness_link ( $forum_id = 0 ) {
    666                 $forum_id   = bbp_get_forum_id( $forum_id );
    667                 $link_url   = bbp_get_forum_last_reply_url( $forum_id );
    668                 $title      = bbp_get_forum_last_reply_title( $forum_id );
    669                 $time_since = bbp_get_forum_last_active( $forum_id );
    670 
    671                 if ( !empty( $time_since ) )
    672                         $anchor = '<a href="' . $link_url . '" title="' . esc_attr( $title ) . '">' . $time_since . '</a>';
    673                 else
    674                         $anchor = __( 'No Topics', 'bbpress' );
    675 
    676                 return apply_filters( 'bbp_get_forum_freshness_link', $anchor );
    677         }
    678 
    679 /**
    680  * bbp_get_forum_last_topic_author_id ()
    681  *
    682  * Return the author ID of the last topic of a forum
    683  *
    684  * @package bbPress
    685  * @subpackage Template Tags
     735         * @param int $forum_id Optional. Forum id
     736         * @uses bbp_get_forum_id() To get the forum id
     737         * @uses bbp_get_forum_last_reply_author_id() To get the forum's last
     738         *                                             reply's author id
     739         * @uses bbp_get_reply_author_id() To get the reply's author id
     740         * @uses apply_filters() Calls 'bbp_get_forum_last_reply_author_id' with
     741         *                        the author id and forum id
     742         * @return int Forum's last reply author id
     743         */
     744        function bbp_get_forum_last_reply_author_id( $forum_id = 0 ) {
     745                $forum_id  = bbp_get_forum_id( $forum_id );
     746                $author_id = bbp_get_reply_author_id( bbp_get_forum_last_reply_id( $forum_id ) );
     747                return apply_filters( 'bbp_get_forum_last_reply_author_id', $author_id, $forum_id );
     748        }
     749
     750/**
     751 * Output link to author of last reply of forum
     752 *
    686753 * @since bbPress (r2625)
    687754 *
    688  * @param int $forum_id
    689  */
    690 function bbp_get_forum_last_topic_author_id ( $forum_id = 0 ) {
    691         $forum_id  = bbp_get_forum_id( $forum_id );
    692         $author_id = get_post_field( 'post_author', bbp_get_forum_last_topic_id( $forum_id ) );
    693         return apply_filters( 'bbp_get_forum_last_topic_author', $author_id );
    694 }
    695 
    696 /**
    697  * bbp_forum_last_topic_author_link ()
    698  *
    699  * Output link to author of last topic of forum
    700  *
    701  * @package bbPress
    702  * @subpackage Template Tags
    703  * @since bbPress (r2625)
    704  *
    705  * @param int $forum_id
    706  */
    707 function bbp_forum_last_topic_author_link ( $forum_id = 0 ) {
    708         echo bbp_get_forum_last_topic_author_link( $forum_id );
    709 }
    710         /**
    711          * bbp_get_forum_last_topic_author_link ()
    712          *
    713          * Return link to author of last topic of forum
    714          *
    715          * @package bbPress
    716          * @subpackage Template Tags
     755 * @param int $forum_id Optional. Forum id
     756 * @uses bbp_get_forum_last_reply_author_link() To get the forum's last reply's
     757 *                                               author link
     758 */
     759function bbp_forum_last_reply_author_link( $forum_id = 0 ) {
     760        echo bbp_get_forum_last_reply_author_link( $forum_id );
     761}
     762        /**
     763         * Return link to author of last reply of forum
     764         *
    717765         * @since bbPress (r2625)
    718766         *
    719          * @param int $forum_id
    720          * @return string
    721          */
    722         function bbp_get_forum_last_topic_author_link ( $forum_id = 0 ) {
    723                 $forum_id    = bbp_get_forum_id( $forum_id );
    724                 $author_id   = bbp_get_forum_last_topic_author_id( $forum_id );
    725                 $author_link = bbp_get_user_profile_link( $author_id );
    726                 return apply_filters( 'bbp_get_forum_last_topic_author_link', $author_link );
    727         }
    728 
    729 /**
    730  * bbp_forum_last_reply_author_id ()
    731  *
    732  * Output author ID of last reply of forum
    733  *
    734  * @package bbPress
    735  * @subpackage Template Tags
    736  * @since bbPress (r2625)
    737  *
    738  * @param int $forum_id
    739  */
    740 function bbp_forum_last_reply_author_id ( $forum_id = 0 ) {
    741         echo bbp_get_forum_last_reply_author_id( $forum_id );
    742 }
    743         /**
    744          * bbp_get_forum_last_reply_author_id ()
    745          *
    746          * Return author ID of last reply of forum
    747          *
    748          * @package bbPress
    749          * @subpackage Template Tags
    750          * @since bbPress (r2625)
    751          *
    752          * @param int $forum_id
    753          */
    754         function bbp_get_forum_last_reply_author_id ( $forum_id = 0 ) {
    755                 $forum_id  = bbp_get_forum_id( $forum_id );
    756                 $author_id = get_post_field( 'post_author', bbp_get_forum_last_reply_id( $forum_id ) );
    757                 return apply_filters( 'bbp_get_forum_last_reply_author', $author_id );
    758         }
    759 
    760 /**
    761  * bbp_forum_last_reply_author_link ()
    762  *
    763  * Output link to author of last reply of forum
    764  *
    765  * @package bbPress
    766  * @subpackage Template Tags
    767  * @since bbPress (r2625)
    768  *
    769  * @param int $forum_id
    770  */
    771 function bbp_forum_last_reply_author_link ( $forum_id = 0 ) {
    772         echo bbp_get_forum_last_reply_author_link( $forum_id );
    773 }
    774         /**
    775          * bbp_get_forum_last_reply_author_link ()
    776          *
    777          * Return link to author of last reply of forum
    778          *
    779          * @package bbPress
    780          * @subpackage Template Tags
    781          * @since bbPress (r2625)
    782          *
    783          * @param int $forum_id
    784          * @return string
    785          */
    786         function bbp_get_forum_last_reply_author_link ( $forum_id = 0 ) {
     767         * @param int $forum_id Optional. Forum id
     768         * @uses bbp_get_forum_id() To get the forum id
     769         * @uses bbp_get_forum_last_reply_author_id() To get the forum's last
     770         *                                             reply's author id
     771         * @uses bbp_get_user_profile_link() To get the reply's author's profile
     772         *                                    link
     773         * @uses apply_filters() Calls 'bbp_get_forum_last_reply_author_link'
     774         *                        with the author link and forum id
     775         * @return string Link to author of last reply of forum
     776         */
     777        function bbp_get_forum_last_reply_author_link( $forum_id = 0 ) {
    787778                $forum_id    = bbp_get_forum_id( $forum_id );
    788779                $author_id   = bbp_get_forum_last_reply_author_id( $forum_id );
    789780                $author_link = bbp_get_user_profile_link( $author_id );
    790                 return apply_filters( 'bbp_get_forum_last_reply_author_link', $author_link );
     781                return apply_filters( 'bbp_get_forum_last_reply_author_link', $author_link, $forum_id );
    791782        }
    792783
    … …  
    794785
    795786/**
    796  * bbp_forum_subforum_count ()
    797  *
    798787 * Output total sub-forum count of a forum
    799788 *
    800  * @package bbPress
    801  * @subpackage Template Tags
    802  * @since bbPress (r2464)
    803  *
    804  * @uses bbp_get_forum_subforum_count()
    805  * @param int $forum_id optional Forum ID to check
    806  */
    807 function bbp_forum_subforum_count ( $forum_id = 0 ) {
     789 * @since bbPress (r2464)
     790 *
     791 * @uses bbp_get_forum_subforum_count() To get the forum's subforum count
     792 * @param int $forum_id Optional. Forum id to check
     793 */
     794function bbp_forum_subforum_count( $forum_id = 0 ) {
    808795        echo bbp_get_forum_subforum_count( $forum_id );
    809796}
    810797        /**
    811          * bbp_get_forum_subforum_count ()
    812          *
    813          * Return total sub-forum count of a forum
    814          *
    815          * @package bbPress
    816          * @subpackage Template Tags
     798         * Return total subforum count of a forum
     799         *
    817800         * @since bbPress (r2464)
    818801         *
    819          * @uses bbp_get_forum_id
    820          * @uses get_pages
    821          * @uses apply_filters
    822          *
    823          * @param int $forum_id optional Forum ID to check
    824          */
    825         function bbp_get_forum_subforum_count ( $forum_id = 0 ) {
     802         * @param int $forum_id Optional. Forum id
     803         * @uses bbp_get_forum_id() To get the forum id
     804         * @uses get_post_meta() To get the subforum count
     805         * @uses bbp_update_forum_subforum_count() To update the forum's
     806         *                                          subforum count if needed
     807         * @uses apply_filters() Calls 'bbp_get_forum_subforum_count' with the
     808         *                        subforum count and forum id
     809         * @return int Forum's subforum count
     810         */
     811        function bbp_get_forum_subforum_count( $forum_id = 0 ) {
    826812                $forum_id    = bbp_get_forum_id( $forum_id );
    827813                $forum_count = get_post_meta( $forum_id, '_bbp_forum_subforum_count', true );
    … …  
    830816                        $forum_count = bbp_update_forum_subforum_count( $forum_id );
    831817
    832                 return apply_filters( 'bbp_get_forum_subforum_count', $forum_count );
    833         }
    834 
    835 /**
    836  * bbp_forum_topic_count ()
    837  *
     818                return apply_filters( 'bbp_get_forum_subforum_count', (int) $forum_count, $forum_id );
     819        }
     820
     821/**
    838822 * Output total topic count of a forum
    839823 *
    840  * @package bbPress
    841  * @subpackage Template Tags
    842  * @since bbPress (r2464)
    843  *
    844  * @uses bbp_get_forum_topic_count()
    845  * @param int $forum_id optional Forum ID to check
    846  */
    847 function bbp_forum_topic_count ( $forum_id = 0 ) {
     824 * @since bbPress (r2464)
     825 *
     826 * @param int $forum_id Optional. Forum id
     827 * @uses bbp_get_forum_topic_count() To get the forum topic count
     828 */
     829function bbp_forum_topic_count( $forum_id = 0 ) {
    848830        echo bbp_get_forum_topic_count( $forum_id );
    849831}
    850832        /**
    851          * bbp_get_forum_topic_count ()
    852          *
    853833         * Return total topic count of a forum
    854834         *
    855          * @package bbPress
    856          * @subpackage Template Tags
    857835         * @since bbPress (r2464)
    858836         *
    859          * @todo stash and cache (see commented out code)
    860          *
    861          * @uses bbp_get_forum_id
    862          * @uses get_pages
    863          * @uses apply_filters
    864          *
    865          * @param int $forum_id optional Forum ID to check
    866          */
    867         function bbp_get_forum_topic_count ( $forum_id = 0 ) {
     837         * @param int $forum_id Optional. Forum id
     838         * @uses bbp_get_forum_id() To get the forum id
     839         * @uses get_post_meta() To get the forum topic count
     840         * @uses bbp_update_forum_topic_count() To update the topic count if
     841         *                                       needed
     842         * @uses apply_filters() Calls 'bbp_get_forum_topic_count' with the
     843         *                        topic count and forum id
     844         * @return int Forum topic count
     845         */
     846        function bbp_get_forum_topic_count( $forum_id = 0 ) {
    868847                $forum_id = bbp_get_forum_id( $forum_id );
    869848                $topics   = get_post_meta( $forum_id, '_bbp_forum_topic_count', true );
    … …  
    876855
    877856/**
    878  * bbp_forum_reply_count ()
    879  *
    880857 * Output total reply count of a forum
    881858 *
    882  * @package bbPress
    883  * @subpackage Template Tags
    884  * @since bbPress (r2464)
    885  *
    886  * @uses bbp_get_forum_topic_reply_count()
    887  * @param int $forum_id optional
    888  */
    889 function bbp_forum_reply_count ( $forum_id = 0 ) {
     859 * @since bbPress (r2464)
     860 *
     861 * @param int $forum_id Optional. Forum id
     862 * @uses bbp_get_forum_reply_count() To get the forum reply count
     863 */
     864function bbp_forum_reply_count( $forum_id = 0 ) {
    890865        echo bbp_get_forum_reply_count( $forum_id );
    891866}
    892867        /**
    893          * bbp_forum_reply_count ()
    894          *
    895868         * Return total post count of a forum
    896869         *
    897          * @package bbPress
    898          * @subpackage Template Tags
    899870         * @since bbPress (r2464)
    900871         *
    901          * @todo stash and cache (see commented out code)
    902          *
    903          * @uses bbp_get_forum_id()
    904          * @uses get_pages
    905          * @uses apply_filters
    906          *
    907          * @param int $forum_id optional
    908          */
    909         function bbp_get_forum_reply_count ( $forum_id = 0 ) {
     872         * @param int $forum_id Optional. Forum id
     873         * @uses bbp_get_forum_id() To get the forum id
     874         * @uses get_post_meta() To get the forum reply count
     875         * @uses bbp_update_forum_reply_count() To update the reply count if
     876         *                                       needed
     877         * @uses apply_filters() Calls 'bbp_get_forum_reply_count' with the
     878         *                        reply count and forum id
     879         * @return int Forum reply count
     880         */
     881        function bbp_get_forum_reply_count( $forum_id = 0 ) {
    910882                $forum_id = bbp_get_forum_id( $forum_id );
    911883                $replies  = get_post_meta( $forum_id, '_bbp_forum_reply_count', true );
    … …  
    918890
    919891/**
    920  * bbp_forum_voice_count ()
    921  *
    922892 * Output total voice count of a forum
    923893 *
    924  * @package bbPress
    925  * @subpackage Template Tags
    926894 * @since bbPress (r2567)
    927895 *
    928  * @uses bbp_get_forum_voice_count()
    929  * @uses apply_filters
    930  *
    931  * @param int $forum_id
    932  */
    933 function bbp_forum_voice_count ( $forum_id = 0 ) {
     896 * @param int $forum_id Optional. Forum id
     897 * @uses bbp_get_forum_voice_count() To get the forum voice count
     898 */
     899function bbp_forum_voice_count( $forum_id = 0 ) {
    934900        echo bbp_get_forum_voice_count( $forum_id );
    935901}
    936902        /**
    937          * bbp_get_forum_voice_count ()
    938          *
    939903         * Return total voice count of a forum
    940904         *
    941          * @package bbPress
    942          * @subpackage Template Tags
    943905         * @since bbPress (r2567)
    944906         *
    945          * @uses bbp_get_forum_id()
    946          * @uses apply_filters
    947          *
    948          * @param int $forum_id
    949          *
    950          * @return int Voice count of the forum
    951          */
    952         function bbp_get_forum_voice_count ( $forum_id = 0 ) {
     907         * @param int $forum_id Optional. Forum id
     908         * @uses bbp_get_forum_id() To get the forum id
     909         * @uses get_post_meta() To get the forum voice count
     910         * @uses bbp_update_forum_voice_count() To update the voice count if
     911         *                                       needed
     912         * @uses apply_filters() Calls 'bbp_get_forum_voice_count' with the
     913         *                        voice count and forum id
     914         * @return int Forum voice count
     915         */
     916        function bbp_get_forum_voice_count( $forum_id = 0 ) {
    953917                $forum_id = bbp_get_forum_id( $forum_id );
    954918                $voices   = get_post_meta( $forum_id, '_bbp_forum_voice_count', true );
    … …  
    961925
    962926/**
    963  * bbp_forum_status ()
    964  *
    965  * Output the status of the forum in the loop
    966  *
    967  * @package bbPress
    968  * @subpackage Template Tags
     927 * Output the status of the forum
     928 *
    969929 * @since bbPress (r2667)
    970  * @param int $forum_id optional
    971  *
    972  * @uses bbp_get_forum_status()
    973  */
    974 function bbp_forum_status ( $forum_id = 0 ) {
     930 *
     931 * @param int $forum_id Optional. Forum id
     932 * @uses bbp_get_forum_status() To get the forum status
     933 */
     934function bbp_forum_status( $forum_id = 0 ) {
    975935        echo bbp_get_forum_status( $forum_id );
    976936}
    977937        /**
    978          * bbp_get_forum_status ()
    979          *
    980          * Return the status of the forum in the loop
    981          *
    982          * @package bbPress
    983          * @subpackage Template Tags
     938         * Return the status of the forum
     939         *
    984940         * @since bbPress (r2667)
    985941         *
    986          * @uses apply_filters
    987          * @uses get_post_status()
    988          * @param int $forum_id optional
    989          *
     942         * @param int $forum_id Optional. Forum id
     943         * @uses bbp_get_forum_id() To get the forum id
     944         * @uses get_post_status() To get the forum's status
     945         * @uses apply_filters() Calls 'bbp_get_forum_status' with the status
     946         *                        and forum id
    990947         * @return string Status of forum
    991948         */
    992         function bbp_get_forum_status ( $forum_id = 0 ) {
     949        function bbp_get_forum_status( $forum_id = 0 ) {
    993950                $forum_id = bbp_get_forum_id( $forum_id );
    994951
    … …  
    12081165
    12091166/**
    1210  * bbp_forum_class ()
    1211  *
    12121167 * Output the row class of a forum
    12131168 *
    1214  * @package bbPress
    1215  * @subpackage Template Tags
    12161169 * @since bbPress (r2667)
    1217  */
    1218 function bbp_forum_class ( $forum_id = 0 ) {
    1219         echo bbp_get_forum_class( $forum_id );
    1220 }
    1221         /**
    1222          * bbp_get_forum_class ()
    1223          *
     1170 *
     1171 * @uses bbp_get_forum_class() To get the row class of the forum
     1172 */
     1173function bbp_forum_class() {
     1174        echo bbp_get_forum_class();
     1175}
     1176        /**
    12241177         * Return the row class of a forum
    12251178         *
    1226          * @package bbPress
    1227          * @subpackage Template Tags
    12281179         * @since bbPress (r2667)
    12291180         *
    1230          * @global WP_Query $bbp->forum_query
    1231          * @param int $forum_id
    1232          * @return string
    1233          */
    1234         function bbp_get_forum_class ( $forum_id = 0 ) {
     1181         * @uses post_class() To get all the classes including ours
     1182         * @uses apply_filters() Calls 'bbp_get_forum_class' with the classes
     1183         * @return string Row class of the forum
     1184         */
     1185        function bbp_get_forum_class() {
    12351186                global $bbp;
    12361187
    1237                 $alternate = $bbp->forum_query->current_post % 2 ? 'even' : 'odd';
    1238                 $status    = 'status-'  . bbp_get_forum_status();
    1239                 $post      = post_class( array( $alternate, $status ) );
     1188                $classes   = array();
     1189                $classes[] = $bbp->forum_query->current_post % 2 ? 'even' : 'odd';
     1190                $classes[] = bbp_is_forum_category() ? 'status-category' : '';
     1191                $classes[] = bbp_is_forum_private()  ? 'status-private'  : '';
     1192                $classes   = array_filter( $classes );
     1193
     1194                $post      = post_class( $classes );
    12401195
    12411196                return apply_filters( 'bbp_get_forum_class', $post );
    … …  
    12451200
    12461201/**
    1247  * bbp_update_forum_last_topic_id ()
    1248  *
    12491202 * Update the forum last topic id
    12501203 *
    1251  * @package bbPress
    1252  * @subpackage Template Tags
    12531204 * @since bbPress (r2625)
    12541205 *
    1255  * @todo everything
    1256  * @param int $forum_id
    1257  */
    1258 function bbp_update_forum_last_topic_id ( $forum_id = 0, $topic_id = 0 ) {
     1206 * @param int $forum_id Optional. Forum id
     1207 * @param int $topic_id Optional. Topic id
     1208 * @uses bbp_get_forum_id() To get the forum id
     1209 * @uses bbp_get_topic_id() To get the topic id
     1210 * @uses update_post_meta() To update the forum's last topic id meta
     1211 * @return bool True on success, false on failure
     1212 */
     1213function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) {
    12591214        $forum_id = bbp_get_forum_id( $forum_id );
    12601215        $topic_id = bbp_get_topic_id( $topic_id );
    12611216
    1262         // Update the last reply ID
    1263         if ( !empty( $topic_id ) ) {
    1264                 update_post_meta( $forum_id, '_bbp_forum_last_topic_id', $topic_id );
    1265                 return true;
    1266         }
     1217        // Update the last topic ID
     1218        if ( !empty( $topic_id ) )
     1219                return update_post_meta( $forum_id, '_bbp_forum_last_topic_id', $topic_id );
    12671220
    12681221        return false;
    … …  
    12701223
    12711224/**
    1272  * bbp_update_forum_last_reply_id ()
    1273  *
    12741225 * Update the forum last reply id
    12751226 *
    1276  * @package bbPress
    1277  * @subpackage Template Tags
    12781227 * @since bbPress (r2625)
    12791228 *
    1280  * @todo everything
    1281  * @param int $forum_id
    1282  */
    1283 function bbp_update_forum_last_reply_id ( $forum_id = 0, $reply_id = 0 ) {
     1229 * @param int $forum_id Optional. Forum id
     1230 * @param int $reply_id Optional. Reply id
     1231 * @uses bbp_get_forum_id() To get the forum id
     1232 * @uses bbp_get_reply_id() To get the reply id
     1233 * @uses update_post_meta() To update the forum's last reply id meta
     1234 * @return bool True on success, false on failure
     1235 */
     1236function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) {
    12841237        $forum_id = bbp_get_forum_id( $forum_id );
    12851238        $reply_id = bbp_get_reply_id( $reply_id );
    12861239
    12871240        // Update the last reply ID
    1288         if ( !empty( $reply_id ) ) {
    1289                 update_post_meta( $forum_id, '_bbp_forum_last_reply_id', $reply_id );
    1290                 return true;
    1291         }
     1241        if ( !empty( $reply_id ) )
     1242                return update_post_meta( $forum_id, '_bbp_forum_last_reply_id', $reply_id );
    12921243
    12931244        return false;
    … …  
    12951246
    12961247/**
    1297  * bbp_update_forum_last_active ()
    1298  *
    12991248 * Update the forums last active date/time (aka freshness)
    13001249 *
    1301  * @package bbPress
    1302  * @subpackage Template Tags
    13031250 * @since bbPress (r2680)
    13041251 *
    1305  * @param int $forum_id optional
    1306  *
    1307  * @return string
    1308  */
    1309 function bbp_update_forum_last_active ( $forum_id = 0, $new_time = '' ) {
     1252 * @param int $forum_id Optional. Forum id
     1253 * @param string $new_time Optional. New time in mysql format
     1254 * @uses bbp_get_forum_id() To get the forum id
     1255 * @uses current_time() To get the current time
     1256 * @uses update_post_meta() To update the forum's last active meta
     1257 * @return bool True on success, false on failure
     1258 */
     1259function bbp_update_forum_last_active( $forum_id = 0, $new_time = '' ) {
    13101260        $forum_id = bbp_get_forum_id( $forum_id );
    13111261
    … …  
    13141264                $new_time = current_time( 'mysql' );
    13151265
    1316         // Update the last reply ID
    1317         if ( !empty( $forum_id ) ) {
    1318                 update_post_meta( $forum_id, '_bbp_forum_last_active', $new_time );
    1319                 return true;
    1320         }
     1266        // Update last active
     1267        if ( !empty( $forum_id ) )
     1268                return update_post_meta( $forum_id, '_bbp_forum_last_active', $new_time );
    13211269
    13221270        return false;
    … …  
    13241272
    13251273/**
    1326  * bbp_update_forum_subforum_count ()
    1327  *
    13281274 * Update the forum sub-forum count
    13291275 *
    13301276 * @todo Make this work.
    13311277 *
    1332  * @package bbPress
    1333  * @subpackage Template Tags
    13341278 * @since bbPress (r2625)
    13351279 *
    1336  * @todo everything
    1337  * @param int $forum_id
    1338  */
    1339 function bbp_update_forum_subforum_count ( $forum_id = 0 ) {
     1280 * @param int $forum_id Optional. Forum id
     1281 * @uses bbp_get_forum_id() To get the forum id
     1282 * @return bool True on success, false on failure
     1283 */
     1284function bbp_update_forum_subforum_count( $forum_id = 0 ) {
    13401285        $forum_id = bbp_get_forum_id( $forum_id );
    1341 }
    1342 
    1343 /**
    1344  * bbp_update_forum_topic_count ()
    1345  *
     1286
     1287        return false;
     1288}
     1289
     1290/**
    13461291 * Adjust the total topic count of a forum
    13471292 *
    1348  * @package bbPress
    1349  * @subpackage Template Tags
    1350  * @since bbPress (r2464)
    1351  *
    1352  * @param int $forum_id optional
    1353  * @return int
    1354  */
    1355 function bbp_update_forum_topic_count ( $forum_id = 0 ) {
     1293 * @since bbPress (r2464)
     1294 *
     1295 * @param int $forum_id Optional. Forum id or topic id. It is checked whether it
     1296 *                       is a topic or a forum. If it's a topic, its parent,
     1297 *                       i.e. the forum is automatically retrieved.
     1298 * @uses get_post_field() To check whether the supplied id is a topic
     1299 * @uses bbp_get_topic_forum_id() To get the topic's forum id
     1300 * @uses wpdb::prepare() To prepare the sql statement
     1301 * @uses wpdb::get_col() To execute the query and get the column back
     1302 * @uses update_post_meta() To update the forum's topic count meta
     1303 * @uses apply_filters() Calls 'bbp_update_forum_topic_count' with the topic
     1304 *                        count and forum id
     1305 * @return int Forum topic count
     1306 */
     1307function bbp_update_forum_topic_count( $forum_id = 0 ) {
    13561308        global $wpdb, $bbp;
    13571309
    … …  
    13721324
    13731325/**
    1374  * bbp_update_forum_reply_count ()
    1375  *
    1376  * Adjust the total post count of a forum
     1326 * Adjust the total reply count of a forum
    13771327 *
    13781328 * @todo Make this work
    13791329 *
    1380  * @package bbPress
    1381  * @subpackage Template Tags
    1382  * @since bbPress (r2464)
    1383  *
    1384  * @uses bbp_get_forum_id()
    1385  * @uses apply_filters
    1386  *
    1387  * @param int $forum_id optional
    1388  *
    1389  * @return int
    1390  */
    1391 function bbp_update_forum_reply_count ( $forum_id = 0 ) {
     1330 * @since bbPress (r2464)
     1331 *
     1332 * @param int $forum_id Optional. Forum id or reply id. It is checked whether it
     1333 *                       is a reply or a forum. If it's a reply, its forum is
     1334 *                       automatically retrieved.
     1335 * @uses get_post_field() To check whether the supplied id is a reply
     1336 * @uses bbp_get_reply_topic_id() To get the reply's topic id
     1337 * @uses bbp_get_topic_forum_id() To get the topic's forum id
     1338 * @uses wpdb::prepare() To prepare the sql statement
     1339 * @uses wpdb::get_col() To execute the query and get the column back
     1340 * @uses update_post_meta() To update the forum's reply count meta
     1341 * @uses apply_filters() Calls 'bbp_update_forum_reply_count' with the reply
     1342 *                        count and forum id
     1343 * @return int Forum reply count
     1344 */
     1345function bbp_update_forum_reply_count( $forum_id = 0 ) {
    13921346        global $wpdb, $bbp;
    13931347
    … …  
    14101364
    14111365/**
    1412  * bbp_update_forum_voice_count ()
    1413  *
    14141366 * Adjust the total voice count of a forum
    14151367 *
    1416  * @package bbPress
    1417  * @subpackage Template Tags
    14181368 * @since bbPress (r2567)
    14191369 *
    1420  * @uses bbp_get_forum_id()
    1421  * @uses wpdb
    1422  * @uses apply_filters
    1423  *
    1424  * @todo cache
    1425  *
    1426  * @param int $forum_id optional Topic ID to update
    1427  *
    1428  * @return bool false on failure, voice count on success
    1429  */
    1430 function bbp_update_forum_voice_count ( $forum_id = 0 ) {
     1370 * @param int $forum_id Optional. Forum, topic or reply id. The forum is
     1371 *                                 automatically retrieved based on the input.
     1372 * @uses get_post_field() To check whether the supplied id is a reply
     1373 * @uses bbp_get_reply_topic_id() To get the reply's topic id
     1374 * @uses bbp_get_topic_forum_id() To get the topic's forum id
     1375 * @uses wpdb::prepare() To prepare the sql statement
     1376 * @uses wpdb::get_col() To execute the query and get the column back
     1377 * @uses update_post_meta() To update the forum's voice count meta
     1378 * @uses apply_filters() Calls 'bbp_update_forum_voice_count' with the voice
     1379 *                        count and forum id
     1380 * @return int Forum voice count
     1381 */
     1382function bbp_update_forum_voice_count( $forum_id = 0 ) {
    14311383        global $wpdb, $bbp;
    14321384
    14331385        $forum_id = bbp_get_forum_id( $forum_id );
    14341386
    1435         // If it is not a forum or reply, then we don't need it
    1436         if ( !in_array( get_post_field( 'post_type', $forum_id ), array( $bbp->forum_id, $bbp->reply_id ) ) )
    1437                 return false;
    1438 
    1439         // If it's a reply, then get the parent (forum id)
     1387        // If it's a reply, then get the parent (topic id)
    14401388        if ( $bbp->reply_id == get_post_field( 'post_type', $forum_id ) )
     1389                $forum_id = bbp_get_reply_topic_id( $forum_id );
     1390
     1391        // If it's a topic, then get the parent (forum id)
     1392        if ( $bbp->topic_id == get_post_field( 'post_type', $forum_id ) )
    14411393                $forum_id = bbp_get_topic_forum_id( $forum_id );
    14421394
Note: See TracChangeset for help on using the changeset viewer.