| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * bbPress Forum Template Tags. | |
| 4 | + * bbPress Forum Template Tags | |
| 5 | 5 | * |
| 6 | 6 | * @package bbPress |
| 7 | 7 | * @subpackage TemplateTags |
| 8 | 8 | */ |
| @@ -12,9 +12,9 @@ | ||
| 12 | 12 | |
| 13 | 13 | /** Post Type *****************************************************************/ |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Output the unique id of the custom post type for forums. | |
| 16 | + * Output the unique id of the custom post type for forums | |
| 17 | 17 | * |
| 18 | 18 | * @since 2.0.0 bbPress (r2857) |
| 19 | 19 | */ |
| 20 | 20 | function bbp_forum_post_type() { |
| @@ -19,24 +19,24 @@ | ||
| 19 | 19 | */ |
| 20 | 20 | function bbp_forum_post_type() { |
| 21 | 21 | echo bbp_get_forum_post_type(); |
| 22 | 22 | } |
| 23 | + /** | |
| 24 | + * Return the unique id of the custom post type for forums | |
| 25 | + * | |
| 26 | + * @since 2.0.0 bbPress (r2857) | |
| 27 | + * | |
| 28 | + * @return string The unique forum post type id | |
| 29 | + */ | |
| 30 | + function bbp_get_forum_post_type() { | |
| 23 | 31 | |
| 24 | -/** | |
| 25 | - * Return the unique id of the custom post type for forums. | |
| 26 | - * | |
| 27 | - * @since 2.0.0 bbPress (r2857) | |
| 28 | - * | |
| 29 | - * @return string The unique forum post type id. | |
| 30 | - */ | |
| 31 | -function bbp_get_forum_post_type() { | |
| 32 | + // Filter & return | |
| 33 | + return apply_filters( 'bbp_get_forum_post_type', bbpress()->forum_post_type ); | |
| 34 | + } | |
| 32 | 35 | |
| 33 | - // Filter & return | |
| 34 | - return apply_filters( 'bbp_get_forum_post_type', bbpress()->forum_post_type ); | |
| 35 | -} | |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Return array of labels used by the forum post type. | |
| 38 | + * Return array of labels used by the forum post type | |
| 39 | 39 | * |
| 40 | 40 | * @since 2.5.0 bbPress (r5129) |
| 41 | 41 | * |
| 42 | 42 | * @return array |
| @@ -51,9 +51,9 @@ | ||
| 51 | 51 | 'menu_name' => esc_attr__( 'Forums', 'bbpress' ), |
| 52 | 52 | 'singular_name' => esc_attr__( 'Forum', 'bbpress' ), |
| 53 | 53 | 'all_items' => esc_attr__( 'All Forums', 'bbpress' ), |
| 54 | 54 | 'add_new' => esc_attr__( 'Add New', 'bbpress' ), |
| 55 | - 'add_new_item' => esc_attr__( 'Add Forum', 'bbpress' ), | |
| 55 | + 'add_new_item' => esc_attr__( 'Create New Forum', 'bbpress' ), | |
| 56 | 56 | 'edit' => esc_attr__( 'Edit', 'bbpress' ), |
| 57 | 57 | 'edit_item' => esc_attr__( 'Edit Forum', 'bbpress' ), |
| 58 | 58 | 'new_item' => esc_attr__( 'New Forum', 'bbpress' ), |
| 59 | 59 | 'view' => esc_attr__( 'View Forum', 'bbpress' ), |
| @@ -83,9 +83,9 @@ | ||
| 83 | 83 | ); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * Return array of forum post type rewrite settings. | |
| 87 | + * Return array of forum post type rewrite settings | |
| 88 | 88 | * |
| 89 | 89 | * @since 2.5.0 bbPress (r5129) |
| 90 | 90 | * |
| 91 | 91 | * @return array |
| @@ -102,9 +102,9 @@ | ||
| 102 | 102 | ); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * Return array of features the forum post type supports. | |
| 106 | + * Return array of features the forum post type supports | |
| 107 | 107 | * |
| 108 | 108 | * @since 2.5.0 bbPress (r5129) |
| 109 | 109 | * |
| 110 | 110 | * @return array |
| @@ -132,9 +132,9 @@ | ||
| 132 | 132 | * @since 2.0.0 bbPress (r2464) |
| 133 | 133 | * |
| 134 | 134 | * @param array $args All the arguments supported by {@link WP_Query} |
| 135 | 135 | * |
| 136 | - * @return object Multidimensional array of forum information. | |
| 136 | + * @return object Multidimensional array of forum information | |
| 137 | 137 | */ |
| 138 | 138 | function bbp_has_forums( $args = array() ) { |
| 139 | 139 | |
| 140 | 140 | // Forum archive only shows root |
| @@ -189,13 +189,13 @@ | ||
| 189 | 189 | return apply_filters( 'bbp_has_forums', $bbp->forum_query->have_posts(), $bbp->forum_query ); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | - * Whether there are more forums available in the loop. | |
| 193 | + * Whether there are more forums available in the loop | |
| 194 | 194 | * |
| 195 | 195 | * @since 2.0.0 bbPress (r2464) |
| 196 | 196 | * |
| 197 | - * @return object Forum information. | |
| 197 | + * @return object Forum information | |
| 198 | 198 | */ |
| 199 | 199 | function bbp_forums() { |
| 200 | 200 | |
| 201 | 201 | // Put into variable to check against next |
| @@ -209,13 +209,13 @@ | ||
| 209 | 209 | return $have_posts; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
| 213 | - * Loads up the current forum in the loop. | |
| 213 | + * Loads up the current forum in the loop | |
| 214 | 214 | * |
| 215 | 215 | * @since 2.0.0 bbPress (r2464) |
| 216 | 216 | * |
| 217 | - * @return object Forum information. | |
| 217 | + * @return object Forum information | |
| 218 | 218 | */ |
| 219 | 219 | function bbp_the_forum() { |
| 220 | 220 | return bbpress()->forum_query->the_post(); |
| 221 | 221 | } |
| @@ -222,73 +222,72 @@ | ||
| 222 | 222 | |
| 223 | 223 | /** Forum *********************************************************************/ |
| 224 | 224 | |
| 225 | 225 | /** |
| 226 | - * Output forum id. | |
| 226 | + * Output forum id | |
| 227 | 227 | * |
| 228 | 228 | * @since 2.0.0 bbPress (r2464) |
| 229 | 229 | * |
| 230 | - * @param $forum_id Optional. Used to check emptiness. | |
| 230 | + * @param $forum_id Optional. Used to check emptiness | |
| 231 | 231 | */ |
| 232 | 232 | function bbp_forum_id( $forum_id = 0 ) { |
| 233 | 233 | echo bbp_get_forum_id( $forum_id ); |
| 234 | 234 | } |
| 235 | + /** | |
| 236 | + * Return the forum id | |
| 237 | + * | |
| 238 | + * @since 2.0.0 bbPress (r2464) | |
| 239 | + * | |
| 240 | + * @param $forum_id Optional. Used to check emptiness | |
| 241 | + * @return int The forum id | |
| 242 | + */ | |
| 243 | + function bbp_get_forum_id( $forum_id = 0 ) { | |
| 244 | + $bbp = bbpress(); | |
| 245 | + $wp_query = bbp_get_wp_query(); | |
| 235 | 246 | |
| 236 | -/** | |
| 237 | - * Return the forum id. | |
| 238 | - * | |
| 239 | - * @since 2.0.0 bbPress (r2464) | |
| 240 | - * | |
| 241 | - * @param $forum_id Optional. Used to check emptiness. | |
| 242 | - * @return int The forum id. | |
| 243 | - */ | |
| 244 | -function bbp_get_forum_id( $forum_id = 0 ) { | |
| 245 | - $bbp = bbpress(); | |
| 246 | - $wp_query = bbp_get_wp_query(); | |
| 247 | + // Easy empty checking | |
| 248 | + if ( ! empty( $forum_id ) && is_numeric( $forum_id ) ) { | |
| 249 | + $bbp_forum_id = $forum_id; | |
| 247 | 250 | |
| 248 | - // Easy empty checking | |
| 249 | - if ( ! empty( $forum_id ) && is_numeric( $forum_id ) ) { | |
| 250 | - $bbp_forum_id = $forum_id; | |
| 251 | + // Currently inside a forum loop | |
| 252 | + } elseif ( ! empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) { | |
| 253 | + $bbp_forum_id = $bbp->forum_query->post->ID; | |
| 251 | 254 | |
| 252 | - // Currently inside a forum loop | |
| 253 | - } elseif ( ! empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) { | |
| 254 | - $bbp_forum_id = $bbp->forum_query->post->ID; | |
| 255 | + // Currently inside a search loop | |
| 256 | + } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_forum( $bbp->search_query->post->ID ) ) { | |
| 257 | + $bbp_forum_id = $bbp->search_query->post->ID; | |
| 255 | 258 | |
| 256 | - // Currently inside a search loop | |
| 257 | - } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_forum( $bbp->search_query->post->ID ) ) { | |
| 258 | - $bbp_forum_id = $bbp->search_query->post->ID; | |
| 259 | + // Currently viewing a forum | |
| 260 | + } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && ! empty( $bbp->current_forum_id ) ) { | |
| 261 | + $bbp_forum_id = $bbp->current_forum_id; | |
| 259 | 262 | |
| 260 | - // Currently viewing a forum | |
| 261 | - } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && ! empty( $bbp->current_forum_id ) ) { | |
| 262 | - $bbp_forum_id = $bbp->current_forum_id; | |
| 263 | + // Currently viewing a forum | |
| 264 | + } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && isset( $wp_query->post->ID ) ) { | |
| 265 | + $bbp_forum_id = $wp_query->post->ID; | |
| 263 | 266 | |
| 264 | - // Currently viewing a forum | |
| 265 | - } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && isset( $wp_query->post->ID ) ) { | |
| 266 | - $bbp_forum_id = $wp_query->post->ID; | |
| 267 | + // Currently viewing a topic | |
| 268 | + } elseif ( bbp_is_single_topic() ) { | |
| 269 | + $bbp_forum_id = bbp_get_topic_forum_id(); | |
| 267 | 270 | |
| 268 | - // Currently viewing a topic | |
| 269 | - } elseif ( bbp_is_single_topic() ) { | |
| 270 | - $bbp_forum_id = bbp_get_topic_forum_id(); | |
| 271 | + // Fallback | |
| 272 | + } else { | |
| 273 | + $bbp_forum_id = 0; | |
| 274 | + } | |
| 271 | 275 | |
| 272 | - // Fallback | |
| 273 | - } else { | |
| 274 | - $bbp_forum_id = 0; | |
| 276 | + // Filter & return | |
| 277 | + return (int) apply_filters( 'bbp_get_forum_id', (int) $bbp_forum_id, $forum_id ); | |
| 275 | 278 | } |
| 276 | 279 | |
| 277 | - // Filter & return | |
| 278 | - return (int) apply_filters( 'bbp_get_forum_id', (int) $bbp_forum_id, $forum_id ); | |
| 279 | -} | |
| 280 | - | |
| 281 | 280 | /** |
| 282 | - * Gets a forum. | |
| 281 | + * Gets a forum | |
| 283 | 282 | * |
| 284 | 283 | * @since 2.0.0 bbPress (r2787) |
| 285 | 284 | * |
| 286 | - * @param int|object $forum forum id or forum object. | |
| 287 | - * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT. | |
| 288 | - * @param string $filter Optional Sanitation filter. See {@link sanitize_post()}. | |
| 285 | + * @param int|object $forum forum id or forum object | |
| 286 | + * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT | |
| 287 | + * @param string $filter Optional Sanitation filter. See {@link sanitize_post()} | |
| 289 | 288 | * |
| 290 | - * @return mixed Null if error or forum (in specified form) if success. | |
| 289 | + * @return mixed Null if error or forum (in specified form) if success | |
| 291 | 290 | */ |
| 292 | 291 | function bbp_get_forum( $forum, $output = OBJECT, $filter = 'raw' ) { |
| 293 | 292 | |
| 294 | 293 | // Maybe get ID from empty or int |
| @@ -323,13 +322,13 @@ | ||
| 323 | 322 | return apply_filters( 'bbp_get_forum', $retval, $forum, $output, $filter ); |
| 324 | 323 | } |
| 325 | 324 | |
| 326 | 325 | /** |
| 327 | - * Output the link to the forum. | |
| 326 | + * Output the link to the forum | |
| 328 | 327 | * |
| 329 | 328 | * @since 2.0.0 bbPress (r2464) |
| 330 | 329 | * |
| 331 | - * @param int $forum_id Optional. Forum id. | |
| 330 | + * @param int $forum_id Optional. Forum id | |
| 332 | 331 | * @param string $redirect_to Optional. Pass a redirect value for use with |
| 333 | 332 | * shortcodes and other fun things. |
| 334 | 333 | */ |
| 335 | 334 | function bbp_forum_permalink( $forum_id = 0, $redirect_to = '' ) { |
| @@ -334,178 +333,140 @@ | ||
| 334 | 333 | */ |
| 335 | 334 | function bbp_forum_permalink( $forum_id = 0, $redirect_to = '' ) { |
| 336 | 335 | echo esc_url( bbp_get_forum_permalink( $forum_id, $redirect_to ) ); |
| 337 | 336 | } |
| 337 | + /** | |
| 338 | + * Return the link to the forum | |
| 339 | + * | |
| 340 | + * @since 2.0.0 bbPress (r2464) | |
| 341 | + * | |
| 342 | + * @param int $forum_id Optional. Forum id | |
| 343 | + * @param string $redirect_to Optional. Pass a redirect value for use with | |
| 344 | + * shortcodes and other fun things. | |
| 345 | + * | |
| 346 | + * @return string Permanent link to forum | |
| 347 | + */ | |
| 348 | + function bbp_get_forum_permalink( $forum_id = 0, $redirect_to = '' ) { | |
| 349 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 338 | 350 | |
| 339 | -/** | |
| 340 | - * Return the link to the forum. | |
| 341 | - * | |
| 342 | - * @since 2.0.0 bbPress (r2464) | |
| 343 | - * | |
| 344 | - * @param int $forum_id Optional. Forum id. | |
| 345 | - * @param string $redirect_to Optional. Pass a redirect value for use with | |
| 346 | - * shortcodes and other fun things. | |
| 347 | - * | |
| 348 | - * @return string Permanent link to forum. | |
| 349 | - */ | |
| 350 | -function bbp_get_forum_permalink( $forum_id = 0, $redirect_to = '' ) { | |
| 351 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 351 | + // Use the redirect address | |
| 352 | + if ( ! empty( $redirect_to ) ) { | |
| 353 | + $forum_permalink = esc_url_raw( $redirect_to ); | |
| 352 | 354 | |
| 353 | - // Default return value | |
| 354 | - $forum_permalink = ''; | |
| 355 | - | |
| 356 | - // Use the redirect address | |
| 357 | - if ( ! empty( $redirect_to ) ) { | |
| 358 | - $forum_permalink = esc_url_raw( $redirect_to ); | |
| 359 | - | |
| 360 | - // Plain permalinks: maybe build a slug-based URL using the forum query_var | |
| 361 | - } elseif ( ! get_option( 'permalink_structure' ) ) { | |
| 362 | - | |
| 363 | - // Get the forum object | |
| 364 | - $forum = bbp_get_forum( $forum_id ); | |
| 365 | - | |
| 366 | - // Forum exists | |
| 367 | - if ( ! empty( $forum ) ) { | |
| 368 | - | |
| 369 | - // Get the post type object from the forum | |
| 370 | - $post_type = get_post_type_object( $forum->post_type ); | |
| 371 | - | |
| 372 | - // Publicly queryable by var | |
| 373 | - if ( ! empty( $post_type->query_var ) ) { | |
| 374 | - | |
| 375 | - // Use hierarchical path (parent/child/...) when applicable | |
| 376 | - $path = ! empty( $post_type->hierarchical ) | |
| 377 | - ? get_page_uri( $forum_id ) | |
| 378 | - : $forum->post_name; | |
| 379 | - | |
| 380 | - // Add path to query var | |
| 381 | - $forum_permalink = add_query_arg( | |
| 382 | - $post_type->query_var, | |
| 383 | - $path, | |
| 384 | - home_url( '/' ) | |
| 385 | - ); | |
| 386 | - } | |
| 355 | + // Use the topic permalink | |
| 356 | + } else { | |
| 357 | + $forum_permalink = get_permalink( $forum_id ); | |
| 387 | 358 | } |
| 388 | - } | |
| 389 | 359 | |
| 390 | - // Fallback to forum permalink | |
| 391 | - if ( empty( $forum_permalink ) ) { | |
| 392 | - $forum_permalink = get_permalink( $forum_id ); | |
| 360 | + // Filter & return | |
| 361 | + return apply_filters( 'bbp_get_forum_permalink', $forum_permalink, $forum_id ); | |
| 393 | 362 | } |
| 394 | 363 | |
| 395 | - // Filter & return | |
| 396 | - return apply_filters( 'bbp_get_forum_permalink', $forum_permalink, $forum_id ); | |
| 397 | -} | |
| 398 | - | |
| 399 | 364 | /** |
| 400 | - * Output the title of the forum. | |
| 365 | + * Output the title of the forum | |
| 401 | 366 | * |
| 402 | 367 | * @since 2.0.0 bbPress (r2464) |
| 403 | 368 | * |
| 404 | - * @param int $forum_id Optional. Forum id. | |
| 369 | + * @param int $forum_id Optional. Forum id | |
| 405 | 370 | */ |
| 406 | 371 | function bbp_forum_title( $forum_id = 0 ) { |
| 407 | 372 | echo bbp_get_forum_title( $forum_id ); |
| 408 | 373 | } |
| 374 | + /** | |
| 375 | + * Return the title of the forum | |
| 376 | + * | |
| 377 | + * @since 2.0.0 bbPress (r2464) | |
| 378 | + * | |
| 379 | + * @param int $forum_id Optional. Forum id | |
| 380 | + * @return string Title of forum | |
| 381 | + */ | |
| 382 | + function bbp_get_forum_title( $forum_id = 0 ) { | |
| 383 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 384 | + $title = get_the_title( $forum_id ); | |
| 409 | 385 | |
| 410 | -/** | |
| 411 | - * Return the title of the forum. | |
| 412 | - * | |
| 413 | - * @since 2.0.0 bbPress (r2464) | |
| 414 | - * | |
| 415 | - * @param int $forum_id Optional. Forum id. | |
| 416 | - * @return string Title of forum. | |
| 417 | - */ | |
| 418 | -function bbp_get_forum_title( $forum_id = 0 ) { | |
| 419 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 420 | - $title = get_post_field( 'post_title', $forum_id ); | |
| 421 | - $title = apply_filters( 'the_title', $title, $forum_id ); | |
| 386 | + // Filter & return | |
| 387 | + return apply_filters( 'bbp_get_forum_title', $title, $forum_id ); | |
| 388 | + } | |
| 422 | 389 | |
| 423 | - // Filter & return | |
| 424 | - return apply_filters( 'bbp_get_forum_title', $title, $forum_id ); | |
| 425 | -} | |
| 426 | - | |
| 427 | 390 | /** |
| 428 | - * Output the forum archive title. | |
| 391 | + * Output the forum archive title | |
| 429 | 392 | * |
| 430 | 393 | * @since 2.0.0 bbPress (r3249) |
| 431 | 394 | * |
| 432 | - * @param string $title Default text to use as title. | |
| 395 | + * @param string $title Default text to use as title | |
| 433 | 396 | */ |
| 434 | 397 | function bbp_forum_archive_title( $title = '' ) { |
| 435 | 398 | echo bbp_get_forum_archive_title( $title ); |
| 436 | 399 | } |
| 400 | + /** | |
| 401 | + * Return the forum archive title | |
| 402 | + * | |
| 403 | + * @since 2.0.0 bbPress (r3249) | |
| 404 | + * | |
| 405 | + * @param string $title Default text to use as title | |
| 406 | + * | |
| 407 | + * @return string The forum archive title | |
| 408 | + */ | |
| 409 | + function bbp_get_forum_archive_title( $title = '' ) { | |
| 437 | 410 | |
| 438 | -/** | |
| 439 | - * Return the forum archive title. | |
| 440 | - * | |
| 441 | - * @since 2.0.0 bbPress (r3249) | |
| 442 | - * | |
| 443 | - * @param string $title Default text to use as title. | |
| 444 | - * | |
| 445 | - * @return string The forum archive title. | |
| 446 | - */ | |
| 447 | -function bbp_get_forum_archive_title( $title = '' ) { | |
| 411 | + // If no title was passed | |
| 412 | + if ( empty( $title ) ) { | |
| 448 | 413 | |
| 449 | - // If no title was passed | |
| 450 | - if ( empty( $title ) ) { | |
| 414 | + // Set root text to page title | |
| 415 | + $page = bbp_get_page_by_path( bbp_get_root_slug() ); | |
| 416 | + if ( ! empty( $page ) ) { | |
| 417 | + $title = get_the_title( $page->ID ); | |
| 451 | 418 | |
| 452 | - // Set root text to page title | |
| 453 | - $page = bbp_get_page_by_path( bbp_get_root_slug() ); | |
| 454 | - if ( ! empty( $page ) ) { | |
| 455 | - $title = get_the_title( $page->ID ); | |
| 419 | + // Default to forum post type name label | |
| 420 | + } else { | |
| 421 | + $fto = get_post_type_object( bbp_get_forum_post_type() ); | |
| 422 | + $title = $fto->labels->name; | |
| 423 | + } | |
| 424 | + } | |
| 456 | 425 | |
| 457 | - // Default to forum post type name label | |
| 458 | - } else { | |
| 459 | - $fto = get_post_type_object( bbp_get_forum_post_type() ); | |
| 460 | - $title = $fto->labels->name; | |
| 461 | - } | |
| 426 | + // Filter & return | |
| 427 | + return apply_filters( 'bbp_get_forum_archive_title', $title ); | |
| 462 | 428 | } |
| 463 | 429 | |
| 464 | - // Filter & return | |
| 465 | - return apply_filters( 'bbp_get_forum_archive_title', $title ); | |
| 466 | -} | |
| 467 | - | |
| 468 | 430 | /** |
| 469 | - * Output the content of the forum. | |
| 431 | + * Output the content of the forum | |
| 470 | 432 | * |
| 471 | 433 | * @since 2.0.0 bbPress (r2780) |
| 472 | 434 | * |
| 473 | - * @param int $forum_id Optional. Topic id. | |
| 435 | + * @param int $forum_id Optional. Topic id | |
| 474 | 436 | */ |
| 475 | 437 | function bbp_forum_content( $forum_id = 0 ) { |
| 476 | 438 | echo bbp_get_forum_content( $forum_id ); |
| 477 | 439 | } |
| 440 | + /** | |
| 441 | + * Return the content of the forum | |
| 442 | + * | |
| 443 | + * @since 2.0.0 bbPress (r2780) | |
| 444 | + * | |
| 445 | + * @param int $forum_id Optional. Topic id | |
| 446 | + * | |
| 447 | + * @return string Content of the forum | |
| 448 | + */ | |
| 449 | + function bbp_get_forum_content( $forum_id = 0 ) { | |
| 450 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 478 | 451 | |
| 479 | -/** | |
| 480 | - * Return the content of the forum. | |
| 481 | - * | |
| 482 | - * @since 2.0.0 bbPress (r2780) | |
| 483 | - * | |
| 484 | - * @param int $forum_id Optional. Topic id. | |
| 485 | - * | |
| 486 | - * @return string Content of the forum. | |
| 487 | - */ | |
| 488 | -function bbp_get_forum_content( $forum_id = 0 ) { | |
| 489 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 452 | + // Check if password is required | |
| 453 | + if ( post_password_required( $forum_id ) ) { | |
| 454 | + return get_the_password_form(); | |
| 455 | + } | |
| 490 | 456 | |
| 491 | - // Check if password is required | |
| 492 | - if ( post_password_required( $forum_id ) ) { | |
| 493 | - return get_the_password_form(); | |
| 457 | + $content = get_post_field( 'post_content', $forum_id ); | |
| 458 | + | |
| 459 | + // Filter & return | |
| 460 | + return apply_filters( 'bbp_get_forum_content', $content, $forum_id ); | |
| 494 | 461 | } |
| 495 | 462 | |
| 496 | - $content = get_post_field( 'post_content', $forum_id ); | |
| 497 | - | |
| 498 | - // Filter & return | |
| 499 | - return apply_filters( 'bbp_get_forum_content', $content, $forum_id ); | |
| 500 | -} | |
| 501 | - | |
| 502 | 463 | /** |
| 503 | - * Allow forum rows to have administrative actions. | |
| 464 | + * Allow forum rows to have administrative actions | |
| 504 | 465 | * |
| 505 | 466 | * @since 2.1.0 bbPress (r3653) |
| 506 | 467 | * |
| 507 | - * @todo Links and filter. | |
| 468 | + * @todo Links and filter | |
| 508 | 469 | */ |
| 509 | 470 | function bbp_forum_row_actions() { |
| 510 | 471 | do_action( 'bbp_forum_row_actions' ); |
| 511 | 472 | } |
| @@ -510,80 +471,75 @@ | ||
| 510 | 471 | do_action( 'bbp_forum_row_actions' ); |
| 511 | 472 | } |
| 512 | 473 | |
| 513 | 474 | /** |
| 514 | - * Output the forums last active ID. | |
| 475 | + * Output the forums last active ID | |
| 515 | 476 | * |
| 516 | 477 | * @since 2.0.0 bbPress (r2860) |
| 517 | 478 | * |
| 518 | - * @param int $forum_id Optional. Forum id. | |
| 479 | + * @param int $forum_id Optional. Forum id | |
| 519 | 480 | */ |
| 520 | 481 | function bbp_forum_last_active_id( $forum_id = 0 ) { |
| 521 | 482 | echo bbp_get_forum_last_active_id( $forum_id ); |
| 522 | 483 | } |
| 484 | + /** | |
| 485 | + * Return the forums last active ID | |
| 486 | + * | |
| 487 | + * @since 2.0.0 bbPress (r2860) | |
| 488 | + * | |
| 489 | + * @param int $forum_id Optional. Forum id | |
| 490 | + * the last active id and forum id | |
| 491 | + * @return int Forum's last active id | |
| 492 | + */ | |
| 493 | + function bbp_get_forum_last_active_id( $forum_id = 0 ) { | |
| 494 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 495 | + $active_id = (int) get_post_meta( $forum_id, '_bbp_last_active_id', true ); | |
| 523 | 496 | |
| 524 | -/** | |
| 525 | - * Return the forums last active ID. | |
| 526 | - * | |
| 527 | - * @since 2.0.0 bbPress (r2860) | |
| 528 | - * | |
| 529 | - * @param int $forum_id Optional. Forum id. | |
| 530 | - * the last active id and forum id. | |
| 531 | - * @return int Forum's last active id. | |
| 532 | - */ | |
| 533 | -function bbp_get_forum_last_active_id( $forum_id = 0 ) { | |
| 534 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 535 | - $active_id = (int) get_post_meta( $forum_id, '_bbp_last_active_id', true ); | |
| 497 | + // Filter & return | |
| 498 | + return (int) apply_filters( 'bbp_get_forum_last_active_id', $active_id, $forum_id ); | |
| 499 | + } | |
| 536 | 500 | |
| 537 | - // Filter & return | |
| 538 | - return (int) apply_filters( 'bbp_get_forum_last_active_id', $active_id, $forum_id ); | |
| 539 | -} | |
| 540 | - | |
| 541 | 501 | /** |
| 542 | - * Output the forums last update date/time (aka freshness). | |
| 502 | + * Output the forums last update date/time (aka freshness) | |
| 543 | 503 | * |
| 544 | 504 | * @since 2.0.0 bbPress (r2464) |
| 545 | 505 | * |
| 546 | - * @param int $forum_id Optional. Forum id. | |
| 506 | + * @param int $forum_id Optional. Forum id | |
| 547 | 507 | */ |
| 548 | 508 | function bbp_forum_last_active_time( $forum_id = 0 ) { |
| 549 | 509 | echo bbp_get_forum_last_active_time( $forum_id ); |
| 550 | 510 | } |
| 511 | + /** | |
| 512 | + * Return the forums last update date/time (aka freshness) | |
| 513 | + * | |
| 514 | + * @since 2.0.0 bbPress (r2464) | |
| 515 | + * | |
| 516 | + * @param int $forum_id Optional. Forum id | |
| 517 | + * @return string Forum last update date/time (freshness) | |
| 518 | + */ | |
| 519 | + function bbp_get_forum_last_active_time( $forum_id = 0 ) { | |
| 551 | 520 | |
| 552 | -/** | |
| 553 | - * Return the forums last update date/time (aka freshness). | |
| 554 | - * | |
| 555 | - * @since 2.0.0 bbPress (r2464) | |
| 556 | - * | |
| 557 | - * @param int $forum_id Optional. Forum id. | |
| 558 | - * @return string Forum last update date/time (freshness). | |
| 559 | - */ | |
| 560 | -function bbp_get_forum_last_active_time( $forum_id = 0 ) { | |
| 521 | + // Verify forum and get last active meta | |
| 522 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 523 | + $last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true ); | |
| 561 | 524 | |
| 562 | - // Verify forum and get last active meta | |
| 563 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 564 | - $last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true ); | |
| 565 | - | |
| 566 | - if ( empty( $last_active ) ) { | |
| 567 | - $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 568 | - | |
| 569 | - if ( ! empty( $reply_id ) ) { | |
| 570 | - $last_active = get_post_field( 'post_date', $reply_id ); | |
| 571 | - } else { | |
| 572 | - $topic_id = bbp_get_forum_last_topic_id( $forum_id ); | |
| 573 | - if ( ! empty( $topic_id ) ) { | |
| 574 | - $last_active = bbp_get_topic_last_active_time( $topic_id ); | |
| 525 | + if ( empty( $last_active ) ) { | |
| 526 | + $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 527 | + if ( ! empty( $reply_id ) ) { | |
| 528 | + $last_active = get_post_field( 'post_date', $reply_id ); | |
| 529 | + } else { | |
| 530 | + $topic_id = bbp_get_forum_last_topic_id( $forum_id ); | |
| 531 | + if ( ! empty( $topic_id ) ) { | |
| 532 | + $last_active = bbp_get_topic_last_active_time( $topic_id ); | |
| 533 | + } | |
| 575 | 534 | } |
| 576 | 535 | } |
| 577 | - } | |
| 578 | 536 | |
| 579 | - $active_time = ! empty( $last_active ) | |
| 580 | - ? bbp_get_time_since( bbp_convert_date( $last_active ) ) | |
| 581 | - : ''; | |
| 537 | + $active_time = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : ''; | |
| 582 | 538 | |
| 583 | - // Filter & return | |
| 584 | - return apply_filters( 'bbp_get_forum_last_active', $active_time, $forum_id ); | |
| 585 | -} | |
| 539 | + // Filter & return | |
| 540 | + return apply_filters( 'bbp_get_forum_last_active', $active_time, $forum_id ); | |
| 541 | + } | |
| 586 | 542 | |
| 587 | 543 | /** |
| 588 | 544 | * Output link to the most recent activity inside a forum. |
| 589 | 545 | * |
| @@ -595,95 +551,93 @@ | ||
| 595 | 551 | */ |
| 596 | 552 | function bbp_forum_freshness_link( $forum_id = 0 ) { |
| 597 | 553 | echo bbp_get_forum_freshness_link( $forum_id ); |
| 598 | 554 | } |
| 555 | + /** | |
| 556 | + * Returns link to the most recent activity inside a forum. | |
| 557 | + * | |
| 558 | + * Returns a complete link with attributes and content. | |
| 559 | + * | |
| 560 | + * @since 2.0.0 bbPress (r2625) | |
| 561 | + * | |
| 562 | + * @param int $forum_id Optional. Forum id | |
| 563 | + */ | |
| 564 | + function bbp_get_forum_freshness_link( $forum_id = 0 ) { | |
| 565 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 566 | + $active_id = bbp_get_forum_last_active_id( $forum_id ); | |
| 567 | + $link_url = $title = ''; | |
| 599 | 568 | |
| 600 | -/** | |
| 601 | - * Returns link to the most recent activity inside a forum. | |
| 602 | - * | |
| 603 | - * Returns a complete link with attributes and content. | |
| 604 | - * | |
| 605 | - * @since 2.0.0 bbPress (r2625) | |
| 606 | - * | |
| 607 | - * @param int $forum_id Optional. Forum id. | |
| 608 | - */ | |
| 609 | -function bbp_get_forum_freshness_link( $forum_id = 0 ) { | |
| 610 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 611 | - $active_id = bbp_get_forum_last_active_id( $forum_id ); | |
| 612 | - $link_url = $title = ''; | |
| 569 | + if ( empty( $active_id ) ) { | |
| 570 | + $active_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 571 | + } | |
| 613 | 572 | |
| 614 | - if ( empty( $active_id ) ) { | |
| 615 | - $active_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 616 | - } | |
| 573 | + if ( empty( $active_id ) ) { | |
| 574 | + $active_id = bbp_get_forum_last_topic_id( $forum_id ); | |
| 575 | + } | |
| 617 | 576 | |
| 618 | - if ( empty( $active_id ) ) { | |
| 619 | - $active_id = bbp_get_forum_last_topic_id( $forum_id ); | |
| 620 | - } | |
| 577 | + if ( bbp_is_topic( $active_id ) ) { | |
| 578 | + $link_url = bbp_get_forum_last_topic_permalink( $forum_id ); | |
| 579 | + $title = bbp_get_forum_last_topic_title( $forum_id ); | |
| 580 | + } elseif ( bbp_is_reply( $active_id ) ) { | |
| 581 | + $link_url = bbp_get_forum_last_reply_url( $forum_id ); | |
| 582 | + $title = bbp_get_forum_last_reply_title( $forum_id ); | |
| 583 | + } | |
| 621 | 584 | |
| 622 | - if ( bbp_is_topic( $active_id ) ) { | |
| 623 | - $link_url = bbp_get_forum_last_topic_permalink( $forum_id ); | |
| 624 | - $title = bbp_get_forum_last_topic_title( $forum_id ); | |
| 625 | - } elseif ( bbp_is_reply( $active_id ) ) { | |
| 626 | - $link_url = bbp_get_forum_last_reply_url( $forum_id ); | |
| 627 | - $title = bbp_get_forum_last_reply_title( $forum_id ); | |
| 628 | - } | |
| 585 | + $time_since = bbp_get_forum_last_active_time( $forum_id ); | |
| 629 | 586 | |
| 630 | - $time_since = bbp_get_forum_last_active_time( $forum_id ); | |
| 587 | + if ( ! empty( $time_since ) && ! empty( $link_url ) ) { | |
| 588 | + $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>'; | |
| 589 | + } else { | |
| 590 | + $anchor = esc_html__( 'No Topics', 'bbpress' ); | |
| 591 | + } | |
| 631 | 592 | |
| 632 | - if ( ! empty( $time_since ) && ! empty( $link_url ) ) { | |
| 633 | - $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>'; | |
| 634 | - } else { | |
| 635 | - $anchor = esc_html__( 'No Topics', 'bbpress' ); | |
| 593 | + // Filter & return | |
| 594 | + return apply_filters( 'bbp_get_forum_freshness_link', $anchor, $forum_id, $time_since, $link_url, $title, $active_id ); | |
| 636 | 595 | } |
| 637 | 596 | |
| 638 | - // Filter & return | |
| 639 | - return apply_filters( 'bbp_get_forum_freshness_link', $anchor, $forum_id, $time_since, $link_url, $title, $active_id ); | |
| 640 | -} | |
| 641 | - | |
| 642 | 597 | /** |
| 643 | - * Output parent ID of a forum, if exists. | |
| 598 | + * Output parent ID of a forum, if exists | |
| 644 | 599 | * |
| 645 | 600 | * @since 2.1.0 bbPress (r3675) |
| 646 | 601 | * |
| 647 | - * @param int $forum_id Forum ID. | |
| 602 | + * @param int $forum_id Forum ID | |
| 648 | 603 | */ |
| 649 | 604 | function bbp_forum_parent_id( $forum_id = 0 ) { |
| 650 | 605 | echo bbp_get_forum_parent_id( $forum_id ); |
| 651 | 606 | } |
| 607 | + /** | |
| 608 | + * Return ID of forum parent, if exists | |
| 609 | + * | |
| 610 | + * @since 2.1.0 bbPress (r3675) | |
| 611 | + * | |
| 612 | + * @param int $forum_id Optional. Forum id | |
| 613 | + * @return int Forum parent | |
| 614 | + */ | |
| 615 | + function bbp_get_forum_parent_id( $forum_id = 0 ) { | |
| 616 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 617 | + $parent_id = (int) get_post_field( 'post_parent', $forum_id ); | |
| 652 | 618 | |
| 653 | -/** | |
| 654 | - * Return ID of forum parent, if exists. | |
| 655 | - * | |
| 656 | - * @since 2.1.0 bbPress (r3675) | |
| 657 | - * | |
| 658 | - * @param int $forum_id Optional. Forum id. | |
| 659 | - * @return int Forum parent id. | |
| 660 | - */ | |
| 661 | -function bbp_get_forum_parent_id( $forum_id = 0 ) { | |
| 662 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 663 | - $parent_id = (int) get_post_field( 'post_parent', $forum_id ); | |
| 619 | + // Meta-data fallback | |
| 620 | + if ( empty( $parent_id ) ) { | |
| 621 | + $parent_id = (int) get_post_meta( $forum_id, '_bbp_forum_id', true ); | |
| 622 | + } | |
| 664 | 623 | |
| 665 | - // Meta-data fallback | |
| 666 | - if ( empty( $parent_id ) ) { | |
| 667 | - $parent_id = (int) get_post_meta( $forum_id, '_bbp_forum_id', true ); | |
| 668 | - } | |
| 624 | + // Filter | |
| 625 | + if ( ! empty( $parent_id ) ) { | |
| 626 | + $parent_id = (int) bbp_get_forum_id( $parent_id ); | |
| 627 | + } | |
| 669 | 628 | |
| 670 | - // Filter | |
| 671 | - if ( ! empty( $parent_id ) ) { | |
| 672 | - $parent_id = (int) bbp_get_forum_id( $parent_id ); | |
| 629 | + // Filter & return | |
| 630 | + return (int) apply_filters( 'bbp_get_forum_parent_id', $parent_id, $forum_id ); | |
| 673 | 631 | } |
| 674 | 632 | |
| 675 | - // Filter & return | |
| 676 | - return (int) apply_filters( 'bbp_get_forum_parent_id', $parent_id, $forum_id ); | |
| 677 | -} | |
| 678 | - | |
| 679 | 633 | /** |
| 680 | - * Return array of parent forums. | |
| 634 | + * Return array of parent forums | |
| 681 | 635 | * |
| 682 | 636 | * @since 2.0.0 bbPress (r2625) |
| 683 | 637 | * |
| 684 | - * @param int $forum_id Optional. Forum id. | |
| 685 | - * @return array Forum ancestors. | |
| 638 | + * @param int $forum_id Optional. Forum id | |
| 639 | + * @return array Forum ancestors | |
| 686 | 640 | */ |
| 687 | 641 | function bbp_get_forum_ancestors( $forum_id = 0 ) { |
| 688 | 642 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 689 | 643 | $ancestors = array(); |
| @@ -700,14 +654,14 @@ | ||
| 700 | 654 | return apply_filters( 'bbp_get_forum_ancestors', $ancestors, $forum_id ); |
| 701 | 655 | } |
| 702 | 656 | |
| 703 | 657 | /** |
| 704 | - * Return subforums of given forum. | |
| 658 | + * Return subforums of given forum | |
| 705 | 659 | * |
| 706 | 660 | * @since 2.0.0 bbPress (r2747) |
| 707 | 661 | * |
| 708 | - * @param array $args All the arguments supported by {@link WP_Query}. | |
| 709 | - * @return mixed false if none, array of subs if yes. | |
| 662 | + * @param array $args All the arguments supported by {@link WP_Query} | |
| 663 | + * @return mixed false if none, array of subs if yes | |
| 710 | 664 | */ |
| 711 | 665 | function bbp_forum_get_subforums( $args = array() ) { |
| 712 | 666 | |
| 713 | 667 | // Default return value |
| @@ -746,9 +700,9 @@ | ||
| 746 | 700 | return (array) apply_filters( 'bbp_forum_get_subforums', $retval, $r, $args ); |
| 747 | 701 | } |
| 748 | 702 | |
| 749 | 703 | /** |
| 750 | - * Output a list of forums (can be used to list subforums). | |
| 704 | + * Output a list of forums (can be used to list subforums) | |
| 751 | 705 | * |
| 752 | 706 | * @since 2.0.0 bbPress (r2708) |
| 753 | 707 | * |
| 754 | 708 | * @param array $args The function supports these args: |
| @@ -860,9 +814,9 @@ | ||
| 860 | 814 | |
| 861 | 815 | /** Forum Subscriptions *******************************************************/ |
| 862 | 816 | |
| 863 | 817 | /** |
| 864 | - * Output the forum subscription link. | |
| 818 | + * Output the forum subscription link | |
| 865 | 819 | * |
| 866 | 820 | * @since 2.5.0 bbPress (r5156) |
| 867 | 821 | * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support |
| 868 | 822 | */ |
| @@ -869,16 +823,16 @@ | ||
| 869 | 823 | function bbp_forum_subscription_link( $args = array() ) { |
| 870 | 824 | echo bbp_get_forum_subscription_link( $args ); |
| 871 | 825 | } |
| 872 | 826 | |
| 873 | -/** | |
| 874 | - * Get the forum subscription link. | |
| 875 | - * | |
| 876 | - * A custom wrapper for bbp_get_user_subscribe_link(). | |
| 877 | - * | |
| 878 | - * @since 2.5.0 bbPress (r5156) | |
| 879 | - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support | |
| 880 | - */ | |
| 827 | + /** | |
| 828 | + * Get the forum subscription link | |
| 829 | + * | |
| 830 | + * A custom wrapper for bbp_get_user_subscribe_link() | |
| 831 | + * | |
| 832 | + * @since 2.5.0 bbPress (r5156) | |
| 833 | + * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support | |
| 834 | + */ | |
| 881 | 835 | function bbp_get_forum_subscription_link( $args = array() ) { |
| 882 | 836 | |
| 883 | 837 | // Defaults |
| 884 | 838 | $retval = false; |
| @@ -914,99 +868,94 @@ | ||
| 914 | 868 | |
| 915 | 869 | /** Forum Last Topic **********************************************************/ |
| 916 | 870 | |
| 917 | 871 | /** |
| 918 | - * Output the forum's last topic id. | |
| 872 | + * Output the forum's last topic id | |
| 919 | 873 | * |
| 920 | 874 | * @since 2.0.0 bbPress (r2464) |
| 921 | 875 | * |
| 922 | - * @param int $forum_id Optional. Forum id. | |
| 876 | + * @param int $forum_id Optional. Forum id | |
| 923 | 877 | */ |
| 924 | 878 | function bbp_forum_last_topic_id( $forum_id = 0 ) { |
| 925 | 879 | echo bbp_get_forum_last_topic_id( $forum_id ); |
| 926 | 880 | } |
| 881 | + /** | |
| 882 | + * Return the forum's last topic id | |
| 883 | + * | |
| 884 | + * @since 2.0.0 bbPress (r2464) | |
| 885 | + * | |
| 886 | + * @param int $forum_id Optional. Forum id | |
| 887 | + * @return int Forum's last topic id | |
| 888 | + */ | |
| 889 | + function bbp_get_forum_last_topic_id( $forum_id = 0 ) { | |
| 890 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 891 | + $topic_id = (int) get_post_meta( $forum_id, '_bbp_last_topic_id', true ); | |
| 927 | 892 | |
| 928 | -/** | |
| 929 | - * Return the forum's last topic id. | |
| 930 | - * | |
| 931 | - * @since 2.0.0 bbPress (r2464) | |
| 932 | - * | |
| 933 | - * @param int $forum_id Optional. Forum id. | |
| 934 | - * @return int Forum's last topic id. | |
| 935 | - */ | |
| 936 | -function bbp_get_forum_last_topic_id( $forum_id = 0 ) { | |
| 937 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 938 | - $topic_id = (int) get_post_meta( $forum_id, '_bbp_last_topic_id', true ); | |
| 893 | + // Filter & return | |
| 894 | + return (int) apply_filters( 'bbp_get_forum_last_topic_id', $topic_id, $forum_id ); | |
| 895 | + } | |
| 939 | 896 | |
| 940 | - // Filter & return | |
| 941 | - return (int) apply_filters( 'bbp_get_forum_last_topic_id', $topic_id, $forum_id ); | |
| 942 | -} | |
| 943 | - | |
| 944 | 897 | /** |
| 945 | - * Output the title of the last topic inside a forum. | |
| 898 | + * Output the title of the last topic inside a forum | |
| 946 | 899 | * |
| 947 | 900 | * @since 2.0.0 bbPress (r2625) |
| 948 | 901 | * |
| 949 | - * @param int $forum_id Optional. Forum id. | |
| 902 | + * @param int $forum_id Optional. Forum id | |
| 950 | 903 | */ |
| 951 | 904 | function bbp_forum_last_topic_title( $forum_id = 0 ) { |
| 952 | 905 | echo bbp_get_forum_last_topic_title( $forum_id ); |
| 953 | 906 | } |
| 907 | + /** | |
| 908 | + * Return the title of the last topic inside a forum | |
| 909 | + * | |
| 910 | + * @since 2.0.0 bbPress (r2625) | |
| 911 | + * | |
| 912 | + * @param int $forum_id Optional. Forum id | |
| 913 | + * @return string Forum's last topic's title | |
| 914 | + */ | |
| 915 | + function bbp_get_forum_last_topic_title( $forum_id = 0 ) { | |
| 916 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 917 | + $topic_id = bbp_get_forum_last_topic_id( $forum_id ); | |
| 918 | + $title = ! empty( $topic_id ) ? bbp_get_topic_title( $topic_id ) : ''; | |
| 954 | 919 | |
| 955 | -/** | |
| 956 | - * Return the title of the last topic inside a forum. | |
| 957 | - * | |
| 958 | - * @since 2.0.0 bbPress (r2625) | |
| 959 | - * | |
| 960 | - * @param int $forum_id Optional. Forum id. | |
| 961 | - * @return string Forum's last topic's title. | |
| 962 | - */ | |
| 963 | -function bbp_get_forum_last_topic_title( $forum_id = 0 ) { | |
| 964 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 965 | - $topic_id = bbp_get_forum_last_topic_id( $forum_id ); | |
| 966 | - $title = ! empty( $topic_id ) | |
| 967 | - ? bbp_get_topic_title( $topic_id ) | |
| 968 | - : ''; | |
| 920 | + // Filter & return | |
| 921 | + return apply_filters( 'bbp_get_forum_last_topic_title', $title, $forum_id ); | |
| 922 | + } | |
| 969 | 923 | |
| 970 | - // Filter & return | |
| 971 | - return apply_filters( 'bbp_get_forum_last_topic_title', $title, $forum_id ); | |
| 972 | -} | |
| 973 | - | |
| 974 | 924 | /** |
| 975 | - * Output the link to the last topic in a forum. | |
| 925 | + * Output the link to the last topic in a forum | |
| 976 | 926 | * |
| 977 | 927 | * @since 2.0.0 bbPress (r2464) |
| 978 | 928 | * |
| 979 | - * @param int $forum_id Optional. Forum id. | |
| 929 | + * @param int $forum_id Optional. Forum id | |
| 980 | 930 | */ |
| 981 | 931 | function bbp_forum_last_topic_permalink( $forum_id = 0 ) { |
| 982 | 932 | echo esc_url( bbp_get_forum_last_topic_permalink( $forum_id ) ); |
| 983 | 933 | } |
| 934 | + /** | |
| 935 | + * Return the link to the last topic in a forum | |
| 936 | + * | |
| 937 | + * @since 2.0.0 bbPress (r2464) | |
| 938 | + * | |
| 939 | + * @param int $forum_id Optional. Forum id | |
| 940 | + * @return string Permanent link to topic | |
| 941 | + */ | |
| 942 | + function bbp_get_forum_last_topic_permalink( $forum_id = 0 ) { | |
| 943 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 944 | + $topic_id = bbp_get_forum_last_topic_id( $forum_id ); | |
| 945 | + $link = bbp_get_topic_permalink( $topic_id ); | |
| 984 | 946 | |
| 985 | -/** | |
| 986 | - * Return the link to the last topic in a forum. | |
| 987 | - * | |
| 988 | - * @since 2.0.0 bbPress (r2464) | |
| 989 | - * | |
| 990 | - * @param int $forum_id Optional. Forum id. | |
| 991 | - * @return string Permanent link to topic. | |
| 992 | - */ | |
| 993 | -function bbp_get_forum_last_topic_permalink( $forum_id = 0 ) { | |
| 994 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 995 | - $topic_id = bbp_get_forum_last_topic_id( $forum_id ); | |
| 996 | - $link = bbp_get_topic_permalink( $topic_id ); | |
| 947 | + // Filter & return | |
| 948 | + return apply_filters( 'bbp_get_forum_last_topic_permalink', $link, $forum_id, $topic_id ); | |
| 949 | + } | |
| 997 | 950 | |
| 998 | - // Filter & return | |
| 999 | - return apply_filters( 'bbp_get_forum_last_topic_permalink', $link, $forum_id, $topic_id ); | |
| 1000 | -} | |
| 1001 | - | |
| 1002 | 951 | /** |
| 1003 | - * Return the author ID of the last topic of a forum. | |
| 952 | + * Return the author ID of the last topic of a forum | |
| 1004 | 953 | * |
| 1005 | 954 | * @since 2.0.0 bbPress (r2625) |
| 1006 | 955 | * |
| 1007 | - * @param int $forum_id Optional. Forum id. | |
| 1008 | - * @return int Forum's last topic's author id. | |
| 956 | + * @param int $forum_id Optional. Forum id | |
| 957 | + * @return int Forum's last topic's author id | |
| 1009 | 958 | */ |
| 1010 | 959 | function bbp_get_forum_last_topic_author_id( $forum_id = 0 ) { |
| 1011 | 960 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 1012 | 961 | $topic_id = bbp_get_forum_last_topic_id( $forum_id ); |
| @@ -1016,234 +965,227 @@ | ||
| 1016 | 965 | return (int) apply_filters( 'bbp_get_forum_last_topic_author_id', (int) $author_id, $forum_id, $topic_id ); |
| 1017 | 966 | } |
| 1018 | 967 | |
| 1019 | 968 | /** |
| 1020 | - * Output link to author of last topic of forum. | |
| 969 | + * Output link to author of last topic of forum | |
| 1021 | 970 | * |
| 1022 | 971 | * @since 2.0.0 bbPress (r2625) |
| 1023 | 972 | * |
| 1024 | - * @param int $forum_id Optional. Forum id. | |
| 973 | + * @param int $forum_id Optional. Forum id | |
| 1025 | 974 | */ |
| 1026 | 975 | function bbp_forum_last_topic_author_link( $forum_id = 0 ) { |
| 1027 | 976 | echo bbp_get_forum_last_topic_author_link( $forum_id ); |
| 1028 | 977 | } |
| 978 | + /** | |
| 979 | + * Return link to author of last topic of forum | |
| 980 | + * | |
| 981 | + * @since 2.0.0 bbPress (r2625) | |
| 982 | + * | |
| 983 | + * @param int $forum_id Optional. Forum id | |
| 984 | + * @return string Forum's last topic's author link | |
| 985 | + */ | |
| 986 | + function bbp_get_forum_last_topic_author_link( $forum_id = 0 ) { | |
| 987 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 988 | + $author_id = bbp_get_forum_last_topic_author_id( $forum_id ); | |
| 989 | + $author_link = bbp_get_user_profile_link( $author_id ); | |
| 1029 | 990 | |
| 1030 | -/** | |
| 1031 | - * Return link to author of last topic of forum. | |
| 1032 | - * | |
| 1033 | - * @since 2.0.0 bbPress (r2625) | |
| 1034 | - * | |
| 1035 | - * @param int $forum_id Optional. Forum id. | |
| 1036 | - * @return string Forum's last topic's author link. | |
| 1037 | - */ | |
| 1038 | -function bbp_get_forum_last_topic_author_link( $forum_id = 0 ) { | |
| 1039 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1040 | - $author_id = bbp_get_forum_last_topic_author_id( $forum_id ); | |
| 1041 | - $author_link = bbp_get_user_profile_link( $author_id ); | |
| 991 | + // Filter & return | |
| 992 | + return apply_filters( 'bbp_get_forum_last_topic_author_link', $author_link, $forum_id ); | |
| 993 | + } | |
| 1042 | 994 | |
| 1043 | - // Filter & return | |
| 1044 | - return apply_filters( 'bbp_get_forum_last_topic_author_link', $author_link, $forum_id ); | |
| 1045 | -} | |
| 1046 | - | |
| 1047 | 995 | /** Forum Last Reply **********************************************************/ |
| 1048 | 996 | |
| 1049 | 997 | /** |
| 1050 | - * Output the forums last reply id. | |
| 998 | + * Output the forums last reply id | |
| 1051 | 999 | * |
| 1052 | 1000 | * @since 2.0.0 bbPress (r2464) |
| 1053 | 1001 | * |
| 1054 | - * @param int $forum_id Optional. Forum id. | |
| 1002 | + * @param int $forum_id Optional. Forum id | |
| 1055 | 1003 | */ |
| 1056 | 1004 | function bbp_forum_last_reply_id( $forum_id = 0 ) { |
| 1057 | 1005 | echo bbp_get_forum_last_reply_id( $forum_id ); |
| 1058 | 1006 | } |
| 1007 | + /** | |
| 1008 | + * Return the forums last reply id | |
| 1009 | + * | |
| 1010 | + * @since 2.0.0 bbPress (r2464) | |
| 1011 | + * | |
| 1012 | + * @param int $forum_id Optional. Forum id | |
| 1013 | + * @return int Forum's last reply id | |
| 1014 | + */ | |
| 1015 | + function bbp_get_forum_last_reply_id( $forum_id = 0 ) { | |
| 1016 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1017 | + $reply_id = (int) get_post_meta( $forum_id, '_bbp_last_reply_id', true ); | |
| 1059 | 1018 | |
| 1060 | -/** | |
| 1061 | - * Return the forums last reply id. | |
| 1062 | - * | |
| 1063 | - * @since 2.0.0 bbPress (r2464) | |
| 1064 | - * | |
| 1065 | - * @param int $forum_id Optional. Forum id. | |
| 1066 | - * @return int Forum's last reply id. | |
| 1067 | - */ | |
| 1068 | -function bbp_get_forum_last_reply_id( $forum_id = 0 ) { | |
| 1069 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1070 | - $reply_id = (int) get_post_meta( $forum_id, '_bbp_last_reply_id', true ); | |
| 1019 | + // Filter & return | |
| 1020 | + return (int) apply_filters( 'bbp_get_forum_last_reply_id', $reply_id, $forum_id ); | |
| 1021 | + } | |
| 1071 | 1022 | |
| 1072 | - // Filter & return | |
| 1073 | - return (int) apply_filters( 'bbp_get_forum_last_reply_id', $reply_id, $forum_id ); | |
| 1074 | -} | |
| 1075 | - | |
| 1076 | 1023 | /** |
| 1077 | - * Output the title of the last reply inside a forum. | |
| 1024 | + * Output the title of the last reply inside a forum | |
| 1078 | 1025 | * |
| 1079 | - * @param int $forum_id Optional. Forum id. | |
| 1026 | + * @param int $forum_id Optional. Forum id | |
| 1080 | 1027 | */ |
| 1081 | 1028 | function bbp_forum_last_reply_title( $forum_id = 0 ) { |
| 1082 | 1029 | echo bbp_get_forum_last_reply_title( $forum_id ); |
| 1083 | 1030 | } |
| 1031 | + /** | |
| 1032 | + * Return the title of the last reply inside a forum | |
| 1033 | + * | |
| 1034 | + * @param int $forum_id Optional. Forum id | |
| 1035 | + * @return string | |
| 1036 | + */ | |
| 1037 | + function bbp_get_forum_last_reply_title( $forum_id = 0 ) { | |
| 1038 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1039 | + $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 1040 | + $title = bbp_get_reply_title( $reply_id ); | |
| 1084 | 1041 | |
| 1085 | -/** | |
| 1086 | - * Return the title of the last reply inside a forum. | |
| 1087 | - * | |
| 1088 | - * @param int $forum_id Optional. Forum id. | |
| 1089 | - * @return string | |
| 1090 | - */ | |
| 1091 | -function bbp_get_forum_last_reply_title( $forum_id = 0 ) { | |
| 1092 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1093 | - $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 1094 | - $title = bbp_get_reply_title( $reply_id ); | |
| 1042 | + // Filter & return | |
| 1043 | + return apply_filters( 'bbp_get_forum_last_reply_title', $title, $forum_id, $reply_id ); | |
| 1044 | + } | |
| 1095 | 1045 | |
| 1096 | - // Filter & return | |
| 1097 | - return apply_filters( 'bbp_get_forum_last_reply_title', $title, $forum_id, $reply_id ); | |
| 1098 | -} | |
| 1099 | - | |
| 1100 | 1046 | /** |
| 1101 | - * Output the link to the last reply in a forum. | |
| 1047 | + * Output the link to the last reply in a forum | |
| 1102 | 1048 | * |
| 1103 | 1049 | * @since 2.0.0 bbPress (r2464) |
| 1104 | 1050 | * |
| 1105 | - * @param int $forum_id Optional. Forum id. | |
| 1051 | + * @param int $forum_id Optional. Forum id | |
| 1106 | 1052 | */ |
| 1107 | 1053 | function bbp_forum_last_reply_permalink( $forum_id = 0 ) { |
| 1108 | 1054 | echo esc_url( bbp_get_forum_last_reply_permalink( $forum_id ) ); |
| 1109 | 1055 | } |
| 1056 | + /** | |
| 1057 | + * Return the link to the last reply in a forum | |
| 1058 | + * | |
| 1059 | + * @since 2.0.0 bbPress (r2464) | |
| 1060 | + * | |
| 1061 | + * @param int $forum_id Optional. Forum id | |
| 1062 | + * | |
| 1063 | + * @return string Permanent link to the forum's last reply | |
| 1064 | + */ | |
| 1065 | + function bbp_get_forum_last_reply_permalink( $forum_id = 0 ) { | |
| 1066 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1067 | + $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 1068 | + $link = bbp_get_reply_permalink( $reply_id ); | |
| 1110 | 1069 | |
| 1111 | -/** | |
| 1112 | - * Return the link to the last reply in a forum. | |
| 1113 | - * | |
| 1114 | - * @since 2.0.0 bbPress (r2464) | |
| 1115 | - * | |
| 1116 | - * @param int $forum_id Optional. Forum id. | |
| 1117 | - * | |
| 1118 | - * @return string Permanent link to the forum's last reply. | |
| 1119 | - */ | |
| 1120 | -function bbp_get_forum_last_reply_permalink( $forum_id = 0 ) { | |
| 1121 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1122 | - $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 1123 | - $link = bbp_get_reply_permalink( $reply_id ); | |
| 1070 | + // Filter & return | |
| 1071 | + return apply_filters( 'bbp_get_forum_last_reply_permalink', $link, $forum_id, $reply_id ); | |
| 1072 | + } | |
| 1124 | 1073 | |
| 1125 | - // Filter & return | |
| 1126 | - return apply_filters( 'bbp_get_forum_last_reply_permalink', $link, $forum_id, $reply_id ); | |
| 1127 | -} | |
| 1128 | - | |
| 1129 | 1074 | /** |
| 1130 | - * Output the url to the last reply in a forum. | |
| 1075 | + * Output the url to the last reply in a forum | |
| 1131 | 1076 | * |
| 1132 | 1077 | * @since 2.0.0 bbPress (r2683) |
| 1133 | 1078 | * |
| 1134 | - * @param int $forum_id Optional. Forum id. | |
| 1079 | + * @param int $forum_id Optional. Forum id | |
| 1135 | 1080 | */ |
| 1136 | 1081 | function bbp_forum_last_reply_url( $forum_id = 0 ) { |
| 1137 | 1082 | echo esc_url( bbp_get_forum_last_reply_url( $forum_id ) ); |
| 1138 | 1083 | } |
| 1084 | + /** | |
| 1085 | + * Return the url to the last reply in a forum | |
| 1086 | + * | |
| 1087 | + * @since 2.0.0 bbPress (r2683) | |
| 1088 | + * | |
| 1089 | + * @param int $forum_id Optional. Forum id | |
| 1090 | + * @return string Paginated URL to latest reply | |
| 1091 | + */ | |
| 1092 | + function bbp_get_forum_last_reply_url( $forum_id = 0 ) { | |
| 1093 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1139 | 1094 | |
| 1140 | -/** | |
| 1141 | - * Return the url to the last reply in a forum. | |
| 1142 | - * | |
| 1143 | - * @since 2.0.0 bbPress (r2683) | |
| 1144 | - * | |
| 1145 | - * @param int $forum_id Optional. Forum id. | |
| 1146 | - * @return string Paginated URL to latest reply. | |
| 1147 | - */ | |
| 1148 | -function bbp_get_forum_last_reply_url( $forum_id = 0 ) { | |
| 1149 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1095 | + // If forum has replies, get the last reply and use its url | |
| 1096 | + $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 1097 | + if ( ! empty( $reply_id ) ) { | |
| 1098 | + $reply_url = bbp_get_reply_url( $reply_id ); | |
| 1150 | 1099 | |
| 1151 | - // If forum has replies, get the last reply and use its url | |
| 1152 | - $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 1153 | - if ( ! empty( $reply_id ) ) { | |
| 1154 | - $reply_url = bbp_get_reply_url( $reply_id ); | |
| 1100 | + // No replies, so look for topics and use last permalink | |
| 1101 | + } else { | |
| 1102 | + $reply_url = bbp_get_forum_last_topic_permalink( $forum_id ); | |
| 1155 | 1103 | |
| 1156 | - // No replies, so look for topics and use last permalink | |
| 1157 | - } else { | |
| 1158 | - $reply_url = bbp_get_forum_last_topic_permalink( $forum_id ); | |
| 1104 | + // No topics either, so set $reply_url as empty string | |
| 1105 | + if ( empty( $reply_url ) ) { | |
| 1106 | + $reply_url = ''; | |
| 1107 | + } | |
| 1108 | + } | |
| 1159 | 1109 | |
| 1160 | - // No topics either, so set $reply_url as empty string | |
| 1161 | - if ( empty( $reply_url ) ) { | |
| 1162 | - $reply_url = ''; | |
| 1163 | - } | |
| 1110 | + // Filter & return | |
| 1111 | + return apply_filters( 'bbp_get_forum_last_reply_url', $reply_url, $forum_id, $reply_id ); | |
| 1164 | 1112 | } |
| 1165 | 1113 | |
| 1166 | - // Filter & return | |
| 1167 | - return apply_filters( 'bbp_get_forum_last_reply_url', $reply_url, $forum_id, $reply_id ); | |
| 1168 | -} | |
| 1169 | - | |
| 1170 | 1114 | /** |
| 1171 | - * Output author ID of last reply of forum. | |
| 1115 | + * Output author ID of last reply of forum | |
| 1172 | 1116 | * |
| 1173 | 1117 | * @since 2.0.0 bbPress (r2625) |
| 1174 | 1118 | * |
| 1175 | - * @param int $forum_id Optional. Forum id. | |
| 1119 | + * @param int $forum_id Optional. Forum id | |
| 1176 | 1120 | */ |
| 1177 | 1121 | function bbp_forum_last_reply_author_id( $forum_id = 0 ) { |
| 1178 | 1122 | echo bbp_get_forum_last_reply_author_id( $forum_id ); |
| 1179 | 1123 | } |
| 1124 | + /** | |
| 1125 | + * Return author ID of last reply of forum | |
| 1126 | + * | |
| 1127 | + * @since 2.0.0 bbPress (r2625) | |
| 1128 | + * | |
| 1129 | + * @param int $forum_id Optional. Forum id | |
| 1130 | + * @return int Forum's last reply author id | |
| 1131 | + */ | |
| 1132 | + function bbp_get_forum_last_reply_author_id( $forum_id = 0 ) { | |
| 1133 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1134 | + $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 1135 | + $author_id = bbp_get_reply_author_id( $reply_id ); | |
| 1180 | 1136 | |
| 1181 | -/** | |
| 1182 | - * Return author ID of last reply of forum. | |
| 1183 | - * | |
| 1184 | - * @since 2.0.0 bbPress (r2625) | |
| 1185 | - * | |
| 1186 | - * @param int $forum_id Optional. Forum id. | |
| 1187 | - * @return int Forum's last reply author id. | |
| 1188 | - */ | |
| 1189 | -function bbp_get_forum_last_reply_author_id( $forum_id = 0 ) { | |
| 1190 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1191 | - $reply_id = bbp_get_forum_last_reply_id( $forum_id ); | |
| 1192 | - $author_id = bbp_get_reply_author_id( $reply_id ); | |
| 1137 | + // Filter & return | |
| 1138 | + return apply_filters( 'bbp_get_forum_last_reply_author_id', $author_id, $forum_id, $reply_id ); | |
| 1139 | + } | |
| 1193 | 1140 | |
| 1194 | - // Filter & return | |
| 1195 | - return apply_filters( 'bbp_get_forum_last_reply_author_id', $author_id, $forum_id, $reply_id ); | |
| 1196 | -} | |
| 1197 | - | |
| 1198 | 1141 | /** |
| 1199 | - * Output link to author of last reply of forum. | |
| 1142 | + * Output link to author of last reply of forum | |
| 1200 | 1143 | * |
| 1201 | 1144 | * @since 2.0.0 bbPress (r2625) |
| 1202 | 1145 | * |
| 1203 | - * @param int $forum_id Optional. Forum id. | |
| 1146 | + * @param int $forum_id Optional. Forum id | |
| 1204 | 1147 | */ |
| 1205 | 1148 | function bbp_forum_last_reply_author_link( $forum_id = 0 ) { |
| 1206 | 1149 | echo bbp_get_forum_last_reply_author_link( $forum_id ); |
| 1207 | 1150 | } |
| 1151 | + /** | |
| 1152 | + * Return link to author of last reply of forum | |
| 1153 | + * | |
| 1154 | + * @since 2.0.0 bbPress (r2625) | |
| 1155 | + * | |
| 1156 | + * @param int $forum_id Optional. Forum id | |
| 1157 | + * @return string Link to author of last reply of forum | |
| 1158 | + */ | |
| 1159 | + function bbp_get_forum_last_reply_author_link( $forum_id = 0 ) { | |
| 1160 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1161 | + $author_id = bbp_get_forum_last_reply_author_id( $forum_id ); | |
| 1162 | + $author_link = bbp_get_user_profile_link( $author_id ); | |
| 1208 | 1163 | |
| 1209 | -/** | |
| 1210 | - * Return link to author of last reply of forum. | |
| 1211 | - * | |
| 1212 | - * @since 2.0.0 bbPress (r2625) | |
| 1213 | - * | |
| 1214 | - * @param int $forum_id Optional. Forum id. | |
| 1215 | - * @return string Link to author of last reply of forum. | |
| 1216 | - */ | |
| 1217 | -function bbp_get_forum_last_reply_author_link( $forum_id = 0 ) { | |
| 1218 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1219 | - $author_id = bbp_get_forum_last_reply_author_id( $forum_id ); | |
| 1220 | - $author_link = bbp_get_user_profile_link( $author_id ); | |
| 1164 | + // Filter & return | |
| 1165 | + return apply_filters( 'bbp_get_forum_last_reply_author_link', $author_link, $forum_id, $author_id ); | |
| 1166 | + } | |
| 1221 | 1167 | |
| 1222 | - // Filter & return | |
| 1223 | - return apply_filters( 'bbp_get_forum_last_reply_author_link', $author_link, $forum_id, $author_id ); | |
| 1224 | -} | |
| 1225 | - | |
| 1226 | 1168 | /** Forum Counts **************************************************************/ |
| 1227 | 1169 | |
| 1228 | 1170 | /** |
| 1229 | - * Output the topics link of the forum. | |
| 1171 | + * Output the topics link of the forum | |
| 1230 | 1172 | * |
| 1231 | 1173 | * @since 2.0.0 bbPress (r2883) |
| 1232 | 1174 | * |
| 1233 | - * @param int $forum_id Optional. Topic id. | |
| 1175 | + * @param int $forum_id Optional. Topic id | |
| 1234 | 1176 | */ |
| 1235 | 1177 | function bbp_forum_topics_link( $forum_id = 0 ) { |
| 1236 | 1178 | echo bbp_get_forum_topics_link( $forum_id ); |
| 1237 | 1179 | } |
| 1238 | 1180 | |
| 1239 | -/** | |
| 1240 | - * Return the topics link of the forum. | |
| 1241 | - * | |
| 1242 | - * @since 2.0.0 bbPress (r2883) | |
| 1243 | - * | |
| 1244 | - * @param int $forum_id Optional. Topic id. | |
| 1245 | - */ | |
| 1181 | + /** | |
| 1182 | + * Return the topics link of the forum | |
| 1183 | + * | |
| 1184 | + * @since 2.0.0 bbPress (r2883) | |
| 1185 | + * | |
| 1186 | + * @param int $forum_id Optional. Topic id | |
| 1187 | + */ | |
| 1246 | 1188 | function bbp_get_forum_topics_link( $forum_id = 0 ) { |
| 1247 | 1189 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 1248 | 1190 | $link = bbp_get_forum_permalink( $forum_id ); |
| 1249 | 1191 | /* translators: %s: Number of topics */ |
| @@ -1275,315 +1217,306 @@ | ||
| 1275 | 1217 | return apply_filters( 'bbp_get_forum_topics_link', $retval, $forum_id ); |
| 1276 | 1218 | } |
| 1277 | 1219 | |
| 1278 | 1220 | /** |
| 1279 | - * Output total sub-forum count of a forum. | |
| 1221 | + * Output total sub-forum count of a forum | |
| 1280 | 1222 | * |
| 1281 | 1223 | * @since 2.0.0 bbPress (r2464) |
| 1282 | 1224 | * |
| 1283 | - * @param int $forum_id Optional. Forum id to check. | |
| 1284 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1225 | + * @param int $forum_id Optional. Forum id to check | |
| 1226 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1285 | 1227 | */ |
| 1286 | 1228 | function bbp_forum_subforum_count( $forum_id = 0, $integer = false ) { |
| 1287 | 1229 | echo bbp_get_forum_subforum_count( $forum_id, $integer ); |
| 1288 | 1230 | } |
| 1231 | + /** | |
| 1232 | + * Return total subforum count of a forum | |
| 1233 | + * | |
| 1234 | + * @since 2.0.0 bbPress (r2464) | |
| 1235 | + * | |
| 1236 | + * @param int $forum_id Optional. Forum id | |
| 1237 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1238 | + * @return int Forum's subforum count | |
| 1239 | + */ | |
| 1240 | + function bbp_get_forum_subforum_count( $forum_id = 0, $integer = false ) { | |
| 1241 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1242 | + $forum_count = (int) get_post_meta( $forum_id, '_bbp_forum_subforum_count', true ); | |
| 1243 | + $filter = ( true === $integer ) | |
| 1244 | + ? 'bbp_get_forum_subforum_count_int' | |
| 1245 | + : 'bbp_get_forum_subforum_count'; | |
| 1289 | 1246 | |
| 1290 | -/** | |
| 1291 | - * Return total subforum count of a forum. | |
| 1292 | - * | |
| 1293 | - * @since 2.0.0 bbPress (r2464) | |
| 1294 | - * | |
| 1295 | - * @param int $forum_id Optional. Forum id. | |
| 1296 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1297 | - * @return int Forum's subforum count. | |
| 1298 | - */ | |
| 1299 | -function bbp_get_forum_subforum_count( $forum_id = 0, $integer = false ) { | |
| 1300 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1301 | - $forum_count = (int) get_post_meta( $forum_id, '_bbp_forum_subforum_count', true ); | |
| 1302 | - $filter = ( true === $integer ) | |
| 1303 | - ? 'bbp_get_forum_subforum_count_int' | |
| 1304 | - : 'bbp_get_forum_subforum_count'; | |
| 1247 | + return apply_filters( $filter, $forum_count, $forum_id ); | |
| 1248 | + } | |
| 1305 | 1249 | |
| 1306 | - return apply_filters( $filter, $forum_count, $forum_id ); | |
| 1307 | -} | |
| 1308 | - | |
| 1309 | 1250 | /** |
| 1310 | - * Output total topic count of a forum. | |
| 1251 | + * Output total topic count of a forum | |
| 1311 | 1252 | * |
| 1312 | 1253 | * @since 2.0.0 bbPress (r2464) |
| 1313 | 1254 | * |
| 1314 | - * @param int $forum_id Optional. Forum id. | |
| 1255 | + * @param int $forum_id Optional. Forum id | |
| 1315 | 1256 | * @param bool $total_count Optional. To get the total count or normal count? |
| 1316 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1257 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1317 | 1258 | */ |
| 1318 | 1259 | function bbp_forum_topic_count( $forum_id = 0, $total_count = true, $integer = false ) { |
| 1319 | 1260 | echo bbp_get_forum_topic_count( $forum_id, $total_count, $integer ); |
| 1320 | 1261 | } |
| 1262 | + /** | |
| 1263 | + * Return total topic count of a forum | |
| 1264 | + * | |
| 1265 | + * @since 2.0.0 bbPress (r2464) | |
| 1266 | + * | |
| 1267 | + * @param int $forum_id Optional. Forum id | |
| 1268 | + * @param bool $total_count Optional. To get the total count or normal | |
| 1269 | + * count? Defaults to total. | |
| 1270 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1271 | + * @return int Forum topic count | |
| 1272 | + */ | |
| 1273 | + function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true, $integer = false ) { | |
| 1274 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1275 | + $meta_key = empty( $total_count ) ? '_bbp_topic_count' : '_bbp_total_topic_count'; | |
| 1276 | + $topics = (int) get_post_meta( $forum_id, $meta_key, true ); | |
| 1277 | + $filter = ( true === $integer ) | |
| 1278 | + ? 'bbp_get_forum_topic_count_int' | |
| 1279 | + : 'bbp_get_forum_topic_count'; | |
| 1321 | 1280 | |
| 1322 | -/** | |
| 1323 | - * Return total topic count of a forum. | |
| 1324 | - * | |
| 1325 | - * @since 2.0.0 bbPress (r2464) | |
| 1326 | - * | |
| 1327 | - * @param int $forum_id Optional. Forum id. | |
| 1328 | - * @param bool $total_count Optional. To get the total count or normal | |
| 1329 | - * count? Defaults to total. | |
| 1330 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1331 | - * @return int Forum topic count. | |
| 1332 | - */ | |
| 1333 | -function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true, $integer = false ) { | |
| 1334 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1335 | - $meta_key = empty( $total_count ) ? '_bbp_topic_count' : '_bbp_total_topic_count'; | |
| 1336 | - $topics = (int) get_post_meta( $forum_id, $meta_key, true ); | |
| 1337 | - $filter = ( true === $integer ) | |
| 1338 | - ? 'bbp_get_forum_topic_count_int' | |
| 1339 | - : 'bbp_get_forum_topic_count'; | |
| 1281 | + return apply_filters( $filter, $topics, $forum_id ); | |
| 1282 | + } | |
| 1340 | 1283 | |
| 1341 | - return apply_filters( $filter, $topics, $forum_id ); | |
| 1342 | -} | |
| 1343 | - | |
| 1344 | 1284 | /** |
| 1345 | - * Output total reply count of a forum. | |
| 1285 | + * Output total reply count of a forum | |
| 1346 | 1286 | * |
| 1347 | 1287 | * @since 2.0.0 bbPress (r2464) |
| 1348 | 1288 | * |
| 1349 | - * @param int $forum_id Optional. Forum id. | |
| 1289 | + * @param int $forum_id Optional. Forum id | |
| 1350 | 1290 | * @param bool $total_count Optional. To get the total count or normal count? |
| 1351 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1291 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1352 | 1292 | */ |
| 1353 | 1293 | function bbp_forum_reply_count( $forum_id = 0, $total_count = true, $integer = false ) { |
| 1354 | 1294 | echo bbp_get_forum_reply_count( $forum_id, $total_count, $integer ); |
| 1355 | 1295 | } |
| 1296 | + /** | |
| 1297 | + * Return total post count of a forum | |
| 1298 | + * | |
| 1299 | + * @since 2.0.0 bbPress (r2464) | |
| 1300 | + * | |
| 1301 | + * @param int $forum_id Optional. Forum id | |
| 1302 | + * @param bool $total_count Optional. To get the total count or normal | |
| 1303 | + * count? | |
| 1304 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1305 | + * @return int Forum reply count | |
| 1306 | + */ | |
| 1307 | + function bbp_get_forum_reply_count( $forum_id = 0, $total_count = true, $integer = false ) { | |
| 1308 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1309 | + $meta_key = empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count'; | |
| 1310 | + $replies = (int) get_post_meta( $forum_id, $meta_key, true ); | |
| 1311 | + $filter = ( true === $integer ) | |
| 1312 | + ? 'bbp_get_forum_reply_count_int' | |
| 1313 | + : 'bbp_get_forum_reply_count'; | |
| 1356 | 1314 | |
| 1357 | -/** | |
| 1358 | - * Return total post count of a forum. | |
| 1359 | - * | |
| 1360 | - * @since 2.0.0 bbPress (r2464) | |
| 1361 | - * | |
| 1362 | - * @param int $forum_id Optional. Forum id. | |
| 1363 | - * @param bool $total_count Optional. To get the total count or normal | |
| 1364 | - * count? | |
| 1365 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1366 | - * @return int Forum reply count. | |
| 1367 | - */ | |
| 1368 | -function bbp_get_forum_reply_count( $forum_id = 0, $total_count = true, $integer = false ) { | |
| 1369 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1370 | - $meta_key = empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count'; | |
| 1371 | - $replies = (int) get_post_meta( $forum_id, $meta_key, true ); | |
| 1372 | - $filter = ( true === $integer ) | |
| 1373 | - ? 'bbp_get_forum_reply_count_int' | |
| 1374 | - : 'bbp_get_forum_reply_count'; | |
| 1315 | + return apply_filters( $filter, $replies, $forum_id ); | |
| 1316 | + } | |
| 1375 | 1317 | |
| 1376 | - return apply_filters( $filter, $replies, $forum_id ); | |
| 1377 | -} | |
| 1378 | - | |
| 1379 | 1318 | /** |
| 1380 | - * Output total post count of a forum. | |
| 1319 | + * Output total post count of a forum | |
| 1381 | 1320 | * |
| 1382 | 1321 | * @since 2.0.0 bbPress (r2954) |
| 1383 | 1322 | * |
| 1384 | - * @param int $forum_id Optional. Forum id. | |
| 1323 | + * @param int $forum_id Optional. Forum id | |
| 1385 | 1324 | * @param bool $total_count Optional. To get the total count or normal count? |
| 1386 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1325 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1387 | 1326 | */ |
| 1388 | 1327 | function bbp_forum_post_count( $forum_id = 0, $total_count = true, $integer = false ) { |
| 1389 | 1328 | echo bbp_get_forum_post_count( $forum_id, $total_count, $integer ); |
| 1390 | 1329 | } |
| 1330 | + /** | |
| 1331 | + * Return total post count of a forum | |
| 1332 | + * | |
| 1333 | + * @since 2.0.0 bbPress (r2954) | |
| 1334 | + * | |
| 1335 | + * @param int $forum_id Optional. Forum id | |
| 1336 | + * @param bool $total_count Optional. To get the total count or normal | |
| 1337 | + * count? | |
| 1338 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1339 | + * @return int Forum post count | |
| 1340 | + */ | |
| 1341 | + function bbp_get_forum_post_count( $forum_id = 0, $total_count = true, $integer = false ) { | |
| 1342 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1343 | + $topics = bbp_get_forum_topic_count( $forum_id, $total_count, true ); | |
| 1344 | + $replies = bbp_get_forum_reply_count( $forum_id, $total_count, true ); | |
| 1345 | + $retval = ( $replies + $topics ); | |
| 1346 | + $filter = ( true === $integer ) | |
| 1347 | + ? 'bbp_get_forum_post_count_int' | |
| 1348 | + : 'bbp_get_forum_post_count'; | |
| 1391 | 1349 | |
| 1392 | -/** | |
| 1393 | - * Return total post count of a forum. | |
| 1394 | - * | |
| 1395 | - * @since 2.0.0 bbPress (r2954) | |
| 1396 | - * | |
| 1397 | - * @param int $forum_id Optional. Forum id. | |
| 1398 | - * @param bool $total_count Optional. To get the total count or normal | |
| 1399 | - * count? | |
| 1400 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1401 | - * @return int Forum post count. | |
| 1402 | - */ | |
| 1403 | -function bbp_get_forum_post_count( $forum_id = 0, $total_count = true, $integer = false ) { | |
| 1404 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1405 | - $topics = bbp_get_forum_topic_count( $forum_id, $total_count, true ); | |
| 1406 | - $replies = bbp_get_forum_reply_count( $forum_id, $total_count, true ); | |
| 1407 | - $retval = ( $replies + $topics ); | |
| 1408 | - $filter = ( true === $integer ) | |
| 1409 | - ? 'bbp_get_forum_post_count_int' | |
| 1410 | - : 'bbp_get_forum_post_count'; | |
| 1350 | + return apply_filters( $filter, $retval, $forum_id ); | |
| 1351 | + } | |
| 1411 | 1352 | |
| 1412 | - return apply_filters( $filter, $retval, $forum_id ); | |
| 1413 | -} | |
| 1414 | - | |
| 1415 | 1353 | /** |
| 1416 | 1354 | * Output total hidden topic count of a forum (hidden includes trashed, spammed, |
| 1417 | - * and pending topics). | |
| 1355 | + * and pending topics) | |
| 1418 | 1356 | * |
| 1419 | 1357 | * @since 2.0.0 bbPress (r2883) |
| 1420 | 1358 | * @since 2.6.0 bbPress (r6922) Changed function signature to add total counts |
| 1421 | 1359 | * |
| 1422 | - * @param int $forum_id Optional. Forum id. | |
| 1360 | + * @param int $forum_id Optional. Forum id | |
| 1423 | 1361 | * @param bool $total_count Optional. To get the total count or normal count? |
| 1424 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1362 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1425 | 1363 | */ |
| 1426 | 1364 | function bbp_forum_topic_count_hidden( $forum_id = 0, $total_count = true, $integer = null ) { |
| 1427 | 1365 | echo bbp_get_forum_topic_count_hidden( $forum_id, $total_count, $integer ); |
| 1428 | 1366 | } |
| 1367 | + /** | |
| 1368 | + * Return total hidden topic count of a forum (hidden includes trashed, | |
| 1369 | + * spammed and pending topics) | |
| 1370 | + * | |
| 1371 | + * @since 2.0.0 bbPress (r2883) | |
| 1372 | + * @since 2.6.0 bbPress (r6922) Changed function signature to add total counts | |
| 1373 | + * | |
| 1374 | + * @param int $forum_id Optional. Forum id | |
| 1375 | + * @param bool $total_count Optional. To get the total count or normal count? | |
| 1376 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1377 | + * @return int Topic hidden topic count | |
| 1378 | + */ | |
| 1379 | + function bbp_get_forum_topic_count_hidden( $forum_id = 0, $total_count = true, $integer = null ) { | |
| 1380 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1381 | + $meta_key = empty( $total_count ) ? '_bbp_topic_count_hidden' : '_bbp_total_topic_count_hidden'; | |
| 1382 | + $topics = (int) get_post_meta( $forum_id, $meta_key, true ); | |
| 1383 | + $filter = ( true === $integer ) | |
| 1384 | + ? 'bbp_get_forum_topic_count_hidden_int' | |
| 1385 | + : 'bbp_get_forum_topic_count_hidden'; | |
| 1429 | 1386 | |
| 1430 | -/** | |
| 1431 | - * Return total hidden topic count of a forum (hidden includes trashed, | |
| 1432 | - * spammed and pending topics). | |
| 1433 | - * | |
| 1434 | - * @since 2.0.0 bbPress (r2883) | |
| 1435 | - * @since 2.6.0 bbPress (r6922) Changed function signature to add total counts | |
| 1436 | - * | |
| 1437 | - * @param int $forum_id Optional. Forum id. | |
| 1438 | - * @param bool $total_count Optional. To get the total count or normal count? | |
| 1439 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1440 | - * @return int Topic hidden topic count. | |
| 1441 | - */ | |
| 1442 | -function bbp_get_forum_topic_count_hidden( $forum_id = 0, $total_count = true, $integer = null ) { | |
| 1443 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1444 | - $meta_key = empty( $total_count ) ? '_bbp_topic_count_hidden' : '_bbp_total_topic_count_hidden'; | |
| 1445 | - $topics = (int) get_post_meta( $forum_id, $meta_key, true ); | |
| 1446 | - $filter = ( true === $integer ) | |
| 1447 | - ? 'bbp_get_forum_topic_count_hidden_int' | |
| 1448 | - : 'bbp_get_forum_topic_count_hidden'; | |
| 1387 | + return apply_filters( $filter, $topics, $forum_id ); | |
| 1388 | + } | |
| 1449 | 1389 | |
| 1450 | - return apply_filters( $filter, $topics, $forum_id ); | |
| 1451 | -} | |
| 1452 | - | |
| 1453 | 1390 | /** |
| 1454 | 1391 | * Output total hidden reply count of a forum (hidden includes trashed, spammed, |
| 1455 | - * and pending replies). | |
| 1392 | + * and pending replies) | |
| 1456 | 1393 | * |
| 1457 | 1394 | * @since 2.6.0 bbPress (r6922) |
| 1458 | 1395 | * |
| 1459 | - * @param int $forum_id Optional. Forum id. | |
| 1396 | + * @param int $forum_id Optional. Forum id | |
| 1460 | 1397 | * @param bool $total_count Optional. To get the total count or normal count? |
| 1461 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1398 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1462 | 1399 | */ |
| 1463 | 1400 | function bbp_forum_reply_count_hidden( $forum_id = 0, $total_count = true, $integer = false ) { |
| 1464 | 1401 | echo bbp_get_forum_reply_count_hidden( $forum_id, $total_count, $integer ); |
| 1465 | 1402 | } |
| 1403 | + /** | |
| 1404 | + * Return total hidden reply count of a forum (hidden includes trashed, | |
| 1405 | + * spammed and pending replies) | |
| 1406 | + * | |
| 1407 | + * @since 2.6.0 bbPress (r6922) | |
| 1408 | + * | |
| 1409 | + * @param int $forum_id Optional. Forum id | |
| 1410 | + * @param bool $total_count Optional. To get the total count or normal | |
| 1411 | + * count? | |
| 1412 | + * @param boolean $integer Optional. Whether or not to format the result | |
| 1413 | + * @return int Forum reply count | |
| 1414 | + */ | |
| 1415 | + function bbp_get_forum_reply_count_hidden( $forum_id = 0, $total_count = true, $integer = false ) { | |
| 1416 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1417 | + $meta_key = empty( $total_count ) ? '_bbp_reply_count_hidden' : '_bbp_total_reply_count_hidden'; | |
| 1418 | + $replies = (int) get_post_meta( $forum_id, $meta_key, true ); | |
| 1419 | + $filter = ( true === $integer ) | |
| 1420 | + ? 'bbp_get_forum_reply_count_hidden_int' | |
| 1421 | + : 'bbp_get_forum_reply_count_hidden'; | |
| 1466 | 1422 | |
| 1467 | -/** | |
| 1468 | - * Return total hidden reply count of a forum (hidden includes trashed, | |
| 1469 | - * spammed and pending replies). | |
| 1470 | - * | |
| 1471 | - * @since 2.6.0 bbPress (r6922) | |
| 1472 | - * | |
| 1473 | - * @param int $forum_id Optional. Forum id. | |
| 1474 | - * @param bool $total_count Optional. To get the total count or normal | |
| 1475 | - * count? | |
| 1476 | - * @param boolean $integer Optional. Whether or not to format the result. | |
| 1477 | - * @return int Forum reply count. | |
| 1478 | - */ | |
| 1479 | -function bbp_get_forum_reply_count_hidden( $forum_id = 0, $total_count = true, $integer = false ) { | |
| 1480 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1481 | - $meta_key = empty( $total_count ) ? '_bbp_reply_count_hidden' : '_bbp_total_reply_count_hidden'; | |
| 1482 | - $replies = (int) get_post_meta( $forum_id, $meta_key, true ); | |
| 1483 | - $filter = ( true === $integer ) | |
| 1484 | - ? 'bbp_get_forum_reply_count_hidden_int' | |
| 1485 | - : 'bbp_get_forum_reply_count_hidden'; | |
| 1423 | + return apply_filters( $filter, $replies, $forum_id ); | |
| 1424 | + } | |
| 1486 | 1425 | |
| 1487 | - return apply_filters( $filter, $replies, $forum_id ); | |
| 1488 | -} | |
| 1489 | - | |
| 1490 | 1426 | /** |
| 1491 | - * Output the status of the forum. | |
| 1427 | + * Output the status of the forum | |
| 1492 | 1428 | * |
| 1493 | 1429 | * @since 2.0.0 bbPress (r2667) |
| 1494 | 1430 | * |
| 1495 | - * @param int $forum_id Optional. Forum id. | |
| 1431 | + * @param int $forum_id Optional. Forum id | |
| 1496 | 1432 | */ |
| 1497 | 1433 | function bbp_forum_status( $forum_id = 0 ) { |
| 1498 | 1434 | echo bbp_get_forum_status( $forum_id ); |
| 1499 | 1435 | } |
| 1436 | + /** | |
| 1437 | + * Return the status of the forum | |
| 1438 | + * | |
| 1439 | + * @since 2.0.0 bbPress (r2667) | |
| 1440 | + * | |
| 1441 | + * @param int $forum_id Optional. Forum id | |
| 1442 | + * @return string Status of forum | |
| 1443 | + */ | |
| 1444 | + function bbp_get_forum_status( $forum_id = 0 ) { | |
| 1445 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1446 | + $status = get_post_meta( $forum_id, '_bbp_status', true ); | |
| 1500 | 1447 | |
| 1501 | -/** | |
| 1502 | - * Return the status of the forum. | |
| 1503 | - * | |
| 1504 | - * @since 2.0.0 bbPress (r2667) | |
| 1505 | - * | |
| 1506 | - * @param int $forum_id Optional. Forum id. | |
| 1507 | - * @return string Status of forum. | |
| 1508 | - */ | |
| 1509 | -function bbp_get_forum_status( $forum_id = 0 ) { | |
| 1510 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1511 | - $status = get_post_meta( $forum_id, '_bbp_status', true ); | |
| 1448 | + if ( empty( $status ) ) { | |
| 1449 | + $status = 'open'; | |
| 1450 | + } | |
| 1512 | 1451 | |
| 1513 | - if ( empty( $status ) ) { | |
| 1514 | - $status = 'open'; | |
| 1452 | + // Filter & return | |
| 1453 | + return apply_filters( 'bbp_get_forum_status', $status, $forum_id ); | |
| 1515 | 1454 | } |
| 1516 | 1455 | |
| 1517 | - // Filter & return | |
| 1518 | - return apply_filters( 'bbp_get_forum_status', $status, $forum_id ); | |
| 1519 | -} | |
| 1520 | - | |
| 1521 | 1456 | /** |
| 1522 | - * Output the visibility of the forum. | |
| 1457 | + * Output the visibility of the forum | |
| 1523 | 1458 | * |
| 1524 | 1459 | * @since 2.0.0 bbPress (r2997) |
| 1525 | 1460 | * |
| 1526 | - * @param int $forum_id Optional. Forum id. | |
| 1461 | + * @param int $forum_id Optional. Forum id | |
| 1527 | 1462 | */ |
| 1528 | 1463 | function bbp_forum_visibility( $forum_id = 0 ) { |
| 1529 | 1464 | echo bbp_get_forum_visibility( $forum_id ); |
| 1530 | 1465 | } |
| 1466 | + /** | |
| 1467 | + * Return the visibility of the forum | |
| 1468 | + * | |
| 1469 | + * @since 2.0.0 bbPress (r2997) | |
| 1470 | + * | |
| 1471 | + * @param int $forum_id Optional. Forum id | |
| 1472 | + * @return string Status of forum | |
| 1473 | + */ | |
| 1474 | + function bbp_get_forum_visibility( $forum_id = 0 ) { | |
| 1475 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1476 | + $visibility = get_post_status( $forum_id ); | |
| 1531 | 1477 | |
| 1532 | -/** | |
| 1533 | - * Return the visibility of the forum. | |
| 1534 | - * | |
| 1535 | - * @since 2.0.0 bbPress (r2997) | |
| 1536 | - * | |
| 1537 | - * @param int $forum_id Optional. Forum id. | |
| 1538 | - * @return string Status of forum. | |
| 1539 | - */ | |
| 1540 | -function bbp_get_forum_visibility( $forum_id = 0 ) { | |
| 1541 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1542 | - $visibility = get_post_status( $forum_id ); | |
| 1478 | + // Filter & return | |
| 1479 | + return apply_filters( 'bbp_get_forum_visibility', $visibility, $forum_id ); | |
| 1480 | + } | |
| 1543 | 1481 | |
| 1544 | - // Filter & return | |
| 1545 | - return apply_filters( 'bbp_get_forum_visibility', $visibility, $forum_id ); | |
| 1546 | -} | |
| 1547 | - | |
| 1548 | 1482 | /** |
| 1549 | - * Output the type of the forum. | |
| 1483 | + * Output the type of the forum | |
| 1550 | 1484 | * |
| 1551 | 1485 | * @since 2.1.0 bbPress (r3563) |
| 1552 | 1486 | * |
| 1553 | - * @param int $forum_id Optional. Forum id. | |
| 1487 | + * @param int $forum_id Optional. Forum id | |
| 1554 | 1488 | */ |
| 1555 | 1489 | function bbp_forum_type( $forum_id = 0 ) { |
| 1556 | 1490 | echo bbp_get_forum_type( $forum_id ); |
| 1557 | 1491 | } |
| 1492 | + /** | |
| 1493 | + * Return the type of forum (category/forum/etc...) | |
| 1494 | + * | |
| 1495 | + * @since 2.1.0 bbPress (r3563) | |
| 1496 | + * | |
| 1497 | + * @param int $forum_id Optional. Forum id | |
| 1498 | + * @return bool Whether the forum is a category or not | |
| 1499 | + */ | |
| 1500 | + function bbp_get_forum_type( $forum_id = 0 ) { | |
| 1501 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1502 | + $retval = get_post_meta( $forum_id, '_bbp_forum_type', true ); | |
| 1558 | 1503 | |
| 1559 | -/** | |
| 1560 | - * Return the type of forum (category/forum/etc...) | |
| 1561 | - * | |
| 1562 | - * @since 2.1.0 bbPress (r3563) | |
| 1563 | - * | |
| 1564 | - * @param int $forum_id Optional. Forum id. | |
| 1565 | - * @return bool Whether the forum is a category or not. | |
| 1566 | - */ | |
| 1567 | -function bbp_get_forum_type( $forum_id = 0 ) { | |
| 1568 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1569 | - $retval = get_post_meta( $forum_id, '_bbp_forum_type', true ); | |
| 1504 | + if ( empty( $retval ) ) { | |
| 1505 | + $retval = 'forum'; | |
| 1506 | + } | |
| 1570 | 1507 | |
| 1571 | - if ( empty( $retval ) ) { | |
| 1572 | - $retval = 'forum'; | |
| 1508 | + // Filter & return | |
| 1509 | + return apply_filters( 'bbp_get_forum_type', $retval, $forum_id ); | |
| 1573 | 1510 | } |
| 1574 | 1511 | |
| 1575 | - // Filter & return | |
| 1576 | - return apply_filters( 'bbp_get_forum_type', $retval, $forum_id ); | |
| 1577 | -} | |
| 1578 | - | |
| 1579 | 1512 | /** |
| 1580 | 1513 | * Is the forum a category? |
| 1581 | 1514 | * |
| 1582 | 1515 | * @since 2.0.0 bbPress (r2746) |
| 1583 | 1516 | * |
| 1584 | - * @param int $forum_id Optional. Forum id. | |
| 1585 | - * @return bool Whether the forum is a category or not. | |
| 1517 | + * @param int $forum_id Optional. Forum id | |
| 1518 | + * @return bool Whether the forum is a category or not | |
| 1586 | 1519 | */ |
| 1587 | 1520 | function bbp_is_forum_category( $forum_id = 0 ) { |
| 1588 | 1521 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 1589 | 1522 | $type = bbp_get_forum_type( $forum_id ); |
| @@ -1597,12 +1530,12 @@ | ||
| 1597 | 1530 | * Is the forum open? |
| 1598 | 1531 | * |
| 1599 | 1532 | * @since 2.0.0 bbPress (r2746) |
| 1600 | 1533 | * |
| 1601 | - * @param int $forum_id Optional. Forum id. | |
| 1534 | + * @param int $forum_id Optional. Forum id | |
| 1602 | 1535 | * @param bool $check_ancestors Check if the ancestors are open (only |
| 1603 | - * if they're a category). | |
| 1604 | - * @return bool Whether the forum is open or not. | |
| 1536 | + * if they're a category) | |
| 1537 | + * @return bool Whether the forum is open or not | |
| 1605 | 1538 | */ |
| 1606 | 1539 | function bbp_is_forum_open( $forum_id = 0, $check_ancestors = true ) { |
| 1607 | 1540 | return ! bbp_is_forum_closed( $forum_id, $check_ancestors ); |
| 1608 | 1541 | } |
| @@ -1611,12 +1544,12 @@ | ||
| 1611 | 1544 | * Is the forum closed? |
| 1612 | 1545 | * |
| 1613 | 1546 | * @since 2.0.0 bbPress (r2746) |
| 1614 | 1547 | * |
| 1615 | - * @param int $forum_id Optional. Forum id. | |
| 1548 | + * @param int $forum_id Optional. Forum id | |
| 1616 | 1549 | * @param bool $check_ancestors Check if the ancestors are closed (only |
| 1617 | - * if they're a category). | |
| 1618 | - * @return bool True if closed, false if not. | |
| 1550 | + * if they're a category) | |
| 1551 | + * @return bool True if closed, false if not | |
| 1619 | 1552 | */ |
| 1620 | 1553 | function bbp_is_forum_closed( $forum_id = 0, $check_ancestors = true ) { |
| 1621 | 1554 | |
| 1622 | 1555 | // Get the forum ID |
| @@ -1629,18 +1562,18 @@ | ||
| 1629 | 1562 | return (bool) apply_filters( 'bbp_is_forum_closed', (bool) $retval, $forum_id, $check_ancestors ); |
| 1630 | 1563 | } |
| 1631 | 1564 | |
| 1632 | 1565 | /** |
| 1633 | - * Check if the forum status is a specific one, also maybe checking ancestors. | |
| 1566 | + * Check if the forum status is a specific one, also maybe checking ancestors | |
| 1634 | 1567 | * |
| 1635 | 1568 | * @since 2.6.0 bbPress (r5499) |
| 1636 | 1569 | * |
| 1637 | - * @param bool $status_name The forum status name to check. | |
| 1638 | - * @param bool $check_ancestors Check the forum ancestors. | |
| 1570 | + * @param bool $status_name The forum status name to check | |
| 1571 | + * @param bool $check_ancestors Check the forum ancestors | |
| 1639 | 1572 | * @param string $operator The logical operation to perform. |
| 1640 | 1573 | * 'OR' means only one forum from the tree needs to match; |
| 1641 | 1574 | * 'AND' means all forums must match. The default is 'AND'. |
| 1642 | - * @return bool True if match, false if not. | |
| 1575 | + * @return bool True if match, false if not | |
| 1643 | 1576 | */ |
| 1644 | 1577 | function bbp_is_forum_status( $forum_id, $status_name, $check_ancestors = true, $operator = 'AND' ) { |
| 1645 | 1578 | |
| 1646 | 1579 | // Setup some default variables |
| @@ -1652,9 +1585,9 @@ | ||
| 1652 | 1585 | |
| 1653 | 1586 | // Quickly compare statuses of first forum ID |
| 1654 | 1587 | if ( $status_name === $forum_status ) { |
| 1655 | 1588 | $retval = true; |
| 1656 | - ++$count; | |
| 1589 | + $count++; | |
| 1657 | 1590 | } |
| 1658 | 1591 | |
| 1659 | 1592 | // Let's check the forum's ancestors too |
| 1660 | 1593 | if ( ! empty( $check_ancestors ) ) { |
| @@ -1703,11 +1636,11 @@ | ||
| 1703 | 1636 | * Is the forum public? |
| 1704 | 1637 | * |
| 1705 | 1638 | * @since 2.0.0 bbPress (r2997) |
| 1706 | 1639 | * |
| 1707 | - * @param int $forum_id Optional. Forum id. | |
| 1708 | - * @param bool $check_ancestors Check if the ancestors are public. | |
| 1709 | - * @return bool True if closed, false if not. | |
| 1640 | + * @param int $forum_id Optional. Forum id | |
| 1641 | + * @param bool $check_ancestors Check if the ancestors are public | |
| 1642 | + * @return bool True if closed, false if not | |
| 1710 | 1643 | */ |
| 1711 | 1644 | function bbp_is_forum_public( $forum_id = 0, $check_ancestors = true ) { |
| 1712 | 1645 | |
| 1713 | 1646 | // Get the forum ID |
| @@ -1724,11 +1657,11 @@ | ||
| 1724 | 1657 | * Is the forum private? |
| 1725 | 1658 | * |
| 1726 | 1659 | * @since 2.0.0 bbPress (r2746) |
| 1727 | 1660 | * |
| 1728 | - * @param int $forum_id Optional. Forum id. | |
| 1729 | - * @param bool $check_ancestors Check if the ancestors are private. | |
| 1730 | - * @return bool True if private, false if not. | |
| 1661 | + * @param int $forum_id Optional. Forum id | |
| 1662 | + * @param bool $check_ancestors Check if the ancestors are private | |
| 1663 | + * @return bool True if private, false if not | |
| 1731 | 1664 | */ |
| 1732 | 1665 | function bbp_is_forum_private( $forum_id = 0, $check_ancestors = true ) { |
| 1733 | 1666 | |
| 1734 | 1667 | // Get the forum ID |
| @@ -1745,12 +1678,12 @@ | ||
| 1745 | 1678 | * Is the forum hidden? |
| 1746 | 1679 | * |
| 1747 | 1680 | * @since 2.0.0 bbPress (r2997) |
| 1748 | 1681 | * |
| 1749 | - * @param int $forum_id Optional. Forum id. | |
| 1682 | + * @param int $forum_id Optional. Forum id | |
| 1750 | 1683 | * @param bool $check_ancestors Check if the ancestors are private (only if |
| 1751 | - * they're a category). | |
| 1752 | - * @return bool True if hidden, false if not. | |
| 1684 | + * they're a category) | |
| 1685 | + * @return bool True if hidden, false if not | |
| 1753 | 1686 | */ |
| 1754 | 1687 | function bbp_is_forum_hidden( $forum_id = 0, $check_ancestors = true ) { |
| 1755 | 1688 | |
| 1756 | 1689 | // Get the forum ID |
| @@ -1806,19 +1739,19 @@ | ||
| 1806 | 1739 | return (bool) apply_filters( 'bbp_is_forum_restricted_for_user', $retval, $forum_id, $user_id ); |
| 1807 | 1740 | } |
| 1808 | 1741 | |
| 1809 | 1742 | /** |
| 1810 | - * Check the forum visibility ID. | |
| 1743 | + * Check the forum visibility ID | |
| 1811 | 1744 | * |
| 1812 | 1745 | * @since 2.6.0 bbPress (r5499) |
| 1813 | 1746 | * |
| 1814 | - * @param int $forum_id Optional. Forum id. | |
| 1815 | - * @param bool $status_name The post status name to check. | |
| 1816 | - * @param bool $check_ancestors Check the forum ancestors. | |
| 1747 | + * @param int $forum_id Optional. Forum id | |
| 1748 | + * @param bool $status_name The post status name to check | |
| 1749 | + * @param bool $check_ancestors Check the forum ancestors | |
| 1817 | 1750 | * @param string $operator The logical operation to perform. |
| 1818 | 1751 | * 'OR' means only one forum from the tree needs to match; |
| 1819 | 1752 | * 'AND' means all forums must match. The default is 'AND'. |
| 1820 | - * @return bool True if match, false if not. | |
| 1753 | + * @return bool True if match, false if not | |
| 1821 | 1754 | */ |
| 1822 | 1755 | function bbp_is_forum_visibility( $forum_id, $status_name, $check_ancestors = true, $operator = 'AND' ) { |
| 1823 | 1756 | |
| 1824 | 1757 | // Setup some default variables |
| @@ -1830,9 +1763,9 @@ | ||
| 1830 | 1763 | |
| 1831 | 1764 | // Quickly compare visibility of first forum ID |
| 1832 | 1765 | if ( $status_name === $visibility ) { |
| 1833 | 1766 | $retval = true; |
| 1834 | - ++$count; | |
| 1767 | + $count++; | |
| 1835 | 1768 | } |
| 1836 | 1769 | |
| 1837 | 1770 | // Let's check the forum's ancestors too |
| 1838 | 1771 | if ( ! empty( $check_ancestors ) ) { |
| @@ -1879,63 +1812,61 @@ | ||
| 1879 | 1812 | return (bool) apply_filters( 'bbp_is_forum_visibility', $retval, $count, $forum_id, $status_name, $check_ancestors, $operator ); |
| 1880 | 1813 | } |
| 1881 | 1814 | |
| 1882 | 1815 | /** |
| 1883 | - * Output the author ID of the forum. | |
| 1816 | + * Output the author ID of the forum | |
| 1884 | 1817 | * |
| 1885 | 1818 | * @since 2.1.0 bbPress (r3675) |
| 1886 | 1819 | * |
| 1887 | - * @param int $forum_id Optional. Forum id. | |
| 1820 | + * @param int $forum_id Optional. Forum id | |
| 1888 | 1821 | */ |
| 1889 | 1822 | function bbp_forum_author_id( $forum_id = 0 ) { |
| 1890 | 1823 | echo bbp_get_forum_author_id( $forum_id ); |
| 1891 | 1824 | } |
| 1825 | + /** | |
| 1826 | + * Return the author ID of the forum | |
| 1827 | + * | |
| 1828 | + * @since 2.1.0 bbPress (r3675) | |
| 1829 | + * | |
| 1830 | + * @param int $forum_id Optional. Forum id | |
| 1831 | + * | |
| 1832 | + * @return string Author of forum | |
| 1833 | + */ | |
| 1834 | + function bbp_get_forum_author_id( $forum_id = 0 ) { | |
| 1835 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1836 | + $author_id = get_post_field( 'post_author', $forum_id ); | |
| 1892 | 1837 | |
| 1893 | -/** | |
| 1894 | - * Return the author ID of the forum. | |
| 1895 | - * | |
| 1896 | - * @since 2.1.0 bbPress (r3675) | |
| 1897 | - * | |
| 1898 | - * @param int $forum_id Optional. Forum id. | |
| 1899 | - * | |
| 1900 | - * @return string Author of forum. | |
| 1901 | - */ | |
| 1902 | -function bbp_get_forum_author_id( $forum_id = 0 ) { | |
| 1903 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1904 | - $author_id = get_post_field( 'post_author', $forum_id ); | |
| 1838 | + // Filter & return | |
| 1839 | + return (int) apply_filters( 'bbp_get_forum_author_id', (int) $author_id, $forum_id ); | |
| 1840 | + } | |
| 1905 | 1841 | |
| 1906 | - // Filter & return | |
| 1907 | - return (int) apply_filters( 'bbp_get_forum_author_id', (int) $author_id, $forum_id ); | |
| 1908 | -} | |
| 1909 | - | |
| 1910 | 1842 | /** |
| 1911 | - * Output the author of the forum. | |
| 1843 | + * Output the author of the forum | |
| 1912 | 1844 | * |
| 1913 | 1845 | * @since 2.1.0 bbPress (r3675) |
| 1914 | 1846 | * |
| 1915 | - * @param int $forum_id Optional. Forum id. | |
| 1847 | + * @param int $forum_id Optional. Forum id | |
| 1916 | 1848 | */ |
| 1917 | 1849 | function bbp_forum_author_display_name( $forum_id = 0 ) { |
| 1918 | 1850 | echo bbp_get_forum_author_display_name( $forum_id ); |
| 1919 | 1851 | } |
| 1852 | + /** | |
| 1853 | + * Return the author of the forum | |
| 1854 | + * | |
| 1855 | + * @since 2.1.0 bbPress (r3675) | |
| 1856 | + * | |
| 1857 | + * @param int $forum_id Optional. Forum id | |
| 1858 | + * @return string Author of forum | |
| 1859 | + */ | |
| 1860 | + function bbp_get_forum_author_display_name( $forum_id = 0 ) { | |
| 1861 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1862 | + $author_id = bbp_get_forum_author_id( $forum_id ); | |
| 1863 | + $author = get_the_author_meta( 'display_name', $author_id ); | |
| 1920 | 1864 | |
| 1921 | -/** | |
| 1922 | - * Return the author of the forum. | |
| 1923 | - * | |
| 1924 | - * @since 2.1.0 bbPress (r3675) | |
| 1925 | - * | |
| 1926 | - * @param int $forum_id Optional. Forum id. | |
| 1927 | - * @return string Author of forum. | |
| 1928 | - */ | |
| 1929 | -function bbp_get_forum_author_display_name( $forum_id = 0 ) { | |
| 1930 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1931 | - $author_id = bbp_get_forum_author_id( $forum_id ); | |
| 1932 | - $author = get_the_author_meta( 'display_name', $author_id ); | |
| 1865 | + // Filter & return | |
| 1866 | + return apply_filters( 'bbp_get_forum_author_display_name', $author, $forum_id, $author_id ); | |
| 1867 | + } | |
| 1933 | 1868 | |
| 1934 | - // Filter & return | |
| 1935 | - return apply_filters( 'bbp_get_forum_author_display_name', $author, $forum_id, $author_id ); | |
| 1936 | -} | |
| 1937 | - | |
| 1938 | 1869 | /** |
| 1939 | 1870 | * Replace forum meta details for users that cannot view them. |
| 1940 | 1871 | * |
| 1941 | 1872 | * Forum visibility is inherited from every ancestor. A public descendant of a |
| @@ -2021,88 +1952,87 @@ | ||
| 2021 | 1952 | return apply_filters( 'bbp_suppress_private_author_link', $retval, $author_link, $args ); |
| 2022 | 1953 | } |
| 2023 | 1954 | |
| 2024 | 1955 | /** |
| 2025 | - * Output the row class of a forum. | |
| 1956 | + * Output the row class of a forum | |
| 2026 | 1957 | * |
| 2027 | 1958 | * @since 2.0.0 bbPress (r2667) |
| 2028 | 1959 | * |
| 2029 | 1960 | * @param int $forum_id Optional. Forum ID. |
| 2030 | - * @param array Extra classes you can pass when calling this function. | |
| 1961 | + * @param array Extra classes you can pass when calling this function | |
| 2031 | 1962 | */ |
| 2032 | 1963 | function bbp_forum_class( $forum_id = 0, $classes = array() ) { |
| 2033 | 1964 | echo bbp_get_forum_class( $forum_id, $classes ); |
| 2034 | 1965 | } |
| 1966 | + /** | |
| 1967 | + * Return the row class of a forum | |
| 1968 | + * | |
| 1969 | + * @since 2.0.0 bbPress (r2667) | |
| 1970 | + * | |
| 1971 | + * @param int $forum_id Optional. Forum ID | |
| 1972 | + * @param array Extra classes you can pass when calling this function | |
| 1973 | + * @return string Row class of the forum | |
| 1974 | + */ | |
| 1975 | + function bbp_get_forum_class( $forum_id = 0, $classes = array() ) { | |
| 1976 | + $bbp = bbpress(); | |
| 1977 | + $forum_id = bbp_get_forum_id( $forum_id ); | |
| 1978 | + $parent_id = bbp_get_forum_parent_id( $forum_id ); | |
| 1979 | + $author_id = bbp_get_forum_author_id( $forum_id ); | |
| 1980 | + $status = bbp_get_forum_status( $forum_id ); | |
| 1981 | + $visibility = bbp_get_forum_visibility( $forum_id ); | |
| 1982 | + $classes = array_filter( (array) $classes ); | |
| 1983 | + $count = isset( $bbp->forum_query->current_post ) | |
| 1984 | + ? (int) $bbp->forum_query->current_post | |
| 1985 | + : 1; | |
| 2035 | 1986 | |
| 2036 | -/** | |
| 2037 | - * Return the row class of a forum. | |
| 2038 | - * | |
| 2039 | - * @since 2.0.0 bbPress (r2667) | |
| 2040 | - * | |
| 2041 | - * @param int $forum_id Optional. Forum ID. | |
| 2042 | - * @param array Extra classes you can pass when calling this function. | |
| 2043 | - * @return string Row class of the forum. | |
| 2044 | - */ | |
| 2045 | -function bbp_get_forum_class( $forum_id = 0, $classes = array() ) { | |
| 2046 | - $bbp = bbpress(); | |
| 2047 | - $forum_id = bbp_get_forum_id( $forum_id ); | |
| 2048 | - $parent_id = bbp_get_forum_parent_id( $forum_id ); | |
| 2049 | - $author_id = bbp_get_forum_author_id( $forum_id ); | |
| 2050 | - $status = bbp_get_forum_status( $forum_id ); | |
| 2051 | - $visibility = bbp_get_forum_visibility( $forum_id ); | |
| 2052 | - $classes = array_filter( (array) $classes ); | |
| 2053 | - $count = isset( $bbp->forum_query->current_post ) | |
| 2054 | - ? (int) $bbp->forum_query->current_post | |
| 2055 | - : 1; | |
| 1987 | + // Stripes | |
| 1988 | + $even_odd = ( $count % 2 ) | |
| 1989 | + ? 'even' | |
| 1990 | + : 'odd'; | |
| 2056 | 1991 | |
| 2057 | - // Stripes | |
| 2058 | - $even_odd = ( $count % 2 ) | |
| 2059 | - ? 'even' | |
| 2060 | - : 'odd'; | |
| 1992 | + // User is moderator of forum | |
| 1993 | + $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id ) | |
| 1994 | + ? 'forum-mod' | |
| 1995 | + : ''; | |
| 2061 | 1996 | |
| 2062 | - // User is moderator of forum | |
| 2063 | - $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id ) | |
| 2064 | - ? 'forum-mod' | |
| 2065 | - : ''; | |
| 1997 | + // Is forum a non-postable category? | |
| 1998 | + $category = bbp_is_forum_category( $forum_id ) | |
| 1999 | + ? 'status-category' | |
| 2000 | + : ''; | |
| 2066 | 2001 | |
| 2067 | - // Is forum a non-postable category? | |
| 2068 | - $category = bbp_is_forum_category( $forum_id ) | |
| 2069 | - ? 'status-category' | |
| 2070 | - : ''; | |
| 2002 | + // Forum has children? | |
| 2003 | + $subs = bbp_get_forum_subforum_count( $forum_id ) | |
| 2004 | + ? 'bbp-has-subforums' | |
| 2005 | + : ''; | |
| 2071 | 2006 | |
| 2072 | - // Forum has children? | |
| 2073 | - $subs = bbp_get_forum_subforum_count( $forum_id ) | |
| 2074 | - ? 'bbp-has-subforums' | |
| 2075 | - : ''; | |
| 2007 | + // Forum has parent? | |
| 2008 | + $parent = ! empty( $parent_id ) | |
| 2009 | + ? 'bbp-parent-forum-' . $parent_id | |
| 2010 | + : ''; | |
| 2076 | 2011 | |
| 2077 | - // Forum has parent? | |
| 2078 | - $parent = ! empty( $parent_id ) | |
| 2079 | - ? 'bbp-parent-forum-' . $parent_id | |
| 2080 | - : ''; | |
| 2012 | + // Get forum classes | |
| 2013 | + $forum_classes = array( | |
| 2014 | + 'loop-item-' . $count, | |
| 2015 | + 'bbp-forum-status-' . $status, | |
| 2016 | + 'bbp-forum-visibility-' . $visibility, | |
| 2017 | + $even_odd, | |
| 2018 | + $forum_moderator, | |
| 2019 | + $category, | |
| 2020 | + $subs, | |
| 2021 | + $parent | |
| 2022 | + ); | |
| 2081 | 2023 | |
| 2082 | - // Get forum classes | |
| 2083 | - $forum_classes = array( | |
| 2084 | - 'loop-item-' . $count, | |
| 2085 | - 'bbp-forum-status-' . $status, | |
| 2086 | - 'bbp-forum-visibility-' . $visibility, | |
| 2087 | - $even_odd, | |
| 2088 | - $forum_moderator, | |
| 2089 | - $category, | |
| 2090 | - $subs, | |
| 2091 | - $parent | |
| 2092 | - ); | |
| 2024 | + // Run the topic classes through the post-class filters, which also | |
| 2025 | + // handles the escaping of each individual class. | |
| 2026 | + $post_classes = get_post_class( array_merge( $classes, $forum_classes ), $forum_id ); | |
| 2093 | 2027 | |
| 2094 | - // Run the topic classes through the post-class filters, which also | |
| 2095 | - // handles the escaping of each individual class. | |
| 2096 | - $post_classes = get_post_class( array_merge( $classes, $forum_classes ), $forum_id ); | |
| 2028 | + // Filter | |
| 2029 | + $new_classes = apply_filters( 'bbp_get_forum_class', $post_classes, $forum_id, $classes ); | |
| 2097 | 2030 | |
| 2098 | - // Filter | |
| 2099 | - $new_classes = apply_filters( 'bbp_get_forum_class', $post_classes, $forum_id, $classes ); | |
| 2031 | + // Return | |
| 2032 | + return 'class="' . implode( ' ', $new_classes ) . '"'; | |
| 2033 | + } | |
| 2100 | 2034 | |
| 2101 | - // Return | |
| 2102 | - return 'class="' . implode( ' ', $new_classes ) . '"'; | |
| 2103 | -} | |
| 2104 | - | |
| 2105 | 2035 | /** Single Forum **************************************************************/ |
| 2106 | 2036 | |
| 2107 | 2037 | /** |
| 2108 | 2038 | * Output a fancy description of the current forum, including total topics, |
| @@ -2109,27 +2039,26 @@ | ||
| 2109 | 2039 | * total replies, and last activity. |
| 2110 | 2040 | * |
| 2111 | 2041 | * @since 2.0.0 bbPress (r2860) |
| 2112 | 2042 | * |
| 2113 | - * @param array $args Arguments passed to alter output. | |
| 2043 | + * @param array $args Arguments passed to alter output | |
| 2114 | 2044 | */ |
| 2115 | 2045 | function bbp_single_forum_description( $args = array() ) { |
| 2116 | 2046 | echo bbp_get_single_forum_description( $args ); |
| 2117 | 2047 | } |
| 2118 | - | |
| 2119 | -/** | |
| 2120 | - * Return a fancy description of the current forum, including total | |
| 2121 | - * topics, total replies, and last activity. | |
| 2122 | - * | |
| 2123 | - * @since 2.0.0 bbPress (r2860) | |
| 2124 | - * | |
| 2125 | - * @param array $args This function supports these arguments: | |
| 2126 | - * - forum_id: Forum id | |
| 2127 | - * - before: Before the text | |
| 2128 | - * - after: After the text | |
| 2129 | - * - size: Size of the avatar | |
| 2130 | - * @return string Filtered forum description. | |
| 2131 | - */ | |
| 2048 | + /** | |
| 2049 | + * Return a fancy description of the current forum, including total | |
| 2050 | + * topics, total replies, and last activity. | |
| 2051 | + * | |
| 2052 | + * @since 2.0.0 bbPress (r2860) | |
| 2053 | + * | |
| 2054 | + * @param array $args This function supports these arguments: | |
| 2055 | + * - forum_id: Forum id | |
| 2056 | + * - before: Before the text | |
| 2057 | + * - after: After the text | |
| 2058 | + * - size: Size of the avatar | |
| 2059 | + * @return string Filtered forum description | |
| 2060 | + */ | |
| 2132 | 2061 | function bbp_get_single_forum_description( $args = array() ) { |
| 2133 | 2062 | |
| 2134 | 2063 | // Parse arguments against default values |
| 2135 | 2064 | $r = bbp_parse_args( |
| @@ -2233,9 +2162,9 @@ | ||
| 2233 | 2162 | |
| 2234 | 2163 | /** Forms *********************************************************************/ |
| 2235 | 2164 | |
| 2236 | 2165 | /** |
| 2237 | - * Output the value of forum title field. | |
| 2166 | + * Output the value of forum title field | |
| 2238 | 2167 | * |
| 2239 | 2168 | * @since 2.1.0 bbPress (r3551) |
| 2240 | 2169 | */ |
| 2241 | 2170 | function bbp_form_forum_title() { |
| @@ -2240,37 +2169,36 @@ | ||
| 2240 | 2169 | */ |
| 2241 | 2170 | function bbp_form_forum_title() { |
| 2242 | 2171 | echo bbp_get_form_forum_title(); |
| 2243 | 2172 | } |
| 2173 | + /** | |
| 2174 | + * Return the value of forum title field | |
| 2175 | + * | |
| 2176 | + * @since 2.1.0 bbPress (r3551) | |
| 2177 | + * | |
| 2178 | + * @return string Value of forum title field | |
| 2179 | + */ | |
| 2180 | + function bbp_get_form_forum_title() { | |
| 2244 | 2181 | |
| 2245 | -/** | |
| 2246 | - * Return the value of forum title field. | |
| 2247 | - * | |
| 2248 | - * @since 2.1.0 bbPress (r3551) | |
| 2249 | - * | |
| 2250 | - * @return string Value of forum title field. | |
| 2251 | - */ | |
| 2252 | -function bbp_get_form_forum_title() { | |
| 2182 | + // Get _POST data | |
| 2183 | + if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_title'] ) ) { | |
| 2184 | + $forum_title = wp_unslash( $_POST['bbp_forum_title'] ); | |
| 2253 | 2185 | |
| 2254 | - // Get _POST data | |
| 2255 | - if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_title'] ) ) { | |
| 2256 | - $forum_title = wp_unslash( $_POST['bbp_forum_title'] ); | |
| 2186 | + // Get edit data | |
| 2187 | + } elseif ( bbp_is_forum_edit() ) { | |
| 2188 | + $forum_title = bbp_get_global_post_field( 'post_title', 'raw' ); | |
| 2257 | 2189 | |
| 2258 | - // Get edit data | |
| 2259 | - } elseif ( bbp_is_forum_edit() ) { | |
| 2260 | - $forum_title = bbp_get_global_post_field( 'post_title', 'raw' ); | |
| 2190 | + // No data | |
| 2191 | + } else { | |
| 2192 | + $forum_title = ''; | |
| 2193 | + } | |
| 2261 | 2194 | |
| 2262 | - // No data | |
| 2263 | - } else { | |
| 2264 | - $forum_title = ''; | |
| 2195 | + // Filter & return | |
| 2196 | + return apply_filters( 'bbp_get_form_forum_title', $forum_title ); | |
| 2265 | 2197 | } |
| 2266 | 2198 | |
| 2267 | - // Filter & return | |
| 2268 | - return apply_filters( 'bbp_get_form_forum_title', $forum_title ); | |
| 2269 | -} | |
| 2270 | - | |
| 2271 | 2199 | /** |
| 2272 | - * Output the value of forum content field. | |
| 2200 | + * Output the value of forum content field | |
| 2273 | 2201 | * |
| 2274 | 2202 | * @since 2.1.0 bbPress (r3551) |
| 2275 | 2203 | */ |
| 2276 | 2204 | function bbp_form_forum_content() { |
| @@ -2275,37 +2203,36 @@ | ||
| 2275 | 2203 | */ |
| 2276 | 2204 | function bbp_form_forum_content() { |
| 2277 | 2205 | echo bbp_get_form_forum_content(); |
| 2278 | 2206 | } |
| 2207 | + /** | |
| 2208 | + * Return the value of forum content field | |
| 2209 | + * | |
| 2210 | + * @since 2.1.0 bbPress (r3551) | |
| 2211 | + * | |
| 2212 | + * @return string Value of forum content field | |
| 2213 | + */ | |
| 2214 | + function bbp_get_form_forum_content() { | |
| 2279 | 2215 | |
| 2280 | -/** | |
| 2281 | - * Return the value of forum content field. | |
| 2282 | - * | |
| 2283 | - * @since 2.1.0 bbPress (r3551) | |
| 2284 | - * | |
| 2285 | - * @return string Value of forum content field. | |
| 2286 | - */ | |
| 2287 | -function bbp_get_form_forum_content() { | |
| 2216 | + // Get _POST data | |
| 2217 | + if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_content'] ) ) { | |
| 2218 | + $forum_content = wp_unslash( $_POST['bbp_forum_content'] ); | |
| 2288 | 2219 | |
| 2289 | - // Get _POST data | |
| 2290 | - if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_content'] ) ) { | |
| 2291 | - $forum_content = wp_unslash( $_POST['bbp_forum_content'] ); | |
| 2220 | + // Get edit data | |
| 2221 | + } elseif ( bbp_is_forum_edit() ) { | |
| 2222 | + $forum_content = bbp_get_global_post_field( 'post_content', 'raw' ); | |
| 2292 | 2223 | |
| 2293 | - // Get edit data | |
| 2294 | - } elseif ( bbp_is_forum_edit() ) { | |
| 2295 | - $forum_content = bbp_get_global_post_field( 'post_content', 'raw' ); | |
| 2224 | + // No data | |
| 2225 | + } else { | |
| 2226 | + $forum_content = ''; | |
| 2227 | + } | |
| 2296 | 2228 | |
| 2297 | - // No data | |
| 2298 | - } else { | |
| 2299 | - $forum_content = ''; | |
| 2229 | + // Filter & return | |
| 2230 | + return apply_filters( 'bbp_get_form_forum_content', $forum_content ); | |
| 2300 | 2231 | } |
| 2301 | 2232 | |
| 2302 | - // Filter & return | |
| 2303 | - return apply_filters( 'bbp_get_form_forum_content', $forum_content ); | |
| 2304 | -} | |
| 2305 | - | |
| 2306 | 2233 | /** |
| 2307 | - * Output value of forum moderators field. | |
| 2234 | + * Output value of forum moderators field | |
| 2308 | 2235 | * |
| 2309 | 2236 | * @since 2.6.0 bbPress (r5837) |
| 2310 | 2237 | */ |
| 2311 | 2238 | function bbp_form_forum_moderators() { |
| @@ -2310,53 +2237,52 @@ | ||
| 2310 | 2237 | */ |
| 2311 | 2238 | function bbp_form_forum_moderators() { |
| 2312 | 2239 | echo bbp_get_form_forum_moderators(); |
| 2313 | 2240 | } |
| 2241 | + /** | |
| 2242 | + * Return value of forum moderators field | |
| 2243 | + * | |
| 2244 | + * @since 2.6.0 bbPress (r5837) | |
| 2245 | + * | |
| 2246 | + * @return string Value of forum mods field | |
| 2247 | + */ | |
| 2248 | + function bbp_get_form_forum_moderators() { | |
| 2314 | 2249 | |
| 2315 | -/** | |
| 2316 | - * Return value of forum moderators field. | |
| 2317 | - * | |
| 2318 | - * @since 2.6.0 bbPress (r5837) | |
| 2319 | - * | |
| 2320 | - * @return string Value of forum mods field. | |
| 2321 | - */ | |
| 2322 | -function bbp_get_form_forum_moderators() { | |
| 2250 | + // Default return value | |
| 2251 | + $forum_mods = ''; | |
| 2323 | 2252 | |
| 2324 | - // Default return value | |
| 2325 | - $forum_mods = ''; | |
| 2253 | + // Get _POST data | |
| 2254 | + if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_moderators'] ) ) { | |
| 2255 | + $forum_mods = wp_unslash( $_POST['bbp_moderators'] ); | |
| 2326 | 2256 | |
| 2327 | - // Get _POST data | |
| 2328 | - if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_moderators'] ) ) { | |
| 2329 | - $forum_mods = wp_unslash( $_POST['bbp_moderators'] ); | |
| 2257 | + // Get edit data | |
| 2258 | + } elseif ( bbp_is_single_forum() || bbp_is_forum_edit() ) { | |
| 2330 | 2259 | |
| 2331 | - // Get edit data | |
| 2332 | - } elseif ( bbp_is_single_forum() || bbp_is_forum_edit() ) { | |
| 2260 | + // Get the forum ID | |
| 2261 | + $forum_id = bbp_get_forum_id( get_the_ID() ); | |
| 2333 | 2262 | |
| 2334 | - // Get the forum ID | |
| 2335 | - $forum_id = bbp_get_forum_id( get_the_ID() ); | |
| 2263 | + // Forum exists | |
| 2264 | + if ( ! empty( $forum_id ) ) { | |
| 2336 | 2265 | |
| 2337 | - // Forum exists | |
| 2338 | - if ( ! empty( $forum_id ) ) { | |
| 2266 | + // Get moderator IDs | |
| 2267 | + $user_ids = bbp_get_moderator_ids( $forum_id ); | |
| 2268 | + if ( ! empty( $user_ids ) ) { | |
| 2269 | + $user_nicenames = bbp_get_user_nicenames_from_ids( $user_ids ); | |
| 2339 | 2270 | |
| 2340 | - // Get moderator IDs | |
| 2341 | - $user_ids = bbp_get_moderator_ids( $forum_id ); | |
| 2342 | - if ( ! empty( $user_ids ) ) { | |
| 2343 | - $user_nicenames = bbp_get_user_nicenames_from_ids( $user_ids ); | |
| 2344 | - | |
| 2345 | - // Comma separate user nicenames | |
| 2346 | - if ( ! empty( $user_nicenames ) ) { | |
| 2347 | - $forum_mods = implode( ', ', wp_list_pluck( $user_nicenames, 'user_nicename' ) ); | |
| 2271 | + // Comma separate user nicenames | |
| 2272 | + if ( ! empty( $user_nicenames ) ) { | |
| 2273 | + $forum_mods = implode( ', ', wp_list_pluck( $user_nicenames, 'user_nicename' ) ); | |
| 2274 | + } | |
| 2348 | 2275 | } |
| 2349 | 2276 | } |
| 2350 | 2277 | } |
| 2278 | + | |
| 2279 | + // Filter & return | |
| 2280 | + return apply_filters( 'bbp_get_form_forum_moderators', $forum_mods ); | |
| 2351 | 2281 | } |
| 2352 | 2282 | |
| 2353 | - // Filter & return | |
| 2354 | - return apply_filters( 'bbp_get_form_forum_moderators', $forum_mods ); | |
| 2355 | -} | |
| 2356 | - | |
| 2357 | 2283 | /** |
| 2358 | - * Output value of forum parent. | |
| 2284 | + * Output value of forum parent | |
| 2359 | 2285 | * |
| 2360 | 2286 | * @since 2.1.0 bbPress (r3551) |
| 2361 | 2287 | */ |
| 2362 | 2288 | function bbp_form_forum_parent() { |
| @@ -2361,37 +2287,36 @@ | ||
| 2361 | 2287 | */ |
| 2362 | 2288 | function bbp_form_forum_parent() { |
| 2363 | 2289 | echo bbp_get_form_forum_parent(); |
| 2364 | 2290 | } |
| 2291 | + /** | |
| 2292 | + * Return value of forum parent | |
| 2293 | + * | |
| 2294 | + * @since 2.1.0 bbPress (r3551) | |
| 2295 | + * | |
| 2296 | + * @return string Value of topic content field | |
| 2297 | + */ | |
| 2298 | + function bbp_get_form_forum_parent() { | |
| 2365 | 2299 | |
| 2366 | -/** | |
| 2367 | - * Return value of forum parent. | |
| 2368 | - * | |
| 2369 | - * @since 2.1.0 bbPress (r3551) | |
| 2370 | - * | |
| 2371 | - * @return string Value of topic content field. | |
| 2372 | - */ | |
| 2373 | -function bbp_get_form_forum_parent() { | |
| 2300 | + // Get _POST data | |
| 2301 | + if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_id'] ) ) { | |
| 2302 | + $forum_parent = (int) $_POST['bbp_forum_id']; | |
| 2374 | 2303 | |
| 2375 | - // Get _POST data | |
| 2376 | - if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_id'] ) ) { | |
| 2377 | - $forum_parent = (int) $_POST['bbp_forum_id']; | |
| 2304 | + // Get edit data | |
| 2305 | + } elseif ( bbp_is_forum_edit() ) { | |
| 2306 | + $forum_parent = bbp_get_forum_parent_id(); | |
| 2378 | 2307 | |
| 2379 | - // Get edit data | |
| 2380 | - } elseif ( bbp_is_forum_edit() ) { | |
| 2381 | - $forum_parent = bbp_get_forum_parent_id(); | |
| 2308 | + // No data | |
| 2309 | + } else { | |
| 2310 | + $forum_parent = 0; | |
| 2311 | + } | |
| 2382 | 2312 | |
| 2383 | - // No data | |
| 2384 | - } else { | |
| 2385 | - $forum_parent = 0; | |
| 2313 | + // Filter & return | |
| 2314 | + return apply_filters( 'bbp_get_form_forum_parent', $forum_parent ); | |
| 2386 | 2315 | } |
| 2387 | 2316 | |
| 2388 | - // Filter & return | |
| 2389 | - return apply_filters( 'bbp_get_form_forum_parent', $forum_parent ); | |
| 2390 | -} | |
| 2391 | - | |
| 2392 | 2317 | /** |
| 2393 | - * Output value of forum type. | |
| 2318 | + * Output value of forum type | |
| 2394 | 2319 | * |
| 2395 | 2320 | * @since 2.1.0 bbPress (r3563) |
| 2396 | 2321 | */ |
| 2397 | 2322 | function bbp_form_forum_type() { |
| @@ -2396,37 +2321,36 @@ | ||
| 2396 | 2321 | */ |
| 2397 | 2322 | function bbp_form_forum_type() { |
| 2398 | 2323 | echo bbp_get_form_forum_type(); |
| 2399 | 2324 | } |
| 2325 | + /** | |
| 2326 | + * Return value of forum type | |
| 2327 | + * | |
| 2328 | + * @since 2.1.0 bbPress (r3563) | |
| 2329 | + * | |
| 2330 | + * @return string Value of topic content field | |
| 2331 | + */ | |
| 2332 | + function bbp_get_form_forum_type() { | |
| 2400 | 2333 | |
| 2401 | -/** | |
| 2402 | - * Return value of forum type. | |
| 2403 | - * | |
| 2404 | - * @since 2.1.0 bbPress (r3563) | |
| 2405 | - * | |
| 2406 | - * @return string Value of topic content field. | |
| 2407 | - */ | |
| 2408 | -function bbp_get_form_forum_type() { | |
| 2334 | + // Get _POST data | |
| 2335 | + if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_type'] ) ) { | |
| 2336 | + $forum_type = sanitize_key( $_POST['bbp_forum_type'] ); | |
| 2409 | 2337 | |
| 2410 | - // Get _POST data | |
| 2411 | - if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_type'] ) ) { | |
| 2412 | - $forum_type = sanitize_key( $_POST['bbp_forum_type'] ); | |
| 2338 | + // Get edit data | |
| 2339 | + } elseif ( bbp_is_forum_edit() ) { | |
| 2340 | + $forum_type = bbp_get_forum_type(); | |
| 2413 | 2341 | |
| 2414 | - // Get edit data | |
| 2415 | - } elseif ( bbp_is_forum_edit() ) { | |
| 2416 | - $forum_type = bbp_get_forum_type(); | |
| 2342 | + // No data | |
| 2343 | + } else { | |
| 2344 | + $forum_type = 'forum'; | |
| 2345 | + } | |
| 2417 | 2346 | |
| 2418 | - // No data | |
| 2419 | - } else { | |
| 2420 | - $forum_type = 'forum'; | |
| 2347 | + // Filter & return | |
| 2348 | + return apply_filters( 'bbp_get_form_forum_type', $forum_type ); | |
| 2421 | 2349 | } |
| 2422 | 2350 | |
| 2423 | - // Filter & return | |
| 2424 | - return apply_filters( 'bbp_get_form_forum_type', $forum_type ); | |
| 2425 | -} | |
| 2426 | - | |
| 2427 | 2351 | /** |
| 2428 | - * Output value of forum visibility. | |
| 2352 | + * Output value of forum visibility | |
| 2429 | 2353 | * |
| 2430 | 2354 | * @since 2.1.0 bbPress (r3563) |
| 2431 | 2355 | */ |
| 2432 | 2356 | function bbp_form_forum_visibility() { |
| @@ -2431,37 +2355,36 @@ | ||
| 2431 | 2355 | */ |
| 2432 | 2356 | function bbp_form_forum_visibility() { |
| 2433 | 2357 | echo bbp_get_form_forum_visibility(); |
| 2434 | 2358 | } |
| 2359 | + /** | |
| 2360 | + * Return value of forum visibility | |
| 2361 | + * | |
| 2362 | + * @since 2.1.0 bbPress (r3563) | |
| 2363 | + * | |
| 2364 | + * @return string Value of topic content field | |
| 2365 | + */ | |
| 2366 | + function bbp_get_form_forum_visibility() { | |
| 2435 | 2367 | |
| 2436 | -/** | |
| 2437 | - * Return value of forum visibility. | |
| 2438 | - * | |
| 2439 | - * @since 2.1.0 bbPress (r3563) | |
| 2440 | - * | |
| 2441 | - * @return string Value of topic content field. | |
| 2442 | - */ | |
| 2443 | -function bbp_get_form_forum_visibility() { | |
| 2368 | + // Get _POST data | |
| 2369 | + if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_visibility'] ) ) { | |
| 2370 | + $forum_visibility = sanitize_key( $_POST['bbp_forum_visibility'] ); | |
| 2444 | 2371 | |
| 2445 | - // Get _POST data | |
| 2446 | - if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_visibility'] ) ) { | |
| 2447 | - $forum_visibility = sanitize_key( $_POST['bbp_forum_visibility'] ); | |
| 2372 | + // Get edit data | |
| 2373 | + } elseif ( bbp_is_forum_edit() ) { | |
| 2374 | + $forum_visibility = bbp_get_forum_visibility(); | |
| 2448 | 2375 | |
| 2449 | - // Get edit data | |
| 2450 | - } elseif ( bbp_is_forum_edit() ) { | |
| 2451 | - $forum_visibility = bbp_get_forum_visibility(); | |
| 2376 | + // No data | |
| 2377 | + } else { | |
| 2378 | + $forum_visibility = bbpress()->public_status_id; | |
| 2379 | + } | |
| 2452 | 2380 | |
| 2453 | - // No data | |
| 2454 | - } else { | |
| 2455 | - $forum_visibility = bbpress()->public_status_id; | |
| 2381 | + // Filter & return | |
| 2382 | + return apply_filters( 'bbp_get_form_forum_visibility', $forum_visibility ); | |
| 2456 | 2383 | } |
| 2457 | 2384 | |
| 2458 | - // Filter & return | |
| 2459 | - return apply_filters( 'bbp_get_form_forum_visibility', $forum_visibility ); | |
| 2460 | -} | |
| 2461 | - | |
| 2462 | 2385 | /** |
| 2463 | - * Output checked value of forum subscription. | |
| 2386 | + * Output checked value of forum subscription | |
| 2464 | 2387 | * |
| 2465 | 2388 | * @since 2.5.0 bbPress (r5156) |
| 2466 | 2389 | */ |
| 2467 | 2390 | function bbp_form_forum_subscribed() { |
| @@ -2466,46 +2389,45 @@ | ||
| 2466 | 2389 | */ |
| 2467 | 2390 | function bbp_form_forum_subscribed() { |
| 2468 | 2391 | echo bbp_get_form_forum_subscribed(); |
| 2469 | 2392 | } |
| 2393 | + /** | |
| 2394 | + * Return checked value of forum subscription | |
| 2395 | + * | |
| 2396 | + * @since 2.5.0 bbPress (r5156) | |
| 2397 | + * | |
| 2398 | + * @return string Checked value of forum subscription | |
| 2399 | + */ | |
| 2400 | + function bbp_get_form_forum_subscribed() { | |
| 2470 | 2401 | |
| 2471 | -/** | |
| 2472 | - * Return checked value of forum subscription. | |
| 2473 | - * | |
| 2474 | - * @since 2.5.0 bbPress (r5156) | |
| 2475 | - * | |
| 2476 | - * @return string Checked value of forum subscription. | |
| 2477 | - */ | |
| 2478 | -function bbp_get_form_forum_subscribed() { | |
| 2402 | + // Default value | |
| 2403 | + $forum_subscribed = false; | |
| 2479 | 2404 | |
| 2480 | - // Default value | |
| 2481 | - $forum_subscribed = false; | |
| 2405 | + // Get _POST data | |
| 2406 | + if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_subscription'] ) ) { | |
| 2407 | + $forum_subscribed = (bool) $_POST['bbp_forum_subscription']; | |
| 2482 | 2408 | |
| 2483 | - // Get _POST data | |
| 2484 | - if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_subscription'] ) ) { | |
| 2485 | - $forum_subscribed = (bool) $_POST['bbp_forum_subscription']; | |
| 2409 | + // Get edit data | |
| 2410 | + } elseif ( bbp_is_forum_edit() || bbp_is_reply_edit() ) { | |
| 2411 | + $post_author = (int) bbp_get_global_post_field( 'post_author', 'raw' ); | |
| 2412 | + $forum_subscribed = bbp_is_user_subscribed( $post_author, bbp_get_forum_id() ); | |
| 2486 | 2413 | |
| 2487 | - // Get edit data | |
| 2488 | - } elseif ( bbp_is_forum_edit() || bbp_is_reply_edit() ) { | |
| 2489 | - $post_author = (int) bbp_get_global_post_field( 'post_author', 'raw' ); | |
| 2490 | - $forum_subscribed = bbp_is_user_subscribed( $post_author, bbp_get_forum_id() ); | |
| 2414 | + // Get current status | |
| 2415 | + } elseif ( bbp_is_single_forum() ) { | |
| 2416 | + $forum_subscribed = bbp_is_user_subscribed( bbp_get_current_user_id(), bbp_get_forum_id() ); | |
| 2417 | + } | |
| 2491 | 2418 | |
| 2492 | - // Get current status | |
| 2493 | - } elseif ( bbp_is_single_forum() ) { | |
| 2494 | - $forum_subscribed = bbp_is_user_subscribed( bbp_get_current_user_id(), bbp_get_forum_id() ); | |
| 2419 | + // Get checked output | |
| 2420 | + $checked = checked( $forum_subscribed, true, false ); | |
| 2421 | + | |
| 2422 | + // Filter & return | |
| 2423 | + return apply_filters( 'bbp_get_form_forum_subscribed', $checked, $forum_subscribed ); | |
| 2495 | 2424 | } |
| 2496 | 2425 | |
| 2497 | - // Get checked output | |
| 2498 | - $checked = checked( $forum_subscribed, true, false ); | |
| 2499 | - | |
| 2500 | - // Filter & return | |
| 2501 | - return apply_filters( 'bbp_get_form_forum_subscribed', $checked, $forum_subscribed ); | |
| 2502 | -} | |
| 2503 | - | |
| 2504 | 2426 | /** Form Dropdowns ************************************************************/ |
| 2505 | 2427 | |
| 2506 | 2428 | /** |
| 2507 | - * Output value forum type dropdown. | |
| 2429 | + * Output value forum type dropdown | |
| 2508 | 2430 | * |
| 2509 | 2431 | * @since 2.1.0 bbPress (r3563) |
| 2510 | 2432 | * |
| 2511 | 2433 | * @param $args This function supports these arguments: |
| @@ -2516,21 +2438,20 @@ | ||
| 2516 | 2438 | */ |
| 2517 | 2439 | function bbp_form_forum_type_dropdown( $args = array() ) { |
| 2518 | 2440 | echo bbp_get_form_forum_type_dropdown( $args ); |
| 2519 | 2441 | } |
| 2520 | - | |
| 2521 | -/** | |
| 2522 | - * Return the forum type dropdown. | |
| 2523 | - * | |
| 2524 | - * @since 2.1.0 bbPress (r3563) | |
| 2525 | - * | |
| 2526 | - * @param $args This function supports these arguments: | |
| 2527 | - * - select_id: Select id. Defaults to bbp_forum_type | |
| 2528 | - * - tab: Deprecated. Tabindex | |
| 2529 | - * - forum_id: Forum id | |
| 2530 | - * - selected: Override the selected option | |
| 2531 | - * @return string HTML select list for selecting forum type | |
| 2532 | - */ | |
| 2442 | + /** | |
| 2443 | + * Return the forum type dropdown | |
| 2444 | + * | |
| 2445 | + * @since 2.1.0 bbPress (r3563) | |
| 2446 | + * | |
| 2447 | + * @param $args This function supports these arguments: | |
| 2448 | + * - select_id: Select id. Defaults to bbp_forum_type | |
| 2449 | + * - tab: Deprecated. Tabindex | |
| 2450 | + * - forum_id: Forum id | |
| 2451 | + * - selected: Override the selected option | |
| 2452 | + * @return string HTML select list for selecting forum type | |
| 2453 | + */ | |
| 2533 | 2454 | function bbp_get_form_forum_type_dropdown( $args = array() ) { |
| 2534 | 2455 | |
| 2535 | 2456 | // Backpat for handling passing of a forum ID as integer |
| 2536 | 2457 | if ( is_int( $args ) ) { |
| @@ -2590,9 +2511,9 @@ | ||
| 2590 | 2511 | return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args ); |
| 2591 | 2512 | } |
| 2592 | 2513 | |
| 2593 | 2514 | /** |
| 2594 | - * Output value forum status dropdown. | |
| 2515 | + * Output value forum status dropdown | |
| 2595 | 2516 | * |
| 2596 | 2517 | * @since 2.1.0 bbPress (r3563) |
| 2597 | 2518 | * |
| 2598 | 2519 | * @param $args This function supports these arguments: |
| @@ -2603,21 +2524,20 @@ | ||
| 2603 | 2524 | */ |
| 2604 | 2525 | function bbp_form_forum_status_dropdown( $args = array() ) { |
| 2605 | 2526 | echo bbp_get_form_forum_status_dropdown( $args ); |
| 2606 | 2527 | } |
| 2607 | - | |
| 2608 | -/** | |
| 2609 | - * Return the forum status dropdown. | |
| 2610 | - * | |
| 2611 | - * @since 2.1.0 bbPress (r3563) | |
| 2612 | - * | |
| 2613 | - * @param $args This function supports these arguments: | |
| 2614 | - * - select_id: Select id. Defaults to bbp_forum_status | |
| 2615 | - * - tab: Deprecated. Tabindex | |
| 2616 | - * - forum_id: Forum id | |
| 2617 | - * - selected: Override the selected option | |
| 2618 | - * @return string HTML select list for selecting forum status. | |
| 2619 | - */ | |
| 2528 | + /** | |
| 2529 | + * Return the forum status dropdown | |
| 2530 | + * | |
| 2531 | + * @since 2.1.0 bbPress (r3563) | |
| 2532 | + * | |
| 2533 | + * @param $args This function supports these arguments: | |
| 2534 | + * - select_id: Select id. Defaults to bbp_forum_status | |
| 2535 | + * - tab: Deprecated. Tabindex | |
| 2536 | + * - forum_id: Forum id | |
| 2537 | + * - selected: Override the selected option | |
| 2538 | + * @return string HTML select list for selecting forum status | |
| 2539 | + */ | |
| 2620 | 2540 | function bbp_get_form_forum_status_dropdown( $args = array() ) { |
| 2621 | 2541 | |
| 2622 | 2542 | // Backpat for handling passing of a forum ID |
| 2623 | 2543 | if ( is_int( $args ) ) { |
| @@ -2677,9 +2597,9 @@ | ||
| 2677 | 2597 | return apply_filters( 'bbp_get_form_forum_status_dropdown', ob_get_clean(), $r, $args ); |
| 2678 | 2598 | } |
| 2679 | 2599 | |
| 2680 | 2600 | /** |
| 2681 | - * Output value forum visibility dropdown. | |
| 2601 | + * Output value forum visibility dropdown | |
| 2682 | 2602 | * |
| 2683 | 2603 | * @since 2.1.0 bbPress (r3563) |
| 2684 | 2604 | * |
| 2685 | 2605 | * @param $args This function supports these arguments: |
| @@ -2690,21 +2610,20 @@ | ||
| 2690 | 2610 | */ |
| 2691 | 2611 | function bbp_form_forum_visibility_dropdown( $args = array() ) { |
| 2692 | 2612 | echo bbp_get_form_forum_visibility_dropdown( $args ); |
| 2693 | 2613 | } |
| 2694 | - | |
| 2695 | -/** | |
| 2696 | - * Return the forum visibility dropdown. | |
| 2697 | - * | |
| 2698 | - * @since 2.1.0 bbPress (r3563) | |
| 2699 | - * | |
| 2700 | - * @param $args This function supports these arguments: | |
| 2701 | - * - select_id: Select id. Defaults to bbp_forum_visibility | |
| 2702 | - * - tab: Deprecated. Tabindex | |
| 2703 | - * - forum_id: Forum id | |
| 2704 | - * - selected: Override the selected option | |
| 2705 | - * @return string HTML select list for selecting forum visibility. | |
| 2706 | - */ | |
| 2614 | + /** | |
| 2615 | + * Return the forum visibility dropdown | |
| 2616 | + * | |
| 2617 | + * @since 2.1.0 bbPress (r3563) | |
| 2618 | + * | |
| 2619 | + * @param $args This function supports these arguments: | |
| 2620 | + * - select_id: Select id. Defaults to bbp_forum_visibility | |
| 2621 | + * - tab: Deprecated. Tabindex | |
| 2622 | + * - forum_id: Forum id | |
| 2623 | + * - selected: Override the selected option | |
| 2624 | + * @return string HTML select list for selecting forum visibility | |
| 2625 | + */ | |
| 2707 | 2626 | function bbp_get_form_forum_visibility_dropdown( $args = array() ) { |
| 2708 | 2627 | |
| 2709 | 2628 | // Backpat for handling passing of a forum ID |
| 2710 | 2629 | if ( is_int( $args ) ) { |
| @@ -2773,9 +2692,9 @@ | ||
| 2773 | 2692 | * @see bbp_forum_form_fields() |
| 2774 | 2693 | * |
| 2775 | 2694 | * @since 2.6.0 bbPress (r5558) |
| 2776 | 2695 | * |
| 2777 | - * @return boolean True if is a post request with valid nonce. | |
| 2696 | + * @return boolean True if is a post request with valid nonce | |
| 2778 | 2697 | */ |
| 2779 | 2698 | function bbp_is_forum_form_post_request() { |
| 2780 | 2699 | |
| 2781 | 2700 | // Bail if not a post request |
| @@ -2798,9 +2717,9 @@ | ||
| 2798 | 2717 | |
| 2799 | 2718 | /** Feeds *********************************************************************/ |
| 2800 | 2719 | |
| 2801 | 2720 | /** |
| 2802 | - * Output the link for the forum feed. | |
| 2721 | + * Output the link for the forum feed | |
| 2803 | 2722 | * |
| 2804 | 2723 | * @since 2.0.0 bbPress (r3172) |
| 2805 | 2724 | * |
| 2806 | 2725 | * @param int $forum_id Optional. Forum ID. |
| @@ -2807,18 +2726,17 @@ | ||
| 2807 | 2726 | */ |
| 2808 | 2727 | function bbp_forum_topics_feed_link( $forum_id = 0 ) { |
| 2809 | 2728 | echo bbp_get_forum_topics_feed_link( $forum_id ); |
| 2810 | 2729 | } |
| 2811 | - | |
| 2812 | -/** | |
| 2813 | - * Retrieve the link for the forum feed. | |
| 2814 | - * | |
| 2815 | - * @since 2.0.0 bbPress (r3172) | |
| 2816 | - * | |
| 2817 | - * @param int $forum_id Optional. Forum ID. | |
| 2818 | - * | |
| 2819 | - * @return string | |
| 2820 | - */ | |
| 2730 | + /** | |
| 2731 | + * Retrieve the link for the forum feed | |
| 2732 | + * | |
| 2733 | + * @since 2.0.0 bbPress (r3172) | |
| 2734 | + * | |
| 2735 | + * @param int $forum_id Optional. Forum ID. | |
| 2736 | + * | |
| 2737 | + * @return string | |
| 2738 | + */ | |
| 2821 | 2739 | function bbp_get_forum_topics_feed_link( $forum_id = 0 ) { |
| 2822 | 2740 | |
| 2823 | 2741 | // Validate forum id |
| 2824 | 2742 | $forum_id = bbp_get_forum_id( $forum_id ); |
| @@ -2855,9 +2773,9 @@ | ||
| 2855 | 2773 | return apply_filters( 'bbp_get_forum_topics_feed_link', $link, $url, $forum_id ); |
| 2856 | 2774 | } |
| 2857 | 2775 | |
| 2858 | 2776 | /** |
| 2859 | - * Output the link for the forum replies feed. | |
| 2777 | + * Output the link for the forum replies feed | |
| 2860 | 2778 | * |
| 2861 | 2779 | * @since 2.0.0 bbPress (r3172) |
| 2862 | 2780 | * |
| 2863 | 2781 | * @param int $forum_id Optional. Forum ID. |
| @@ -2864,18 +2782,17 @@ | ||
| 2864 | 2782 | */ |
| 2865 | 2783 | function bbp_forum_replies_feed_link( $forum_id = 0 ) { |
| 2866 | 2784 | echo bbp_get_forum_replies_feed_link( $forum_id ); |
| 2867 | 2785 | } |
| 2868 | - | |
| 2869 | -/** | |
| 2870 | - * Retrieve the link for the forum replies feed. | |
| 2871 | - * | |
| 2872 | - * @since 2.0.0 bbPress (r3172) | |
| 2873 | - * | |
| 2874 | - * @param int $forum_id Optional. Forum ID. | |
| 2875 | - * | |
| 2876 | - * @return string | |
| 2877 | - */ | |
| 2786 | + /** | |
| 2787 | + * Retrieve the link for the forum replies feed | |
| 2788 | + * | |
| 2789 | + * @since 2.0.0 bbPress (r3172) | |
| 2790 | + * | |
| 2791 | + * @param int $forum_id Optional. Forum ID. | |
| 2792 | + * | |
| 2793 | + * @return string | |
| 2794 | + */ | |
| 2878 | 2795 | function bbp_get_forum_replies_feed_link( $forum_id = 0 ) { |
| 2879 | 2796 | |
| 2880 | 2797 | // Validate forum id |
| 2881 | 2798 | $forum_id = bbp_get_forum_id( $forum_id ); |