Changeset 2758 for branches/plugin/bbp-includes/bbp-forum-template.php
- Timestamp:
- 01/06/2011 08:25:58 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-forum-template.php
r2747 r2758 1 1 <?php 2 2 3 /** 4 * bbPress Forum Template Tags 5 * 6 * @package bbPress 7 * @subpackage TemplateTags 8 */ 9 3 10 /** START - Forum Loop Functions **********************************************/ 4 11 5 12 /** 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 16 26 * @return object Multidimensional array of forum information 17 27 */ 18 function bbp_has_forums ( $args = '' ) {28 function bbp_has_forums( $args = '' ) { 19 29 global $wp_query, $bbp; 20 30 … … 42 52 43 53 /** 44 * bbp_forums ()45 *46 54 * Whether there are more forums available in the loop 47 55 * 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 53 60 * @return object Forum information 54 61 */ 55 function bbp_forums () {62 function bbp_forums() { 56 63 global $bbp; 57 64 return $bbp->forum_query->have_posts(); … … 59 66 60 67 /** 61 * bbp_the_forum ()62 *63 68 * Loads up the current forum in the loop 64 69 * 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 70 73 * @return object Forum information 71 74 */ 72 function bbp_the_forum () {75 function bbp_the_forum() { 73 76 global $bbp; 74 77 return $bbp->forum_query->the_post(); … … 78 81 79 82 /** 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 */ 90 function bbp_forum_id( $forum_id = 0 ) { 91 echo bbp_get_forum_id( $forum_id ); 92 } 93 /** 94 * Return the forum id 95 * 100 96 * @since bbPress (r2464) 101 97 * 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 ) { 107 109 global $bbp, $wp_query; 108 110 … … 130 132 $bbp->current_forum_id = $bbp_forum_id; 131 133 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 /** 138 138 * Output the link to the forum 139 139 * 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 */ 145 function bbp_forum_permalink( $forum_id = 0 ) { 148 146 echo bbp_get_forum_permalink( $forum_id ); 149 147 } 150 148 /** 151 * bbp_get_forum_permalink ()152 *153 149 * Return the link to the forum 154 150 * 155 * @package bbPress156 * @subpackage Template Tags157 151 * @since bbPress (r2464) 158 152 * 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 162 158 * @return string Permanent link to forum 163 159 */ 164 function bbp_get_forum_permalink ( $forum_id = 0 ) {160 function bbp_get_forum_permalink( $forum_id = 0 ) { 165 161 $forum_id = bbp_get_forum_id( $forum_id ); 166 162 return apply_filters( 'bbp_get_forum_permalink', get_permalink( $forum_id ) ); … … 168 164 169 165 /** 170 * bbp_forum_title ()171 *172 166 * Output the title of the forum in the loop 173 167 * 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 */ 173 function bbp_forum_title( $forum_id = 0 ) { 182 174 echo bbp_get_forum_title( $forum_id ); 183 175 } 184 176 /** 185 * bbp_get_forum_title ()186 *187 177 * Return the title of the forum in the loop 188 178 * 189 * @package bbPress190 * @subpackage Template Tags191 179 * @since bbPress (r2464) 192 180 * 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 196 185 * @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 ) { 200 188 $forum_id = bbp_get_forum_id( $forum_id ); 201 189 … … 204 192 205 193 /** 206 * bbp_forum_last_active ()207 *208 194 * Output the forums last update date/time (aka freshness) 209 195 * 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 */ 201 function bbp_forum_last_active( $forum_id = 0 ) { 218 202 echo bbp_get_forum_last_active( $forum_id ); 219 203 } 220 204 /** 221 * bbp_get_forum_last_active ()222 *223 205 * Return the forums last update date/time (aka freshness) 224 206 * 225 * @package bbPress226 * @subpackage Template Tags227 207 * @since bbPress (r2464) 228 208 * 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 ) { 233 224 $forum_id = bbp_get_forum_id( $forum_id ); 234 225 … … 238 229 } else { 239 230 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 ); 241 232 } 242 233 } … … 245 236 $last_active = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : ''; 246 237 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 */ 251 function 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 /** 253 286 * Return ID of forum parent, if exists 254 287 * 255 * @package bbPress256 * @subpackage Template Tags257 288 * @since bbPress (r2625) 258 289 * 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 */ 296 function bbp_get_forum_parent( $forum_id = 0 ) { 263 297 $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 /** 270 302 * Return array of parent forums 271 303 * 272 * @package bbPress273 * @subpackage Template Tags274 304 * @since bbPress (r2625) 275 305 * 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 */ 313 function bbp_get_forum_ancestors( $forum_id = 0 ) { 280 314 $forum_id = bbp_get_forum_id( $forum_id ); 281 315 … … 292 326 293 327 /** 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) 301 331 * 302 332 * @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 */ 341 function bbp_forum_has_subforums( $args = '' ) { 306 342 global $bbp; 307 343 … … 333 369 334 370 /** 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 */ 391 function bbp_list_forums( $args = '' ) { 342 392 global $bbp; 343 393 … … 361 411 362 412 // 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 ) ) { 364 414 // Total count (for separator) 365 415 $total_subs = count( $sub_forums ); … … 373 423 374 424 // Show topic and reply counts 375 if ( !empty( $show_topic_count ) )425 if ( !empty( $show_topic_count ) && !bbp_is_forum_category( $sub_forum->ID ) ) 376 426 $topic_count = ' (' . bbp_get_forum_topic_count( $sub_forum->ID ) . ')'; 377 427 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 ) ) 380 429 // $reply_count = ' (' . bbp_get_forum_reply_count( $sub_forum->ID ) . ')'; 381 430 … … 391 440 392 441 /** 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 */ 449 function bbp_forum_last_topic_id( $forum_id = 0 ) { 405 450 echo bbp_get_forum_last_topic_id( $forum_id ); 406 451 } 407 452 /** 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 * 414 455 * @since bbPress (r2464) 415 456 * 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 ) { 420 465 $forum_id = bbp_get_forum_id( $forum_id ); 421 466 $topic_id = get_post_meta( $forum_id, '_bbp_forum_last_topic_id', true ); 422 467 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 /** 429 472 * Output the title of the last topic inside a forum 430 473 * 431 * @package bbPress432 * @subpackage Template Tags433 474 * @since bbPress (r2625) 434 475 * 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 */ 479 function bbp_forum_last_topic_title( $forum_id = 0 ) { 438 480 echo bbp_get_forum_last_topic_title( $forum_id ); 439 481 } 440 482 /** 441 * bbp_get_forum_last_topic_title ()442 *443 483 * Return the title of the last topic inside a forum 444 484 * 445 * @package bbPress446 * @subpackage Template Tags447 485 * @since bbPress (r2625) 448 486 * 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 451 494 */ 452 495 function bbp_get_forum_last_topic_title( $forum_id = 0 ) { 453 496 $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 /** 460 501 * Output the link to the last topic in a forum 461 502 * 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 */ 509 function bbp_forum_last_topic_permalink( $forum_id = 0 ) { 470 510 echo bbp_get_forum_last_topic_permalink( $forum_id ); 471 511 } 472 512 /** 473 * bbp_get_forum_last_topic_permalink ()474 *475 513 * Return the link to the last topic in a forum 476 514 * 477 * @package bbPress478 * @subpackage Template Tags479 515 * @since bbPress (r2464) 480 516 * 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 484 523 * @return string Permanent link to topic 485 524 */ 486 function bbp_get_forum_last_topic_permalink ( $forum_id = 0 ) {525 function bbp_get_forum_last_topic_permalink( $forum_id = 0 ) { 487 526 $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 */ 543 function 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 */ 558 function 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 ); 489 580 } 490 581 … … 492 583 493 584 /** 494 * bbp_forum_last_reply_id ()495 *496 585 * Output the forums last reply id 497 586 * 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 */ 592 function bbp_forum_last_reply_id( $forum_id = 0 ) { 506 593 echo bbp_get_forum_last_reply_id( $forum_id ); 507 594 } 508 595 /** 509 * bbp_get_forum_last_reply_id ()510 *511 596 * Return the forums last reply id 512 597 * 513 * @package bbPress514 * @subpackage Template Tags515 598 * @since bbPress (r2464) 516 599 * 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 ) { 521 610 $forum_id = bbp_get_forum_id( $forum_id ); 522 611 $reply_id = get_post_meta( $forum_id, '_bbp_forum_last_reply_id', true ); … … 525 614 $reply_id = bbp_update_forum_last_reply_id( $forum_id ); 526 615 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 /** 533 620 * Output the title of the last reply inside a forum 534 621 * 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 */ 625 function bbp_forum_last_reply_title( $forum_id = 0 ) { 538 626 echo bbp_get_forum_last_reply_title( $forum_id ); 539 627 } 540 628 /** 541 * bbp_get_forum_last_reply_title ()542 *543 629 * Return the title of the last reply inside a forum 544 630 * 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 546 637 * @return string 547 638 */ 548 639 function bbp_get_forum_last_reply_title( $forum_id = 0 ) { 549 640 $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 /** 556 645 * Output the link to the last reply in a forum 557 646 * 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 */ 652 function bbp_forum_last_reply_permalink( $forum_id = 0 ) { 566 653 echo bbp_get_forum_last_reply_permalink( $forum_id ); 567 654 } 568 655 /** 569 * bbp_get_forum_last_reply_permalink ()570 *571 656 * Return the link to the last reply in a forum 572 657 * 573 * @package bbPress574 * @subpackage Template Tags575 658 * @since bbPress (r2464) 576 659 * 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 ) { 583 669 $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 * 594 676 * @since bbPress (r2683) 595 677 * 596 * @param int $forum_id optional597 * @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 */ 681 function bbp_forum_last_reply_url( $forum_id = 0 ) { 600 682 echo bbp_get_forum_last_reply_url( $forum_id ); 601 683 } 602 684 /** 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 * 609 687 * @since bbPress (r2683) 610 688 * 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 614 697 * @return string Paginated URL to latest reply 615 698 */ 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 ); 618 701 619 702 // 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 ) ) { 621 704 $reply_url = bbp_get_reply_url( $reply_id ); 622 705 623 706 // No replies, so look for topics and use last permalink 624 707 } 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 630 710 $reply_url = ''; 631 711 } … … 633 713 634 714 // 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 * 646 721 * @since bbPress (r2625) 647 722 * 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 */ 727 function 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 * 661 733 * @since bbPress (r2625) 662 734 * 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 * 686 753 * @since bbPress (r2625) 687 754 * 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 */ 759 function 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 * 717 765 * @since bbPress (r2625) 718 766 * 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 ) { 787 778 $forum_id = bbp_get_forum_id( $forum_id ); 788 779 $author_id = bbp_get_forum_last_reply_author_id( $forum_id ); 789 780 $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 ); 791 782 } 792 783 … … 794 785 795 786 /** 796 * bbp_forum_subforum_count ()797 *798 787 * Output total sub-forum count of a forum 799 788 * 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 */ 794 function bbp_forum_subforum_count( $forum_id = 0 ) { 808 795 echo bbp_get_forum_subforum_count( $forum_id ); 809 796 } 810 797 /** 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 * 817 800 * @since bbPress (r2464) 818 801 * 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 ) { 826 812 $forum_id = bbp_get_forum_id( $forum_id ); 827 813 $forum_count = get_post_meta( $forum_id, '_bbp_forum_subforum_count', true ); … … 830 816 $forum_count = bbp_update_forum_subforum_count( $forum_id ); 831 817 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 /** 838 822 * Output total topic count of a forum 839 823 * 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 */ 829 function bbp_forum_topic_count( $forum_id = 0 ) { 848 830 echo bbp_get_forum_topic_count( $forum_id ); 849 831 } 850 832 /** 851 * bbp_get_forum_topic_count ()852 *853 833 * Return total topic count of a forum 854 834 * 855 * @package bbPress856 * @subpackage Template Tags857 835 * @since bbPress (r2464) 858 836 * 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 ) { 868 847 $forum_id = bbp_get_forum_id( $forum_id ); 869 848 $topics = get_post_meta( $forum_id, '_bbp_forum_topic_count', true ); … … 876 855 877 856 /** 878 * bbp_forum_reply_count ()879 *880 857 * Output total reply count of a forum 881 858 * 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 */ 864 function bbp_forum_reply_count( $forum_id = 0 ) { 890 865 echo bbp_get_forum_reply_count( $forum_id ); 891 866 } 892 867 /** 893 * bbp_forum_reply_count ()894 *895 868 * Return total post count of a forum 896 869 * 897 * @package bbPress898 * @subpackage Template Tags899 870 * @since bbPress (r2464) 900 871 * 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 ) { 910 882 $forum_id = bbp_get_forum_id( $forum_id ); 911 883 $replies = get_post_meta( $forum_id, '_bbp_forum_reply_count', true ); … … 918 890 919 891 /** 920 * bbp_forum_voice_count ()921 *922 892 * Output total voice count of a forum 923 893 * 924 * @package bbPress925 * @subpackage Template Tags926 894 * @since bbPress (r2567) 927 895 * 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 */ 899 function bbp_forum_voice_count( $forum_id = 0 ) { 934 900 echo bbp_get_forum_voice_count( $forum_id ); 935 901 } 936 902 /** 937 * bbp_get_forum_voice_count ()938 *939 903 * Return total voice count of a forum 940 904 * 941 * @package bbPress942 * @subpackage Template Tags943 905 * @since bbPress (r2567) 944 906 * 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 ) { 953 917 $forum_id = bbp_get_forum_id( $forum_id ); 954 918 $voices = get_post_meta( $forum_id, '_bbp_forum_voice_count', true ); … … 961 925 962 926 /** 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 * 969 929 * @since bbPress (r2667) 970 * @param int $forum_id optional971 * 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 */ 934 function bbp_forum_status( $forum_id = 0 ) { 975 935 echo bbp_get_forum_status( $forum_id ); 976 936 } 977 937 /** 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 * 984 940 * @since bbPress (r2667) 985 941 * 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 990 947 * @return string Status of forum 991 948 */ 992 function bbp_get_forum_status ( $forum_id = 0 ) {949 function bbp_get_forum_status( $forum_id = 0 ) { 993 950 $forum_id = bbp_get_forum_id( $forum_id ); 994 951 … … 1208 1165 1209 1166 /** 1210 * bbp_forum_class ()1211 *1212 1167 * Output the row class of a forum 1213 1168 * 1214 * @package bbPress1215 * @subpackage Template Tags1216 1169 * @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 */ 1173 function bbp_forum_class() { 1174 echo bbp_get_forum_class(); 1175 } 1176 /** 1224 1177 * Return the row class of a forum 1225 1178 * 1226 * @package bbPress1227 * @subpackage Template Tags1228 1179 * @since bbPress (r2667) 1229 1180 * 1230 * @ global WP_Query $bbp->forum_query1231 * @ param int $forum_id1232 * @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() { 1235 1186 global $bbp; 1236 1187 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 ); 1240 1195 1241 1196 return apply_filters( 'bbp_get_forum_class', $post ); … … 1245 1200 1246 1201 /** 1247 * bbp_update_forum_last_topic_id ()1248 *1249 1202 * Update the forum last topic id 1250 1203 * 1251 * @package bbPress1252 * @subpackage Template Tags1253 1204 * @since bbPress (r2625) 1254 1205 * 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 */ 1213 function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { 1259 1214 $forum_id = bbp_get_forum_id( $forum_id ); 1260 1215 $topic_id = bbp_get_topic_id( $topic_id ); 1261 1216 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 ); 1267 1220 1268 1221 return false; … … 1270 1223 1271 1224 /** 1272 * bbp_update_forum_last_reply_id ()1273 *1274 1225 * Update the forum last reply id 1275 1226 * 1276 * @package bbPress1277 * @subpackage Template Tags1278 1227 * @since bbPress (r2625) 1279 1228 * 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 */ 1236 function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { 1284 1237 $forum_id = bbp_get_forum_id( $forum_id ); 1285 1238 $reply_id = bbp_get_reply_id( $reply_id ); 1286 1239 1287 1240 // 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 ); 1292 1243 1293 1244 return false; … … 1295 1246 1296 1247 /** 1297 * bbp_update_forum_last_active ()1298 *1299 1248 * Update the forums last active date/time (aka freshness) 1300 1249 * 1301 * @package bbPress1302 * @subpackage Template Tags1303 1250 * @since bbPress (r2680) 1304 1251 * 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 */ 1259 function bbp_update_forum_last_active( $forum_id = 0, $new_time = '' ) { 1310 1260 $forum_id = bbp_get_forum_id( $forum_id ); 1311 1261 … … 1314 1264 $new_time = current_time( 'mysql' ); 1315 1265 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 ); 1321 1269 1322 1270 return false; … … 1324 1272 1325 1273 /** 1326 * bbp_update_forum_subforum_count ()1327 *1328 1274 * Update the forum sub-forum count 1329 1275 * 1330 1276 * @todo Make this work. 1331 1277 * 1332 * @package bbPress1333 * @subpackage Template Tags1334 1278 * @since bbPress (r2625) 1335 1279 * 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 */ 1284 function bbp_update_forum_subforum_count( $forum_id = 0 ) { 1340 1285 $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 /** 1346 1291 * Adjust the total topic count of a forum 1347 1292 * 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 */ 1307 function bbp_update_forum_topic_count( $forum_id = 0 ) { 1356 1308 global $wpdb, $bbp; 1357 1309 … … 1372 1324 1373 1325 /** 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 1377 1327 * 1378 1328 * @todo Make this work 1379 1329 * 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 */ 1345 function bbp_update_forum_reply_count( $forum_id = 0 ) { 1392 1346 global $wpdb, $bbp; 1393 1347 … … 1410 1364 1411 1365 /** 1412 * bbp_update_forum_voice_count ()1413 *1414 1366 * Adjust the total voice count of a forum 1415 1367 * 1416 * @package bbPress1417 * @subpackage Template Tags1418 1368 * @since bbPress (r2567) 1419 1369 * 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 */ 1382 function bbp_update_forum_voice_count( $forum_id = 0 ) { 1431 1383 global $wpdb, $bbp; 1432 1384 1433 1385 $forum_id = bbp_get_forum_id( $forum_id ); 1434 1386 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) 1440 1388 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 ) ) 1441 1393 $forum_id = bbp_get_topic_forum_id( $forum_id ); 1442 1394
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)