LLMS_Admin_Notices::add_notice( string $notice_id, string $html_or_options = '', array $options = array() )

Add a notice Saves options to the database to be output later


Description Description


Parameters Parameters

$notice_id

(string) (Required) unique id of the notice

$html_or_options

(string) (Optional) html content of the notice for short notices that don't need a template or array of options, html of the notice will be in a template passed as the "template" param of this array

Default value: ''

$options

(array) (Optional) array of options, when passing html directly via $html_or_options notice options should be passed in this array

Default value: array()


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/admin/class.llms.admin.notices.php

	public static function add_notice( $notice_id, $html_or_options = '', $options = array() ) {

		// dont add the notice if we've already dismissed of delayed it
		if ( get_transient( 'llms_admin_notice_' . $notice_id . '_delay' ) ) {
			return;
		}

		if ( is_array( $html_or_options ) ) {

			$options = $html_or_options;

		} else {

			$options['html'] = $html_or_options;
		}

		$options = wp_parse_args( $options, array(
			'dismissible' => true,
			'dismiss_for_days' => 7,
			'flash' => false, // if true, will delete the notice after displaying it
			'html' => '',
			'remind_in_days' => 7,
			'remindable' => false,
			'type' => 'info', // info, warning, success, error
			'template' => false, // template name, eg "admin/notices/notice.php"
			'template_path' => '', // allow override of default LLMS()->template_path()
			'default_path' => '', // allow override of default path LLMS()->plugin_path() . '/templates/'
								  // an addon may add a notice and pass it's own path in here
		) );

		self::$notices = array_unique( array_merge( self::get_notices(), array( $notice_id ) ) );
		update_option( 'llms_admin_notice_' . $notice_id, $options );

	}

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.