PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
← All changes | includes/replies/functions.php +144 -192 trunk2.6.17 View file →
@@ -17,12 +17,10 @@
17 17 * for the reply to function properly.
18 18 *
19 19 * @since 2.0.0 bbPress (r3349)
20 20 *
21 - * @param array $reply_data Forum post data.
22 - * @param array $reply_meta Forum meta data.
23 - *
24 - * @return int|false Reply ID on success, false on failure.
21 + * @param array $reply_data Forum post data
22 + * @param array $reply_meta Forum meta data
25 23 */
26 24 function bbp_insert_reply( $reply_data = array(), $reply_meta = array() ) {
27 25
28 26 // Parse arguments against default values
@@ -103,8 +101,10 @@
103 101 *
104 102 * @param int $reply_id The reply id.
105 103 * @param int $topic_id The topic id.
106 104 * @param int $forum_id The forum id.
105 + *
106 + * @return void
107 107 */
108 108 function bbp_insert_reply_update_counts( $reply_id = 0, $topic_id = 0, $forum_id = 0 ) {
109 109
110 110 // If the reply is public, update the reply counts.
@@ -121,15 +121,15 @@
121 121
122 122 /** Post Form Handlers ********************************************************/
123 123
124 124 /**
125 - * Handles the front end reply submission.
125 + * Handles the front end reply submission
126 126 *
127 127 * @since 2.0.0 bbPress (r2574)
128 128 *
129 129 * @param string $action The requested action to compare this function to
130 130 * id, anonymous data, reply author, edit (false), and
131 - * the reply to id.
131 + * the reply to id
132 132 */
133 133 function bbp_new_reply_handler( $action = '' ) {
134 134
135 135 // Bail if action is not bbp-new-reply
@@ -186,14 +186,10 @@
186 186
187 187 // Get the topic id
188 188 $posted_topic_id = intval( $_POST['bbp_topic_id'] );
189 189
190 - // Topic id is 0
191 - if ( 0 === $posted_topic_id ) {
192 - bbp_add_error( 'bbp_reply_topic_id', __( '<strong>Error</strong>: Topic ID is missing.', 'bbpress' ) );
193 -
194 190 // Topic id is a negative number
195 - } elseif ( 0 > $posted_topic_id ) {
191 + if ( 0 > $posted_topic_id ) {
196 192 bbp_add_error( 'bbp_reply_topic_id', __( '<strong>Error</strong>: Topic ID cannot be a negative number.', 'bbpress' ) );
197 193
198 194 // Topic does not exist
199 195 } elseif ( ! bbp_get_topic( $posted_topic_id ) ) {
@@ -233,19 +229,19 @@
233 229
234 230 // Get the forum id
235 231 $posted_forum_id = intval( $_POST['bbp_forum_id'] );
236 232
237 - // Forum id is 0
233 + // Forum id is empty
238 234 if ( 0 === $posted_forum_id ) {
239 - bbp_add_error( 'bbp_reply_forum_id', __( '<strong>Error</strong>: Forum ID is missing.', 'bbpress' ) );
235 + bbp_add_error( 'bbp_topic_forum_id', __( '<strong>Error</strong>: Forum ID is missing.', 'bbpress' ) );
240 236
241 237 // Forum id is a negative number
242 238 } elseif ( 0 > $posted_forum_id ) {
243 - bbp_add_error( 'bbp_reply_forum_id', __( '<strong>Error</strong>: Forum ID cannot be a negative number.', 'bbpress' ) );
239 + bbp_add_error( 'bbp_topic_forum_id', __( '<strong>Error</strong>: Forum ID cannot be a negative number.', 'bbpress' ) );
244 240
245 241 // Forum does not exist
246 242 } elseif ( ! bbp_get_forum( $posted_forum_id ) ) {
247 - bbp_add_error( 'bbp_reply_forum_id', __( '<strong>Error</strong>: Forum does not exist.', 'bbpress' ) );
243 + bbp_add_error( 'bbp_topic_forum_id', __( '<strong>Error</strong>: Forum does not exist.', 'bbpress' ) );
248 244
249 245 }
250 246 }
251 247 }
@@ -259,15 +255,11 @@
259 255
260 256 // Forum is not a category
261 257 } else {
262 258
263 - // Forum not editable by user
264 - if ( ! current_user_can( 'edit_forum', $forum_id ) ) {
265 -
266 - // Forum is closed
267 - if ( bbp_is_forum_closed( $forum_id ) ) {
268 - bbp_add_error( 'bbp_new_reply_forum_closed', __( '<strong>Error</strong>: This forum is closed to new replies.', 'bbpress' ) );
269 - }
259 + // Forum is closed and user cannot access
260 + if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) {
261 + bbp_add_error( 'bbp_new_reply_forum_closed', __( '<strong>Error</strong>: This forum has been closed to new replies.', 'bbpress' ) );
270 262 }
271 263
272 264 // Forum not readable by user
273 265 if ( ! current_user_can( 'read_forum', $forum_id ) ) {
@@ -284,24 +276,8 @@
284 276 remove_filter( 'bbp_new_reply_pre_content', 'bbp_encode_bad', 10 );
285 277 remove_filter( 'bbp_new_reply_pre_content', 'bbp_filter_kses', 30 );
286 278 }
287 279
288 - /** Reply To **************************************************************/
289 -
290 - // Handle Reply To of the reply; $_REQUEST for non-JS submissions
291 - if ( isset( $_REQUEST['bbp_reply_to'] ) && is_numeric( $_REQUEST['bbp_reply_to'] ) ) {
292 - $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] );
293 - }
294 -
295 - // Check the Reply To ID
296 - if ( ! empty( $reply_to ) ) {
297 -
298 - // User cannot read parent reply ID
299 - if ( ! current_user_can( 'read_reply', $reply_to ) ) {
300 - bbp_add_error( 'bbp_new_reply_reply_to', __( '<strong>Error</strong>: You do not have the capability to read or create new replies to this reply.', 'bbpress' ) );
301 - }
302 - }
303 -
304 280 /** Reply Title ***********************************************************/
305 281
306 282 if ( ! empty( $_POST['bbp_reply_title'] ) ) {
307 283 $reply_title = sanitize_text_field( $_POST['bbp_reply_title'] );
@@ -364,8 +340,15 @@
364 340 if ( bbp_is_topic_pending( $topic_id ) || ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {
365 341 $reply_status = bbp_get_pending_status_id();
366 342 }
367 343
344 + /** Reply To **************************************************************/
345 +
346 + // Handle Reply To of the reply; $_REQUEST for non-JS submissions
347 + if ( isset( $_REQUEST['bbp_reply_to'] ) ) {
348 + $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] );
349 + }
350 +
368 351 /** Topic Closed **********************************************************/
369 352
370 353 // If topic is closed, moderators can still reply
371 354 if ( bbp_is_topic_closed( $topic_id ) && ! current_user_can( 'moderate', $topic_id ) ) {
@@ -520,13 +503,13 @@
520 503 }
521 504 }
522 505
523 506 /**
524 - * Handles the front end edit reply submission.
507 + * Handles the front end edit reply submission
525 508 *
526 509 * @param string $action The requested action to compare this function to
527 - * id, anonymous data, reply author, bool true (for edit),
528 - * and the reply to id.
510 + * id, anonymous data, reply author, bool true (for edit),
511 + * and the reply to id
529 512 */
530 513 function bbp_edit_reply_handler( $action = '' ) {
531 514
532 515 // Bail if action is not bbp-edit-reply
@@ -590,13 +573,8 @@
590 573 /** Reply Topic ***********************************************************/
591 574
592 575 $topic_id = bbp_get_reply_topic_id( $reply_id );
593 576
594 - // User cannot read parent topic ID
595 - if ( ! current_user_can( 'read_topic', $topic_id ) ) {
596 - bbp_add_error( 'bbp_edit_reply_topic_read', __( '<strong>Error</strong>: You do not have the capability to read or create new replies in this topic.', 'bbpress' ) );
597 - }
598 -
599 577 /** Topic Forum ***********************************************************/
600 578
601 579 $forum_id = bbp_get_topic_forum_id( $topic_id );
602 580
@@ -609,45 +587,24 @@
609 587
610 588 // Forum is not a category
611 589 } else {
612 590
613 - // Forum not editable by user
614 - if ( ! current_user_can( 'edit_forum', $forum_id ) ) {
591 + // Forum is closed and user cannot access
592 + if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) {
593 + bbp_add_error( 'bbp_edit_reply_forum_closed', __( '<strong>Error</strong>: This forum has been closed to new replies.', 'bbpress' ) );
594 + }
615 595
616 - // Forum is closed
617 - if ( bbp_is_forum_closed( $forum_id ) ) {
618 - bbp_add_error( 'bbp_edit_reply_forum_closed', __( '<strong>Error</strong>: This forum is closed to new replies.', 'bbpress' ) );
619 - }
620 - }
596 + // Forum is private and user cannot access
597 + if ( bbp_is_forum_private( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) {
598 + bbp_add_error( 'bbp_edit_reply_forum_private', __( '<strong>Error</strong>: This forum is private and you do not have the capability to read or create new replies in it.', 'bbpress' ) );
621 599
622 - // Forum not readable by user
623 - if ( ! current_user_can( 'read_forum', $forum_id ) ) {
624 - bbp_add_error( 'bbp_edit_reply_forum_read', __( '<strong>Error</strong>: You do not have the capability to read or create new replies in this forum.', 'bbpress' ) );
600 + // Forum is hidden and user cannot access
601 + } elseif ( bbp_is_forum_hidden( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) {
602 + bbp_add_error( 'bbp_edit_reply_forum_hidden', __( '<strong>Error</strong>: This forum is hidden and you do not have the capability to read or create new replies in it.', 'bbpress' ) );
625 603 }
626 604 }
627 605 }
628 606
629 - /** Reply To **************************************************************/
630 -
631 - $reply_to = bbp_get_reply_to( $reply_id );
632 -
633 - // Maybe sanitize Reply To, using $_REQUEST for non-JS submissions
634 - if ( isset( $_REQUEST['bbp_reply_to'] ) && is_numeric( $_REQUEST['bbp_reply_to'] ) ) {
635 - $reply_to = intval( $_REQUEST['bbp_reply_to'] );
636 - }
637 -
638 - // Validate Reply To
639 - $reply_to = bbp_validate_reply_to( $reply_to, $reply_id );
640 -
641 - // Check the Reply To ID
642 - if ( ! empty( $reply_to ) ) {
643 -
644 - // User cannot read parent reply ID
645 - if ( ! current_user_can( 'read_reply', $reply_to ) ) {
646 - bbp_add_error( 'bbp_edit_reply_reply_to', __( '<strong>Error</strong>: You do not have the capability to read or create new replies to this reply.', 'bbpress' ) );
647 - }
648 - }
649 -
650 607 /** Reply Title ***********************************************************/
651 608
652 609 if ( ! empty( $_POST['bbp_reply_title'] ) ) {
653 610 $reply_title = sanitize_text_field( $_POST['bbp_reply_title'] );
@@ -705,8 +662,17 @@
705 662 bbp_add_error( 'bbp_edit_reply_status', __( '<strong>Error</strong>: You do not have permission to do that.', 'bbpress' ) );
706 663 }
707 664 }
708 665
666 + /** Reply To **************************************************************/
667 +
668 + // Handle Reply To of the reply; $_REQUEST for non-JS submissions
669 + if ( isset( $_REQUEST['bbp_reply_to'] ) && current_user_can( 'moderate', $reply_id ) ) {
670 + $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'], $reply_id );
671 + } elseif ( bbp_thread_replies() ) {
672 + $reply_to = bbp_get_reply_to( $reply_id );
673 + }
674 +
709 675 /** Topic Tags ************************************************************/
710 676
711 677 // Replace allowed terms
712 678 if ( bbp_allow_topic_tags() && isset( $_POST['bbp_topic_tags'] ) ) {
@@ -779,8 +745,12 @@
779 745 do_action( 'bbp_edit_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_data['post_author'], true, $reply_to );
780 746
781 747 /** Revisions *********************************************************/
782 748
749 + // Update locks
750 + update_post_meta( $reply_id, '_edit_last', bbp_get_current_user_id() );
751 + delete_post_meta( $reply_id, '_edit_lock' );
752 +
783 753 // Revision Reason
784 754 if ( ! empty( $_POST['bbp_reply_edit_reason'] ) ) {
785 755 $reply_edit_reason = sanitize_text_field( $_POST['bbp_reply_edit_reason'] );
786 756 }
@@ -825,26 +795,31 @@
825 795 } else {
826 796 $append_error = ( is_wp_error( $reply_id ) && $reply_id->get_error_message() )
827 797 ? $reply_id->get_error_message() . ' '
828 798 : '';
829 -
830 - /* translators: %s: Error message(s) */
831 - bbp_add_error( 'bbp_reply_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found with your reply: %s. Please try again.', 'bbpress' ) ), $append_error );
799 + bbp_add_error(
800 + 'bbp_reply_error',
801 + sprintf(
802 + /* translators: %s: Error message */
803 + __( '<strong>Error</strong>: The following problem(s) have been found with your reply: %sPlease try again.', 'bbpress' ),
804 + $append_error
805 + )
806 + );
832 807 }
833 808 }
834 809
835 810 /**
836 - * Handle all the extra meta stuff from posting a new reply or editing a reply.
811 + * Handle all the extra meta stuff from posting a new reply or editing a reply
837 812 *
838 - * @param int $reply_id Optional. Reply id.
839 - * @param int $topic_id Optional. Topic id.
840 - * @param int $forum_id Optional. Forum id.
813 + * @param int $reply_id Optional. Reply id
814 + * @param int $topic_id Optional. Topic id
815 + * @param int $forum_id Optional. Forum id
841 816 * @param array $anonymous_data Optional - if it's an anonymous post. Do not
842 817 * supply if supplying $author_id. Should be
843 - * sanitized (see {@link bbp_filter_anonymous_post_data()}.
844 - * @param int $author_id Author id.
818 + * sanitized (see {@link bbp_filter_anonymous_post_data()}
819 + * @param int $author_id Author id
845 820 * @param bool $is_edit Optional. Is the post being edited? Defaults to false.
846 - * @param int $reply_to Optional. Reply to id.
821 + * @param int $reply_to Optional. Reply to id
847 822 */
848 823 function bbp_update_reply( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $author_id = 0, $is_edit = false, $reply_to = 0 ) {
849 824
850 825 // Validate the ID's passed from 'bbp_new_reply' action
@@ -852,40 +827,28 @@
852 827 $topic_id = bbp_get_topic_id( $topic_id );
853 828 $forum_id = bbp_get_forum_id( $forum_id );
854 829 $reply_to = bbp_validate_reply_to( $reply_to, $reply_id );
855 830
856 - // Get the current user ID
857 - $user_id = bbp_get_current_user_id();
858 -
859 831 // Bail if there is no reply
860 832 if ( empty( $reply_id ) ) {
861 833 return;
862 834 }
863 835
864 - // Check author_id, fallback to current user ID
836 + // Check author_id
865 837 if ( empty( $author_id ) ) {
866 - $author_id = $user_id;
838 + $author_id = bbp_get_current_user_id();
867 839 }
868 840
869 - // Check topic_id, fallback to post_parent or meta
841 + // Check topic_id
870 842 if ( empty( $topic_id ) ) {
871 843 $topic_id = bbp_get_reply_topic_id( $reply_id );
872 844 }
873 845
874 - // Check forum_id, fallback to post_parent or meta
846 + // Check forum_id
875 847 if ( ! empty( $topic_id ) && empty( $forum_id ) ) {
876 848 $forum_id = bbp_get_topic_forum_id( $topic_id );
877 849 }
878 850
879 - // Update locks
880 - update_post_meta( $reply_id, '_edit_last', $user_id );
881 - delete_post_meta( $reply_id, '_edit_lock' );
882 -
883 - // Forum/Topic meta (early, for use in downstream functions)
884 - bbp_update_reply_forum_id( $reply_id, $forum_id );
885 - bbp_update_reply_topic_id( $reply_id, $topic_id );
886 - bbp_update_reply_to ( $reply_id, $reply_to );
887 -
888 851 // If anonymous post, store name, email, website and ip in post_meta.
889 852 if ( ! empty( $anonymous_data ) ) {
890 853
891 854 // Update anonymous meta data (not cookies)
@@ -917,8 +880,13 @@
917 880 bbp_add_user_subscription( $author_id, $topic_id );
918 881 }
919 882 }
920 883
884 + // Reply meta relating to reply position in tree
885 + bbp_update_reply_forum_id( $reply_id, $forum_id );
886 + bbp_update_reply_topic_id( $reply_id, $topic_id );
887 + bbp_update_reply_to ( $reply_id, $reply_to );
888 +
921 889 // Update associated topic values if this is a new reply
922 890 if ( empty( $is_edit ) ) {
923 891
924 892 // Update poster activity time
@@ -938,18 +906,18 @@
938 906 wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' );
939 907 }
940 908
941 909 /**
942 - * Walk up the ancestor tree from the current reply, and update all the counts.
910 + * Walk up the ancestor tree from the current reply, and update all the counts
943 911 *
944 912 * @since 2.0.0 bbPress (r2884)
945 913 *
946 - * @param int $reply_id Optional. Reply id.
947 - * @param string $last_active_time Optional. Last active time.
948 - * @param int $forum_id Optional. Forum id.
949 - * @param int $topic_id Optional. Topic id.
914 + * @param int $reply_id Optional. Reply id
915 + * @param string $last_active_time Optional. Last active time
916 + * @param int $forum_id Optional. Forum id
917 + * @param int $topic_id Optional. Topic id
950 918 * @param bool $refresh If set to true, unsets all the previous parameters.
951 - * Defaults to true.
919 + * Defaults to true
952 920 */
953 921 function bbp_update_reply_walker( $reply_id, $last_active_time = '', $forum_id = 0, $topic_id = 0, $refresh = true ) {
954 922
955 923 // Verify the reply ID
@@ -1049,15 +1017,15 @@
1049 1017
1050 1018 /** Reply Updaters ************************************************************/
1051 1019
1052 1020 /**
1053 - * Update the reply with its forum id it is in.
1021 + * Update the reply with its forum id it is in
1054 1022 *
1055 1023 * @since 2.0.0 bbPress (r2855)
1056 1024 *
1057 - * @param int $reply_id Optional. Reply id to update.
1058 - * @param int $forum_id Optional. Forum id.
1059 - * @return bool The forum id of the reply.
1025 + * @param int $reply_id Optional. Reply id to update
1026 + * @param int $forum_id Optional. Forum id
1027 + * @return bool The forum id of the reply
1060 1028 */
1061 1029 function bbp_update_reply_forum_id( $reply_id = 0, $forum_id = 0 ) {
1062 1030
1063 1031 // Validation
@@ -1092,15 +1060,15 @@
1092 1060 return (int) apply_filters( 'bbp_update_reply_forum_id', $retval, $reply_id, $forum_id );
1093 1061 }
1094 1062
1095 1063 /**
1096 - * Update the reply with its topic id it is in.
1064 + * Update the reply with its topic id it is in
1097 1065 *
1098 1066 * @since 2.0.0 bbPress (r2855)
1099 1067 *
1100 - * @param int $reply_id Optional. Reply id to update.
1101 - * @param int $topic_id Optional. Topic id.
1102 - * @return bool The topic id of the reply.
1068 + * @param int $reply_id Optional. Reply id to update
1069 + * @param int $topic_id Optional. Topic id
1070 + * @return bool The topic id of the reply
1103 1071 */
1104 1072 function bbp_update_reply_topic_id( $reply_id = 0, $topic_id = 0 ) {
1105 1073
1106 1074 // Validation
@@ -1135,15 +1103,15 @@
1135 1103 return (int) apply_filters( 'bbp_update_reply_topic_id', $retval, $reply_id, $topic_id );
1136 1104 }
1137 1105
1138 1106 /*
1139 - * Update the meta data with its parent reply-to id, of a reply.
1107 + * Update the meta data with its parent reply-to id, of a reply
1140 1108 *
1141 1109 * @since 2.4.0 bbPress (r4944)
1142 1110 *
1143 - * @param int $reply_id Reply id to update.
1144 - * @param int $reply_to Optional. Reply to id.
1145 - * @return bool The parent reply id of the reply.
1111 + * @param int $reply_id Reply id to update
1112 + * @param int $reply_to Optional. Reply to id
1113 + * @return bool The parent reply id of the reply
1146 1114 */
1147 1115 function bbp_update_reply_to( $reply_id = 0, $reply_to = 0 ) {
1148 1116
1149 1117 // Validation
@@ -1167,9 +1135,9 @@
1167 1135 return (int) apply_filters( 'bbp_update_reply_to', $reply_to, $reply_id );
1168 1136 }
1169 1137
1170 1138 /**
1171 - * Get all ancestors to a reply.
1139 + * Get all ancestors to a reply
1172 1140 *
1173 1141 * Because settings can be changed, this function does not care if hierarchical
1174 1142 * replies are active or to what depth.
1175 1143 *
@@ -1197,9 +1165,8 @@
1197 1165 $id = $reply_to;
1198 1166 $ancestors = array( $reply_to );
1199 1167
1200 1168 // Get parent reply
1201 - // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
1202 1169 while ( $ancestor = bbp_get_reply( $id ) ) {
1203 1170
1204 1171 // Does parent have a parent?
1205 1172 $grampy_id = bbp_get_reply_to( $ancestor->ID );
@@ -1218,9 +1185,9 @@
1218 1185 return (array) apply_filters( 'bbp_get_reply_ancestors', $ancestors, $reply_id );
1219 1186 }
1220 1187
1221 1188 /**
1222 - * Update the revision log of the reply.
1189 + * Update the revision log of the reply
1223 1190 *
1224 1191 * @since 2.0.0 bbPress (r2782)
1225 1192 *
1226 1193 * @param array $args Supports these args:
@@ -1227,9 +1194,9 @@
1227 1194 * - reply_id: reply id
1228 1195 * - author_id: Author id
1229 1196 * - reason: Reason for editing
1230 1197 * - revision_id: Revision id
1231 - * @return mixed False on failure, true on success.
1198 + * @return mixed False on failure, true on success
1232 1199 */
1233 1200 function bbp_update_reply_revision_log( $args = array() ) {
1234 1201
1235 1202 // Parse arguments against default values
@@ -1264,15 +1231,15 @@
1264 1231 return apply_filters( 'bbp_update_reply_revision_log', $revision_log, $r['reply_id'] );
1265 1232 }
1266 1233
1267 1234 /**
1268 - * Move reply handler.
1235 + * Move reply handler
1269 1236 *
1270 - * Handles the front end move reply submission.
1237 + * Handles the front end move reply submission
1271 1238 *
1272 1239 * @since 2.3.0 bbPress (r4521)
1273 1240 *
1274 - * @param string $action The requested action to compare this function to.
1241 + * @param string $action The requested action to compare this function to
1275 1242 */
1276 1243 function bbp_move_reply_handler( $action = '' ) {
1277 1244
1278 1245 // Bail if action is not 'bbp-move-reply'
@@ -1536,9 +1503,9 @@
1536 1503 bbp_redirect( bbp_get_topic_permalink( $destination_topic->ID ) );
1537 1504 }
1538 1505
1539 1506 /**
1540 - * Fix counts on reply move.
1507 + * Fix counts on reply move
1541 1508 *
1542 1509 * When a reply is moved, update the counts of source and destination topic
1543 1510 * and their forums.
1544 1511 *
@@ -1544,11 +1511,11 @@
1544 1511 *
1545 1512 * @since 2.3.0 bbPress (r4521)
1546 1513 * @since 2.6.17 Recount both forums and topic engagements.
1547 1514 *
1548 - * @param int $move_reply_id Move reply id.
1549 - * @param int $source_topic_id Source topic id.
1550 - * @param int $destination_topic_id Destination topic id.
1515 + * @param int $move_reply_id Move reply id
1516 + * @param int $source_topic_id Source topic id
1517 + * @param int $destination_topic_id Destination topic id
1551 1518 */
1552 1519 function bbp_move_reply_count( $move_reply_id, $source_topic_id, $destination_topic_id ) {
1553 1520 $source_forum_id = bbp_get_topic_forum_id( $source_topic_id );
1554 1521 $destination_forum_id = bbp_get_topic_forum_id( $destination_topic_id );
@@ -1592,13 +1559,13 @@
1592 1559 /** Reply Actions *************************************************************/
1593 1560
1594 1561 /**
1595 1562 * Handles the front end spamming/unspamming and trashing/untrashing/deleting of
1596 - * replies.
1563 + * replies
1597 1564 *
1598 1565 * @since 2.0.0 bbPress (r2740)
1599 1566 *
1600 - * @param string $action The requested action to compare this function to.
1567 + * @param string $action The requested action to compare this function to
1601 1568 */
1602 1569 function bbp_toggle_reply_handler( $action = '' ) {
1603 1570
1604 1571 // Bail if required GET actions aren't passed
@@ -1661,9 +1628,9 @@
1661 1628 }
1662 1629 }
1663 1630
1664 1631 /**
1665 - * Do the actual reply toggling.
1632 + * Do the actual reply toggling
1666 1633 *
1667 1634 * This function is used by `bbp_toggle_reply_handler()` to do the actual heavy
1668 1635 * lifting when it comes to toggling replies. It only really makes sense to call
1669 1636 * within that context, so if you need to call this function directly, make sure
@@ -1768,13 +1735,13 @@
1768 1735
1769 1736 /** Helpers *******************************************************************/
1770 1737
1771 1738 /**
1772 - * Return an associative array of available reply statuses.
1739 + * Return an associative array of available reply statuses
1773 1740 *
1774 1741 * @since 2.6.0 bbPress (r5399)
1775 1742 *
1776 - * @param int $reply_id Optional. Reply id.
1743 + * @param int $reply_id Optional. Reply id.
1777 1744 *
1778 1745 * @return array
1779 1746 */
1780 1747 function bbp_get_reply_statuses( $reply_id = 0 ) {
@@ -1792,13 +1759,13 @@
1792 1759 );
1793 1760 }
1794 1761
1795 1762 /**
1796 - * Return array of available reply toggle actions.
1763 + * Return array of available reply toggle actions
1797 1764 *
1798 1765 * @since 2.6.0 bbPress (r6133)
1799 1766 *
1800 - * @param int $reply_id Optional. Reply id.
1767 + * @param int $reply_id Optional. Reply id.
1801 1768 *
1802 1769 * @return array
1803 1770 */
1804 1771 function bbp_get_reply_toggles( $reply_id = 0 ) {
@@ -1851,14 +1818,14 @@
1851 1818
1852 1819 /** Reply Actions *************************************************************/
1853 1820
1854 1821 /**
1855 - * Marks a reply as spam.
1822 + * Marks a reply as spam
1856 1823 *
1857 1824 * @since 2.0.0 bbPress (r2740)
1858 1825 *
1859 - * @param int $reply_id Reply id.
1860 - * @return mixed False or {@link WP_Error} on failure, reply id on success.
1826 + * @param int $reply_id Reply id
1827 + * @return mixed False or {@link WP_Error} on failure, reply id on success
1861 1828 */
1862 1829 function bbp_spam_reply( $reply_id = 0 ) {
1863 1830
1864 1831 // Get reply
@@ -1894,14 +1861,14 @@
1894 1861 return $reply_id;
1895 1862 }
1896 1863
1897 1864 /**
1898 - * Unspams a reply.
1865 + * Unspams a reply
1899 1866 *
1900 1867 * @since 2.0.0 bbPress (r2740)
1901 1868 *
1902 - * @param int $reply_id Reply id.
1903 - * @return mixed False or {@link WP_Error} on failure, reply id on success.
1869 + * @param int $reply_id Reply id
1870 + * @return mixed False or {@link WP_Error} on failure, reply id on success
1904 1871 */
1905 1872 function bbp_unspam_reply( $reply_id = 0 ) {
1906 1873
1907 1874 // Get reply
@@ -1942,14 +1909,14 @@
1942 1909 return $reply_id;
1943 1910 }
1944 1911
1945 1912 /**
1946 - * Approves a reply.
1913 + * Approves a reply
1947 1914 *
1948 1915 * @since 2.6.0 bbPress (r5506)
1949 1916 *
1950 - * @param int $reply_id Reply id.
1951 - * @return mixed False or {@link WP_Error} on failure, reply id on success.
1917 + * @param int $reply_id Reply id
1918 + * @return mixed False or {@link WP_Error} on failure, reply id on success
1952 1919 */
1953 1920 function bbp_approve_reply( $reply_id = 0 ) {
1954 1921
1955 1922 // Get reply
@@ -1988,14 +1955,14 @@
1988 1955 return $reply_id;
1989 1956 }
1990 1957
1991 1958 /**
1992 - * Unapproves a reply.
1959 + * Unapproves a reply
1993 1960 *
1994 1961 * @since 2.6.0 bbPress (r5506)
1995 1962 *
1996 - * @param int $reply_id Reply id.
1997 - * @return mixed False or {@link WP_Error} on failure, reply id on success.
1963 + * @param int $reply_id Reply id
1964 + * @return mixed False or {@link WP_Error} on failure, reply id on success
1998 1965 */
1999 1966 function bbp_unapprove_reply( $reply_id = 0 ) {
2000 1967
2001 1968 // Get reply
@@ -2033,11 +2000,9 @@
2033 2000
2034 2001 /** Before Delete/Trash/Untrash ***********************************************/
2035 2002
2036 2003 /**
2037 - * Called before deleting a reply.
2038 - *
2039 - * @since 2.0.0 bbPress (r2895)
2004 + * Called before deleting a reply
2040 2005 */
2041 2006 function bbp_delete_reply( $reply_id = 0 ) {
2042 2007 $reply_id = bbp_get_reply_id( $reply_id );
2043 2008
@@ -2048,11 +2013,9 @@
2048 2013 do_action( 'bbp_delete_reply', $reply_id );
2049 2014 }
2050 2015
2051 2016 /**
2052 - * Called before trashing a reply.
2053 - *
2054 - * @since 2.0.0 bbPress (r2895)
2017 + * Called before trashing a reply
2055 2018 */
2056 2019 function bbp_trash_reply( $reply_id = 0 ) {
2057 2020 $reply_id = bbp_get_reply_id( $reply_id );
2058 2021
@@ -2063,11 +2026,9 @@
2063 2026 do_action( 'bbp_trash_reply', $reply_id );
2064 2027 }
2065 2028
2066 2029 /**
2067 - * Called before untrashing (restoring) a reply.
2068 - *
2069 - * @since 2.0.0 bbPress (r2895)
2030 + * Called before untrashing (restoring) a reply
2070 2031 */
2071 2032 function bbp_untrash_reply( $reply_id = 0 ) {
2072 2033 $reply_id = bbp_get_reply_id( $reply_id );
2073 2034
@@ -2080,9 +2041,9 @@
2080 2041
2081 2042 /** After Delete/Trash/Untrash ************************************************/
2082 2043
2083 2044 /**
2084 - * Called after deleting a reply.
2045 + * Called after deleting a reply
2085 2046 *
2086 2047 * @since 2.0.0 bbPress (r2993)
2087 2048 */
2088 2049 function bbp_deleted_reply( $reply_id = 0 ) {
@@ -2095,9 +2056,9 @@
2095 2056 do_action( 'bbp_deleted_reply', $reply_id );
2096 2057 }
2097 2058
2098 2059 /**
2099 - * Called after trashing a reply.
2060 + * Called after trashing a reply
2100 2061 *
2101 2062 * @since 2.0.0 bbPress (r2993)
2102 2063 */
2103 2064 function bbp_trashed_reply( $reply_id = 0 ) {
@@ -2110,9 +2071,9 @@
2110 2071 do_action( 'bbp_trashed_reply', $reply_id );
2111 2072 }
2112 2073
2113 2074 /**
2114 - * Called after untrashing (restoring) a reply.
2075 + * Called after untrashing (restoring) a reply
2115 2076 *
2116 2077 * @since 2.0.0 bbPress (r2993)
2117 2078 */
2118 2079 function bbp_untrashed_reply( $reply_id = 0 ) {
@@ -2127,13 +2088,13 @@
2127 2088
2128 2089 /** Settings ******************************************************************/
2129 2090
2130 2091 /**
2131 - * Return the replies per page setting.
2092 + * Return the replies per page setting
2132 2093 *
2133 2094 * @since 2.0.0 bbPress (r3540)
2134 2095 *
2135 - * @param int $default Default replies per page (15).
2096 + * @param int $default Default replies per page (15)
2136 2097 * @return int
2137 2098 */
2138 2099 function bbp_get_replies_per_page( $default = 15 ) {
2139 2100
@@ -2149,13 +2110,13 @@
2149 2110 return (int) apply_filters( 'bbp_get_replies_per_page', $retval, $default );
2150 2111 }
2151 2112
2152 2113 /**
2153 - * Return the replies per RSS page setting.
2114 + * Return the replies per RSS page setting
2154 2115 *
2155 2116 * @since 2.0.0 bbPress (r3540)
2156 2117 *
2157 - * @param int $default Default replies per page (25).
2118 + * @param int $default Default replies per page (25)
2158 2119 * @return int
2159 2120 */
2160 2121 function bbp_get_replies_per_rss_page( $default = 25 ) {
2161 2122
@@ -2173,9 +2134,9 @@
2173 2134
2174 2135 /** Autoembed *****************************************************************/
2175 2136
2176 2137 /**
2177 - * Check if auto-embeds are enabled and hook them in if so.
2138 + * Check if autoembeds are enabled and hook them in if so
2178 2139 *
2179 2140 * @since 2.1.0 bbPress (r3752)
2180 2141 *
2181 2142 * @global WP_Embed $wp_embed
@@ -2190,9 +2151,9 @@
2190 2151
2191 2152 /** Filters *******************************************************************/
2192 2153
2193 2154 /**
2194 - * Used by bbp_has_replies() to add the lead topic post to the posts loop.
2155 + * Used by bbp_has_replies() to add the lead topic post to the posts loop
2195 2156 *
2196 2157 * This function filters the 'post_where' of the WP_Query, and changes the query
2197 2158 * to include both the topic AND its children in the same loop.
2198 2159 *
@@ -2309,10 +2270,10 @@
2309 2270
2310 2271 <title><?php echo $title; // Already escaped ?></title>
2311 2272 <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
2312 2273 <link><?php self_link(); ?></link>
2313 - <description><?php //?></description><?php // phpcs:ignore ?>
2314 - <lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
2274 + <description><?php // ?></description>
2275 + <lastBuildDate><?php echo date( 'r' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date ?></lastBuildDate>
2315 2276 <generator><?php echo esc_url_raw( 'https://bbpress.org/?v=' . convert_chars( bbp_get_version() ) ); ?></generator>
2316 2277 <language><?php bloginfo_rss( 'language' ); ?></language>
2317 2278
2318 2279 <?php do_action( 'bbp_feed_head' ); ?>
@@ -2329,17 +2290,13 @@
2329 2290 <dc:creator><?php bbp_topic_author_display_name(); ?></dc:creator>
2330 2291
2331 2292 <description>
2332 2293 <![CDATA[
2333 - <p>
2334 - <?php
2335 - printf(
2294 + <p><?php printf(
2336 2295 /* translators: %s: Number of replies */
2337 - __( 'Replies: %s', 'bbpress' ),
2338 - bbp_get_topic_reply_count()
2339 - );
2340 - ?>
2341 - </p>
2296 + __( 'Replies: %s', 'bbpress' ),
2297 + bbp_get_topic_reply_count()
2298 + ); ?></p>
2342 2299 <?php bbp_topic_content(); ?>
2343 2300 ]]>
2344 2301 </description>
2345 2302
@@ -2393,9 +2350,9 @@
2393 2350
2394 2351 /** Permissions ***************************************************************/
2395 2352
2396 2353 /**
2397 - * Redirect if unauthorized user is attempting to edit a reply.
2354 + * Redirect if unauthorized user is attempting to edit a reply
2398 2355 *
2399 2356 * @since 2.1.0 bbPress (r3605)
2400 2357 */
2401 2358 function bbp_check_reply_edit() {
@@ -2502,17 +2459,12 @@
2502 2459 if ( ! empty( $topic_replies ) ) {
2503 2460
2504 2461 // Reverse replies array and search for current reply position
2505 2462 $topic_replies = array_reverse( $topic_replies );
2506 - $reply_position = array_search( $reply_id, $topic_replies, true );
2463 + $reply_position = array_search( (string) $reply_id, $topic_replies );
2507 2464
2508 - // Bump the position to compensate for the lead topic post,
2509 - // or reset to 0 if the reply was not found in the children list.
2510 - if ( false !== $reply_position ) {
2511 - ++$reply_position;
2512 - } else {
2513 - $reply_position = 0;
2514 - }
2465 + // Bump the position to compensate for the lead topic post
2466 + ++$reply_position;
2515 2467 }
2516 2468 }
2517 2469 }
2518 2470
@@ -2524,11 +2476,11 @@
2524 2476 /**
2525 2477 * Are replies threaded?
2526 2478 *
2527 2479 * @since 2.4.0 bbPress (r4944)
2528 - * @since 2.6.0 bbPress (r6245) Always false on user profile reply pages.
2480 + * @since 2.6.0 bbPress (r6245) Always false on user profile reply pages
2529 2481 *
2530 - * @param bool $default Optional. Default value true.
2482 + * @param bool $default Optional. Default value true
2531 2483 *
2532 2484 * @return bool Are replies threaded?
2533 2485 */
2534 2486 function bbp_thread_replies() {
@@ -2547,9 +2499,9 @@
2547 2499 return (bool) apply_filters( 'bbp_thread_replies', $retval, $depth, $allow );
2548 2500 }
2549 2501
2550 2502 /**
2551 - * List threaded replies.
2503 + * List threaded replies
2552 2504 *
2553 2505 * @since 2.4.0 bbPress (r4944)
2554 2506 */
2555 2507 function bbp_list_replies( $args = array() ) {
@@ -2605,9 +2557,9 @@
2605 2557 echo "<{$style} class='bbp-replies-list'>" . $walked_html . "</{$style}>";
2606 2558 }
2607 2559
2608 2560 /**
2609 - * Validate a `reply_to` field for hierarchical replies.
2561 + * Validate a `reply_to` field for hierarchical replies
2610 2562 *
2611 2563 * Checks for 2 scenarios:
2612 2564 * -- The reply to ID is actually a reply
2613 2565 * -- The reply to ID does not match the current reply