BBP_Topics_Admin::toggle_topic_notice()
Toggle topic notices
Description
Display the success/error notices from BBP_Admin::toggle_topic()
Source
File: bp-forums/admin/topics.php
public function toggle_topic_notice() { if ( $this->bail() ) return; // Only proceed if GET is a topic toggle action if ( bbp_is_get_request() && !empty( $_GET['bbp_topic_toggle_notice'] ) && in_array( $_GET['bbp_topic_toggle_notice'], array( 'opened', 'closed', 'super_sticked', 'sticked', 'unsticked', 'spammed', 'unspammed' ) ) && !empty( $_GET['topic_id'] ) ) { $notice = $_GET['bbp_topic_toggle_notice']; // Which notice? $topic_id = (int) $_GET['topic_id']; // What's the topic id? $is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure? // Bais if no topic_id or notice if ( empty( $notice ) || empty( $topic_id ) ) return; // Bail if topic is missing $topic = bbp_get_topic( $topic_id ); if ( empty( $topic ) ) return; $topic_title = bbp_get_topic_title( $topic->ID ); switch ( $notice ) { case 'opened' : $message = $is_failure === true ? sprintf( __( 'There was a problem opening the discussion "%1$s".', 'buddyboss' ), $topic_title ) : sprintf( __( 'Discussion "%1$s" successfully opened.', 'buddyboss' ), $topic_title ); break; case 'closed' : $message = $is_failure === true ? sprintf( __( 'There was a problem closing the discussion "%1$s".', 'buddyboss' ), $topic_title ) : sprintf( __( 'Discussion "%1$s" successfully closed.', 'buddyboss' ), $topic_title ); break; case 'super_sticked' : $message = $is_failure === true ? sprintf( __( 'There was a problem sticking the discussion "%1$s" to front.', 'buddyboss' ), $topic_title ) : sprintf( __( 'Discussion "%1$s" successfully sticked to front.', 'buddyboss' ), $topic_title ); break; case 'sticked' : $message = $is_failure === true ? sprintf( __( 'There was a problem sticking the discussion "%1$s".', 'buddyboss' ), $topic_title ) : sprintf( __( 'Discussion "%1$s" successfully sticked.', 'buddyboss' ), $topic_title ); break; case 'unsticked' : $message = $is_failure === true ? sprintf( __( 'There was a problem unsticking the discussion "%1$s".', 'buddyboss' ), $topic_title ) : sprintf( __( 'Discussion "%1$s" successfully unsticked.', 'buddyboss' ), $topic_title ); break; case 'spammed' : $message = $is_failure === true ? sprintf( __( 'There was a problem marking the discussion "%1$s" as spam.', 'buddyboss' ), $topic_title ) : sprintf( __( 'Discussion "%1$s" successfully marked as spam.', 'buddyboss' ), $topic_title ); break; case 'unspammed' : $message = $is_failure === true ? sprintf( __( 'There was a problem unmarking the discussion "%1$s" as spam.', 'buddyboss' ), $topic_title ) : sprintf( __( 'Discussion "%1$s" successfully unmarked as spam.', 'buddyboss' ), $topic_title ); break; } // Do additional topic toggle notice filters (admin side) $message = apply_filters( 'bbp_toggle_topic_notice_admin', $message, $topic->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
Version | Description |
---|---|
bbPress (r2727) | 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.