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

Add a notice


Description Description

Saves options to the database to be output later


Top ↑

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 an 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() ) {

		// Don't add the notice if we've already dismissed or 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.3.0 Added "flash" option.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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