Tribe__Admin__Notices::render( string $slug, string $content = null, boolean $return = true, string|bool $wrap = false )

This is a helper to actually print the Message


Parameters

$slug

(string) (Required) The name of the notice.

$content

(string) (Optional) The content of the notice.

Default value: null

$return

(boolean) (Optional) Echo or return the content.

Default value: true

$wrap

(string|bool) (Optional) An optional HTML tag to wrap the content.

Default value: false


Top ↑

Return

(bool|string)


Top ↑

Source

File: src/Tribe/Admin/Notices.php

	public function render( $slug, $content = null, $return = true, $wrap = false ) {
		if ( ! $this->exists( $slug ) ) {
			return false;
		}

		// Bail if we already rendered
		if ( $this->is_rendered( $slug ) ) {
			if ( $this->is_rendered_html( $slug, $content ) && ! $return ) {
				echo $content;
			}

			return false;
		}

		$notice = $this->get( $slug );
		$this->notices[ $slug ]->is_rendered = true;

		$classes = array( 'tribe-dismiss-notice', 'notice' );
		$classes[] = sanitize_html_class( 'notice-' . $notice->type );
		$classes[] = sanitize_html_class( 'tribe-notice-' . $notice->slug );

		if ( $notice->dismiss ) {
			$classes[] = 'is-dismissible';
		}

		// Prevents Empty Notices
		if ( empty( $content ) ) {
			return false;
		}

		if ( is_string( $wrap ) ) {
			$content = sprintf( '<%1$s>' . $content . '</%1$s>', $wrap );
		}

		$html = sprintf( '<div class="%s" data-ref="%s">%s</div>', implode( ' ', $classes ), $notice->slug, $content );

		if ( ! $return ) {
			echo $html;
		}

		return $html;
	}

Top ↑

Changelog

Changelog
Version Description
4.3 Introduced.