Skip to:
Content

bbPress.org

Ticket #1988: 1988.diff

File 1988.diff, 3.6 KB (added by tharsheblows, 9 years ago)

display notices at the top of the page based on query string

  • src/includes/common/template.php

     
    25272527        <?php endif;
    25282528}
    25292529
     2530/**
     2531 * Display a notice to the user at the top of the page
     2532 */
     2533
     2534function bbp_posting_notices(){
     2535
     2536        $query_args = $_GET;
     2537        $bbpid = $_GET['bbpid'];
     2538
     2539        // If the post id has been passed through, get the type if possible otherwise assume 'post'
     2540        if( !empty( $bbpid ) ){
     2541                $post_type = ( get_post_type( (int)$bbpid ) ) ? get_post_type( (int)$bbpid ) : '<<em>not a valid post id</em>>';
     2542        }
     2543        else{
     2544                $post_type = 'post';
     2545        }
     2546
     2547        foreach( $query_args as $param => $arg ){
     2548
     2549                if( $param =='pending' ){
     2550                                $notices[] = __( 'Your ' . $post_type . ' has been submitted successfully and is pending moderator approval.', 'bbpress' );
     2551                }
     2552                if( $param == 'test' ){
     2553                                $notices[] = __( 'This is a test, this is only a test.', 'bbpress' );
     2554                }
     2555
     2556        }
     2557
     2558        $notices = apply_filters( 'bbp_posting_notices', $notices, $post_type );
     2559
     2560        if( !empty( $notices ) ){
     2561               
     2562                $notice_list = '<div class="bbp-template-notice error">';
     2563                $notice_list .= '<ul>';
     2564
     2565                foreach( $notices as $notice ){
     2566                       
     2567                        $notice_list .= '<li>' . $notice . '</li>';
     2568                }
     2569
     2570                $notice_list .= '</ul>';
     2571                $notice_list .= '</div>';
     2572
     2573                echo $notice_list;
     2574        }
     2575
     2576}
     2577
    25302578/** Login/logout/register/lost pass *******************************************/
    25312579
    25322580/**
  • src/includes/core/actions.php

     
    155155add_action( 'bbp_template_notices', 'bbp_notice_edit_user_success'           );
    156156add_action( 'bbp_template_notices', 'bbp_notice_edit_user_is_super_admin', 2 );
    157157
     158// Notice that the post (topic or reply) is pending
     159add_action( 'bbp_template_before_single_topic', 'bbp_posting_notices' );
     160add_action( 'bbp_template_before_single_forum', 'bbp_posting_notices' );
     161
     162
    158163// Before Delete/Trash/Untrash Forum
    159164add_action( 'wp_trash_post', 'bbp_trash_forum'   );
    160165add_action( 'trash_post',    'bbp_trash_forum'   );
  • src/includes/replies/functions.php

     
    443443                // Get the reply URL
    444444                $reply_url = bbp_get_reply_url( $reply_id, $redirect_to );
    445445
     446                // If it is pending, add the pending query arg
     447                $reply_url = ( $reply_status != bbp_get_pending_status_id() ) ? $reply_url : add_query_arg( array('pending' => 'true'), $reply_url );
     448
    446449                // Allow to be filtered
    447450                $reply_url = apply_filters( 'bbp_new_reply_redirect_to', $reply_url, $redirect_to, $reply_id );
    448451
  • src/includes/topics/functions.php

     
    405405                // Redirect to
    406406                $redirect_to = bbp_get_redirect_to();
    407407
    408                 // Get the topic URL
    409                 $redirect_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
     408                // If it is pending, add the pending query arg to the forum permalink
     409                $forum_url = bbp_get_forum_permalink( $forum_id );
     410                $topic_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
     411                $redirect_url = ( $topic_status != bbp_get_pending_status_id() ) ? $topic_url : add_query_arg( array('pending' => 'true'), $forum_url );
    410412
     413
    411414                // Add view all?
    412415                if ( bbp_get_view_all() || ! empty( $view_all ) ) {
    413416