Skip to:
Content

bbPress.org

Ticket #1988: 1988.sample.diff

File 1988.sample.diff, 3.0 KB (added by tharsheblows, 10 years ago)
  • 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
     158add_action( 'bbp_template_before_single_topic', 'bbp_posting_notices' );
     159
    158160// Before Delete/Trash/Untrash Forum
    159161add_action( 'wp_trash_post', 'bbp_trash_forum'   );
    160162add_action( 'trash_post',    'bbp_trash_forum'   );
  • src/templates/default/bbpress-functions.php

     
    8585                /** Override **********************************************************/
    8686
    8787                do_action_ref_array( 'bbp_theme_compat_actions', array( &$this ) );
     88
     89                /** Test posting notice filter */
     90                add_filter( 'bbp_posting_notices', array( $this, 'mjj_custom_notices' ), 10, 2 );
    8891        }
    8992
    9093        /**
     
    460463                // Action succeeded
    461464                bbp_ajax_response( true, bbp_get_user_subscribe_link( $attrs, $user_id, false ), 200 );
    462465        }
     466
     467        function mjj_custom_notices( $notices, $post_type = '' ){
     468                $notices['filter_test'] = __('This is a test of the filter and if there is valid bbpid in the query string, the post type will be here: ' . $post_type );
     469                return $notices;
     470        }
    463471}
    464472new BBP_Default();
    465473endif;