Ticket #3353: 3353.2.patch
| File 3353.2.patch, 6.8 KB (added by , 5 years ago) |
|---|
-
src/includes/core/functions.php
305 305 return (bool) apply_filters( 'bbp_has_errors', $has_errors, bbpress()->errors ); 306 306 } 307 307 308 /** 309 * Check if a specific error message exists in queue 310 * 311 * @since 2.6.7 bbPress (r3381) 312 * 313 * @param string $code Unique code to check for 314 */ 315 function bbp_has_error( $code = '' ) { 316 317 // Default return value 318 $retval = false; 319 320 // Has errors 321 if ( bbp_has_errors() ) { 322 $errors = bbpress()->errors->get_error_codes(); 323 $retval = in_array( $code, $errors, true ); 324 } 325 326 return (bool) apply_filters( 'bbp_has_error', $retval, $code ); 327 } 328 308 329 /** Mentions ******************************************************************/ 309 330 310 331 /** -
src/includes/forums/template.php
2108 2108 */ 2109 2109 function bbp_get_form_forum_content() { 2110 2110 2111 // Default return value 2112 $forum_content = ''; 2113 2111 2114 // Get _POST data 2112 2115 if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_content'] ) ) { 2113 $forum_content = wp_unslash( $_POST['bbp_forum_content'] );2114 2116 2117 // Use if content was not moderated 2118 if ( ! bbp_has_error( 'bbp_forum_moderated' ) ) { 2119 $forum_content = wp_unslash( $_POST['bbp_forum_content'] ); 2120 } 2121 2115 2122 // Get edit data 2116 2123 } elseif ( bbp_is_forum_edit() ) { 2117 2124 $forum_content = bbp_get_global_post_field( 'post_content', 'raw' ); 2118 2119 // No data2120 } else {2121 $forum_content = '';2122 2125 } 2123 2126 2124 2127 // Filter & return -
src/includes/replies/functions.php
461 461 462 462 do_action( 'bbp_new_reply_post_extras', $reply_id ); 463 463 464 /** Redirect **********************************************************/464 /** Unapproved ********************************************************/ 465 465 466 // Redirect to 467 $redirect_to = bbp_get_redirect_to(); 466 if ( bbp_get_pending_status_id() === $reply_data['reply_status'] ) { 468 467 469 // Get the reply URL470 $reply_url = bbp_get_reply_url( $reply_id, $redirect_to);468 // Add an error 469 bbp_add_error( 'bbp_reply_moderated', esc_html__( 'Your reply is pending moderation.', 'bbpress' ) ); 471 470 472 // Allow to be filtered 473 $reply_url = apply_filters( 'bbp_new_reply_redirect_to', $reply_url, $redirect_to, $reply_id ); 471 /** Approved **********************************************************/ 474 472 475 /** Successful Save ***************************************************/473 } else { 476 474 477 // Redirect back to new reply478 bbp_redirect( $reply_url);475 // Redirect to 476 $redirect_to = bbp_get_redirect_to(); 479 477 478 // Get the reply URL 479 $reply_url = bbp_get_reply_url( $reply_id, $redirect_to ); 480 481 // Allow to be filtered 482 $reply_url = apply_filters( 'bbp_new_reply_redirect_to', $reply_url, $redirect_to, $reply_id ); 483 484 // Redirect back to new reply 485 bbp_redirect( $reply_url ); 486 } 487 480 488 /** Errors ****************************************************************/ 481 489 482 490 // WP_Error -
src/includes/replies/template.php
2455 2455 */ 2456 2456 function bbp_get_form_reply_content() { 2457 2457 2458 // Default return value 2459 $reply_content = ''; 2460 2458 2461 // Get _POST data 2459 2462 if ( bbp_is_reply_form_post_request() && isset( $_POST['bbp_reply_content'] ) ) { 2460 $reply_content = wp_unslash( $_POST['bbp_reply_content'] );2461 2463 2464 // Use if content was not moderated 2465 if ( ! bbp_has_error( 'bbp_reply_moderated' ) ) { 2466 $reply_content = wp_unslash( $_POST['bbp_reply_content'] ); 2467 } 2468 2462 2469 // Get edit data 2463 2470 } elseif ( bbp_is_reply_edit() ) { 2464 2471 $reply_content = bbp_get_global_post_field( 'post_content', 'raw' ); 2465 2466 // No data2467 } else {2468 $reply_content = '';2469 2472 } 2470 2473 2471 2474 // Filter & return -
src/includes/topics/functions.php
364 364 365 365 do_action( 'bbp_new_topic_post_extras', $topic_id ); 366 366 367 /** Redirect **********************************************************/367 /** Unapproved ********************************************************/ 368 368 369 // Redirect to 370 $redirect_to = bbp_get_redirect_to(); 369 if ( bbp_get_pending_status_id() === $topic_data['post_status'] ) { 371 370 372 // Get the topic URL373 $redirect_url = bbp_get_topic_permalink( $topic_id, $redirect_to);371 // Add an error 372 bbp_add_error( 'bbp_topic_moderated', esc_html__( 'Your topic is pending moderation.', 'bbpress' ) ); 374 373 375 // Add view all? 376 if ( bbp_get_view_all() || ! empty( $view_all ) ) { 374 /** Approved **********************************************************/ 377 375 378 // User can moderate, so redirect to topic with view all set 379 if ( current_user_can( 'moderate', $topic_id ) ) { 380 $redirect_url = bbp_add_view_all( $redirect_url ); 376 } else { 381 377 382 // User cannot moderate, so redirect to forum 383 } else { 384 $redirect_url = bbp_get_forum_permalink( $forum_id ); 385 } 386 } 378 // Redirect to 379 $redirect_to = bbp_get_redirect_to(); 387 380 388 // Allow to be filtered389 $redirect_url = apply_filters( 'bbp_new_topic_redirect_to', $redirect_url, $redirect_to, $topic_id);381 // Get the topic URL 382 $redirect_url = bbp_get_topic_permalink( $topic_id, $redirect_to ); 390 383 391 /** Successful Save ***************************************************/ 384 // Add view all? 385 if ( bbp_get_view_all() || ! empty( $view_all ) ) { 392 386 393 // Redirect back to new topic 394 bbp_redirect( $redirect_url ); 387 // User can moderate, so redirect to topic with view all set 388 if ( current_user_can( 'moderate', $topic_id ) ) { 389 $redirect_url = bbp_add_view_all( $redirect_url ); 395 390 391 // User cannot moderate, so redirect to forum 392 } else { 393 $redirect_url = bbp_get_forum_permalink( $forum_id ); 394 } 395 } 396 397 // Allow to be filtered 398 $redirect_url = apply_filters( 'bbp_new_topic_redirect_to', $redirect_url, $redirect_to, $topic_id ); 399 400 // Redirect back to new topic 401 bbp_redirect( $redirect_url ); 402 } 403 396 404 /** Errors ****************************************************************/ 397 405 398 406 // WP_Error -
src/includes/topics/template.php
3698 3698 */ 3699 3699 function bbp_get_form_topic_content() { 3700 3700 3701 // Default return value 3702 $topic_content = ''; 3703 3701 3704 // Get _POST data 3702 3705 if ( bbp_is_topic_form_post_request() && isset( $_POST['bbp_topic_content'] ) ) { 3703 $topic_content = wp_unslash( $_POST['bbp_topic_content'] );3704 3706 3707 // Use if content was not moderated 3708 if ( ! bbp_has_error( 'bbp_topic_moderated' ) ) { 3709 $topic_content = wp_unslash( $_POST['bbp_topic_content'] ); 3710 } 3711 3705 3712 // Get edit data 3706 3713 } elseif ( bbp_is_topic_edit() ) { 3707 3714 $topic_content = bbp_get_global_post_field( 'post_content', 'raw' ); 3708 3709 // No data3710 } else {3711 $topic_content = '';3712 3715 } 3713 3716 3714 3717 // Filter & return