| @@ -168,8 +168,12 @@ | ||
| 168 | 168 | 'reply' => bbp_get_reply_to_link( $r ), |
| 169 | 169 | ], $r['id'] ); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | + if ( bbp_get_user_role( get_current_user_id() ) === bbp_get_participant_role() ) { | |
| 173 | + unset( $r['links']['edit'] ); | |
| 174 | + } | |
| 175 | + | |
| 172 | 176 | // See if links need to be unset |
| 173 | 177 | $reply_status = bbp_get_reply_status( $r['id'] ); |
| 174 | 178 | if ( in_array( $reply_status, [ bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ], true ) ) { |
| 175 | 179 | |
| @@ -272,8 +276,12 @@ | ||
| 272 | 276 | 'reply' => bbp_get_topic_reply_link( $r ), |
| 273 | 277 | ], $r['id'] ); |
| 274 | 278 | } |
| 275 | 279 | |
| 280 | + if ( bbp_get_user_role( get_current_user_id() ) === bbp_get_participant_role() ) { | |
| 281 | + unset( $r['links']['edit'] ); | |
| 282 | + } | |
| 283 | + | |
| 276 | 284 | // See if links need to be unset |
| 277 | 285 | $topic_status = bbp_get_topic_status( $r['id'] ); |
| 278 | 286 | if ( in_array( $topic_status, [ bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ], true ) ) { |
| 279 | 287 | |
| @@ -333,23 +341,8 @@ | ||
| 333 | 341 | return apply_filters( 'forumax_bbp_get_topic_admin_links', $retval, $r, $args ); |
| 334 | 342 | } |
| 335 | 343 | } |
| 336 | 344 | |
| 337 | -/** | |
| 338 | - * Enqueue the script for sorting bbPress replies | |
| 339 | - */ | |
| 340 | -if ( ! function_exists( 'forumax_enqueue_bbp_replies_sorting_script' ) ) { | |
| 341 | - /** | |
| 342 | - * Enqueue replies sorting script. | |
| 343 | - */ | |
| 344 | - function forumax_enqueue_bbp_replies_sorting_script() { | |
| 345 | - wp_localize_script( 'bbp-replies-sorting', 'bbp_reply_ajax_obj', [ | |
| 346 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 347 | - 'bbp_topic_id' => get_the_ID(), | |
| 348 | - ] ); | |
| 349 | - } | |
| 350 | - add_action( 'wp_enqueue_scripts', 'forumax_enqueue_bbp_replies_sorting_script' ); | |
| 351 | -} | |
| 352 | 345 | |
| 353 | 346 | if ( ! function_exists( 'forumax_ajax_sort_bbp_replies' ) ) { |
| 354 | 347 | /** |
| 355 | 348 | * AJAX handler for sorting replies. |
| @@ -374,9 +367,10 @@ | ||
| 374 | 367 | 'post_type' => bbp_get_reply_post_type(), |
| 375 | 368 | 'orderby' => ( 'vote' === $sort ? 'meta_value_num' : 'date' ), |
| 376 | 369 | 'order' => ( 'asc' === $sort ? 'ASC' : 'DESC' ), |
| 377 | 370 | 'meta_key' => ( 'vote' === $sort ? 'bbp_voting_score' : '' ), |
| 378 | - 'posts_per_page' => -1, | |
| 371 | + // Public endpoint: cap it so a huge topic can't be dumped in one request. | |
| 372 | + 'posts_per_page' => (int) apply_filters( 'forumax_sort_replies_limit', 200, $topic_id ), | |
| 379 | 373 | ]; |
| 380 | 374 | if ( bbp_has_replies( $replies_args ) ) { |
| 381 | 375 | while ( bbp_replies() ) : |
| 382 | 376 | bbp_the_reply(); |