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

	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.