| @@ -126,21 +126,33 @@ | ||
| 126 | 126 | if ( bbp_is_group_forums_active() ) { |
| 127 | 127 | |
| 128 | 128 | // Only filter for single group forum topics |
| 129 | 129 | if ( bp_is_group_forum_topic() || bp_is_group_forum_topic_edit() ) { |
| 130 | + if ( ! bp_group_is_visible( bp_get_current_group_id() ) ) { | |
| 131 | + return $new_title; | |
| 132 | + } | |
| 130 | 133 | |
| 131 | - // Get the topic | |
| 134 | + $forum_ids = bbp_get_group_forum_ids(); | |
| 135 | + | |
| 136 | + if ( empty( $forum_ids ) ) { | |
| 137 | + return $new_title; | |
| 138 | + } | |
| 139 | + | |
| 140 | + // Get a topic belonging to the current group's forums | |
| 132 | 141 | $topic = get_posts( |
| 133 | 142 | array( |
| 134 | - 'name' => bp_action_variable( 1 ), | |
| 135 | - 'post_status' => array_keys( bbp_get_topic_statuses() ), | |
| 136 | - 'post_type' => bbp_get_topic_post_type(), | |
| 137 | - 'numberposts' => 1 | |
| 143 | + 'name' => bp_action_variable( 1 ), | |
| 144 | + 'post_parent__in' => $forum_ids, | |
| 145 | + 'post_status' => array_keys( bbp_get_topic_statuses() ), | |
| 146 | + 'post_type' => bbp_get_topic_post_type(), | |
| 147 | + 'numberposts' => 1 | |
| 138 | 148 | ) |
| 139 | 149 | ); |
| 140 | 150 | |
| 141 | - // Add the topic title to the <title> | |
| 142 | - $new_title .= bbp_get_topic_title( $topic[0]->ID ) . ' ' . $sep . ' '; | |
| 151 | + // Add the title only when the topic and its forum are readable | |
| 152 | + if ( ! empty( $topic ) && bbp_user_can_view_forum( array( 'forum_id' => $topic[0]->post_parent ) ) && ( bbp_is_topic_public( $topic[0]->ID ) || current_user_can( 'read_topic', $topic[0]->ID ) ) ) { | |
| 153 | + $new_title .= bbp_get_topic_title( $topic[0]->ID ) . ' ' . $sep . ' '; | |
| 154 | + } | |
| 143 | 155 | } |
| 144 | 156 | } |
| 145 | 157 | |
| 146 | 158 | // Return the title |
| @@ -290,9 +302,9 @@ | ||
| 290 | 302 | |
| 291 | 303 | /** |
| 292 | 304 | * Clean up the group root setting if the forum is being deleted |
| 293 | 305 | * |
| 294 | - * @since 2.6.0 bbPress (r6479) | |
| 306 | + * @since 2.6.0 bbPress (r6485) | |
| 295 | 307 | * |
| 296 | 308 | * @param int $forum_id The forum ID being deleted |
| 297 | 309 | */ |
| 298 | 310 | function bbp_maybe_delete_group_forum_root( $forum_id = 0 ) { |
| @@ -314,9 +326,9 @@ | ||
| 314 | 326 | |
| 315 | 327 | /** |
| 316 | 328 | * Handle the new group forum root creation |
| 317 | 329 | * |
| 318 | - * @since 2.6.0 bbPress (r6479) | |
| 330 | + * @since 2.6.0 bbPress (r6485) | |
| 319 | 331 | * |
| 320 | 332 | * @return |
| 321 | 333 | */ |
| 322 | 334 | function bbp_maybe_create_group_forum_root() { |
| @@ -372,9 +384,9 @@ | ||
| 372 | 384 | |
| 373 | 385 | /** |
| 374 | 386 | * Get forum ID's for a group |
| 375 | 387 | * |
| 376 | - * @since 2.1.0 bbPress (r3653) | |
| 388 | + * @since 2.1.0 bbPress (r3654) | |
| 377 | 389 | * |
| 378 | 390 | * @param int $group_id |
| 379 | 391 | */ |
| 380 | 392 | function bbp_get_group_forum_ids( $group_id = 0 ) { |
| @@ -401,9 +413,9 @@ | ||
| 401 | 413 | |
| 402 | 414 | /** |
| 403 | 415 | * Get group ID's for a forum |
| 404 | 416 | * |
| 405 | - * @since 2.1.0 bbPress (r3653) | |
| 417 | + * @since 2.1.0 bbPress (r3654) | |
| 406 | 418 | * |
| 407 | 419 | * @param int $forum_id |
| 408 | 420 | */ |
| 409 | 421 | function bbp_get_forum_group_ids( $forum_id = 0 ) { |
| @@ -430,9 +442,9 @@ | ||
| 430 | 442 | |
| 431 | 443 | /** |
| 432 | 444 | * Get forum ID's for a group |
| 433 | 445 | * |
| 434 | - * @since 2.1.0 bbPress (r3653) | |
| 446 | + * @since 2.1.0 bbPress (r3654) | |
| 435 | 447 | * |
| 436 | 448 | * @param int $group_id |
| 437 | 449 | */ |
| 438 | 450 | function bbp_update_group_forum_ids( $group_id = 0, $forum_ids = array() ) { |
| @@ -451,9 +463,9 @@ | ||
| 451 | 463 | |
| 452 | 464 | /** |
| 453 | 465 | * Update group ID's for a forum |
| 454 | 466 | * |
| 455 | - * @since 2.1.0 bbPress (r3653) | |
| 467 | + * @since 2.1.0 bbPress (r3654) | |
| 456 | 468 | * |
| 457 | 469 | * @param int $forum_id |
| 458 | 470 | */ |
| 459 | 471 | function bbp_update_forum_group_ids( $forum_id = 0, $group_ids = array() ) { |
| @@ -468,9 +480,9 @@ | ||
| 468 | 480 | |
| 469 | 481 | /** |
| 470 | 482 | * Add a group to a forum |
| 471 | 483 | * |
| 472 | - * @since 2.1.0 bbPress (r3653) | |
| 484 | + * @since 2.1.0 bbPress (r3654) | |
| 473 | 485 | * |
| 474 | 486 | * @param int $group_id |
| 475 | 487 | */ |
| 476 | 488 | function bbp_add_group_id_to_forum( $forum_id = 0, $group_id = 0 ) { |
| @@ -495,9 +507,9 @@ | ||
| 495 | 507 | |
| 496 | 508 | /** |
| 497 | 509 | * Remove a forum from a group |
| 498 | 510 | * |
| 499 | - * @since 2.1.0 bbPress (r3653) | |
| 511 | + * @since 2.1.0 bbPress (r3654) | |
| 500 | 512 | * |
| 501 | 513 | * @param int $group_id |
| 502 | 514 | */ |
| 503 | 515 | function bbp_add_forum_id_to_group( $group_id = 0, $forum_id = 0 ) { |
| @@ -522,9 +534,9 @@ | ||
| 522 | 534 | |
| 523 | 535 | /** |
| 524 | 536 | * Remove a group from a forum |
| 525 | 537 | * |
| 526 | - * @since 2.1.0 bbPress (r3653) | |
| 538 | + * @since 2.1.0 bbPress (r3654) | |
| 527 | 539 | * |
| 528 | 540 | * @param int $group_id |
| 529 | 541 | */ |
| 530 | 542 | function bbp_remove_group_id_from_forum( $forum_id = 0, $group_id = 0 ) { |
| @@ -549,9 +561,9 @@ | ||
| 549 | 561 | |
| 550 | 562 | /** |
| 551 | 563 | * Remove a forum from a group |
| 552 | 564 | * |
| 553 | - * @since 2.1.0 bbPress (r3653) | |
| 565 | + * @since 2.1.0 bbPress (r3654) | |
| 554 | 566 | * |
| 555 | 567 | * @param int $group_id |
| 556 | 568 | */ |
| 557 | 569 | function bbp_remove_forum_id_from_group( $group_id = 0, $forum_id = 0 ) { |
| @@ -576,9 +588,9 @@ | ||
| 576 | 588 | |
| 577 | 589 | /** |
| 578 | 590 | * Remove a group from all forums |
| 579 | 591 | * |
| 580 | - * @since 2.1.0 bbPress (r3653) | |
| 592 | + * @since 2.1.0 bbPress (r3654) | |
| 581 | 593 | * |
| 582 | 594 | * @param int $group_id |
| 583 | 595 | */ |
| 584 | 596 | function bbp_remove_group_id_from_all_forums( $group_id = 0 ) { |
| @@ -599,9 +611,9 @@ | ||
| 599 | 611 | |
| 600 | 612 | /** |
| 601 | 613 | * Remove a forum from all groups |
| 602 | 614 | * |
| 603 | - * @since 2.1.0 bbPress (r3653) | |
| 615 | + * @since 2.1.0 bbPress (r3654) | |
| 604 | 616 | * |
| 605 | 617 | * @param int $forum_id |
| 606 | 618 | */ |
| 607 | 619 | function bbp_remove_forum_id_from_all_groups( $forum_id = 0 ) { |
| @@ -618,9 +630,9 @@ | ||
| 618 | 630 | |
| 619 | 631 | /** |
| 620 | 632 | * Return true if a forum is a group forum |
| 621 | 633 | * |
| 622 | - * @since 2.3.0 bbPress (r4571) | |
| 634 | + * @since 2.3.0 bbPress (r4572) | |
| 623 | 635 | * |
| 624 | 636 | * @param int $forum_id |
| 625 | 637 | * @return bool True if it is a group forum, false if not |
| 626 | 638 | */ |
| @@ -643,9 +655,9 @@ | ||
| 643 | 655 | |
| 644 | 656 | /** |
| 645 | 657 | * Is the current user an admin of the current group |
| 646 | 658 | * |
| 647 | - * @since 2.3.0 bbPress (r4632) | |
| 659 | + * @since 2.3.0 bbPress (r4633) | |
| 648 | 660 | * |
| 649 | 661 | * @return bool If current user is an admin of the current group |
| 650 | 662 | */ |
| 651 | 663 | function bbp_group_is_admin() { |
| @@ -668,9 +680,9 @@ | ||
| 668 | 680 | |
| 669 | 681 | /** |
| 670 | 682 | * Is the current user a moderator of the current group |
| 671 | 683 | * |
| 672 | - * @since 2.3.0 bbPress (r4632) | |
| 684 | + * @since 2.3.0 bbPress (r4633) | |
| 673 | 685 | * |
| 674 | 686 | * @return bool If current user is a moderator of the current group |
| 675 | 687 | */ |
| 676 | 688 | function bbp_group_is_mod() { |
| @@ -693,9 +705,9 @@ | ||
| 693 | 705 | |
| 694 | 706 | /** |
| 695 | 707 | * Is the current user a member of the current group |
| 696 | 708 | * |
| 697 | - * @since 2.3.0 bbPress (r4632) | |
| 709 | + * @since 2.3.0 bbPress (r4633) | |
| 698 | 710 | * |
| 699 | 711 | * @return bool If current user is a member of the current group |
| 700 | 712 | */ |
| 701 | 713 | function bbp_group_is_member() { |
| @@ -718,9 +730,9 @@ | ||
| 718 | 730 | |
| 719 | 731 | /** |
| 720 | 732 | * Is the current user banned from the current group |
| 721 | 733 | * |
| 722 | - * @since 2.3.0 bbPress (r4632) | |
| 734 | + * @since 2.3.0 bbPress (r4633) | |
| 723 | 735 | * |
| 724 | 736 | * @return bool If current user is banned from the current group |
| 725 | 737 | */ |
| 726 | 738 | function bbp_group_is_banned() { |
| @@ -743,9 +755,9 @@ | ||
| 743 | 755 | |
| 744 | 756 | /** |
| 745 | 757 | * Is the current user the creator of the current group |
| 746 | 758 | * |
| 747 | - * @since 2.3.0 bbPress (r4632) | |
| 759 | + * @since 2.3.0 bbPress (r4633) | |
| 748 | 760 | * |
| 749 | 761 | * @return bool If current user the creator of the current group |
| 750 | 762 | */ |
| 751 | 763 | function bbp_group_is_creator() { |