Skip to:
Content

bbPress.org

Ticket #1988: 1988.2.diff

File 1988.2.diff, 7.0 KB (added by thebrandonallen, 9 years ago)
  • src/includes/common/functions.php

    diff --git src/includes/common/functions.php src/includes/common/functions.php
    index 8afcb14..f8a2ca1 100644
    function bbp_get_view_all( $cap = 'moderate' ) { 
    300300}
    301301
    302302/**
     303 * Append 'pending=type' to query string if it's already there from referer.
     304 *
     305 * @since 2.6.0 bbPress (rXXXX)
     306 *
     307 * @param string $original_link Original Link to be modified.
     308 * @param string $type          The type of object pending.
     309 *
     310 * @return string The link with 'pending=type' appended if necessary.
     311 */
     312function bbp_add_pending( $original_link = '', $type = '' ) {
     313
     314        // Appending the pending=type vars.
     315        $link = add_query_arg( array( 'pending' => $type ), $original_link );
     316
     317        return apply_filters( 'bbp_add_pending', $link, $original_link );
     318}
     319
     320/**
     321 * Remove 'pending=type' from query string.
     322 *
     323 * @since 2.6.0 bbPress (rXXXX)
     324 *
     325 * @param string $original_link Original Link to be modified.
     326 *
     327 * @return string The link with 'pending=type' appended if necessary.
     328 */
     329function bbp_remove_pending( $original_link = '' ) {
     330        return apply_filters( 'bbp_remove_pending', remove_query_arg( 'pending', $original_link ), $original_link );
     331}
     332
     333/**
     334 * If the pending query arg exists.
     335 *
     336 * @since 2.6.0 bbPress (rXXXX)
     337 *
     338 * @return bool Whether the pending query arg exists.
     339 */
     340function bbp_get_pending() {
     341        $retval = ( isset( $_GET['pending'] ) && in_array( $_GET['pending'], array( 'forum', 'topic', 'reply' ), true ) );
     342        return (bool) apply_filters( 'bbp_get_pending', $retval );
     343}
     344
     345/**
    303346 * Assist pagination by returning correct page number
    304347 *
    305348 * @since 2.0.0 bbPress (r2628)
  • src/includes/common/template.php

    diff --git src/includes/common/template.php src/includes/common/template.php
    index 5e938e2..a92282a 100644
    function bbp_allowed_tags() { 
    24932493/** Errors & Messages *********************************************************/
    24942494
    24952495/**
     2496 * Displays the pending forum/topic/reply notice.
     2497 *
     2498 * @since 2.6.0 bbPress (rXXXX)
     2499 *
     2500 * @return void
     2501 */
     2502function bbp_pending_notices() {
     2503
     2504        // Bail if we don't have a pending query arg.
     2505        if ( ! bbp_get_pending() ) {
     2506                return;
     2507        }
     2508
     2509        // Get the pending object type.
     2510        $type = sanitize_key( $_GET['pending'] );
     2511
     2512        // Set the notice text based on the object type.
     2513        switch ( $type ) {
     2514
     2515                case 'forum' :
     2516                        $notice_text = __( 'Your forum has been successfully submitted and is pending moderator approval.', 'bbpress' );
     2517                        break;
     2518
     2519                case 'topic' :
     2520                        $notice_text = __( 'Your topic has been successfully submitted and is pending moderator approval.', 'bbpress' );
     2521                        break;
     2522
     2523                case 'reply' :
     2524                        $notice_text = __( 'Your reply has been successfully submitted and is pending moderator approval.', 'bbpress' );
     2525                        break;
     2526
     2527                default :
     2528                        $notice_text = '';
     2529                        break;
     2530        }
     2531
     2532        // Filter notice text and bail if empty.
     2533        $notice_text = apply_filters( 'bbp_pending_notices', $notice_text, $type );
     2534        if ( empty( $notice_text ) ) {
     2535                return;
     2536        }
     2537
     2538        bbp_add_error( 'bbp_pending_notices', $notice_text, 'message' );
     2539}
     2540
     2541/**
    24962542 * Display possible errors & messages inside a template file
    24972543 *
    24982544 * @since 2.0.0 bbPress (r2688)
  • src/includes/core/actions.php

    diff --git src/includes/core/actions.php src/includes/core/actions.php
    index c9efadb..f847692 100644
    add_action( 'bbp_widgets_init', array( 'BBP_Stats_Widget', 'register_widget' ) 
    146146// Notices (loaded after bbp_init for translations)
    147147add_action( 'bbp_head',             'bbp_login_notices'    );
    148148add_action( 'bbp_head',             'bbp_topic_notices'    );
     149add_action( 'bbp_init',             'bbp_pending_notices'  );
    149150add_action( 'bbp_template_notices', 'bbp_template_notices' );
    150151
    151152// Always exclude private/hidden forums if needed
  • src/includes/forums/functions.php

    diff --git src/includes/forums/functions.php src/includes/forums/functions.php
    index ff6c07e..91dc19c 100644
    function bbp_new_forum_handler( $action = '' ) { 
    343343                // Get the forum URL
    344344                $redirect_url = bbp_get_forum_permalink( $forum_id, $redirect_to );
    345345
     346                // Maybe add a 'pending=forum' query arg.
     347                if ( $forum_data['post_status'] === bbp_get_pending_status_id() ) {
     348                        $redirect_url = bbp_add_pending( $redirect_url, 'forum' );
     349                }
     350
    346351                // Add view all?
    347352                if ( bbp_get_view_all() || ! empty( $view_all ) ) {
    348353
    function bbp_edit_forum_handler( $action = '' ) { 
    627632                // Get the forum URL
    628633                $forum_url = bbp_get_forum_permalink( $forum_id, $redirect_to );
    629634
     635                // Maybe add a 'pending=forum' query arg.
     636                if ( $forum_data['post_status'] === bbp_get_pending_status_id() ) {
     637                        $forum_url = bbp_add_pending( $forum_url, 'forum' );
     638                }
     639
    630640                // Add view all?
    631641                if ( ! empty( $view_all ) ) {
    632642                        $forum_url = bbp_add_view_all( $forum_url );
  • src/includes/replies/functions.php

    diff --git src/includes/replies/functions.php src/includes/replies/functions.php
    index bb66f52..4ab169c 100644
    function bbp_new_reply_handler( $action = '' ) { 
    482482                // Get the reply URL
    483483                $reply_url = bbp_get_reply_url( $reply_id, $redirect_to );
    484484
     485                // Maybe add a 'pending=reply' query arg.
     486                if ( $reply_data['post_status'] === bbp_get_pending_status_id() ) {
     487                        $reply_url = bbp_add_pending( $reply_url, 'reply' );
     488                }
     489
    485490                // Allow to be filtered
    486491                $reply_url = apply_filters( 'bbp_new_reply_redirect_to', $reply_url, $redirect_to, $reply_id );
    487492
    function bbp_edit_reply_handler( $action = '' ) { 
    788793                // Get the reply URL
    789794                $reply_url = bbp_get_reply_url( $reply_id, $redirect_to );
    790795
     796                // Maybe add a 'pending=reply' query arg.
     797                if ( $reply_data['post_status'] === bbp_get_pending_status_id() ) {
     798                        $reply_url = bbp_add_pending( $reply_url, 'reply' );
     799                }
     800
    791801                // Allow to be filtered
    792802                $reply_url = apply_filters( 'bbp_edit_reply_redirect_to', $reply_url, $redirect_to );
    793803
  • src/includes/topics/functions.php

    diff --git src/includes/topics/functions.php src/includes/topics/functions.php
    index 1f5089e..55a1d81 100644
    function bbp_new_topic_handler( $action = '' ) { 
    433433                // Get the topic URL
    434434                $redirect_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
    435435
     436                // Maybe add a 'pending=topic' query arg.
     437                if ( $topic_data['post_status'] === bbp_get_pending_status_id() ) {
     438                        $redirect_url = bbp_add_pending( $redirect_url, 'topic' );
     439                }
     440
    436441                // Add view all?
    437442                if ( bbp_get_view_all() || ! empty( $view_all ) ) {
    438443
    function bbp_edit_topic_handler( $action = '' ) { 
    808813                // Get the topic URL
    809814                $topic_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
    810815
     816                // Maybe add a 'pending=topic' query arg.
     817                if ( $topic_data['post_status'] === bbp_get_pending_status_id() ) {
     818                        $topic_url = bbp_add_pending( $topic_url, 'topic' );
     819                }
     820
    811821                // Add view all?
    812822                if ( ! empty( $view_all ) ) {
    813823                        $topic_url = bbp_add_view_all( $topic_url );