BBP_Topics_Admin::toggle_topic_notice()
Toggle topic notices
Description Description
Display the success/error notices from BBP_Admin::toggle_topic()
Source Source
File: includes/admin/topics.php
public function toggle_topic_notice() { // Bail if missing topic toggle action if ( ! bbp_is_get_request() || empty( $_GET['topic_id'] ) || empty( $_GET['bbp_topic_toggle_notice'] ) ) { return; } // Bail if not an allowed notice $notice = sanitize_key( $_GET['bbp_topic_toggle_notice'] ); if ( empty( $notice ) || ! in_array( $notice, $this->get_allowed_notice_toggles(), true ) ) { return; } // Bail if no topic_id or notice $topic_id = bbp_get_topic_id( $_GET['topic_id'] ); if ( empty( $topic_id ) ) { return; } // Bail if topic is missing if ( ! bbp_get_topic( $topic_id ) ) { return; } // Use the title in the responses $topic_title = bbp_get_topic_title( $topic_id ); $is_failure = ! empty( $_GET['failed'] ); $message = ''; // Which notice? switch ( $notice ) { case 'opened' : $message = ( $is_failure === true ) ? sprintf( esc_html__( 'There was a problem opening the topic "%1$s".', 'bbpress' ), $topic_title ) : sprintf( esc_html__( 'Topic "%1$s" successfully opened.', 'bbpress' ), $topic_title ); break; case 'closed' : $message = ( $is_failure === true ) ? sprintf( esc_html__( 'There was a problem closing the topic "%1$s".', 'bbpress' ), $topic_title ) : sprintf( esc_html__( 'Topic "%1$s" successfully closed.', 'bbpress' ), $topic_title ); break; case 'super_sticky' : $message = ( $is_failure === true ) ? sprintf( esc_html__( 'There was a problem sticking the topic "%1$s" to front.', 'bbpress' ), $topic_title ) : sprintf( esc_html__( 'Topic "%1$s" successfully stuck to front.', 'bbpress' ), $topic_title ); break; case 'stuck' : $message = ( $is_failure === true ) ? sprintf( esc_html__( 'There was a problem sticking the topic "%1$s".', 'bbpress' ), $topic_title ) : sprintf( esc_html__( 'Topic "%1$s" successfully stuck.', 'bbpress' ), $topic_title ); break; case 'unstuck' : $message = ( $is_failure === true ) ? sprintf( esc_html__( 'There was a problem unsticking the topic "%1$s".', 'bbpress' ), $topic_title ) : sprintf( esc_html__( 'Topic "%1$s" successfully unstuck.', 'bbpress' ), $topic_title ); break; case 'spammed' : $message = ( $is_failure === true ) ? sprintf( esc_html__( 'There was a problem marking the topic "%1$s" as spam.', 'bbpress' ), $topic_title ) : sprintf( esc_html__( 'Topic "%1$s" successfully marked as spam.', 'bbpress' ), $topic_title ); break; case 'unspammed' : $message = ( $is_failure === true ) ? sprintf( esc_html__( 'There was a problem unmarking the topic "%1$s" as spam.', 'bbpress' ), $topic_title ) : sprintf( esc_html__( 'Topic "%1$s" successfully unmarked as spam.', 'bbpress' ), $topic_title ); break; case 'approved' : $message = ( $is_failure === true ) ? sprintf( esc_html__( 'There was a problem approving the topic "%1$s".', 'bbpress' ), $topic_title ) : sprintf( esc_html__( 'Topic "%1$s" successfully approved.', 'bbpress' ), $topic_title ); break; case 'unapproved' : $message = ( $is_failure === true ) ? sprintf( esc_html__( 'There was a problem unapproving the topic "%1$s".', 'bbpress' ), $topic_title ) : sprintf( esc_html__( 'Topic "%1$s" successfully unapproved.', 'bbpress' ), $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 ); $class = ( $is_failure === true ) ? 'error' : 'updated'; // Add the notice bbp_admin()->add_notice( $message, $class, true ); }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |