BBP_Forums_Admin::toggle_forum_notice()

Toggle forum notices


Description Description

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


Source Source

File: includes/admin/forums.php

	public function toggle_forum_notice() {

		// Bail if missing forum toggle action
		if ( ! bbp_is_get_request() || empty( $_GET['forum_id'] ) || empty( $_GET['bbp_forum_toggle_notice'] ) ) {
			return;
		}

		// Bail if not an allowed notice
		$notice = sanitize_key( $_GET['bbp_forum_toggle_notice'] );
		if ( empty( $notice ) || ! in_array( $notice, $this->get_allowed_notice_toggles(), true ) ) {
			return;
		}

		// Bail if no forum_id or notice
		$forum_id = bbp_get_forum_id( $_GET['forum_id'] );
		if ( empty( $forum_id ) ) {
			return;
		}

		// Bail if forum is missing
		if ( ! bbp_get_forum( $forum_id ) ) {
			return;
		}

		// Use the title in the responses
		$forum_title = bbp_get_forum_title( $forum_id );
		$is_failure  = ! empty( $_GET['failed'] );
		$message     = '';

		switch ( $notice ) {
			case 'opened' :
				$message = ( $is_failure === true )
					? sprintf( esc_html__( 'There was a problem opening the forum "%1$s".', 'bbpress' ), $forum_title )
					: sprintf( esc_html__( 'Forum "%1$s" successfully opened.',             'bbpress' ), $forum_title );
				break;

			case 'closed' :
				$message = ( $is_failure === true )
					? sprintf( esc_html__( 'There was a problem closing the forum "%1$s".', 'bbpress' ), $forum_title )
					: sprintf( esc_html__( 'Forum "%1$s" successfully closed.',             'bbpress' ), $forum_title );
				break;
		}

		// Do additional forum toggle notice filters (admin side)
		$message = apply_filters( 'bbp_toggle_forum_notice_admin', $message, $forum_id, $notice, $is_failure );
		$class   = ( $is_failure === true )
			? 'error'
			: 'updated';

		// Add the notice
		bbp_admin()->add_notice( $message, $class, true );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.