| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * bbPress Topic Functions. | |
| 4 | + * bbPress Topic Functions | |
| 5 | 5 | * |
| 6 | 6 | * @package bbPress |
| 7 | 7 | * @subpackage Functions |
| 8 | 8 | */ |
| @@ -17,12 +17,10 @@ | ||
| 17 | 17 | * for the topic to function properly. |
| 18 | 18 | * |
| 19 | 19 | * @since 2.0.0 bbPress (r2970) |
| 20 | 20 | * |
| 21 | - * @param array $topic_data Forum post data. | |
| 22 | - * @param array $topic_meta Forum meta data. | |
| 23 | - * | |
| 24 | - * @return int|false Topic ID on success, false on failure. | |
| 21 | + * @param array $topic_data Forum post data | |
| 22 | + * @param array $topic_meta Forum meta data | |
| 25 | 23 | */ |
| 26 | 24 | function bbp_insert_topic( $topic_data = array(), $topic_meta = array() ) { |
| 27 | 25 | |
| 28 | 26 | // Parse arguments against default values |
| @@ -98,11 +96,11 @@ | ||
| 98 | 96 | |
| 99 | 97 | /** Post Form Handlers ********************************************************/ |
| 100 | 98 | |
| 101 | 99 | /** |
| 102 | - * Handles the front end topic submission. | |
| 100 | + * Handles the front end topic submission | |
| 103 | 101 | * |
| 104 | - * @param string $action The requested action to compare this function to. | |
| 102 | + * @param string $action The requested action to compare this function to | |
| 105 | 103 | */ |
| 106 | 104 | function bbp_new_topic_handler( $action = '' ) { |
| 107 | 105 | |
| 108 | 106 | // Bail if action is not bbp-new-topic |
| @@ -205,9 +203,9 @@ | ||
| 205 | 203 | |
| 206 | 204 | // Get the forum id |
| 207 | 205 | $posted_forum_id = intval( $_POST['bbp_forum_id'] ); |
| 208 | 206 | |
| 209 | - // Forum id is 0 | |
| 207 | + // Forum id is empty | |
| 210 | 208 | if ( 0 === $posted_forum_id ) { |
| 211 | 209 | bbp_add_error( 'bbp_topic_forum_id', __( '<strong>Error</strong>: Forum ID is missing.', 'bbpress' ) ); |
| 212 | 210 | |
| 213 | 211 | // Forum id is a negative number |
| @@ -234,20 +232,20 @@ | ||
| 234 | 232 | |
| 235 | 233 | // Forum is not a category |
| 236 | 234 | } else { |
| 237 | 235 | |
| 238 | - // Forum not editable by user | |
| 239 | - if ( ! current_user_can( 'edit_forum', $forum_id ) ) { | |
| 236 | + // Forum is closed and user cannot access | |
| 237 | + if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) { | |
| 238 | + bbp_add_error( 'bbp_new_topic_forum_closed', __( '<strong>Error</strong>: This forum has been closed to new topics.', 'bbpress' ) ); | |
| 239 | + } | |
| 240 | 240 | |
| 241 | - // Forum is closed | |
| 242 | - if ( bbp_is_forum_closed( $forum_id ) ) { | |
| 243 | - bbp_add_error( 'bbp_new_topic_forum_closed', __( '<strong>Error</strong>: This forum is closed to new topics.', 'bbpress' ) ); | |
| 244 | - } | |
| 245 | - } | |
| 241 | + // Forum is private and user cannot access | |
| 242 | + if ( bbp_is_forum_private( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { | |
| 243 | + bbp_add_error( 'bbp_new_topic_forum_private', __( '<strong>Error</strong>: This forum is private and you do not have the capability to read or create new topics in it.', 'bbpress' ) ); | |
| 246 | 244 | |
| 247 | - // Forum not readable by user | |
| 248 | - if ( ! current_user_can( 'read_forum', $forum_id ) ) { | |
| 249 | - bbp_add_error( 'bbp_new_topic_forum_read', __( '<strong>Error</strong>: You do not have the capability to read or create new topics in this forum.', 'bbpress' ) ); | |
| 245 | + // Forum is hidden and user cannot access | |
| 246 | + } elseif ( bbp_is_forum_hidden( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { | |
| 247 | + bbp_add_error( 'bbp_new_topic_forum_hidden', __( '<strong>Error</strong>: This forum is hidden and you do not have the capability to read or create new topics in it.', 'bbpress' ) ); | |
| 250 | 248 | } |
| 251 | 249 | } |
| 252 | 250 | } |
| 253 | 251 | |
| @@ -434,13 +432,13 @@ | ||
| 434 | 432 | } |
| 435 | 433 | } |
| 436 | 434 | |
| 437 | 435 | /** |
| 438 | - * Handles the front end edit topic submission. | |
| 436 | + * Handles the front end edit topic submission | |
| 439 | 437 | * |
| 440 | - * @since 2.6.19 bbPress (r7679) Enforce the edit lock on submissions. | |
| 438 | + * @since 2.6.19 bbPress (r7680) Enforce the edit lock on submissions. | |
| 441 | 439 | * |
| 442 | - * @param string $action The requested action to compare this function to. | |
| 440 | + * @param string $action The requested action to compare this function to | |
| 443 | 441 | */ |
| 444 | 442 | function bbp_edit_topic_handler( $action = '' ) { |
| 445 | 443 | |
| 446 | 444 | // Bail if action is not bbp-edit-topic |
| @@ -513,48 +511,16 @@ | ||
| 513 | 511 | bbp_add_error( 'bbp_topic_forum_id', __( '<strong>Error</strong>: Forum ID is missing.', 'bbpress' ) ); |
| 514 | 512 | |
| 515 | 513 | // Forum id was passed |
| 516 | 514 | } elseif ( is_numeric( $_POST['bbp_forum_id'] ) ) { |
| 517 | - | |
| 518 | - // Get the forum id | |
| 519 | - $posted_forum_id = intval( $_POST['bbp_forum_id'] ); | |
| 520 | - | |
| 521 | - // Forum id is 0 | |
| 522 | - if ( 0 === $posted_forum_id ) { | |
| 523 | - bbp_add_error( 'bbp_topic_forum_id', __( '<strong>Error</strong>: Forum ID is missing.', 'bbpress' ) ); | |
| 524 | - | |
| 525 | - // Forum id is a negative number | |
| 526 | - } elseif ( 0 > $posted_forum_id ) { | |
| 527 | - bbp_add_error( 'bbp_topic_forum_id', __( '<strong>Error</strong>: Forum ID cannot be a negative number.', 'bbpress' ) ); | |
| 528 | - | |
| 529 | - // Forum does not exist | |
| 530 | - } elseif ( ! bbp_get_forum( $posted_forum_id ) ) { | |
| 531 | - bbp_add_error( 'bbp_topic_forum_id', __( '<strong>Error</strong>: Forum does not exist.', 'bbpress' ) ); | |
| 532 | - | |
| 533 | - // Use the POST'ed forum id | |
| 534 | - } else { | |
| 535 | - $forum_id = $posted_forum_id; | |
| 536 | - } | |
| 515 | + $forum_id = (int) $_POST['bbp_forum_id']; | |
| 537 | 516 | } |
| 538 | 517 | |
| 539 | 518 | // Current forum this topic is in |
| 540 | 519 | $current_forum_id = bbp_get_topic_forum_id( $topic_id ); |
| 541 | 520 | |
| 542 | - // Forum change | |
| 543 | - if ( $forum_id !== $current_forum_id ) { | |
| 544 | - | |
| 545 | - // User cannot edit current forum | |
| 546 | - if ( ! current_user_can( 'edit_forum', $current_forum_id ) ) { | |
| 547 | - bbp_add_error( 'bbp_edit_topic_forum_move_old', __( '<strong>Error</strong>: You do not have the capability to move topics out of this forum.', 'bbpress' ) ); | |
| 548 | - | |
| 549 | - // User cannot read new forum | |
| 550 | - } elseif ( ! current_user_can( 'read_forum', $forum_id ) ) { | |
| 551 | - bbp_add_error( 'bbp_edit_topic_forum_move_new', __( '<strong>Error</strong>: You do not have the capability to move topics into this forum.', 'bbpress' ) ); | |
| 552 | - } | |
| 553 | - } | |
| 554 | - | |
| 555 | 521 | // Forum exists |
| 556 | - if ( ! empty( $forum_id ) ) { | |
| 522 | + if ( ! empty( $forum_id ) && ( $forum_id !== $current_forum_id ) ) { | |
| 557 | 523 | |
| 558 | 524 | // Forum is a category |
| 559 | 525 | if ( bbp_is_forum_category( $forum_id ) ) { |
| 560 | 526 | bbp_add_error( 'bbp_edit_topic_forum_category', __( '<strong>Error</strong>: This forum is a category. No topics can be created in it.', 'bbpress' ) ); |
| @@ -561,20 +527,20 @@ | ||
| 561 | 527 | |
| 562 | 528 | // Forum is not a category |
| 563 | 529 | } else { |
| 564 | 530 | |
| 565 | - // Forum not editable by user | |
| 566 | - if ( ! current_user_can( 'edit_forum', $forum_id ) ) { | |
| 531 | + // Forum is closed and user cannot access | |
| 532 | + if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) { | |
| 533 | + bbp_add_error( 'bbp_edit_topic_forum_closed', __( '<strong>Error</strong>: This forum has been closed to new topics.', 'bbpress' ) ); | |
| 534 | + } | |
| 567 | 535 | |
| 568 | - // Forum is closed | |
| 569 | - if ( bbp_is_forum_closed( $forum_id ) ) { | |
| 570 | - bbp_add_error( 'bbp_edit_topic_forum_closed', __( '<strong>Error</strong>: This forum is closed to new topics.', 'bbpress' ) ); | |
| 571 | - } | |
| 572 | - } | |
| 536 | + // Forum is private and user cannot access | |
| 537 | + if ( bbp_is_forum_private( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { | |
| 538 | + bbp_add_error( 'bbp_edit_topic_forum_private', __( '<strong>Error</strong>: This forum is private and you do not have the capability to read or create new topics in it.', 'bbpress' ) ); | |
| 573 | 539 | |
| 574 | - // Forum not readable by user | |
| 575 | - if ( ! current_user_can( 'read_forum', $forum_id ) ) { | |
| 576 | - bbp_add_error( 'bbp_edit_topic_forum_read', __( '<strong>Error</strong>: You do not have the capability to read or create new topics in this forum.', 'bbpress' ) ); | |
| 540 | + // Forum is hidden and user cannot access | |
| 541 | + } elseif ( bbp_is_forum_hidden( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { | |
| 542 | + bbp_add_error( 'bbp_edit_topic_forum_hidden', __( '<strong>Error</strong>: This forum is hidden and you do not have the capability to read or create new topics in it.', 'bbpress' ) ); | |
| 577 | 543 | } |
| 578 | 544 | } |
| 579 | 545 | } |
| 580 | 546 | |
| @@ -703,8 +669,12 @@ | ||
| 703 | 669 | do_action( 'bbp_edit_topic', $topic_id, $forum_id, $anonymous_data, $topic_data['post_author'], true /* Is edit */ ); |
| 704 | 670 | |
| 705 | 671 | /** Revisions *********************************************************/ |
| 706 | 672 | |
| 673 | + // Update locks | |
| 674 | + update_post_meta( $topic_id, '_edit_last', bbp_get_current_user_id() ); | |
| 675 | + delete_post_meta( $topic_id, '_edit_lock' ); | |
| 676 | + | |
| 707 | 677 | // Revision Reason |
| 708 | 678 | if ( ! empty( $_POST['bbp_topic_edit_reason'] ) ) { |
| 709 | 679 | $topic_edit_reason = sanitize_text_field( $_POST['bbp_topic_edit_reason'] ); |
| 710 | 680 | } |
| @@ -764,22 +734,28 @@ | ||
| 764 | 734 | /** Errors ****************************************************************/ |
| 765 | 735 | |
| 766 | 736 | } else { |
| 767 | 737 | $append_error = ( is_wp_error( $topic_id ) && $topic_id->get_error_message() ) ? $topic_id->get_error_message() . ' ' : ''; |
| 768 | - /* translators: %s: Error message(s) */ | |
| 769 | - bbp_add_error( 'bbp_topic_error', sprintf( esc_html_e( '<strong>Error</strong>: The following problem(s) have been found with your topic: %s. Please try again.', 'bbpress' ) ), $append_error ); | |
| 738 | + bbp_add_error( | |
| 739 | + 'bbp_topic_error', | |
| 740 | + sprintf( | |
| 741 | + /* translators: %s: Error message */ | |
| 742 | + __( '<strong>Error</strong>: The following problem(s) have been found with your topic: %sPlease try again.', 'bbpress' ), | |
| 743 | + $append_error | |
| 744 | + ) | |
| 745 | + ); | |
| 770 | 746 | } |
| 771 | 747 | } |
| 772 | 748 | |
| 773 | 749 | /** |
| 774 | - * Handle all the extra meta stuff from posting a new topic. | |
| 750 | + * Handle all the extra meta stuff from posting a new topic | |
| 775 | 751 | * |
| 776 | - * @param int $topic_id Optional. Topic id. | |
| 777 | - * @param int $forum_id Optional. Forum id. | |
| 752 | + * @param int $topic_id Optional. Topic id | |
| 753 | + * @param int $forum_id Optional. Forum id | |
| 778 | 754 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 779 | 755 | * supply if supplying $author_id. Should be |
| 780 | 756 | * sanitized (see {@link bbp_filter_anonymous_post_data()} |
| 781 | - * @param int $author_id Author id. | |
| 757 | + * @param int $author_id Author id | |
| 782 | 758 | * @param bool $is_edit Optional. Is the post being edited? Defaults to false. |
| 783 | 759 | */ |
| 784 | 760 | function bbp_update_topic( $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $author_id = 0, $is_edit = false ) { |
| 785 | 761 | |
| @@ -786,34 +762,53 @@ | ||
| 786 | 762 | // Validate the ID's passed from 'bbp_new_topic' action |
| 787 | 763 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 788 | 764 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 789 | 765 | |
| 790 | - // Get the current user ID | |
| 791 | - $user_id = bbp_get_current_user_id(); | |
| 792 | - | |
| 793 | 766 | // Bail if there is no topic |
| 794 | 767 | if ( empty( $topic_id ) ) { |
| 795 | 768 | return; |
| 796 | 769 | } |
| 797 | 770 | |
| 798 | - // Check author_id, fallback to current user ID | |
| 771 | + // Check author_id | |
| 799 | 772 | if ( empty( $author_id ) ) { |
| 800 | - $author_id = $user_id; | |
| 773 | + $author_id = bbp_get_current_user_id(); | |
| 801 | 774 | } |
| 802 | 775 | |
| 803 | - // Check forum_id, fallback to post_parent or meta | |
| 804 | - if ( empty( $forum_id ) ) { | |
| 805 | - $forum_id = bbp_get_topic_forum_id( $topic_id ); | |
| 806 | - } | |
| 807 | - | |
| 808 | - // Update locks | |
| 809 | - update_post_meta( $topic_id, '_edit_last', $user_id ); | |
| 810 | - delete_post_meta( $topic_id, '_edit_lock' ); | |
| 811 | - | |
| 812 | 776 | // Forum/Topic meta (early, for use in downstream functions) |
| 813 | 777 | bbp_update_topic_forum_id( $topic_id, $forum_id ); |
| 814 | 778 | bbp_update_topic_topic_id( $topic_id, $topic_id ); |
| 815 | 779 | |
| 780 | + // Get the topic types | |
| 781 | + $topic_types = bbp_get_topic_types( $topic_id ); | |
| 782 | + | |
| 783 | + // Sticky check after 'bbp_new_topic' action so forum ID meta is set | |
| 784 | + if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array_keys( $topic_types ), true ) ) { | |
| 785 | + | |
| 786 | + // What's the caps? | |
| 787 | + if ( current_user_can( 'moderate', $topic_id ) && ( current_user_can( 'moderate' ) || ( 'super' !== $_POST['bbp_stick_topic'] && ! bbp_is_topic_super_sticky( $topic_id ) ) ) ) { | |
| 788 | + | |
| 789 | + // What's the haps? | |
| 790 | + switch ( $_POST['bbp_stick_topic'] ) { | |
| 791 | + | |
| 792 | + // Sticky in this forum | |
| 793 | + case 'stick' : | |
| 794 | + bbp_stick_topic( $topic_id ); | |
| 795 | + break; | |
| 796 | + | |
| 797 | + // Super sticky in all forums | |
| 798 | + case 'super' : | |
| 799 | + bbp_stick_topic( $topic_id, true ); | |
| 800 | + break; | |
| 801 | + | |
| 802 | + // Unsticky from everywhere | |
| 803 | + case 'unstick' : | |
| 804 | + default : | |
| 805 | + bbp_unstick_topic( $topic_id ); | |
| 806 | + break; | |
| 807 | + } | |
| 808 | + } | |
| 809 | + } | |
| 810 | + | |
| 816 | 811 | // If anonymous post, store name, email, website and ip in post_meta. |
| 817 | 812 | if ( ! empty( $anonymous_data ) ) { |
| 818 | 813 | |
| 819 | 814 | // Update anonymous meta data (not cookies) |
| @@ -845,39 +840,8 @@ | ||
| 845 | 840 | bbp_add_user_subscription( $author_id, $topic_id ); |
| 846 | 841 | } |
| 847 | 842 | } |
| 848 | 843 | |
| 849 | - // Get the topic types | |
| 850 | - $topic_types = bbp_get_topic_types( $topic_id ); | |
| 851 | - | |
| 852 | - // Sticky check after 'bbp_new_topic' action so forum ID meta is set | |
| 853 | - if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array_keys( $topic_types ), true ) ) { | |
| 854 | - | |
| 855 | - // What's the caps? | |
| 856 | - if ( current_user_can( 'moderate', $topic_id ) && ( current_user_can( 'moderate' ) || ( 'super' !== $_POST['bbp_stick_topic'] && ! bbp_is_topic_super_sticky( $topic_id ) ) ) ) { | |
| 857 | - | |
| 858 | - // What's the haps? | |
| 859 | - switch ( $_POST['bbp_stick_topic'] ) { | |
| 860 | - | |
| 861 | - // Sticky in this forum | |
| 862 | - case 'stick' : | |
| 863 | - bbp_stick_topic( $topic_id ); | |
| 864 | - break; | |
| 865 | - | |
| 866 | - // Super sticky in all forums | |
| 867 | - case 'super' : | |
| 868 | - bbp_stick_topic( $topic_id, true ); | |
| 869 | - break; | |
| 870 | - | |
| 871 | - // Unsticky from everywhere | |
| 872 | - case 'unstick' : | |
| 873 | - default : | |
| 874 | - bbp_unstick_topic( $topic_id ); | |
| 875 | - break; | |
| 876 | - } | |
| 877 | - } | |
| 878 | - } | |
| 879 | - | |
| 880 | 844 | // Update associated topic values if this is a new topic |
| 881 | 845 | if ( empty( $is_edit ) ) { |
| 882 | 846 | |
| 883 | 847 | // Update poster activity time |
| @@ -913,12 +877,12 @@ | ||
| 913 | 877 | * function can be costly to run but is necessary to keep everything accurate. |
| 914 | 878 | * |
| 915 | 879 | * @since 2.0.0 bbPress (r2895) |
| 916 | 880 | * |
| 917 | - * @param int $topic_id Topic id. | |
| 918 | - * @param string $last_active_time Optional. Last active time. | |
| 919 | - * @param int $forum_id Optional. Forum id. | |
| 920 | - * @param int $reply_id Optional. Reply id. | |
| 881 | + * @param int $topic_id Topic id | |
| 882 | + * @param string $last_active_time Optional. Last active time | |
| 883 | + * @param int $forum_id Optional. Forum id | |
| 884 | + * @param int $reply_id Optional. Reply id | |
| 921 | 885 | * @param bool $refresh Reset all the previous parameters? Defaults to true. |
| 922 | 886 | */ |
| 923 | 887 | function bbp_update_topic_walker( $topic_id, $last_active_time = '', $forum_id = 0, $reply_id = 0, $refresh = true ) { |
| 924 | 888 | |
| @@ -1122,15 +1086,15 @@ | ||
| 1122 | 1086 | } |
| 1123 | 1087 | } |
| 1124 | 1088 | |
| 1125 | 1089 | /** |
| 1126 | - * Merge topic handler. | |
| 1090 | + * Merge topic handler | |
| 1127 | 1091 | * |
| 1128 | - * Handles the front end merge topic submission. | |
| 1092 | + * Handles the front end merge topic submission | |
| 1129 | 1093 | * |
| 1130 | 1094 | * @since 2.0.0 bbPress (r2756) |
| 1131 | 1095 | * |
| 1132 | - * @param string $action The requested action to compare this function to. | |
| 1096 | + * @param string $action The requested action to compare this function to | |
| 1133 | 1097 | */ |
| 1134 | 1098 | function bbp_merge_topic_handler( $action = '' ) { |
| 1135 | 1099 | |
| 1136 | 1100 | // Bail if action is not bbp-merge-topic |
| @@ -1366,9 +1330,9 @@ | ||
| 1366 | 1330 | * When a topic is merged, update the counts of source and destination topic |
| 1367 | 1331 | * and their forums. |
| 1368 | 1332 | * |
| 1369 | 1333 | * @since 2.0.0 bbPress (r2756) |
| 1370 | - * @since 2.6.17 bbPress (r7467) Recount both forums and topic engagements. | |
| 1334 | + * @since 2.6.17 bbPress (r7468) Recount both forums and topic engagements. | |
| 1371 | 1335 | * |
| 1372 | 1336 | * @param int $destination_topic_id Destination topic id. |
| 1373 | 1337 | * @param int $source_topic_id Source topic id. |
| 1374 | 1338 | * @param int $source_topic_forum_id Source topic's forum id. |
| @@ -1410,15 +1374,16 @@ | ||
| 1410 | 1374 | do_action( 'bbp_merge_topic_count', $destination_topic_id, $source_topic_id, $source_topic_forum_id ); |
| 1411 | 1375 | } |
| 1412 | 1376 | |
| 1413 | 1377 | /** |
| 1414 | - * Split topic handler. | |
| 1378 | + * Split topic handler | |
| 1415 | 1379 | * |
| 1416 | - * Handles the front end split topic submission. | |
| 1380 | + * Handles the front end split topic submission | |
| 1417 | 1381 | * |
| 1418 | 1382 | * @since 2.0.0 bbPress (r2756) |
| 1383 | + * @since 2.6.17 bbPress (r7468) Recount both forums and topic engagements. | |
| 1419 | 1384 | * |
| 1420 | - * @param string $action The requested action to compare this function to. | |
| 1385 | + * @param string $action The requested action to compare this function to | |
| 1421 | 1386 | */ |
| 1422 | 1387 | function bbp_split_topic_handler( $action = '' ) { |
| 1423 | 1388 | |
| 1424 | 1389 | // Bail if action is not 'bbp-split-topic' |
| @@ -1753,19 +1718,19 @@ | ||
| 1753 | 1718 | bbp_redirect( bbp_get_topic_permalink( $destination_topic->ID ) ); |
| 1754 | 1719 | } |
| 1755 | 1720 | |
| 1756 | 1721 | /** |
| 1757 | - * Fix counts on topic split. | |
| 1722 | + * Fix counts on topic split | |
| 1758 | 1723 | * |
| 1759 | 1724 | * When a topic is split, update the counts of source and destination topic |
| 1760 | 1725 | * and their forums. |
| 1761 | 1726 | * |
| 1762 | 1727 | * @since 2.0.0 bbPress (r2756) |
| 1763 | - * @since 2.6.17 bbPress (r7467) Recount both forums and topic engagements. | |
| 1728 | + * @since 2.6.17 bbPress (r7468) Recount both forums and topic engagements. | |
| 1764 | 1729 | * |
| 1765 | - * @param int $from_reply_id From reply id. | |
| 1766 | - * @param int $source_topic_id Source topic id. | |
| 1767 | - * @param int $destination_topic_id Destination topic id. | |
| 1730 | + * @param int $from_reply_id From reply id | |
| 1731 | + * @param int $source_topic_id Source topic id | |
| 1732 | + * @param int $destination_topic_id Destination topic id | |
| 1768 | 1733 | */ |
| 1769 | 1734 | function bbp_split_topic_count( $from_reply_id, $source_topic_id, $destination_topic_id ) { |
| 1770 | 1735 | $source_forum_id = bbp_get_topic_forum_id( $source_topic_id ); |
| 1771 | 1736 | $destination_forum_id = bbp_get_topic_forum_id( $destination_topic_id ); |
| @@ -1806,13 +1771,13 @@ | ||
| 1806 | 1771 | do_action( 'bbp_split_topic_count', $from_reply_id, $source_topic_id, $destination_topic_id ); |
| 1807 | 1772 | } |
| 1808 | 1773 | |
| 1809 | 1774 | /** |
| 1810 | - * Handles the front end tag management (renaming, merging, destroying). | |
| 1775 | + * Handles the front end tag management (renaming, merging, destroying) | |
| 1811 | 1776 | * |
| 1812 | 1777 | * @since 2.1.0 bbPress (r3671) |
| 1813 | 1778 | * |
| 1814 | - * @param string $action The requested action to compare this function to. | |
| 1779 | + * @param string $action The requested action to compare this function to | |
| 1815 | 1780 | */ |
| 1816 | 1781 | function bbp_edit_topic_tag_handler( $action = '' ) { |
| 1817 | 1782 | |
| 1818 | 1783 | // Bail if required POST actions aren't passed |
| @@ -1860,16 +1825,18 @@ | ||
| 1860 | 1825 | bbp_add_error( 'bbp_manage_topic_tag_update_permission', __( '<strong>Error</strong>: You do not have permission to edit the topic tags.', 'bbpress' ) ); |
| 1861 | 1826 | return; |
| 1862 | 1827 | } |
| 1863 | 1828 | |
| 1829 | + // Unsanitized tag name | |
| 1830 | + $name = empty( $_POST['tag-name'] ) ? false : $_POST['tag-name']; | |
| 1831 | + | |
| 1864 | 1832 | // No tag name was provided |
| 1865 | - if ( empty( $_POST['tag-name'] ) || ! is_scalar( $_POST['tag-name'] ) ) { | |
| 1833 | + if ( empty( $_POST['tag-name'] ) || ! $name ) { | |
| 1866 | 1834 | bbp_add_error( 'bbp_manage_topic_tag_update_name', __( '<strong>Error</strong>: You need to enter a tag name.', 'bbpress' ) ); |
| 1867 | 1835 | return; |
| 1868 | 1836 | } |
| 1869 | 1837 | |
| 1870 | 1838 | // Attempt to update the tag |
| 1871 | - $name = $_POST['tag-name']; | |
| 1872 | 1839 | $slug = ! empty( $_POST['tag-slug'] ) ? $_POST['tag-slug'] : ''; |
| 1873 | 1840 | $description = ! empty( $_POST['tag-description'] ) ? $_POST['tag-description'] : ''; |
| 1874 | 1841 | $tag = wp_update_term( |
| 1875 | 1842 | $tag_id, |
| @@ -1910,20 +1877,20 @@ | ||
| 1910 | 1877 | bbp_add_error( 'bbp_manage_topic_tag_merge_permission', __( '<strong>Error</strong>: You do not have permission to edit the topic tags.', 'bbpress' ) ); |
| 1911 | 1878 | return; |
| 1912 | 1879 | } |
| 1913 | 1880 | |
| 1881 | + // Unsanitized name of existing tag | |
| 1882 | + $name = empty( $_POST['tag-existing-name'] ) ? false : $_POST['tag-existing-name']; | |
| 1883 | + | |
| 1914 | 1884 | // No tag name was provided |
| 1915 | - if ( empty( $_POST['tag-existing-name'] ) || ! is_scalar( $_POST['tag-existing-name'] ) ) { | |
| 1885 | + if ( empty( $_POST['tag-existing-name'] ) || ! $name ) { | |
| 1916 | 1886 | bbp_add_error( 'bbp_manage_topic_tag_merge_name', __( '<strong>Error</strong>: You need to enter a tag name.', 'bbpress' ) ); |
| 1917 | 1887 | return; |
| 1918 | 1888 | } |
| 1919 | 1889 | |
| 1920 | - // Unsanitized name of existing tag | |
| 1921 | - $name = $_POST['tag-existing-name']; | |
| 1922 | - | |
| 1923 | 1890 | // If term does not exist, create it |
| 1924 | 1891 | $tag = term_exists( $name, bbp_get_topic_tag_tax_id() ); |
| 1925 | - if ( empty( $tag ) ) { | |
| 1892 | + if ( ! $tag ) { | |
| 1926 | 1893 | $tag = wp_insert_term( $name, bbp_get_topic_tag_tax_id() ); |
| 1927 | 1894 | } |
| 1928 | 1895 | |
| 1929 | 1896 | // Problem inserting the new term |
| @@ -2003,12 +1970,9 @@ | ||
| 2003 | 1970 | |
| 2004 | 1971 | /** Successful Moderation *************************************************/ |
| 2005 | 1972 | |
| 2006 | 1973 | // Redirect back |
| 2007 | - $redirect = ( ! empty( $redirect ) && ! is_wp_error( $redirect ) ) | |
| 2008 | - ? $redirect | |
| 2009 | - : home_url(); | |
| 2010 | - | |
| 1974 | + $redirect = ( ! empty( $redirect ) && ! is_wp_error( $redirect ) ) ? $redirect : home_url(); | |
| 2011 | 1975 | bbp_redirect( $redirect ); |
| 2012 | 1976 | } |
| 2013 | 1977 | |
| 2014 | 1978 | /** Helpers *******************************************************************/ |
| @@ -2013,13 +1977,13 @@ | ||
| 2013 | 1977 | |
| 2014 | 1978 | /** Helpers *******************************************************************/ |
| 2015 | 1979 | |
| 2016 | 1980 | /** |
| 2017 | - * Return an associative array of available topic statuses. | |
| 1981 | + * Return an associative array of available topic statuses | |
| 2018 | 1982 | * |
| 2019 | 1983 | * @since 2.4.0 bbPress (r5060) |
| 2020 | 1984 | * |
| 2021 | - * @param int $topic_id Optional. Topic id. | |
| 1985 | + * @param int $topic_id Optional. Topic id. | |
| 2022 | 1986 | * |
| 2023 | 1987 | * @return array |
| 2024 | 1988 | */ |
| 2025 | 1989 | function bbp_get_topic_statuses( $topic_id = 0 ) { |
| @@ -2038,13 +2002,13 @@ | ||
| 2038 | 2002 | ); |
| 2039 | 2003 | } |
| 2040 | 2004 | |
| 2041 | 2005 | /** |
| 2042 | - * Return an associative array of topic sticky types. | |
| 2006 | + * Return an associative array of topic sticky types | |
| 2043 | 2007 | * |
| 2044 | 2008 | * @since 2.4.0 bbPress (r5060) |
| 2045 | 2009 | * |
| 2046 | - * @param int $topic_id Optional. Topic id. | |
| 2010 | + * @param int $topic_id Optional. Topic id. | |
| 2047 | 2011 | * |
| 2048 | 2012 | * @return array |
| 2049 | 2013 | */ |
| 2050 | 2014 | function bbp_get_topic_types( $topic_id = 0 ) { |
| @@ -2061,13 +2025,13 @@ | ||
| 2061 | 2025 | ); |
| 2062 | 2026 | } |
| 2063 | 2027 | |
| 2064 | 2028 | /** |
| 2065 | - * Return array of available topic toggle actions. | |
| 2029 | + * Return array of available topic toggle actions | |
| 2066 | 2030 | * |
| 2067 | 2031 | * @since 2.6.0 bbPress (r6142) |
| 2068 | 2032 | * |
| 2069 | - * @param int $topic_id Optional. Topic id. | |
| 2033 | + * @param int $topic_id Optional. Topic id. | |
| 2070 | 2034 | * |
| 2071 | 2035 | * @return array |
| 2072 | 2036 | */ |
| 2073 | 2037 | function bbp_get_topic_toggles( $topic_id = 0 ) { |
| @@ -2123,15 +2087,14 @@ | ||
| 2123 | 2087 | |
| 2124 | 2088 | /** Stickies ******************************************************************/ |
| 2125 | 2089 | |
| 2126 | 2090 | /** |
| 2127 | - * Return sticky topics of a forum. | |
| 2091 | + * Return sticky topics of a forum | |
| 2128 | 2092 | * |
| 2129 | 2093 | * @since 2.0.0 bbPress (r2592) |
| 2130 | 2094 | * |
| 2131 | 2095 | * @param int $forum_id Optional. If not passed, super stickies are returned. |
| 2132 | - * | |
| 2133 | - * @return array IDs of sticky topics of a forum or super stickies. | |
| 2096 | + * @return array IDs of sticky topics of a forum or super stickies | |
| 2134 | 2097 | */ |
| 2135 | 2098 | function bbp_get_stickies( $forum_id = 0 ) { |
| 2136 | 2099 | |
| 2137 | 2100 | // Get stickies (maybe super if empty) |
| @@ -2148,13 +2111,13 @@ | ||
| 2148 | 2111 | return (array) apply_filters( 'bbp_get_stickies', $stickies, $forum_id ); |
| 2149 | 2112 | } |
| 2150 | 2113 | |
| 2151 | 2114 | /** |
| 2152 | - * Return topics stuck to front page of the forums. | |
| 2115 | + * Return topics stuck to front page of the forums | |
| 2153 | 2116 | * |
| 2154 | 2117 | * @since 2.0.0 bbPress (r2592) |
| 2155 | 2118 | * |
| 2156 | - * @return array IDs of super sticky topics. | |
| 2119 | + * @return array IDs of super sticky topics | |
| 2157 | 2120 | */ |
| 2158 | 2121 | function bbp_get_super_stickies() { |
| 2159 | 2122 | |
| 2160 | 2123 | // Get super stickies |
| @@ -2172,13 +2135,13 @@ | ||
| 2172 | 2135 | /** Topics Actions ************************************************************/ |
| 2173 | 2136 | |
| 2174 | 2137 | /** |
| 2175 | 2138 | * Handles the front end opening/closing, spamming/unspamming, |
| 2176 | - * sticking/unsticking and trashing/untrashing/deleting of topics. | |
| 2139 | + * sticking/unsticking and trashing/untrashing/deleting of topics | |
| 2177 | 2140 | * |
| 2178 | 2141 | * @since 2.0.0 bbPress (r2727) |
| 2179 | 2142 | * |
| 2180 | - * @param string $action The requested action to compare this function to. | |
| 2143 | + * @param string $action The requested action to compare this function to | |
| 2181 | 2144 | */ |
| 2182 | 2145 | function bbp_toggle_topic_handler( $action = '' ) { |
| 2183 | 2146 | |
| 2184 | 2147 | // Bail if required GET actions aren't passed |
| @@ -2247,9 +2210,9 @@ | ||
| 2247 | 2210 | } |
| 2248 | 2211 | } |
| 2249 | 2212 | |
| 2250 | 2213 | /** |
| 2251 | - * Do the actual topic toggling. | |
| 2214 | + * Do the actual topic toggling | |
| 2252 | 2215 | * |
| 2253 | 2216 | * This function is used by `bbp_toggle_topic_handler()` to do the actual heavy |
| 2254 | 2217 | * lifting when it comes to toggling topic. It only really makes sense to call |
| 2255 | 2218 | * within that context, so if you need to call this function directly, make sure |
| @@ -2411,13 +2374,13 @@ | ||
| 2411 | 2374 | |
| 2412 | 2375 | /** Favorites & Subscriptions *************************************************/ |
| 2413 | 2376 | |
| 2414 | 2377 | /** |
| 2415 | - * Remove a deleted topic from all user favorites. | |
| 2378 | + * Remove a deleted topic from all user favorites | |
| 2416 | 2379 | * |
| 2417 | 2380 | * @since 2.0.0 bbPress (r2652) |
| 2418 | 2381 | * |
| 2419 | - * @param int $topic_id Get the topic id to remove. | |
| 2382 | + * @param int $topic_id Get the topic id to remove | |
| 2420 | 2383 | */ |
| 2421 | 2384 | function bbp_remove_topic_from_all_favorites( $topic_id = 0 ) { |
| 2422 | 2385 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 2423 | 2386 | |
| @@ -2441,13 +2404,13 @@ | ||
| 2441 | 2404 | } |
| 2442 | 2405 | } |
| 2443 | 2406 | |
| 2444 | 2407 | /** |
| 2445 | - * Remove a deleted topic from all user subscriptions. | |
| 2408 | + * Remove a deleted topic from all user subscriptions | |
| 2446 | 2409 | * |
| 2447 | 2410 | * @since 2.0.0 bbPress (r2668) |
| 2448 | 2411 | * |
| 2449 | - * @param int $topic_id Get the topic id to remove. | |
| 2412 | + * @param int $topic_id Get the topic id to remove | |
| 2450 | 2413 | */ |
| 2451 | 2414 | function bbp_remove_topic_from_all_subscriptions( $topic_id = 0 ) { |
| 2452 | 2415 | |
| 2453 | 2416 | // Subscriptions are not active |
| @@ -2467,17 +2430,16 @@ | ||
| 2467 | 2430 | |
| 2468 | 2431 | /** Count Bumpers *************************************************************/ |
| 2469 | 2432 | |
| 2470 | 2433 | /** |
| 2471 | - * Bump the total reply count of a topic. | |
| 2434 | + * Bump the total reply count of a topic | |
| 2472 | 2435 | * |
| 2473 | 2436 | * @since 2.1.0 bbPress (r3826) |
| 2474 | - * @since 2.6.17 bbPress (r7467) Use atomic metadata writes and non-negative counts. | |
| 2437 | + * @since 2.6.17 bbPress (r7468) Use atomic metadata writes and non-negative counts. | |
| 2475 | 2438 | * |
| 2476 | 2439 | * @param int $topic_id Optional. Topic id. |
| 2477 | - * @param int $difference Optional. Default 1. | |
| 2478 | - * | |
| 2479 | - * @return int Topic reply count. | |
| 2440 | + * @param int $difference Optional. Default 1 | |
| 2441 | + * @return int Topic reply count | |
| 2480 | 2442 | */ |
| 2481 | 2443 | function bbp_bump_topic_reply_count( $topic_id = 0, $difference = 1 ) { |
| 2482 | 2444 | |
| 2483 | 2445 | // Bail if no bump |
| @@ -2503,8 +2465,10 @@ | ||
| 2503 | 2465 | * |
| 2504 | 2466 | * @since 2.6.0 bbPress (r6036) |
| 2505 | 2467 | * |
| 2506 | 2468 | * @param int $topic_id The topic id. |
| 2469 | + * | |
| 2470 | + * @return void | |
| 2507 | 2471 | */ |
| 2508 | 2472 | function bbp_increase_topic_reply_count( $topic_id = 0 ) { |
| 2509 | 2473 | |
| 2510 | 2474 | // Bail early if no id is passed. |
| @@ -2533,8 +2497,10 @@ | ||
| 2533 | 2497 | * |
| 2534 | 2498 | * @since 2.6.0 bbPress (r6036) |
| 2535 | 2499 | * |
| 2536 | 2500 | * @param int $topic_id The topic id. |
| 2501 | + * | |
| 2502 | + * @return void | |
| 2537 | 2503 | */ |
| 2538 | 2504 | function bbp_decrease_topic_reply_count( $topic_id = 0 ) { |
| 2539 | 2505 | |
| 2540 | 2506 | // Bail early if no id is passed. |
| @@ -2558,17 +2524,16 @@ | ||
| 2558 | 2524 | bbp_bump_topic_reply_count( $topic_id, -1 ); |
| 2559 | 2525 | } |
| 2560 | 2526 | |
| 2561 | 2527 | /** |
| 2562 | - * Bump the total hidden reply count of a topic. | |
| 2528 | + * Bump the total hidden reply count of a topic | |
| 2563 | 2529 | * |
| 2564 | 2530 | * @since 2.1.0 bbPress (r3826) |
| 2565 | - * @since 2.6.17 bbPress (r7467) Use atomic metadata writes and non-negative counts. | |
| 2531 | + * @since 2.6.17 bbPress (r7468) Use atomic metadata writes and non-negative counts. | |
| 2566 | 2532 | * |
| 2567 | 2533 | * @param int $topic_id Optional. Topic id. |
| 2568 | - * @param int $difference Optional. Default 1. | |
| 2569 | - * | |
| 2570 | - * @return int Topic hidden reply count. | |
| 2534 | + * @param int $difference Optional. Default 1 | |
| 2535 | + * @return int Topic hidden reply count | |
| 2571 | 2536 | */ |
| 2572 | 2537 | function bbp_bump_topic_reply_count_hidden( $topic_id = 0, $difference = 1 ) { |
| 2573 | 2538 | |
| 2574 | 2539 | // Bail if no bump |
| @@ -2594,8 +2559,10 @@ | ||
| 2594 | 2559 | * |
| 2595 | 2560 | * @since 2.6.0 bbPress (r6036) |
| 2596 | 2561 | * |
| 2597 | 2562 | * @param int $topic_id The topic id. |
| 2563 | + * | |
| 2564 | + * @return void | |
| 2598 | 2565 | */ |
| 2599 | 2566 | function bbp_increase_topic_reply_count_hidden( $topic_id = 0 ) { |
| 2600 | 2567 | |
| 2601 | 2568 | // Bail early if no id is passed. |
| @@ -2624,8 +2591,10 @@ | ||
| 2624 | 2591 | * |
| 2625 | 2592 | * @since 2.6.0 bbPress (r6036) |
| 2626 | 2593 | * |
| 2627 | 2594 | * @param int $topic_id The topic id. |
| 2595 | + * | |
| 2596 | + * @return void | |
| 2628 | 2597 | */ |
| 2629 | 2598 | function bbp_decrease_topic_reply_count_hidden( $topic_id = 0 ) { |
| 2630 | 2599 | |
| 2631 | 2600 | // Bail early if no id is passed. |
| @@ -2655,8 +2624,10 @@ | ||
| 2655 | 2624 | * @since 2.6.0 bbPress (r6036) |
| 2656 | 2625 | * |
| 2657 | 2626 | * @param int $topic_id The topic id. |
| 2658 | 2627 | * @param int $forum_id The forum id. |
| 2628 | + * | |
| 2629 | + * @return void | |
| 2659 | 2630 | */ |
| 2660 | 2631 | function bbp_insert_topic_update_counts( $topic_id = 0, $forum_id = 0 ) { |
| 2661 | 2632 | |
| 2662 | 2633 | // If the topic is public, update the forum topic counts. |
| @@ -2675,12 +2646,11 @@ | ||
| 2675 | 2646 | * Update the topic's forum id |
| 2676 | 2647 | * |
| 2677 | 2648 | * @since 2.0.0 bbPress (r2858) |
| 2678 | 2649 | * |
| 2679 | - * @param int $topic_id Optional. Topic id to update. | |
| 2650 | + * @param int $topic_id Optional. Topic id to update | |
| 2680 | 2651 | * @param int $forum_id Optional. Forum id |
| 2681 | - * | |
| 2682 | - * @return int Forum id. | |
| 2652 | + * @return int Forum id | |
| 2683 | 2653 | */ |
| 2684 | 2654 | function bbp_update_topic_forum_id( $topic_id = 0, $forum_id = 0 ) { |
| 2685 | 2655 | |
| 2686 | 2656 | // If it's a reply, then get the parent (topic id) |
| @@ -2700,15 +2670,14 @@ | ||
| 2700 | 2670 | return (int) apply_filters( 'bbp_update_topic_forum_id', $forum_id, $topic_id ); |
| 2701 | 2671 | } |
| 2702 | 2672 | |
| 2703 | 2673 | /** |
| 2704 | - * Update the topic's topic id. | |
| 2674 | + * Update the topic's topic id | |
| 2705 | 2675 | * |
| 2706 | 2676 | * @since 2.0.0 bbPress (r2955) |
| 2707 | 2677 | * |
| 2708 | - * @param int $topic_id Optional. Topic id to update. | |
| 2709 | - * | |
| 2710 | - * @return int Topic id. | |
| 2678 | + * @param int $topic_id Optional. Topic id to update | |
| 2679 | + * @return int Topic id | |
| 2711 | 2680 | */ |
| 2712 | 2681 | function bbp_update_topic_topic_id( $topic_id = 0 ) { |
| 2713 | 2682 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 2714 | 2683 | $topic_id = bbp_update_topic_id( $topic_id, $topic_id ); |
| @@ -2717,16 +2686,15 @@ | ||
| 2717 | 2686 | return (int) apply_filters( 'bbp_update_topic_topic_id', $topic_id ); |
| 2718 | 2687 | } |
| 2719 | 2688 | |
| 2720 | 2689 | /** |
| 2721 | - * Adjust the total reply count of a topic. | |
| 2690 | + * Adjust the total reply count of a topic | |
| 2722 | 2691 | * |
| 2723 | 2692 | * @since 2.0.0 bbPress (r2485) |
| 2724 | 2693 | * |
| 2725 | - * @param int $topic_id Optional. Topic id to update. | |
| 2694 | + * @param int $topic_id Optional. Topic id to update | |
| 2726 | 2695 | * @param int $reply_count Optional. Set the reply count manually. |
| 2727 | - * | |
| 2728 | - * @return int Topic reply count. | |
| 2696 | + * @return int Topic reply count | |
| 2729 | 2697 | */ |
| 2730 | 2698 | function bbp_update_topic_reply_count( $topic_id = 0, $reply_count = false ) { |
| 2731 | 2699 | |
| 2732 | 2700 | // If it's a reply, then get the parent (topic id) |
| @@ -2746,16 +2714,15 @@ | ||
| 2746 | 2714 | } |
| 2747 | 2715 | |
| 2748 | 2716 | /** |
| 2749 | 2717 | * Adjust the total hidden reply count of a topic (hidden includes trashed, |
| 2750 | - * spammed and pending replies). | |
| 2718 | + * spammed and pending replies) | |
| 2751 | 2719 | * |
| 2752 | 2720 | * @since 2.0.0 bbPress (r3349) |
| 2753 | 2721 | * |
| 2754 | - * @param int $topic_id Optional. Topic id to update. | |
| 2755 | - * @param int $reply_count Optional. Set the reply count manually. | |
| 2756 | - * | |
| 2757 | - * @return int Topic hidden reply count. | |
| 2722 | + * @param int $topic_id Optional. Topic id to update | |
| 2723 | + * @param int $reply_count Optional. Set the reply count manually | |
| 2724 | + * @return int Topic hidden reply count | |
| 2758 | 2725 | */ |
| 2759 | 2726 | function bbp_update_topic_reply_count_hidden( $topic_id = 0, $reply_count = false ) { |
| 2760 | 2727 | |
| 2761 | 2728 | // If it's a reply, then get the parent (topic id) |
| @@ -2774,16 +2741,15 @@ | ||
| 2774 | 2741 | return (int) apply_filters( 'bbp_update_topic_reply_count_hidden', $reply_count, $topic_id ); |
| 2775 | 2742 | } |
| 2776 | 2743 | |
| 2777 | 2744 | /** |
| 2778 | - * Update the topic with the last active post ID. | |
| 2745 | + * Update the topic with the last active post ID | |
| 2779 | 2746 | * |
| 2780 | 2747 | * @since 2.0.0 bbPress (r2895) |
| 2781 | 2748 | * |
| 2782 | - * @param int $topic_id Optional. Topic id to update. | |
| 2783 | - * @param int $active_id Optional. Active id. | |
| 2784 | - * | |
| 2785 | - * @return int Active id. | |
| 2749 | + * @param int $topic_id Optional. Topic id to update | |
| 2750 | + * @param int $active_id Optional. active id | |
| 2751 | + * @return int Active id | |
| 2786 | 2752 | */ |
| 2787 | 2753 | function bbp_update_topic_last_active_id( $topic_id = 0, $active_id = 0 ) { |
| 2788 | 2754 | |
| 2789 | 2755 | // If it's a reply, then get the parent (topic id) |
| @@ -2810,16 +2776,15 @@ | ||
| 2810 | 2776 | return (int) apply_filters( 'bbp_update_topic_last_active_id', $active_id, $topic_id ); |
| 2811 | 2777 | } |
| 2812 | 2778 | |
| 2813 | 2779 | /** |
| 2814 | - * Update the topics last active date/time (aka freshness). | |
| 2780 | + * Update the topics last active date/time (aka freshness) | |
| 2815 | 2781 | * |
| 2816 | 2782 | * @since 2.0.0 bbPress (r2895) |
| 2817 | 2783 | * |
| 2818 | 2784 | * @param int $topic_id Optional. Topic id. |
| 2819 | 2785 | * @param string $new_time Optional. New time in mysql format. |
| 2820 | - * | |
| 2821 | - * @return string MySQL timestamp of last active reply. | |
| 2786 | + * @return string MySQL timestamp of last active reply | |
| 2822 | 2787 | */ |
| 2823 | 2788 | function bbp_update_topic_last_active_time( $topic_id = 0, $new_time = '' ) { |
| 2824 | 2789 | |
| 2825 | 2790 | // If it's a reply, then get the parent (topic id) |
| @@ -2841,16 +2806,15 @@ | ||
| 2841 | 2806 | return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $topic_id ); |
| 2842 | 2807 | } |
| 2843 | 2808 | |
| 2844 | 2809 | /** |
| 2845 | - * Update the topic with the most recent reply ID. | |
| 2810 | + * Update the topic with the most recent reply ID | |
| 2846 | 2811 | * |
| 2847 | 2812 | * @since 2.0.0 bbPress (r2627) |
| 2848 | 2813 | * |
| 2849 | - * @param int $topic_id Optional. Topic id to update. | |
| 2850 | - * @param int $reply_id Optional. Reply id. | |
| 2851 | - * | |
| 2852 | - * @return int Reply id. | |
| 2814 | + * @param int $topic_id Optional. Topic id to update | |
| 2815 | + * @param int $reply_id Optional. Reply id | |
| 2816 | + * @return int Reply id | |
| 2853 | 2817 | */ |
| 2854 | 2818 | function bbp_update_topic_last_reply_id( $topic_id = 0, $reply_id = 0 ) { |
| 2855 | 2819 | |
| 2856 | 2820 | // If it's a reply, then get the parent (topic id) |
| @@ -2880,16 +2844,15 @@ | ||
| 2880 | 2844 | return (int) apply_filters( 'bbp_update_topic_last_reply_id', $reply_id, $topic_id ); |
| 2881 | 2845 | } |
| 2882 | 2846 | |
| 2883 | 2847 | /** |
| 2884 | - * Adjust the total voice count of a topic. | |
| 2848 | + * Adjust the total voice count of a topic | |
| 2885 | 2849 | * |
| 2886 | 2850 | * @since 2.0.0 bbPress (r2567) |
| 2887 | - * @since 2.6.0 bbPress (r6516) This must be called after any engagement changes. | |
| 2851 | + * @since 2.6.0 bbPress (r6515) This must be called after any engagement changes | |
| 2888 | 2852 | * |
| 2889 | - * @param int $topic_id Optional. Topic id to update. | |
| 2890 | - * | |
| 2891 | - * @return int Voice count. | |
| 2853 | + * @param int $topic_id Optional. Topic id to update | |
| 2854 | + * @return int Voice count | |
| 2892 | 2855 | */ |
| 2893 | 2856 | function bbp_update_topic_voice_count( $topic_id = 0 ) { |
| 2894 | 2857 | |
| 2895 | 2858 | // If it's a reply, then get the parent (topic id) |
| @@ -2912,15 +2875,14 @@ | ||
| 2912 | 2875 | return (int) apply_filters( 'bbp_update_topic_voice_count', $count, $topic_id ); |
| 2913 | 2876 | } |
| 2914 | 2877 | |
| 2915 | 2878 | /** |
| 2916 | - * Adjust the total anonymous reply count of a topic. | |
| 2879 | + * Adjust the total anonymous reply count of a topic | |
| 2917 | 2880 | * |
| 2918 | 2881 | * @since 2.0.0 bbPress (r2918) |
| 2919 | 2882 | * |
| 2920 | - * @param int $topic_id Optional. Topic id to update. | |
| 2921 | - * | |
| 2922 | - * @return int Anonymous reply count. | |
| 2883 | + * @param int $topic_id Optional. Topic id to update | |
| 2884 | + * @return int Anonymous reply count | |
| 2923 | 2885 | */ |
| 2924 | 2886 | function bbp_update_topic_anonymous_reply_count( $topic_id = 0 ) { |
| 2925 | 2887 | |
| 2926 | 2888 | // If it's a reply, then get the parent (topic id) |
| @@ -2939,9 +2901,9 @@ | ||
| 2939 | 2901 | return (int) apply_filters( 'bbp_update_topic_anonymous_reply_count', $replies, $topic_id ); |
| 2940 | 2902 | } |
| 2941 | 2903 | |
| 2942 | 2904 | /** |
| 2943 | - * Update the revision log of the topic. | |
| 2905 | + * Update the revision log of the topic | |
| 2944 | 2906 | * |
| 2945 | 2907 | * @since 2.0.0 bbPress (r2782) |
| 2946 | 2908 | * |
| 2947 | 2909 | * @param array $args Supports these args: |
| @@ -2948,10 +2910,9 @@ | ||
| 2948 | 2910 | * - topic_id: Topic id |
| 2949 | 2911 | * - author_id: Author id |
| 2950 | 2912 | * - reason: Reason for editing |
| 2951 | 2913 | * - revision_id: Revision id |
| 2952 | - * | |
| 2953 | - * @return mixed False on failure, true on success. | |
| 2914 | + * @return mixed False on failure, true on success | |
| 2954 | 2915 | */ |
| 2955 | 2916 | function bbp_update_topic_revision_log( $args = array() ) { |
| 2956 | 2917 | |
| 2957 | 2918 | // Parse arguments against default values |
| @@ -2985,15 +2946,14 @@ | ||
| 2985 | 2946 | |
| 2986 | 2947 | /** Topic Actions *************************************************************/ |
| 2987 | 2948 | |
| 2988 | 2949 | /** |
| 2989 | - * Closes a topic. | |
| 2950 | + * Closes a topic | |
| 2990 | 2951 | * |
| 2991 | 2952 | * @since 2.0.0 bbPress (r2740) |
| 2992 | 2953 | * |
| 2993 | - * @param int $topic_id Topic id. | |
| 2994 | - * | |
| 2995 | - * @return mixed False or {@link WP_Error} on failure, topic id on success. | |
| 2954 | + * @param int $topic_id Topic id | |
| 2955 | + * @return mixed False or {@link WP_Error} on failure, topic id on success | |
| 2996 | 2956 | */ |
| 2997 | 2957 | function bbp_close_topic( $topic_id = 0 ) { |
| 2998 | 2958 | |
| 2999 | 2959 | // Get topic |
| @@ -3045,15 +3005,14 @@ | ||
| 3045 | 3005 | return $topic_id; |
| 3046 | 3006 | } |
| 3047 | 3007 | |
| 3048 | 3008 | /** |
| 3049 | - * Opens a topic. | |
| 3009 | + * Opens a topic | |
| 3050 | 3010 | * |
| 3051 | 3011 | * @since 2.0.0 bbPress (r2740) |
| 3052 | 3012 | * |
| 3053 | - * @param int $topic_id Topic id. | |
| 3054 | - * | |
| 3055 | - * @return mixed False or {@link WP_Error} on failure, topic id on success. | |
| 3013 | + * @param int $topic_id Topic id | |
| 3014 | + * @return mixed False or {@link WP_Error} on failure, topic id on success | |
| 3056 | 3015 | */ |
| 3057 | 3016 | function bbp_open_topic( $topic_id = 0 ) { |
| 3058 | 3017 | |
| 3059 | 3018 | // Get topic |
| @@ -3106,14 +3065,14 @@ | ||
| 3106 | 3065 | return $topic_id; |
| 3107 | 3066 | } |
| 3108 | 3067 | |
| 3109 | 3068 | /** |
| 3110 | - * Marks a topic as spam. | |
| 3069 | + * Marks a topic as spam | |
| 3111 | 3070 | * |
| 3112 | 3071 | * @since 2.0.0 bbPress (r2740) |
| 3113 | 3072 | * |
| 3114 | - * @param int $topic_id Topic id. | |
| 3115 | - * @return mixed False or {@link WP_Error} on failure, topic id on success. | |
| 3073 | + * @param int $topic_id Topic id | |
| 3074 | + * @return mixed False or {@link WP_Error} on failure, topic id on success | |
| 3116 | 3075 | */ |
| 3117 | 3076 | function bbp_spam_topic( $topic_id = 0 ) { |
| 3118 | 3077 | |
| 3119 | 3078 | // Get the topic |
| @@ -3155,15 +3114,15 @@ | ||
| 3155 | 3114 | return $topic_id; |
| 3156 | 3115 | } |
| 3157 | 3116 | |
| 3158 | 3117 | /** |
| 3159 | - * Trash replies to a topic when it's marked as spam. | |
| 3118 | + * Trash replies to a topic when it's marked as spam | |
| 3160 | 3119 | * |
| 3161 | 3120 | * Usually you'll want to do this before the topic itself is marked as spam. |
| 3162 | 3121 | * |
| 3163 | 3122 | * @since 2.6.0 bbPress (r5406) |
| 3164 | 3123 | * |
| 3165 | - * @param int $topic_id Topic id. | |
| 3124 | + * @param int $topic_id | |
| 3166 | 3125 | */ |
| 3167 | 3126 | function bbp_spam_topic_replies( $topic_id = 0 ) { |
| 3168 | 3127 | |
| 3169 | 3128 | // Validation |
| @@ -3216,11 +3175,9 @@ | ||
| 3216 | 3175 | * Usually you'll want to do this before the topic itself is marked as spam. |
| 3217 | 3176 | * |
| 3218 | 3177 | * @since 2.6.0 bbPress (r5406) |
| 3219 | 3178 | * |
| 3220 | - * @param int $topic_id Topic id. | |
| 3221 | - * | |
| 3222 | - * @return array | |
| 3179 | + * @param int $topic_id | |
| 3223 | 3180 | */ |
| 3224 | 3181 | function bbp_spam_topic_tags( $topic_id = 0 ) { |
| 3225 | 3182 | |
| 3226 | 3183 | // Validation |
| @@ -3251,15 +3208,14 @@ | ||
| 3251 | 3208 | return array( bbp_get_topic_tag_tax_id() => '' ); |
| 3252 | 3209 | } |
| 3253 | 3210 | |
| 3254 | 3211 | /** |
| 3255 | - * Unspams a topic. | |
| 3212 | + * Unspams a topic | |
| 3256 | 3213 | * |
| 3257 | 3214 | * @since 2.0.0 bbPress (r2740) |
| 3258 | 3215 | * |
| 3259 | - * @param int $topic_id Topic id. | |
| 3260 | - * | |
| 3261 | - * @return mixed False or {@link WP_Error} on failure, topic id on success. | |
| 3216 | + * @param int $topic_id Topic id | |
| 3217 | + * @return mixed False or {@link WP_Error} on failure, topic id on success | |
| 3262 | 3218 | */ |
| 3263 | 3219 | function bbp_unspam_topic( $topic_id = 0 ) { |
| 3264 | 3220 | |
| 3265 | 3221 | // Get the topic |
| @@ -3310,9 +3266,9 @@ | ||
| 3310 | 3266 | * Usually you'll want to do this after the topic is unspammed. |
| 3311 | 3267 | * |
| 3312 | 3268 | * @since 2.6.0 bbPress (r5406) |
| 3313 | 3269 | * |
| 3314 | - * @param int $topic_id Topic id. | |
| 3270 | + * @param int $topic_id | |
| 3315 | 3271 | */ |
| 3316 | 3272 | function bbp_unspam_topic_replies( $topic_id = 0 ) { |
| 3317 | 3273 | |
| 3318 | 3274 | // Validation |
| @@ -3345,11 +3301,9 @@ | ||
| 3345 | 3301 | * Usually you'll want to do this before the topic itself is unmarked as spam. |
| 3346 | 3302 | * |
| 3347 | 3303 | * @since 2.6.0 bbPress (r5406) |
| 3348 | 3304 | * |
| 3349 | - * @param int $topic_id Topic id. | |
| 3350 | - * | |
| 3351 | - * @return array | |
| 3305 | + * @param int $topic_id | |
| 3352 | 3306 | */ |
| 3353 | 3307 | function bbp_unspam_topic_tags( $topic_id = 0 ) { |
| 3354 | 3308 | |
| 3355 | 3309 | // Validation |
| @@ -3366,15 +3320,14 @@ | ||
| 3366 | 3320 | return array( bbp_get_topic_tag_tax_id() => $terms ); |
| 3367 | 3321 | } |
| 3368 | 3322 | |
| 3369 | 3323 | /** |
| 3370 | - * Sticks a topic to a forum or front. | |
| 3324 | + * Sticks a topic to a forum or front | |
| 3371 | 3325 | * |
| 3372 | 3326 | * @since 2.0.0 bbPress (r2754) |
| 3373 | 3327 | * |
| 3374 | - * @param int $topic_id Optional. Topic id. | |
| 3328 | + * @param int $topic_id Optional. Topic id | |
| 3375 | 3329 | * @param int $super Should we make the topic a super sticky? |
| 3376 | - * | |
| 3377 | 3330 | * @return bool True on success, false on failure |
| 3378 | 3331 | */ |
| 3379 | 3332 | function bbp_stick_topic( $topic_id = 0, $super = false ) { |
| 3380 | 3333 | |
| @@ -3422,15 +3375,14 @@ | ||
| 3422 | 3375 | return (bool) $success; |
| 3423 | 3376 | } |
| 3424 | 3377 | |
| 3425 | 3378 | /** |
| 3426 | - * Approves a pending topic. | |
| 3379 | + * Approves a pending topic | |
| 3427 | 3380 | * |
| 3428 | 3381 | * @since 2.6.0 bbPress (r5503) |
| 3429 | 3382 | * |
| 3430 | - * @param int $topic_id Topic id. | |
| 3431 | - * | |
| 3432 | - * @return mixed False or {@link WP_Error} on failure, topic id on success. | |
| 3383 | + * @param int $topic_id Topic id | |
| 3384 | + * @return mixed False or {@link WP_Error} on failure, topic id on success | |
| 3433 | 3385 | */ |
| 3434 | 3386 | function bbp_approve_topic( $topic_id = 0 ) { |
| 3435 | 3387 | |
| 3436 | 3388 | // Get topic |
| @@ -3469,15 +3421,14 @@ | ||
| 3469 | 3421 | return $topic_id; |
| 3470 | 3422 | } |
| 3471 | 3423 | |
| 3472 | 3424 | /** |
| 3473 | - * Unapproves a topic. | |
| 3425 | + * Unapproves a topic | |
| 3474 | 3426 | * |
| 3475 | 3427 | * @since 2.6.0 bbPress (r5503) |
| 3476 | 3428 | * |
| 3477 | - * @param int $topic_id Topic id. | |
| 3478 | - * | |
| 3479 | - * @return mixed False or {@link WP_Error} on failure, topic id on success. | |
| 3429 | + * @param int $topic_id Topic id | |
| 3430 | + * @return mixed False or {@link WP_Error} on failure, topic id on success | |
| 3480 | 3431 | */ |
| 3481 | 3432 | function bbp_unapprove_topic( $topic_id = 0 ) { |
| 3482 | 3433 | |
| 3483 | 3434 | // Get topic |
| @@ -3513,14 +3464,13 @@ | ||
| 3513 | 3464 | return $topic_id; |
| 3514 | 3465 | } |
| 3515 | 3466 | |
| 3516 | 3467 | /** |
| 3517 | - * Unsticks a topic both from front and it's forum. | |
| 3468 | + * Unsticks a topic both from front and it's forum | |
| 3518 | 3469 | * |
| 3519 | 3470 | * @since 2.0.0 bbPress (r2754) |
| 3520 | 3471 | * |
| 3521 | - * @param int $topic_id Optional. Topic id. | |
| 3522 | - * | |
| 3472 | + * @param int $topic_id Optional. Topic id | |
| 3523 | 3473 | * @return bool Always true. |
| 3524 | 3474 | */ |
| 3525 | 3475 | function bbp_unstick_topic( $topic_id = 0 ) { |
| 3526 | 3476 | |
| @@ -3528,9 +3478,9 @@ | ||
| 3528 | 3478 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 3529 | 3479 | $super = bbp_is_topic_super_sticky( $topic_id ); |
| 3530 | 3480 | $forum_id = empty( $super ) ? bbp_get_topic_forum_id( $topic_id ) : 0; |
| 3531 | 3481 | $stickies = bbp_get_stickies( $forum_id ); |
| 3532 | - $offset = array_search( $topic_id, $stickies, true ); | |
| 3482 | + $offset = array_search( $topic_id, $stickies ); | |
| 3533 | 3483 | |
| 3534 | 3484 | do_action( 'bbp_unstick_topic', $topic_id ); |
| 3535 | 3485 | |
| 3536 | 3486 | // Nothing to unstick |
| @@ -3572,12 +3522,8 @@ | ||
| 3572 | 3522 | * |
| 3573 | 3523 | * This function is supplemental to the actual topic deletion which is |
| 3574 | 3524 | * handled by WordPress core API functions. It is used to clean up after |
| 3575 | 3525 | * a topic that is being deleted. |
| 3576 | - * | |
| 3577 | - * @since 2.0.0 bbPress (r2895) | |
| 3578 | - * | |
| 3579 | - * @param int $topic_id Topic id. | |
| 3580 | 3526 | */ |
| 3581 | 3527 | function bbp_delete_topic( $topic_id = 0 ) { |
| 3582 | 3528 | |
| 3583 | 3529 | // Validate topic ID |
| @@ -3590,15 +3536,15 @@ | ||
| 3590 | 3536 | do_action( 'bbp_delete_topic', $topic_id ); |
| 3591 | 3537 | } |
| 3592 | 3538 | |
| 3593 | 3539 | /** |
| 3594 | - * Delete replies to a topic when it's deleted. | |
| 3540 | + * Delete replies to a topic when it's deleted | |
| 3595 | 3541 | * |
| 3596 | 3542 | * Usually you'll want to do this before the topic itself is deleted. |
| 3597 | 3543 | * |
| 3598 | 3544 | * @since 2.6.0 bbPress (r5406) |
| 3599 | 3545 | * |
| 3600 | - * @param int $topic_id Topic id. | |
| 3546 | + * @param int $topic_id | |
| 3601 | 3547 | */ |
| 3602 | 3548 | function bbp_delete_topic_replies( $topic_id = 0 ) { |
| 3603 | 3549 | |
| 3604 | 3550 | // Validate topic ID |
| @@ -3635,17 +3581,13 @@ | ||
| 3635 | 3581 | } |
| 3636 | 3582 | } |
| 3637 | 3583 | |
| 3638 | 3584 | /** |
| 3639 | - * Called before trashing a topic. | |
| 3585 | + * Called before trashing a topic | |
| 3640 | 3586 | * |
| 3641 | 3587 | * This function is supplemental to the actual topic being trashed which is |
| 3642 | 3588 | * handled by WordPress core API functions. It is used to clean up after |
| 3643 | 3589 | * a topic that is being trashed. |
| 3644 | - * | |
| 3645 | - * @since 2.0.0 bbPress (r2895) | |
| 3646 | - * | |
| 3647 | - * @param int $topic_id Topic id. | |
| 3648 | 3590 | */ |
| 3649 | 3591 | function bbp_trash_topic( $topic_id = 0 ) { |
| 3650 | 3592 | |
| 3651 | 3593 | // Validate topic ID |
| @@ -3664,9 +3606,9 @@ | ||
| 3664 | 3606 | * Usually you'll want to do this before the topic itself is marked as spam. |
| 3665 | 3607 | * |
| 3666 | 3608 | * @since 2.6.0 bbPress (r5406) |
| 3667 | 3609 | * |
| 3668 | - * @param int $topic_id Topic id. | |
| 3610 | + * @param int $topic_id | |
| 3669 | 3611 | */ |
| 3670 | 3612 | function bbp_trash_topic_replies( $topic_id = 0 ) { |
| 3671 | 3613 | |
| 3672 | 3614 | // Validate topic ID |
| @@ -3712,13 +3654,9 @@ | ||
| 3712 | 3654 | } |
| 3713 | 3655 | } |
| 3714 | 3656 | |
| 3715 | 3657 | /** |
| 3716 | - * Called before untrashing a topic. | |
| 3717 | - * | |
| 3718 | - * @since 2.0.0 bbPress (r2895) | |
| 3719 | - * | |
| 3720 | - * @param int $topic_id Topic id. | |
| 3658 | + * Called before untrashing a topic | |
| 3721 | 3659 | */ |
| 3722 | 3660 | function bbp_untrash_topic( $topic_id = 0 ) { |
| 3723 | 3661 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 3724 | 3662 | |
| @@ -3735,9 +3673,9 @@ | ||
| 3735 | 3673 | * Usually you'll want to do this after the topic is unspammed. |
| 3736 | 3674 | * |
| 3737 | 3675 | * @since 2.6.0 bbPress (r5406) |
| 3738 | 3676 | * |
| 3739 | - * @param int $topic_id Topic id. | |
| 3677 | + * @param int $topic_id | |
| 3740 | 3678 | */ |
| 3741 | 3679 | function bbp_untrash_topic_replies( $topic_id = 0 ) { |
| 3742 | 3680 | |
| 3743 | 3681 | // Validation |
| @@ -3766,13 +3704,11 @@ | ||
| 3766 | 3704 | |
| 3767 | 3705 | /** After Delete/Trash/Untrash ************************************************/ |
| 3768 | 3706 | |
| 3769 | 3707 | /** |
| 3770 | - * Called after deleting a topic. | |
| 3708 | + * Called after deleting a topic | |
| 3771 | 3709 | * |
| 3772 | 3710 | * @since 2.0.0 bbPress (r2895) |
| 3773 | - * | |
| 3774 | - * @param int $topic_id Topic id. | |
| 3775 | 3711 | */ |
| 3776 | 3712 | function bbp_deleted_topic( $topic_id = 0 ) { |
| 3777 | 3713 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 3778 | 3714 | |
| @@ -3783,13 +3719,11 @@ | ||
| 3783 | 3719 | do_action( 'bbp_deleted_topic', $topic_id ); |
| 3784 | 3720 | } |
| 3785 | 3721 | |
| 3786 | 3722 | /** |
| 3787 | - * Called after trashing a topic. | |
| 3723 | + * Called after trashing a topic | |
| 3788 | 3724 | * |
| 3789 | 3725 | * @since 2.0.0 bbPress (r2895) |
| 3790 | - * | |
| 3791 | - * @param int $topic_id Topic id. | |
| 3792 | 3726 | */ |
| 3793 | 3727 | function bbp_trashed_topic( $topic_id = 0 ) { |
| 3794 | 3728 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 3795 | 3729 | |
| @@ -3800,13 +3734,11 @@ | ||
| 3800 | 3734 | do_action( 'bbp_trashed_topic', $topic_id ); |
| 3801 | 3735 | } |
| 3802 | 3736 | |
| 3803 | 3737 | /** |
| 3804 | - * Called after untrashing a topic. | |
| 3738 | + * Called after untrashing a topic | |
| 3805 | 3739 | * |
| 3806 | 3740 | * @since 2.0.0 bbPress (r2895) |
| 3807 | - * | |
| 3808 | - * @param int $topic_id Topic id. | |
| 3809 | 3741 | */ |
| 3810 | 3742 | function bbp_untrashed_topic( $topic_id = 0 ) { |
| 3811 | 3743 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 3812 | 3744 | |
| @@ -3819,15 +3751,12 @@ | ||
| 3819 | 3751 | |
| 3820 | 3752 | /** Settings ******************************************************************/ |
| 3821 | 3753 | |
| 3822 | 3754 | /** |
| 3823 | - * Return the topics per page setting. | |
| 3755 | + * Return the topics per page setting | |
| 3824 | 3756 | * |
| 3825 | 3757 | * @since 2.1.0 bbPress (r3572) |
| 3826 | - * | |
| 3827 | - * @param int $default Optional. Number of topics per page if no value exists. | |
| 3828 | - * | |
| 3829 | - * @return int Number of topics per page. | |
| 3758 | + * @return int | |
| 3830 | 3759 | */ |
| 3831 | 3760 | function bbp_get_topics_per_page( $default = 15 ) { |
| 3832 | 3761 | |
| 3833 | 3762 | // Get database option and cast as integer |
| @@ -3842,15 +3771,14 @@ | ||
| 3842 | 3771 | return (int) apply_filters( 'bbp_get_topics_per_page', $retval, $default ); |
| 3843 | 3772 | } |
| 3844 | 3773 | |
| 3845 | 3774 | /** |
| 3846 | - * Return the topics per RSS page setting. | |
| 3775 | + * Return the topics per RSS page setting | |
| 3847 | 3776 | * |
| 3848 | 3777 | * @since 2.1.0 bbPress (r3572) |
| 3849 | 3778 | * |
| 3850 | 3779 | * @param int $default Default replies per page (25) |
| 3851 | - * | |
| 3852 | - * @return int Number of topics per RSS page. | |
| 3780 | + * @return int | |
| 3853 | 3781 | */ |
| 3854 | 3782 | function bbp_get_topics_per_rss_page( $default = 25 ) { |
| 3855 | 3783 | |
| 3856 | 3784 | // Get database option and cast as integer |
| @@ -3867,13 +3795,13 @@ | ||
| 3867 | 3795 | |
| 3868 | 3796 | /** Topic Tags ****************************************************************/ |
| 3869 | 3797 | |
| 3870 | 3798 | /** |
| 3871 | - * Get topic tags for a specific topic ID. | |
| 3799 | + * Get topic tags for a specific topic ID | |
| 3872 | 3800 | * |
| 3873 | 3801 | * @since 2.6.0 bbPress (r5837) |
| 3874 | 3802 | * |
| 3875 | - * @param int $topic_id Topic id. | |
| 3803 | + * @param int $topic_id | |
| 3876 | 3804 | * |
| 3877 | 3805 | * @return string |
| 3878 | 3806 | */ |
| 3879 | 3807 | function bbp_get_topic_tags( $topic_id = 0 ) { |
| @@ -3885,14 +3813,14 @@ | ||
| 3885 | 3813 | return apply_filters( 'bbp_get_topic_tags', $topic_tags, $topic_id ); |
| 3886 | 3814 | } |
| 3887 | 3815 | |
| 3888 | 3816 | /** |
| 3889 | - * Get topic tags for a specific topic ID. | |
| 3817 | + * Get topic tags for a specific topic ID | |
| 3890 | 3818 | * |
| 3891 | 3819 | * @since 2.2.0 bbPress (r4166) |
| 3892 | 3820 | * |
| 3893 | - * @param int $topic_id Topic id. | |
| 3894 | - * @param string $sep Separator string. | |
| 3821 | + * @param int $topic_id | |
| 3822 | + * @param string $sep | |
| 3895 | 3823 | * |
| 3896 | 3824 | * @return string |
| 3897 | 3825 | */ |
| 3898 | 3826 | function bbp_get_topic_tag_names( $topic_id = 0, $sep = ', ' ) { |
| @@ -3908,9 +3836,9 @@ | ||
| 3908 | 3836 | |
| 3909 | 3837 | /** |
| 3910 | 3838 | * Get the topic-tag names a user is allowed to set on a topic. |
| 3911 | 3839 | * |
| 3912 | - * @since 2.6.17 bbPress (r7509) | |
| 3840 | + * @since 2.6.17 bbPress (r7510) | |
| 3913 | 3841 | * |
| 3914 | 3842 | * @param int $topic_id Topic id. |
| 3915 | 3843 | * @param string $tag_names Comma-separated topic-tag names. |
| 3916 | 3844 | * @param int|bool $user_id User id. Default false for the current user. |
| @@ -4012,9 +3940,9 @@ | ||
| 4012 | 3940 | |
| 4013 | 3941 | /** Autoembed *****************************************************************/ |
| 4014 | 3942 | |
| 4015 | 3943 | /** |
| 4016 | - * Check if autoembeds are enabled and hook them in if so. | |
| 3944 | + * Check if autoembeds are enabled and hook them in if so | |
| 4017 | 3945 | * |
| 4018 | 3946 | * @since 2.1.0 bbPress (r3753) |
| 4019 | 3947 | * |
| 4020 | 3948 | * @global WP_Embed $wp_embed |
| @@ -4065,10 +3993,10 @@ | ||
| 4065 | 3993 | |
| 4066 | 3994 | <title><?php echo $title; // Already escaped ?></title> |
| 4067 | 3995 | <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> |
| 4068 | 3996 | <link><?php self_link(); ?></link> |
| 4069 | - <description><?php //?></description><?php // phpcs:ignore ?> | |
| 4070 | - <lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate> | |
| 3997 | + <description><?php // ?></description> | |
| 3998 | + <lastBuildDate><?php echo date( 'r' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date ?></lastBuildDate> | |
| 4071 | 3999 | <generator><?php echo esc_url_raw( 'https://bbpress.org/?v=' . convert_chars( bbp_get_version() ) ); ?></generator> |
| 4072 | 4000 | <language><?php bloginfo_rss( 'language' ); ?></language> |
| 4073 | 4001 | |
| 4074 | 4002 | <?php do_action( 'bbp_feed_head' ); ?> |
| @@ -4089,17 +4017,13 @@ | ||
| 4089 | 4017 | <?php if ( ! bbp_get_password_required_id( bbp_get_topic_id() ) ) : ?> |
| 4090 | 4018 | |
| 4091 | 4019 | <description> |
| 4092 | 4020 | <![CDATA[ |
| 4093 | - <p> | |
| 4094 | - <?php | |
| 4095 | - printf( | |
| 4021 | + <p><?php printf( | |
| 4096 | 4022 | /* translators: %s: Number of replies to the topic */ |
| 4097 | - esc_html__( 'Replies: %s', 'bbpress' ), | |
| 4098 | - bbp_get_topic_reply_count() | |
| 4099 | - ); | |
| 4100 | - ?> | |
| 4101 | - </p> | |
| 4023 | + esc_html__( 'Replies: %s', 'bbpress' ), | |
| 4024 | + bbp_get_topic_reply_count() | |
| 4025 | + ); ?></p> | |
| 4102 | 4026 | <?php echo bbp_escape_feed_cdata( bbp_get_topic_content() ); ?> |
| 4103 | 4027 | ]]> |
| 4104 | 4028 | </description> |
| 4105 | 4029 | |
| @@ -4125,9 +4049,9 @@ | ||
| 4125 | 4049 | |
| 4126 | 4050 | /** Permissions ***************************************************************/ |
| 4127 | 4051 | |
| 4128 | 4052 | /** |
| 4129 | - * Redirect if unauthorized user is attempting to edit a topic. | |
| 4053 | + * Redirect if unauthorized user is attempting to edit a topic | |
| 4130 | 4054 | * |
| 4131 | 4055 | * @since 2.1.0 bbPress (r3607) |
| 4132 | 4056 | */ |
| 4133 | 4057 | function bbp_check_topic_edit() { |
| @@ -4143,9 +4067,9 @@ | ||
| 4143 | 4067 | } |
| 4144 | 4068 | } |
| 4145 | 4069 | |
| 4146 | 4070 | /** |
| 4147 | - * Redirect if unauthorized user is attempting to edit a topic tag. | |
| 4071 | + * Redirect if unauthorized user is attempting to edit a topic tag | |
| 4148 | 4072 | * |
| 4149 | 4073 | * @since 2.1.0 bbPress (r3607) |
| 4150 | 4074 | */ |
| 4151 | 4075 | function bbp_check_topic_tag_edit() { |