bp_nouveau_push_sitewide_notices()

Add active sitewide notices to the BP template_message global.


Description Description


Source Source

File: bp-templates/bp-nouveau/includes/messages/functions.php

function bp_nouveau_push_sitewide_notices() {
	// Do not show notices if user is not logged in.
	if ( ! is_user_logged_in() || ! bp_is_my_profile() ) {
		return;
	}

	$notice = BP_Messages_Notice::get_active();
	if ( empty( $notice ) ) {
		return;
	}

	$user_id = bp_loggedin_user_id();

	$closed_notices = bp_get_user_meta( $user_id, 'closed_notices', true );
	if ( empty( $closed_notices ) ) {
		$closed_notices = array();
	}

	if ( $notice->id && is_array( $closed_notices ) && ! in_array( $notice->id, $closed_notices, true ) ) {
		// Inject the notice into the template_message if no other message has priority.
		$bp = buddypress();

		if ( empty( $bp->template_message ) ) {
			$message = sprintf(
				'<strong class="subject">%s</strong>
				%s',
				stripslashes( $notice->subject ),
				stripslashes( $notice->message )
			);
			$bp->template_message      = $message;
			$bp->template_message_type = 'bp-sitewide-notice';
		}
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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