| @@ -17,12 +17,10 @@ | ||
| 17 | 17 | * for the forum to function properly. |
| 18 | 18 | * |
| 19 | 19 | * @since 2.0.0 bbPress (r3349) |
| 20 | 20 | * |
| 21 | - * @param array $forum_data Forum post data. | |
| 22 | - * @param array $forum_meta Forum meta data. | |
| 23 | - * | |
| 24 | - * @return int|false Forum ID on success, false on failure. | |
| 21 | + * @param array $forum_data Forum post data | |
| 22 | + * @param array $forum_meta Forum meta data | |
| 25 | 23 | */ |
| 26 | 24 | function bbp_insert_forum( $forum_data = array(), $forum_meta = array() ) { |
| 27 | 25 | |
| 28 | 26 | // Forum |
| @@ -121,11 +119,11 @@ | ||
| 121 | 119 | |
| 122 | 120 | /** Post Form Handlers ********************************************************/ |
| 123 | 121 | |
| 124 | 122 | /** |
| 125 | - * Handles the front end forum submission. | |
| 123 | + * Handles the front end forum submission | |
| 126 | 124 | * |
| 127 | - * @param string $action The requested action to compare this function to. | |
| 125 | + * @param string $action The requested action to compare this function to | |
| 128 | 126 | */ |
| 129 | 127 | function bbp_new_forum_handler( $action = '' ) { |
| 130 | 128 | |
| 131 | 129 | // Bail if action is not bbp-new-forum |
| @@ -197,10 +195,10 @@ | ||
| 197 | 195 | } |
| 198 | 196 | |
| 199 | 197 | /** Forum Parent **********************************************************/ |
| 200 | 198 | |
| 201 | - // Forum parent is expected for theme-side submissions | |
| 202 | - if ( ! empty( $_POST['bbp_forum_parent_id'] ) && is_numeric( $_POST['bbp_forum_parent_id'] ) ) { | |
| 199 | + // Forum parent was passed (the norm) | |
| 200 | + if ( ! empty( $_POST['bbp_forum_parent_id'] ) ) { | |
| 203 | 201 | $forum_parent_id = bbp_get_forum_id( $_POST['bbp_forum_parent_id'] ); |
| 204 | 202 | } |
| 205 | 203 | |
| 206 | 204 | // Filter and sanitize |
| @@ -205,28 +203,34 @@ | ||
| 205 | 203 | |
| 206 | 204 | // Filter and sanitize |
| 207 | 205 | $forum_parent_id = apply_filters( 'bbp_new_forum_pre_parent_id', $forum_parent_id ); |
| 208 | 206 | |
| 209 | - // Forum parent was not passed (required for theme-side BuddyPress support) | |
| 207 | + // No forum parent was passed (should never happen) | |
| 210 | 208 | if ( empty( $forum_parent_id ) ) { |
| 211 | 209 | bbp_add_error( 'bbp_new_forum_missing_parent', __( '<strong>Error</strong>: Your forum must have a parent.', 'bbpress' ) ); |
| 212 | 210 | |
| 213 | - // Forum parent exists | |
| 211 | + // Forum exists | |
| 214 | 212 | } elseif ( ! empty( $forum_parent_id ) ) { |
| 215 | 213 | |
| 216 | - // Forum parent not editable by user | |
| 217 | - if ( ! current_user_can( 'edit_forum', $forum_parent_id ) ) { | |
| 214 | + // Forum is a category | |
| 215 | + if ( bbp_is_forum_category( $forum_parent_id ) ) { | |
| 216 | + bbp_add_error( 'bbp_new_forum_forum_category', __( '<strong>Error</strong>: This forum is a category. No forums can be created in this forum.', 'bbpress' ) ); | |
| 217 | + } | |
| 218 | 218 | |
| 219 | - // Forum parent is closed | |
| 220 | - if ( bbp_is_forum_closed( $forum_parent_id ) ) { | |
| 221 | - bbp_add_error( 'bbp_new_forum_forum_closed', __( '<strong>Error</strong>: This forum is closed to new forums.', 'bbpress' ) ); | |
| 222 | - } | |
| 219 | + // Forum is closed and user cannot access | |
| 220 | + if ( bbp_is_forum_closed( $forum_parent_id ) && ! current_user_can( 'edit_forum', $forum_parent_id ) ) { | |
| 221 | + bbp_add_error( 'bbp_new_forum_forum_closed', __( '<strong>Error</strong>: This forum has been closed to new forums.', 'bbpress' ) ); | |
| 223 | 222 | } |
| 224 | 223 | |
| 225 | - // Forum parent not readable by user | |
| 226 | - if ( ! current_user_can( 'read_forum', $forum_parent_id ) ) { | |
| 227 | - bbp_add_error( 'bbp_new_forum_forum_read', __( '<strong>Error</strong>: You do not have the capability to create new forums in this forum.', 'bbpress' ) ); | |
| 224 | + // Forum is private and user cannot access | |
| 225 | + if ( bbp_is_forum_private( $forum_parent_id ) && ! current_user_can( 'read_forum', $forum_parent_id ) ) { | |
| 226 | + bbp_add_error( 'bbp_new_forum_forum_private', __( '<strong>Error</strong>: This forum is private and you do not have the capability to read or create new forums in it.', 'bbpress' ) ); | |
| 228 | 227 | } |
| 228 | + | |
| 229 | + // Forum is hidden and user cannot access | |
| 230 | + if ( bbp_is_forum_hidden( $forum_parent_id ) && ! current_user_can( 'read_forum', $forum_parent_id ) ) { | |
| 231 | + bbp_add_error( 'bbp_new_forum_forum_hidden', __( '<strong>Error</strong>: This forum is hidden and you do not have the capability to read or create new forums in it.', 'bbpress' ) ); | |
| 232 | + } | |
| 229 | 233 | } |
| 230 | 234 | |
| 231 | 235 | /** Forum Flooding ********************************************************/ |
| 232 | 236 | |
| @@ -375,14 +379,14 @@ | ||
| 375 | 379 | |
| 376 | 380 | } elseif ( is_wp_error( $forum_id ) ) { |
| 377 | 381 | bbp_add_error( |
| 378 | 382 | 'bbp_forum_error', |
| 379 | - sprintf( | |
| 380 | - /* translators: %s: Error message */ | |
| 381 | - esc_html__( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ), | |
| 383 | + sprintf( /* translators: %s: Error message(s) */ __( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ), | |
| 382 | 384 | $forum_id->get_error_message() |
| 383 | 385 | ) |
| 384 | 386 | ); |
| 387 | + | |
| 388 | + // Generic error | |
| 385 | 389 | } else { |
| 386 | 390 | bbp_add_error( 'bbp_forum_error', __( '<strong>Error</strong>: The forum was not created.', 'bbpress' ) ); |
| 387 | 391 | } |
| 388 | 392 | } |
| @@ -387,11 +391,11 @@ | ||
| 387 | 391 | } |
| 388 | 392 | } |
| 389 | 393 | |
| 390 | 394 | /** |
| 391 | - * Handles the front end edit forum submission. | |
| 395 | + * Handles the front end edit forum submission | |
| 392 | 396 | * |
| 393 | - * @param string $action The requested action to compare this function to. | |
| 397 | + * @param string $action The requested action to compare this function to | |
| 394 | 398 | */ |
| 395 | 399 | function bbp_edit_forum_handler( $action = '' ) { |
| 396 | 400 | |
| 397 | 401 | // Bail if action is not bbp-edit-forum |
| @@ -449,9 +453,9 @@ | ||
| 449 | 453 | $current_parent_forum_id = bbp_get_forum_parent_id( $forum_id ); |
| 450 | 454 | |
| 451 | 455 | // Only users who can assign forum moderators can change forum structure |
| 452 | 456 | if ( current_user_can( 'assign_moderators' ) ) { |
| 453 | - $forum_parent_id = ( ! empty( $_POST['bbp_forum_parent_id'] ) && is_numeric( $_POST['bbp_forum_parent_id'] ) ) | |
| 457 | + $forum_parent_id = ! empty( $_POST['bbp_forum_parent_id'] ) | |
| 454 | 458 | ? bbp_get_forum_id( $_POST['bbp_forum_parent_id'] ) |
| 455 | 459 | : 0; |
| 456 | 460 | } else { |
| 457 | 461 | $forum_parent_id = $current_parent_forum_id; |
| @@ -456,23 +460,24 @@ | ||
| 456 | 460 | } else { |
| 457 | 461 | $forum_parent_id = $current_parent_forum_id; |
| 458 | 462 | } |
| 459 | 463 | |
| 460 | - // Forum parent exists | |
| 464 | + // Forum exists | |
| 461 | 465 | if ( ! empty( $forum_parent_id ) && ( $forum_parent_id !== $current_parent_forum_id ) ) { |
| 462 | 466 | |
| 463 | - // Forum parent not editable by user | |
| 464 | - if ( ! current_user_can( 'edit_forum', $forum_parent_id ) ) { | |
| 467 | + // Forum is closed and user cannot access | |
| 468 | + if ( bbp_is_forum_closed( $forum_parent_id ) && ! current_user_can( 'edit_forum', $forum_parent_id ) ) { | |
| 469 | + bbp_add_error( 'bbp_edit_forum_forum_closed', __( '<strong>Error</strong>: This forum has been closed to new forums.', 'bbpress' ) ); | |
| 470 | + } | |
| 465 | 471 | |
| 466 | - // Forum is closed | |
| 467 | - if ( bbp_is_forum_closed( $forum_parent_id ) ) { | |
| 468 | - bbp_add_error( 'bbp_edit_forum_forum_closed', __( '<strong>Error</strong>: This forum is closed to new forums.', 'bbpress' ) ); | |
| 469 | - } | |
| 472 | + // Forum is private and user cannot access | |
| 473 | + if ( bbp_is_forum_private( $forum_parent_id ) && ! current_user_can( 'read_forum', $forum_parent_id ) ) { | |
| 474 | + bbp_add_error( 'bbp_edit_forum_forum_private', __( '<strong>Error</strong>: This forum is private and you do not have the capability to read or create new forums in it.', 'bbpress' ) ); | |
| 470 | 475 | } |
| 471 | 476 | |
| 472 | - // Forum parent not readable by user | |
| 473 | - if ( ! current_user_can( 'read_forum', $forum_parent_id ) ) { | |
| 474 | - bbp_add_error( 'bbp_edit_forum_forum_read', __( '<strong>Error</strong>: You do not have the capability to create new forums in this forum.', 'bbpress' ) ); | |
| 477 | + // Forum is hidden and user cannot access | |
| 478 | + if ( bbp_is_forum_hidden( $forum_parent_id ) && ! current_user_can( 'read_forum', $forum_parent_id ) ) { | |
| 479 | + bbp_add_error( 'bbp_edit_forum_forum_hidden', __( '<strong>Error</strong>: This forum is hidden and you do not have the capability to read or create new forums in it.', 'bbpress' ) ); | |
| 475 | 480 | } |
| 476 | 481 | } |
| 477 | 482 | |
| 478 | 483 | /** Forum Title ***********************************************************/ |
| @@ -638,11 +643,11 @@ | ||
| 638 | 643 | bbp_add_error( |
| 639 | 644 | 'bbp_forum_error', |
| 640 | 645 | sprintf( |
| 641 | 646 | /* translators: %s: Error message */ |
| 642 | - __( '<strong>Error</strong>: The following problem(s) have been found with your forum: %s Please try again.', 'bbpress' ) | |
| 643 | - ), | |
| 644 | - $append_error | |
| 647 | + __( '<strong>Error</strong>: The following problem(s) have been found with your forum: %sPlease try again.', 'bbpress' ), | |
| 648 | + $append_error | |
| 649 | + ) | |
| 645 | 650 | ); |
| 646 | 651 | } |
| 647 | 652 | } |
| 648 | 653 | |
| @@ -648,9 +653,9 @@ | ||
| 648 | 653 | |
| 649 | 654 | /** |
| 650 | 655 | * Filter forum data submitted through the WordPress administration area. |
| 651 | 656 | * |
| 652 | - * @since 2.7.0 bbPress (r7489) | |
| 657 | + * @since 2.6.17 bbPress (r7490) | |
| 653 | 658 | * |
| 654 | 659 | * @param array $data Sanitized post data. |
| 655 | 660 | * @param array $postarr Raw post data. |
| 656 | 661 | * @return array Filtered post data. |
| @@ -683,14 +688,14 @@ | ||
| 683 | 688 | return $data; |
| 684 | 689 | } |
| 685 | 690 | |
| 686 | 691 | /** |
| 687 | - * Handle the saving of core forum metadata (Status, Visibility, and Type). | |
| 692 | + * Handle the saving of core forum metadata (Status, Visibility, and Type) | |
| 688 | 693 | * |
| 689 | 694 | * @since 2.1.0 bbPress (r3679) |
| 690 | 695 | * |
| 691 | - * @param int $forum_id. | |
| 692 | - * @return If forum ID is empty. | |
| 696 | + * @param int $forum_id | |
| 697 | + * @return If forum ID is empty | |
| 693 | 698 | */ |
| 694 | 699 | function bbp_save_forum_extras( $forum_id = 0 ) { |
| 695 | 700 | |
| 696 | 701 | // Validate the forum ID |
| @@ -755,15 +760,15 @@ | ||
| 755 | 760 | break; |
| 756 | 761 | } |
| 757 | 762 | |
| 758 | 763 | /** |
| 759 | - * Allow custom forum visibility save actions. | |
| 764 | + * Allow custom forum visibility save actions | |
| 760 | 765 | * |
| 761 | 766 | * @since 2.6.0 bbPress (r5856) |
| 762 | 767 | * |
| 763 | - * @param int $forum_id The forum ID. | |
| 764 | - * @param string $old_visibility The current forum visibility. | |
| 765 | - * @param string $new_visibility The new forum visibility. | |
| 768 | + * @param int $forum_id The forum ID | |
| 769 | + * @param string $old_visibility The current forum visibility | |
| 770 | + * @param string $new_visibility The new forum visibility | |
| 766 | 771 | */ |
| 767 | 772 | do_action( 'bbp_update_forum_visibility', $forum_id, $old_visibility, $new_visibility ); |
| 768 | 773 | } |
| 769 | 774 | |
| @@ -798,14 +803,14 @@ | ||
| 798 | 803 | |
| 799 | 804 | /** Forum Open/Close **********************************************************/ |
| 800 | 805 | |
| 801 | 806 | /** |
| 802 | - * Closes a forum. | |
| 807 | + * Closes a forum | |
| 803 | 808 | * |
| 804 | 809 | * @since 2.0.0 bbPress (r2746) |
| 805 | 810 | * |
| 806 | - * @param int $forum_id forum id. | |
| 807 | - * @return mixed False or {@link WP_Error} on failure, forum id on success. | |
| 811 | + * @param int $forum_id forum id | |
| 812 | + * @return mixed False or {@link WP_Error} on failure, forum id on success | |
| 808 | 813 | */ |
| 809 | 814 | function bbp_close_forum( $forum_id = 0 ) { |
| 810 | 815 | |
| 811 | 816 | $forum_id = bbp_get_forum_id( $forum_id ); |
| @@ -819,14 +824,14 @@ | ||
| 819 | 824 | return $forum_id; |
| 820 | 825 | } |
| 821 | 826 | |
| 822 | 827 | /** |
| 823 | - * Opens a forum. | |
| 828 | + * Opens a forum | |
| 824 | 829 | * |
| 825 | 830 | * @since 2.0.0 bbPress (r2746) |
| 826 | 831 | * |
| 827 | - * @param int $forum_id forum id. | |
| 828 | - * @return mixed False or {@link WP_Error} on failure, forum id on success. | |
| 832 | + * @param int $forum_id forum id | |
| 833 | + * @return mixed False or {@link WP_Error} on failure, forum id on success | |
| 829 | 834 | */ |
| 830 | 835 | function bbp_open_forum( $forum_id = 0 ) { |
| 831 | 836 | |
| 832 | 837 | $forum_id = bbp_get_forum_id( $forum_id ); |
| @@ -842,14 +847,14 @@ | ||
| 842 | 847 | |
| 843 | 848 | /** Forum Type ****************************************************************/ |
| 844 | 849 | |
| 845 | 850 | /** |
| 846 | - * Make the forum a category. | |
| 851 | + * Make the forum a category | |
| 847 | 852 | * |
| 848 | 853 | * @since 2.0.0 bbPress (r2746) |
| 849 | 854 | * |
| 850 | - * @param int $forum_id Optional. Forum id. | |
| 851 | - * @return bool False on failure, true on success. | |
| 855 | + * @param int $forum_id Optional. Forum id | |
| 856 | + * @return bool False on failure, true on success | |
| 852 | 857 | */ |
| 853 | 858 | function bbp_categorize_forum( $forum_id = 0 ) { |
| 854 | 859 | |
| 855 | 860 | $forum_id = bbp_get_forum_id( $forum_id ); |
| @@ -863,14 +868,14 @@ | ||
| 863 | 868 | return $forum_id; |
| 864 | 869 | } |
| 865 | 870 | |
| 866 | 871 | /** |
| 867 | - * Remove the category status from a forum. | |
| 872 | + * Remove the category status from a forum | |
| 868 | 873 | * |
| 869 | 874 | * @since 2.0.0 bbPress (r2746) |
| 870 | 875 | * |
| 871 | - * @param int $forum_id Optional. Forum id. | |
| 872 | - * @return bool False on failure, true on success. | |
| 876 | + * @param int $forum_id Optional. Forum id | |
| 877 | + * @return bool False on failure, true on success | |
| 873 | 878 | */ |
| 874 | 879 | function bbp_normalize_forum( $forum_id = 0 ) { |
| 875 | 880 | |
| 876 | 881 | $forum_id = bbp_get_forum_id( $forum_id ); |
| @@ -891,9 +896,9 @@ | ||
| 891 | 896 | * |
| 892 | 897 | * This function only synchronizes the private and hidden forum ID options. It |
| 893 | 898 | * does not update the forum post status or fire any status transition actions. |
| 894 | 899 | * |
| 895 | - * @since 2.6.19 bbPress (r7671) | |
| 900 | + * @since 2.6.19 bbPress | |
| 896 | 901 | * |
| 897 | 902 | * @param int $forum_id Optional. Forum ID. |
| 898 | 903 | * @param string $visibility Optional. Forum visibility. |
| 899 | 904 | * @return int|false Forum ID on success, false on failure. |
| @@ -945,9 +950,9 @@ | ||
| 945 | 950 | |
| 946 | 951 | /** |
| 947 | 952 | * Synchronize forum visibility options after a post status transition. |
| 948 | 953 | * |
| 949 | - * @since 2.6.19 bbPress (r7671) | |
| 954 | + * @since 2.6.19 bbPress | |
| 950 | 955 | * |
| 951 | 956 | * @param string $new_status New post status. |
| 952 | 957 | * @param string $old_status Old post status. |
| 953 | 958 | * @param WP_Post $post Post object. |
| @@ -962,14 +967,14 @@ | ||
| 962 | 967 | bbp_update_forum_visibility_options( $post->ID, $new_status ); |
| 963 | 968 | } |
| 964 | 969 | |
| 965 | 970 | /** |
| 966 | - * Mark the forum as public. | |
| 971 | + * Mark the forum as public | |
| 967 | 972 | * |
| 968 | 973 | * @since 2.0.0 bbPress (r2746) |
| 969 | 974 | * |
| 970 | - * @param int $forum_id Optional. Forum id. | |
| 971 | - * @return bool False on failure, true on success. | |
| 975 | + * @param int $forum_id Optional. Forum id | |
| 976 | + * @return bool False on failure, true on success | |
| 972 | 977 | */ |
| 973 | 978 | function bbp_publicize_forum( $forum_id = 0, $current_visibility = '' ) { |
| 974 | 979 | |
| 975 | 980 | $forum_id = bbp_get_forum_id( $forum_id ); |
| @@ -992,14 +997,14 @@ | ||
| 992 | 997 | return $forum_id; |
| 993 | 998 | } |
| 994 | 999 | |
| 995 | 1000 | /** |
| 996 | - * Mark the forum as private. | |
| 1001 | + * Mark the forum as private | |
| 997 | 1002 | * |
| 998 | 1003 | * @since 2.0.0 bbPress (r2746) |
| 999 | 1004 | * |
| 1000 | - * @param int $forum_id Optional. Forum id. | |
| 1001 | - * @return bool False on failure, true on success. | |
| 1005 | + * @param int $forum_id Optional. Forum id | |
| 1006 | + * @return bool False on failure, true on success | |
| 1002 | 1007 | */ |
| 1003 | 1008 | function bbp_privatize_forum( $forum_id = 0, $current_visibility = '' ) { |
| 1004 | 1009 | |
| 1005 | 1010 | $forum_id = bbp_get_forum_id( $forum_id ); |
| @@ -1024,14 +1029,14 @@ | ||
| 1024 | 1029 | return $forum_id; |
| 1025 | 1030 | } |
| 1026 | 1031 | |
| 1027 | 1032 | /** |
| 1028 | - * Mark the forum as hidden. | |
| 1033 | + * Mark the forum as hidden | |
| 1029 | 1034 | * |
| 1030 | 1035 | * @since 2.0.0 bbPress (r2996) |
| 1031 | 1036 | * |
| 1032 | - * @param int $forum_id Optional. Forum id. | |
| 1033 | - * @return bool False on failure, true on success. | |
| 1037 | + * @param int $forum_id Optional. Forum id | |
| 1038 | + * @return bool False on failure, true on success | |
| 1034 | 1039 | */ |
| 1035 | 1040 | function bbp_hide_forum( $forum_id = 0, $current_visibility = '' ) { |
| 1036 | 1041 | |
| 1037 | 1042 | $forum_id = bbp_get_forum_id( $forum_id ); |
| @@ -1056,13 +1061,13 @@ | ||
| 1056 | 1061 | return $forum_id; |
| 1057 | 1062 | } |
| 1058 | 1063 | |
| 1059 | 1064 | /** |
| 1060 | - * Re-caches the private and hidden forums. | |
| 1065 | + * Recaches the private and hidden forums | |
| 1061 | 1066 | * |
| 1062 | 1067 | * @since 2.4.0 bbPress (r5017) |
| 1063 | 1068 | * |
| 1064 | - * @return array An array of the status code and the message. | |
| 1069 | + * @return array An array of the status code and the message | |
| 1065 | 1070 | */ |
| 1066 | 1071 | function bbp_repair_forum_visibility() { |
| 1067 | 1072 | |
| 1068 | 1073 | // First, delete everything. |
| @@ -1136,13 +1141,13 @@ | ||
| 1136 | 1141 | |
| 1137 | 1142 | /** Subscriptions *************************************************************/ |
| 1138 | 1143 | |
| 1139 | 1144 | /** |
| 1140 | - * Remove a deleted forum from all user subscriptions. | |
| 1145 | + * Remove a deleted forum from all user subscriptions | |
| 1141 | 1146 | * |
| 1142 | 1147 | * @since 2.5.0 bbPress (r5156) |
| 1143 | 1148 | * |
| 1144 | - * @param int $forum_id Get the forum ID to remove. | |
| 1149 | + * @param int $forum_id Get the forum ID to remove | |
| 1145 | 1150 | */ |
| 1146 | 1151 | function bbp_remove_forum_from_all_subscriptions( $forum_id = 0 ) { |
| 1147 | 1152 | |
| 1148 | 1153 | // Subscriptions are not active |
| @@ -1162,12 +1167,12 @@ | ||
| 1162 | 1167 | |
| 1163 | 1168 | /** Count Bumpers *************************************************************/ |
| 1164 | 1169 | |
| 1165 | 1170 | /** |
| 1166 | - * Bump the total topic count of a forum. | |
| 1171 | + * Bump the total topic count of a forum | |
| 1167 | 1172 | * |
| 1168 | 1173 | * @since 2.1.0 bbPress (r3826) |
| 1169 | - * @since 2.6.17 bbPress (r7467) Use atomic metadata writes and non-negative counts. | |
| 1174 | + * @since 2.6.17 bbPress (r7468) Use atomic metadata writes and non-negative counts. | |
| 1170 | 1175 | * |
| 1171 | 1176 | * @param int $forum_id Optional. Forum id. |
| 1172 | 1177 | * @param int $difference Optional. Default 1 |
| 1173 | 1178 | * @param bool $update_ancestors Optional. Default true |
| @@ -1227,8 +1232,9 @@ | ||
| 1227 | 1232 | * |
| 1228 | 1233 | * @since 2.6.0 bbPress (r6036) |
| 1229 | 1234 | * |
| 1230 | 1235 | * @param int $forum_id The forum id. |
| 1236 | + * @return void | |
| 1231 | 1237 | */ |
| 1232 | 1238 | function bbp_increase_forum_topic_count( $forum_id = 0 ) { |
| 1233 | 1239 | |
| 1234 | 1240 | // Bail early if no id is passed. |
| @@ -1257,8 +1263,10 @@ | ||
| 1257 | 1263 | * |
| 1258 | 1264 | * @since 2.6.0 bbPress (r6036) |
| 1259 | 1265 | * |
| 1260 | 1266 | * @param int $forum_id The forum id. |
| 1267 | + * | |
| 1268 | + * @return void | |
| 1261 | 1269 | */ |
| 1262 | 1270 | function bbp_decrease_forum_topic_count( $forum_id = 0 ) { |
| 1263 | 1271 | |
| 1264 | 1272 | // Bail early if no id is passed. |
| @@ -1282,12 +1290,12 @@ | ||
| 1282 | 1290 | bbp_bump_forum_topic_count( $forum_id, -1 ); |
| 1283 | 1291 | } |
| 1284 | 1292 | |
| 1285 | 1293 | /** |
| 1286 | - * Bump the total topic count of a forum. | |
| 1294 | + * Bump the total topic count of a forum | |
| 1287 | 1295 | * |
| 1288 | 1296 | * @since 2.1.0 bbPress (r3826) |
| 1289 | - * @since 2.6.17 bbPress (r7467) Use atomic metadata writes and non-negative counts. | |
| 1297 | + * @since 2.6.17 bbPress (r7468) Use atomic metadata writes and non-negative counts. | |
| 1290 | 1298 | * |
| 1291 | 1299 | * @param int $forum_id Optional. Forum id. |
| 1292 | 1300 | * @param int $difference Optional. Default 1 |
| 1293 | 1301 | * @param bool $update_ancestors Optional. Default true |
| @@ -1347,8 +1355,10 @@ | ||
| 1347 | 1355 | * |
| 1348 | 1356 | * @since 2.6.0 bbPress (r6036) |
| 1349 | 1357 | * |
| 1350 | 1358 | * @param int $forum_id The forum id. |
| 1359 | + * | |
| 1360 | + * @return void | |
| 1351 | 1361 | */ |
| 1352 | 1362 | function bbp_increase_forum_topic_count_hidden( $forum_id = 0 ) { |
| 1353 | 1363 | |
| 1354 | 1364 | // Bail early if no id is passed. |
| @@ -1377,8 +1387,10 @@ | ||
| 1377 | 1387 | * |
| 1378 | 1388 | * @since 2.6.0 bbPress (r6036) |
| 1379 | 1389 | * |
| 1380 | 1390 | * @param int $forum_id The forum id. |
| 1391 | + * | |
| 1392 | + * @return void | |
| 1381 | 1393 | */ |
| 1382 | 1394 | function bbp_decrease_forum_topic_count_hidden( $forum_id = 0 ) { |
| 1383 | 1395 | |
| 1384 | 1396 | // Bail early if no id is passed. |
| @@ -1402,16 +1414,16 @@ | ||
| 1402 | 1414 | bbp_bump_forum_topic_count_hidden( $forum_id, -1 ); |
| 1403 | 1415 | } |
| 1404 | 1416 | |
| 1405 | 1417 | /** |
| 1406 | - * Bump the total topic count of a forum. | |
| 1418 | + * Bump the total topic count of a forum | |
| 1407 | 1419 | * |
| 1408 | 1420 | * @since 2.1.0 bbPress (r3826) |
| 1409 | - * @since 2.6.17 bbPress (r7467) Use atomic metadata writes and non-negative counts. | |
| 1421 | + * @since 2.6.17 bbPress (r7468) Use atomic metadata writes and non-negative counts. | |
| 1410 | 1422 | * |
| 1411 | 1423 | * @param int $forum_id Optional. Forum id. |
| 1412 | - * @param int $difference Optional. Default 1. | |
| 1413 | - * @param bool $update_ancestors Optional. Default true. | |
| 1424 | + * @param int $difference Optional. Default 1 | |
| 1425 | + * @param bool $update_ancestors Optional. Default true | |
| 1414 | 1426 | * |
| 1415 | 1427 | * @return int Forum topic count |
| 1416 | 1428 | */ |
| 1417 | 1429 | function bbp_bump_forum_reply_count( $forum_id = 0, $difference = 1, $update_ancestors = true ) { |
| @@ -1462,16 +1474,16 @@ | ||
| 1462 | 1474 | return (int) apply_filters( 'bbp_bump_forum_reply_count', $forum_reply_count, $forum_id, $difference, $update_ancestors ); |
| 1463 | 1475 | } |
| 1464 | 1476 | |
| 1465 | 1477 | /** |
| 1466 | - * Bump the total topic count of a forum. | |
| 1478 | + * Bump the total topic count of a forum | |
| 1467 | 1479 | * |
| 1468 | 1480 | * @since 2.6.0 bbPress (r6923) |
| 1469 | - * @since 2.6.17 bbPress (r7467) Use atomic metadata writes and non-negative counts. | |
| 1481 | + * @since 2.6.17 bbPress (r7468) Use atomic metadata writes and non-negative counts. | |
| 1470 | 1482 | * |
| 1471 | 1483 | * @param int $forum_id Optional. Forum id. |
| 1472 | - * @param int $difference Optional. Default 1. | |
| 1473 | - * @param bool $update_ancestors Optional. Default true. | |
| 1484 | + * @param int $difference Optional. Default 1 | |
| 1485 | + * @param bool $update_ancestors Optional. Default true | |
| 1474 | 1486 | * |
| 1475 | 1487 | * @return int Forum topic count |
| 1476 | 1488 | */ |
| 1477 | 1489 | function bbp_bump_forum_reply_count_hidden( $forum_id = 0, $difference = 1, $update_ancestors = true ) { |
| @@ -1535,9 +1547,9 @@ | ||
| 1535 | 1547 | * Only parent forums are traversed: topics and replies are never ancestors in |
| 1536 | 1548 | * a valid forum hierarchy, even when the metadata key stores their totals. The |
| 1537 | 1549 | * walk stops if a malformed parent relationship leaves the forum post type. |
| 1538 | 1550 | * |
| 1539 | - * @since 2.6.17 bbPress (r7467) | |
| 1551 | + * @since 2.6.17 bbPress (r7468) | |
| 1540 | 1552 | * |
| 1541 | 1553 | * @param int $forum_id Starting forum ID. Its own count is not changed. |
| 1542 | 1554 | * @param string $meta_key Topic or reply total count metadata key. |
| 1543 | 1555 | * @param int $difference Amount to add to the stored value. |
| @@ -1583,8 +1595,10 @@ | ||
| 1583 | 1595 | * |
| 1584 | 1596 | * @since 2.6.0 bbPress (r6036) |
| 1585 | 1597 | * |
| 1586 | 1598 | * @param int $forum_id The forum id. |
| 1599 | + * | |
| 1600 | + * @return void | |
| 1587 | 1601 | */ |
| 1588 | 1602 | function bbp_increase_forum_reply_count( $forum_id = 0 ) { |
| 1589 | 1603 | |
| 1590 | 1604 | // Bail early if no id is passed. |
| @@ -1613,8 +1627,10 @@ | ||
| 1613 | 1627 | * |
| 1614 | 1628 | * @since 2.6.0 bbPress (r6036) |
| 1615 | 1629 | * |
| 1616 | 1630 | * @param int $forum_id The forum id. |
| 1631 | + * | |
| 1632 | + * @return void | |
| 1617 | 1633 | */ |
| 1618 | 1634 | function bbp_decrease_forum_reply_count( $forum_id = 0 ) { |
| 1619 | 1635 | |
| 1620 | 1636 | // Bail early if no id is passed. |
| @@ -1643,8 +1659,10 @@ | ||
| 1643 | 1659 | * |
| 1644 | 1660 | * @since 2.6.0 bbPress (r6923) |
| 1645 | 1661 | * |
| 1646 | 1662 | * @param int $forum_id The forum id. |
| 1663 | + * | |
| 1664 | + * @return void | |
| 1647 | 1665 | */ |
| 1648 | 1666 | function bbp_increase_forum_reply_count_hidden( $forum_id = 0 ) { |
| 1649 | 1667 | |
| 1650 | 1668 | // Bail early if no id is passed. |
| @@ -1673,8 +1691,10 @@ | ||
| 1673 | 1691 | * |
| 1674 | 1692 | * @since 2.6.0 bbPress (r6923) |
| 1675 | 1693 | * |
| 1676 | 1694 | * @param int $forum_id The forum id. |
| 1695 | + * | |
| 1696 | + * @return void | |
| 1677 | 1697 | */ |
| 1678 | 1698 | function bbp_decrease_forum_reply_count_hidden( $forum_id = 0 ) { |
| 1679 | 1699 | |
| 1680 | 1700 | // Bail early if no id is passed. |
| @@ -1703,8 +1723,10 @@ | ||
| 1703 | 1723 | * |
| 1704 | 1724 | * @since 2.6.0 bbPress (r6036) |
| 1705 | 1725 | * |
| 1706 | 1726 | * @param int $topic_id The topic id. |
| 1727 | + * | |
| 1728 | + * @return void | |
| 1707 | 1729 | */ |
| 1708 | 1730 | function bbp_approved_unapproved_topic_update_forum_reply_count( $topic_id = 0 ) { |
| 1709 | 1731 | |
| 1710 | 1732 | // Bail early if we don't have a topic id. |
| @@ -1726,15 +1748,15 @@ | ||
| 1726 | 1748 | |
| 1727 | 1749 | /** Forum Updaters ************************************************************/ |
| 1728 | 1750 | |
| 1729 | 1751 | /** |
| 1730 | - * Update the forum last topic id. | |
| 1752 | + * Update the forum last topic id | |
| 1731 | 1753 | * |
| 1732 | 1754 | * @since 2.0.0 bbPress (r2627) |
| 1733 | 1755 | * |
| 1734 | 1756 | * @param int $forum_id Optional. Forum id. |
| 1735 | 1757 | * @param int $topic_id Optional. Topic id. |
| 1736 | - * @return int Id of the forums most recent topic. | |
| 1758 | + * @return int Id of the forums most recent topic | |
| 1737 | 1759 | */ |
| 1738 | 1760 | function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { |
| 1739 | 1761 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 1740 | 1762 | |
| @@ -1785,15 +1807,15 @@ | ||
| 1785 | 1807 | return (int) apply_filters( 'bbp_update_forum_last_topic_id', $topic_id, $forum_id ); |
| 1786 | 1808 | } |
| 1787 | 1809 | |
| 1788 | 1810 | /** |
| 1789 | - * Update the forum last reply id. | |
| 1811 | + * Update the forum last reply id | |
| 1790 | 1812 | * |
| 1791 | 1813 | * @since 2.0.0 bbPress (r2627) |
| 1792 | 1814 | * |
| 1793 | 1815 | * @param int $forum_id Optional. Forum id. |
| 1794 | 1816 | * @param int $reply_id Optional. Reply id. |
| 1795 | - * @return int Id of the forums most recent reply. | |
| 1817 | + * @return int Id of the forums most recent reply | |
| 1796 | 1818 | */ |
| 1797 | 1819 | function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { |
| 1798 | 1820 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 1799 | 1821 | |
| @@ -1841,15 +1863,15 @@ | ||
| 1841 | 1863 | return (int) apply_filters( 'bbp_update_forum_last_reply_id', $reply_id, $forum_id ); |
| 1842 | 1864 | } |
| 1843 | 1865 | |
| 1844 | 1866 | /** |
| 1845 | - * Update the forum last active post id. | |
| 1867 | + * Update the forum last active post id | |
| 1846 | 1868 | * |
| 1847 | 1869 | * @since 2.0.0 bbPress (r2870) |
| 1848 | 1870 | * |
| 1849 | 1871 | * @param int $forum_id Optional. Forum id. |
| 1850 | 1872 | * @param int $active_id Optional. Active post id. |
| 1851 | - * @return int Id of the forums last active post. | |
| 1873 | + * @return int Id of the forums last active post | |
| 1852 | 1874 | */ |
| 1853 | 1875 | function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { |
| 1854 | 1876 | |
| 1855 | 1877 | $forum_id = bbp_get_forum_id( $forum_id ); |
| @@ -1899,9 +1921,9 @@ | ||
| 1899 | 1921 | return (int) apply_filters( 'bbp_update_forum_last_active_id', $active_id, $forum_id ); |
| 1900 | 1922 | } |
| 1901 | 1923 | |
| 1902 | 1924 | /** |
| 1903 | - * Update the forums last active date/time (aka freshness). | |
| 1925 | + * Update the forums last active date/time (aka freshness) | |
| 1904 | 1926 | * |
| 1905 | 1927 | * @since 2.0.0 bbPress (r2870) |
| 1906 | 1928 | * |
| 1907 | 1929 | * @param int $forum_id Optional. Topic id. |
| @@ -1906,9 +1928,9 @@ | ||
| 1906 | 1928 | * |
| 1907 | 1929 | * @param int $forum_id Optional. Topic id. |
| 1908 | 1930 | * @param string $new_time Optional. New time in mysql format. |
| 1909 | 1931 | * |
| 1910 | - * @return string MySQL timestamp of last active topic or reply. | |
| 1932 | + * @return string MySQL timestamp of last active topic or reply | |
| 1911 | 1933 | */ |
| 1912 | 1934 | function bbp_update_forum_last_active_time( $forum_id = 0, $new_time = '' ) { |
| 1913 | 1935 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 1914 | 1936 | |
| @@ -1926,17 +1948,17 @@ | ||
| 1926 | 1948 | return apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id ); |
| 1927 | 1949 | } |
| 1928 | 1950 | |
| 1929 | 1951 | /** |
| 1930 | - * Update the forum sub-forum count. | |
| 1952 | + * Update the forum sub-forum count | |
| 1931 | 1953 | * |
| 1932 | 1954 | * @since 2.0.0 bbPress (r2627) |
| 1933 | - * @since 2.6.17 bbPress (r7453) Count supported forum visibilities from the post hierarchy. | |
| 1955 | + * @since 2.6.17 bbPress (r7454) Count supported forum visibilities from the post hierarchy. | |
| 1934 | 1956 | * |
| 1935 | 1957 | * @param int $forum_id Optional. Forum ID. |
| 1936 | 1958 | * @param int|bool $subforums Optional. Number of subforums, or false to query. |
| 1937 | 1959 | * @return int|false Number of subforums, or false on query failure. |
| 1938 | - */ | |
| 1960 | +*/ | |
| 1939 | 1961 | function bbp_update_forum_subforum_count( $forum_id = 0, $subforums = false ) { |
| 1940 | 1962 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 1941 | 1963 | |
| 1942 | 1964 | // Maybe query for counts |
| @@ -1970,9 +1992,9 @@ | ||
| 1970 | 1992 | |
| 1971 | 1993 | /** |
| 1972 | 1994 | * Synchronize child-forum metadata after WordPress reparents deleted children. |
| 1973 | 1995 | * |
| 1974 | - * @since 2.6.17 bbPress (r7453) | |
| 1996 | + * @since 2.6.17 bbPress (r7454) | |
| 1975 | 1997 | * |
| 1976 | 1998 | * @param int $forum_id Deleted forum ID. |
| 1977 | 1999 | * @param WP_Post $forum Deleted forum post object. |
| 1978 | 2000 | */ |
| @@ -1997,9 +2019,9 @@ | ||
| 1997 | 2019 | |
| 1998 | 2020 | /** |
| 1999 | 2021 | * Update a parent forum's subforum count after a child is permanently deleted. |
| 2000 | 2022 | * |
| 2001 | - * @since 2.6.17 bbPress (r7453) | |
| 2023 | + * @since 2.6.17 bbPress (r7454) | |
| 2002 | 2024 | * |
| 2003 | 2025 | * @param int $forum_id Forum ID. |
| 2004 | 2026 | * @param WP_Post|bool $forum Optional. Forum post object. |
| 2005 | 2027 | * @return int|false Updated subforum count, or false if there is no parent. |
| @@ -2019,9 +2041,9 @@ | ||
| 2019 | 2041 | |
| 2020 | 2042 | /** |
| 2021 | 2043 | * Update a parent forum's subforum count after a child changes count status. |
| 2022 | 2044 | * |
| 2023 | - * @since 2.6.17 bbPress (r7453) | |
| 2045 | + * @since 2.6.17 bbPress (r7454) | |
| 2024 | 2046 | * |
| 2025 | 2047 | * @param string $new_status New post status. |
| 2026 | 2048 | * @param string $old_status Old post status. |
| 2027 | 2049 | * @param WP_Post $forum Forum post object. |
| @@ -2048,9 +2070,9 @@ | ||
| 2048 | 2070 | |
| 2049 | 2071 | /** |
| 2050 | 2072 | * Update subforum counts after a forum changes parent or post type. |
| 2051 | 2073 | * |
| 2052 | - * @since 2.6.17 bbPress (r7453) | |
| 2074 | + * @since 2.6.17 bbPress (r7454) | |
| 2053 | 2075 | * |
| 2054 | 2076 | * @param int $forum_id Forum ID. |
| 2055 | 2077 | * @param WP_Post $forum_after Forum object following the update. |
| 2056 | 2078 | * @param WP_Post $forum_before Forum object before the update. |
| @@ -2092,9 +2114,9 @@ | ||
| 2092 | 2114 | /** |
| 2093 | 2115 | * Adjust the total topic count of a forum. |
| 2094 | 2116 | * |
| 2095 | 2117 | * @since 2.0.0 bbPress (r2464) |
| 2096 | - * @since 2.6.17 bbPress (r7467) Optionally update ancestor forum totals. | |
| 2118 | + * @since 2.6.17 bbPress (r7468) Optionally update ancestor forum totals. | |
| 2097 | 2119 | * |
| 2098 | 2120 | * @param int $forum_id Optional. Forum id or topic id. It is checked whether it |
| 2099 | 2121 | * is a topic or a forum. If it's a topic, its parent, |
| 2100 | 2122 | * i.e. the forum is automatically retrieved. |
| @@ -2141,9 +2163,9 @@ | ||
| 2141 | 2163 | * spammed and pending topics). |
| 2142 | 2164 | * |
| 2143 | 2165 | * @since 2.0.0 bbPress (r3349) |
| 2144 | 2166 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2145 | - * @since 2.6.17 bbPress (r7467) Optionally update ancestor forum totals. | |
| 2167 | + * @since 2.6.17 bbPress (r7468) Optionally update ancestor forum totals. | |
| 2146 | 2168 | * |
| 2147 | 2169 | * @param int $forum_id Optional. Topic id to update. |
| 2148 | 2170 | * @param int $topic_count Optional. Set the topic count manually. |
| 2149 | 2171 | * @param bool $update_ancestors Optional. Whether to update ancestor totals. |
| @@ -2226,10 +2248,10 @@ | ||
| 2226 | 2248 | * Adjust the total reply count of a forum. |
| 2227 | 2249 | * |
| 2228 | 2250 | * @since 2.0.0 bbPress (r2615) |
| 2229 | 2251 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects. |
| 2230 | - * @since 2.6.17 bbPress (r7467) Count replies only when their parent topics are public. | |
| 2231 | - * @since 2.6.17 bbPress (r7467) Optionally update ancestor forum totals. | |
| 2252 | + * @since 2.6.17 bbPress (r7468) Count replies only when their parent topics are public. | |
| 2253 | + * @since 2.6.17 bbPress (r7468) Optionally update ancestor forum totals. | |
| 2232 | 2254 | * |
| 2233 | 2255 | * @param int $forum_id Optional. Forum id or topic id. It is checked whether it |
| 2234 | 2256 | * is a topic or a forum. If it's a topic, its parent, |
| 2235 | 2257 | * i.e. the forum is automatically retrieved. |
| @@ -2307,9 +2329,9 @@ | ||
| 2307 | 2329 | /** |
| 2308 | 2330 | * Adjust the total hidden reply count of a forum. |
| 2309 | 2331 | * |
| 2310 | 2332 | * @since 2.6.0 bbPress (r6923) |
| 2311 | - * @since 2.6.17 bbPress (r7467) Optionally update ancestor forum totals. | |
| 2333 | + * @since 2.6.17 bbPress (r7468) Optionally update ancestor forum totals. | |
| 2312 | 2334 | * |
| 2313 | 2335 | * @param int $forum_id Optional. Forum id or topic id. It is checked whether it |
| 2314 | 2336 | * is a topic or a forum. If it's a topic, its parent, |
| 2315 | 2337 | * i.e. the forum is automatically retrieved. |
| @@ -2426,9 +2448,9 @@ | ||
| 2426 | 2448 | |
| 2427 | 2449 | /** |
| 2428 | 2450 | * Walk up the forum hierarchy and update parent forums. |
| 2429 | 2451 | * |
| 2430 | - * @since 2.6.17 bbPress (r7455) | |
| 2452 | + * @since 2.6.17 bbPress (r7456) | |
| 2431 | 2453 | * |
| 2432 | 2454 | * @param array $args Parsed arguments from bbp_update_forum(). |
| 2433 | 2455 | * @return false|null False if there is no parent forum, otherwise null. |
| 2434 | 2456 | */ |
| @@ -2454,9 +2476,9 @@ | ||
| 2454 | 2476 | |
| 2455 | 2477 | /** Helpers *******************************************************************/ |
| 2456 | 2478 | |
| 2457 | 2479 | /** |
| 2458 | - * Return an associative array of available topic statuses. | |
| 2480 | + * Return an associative array of available topic statuses | |
| 2459 | 2481 | * |
| 2460 | 2482 | * Developers note: these statuses are actually stored as meta data, and |
| 2461 | 2483 | * Visibilities are stored in post_status. |
| 2462 | 2484 | * |
| @@ -2461,9 +2483,9 @@ | ||
| 2461 | 2483 | * Visibilities are stored in post_status. |
| 2462 | 2484 | * |
| 2463 | 2485 | * @since 2.4.0 bbPress (r5060) |
| 2464 | 2486 | * |
| 2465 | - * @param int $forum_id Optional. Forum id. | |
| 2487 | + * @param int $forum_id Optional. Forum id. | |
| 2466 | 2488 | * |
| 2467 | 2489 | * @return array |
| 2468 | 2490 | */ |
| 2469 | 2491 | function bbp_get_forum_statuses( $forum_id = 0 ) { |
| @@ -2479,13 +2501,13 @@ | ||
| 2479 | 2501 | ); |
| 2480 | 2502 | } |
| 2481 | 2503 | |
| 2482 | 2504 | /** |
| 2483 | - * Return an associative array of forum type. | |
| 2505 | + * Return an associative array of forum types | |
| 2484 | 2506 | * |
| 2485 | 2507 | * @since 2.4.0 bbPress (r5060) |
| 2486 | 2508 | * |
| 2487 | - * @param int $forum_id Optional. Forum id. | |
| 2509 | + * @param int $forum_id Optional. Forum id. | |
| 2488 | 2510 | * |
| 2489 | 2511 | * @return array |
| 2490 | 2512 | */ |
| 2491 | 2513 | function bbp_get_forum_types( $forum_id = 0 ) { |
| @@ -2508,9 +2530,9 @@ | ||
| 2508 | 2530 | * Statuses are stored in meta data. |
| 2509 | 2531 | * |
| 2510 | 2532 | * @since 2.4.0 bbPress (r5060) |
| 2511 | 2533 | * |
| 2512 | - * @param int $forum_id Optional. Forum id. | |
| 2534 | + * @param int $forum_id Optional. Forum id. | |
| 2513 | 2535 | * |
| 2514 | 2536 | * @return array |
| 2515 | 2537 | */ |
| 2516 | 2538 | function bbp_get_forum_visibilities( $forum_id = 0 ) { |
| @@ -2562,9 +2584,9 @@ | ||
| 2562 | 2584 | |
| 2563 | 2585 | /** |
| 2564 | 2586 | * Return forum statuses included in forum and subforum counts. |
| 2565 | 2587 | * |
| 2566 | - * @since 2.6.17 bbPress (r7453) | |
| 2588 | + * @since 2.6.17 bbPress (r7454) | |
| 2567 | 2589 | * |
| 2568 | 2590 | * @return array |
| 2569 | 2591 | */ |
| 2570 | 2592 | function bbp_get_countable_forum_statuses() { |
| @@ -2576,9 +2598,9 @@ | ||
| 2576 | 2598 | |
| 2577 | 2599 | /** Queries *******************************************************************/ |
| 2578 | 2600 | |
| 2579 | 2601 | /** |
| 2580 | - * Returns the hidden forum ids. | |
| 2602 | + * Returns the hidden forum ids | |
| 2581 | 2603 | * |
| 2582 | 2604 | * Only hidden forum ids are returned. Public and private ids are not. |
| 2583 | 2605 | * |
| 2584 | 2606 | * @since 2.0.0 bbPress (r3008) |
| @@ -2593,9 +2615,9 @@ | ||
| 2593 | 2615 | return (array) apply_filters( 'bbp_get_hidden_forum_ids', $forum_ids ); |
| 2594 | 2616 | } |
| 2595 | 2617 | |
| 2596 | 2618 | /** |
| 2597 | - * Returns the private forum ids. | |
| 2619 | + * Returns the private forum ids | |
| 2598 | 2620 | * |
| 2599 | 2621 | * Only private forum ids are returned. Public and hidden ids are not. |
| 2600 | 2622 | * |
| 2601 | 2623 | * @since 2.0.0 bbPress (r3008) |
| @@ -2613,11 +2635,18 @@ | ||
| 2613 | 2635 | /** |
| 2614 | 2636 | * Returns the forum IDs that should be excluded from various views & queries, |
| 2615 | 2637 | * based on the current user's capabilities. |
| 2616 | 2638 | * |
| 2639 | + * These results are automatically filtered by bbp_allow_forums_of_user(), to | |
| 2640 | + * allow per-forum moderators to see forums that would otherwise be private or | |
| 2641 | + * hidden to them. | |
| 2642 | + * | |
| 2643 | + * If you have a need to filter these results based on your own custom | |
| 2644 | + * engagements API usages, please see: bbp_allow_forums_of_user() | |
| 2645 | + * | |
| 2617 | 2646 | * @since 2.6.0 bbPress (r6426) |
| 2618 | 2647 | * |
| 2619 | - * @return array Forum IDs to exclude, or an empty array. | |
| 2648 | + * @return array Forum IDs to exclude, or an empty array | |
| 2620 | 2649 | */ |
| 2621 | 2650 | function bbp_get_excluded_forum_ids() { |
| 2622 | 2651 | |
| 2623 | 2652 | // Private forums |
| @@ -2697,9 +2726,9 @@ | ||
| 2697 | 2726 | * from a query. |
| 2698 | 2727 | * |
| 2699 | 2728 | * @since 2.0.0 bbPress (r3085) |
| 2700 | 2729 | * |
| 2701 | - * @param string Optional. The type of value to return (string|array|meta_query). | |
| 2730 | + * @param string Optional. The type of value to return. (string|array|meta_query) | |
| 2702 | 2731 | */ |
| 2703 | 2732 | function bbp_exclude_forum_ids( $type = 'string' ) { |
| 2704 | 2733 | |
| 2705 | 2734 | // Setup arrays |
| @@ -2749,9 +2778,9 @@ | ||
| 2749 | 2778 | * to hardcode this logic into each query. It also protects forum content for |
| 2750 | 2779 | * plugins that might be doing their own queries. |
| 2751 | 2780 | * |
| 2752 | 2781 | * @since 2.3.0 bbPress (r4808) |
| 2753 | - * @since 2.6.19 bbPress (r7691) Exclude restricted forum IDs from post__in queries. | |
| 2782 | + * @since 2.6.19 bbPress (r7692) Exclude restricted forum IDs from post__in queries. | |
| 2754 | 2783 | * |
| 2755 | 2784 | * @param WP_Query $posts_query |
| 2756 | 2785 | * |
| 2757 | 2786 | * @return WP_Query |
| @@ -2945,9 +2974,9 @@ | ||
| 2945 | 2974 | * Queries with `suppress_filters` enabled are handled conservatively in |
| 2946 | 2975 | * bbp_pre_get_posts_normalize_forum_visibility(), because this filter will not |
| 2947 | 2976 | * run for those queries. |
| 2948 | 2977 | * |
| 2949 | - * @since 2.6.15 bbPress (r7415) | |
| 2978 | + * @since 2.6.15 bbPress (r7414) | |
| 2950 | 2979 | * |
| 2951 | 2980 | * @param string $where SQL WHERE clause. |
| 2952 | 2981 | * @param WP_Query $posts_query WordPress posts query. |
| 2953 | 2982 | * @return string SQL WHERE clause. |
| @@ -3026,9 +3055,9 @@ | ||
| 3026 | 3055 | |
| 3027 | 3056 | /** |
| 3028 | 3057 | * Filters the forum visibility SQL appended to mixed post-type queries. |
| 3029 | 3058 | * |
| 3030 | - * @since 2.6.15 bbPress (r7415) | |
| 3059 | + * @since 2.6.15 bbPress (r7414) | |
| 3031 | 3060 | * |
| 3032 | 3061 | * @param string $visibility_where Forum visibility SQL clause. |
| 3033 | 3062 | * @param WP_Query $posts_query WordPress posts query. |
| 3034 | 3063 | * @param string[] $post_types bbPress post types protected by the clause. |
| @@ -3046,15 +3075,15 @@ | ||
| 3046 | 3075 | return $where . $visibility_where; |
| 3047 | 3076 | } |
| 3048 | 3077 | |
| 3049 | 3078 | /** |
| 3050 | - * Returns the forum's topic ids. | |
| 3079 | + * Returns the forum's topic ids | |
| 3051 | 3080 | * |
| 3052 | - * Only topics with published and closed statuses are returned. | |
| 3081 | + * Only topics with published and closed statuses are returned | |
| 3053 | 3082 | * |
| 3054 | 3083 | * @since 2.0.0 bbPress (r2895) |
| 3055 | 3084 | * |
| 3056 | - * @param int $forum_id Forum id. | |
| 3085 | + * @param int $forum_id Forum id | |
| 3057 | 3086 | */ |
| 3058 | 3087 | function bbp_forum_query_topic_ids( $forum_id ) { |
| 3059 | 3088 | $topic_ids = bbp_get_public_child_ids( $forum_id, bbp_get_topic_post_type() ); |
| 3060 | 3089 | |
| @@ -3067,9 +3096,9 @@ | ||
| 3067 | 3096 | * |
| 3068 | 3097 | * Only forums with countable statuses are returned. |
| 3069 | 3098 | * |
| 3070 | 3099 | * @since 2.0.0 bbPress (r2895) |
| 3071 | - * @since 2.6.17 bbPress (r7467) Restrict results to countable statuses instead of using | |
| 3100 | + * @since 2.6.17 bbPress (r7468) Restrict results to countable statuses instead of using | |
| 3072 | 3101 | * bbp_get_all_child_ids(). |
| 3073 | 3102 | * |
| 3074 | 3103 | * @param int $forum_id Forum id. |
| 3075 | 3104 | */ |
| @@ -3111,12 +3140,12 @@ | ||
| 3111 | 3140 | return (array) apply_filters( 'bbp_forum_query_subforum_ids', $subforum_ids, $forum_id ); |
| 3112 | 3141 | } |
| 3113 | 3142 | |
| 3114 | 3143 | /** |
| 3115 | - * Returns the forum's last reply id. | |
| 3144 | + * Returns the forum's last reply id | |
| 3116 | 3145 | * |
| 3117 | 3146 | * @since 2.0.0 bbPress (r2895) |
| 3118 | - * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects. | |
| 3147 | + * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects | |
| 3119 | 3148 | * |
| 3120 | 3149 | * @param int $forum_id Forum id. |
| 3121 | 3150 | * @param int $topic_ids Optional. Topic ids. |
| 3122 | 3151 | */ |
| @@ -3162,9 +3191,9 @@ | ||
| 3162 | 3191 | /** Listeners *****************************************************************/ |
| 3163 | 3192 | |
| 3164 | 3193 | /** |
| 3165 | 3194 | * Check if it's a hidden forum or a topic or reply of a hidden forum and if |
| 3166 | - * the user can't view it, then sets a 404. | |
| 3195 | + * the user can't view it, then sets a 404 | |
| 3167 | 3196 | * |
| 3168 | 3197 | * @since 2.0.0 bbPress (r3430) |
| 3169 | 3198 | */ |
| 3170 | 3199 | function bbp_forum_enforce_hidden() { |
| @@ -3199,12 +3228,10 @@ | ||
| 3199 | 3228 | $forum_id = bbp_get_reply_forum_id( $post_id ); |
| 3200 | 3229 | break; |
| 3201 | 3230 | } |
| 3202 | 3231 | |
| 3203 | - // If forum is explicitly hidden and user not capable... | |
| 3232 | + // If forum is explicitly hidden and user not capable, set 404 | |
| 3204 | 3233 | if ( ! empty( $forum_id ) && bbp_is_forum_hidden( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { |
| 3205 | - | |
| 3206 | - // Set 404 status | |
| 3207 | 3234 | bbp_set_404( $wp_query ); |
| 3208 | 3235 | } |
| 3209 | 3236 | } |
| 3210 | 3237 | |
| @@ -3209,9 +3236,9 @@ | ||
| 3209 | 3236 | } |
| 3210 | 3237 | |
| 3211 | 3238 | /** |
| 3212 | 3239 | * Check if it's a private forum or a topic or reply of a private forum and if |
| 3213 | - * the user can't view it, then sets a 404. | |
| 3240 | + * the user can't view it, then sets a 404 | |
| 3214 | 3241 | * |
| 3215 | 3242 | * @since 2.0.0 bbPress (r3430) |
| 3216 | 3243 | */ |
| 3217 | 3244 | function bbp_forum_enforce_private() { |
| @@ -3246,12 +3273,10 @@ | ||
| 3246 | 3273 | $forum_id = bbp_get_reply_forum_id( $post_id ); |
| 3247 | 3274 | break; |
| 3248 | 3275 | } |
| 3249 | 3276 | |
| 3250 | - // If forum is explicitly private and user not capable | |
| 3277 | + // If forum is explicitly hidden and user not capable, set 404 | |
| 3251 | 3278 | if ( ! empty( $forum_id ) && bbp_is_forum_private( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { |
| 3252 | - | |
| 3253 | - // Set 404 status | |
| 3254 | 3279 | bbp_set_404( $wp_query ); |
| 3255 | 3280 | } |
| 3256 | 3281 | } |
| 3257 | 3282 | |
| @@ -3257,9 +3282,9 @@ | ||
| 3257 | 3282 | |
| 3258 | 3283 | /** Permissions ***************************************************************/ |
| 3259 | 3284 | |
| 3260 | 3285 | /** |
| 3261 | - * Redirect if unauthorized user is attempting to edit a forum. | |
| 3286 | + * Redirect if unauthorized user is attempting to edit a forum | |
| 3262 | 3287 | * |
| 3263 | 3288 | * @since 2.1.0 bbPress (r3607) |
| 3264 | 3289 | */ |
| 3265 | 3290 | function bbp_check_forum_edit() { |
| @@ -3275,13 +3300,14 @@ | ||
| 3275 | 3300 | } |
| 3276 | 3301 | } |
| 3277 | 3302 | |
| 3278 | 3303 | /** |
| 3279 | - * Delete all topics (and their replies) for a specific forum ID. | |
| 3304 | + * Delete all topics (and their replies) for a specific forum ID | |
| 3280 | 3305 | * |
| 3281 | 3306 | * @since 2.1.0 bbPress (r3669) |
| 3282 | 3307 | * |
| 3283 | 3308 | * @param int $forum_id |
| 3309 | + * @return If forum is not valid | |
| 3284 | 3310 | */ |
| 3285 | 3311 | function bbp_delete_forum_topics( $forum_id = 0 ) { |
| 3286 | 3312 | |
| 3287 | 3313 | // Validate forum ID |
| @@ -3325,13 +3351,14 @@ | ||
| 3325 | 3351 | unset( $topics ); |
| 3326 | 3352 | } |
| 3327 | 3353 | |
| 3328 | 3354 | /** |
| 3329 | - * Trash all topics inside a forum. | |
| 3355 | + * Trash all topics inside a forum | |
| 3330 | 3356 | * |
| 3331 | 3357 | * @since 2.1.0 bbPress (r3669) |
| 3332 | 3358 | * |
| 3333 | 3359 | * @param int $forum_id |
| 3360 | + * @return If forum is not valid | |
| 3334 | 3361 | */ |
| 3335 | 3362 | function bbp_trash_forum_topics( $forum_id = 0 ) { |
| 3336 | 3363 | |
| 3337 | 3364 | // Validate forum ID |
| @@ -3392,13 +3419,14 @@ | ||
| 3392 | 3419 | unset( $topics ); |
| 3393 | 3420 | } |
| 3394 | 3421 | |
| 3395 | 3422 | /** |
| 3396 | - * Untrash all topics inside a forum. | |
| 3423 | + * Untrash all topics inside a forum | |
| 3397 | 3424 | * |
| 3398 | 3425 | * @since 2.1.0 bbPress (r3669) |
| 3399 | 3426 | * |
| 3400 | 3427 | * @param int $forum_id |
| 3428 | + * @return If forum is not valid | |
| 3401 | 3429 | */ |
| 3402 | 3430 | function bbp_untrash_forum_topics( $forum_id = 0 ) { |
| 3403 | 3431 | |
| 3404 | 3432 | // Validate forum ID |
| @@ -3447,9 +3475,9 @@ | ||
| 3447 | 3475 | do_action( 'bbp_delete_forum', $forum_id ); |
| 3448 | 3476 | } |
| 3449 | 3477 | |
| 3450 | 3478 | /** |
| 3451 | - * Called before trashing a forum. | |
| 3479 | + * Called before trashing a forum | |
| 3452 | 3480 | * |
| 3453 | 3481 | * This function is supplemental to the actual forum being trashed which is |
| 3454 | 3482 | * handled by WordPress core API functions. It is used to clean up after |
| 3455 | 3483 | * a forum that is being trashed. |
| @@ -3466,9 +3494,9 @@ | ||
| 3466 | 3494 | do_action( 'bbp_trash_forum', $forum_id ); |
| 3467 | 3495 | } |
| 3468 | 3496 | |
| 3469 | 3497 | /** |
| 3470 | - * Called before untrashing a forum. | |
| 3498 | + * Called before untrashing a forum | |
| 3471 | 3499 | * |
| 3472 | 3500 | * @since 2.1.0 bbPress (r3669) |
| 3473 | 3501 | */ |
| 3474 | 3502 | function bbp_untrash_forum( $forum_id = 0 ) { |
| @@ -3483,9 +3511,9 @@ | ||
| 3483 | 3511 | |
| 3484 | 3512 | /** After Delete/Trash/Untrash ************************************************/ |
| 3485 | 3513 | |
| 3486 | 3514 | /** |
| 3487 | - * Called after deleting a forum. | |
| 3515 | + * Called after deleting a forum | |
| 3488 | 3516 | * |
| 3489 | 3517 | * Try not to use this action. All meta & taxonomy terms have already been |
| 3490 | 3518 | * deleted, making them impossible to use. |
| 3491 | 3519 | * |
| @@ -3490,9 +3518,9 @@ | ||
| 3490 | 3518 | * deleted, making them impossible to use. |
| 3491 | 3519 | * |
| 3492 | 3520 | * @since 2.1.0 bbPress (r3669) |
| 3493 | 3521 | * @since 2.6.0 bbPress (r6529) Not recommend for usage |
| 3494 | - * @since 2.6.17 bbPress (r7453) Added the `$forum` parameter and passed it to the action. | |
| 3522 | + * @since 2.6.17 bbPress (r7454) Added the `$forum` parameter and passed it to the action. | |
| 3495 | 3523 | * |
| 3496 | 3524 | * @param int $forum_id Forum ID. |
| 3497 | 3525 | * @param WP_Post|bool $forum Optional. Deleted forum post object. |
| 3498 | 3526 | * @return false|null False if the post is not a forum, otherwise null. |
| @@ -3510,9 +3538,9 @@ | ||
| 3510 | 3538 | do_action( 'bbp_deleted_forum', $forum_id, $forum ); |
| 3511 | 3539 | } |
| 3512 | 3540 | |
| 3513 | 3541 | /** |
| 3514 | - * Called after trashing a forum. | |
| 3542 | + * Called after trashing a forum | |
| 3515 | 3543 | * |
| 3516 | 3544 | * @since 2.1.0 bbPress (r3669) |
| 3517 | 3545 | */ |
| 3518 | 3546 | function bbp_trashed_forum( $forum_id = 0 ) { |
| @@ -3525,9 +3553,9 @@ | ||
| 3525 | 3553 | do_action( 'bbp_trashed_forum', $forum_id ); |
| 3526 | 3554 | } |
| 3527 | 3555 | |
| 3528 | 3556 | /** |
| 3529 | - * Called after untrashing a forum. | |
| 3557 | + * Called after untrashing a forum | |
| 3530 | 3558 | * |
| 3531 | 3559 | * @since 2.1.0 bbPress (r3669) |
| 3532 | 3560 | */ |
| 3533 | 3561 | function bbp_untrashed_forum( $forum_id = 0 ) { |