PluginProbe
bbPress / 2.6.19
bbPress v2.6.19
2.6.19 2.6.18 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 All 74 releases
← All changes | includes/replies/functions.php +144 -186 trunk → 2.6.19 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 ) ) {
@@ -523,15 +506,15 @@
523 506 }
524 507 }
525 508
526 509 /**
527 - * Handles the front end edit reply submission.
510 + * Handles the front end edit reply submission
528 511 *
529 - * @since 2.6.19 bbPress (r7679) Enforce the edit lock on submissions.
512 + * @since 2.6.19 bbPress (r7680) Enforce the edit lock on submissions.
530 513 *
531 514 * @param string $action The requested action to compare this function to
532 - * id, anonymous data, reply author, bool true (for edit),
533 - * and the reply to id.
515 + * id, anonymous data, reply author, bool true (for edit),
516 + * and the reply to id
534 517 */
535 518 function bbp_edit_reply_handler( $action = '' ) {
536 519
537 520 // Bail if action is not bbp-edit-reply
@@ -600,13 +583,8 @@
600 583 /** Reply Topic ***********************************************************/
601 584
602 585 $topic_id = bbp_get_reply_topic_id( $reply_id );
603 586
604 - // User cannot read parent topic ID
605 - if ( ! current_user_can( 'read_topic', $topic_id ) ) {
606 - 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' ) );
607 - }
608 -
609 587 /** Topic Forum ***********************************************************/
610 588
611 589 $forum_id = bbp_get_topic_forum_id( $topic_id );
612 590
@@ -619,45 +597,24 @@
619 597
620 598 // Forum is not a category
621 599 } else {
622 600
623 - // Forum not editable by user
624 - if ( ! current_user_can( 'edit_forum', $forum_id ) ) {
601 + // Forum is closed and user cannot access
602 + if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) {
603 + bbp_add_error( 'bbp_edit_reply_forum_closed', __( '<strong>Error</strong>: This forum has been closed to new replies.', 'bbpress' ) );
604 + }
625 605
626 - // Forum is closed
627 - if ( bbp_is_forum_closed( $forum_id ) ) {
628 - bbp_add_error( 'bbp_edit_reply_forum_closed', __( '<strong>Error</strong>: This forum is closed to new replies.', 'bbpress' ) );
629 - }
630 - }
606 + // Forum is private and user cannot access
607 + if ( bbp_is_forum_private( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) {
608 + 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' ) );
631 609
632 - // Forum not readable by user
633 - if ( ! current_user_can( 'read_forum', $forum_id ) ) {
634 - 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' ) );
610 + // Forum is hidden and user cannot access
611 + } elseif ( bbp_is_forum_hidden( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) {
612 + 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' ) );
635 613 }
636 614 }
637 615 }
638 616
639 - /** Reply To **************************************************************/
640 -
641 - $reply_to = bbp_get_reply_to( $reply_id );
642 -
643 - // Maybe sanitize Reply To, using $_REQUEST for non-JS submissions
644 - if ( isset( $_REQUEST['bbp_reply_to'] ) && is_numeric( $_REQUEST['bbp_reply_to'] ) ) {
645 - $reply_to = intval( $_REQUEST['bbp_reply_to'] );
646 - }
647 -
648 - // Validate Reply To
649 - $reply_to = bbp_validate_reply_to( $reply_to, $reply_id );
650 -
651 - // Check the Reply To ID
652 - if ( ! empty( $reply_to ) ) {
653 -
654 - // User cannot read parent reply ID
655 - if ( ! current_user_can( 'read_reply', $reply_to ) ) {
656 - 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' ) );
657 - }
658 - }
659 -
660 617 /** Reply Title ***********************************************************/
661 618
662 619 if ( ! empty( $_POST['bbp_reply_title'] ) ) {
663 620 $reply_title = sanitize_text_field( $_POST['bbp_reply_title'] );
@@ -715,8 +672,17 @@
715 672 bbp_add_error( 'bbp_edit_reply_status', __( '<strong>Error</strong>: You do not have permission to do that.', 'bbpress' ) );
716 673 }
717 674 }
718 675
676 + /** Reply To **************************************************************/
677 +
678 + // Handle Reply To of the reply; $_REQUEST for non-JS submissions
679 + if ( isset( $_REQUEST['bbp_reply_to'] ) && current_user_can( 'moderate', $reply_id ) ) {
680 + $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'], $reply_id );
681 + } elseif ( bbp_thread_replies() ) {
682 + $reply_to = bbp_get_reply_to( $reply_id );
683 + }
684 +
719 685 /** Topic Tags ************************************************************/
720 686
721 687 // Replace allowed terms
722 688 if ( bbp_allow_topic_tags() && isset( $_POST['bbp_topic_tags'] ) ) {
@@ -789,8 +755,12 @@
789 755 do_action( 'bbp_edit_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_data['post_author'], true, $reply_to );
790 756
791 757 /** Revisions *********************************************************/
792 758
759 + // Update locks
760 + update_post_meta( $reply_id, '_edit_last', bbp_get_current_user_id() );
761 + delete_post_meta( $reply_id, '_edit_lock' );
762 +
793 763 // Revision Reason
794 764 if ( ! empty( $_POST['bbp_reply_edit_reason'] ) ) {
795 765 $reply_edit_reason = sanitize_text_field( $_POST['bbp_reply_edit_reason'] );
796 766 }
@@ -835,26 +805,31 @@
835 805 } else {
836 806 $append_error = ( is_wp_error( $reply_id ) && $reply_id->get_error_message() )
837 807 ? $reply_id->get_error_message() . ' '
838 808 : '';
839 -
840 - /* translators: %s: Error message(s) */
841 - 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 );
809 + bbp_add_error(
810 + 'bbp_reply_error',
811 + sprintf(
812 + /* translators: %s: Error message */
813 + __( '<strong>Error</strong>: The following problem(s) have been found with your reply: %sPlease try again.', 'bbpress' ),
814 + $append_error
815 + )
816 + );
842 817 }
843 818 }
844 819
845 820 /**
846 - * Handle all the extra meta stuff from posting a new reply or editing a reply.
821 + * Handle all the extra meta stuff from posting a new reply or editing a reply
847 822 *
848 - * @param int $reply_id Optional. Reply id.
849 - * @param int $topic_id Optional. Topic id.
850 - * @param int $forum_id Optional. Forum id.
823 + * @param int $reply_id Optional. Reply id
824 + * @param int $topic_id Optional. Topic id
825 + * @param int $forum_id Optional. Forum id
851 826 * @param array $anonymous_data Optional - if it's an anonymous post. Do not
852 827 * supply if supplying $author_id. Should be
853 - * sanitized (see {@link bbp_filter_anonymous_post_data()}.
854 - * @param int $author_id Author id.
828 + * sanitized (see {@link bbp_filter_anonymous_post_data()}
829 + * @param int $author_id Author id
855 830 * @param bool $is_edit Optional. Is the post being edited? Defaults to false.
856 - * @param int $reply_to Optional. Reply to id.
831 + * @param int $reply_to Optional. Reply to id
857 832 */
858 833 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 ) {
859 834
860 835 // Validate the ID's passed from 'bbp_new_reply' action
@@ -862,40 +837,28 @@
862 837 $topic_id = bbp_get_topic_id( $topic_id );
863 838 $forum_id = bbp_get_forum_id( $forum_id );
864 839 $reply_to = bbp_validate_reply_to( $reply_to, $reply_id );
865 840
866 - // Get the current user ID
867 - $user_id = bbp_get_current_user_id();
868 -
869 841 // Bail if there is no reply
870 842 if ( empty( $reply_id ) ) {
871 843 return;
872 844 }
873 845
874 - // Check author_id, fallback to current user ID
846 + // Check author_id
875 847 if ( empty( $author_id ) ) {
876 - $author_id = $user_id;
848 + $author_id = bbp_get_current_user_id();
877 849 }
878 850
879 - // Check topic_id, fallback to post_parent or meta
851 + // Check topic_id
880 852 if ( empty( $topic_id ) ) {
881 853 $topic_id = bbp_get_reply_topic_id( $reply_id );
882 854 }
883 855
884 - // Check forum_id, fallback to post_parent or meta
856 + // Check forum_id
885 857 if ( ! empty( $topic_id ) && empty( $forum_id ) ) {
886 858 $forum_id = bbp_get_topic_forum_id( $topic_id );
887 859 }
888 860
889 - // Update locks
890 - update_post_meta( $reply_id, '_edit_last', $user_id );
891 - delete_post_meta( $reply_id, '_edit_lock' );
892 -
893 - // Forum/Topic meta (early, for use in downstream functions)
894 - bbp_update_reply_forum_id( $reply_id, $forum_id );
895 - bbp_update_reply_topic_id( $reply_id, $topic_id );
896 - bbp_update_reply_to ( $reply_id, $reply_to );
897 -
898 861 // If anonymous post, store name, email, website and ip in post_meta.
899 862 if ( ! empty( $anonymous_data ) ) {
900 863
901 864 // Update anonymous meta data (not cookies)
@@ -927,8 +890,13 @@
927 890 bbp_add_user_subscription( $author_id, $topic_id );
928 891 }
929 892 }
930 893
894 + // Reply meta relating to reply position in tree
895 + bbp_update_reply_forum_id( $reply_id, $forum_id );
896 + bbp_update_reply_topic_id( $reply_id, $topic_id );
897 + bbp_update_reply_to ( $reply_id, $reply_to );
898 +
931 899 // Update associated topic values if this is a new reply
932 900 if ( empty( $is_edit ) ) {
933 901
934 902 // Update poster activity time
@@ -948,18 +916,18 @@
948 916 wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' );
949 917 }
950 918
951 919 /**
952 - * Walk up the ancestor tree from the current reply, and update all the counts.
920 + * Walk up the ancestor tree from the current reply, and update all the counts
953 921 *
954 922 * @since 2.0.0 bbPress (r2895)
955 923 *
956 - * @param int $reply_id Optional. Reply id.
957 - * @param string $last_active_time Optional. Last active time.
958 - * @param int $forum_id Optional. Forum id.
959 - * @param int $topic_id Optional. Topic id.
924 + * @param int $reply_id Optional. Reply id
925 + * @param string $last_active_time Optional. Last active time
926 + * @param int $forum_id Optional. Forum id
927 + * @param int $topic_id Optional. Topic id
960 928 * @param bool $refresh If set to true, unsets all the previous parameters.
961 - * Defaults to true.
929 + * Defaults to true
962 930 */
963 931 function bbp_update_reply_walker( $reply_id, $last_active_time = '', $forum_id = 0, $topic_id = 0, $refresh = true ) {
964 932
965 933 // Verify the reply ID
@@ -1059,15 +1027,15 @@
1059 1027
1060 1028 /** Reply Updaters ************************************************************/
1061 1029
1062 1030 /**
1063 - * Update the reply with its forum id it is in.
1031 + * Update the reply with its forum id it is in
1064 1032 *
1065 1033 * @since 2.0.0 bbPress (r2858)
1066 1034 *
1067 - * @param int $reply_id Optional. Reply id to update.
1068 - * @param int $forum_id Optional. Forum id.
1069 - * @return bool The forum id of the reply.
1035 + * @param int $reply_id Optional. Reply id to update
1036 + * @param int $forum_id Optional. Forum id
1037 + * @return bool The forum id of the reply
1070 1038 */
1071 1039 function bbp_update_reply_forum_id( $reply_id = 0, $forum_id = 0 ) {
1072 1040
1073 1041 // Validation
@@ -1102,15 +1070,15 @@
1102 1070 return (int) apply_filters( 'bbp_update_reply_forum_id', $retval, $reply_id, $forum_id );
1103 1071 }
1104 1072
1105 1073 /**
1106 - * Update the reply with its topic id it is in.
1074 + * Update the reply with its topic id it is in
1107 1075 *
1108 1076 * @since 2.0.0 bbPress (r2858)
1109 1077 *
1110 - * @param int $reply_id Optional. Reply id to update.
1111 - * @param int $topic_id Optional. Topic id.
1112 - * @return bool The topic id of the reply.
1078 + * @param int $reply_id Optional. Reply id to update
1079 + * @param int $topic_id Optional. Topic id
1080 + * @return bool The topic id of the reply
1113 1081 */
1114 1082 function bbp_update_reply_topic_id( $reply_id = 0, $topic_id = 0 ) {
1115 1083
1116 1084 // Validation
@@ -1145,15 +1113,15 @@
1145 1113 return (int) apply_filters( 'bbp_update_reply_topic_id', $retval, $reply_id, $topic_id );
1146 1114 }
1147 1115
1148 1116 /*
1149 - * Update the meta data with its parent reply-to id, of a reply.
1117 + * Update the meta data with its parent reply-to id, of a reply
1150 1118 *
1151 1119 * @since 2.4.0 bbPress (r4944)
1152 1120 *
1153 - * @param int $reply_id Reply id to update.
1154 - * @param int $reply_to Optional. Reply to id.
1155 - * @return bool The parent reply id of the reply.
1121 + * @param int $reply_id Reply id to update
1122 + * @param int $reply_to Optional. Reply to id
1123 + * @return bool The parent reply id of the reply
1156 1124 */
1157 1125 function bbp_update_reply_to( $reply_id = 0, $reply_to = 0 ) {
1158 1126
1159 1127 // Validation
@@ -1177,9 +1145,9 @@
1177 1145 return (int) apply_filters( 'bbp_update_reply_to', $reply_to, $reply_id );
1178 1146 }
1179 1147
1180 1148 /**
1181 - * Get all ancestors to a reply.
1149 + * Get all ancestors to a reply
1182 1150 *
1183 1151 * Because settings can be changed, this function does not care if hierarchical
1184 1152 * replies are active or to what depth.
1185 1153 *
@@ -1207,9 +1175,9 @@
1207 1175 $id = $reply_to;
1208 1176 $ancestors = array( $reply_to );
1209 1177
1210 1178 // Get parent reply
1211 - // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
1179 + // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition -- Fetch each ancestor until none remains.
1212 1180 while ( $ancestor = bbp_get_reply( $id ) ) {
1213 1181
1214 1182 // Does parent have a parent?
1215 1183 $grampy_id = bbp_get_reply_to( $ancestor->ID );
@@ -1228,9 +1196,9 @@
1228 1196 return (array) apply_filters( 'bbp_get_reply_ancestors', $ancestors, $reply_id );
1229 1197 }
1230 1198
1231 1199 /**
1232 - * Update the revision log of the reply.
1200 + * Update the revision log of the reply
1233 1201 *
1234 1202 * @since 2.0.0 bbPress (r2782)
1235 1203 *
1236 1204 * @param array $args Supports these args:
@@ -1237,9 +1205,9 @@
1237 1205 * - reply_id: reply id
1238 1206 * - author_id: Author id
1239 1207 * - reason: Reason for editing
1240 1208 * - revision_id: Revision id
1241 - * @return mixed False on failure, true on success.
1209 + * @return mixed False on failure, true on success
1242 1210 */
1243 1211 function bbp_update_reply_revision_log( $args = array() ) {
1244 1212
1245 1213 // Parse arguments against default values
@@ -1274,15 +1242,15 @@
1274 1242 return apply_filters( 'bbp_update_reply_revision_log', $revision_log, $r['reply_id'] );
1275 1243 }
1276 1244
1277 1245 /**
1278 - * Move reply handler.
1246 + * Move reply handler
1279 1247 *
1280 - * Handles the front end move reply submission.
1248 + * Handles the front end move reply submission
1281 1249 *
1282 1250 * @since 2.3.0 bbPress (r4522)
1283 1251 *
1284 - * @param string $action The requested action to compare this function to.
1252 + * @param string $action The requested action to compare this function to
1285 1253 */
1286 1254 function bbp_move_reply_handler( $action = '' ) {
1287 1255
1288 1256 // Bail if action is not 'bbp-move-reply'
@@ -1546,19 +1514,19 @@
1546 1514 bbp_redirect( bbp_get_topic_permalink( $destination_topic->ID ) );
1547 1515 }
1548 1516
1549 1517 /**
1550 - * Fix counts on reply move.
1518 + * Fix counts on reply move
1551 1519 *
1552 1520 * When a reply is moved, update the counts of source and destination topic
1553 1521 * and their forums.
1554 1522 *
1555 1523 * @since 2.3.0 bbPress (r4522)
1556 - * @since 2.6.17 bbPress (r7467) Recount both forums and topic engagements.
1524 + * @since 2.6.17 bbPress (r7468) Recount both forums and topic engagements.
1557 1525 *
1558 - * @param int $move_reply_id Move reply id.
1559 - * @param int $source_topic_id Source topic id.
1560 - * @param int $destination_topic_id Destination topic id.
1526 + * @param int $move_reply_id Move reply id
1527 + * @param int $source_topic_id Source topic id
1528 + * @param int $destination_topic_id Destination topic id
1561 1529 */
1562 1530 function bbp_move_reply_count( $move_reply_id, $source_topic_id, $destination_topic_id ) {
1563 1531 $source_forum_id = bbp_get_topic_forum_id( $source_topic_id );
1564 1532 $destination_forum_id = bbp_get_topic_forum_id( $destination_topic_id );
@@ -1602,13 +1570,13 @@
1602 1570 /** Reply Actions *************************************************************/
1603 1571
1604 1572 /**
1605 1573 * Handles the front end spamming/unspamming and trashing/untrashing/deleting of
1606 - * replies.
1574 + * replies
1607 1575 *
1608 1576 * @since 2.0.0 bbPress (r2740)
1609 1577 *
1610 - * @param string $action The requested action to compare this function to.
1578 + * @param string $action The requested action to compare this function to
1611 1579 */
1612 1580 function bbp_toggle_reply_handler( $action = '' ) {
1613 1581
1614 1582 // Bail if required GET actions aren't passed
@@ -1671,9 +1639,9 @@
1671 1639 }
1672 1640 }
1673 1641
1674 1642 /**
1675 - * Do the actual reply toggling.
1643 + * Do the actual reply toggling
1676 1644 *
1677 1645 * This function is used by `bbp_toggle_reply_handler()` to do the actual heavy
1678 1646 * lifting when it comes to toggling replies. It only really makes sense to call
1679 1647 * within that context, so if you need to call this function directly, make sure
@@ -1778,13 +1746,13 @@
1778 1746
1779 1747 /** Helpers *******************************************************************/
1780 1748
1781 1749 /**
1782 - * Return an associative array of available reply statuses.
1750 + * Return an associative array of available reply statuses
1783 1751 *
1784 1752 * @since 2.6.0 bbPress (r5399)
1785 1753 *
1786 - * @param int $reply_id Optional. Reply id.
1754 + * @param int $reply_id Optional. Reply id.
1787 1755 *
1788 1756 * @return array
1789 1757 */
1790 1758 function bbp_get_reply_statuses( $reply_id = 0 ) {
@@ -1802,13 +1770,13 @@
1802 1770 );
1803 1771 }
1804 1772
1805 1773 /**
1806 - * Return array of available reply toggle actions.
1774 + * Return array of available reply toggle actions
1807 1775 *
1808 1776 * @since 2.6.0 bbPress (r6134)
1809 1777 *
1810 - * @param int $reply_id Optional. Reply id.
1778 + * @param int $reply_id Optional. Reply id.
1811 1779 *
1812 1780 * @return array
1813 1781 */
1814 1782 function bbp_get_reply_toggles( $reply_id = 0 ) {
@@ -1861,14 +1829,14 @@
1861 1829
1862 1830 /** Reply Actions *************************************************************/
1863 1831
1864 1832 /**
1865 - * Marks a reply as spam.
1833 + * Marks a reply as spam
1866 1834 *
1867 1835 * @since 2.0.0 bbPress (r2740)
1868 1836 *
1869 - * @param int $reply_id Reply id.
1870 - * @return mixed False or {@link WP_Error} on failure, reply id on success.
1837 + * @param int $reply_id Reply id
1838 + * @return mixed False or {@link WP_Error} on failure, reply id on success
1871 1839 */
1872 1840 function bbp_spam_reply( $reply_id = 0 ) {
1873 1841
1874 1842 // Get reply
@@ -1904,14 +1872,14 @@
1904 1872 return $reply_id;
1905 1873 }
1906 1874
1907 1875 /**
1908 - * Unspams a reply.
1876 + * Unspams a reply
1909 1877 *
1910 1878 * @since 2.0.0 bbPress (r2740)
1911 1879 *
1912 - * @param int $reply_id Reply id.
1913 - * @return mixed False or {@link WP_Error} on failure, reply id on success.
1880 + * @param int $reply_id Reply id
1881 + * @return mixed False or {@link WP_Error} on failure, reply id on success
1914 1882 */
1915 1883 function bbp_unspam_reply( $reply_id = 0 ) {
1916 1884
1917 1885 // Get reply
@@ -1952,14 +1920,14 @@
1952 1920 return $reply_id;
1953 1921 }
1954 1922
1955 1923 /**
1956 - * Approves a reply.
1924 + * Approves a reply
1957 1925 *
1958 1926 * @since 2.6.0 bbPress (r5506)
1959 1927 *
1960 - * @param int $reply_id Reply id.
1961 - * @return mixed False or {@link WP_Error} on failure, reply id on success.
1928 + * @param int $reply_id Reply id
1929 + * @return mixed False or {@link WP_Error} on failure, reply id on success
1962 1930 */
1963 1931 function bbp_approve_reply( $reply_id = 0 ) {
1964 1932
1965 1933 // Get reply
@@ -1998,14 +1966,14 @@
1998 1966 return $reply_id;
1999 1967 }
2000 1968
2001 1969 /**
2002 - * Unapproves a reply.
1970 + * Unapproves a reply
2003 1971 *
2004 1972 * @since 2.6.0 bbPress (r5506)
2005 1973 *
2006 - * @param int $reply_id Reply id.
2007 - * @return mixed False or {@link WP_Error} on failure, reply id on success.
1974 + * @param int $reply_id Reply id
1975 + * @return mixed False or {@link WP_Error} on failure, reply id on success
2008 1976 */
2009 1977 function bbp_unapprove_reply( $reply_id = 0 ) {
2010 1978
2011 1979 // Get reply
@@ -2043,11 +2011,9 @@
2043 2011
2044 2012 /** Before Delete/Trash/Untrash ***********************************************/
2045 2013
2046 2014 /**
2047 - * Called before deleting a reply.
2048 - *
2049 - * @since 2.0.0 bbPress (r2895)
2015 + * Called before deleting a reply
2050 2016 */
2051 2017 function bbp_delete_reply( $reply_id = 0 ) {
2052 2018 $reply_id = bbp_get_reply_id( $reply_id );
2053 2019
@@ -2058,11 +2024,9 @@
2058 2024 do_action( 'bbp_delete_reply', $reply_id );
2059 2025 }
2060 2026
2061 2027 /**
2062 - * Called before trashing a reply.
2063 - *
2064 - * @since 2.0.0 bbPress (r2895)
2028 + * Called before trashing a reply
2065 2029 */
2066 2030 function bbp_trash_reply( $reply_id = 0 ) {
2067 2031 $reply_id = bbp_get_reply_id( $reply_id );
2068 2032
@@ -2073,11 +2037,9 @@
2073 2037 do_action( 'bbp_trash_reply', $reply_id );
2074 2038 }
2075 2039
2076 2040 /**
2077 - * Called before untrashing (restoring) a reply.
2078 - *
2079 - * @since 2.0.0 bbPress (r2895)
2041 + * Called before untrashing (restoring) a reply
2080 2042 */
2081 2043 function bbp_untrash_reply( $reply_id = 0 ) {
2082 2044 $reply_id = bbp_get_reply_id( $reply_id );
2083 2045
@@ -2090,9 +2052,9 @@
2090 2052
2091 2053 /** After Delete/Trash/Untrash ************************************************/
2092 2054
2093 2055 /**
2094 - * Called after deleting a reply.
2056 + * Called after deleting a reply
2095 2057 *
2096 2058 * @since 2.0.0 bbPress (r2895)
2097 2059 */
2098 2060 function bbp_deleted_reply( $reply_id = 0 ) {
@@ -2105,9 +2067,9 @@
2105 2067 do_action( 'bbp_deleted_reply', $reply_id );
2106 2068 }
2107 2069
2108 2070 /**
2109 - * Called after trashing a reply.
2071 + * Called after trashing a reply
2110 2072 *
2111 2073 * @since 2.0.0 bbPress (r2895)
2112 2074 */
2113 2075 function bbp_trashed_reply( $reply_id = 0 ) {
@@ -2120,9 +2082,9 @@
2120 2082 do_action( 'bbp_trashed_reply', $reply_id );
2121 2083 }
2122 2084
2123 2085 /**
2124 - * Called after untrashing (restoring) a reply.
2086 + * Called after untrashing (restoring) a reply
2125 2087 *
2126 2088 * @since 2.0.0 bbPress (r2895)
2127 2089 */
2128 2090 function bbp_untrashed_reply( $reply_id = 0 ) {
@@ -2137,13 +2099,13 @@
2137 2099
2138 2100 /** Settings ******************************************************************/
2139 2101
2140 2102 /**
2141 - * Return the replies per page setting.
2103 + * Return the replies per page setting
2142 2104 *
2143 2105 * @since 2.1.0 bbPress (r3572)
2144 2106 *
2145 - * @param int $default Default replies per page (15).
2107 + * @param int $default Default replies per page (15)
2146 2108 * @return int
2147 2109 */
2148 2110 function bbp_get_replies_per_page( $default = 15 ) {
2149 2111
@@ -2159,13 +2121,13 @@
2159 2121 return (int) apply_filters( 'bbp_get_replies_per_page', $retval, $default );
2160 2122 }
2161 2123
2162 2124 /**
2163 - * Return the replies per RSS page setting.
2125 + * Return the replies per RSS page setting
2164 2126 *
2165 2127 * @since 2.1.0 bbPress (r3572)
2166 2128 *
2167 - * @param int $default Default replies per page (25).
2129 + * @param int $default Default replies per page (25)
2168 2130 * @return int
2169 2131 */
2170 2132 function bbp_get_replies_per_rss_page( $default = 25 ) {
2171 2133
@@ -2183,9 +2145,9 @@
2183 2145
2184 2146 /** Autoembed *****************************************************************/
2185 2147
2186 2148 /**
2187 - * Check if auto-embeds are enabled and hook them in if so.
2149 + * Check if autoembeds are enabled and hook them in if so
2188 2150 *
2189 2151 * @since 2.1.0 bbPress (r3753)
2190 2152 *
2191 2153 * @global WP_Embed $wp_embed
@@ -2200,9 +2162,9 @@
2200 2162
2201 2163 /** Filters *******************************************************************/
2202 2164
2203 2165 /**
2204 - * Used by bbp_has_replies() to add the lead topic post to the posts loop.
2166 + * Used by bbp_has_replies() to add the lead topic post to the posts loop
2205 2167 *
2206 2168 * This function filters the 'post_where' of the WP_Query, and changes the query
2207 2169 * to include both the topic AND its children in the same loop.
2208 2170 *
@@ -2326,10 +2288,10 @@
2326 2288
2327 2289 <title><?php echo $title; // Already escaped ?></title>
2328 2290 <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
2329 2291 <link><?php self_link(); ?></link>
2330 - <description><?php //?></description><?php // phpcs:ignore ?>
2331 - <lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
2292 + <description><?php // ?></description>
2293 + <lastBuildDate><?php echo date( 'r' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date ?></lastBuildDate>
2332 2294 <generator><?php echo esc_url_raw( 'https://bbpress.org/?v=' . convert_chars( bbp_get_version() ) ); ?></generator>
2333 2295 <language><?php bloginfo_rss( 'language' ); ?></language>
2334 2296
2335 2297 <?php do_action( 'bbp_feed_head' ); ?>
@@ -2346,17 +2308,13 @@
2346 2308 <dc:creator><?php bbp_topic_author_display_name(); ?></dc:creator>
2347 2309
2348 2310 <description>
2349 2311 <![CDATA[
2350 - <p>
2351 - <?php
2352 - printf(
2312 + <p><?php printf(
2353 2313 /* translators: %s: Number of replies */
2354 - __( 'Replies: %s', 'bbpress' ),
2355 - bbp_get_topic_reply_count()
2356 - );
2357 - ?>
2358 - </p>
2314 + __( 'Replies: %s', 'bbpress' ),
2315 + bbp_get_topic_reply_count()
2316 + ); ?></p>
2359 2317 <?php echo bbp_escape_feed_cdata( bbp_get_topic_content() ); ?>
2360 2318 ]]>
2361 2319 </description>
2362 2320
@@ -2410,9 +2368,9 @@
2410 2368
2411 2369 /** Permissions ***************************************************************/
2412 2370
2413 2371 /**
2414 - * Redirect if unauthorized user is attempting to edit a reply.
2372 + * Redirect if unauthorized user is attempting to edit a reply
2415 2373 *
2416 2374 * @since 2.1.0 bbPress (r3607)
2417 2375 */
2418 2376 function bbp_check_reply_edit() {
@@ -2541,11 +2499,11 @@
2541 2499 /**
2542 2500 * Are replies threaded?
2543 2501 *
2544 2502 * @since 2.4.0 bbPress (r4944)
2545 - * @since 2.6.0 bbPress (r6245) Always false on user profile reply pages.
2503 + * @since 2.6.0 bbPress (r6245) Always false on user profile reply pages
2546 2504 *
2547 - * @param bool $default Optional. Default value true.
2505 + * @param bool $default Optional. Default value true
2548 2506 *
2549 2507 * @return bool Are replies threaded?
2550 2508 */
2551 2509 function bbp_thread_replies() {
@@ -2564,9 +2522,9 @@
2564 2522 return (bool) apply_filters( 'bbp_thread_replies', $retval, $depth, $allow );
2565 2523 }
2566 2524
2567 2525 /**
2568 - * List threaded replies.
2526 + * List threaded replies
2569 2527 *
2570 2528 * @since 2.4.0 bbPress (r4944)
2571 2529 */
2572 2530 function bbp_list_replies( $args = array() ) {
@@ -2622,9 +2580,9 @@
2622 2580 echo "<{$style} class='bbp-replies-list'>" . $walked_html . "</{$style}>";
2623 2581 }
2624 2582
2625 2583 /**
2626 - * Validate a `reply_to` field for hierarchical replies.
2584 + * Validate a `reply_to` field for hierarchical replies
2627 2585 *
2628 2586 * Checks for 3 scenarios:
2629 2587 * -- The reply to ID is actually a reply
2630 2588 * -- The reply to ID does not match the current reply