BBP_Replies_Admin::toggle_reply_notice()

Toggle reply notices

Description

Display the success/error notices from BBP_Admin::toggle_reply()

Source

File: bp-forums/admin/replies.php

556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
public function toggle_reply_notice() {
 
    if ( $this->bail() ) return;
 
    // Only proceed if GET is a reply toggle action
    if ( bbp_is_get_request() && !empty( $_GET['bbp_reply_toggle_notice'] ) && in_array( $_GET['bbp_reply_toggle_notice'], array( 'spammed', 'unspammed' ) ) && !empty( $_GET['reply_id'] ) ) {
        $notice     = $_GET['bbp_reply_toggle_notice'];         // Which notice?
        $reply_id   = (int) $_GET['reply_id'];                  // What's the reply id?
        $is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure?
 
        // Empty? No reply?
        if ( empty( $notice ) || empty( $reply_id ) )
            return;
 
        // Get reply and bail if empty
        $reply = bbp_get_reply( $reply_id );
        if ( empty( $reply ) )
            return;
 
        $reply_title = bbp_get_reply_title( $reply->ID );
 
        switch ( $notice ) {
            case 'spammed' :
                $message = $is_failure === true ? sprintf( __( 'There was a problem marking the reply "%1$s" as spam.', 'buddyboss' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully marked as spam.', 'buddyboss' ), $reply_title );
                break;
 
            case 'unspammed' :
                $message = $is_failure === true ? sprintf( __( 'There was a problem unmarking the reply "%1$s" as spam.', 'buddyboss' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully unmarked as spam.', 'buddyboss' ), $reply_title );
                break;
        }
 
        // Do additional reply toggle notice filters (admin side)
        $message = apply_filters( 'bbp_toggle_reply_notice_admin', $message, $reply->ID, $notice, $is_failure );
 
        ?>
 
        <div id="message" class="<?php echo $is_failure === true ? 'error' : 'updated'; ?> fade">
            <p style="line-height: 150%"><?php echo esc_html( $message ); ?></p>
        </div>
 
        <?php
    }
}

Changelog

Changelog
Version Description
bbPress (r2740) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.