Clanbite JavaScript Since 1.5.0

wp.hooks.applyFilters( 'clanbite.toasts.element', HTMLElement|null element, Object payload, {{id: string, element: HTMLElement}} handle )

Lets a handler build the toast element itself (custom markup).

Return an HTMLElement to use it instead of the default. Clanbite still places it in the stack and runs the timer, hover pause, Escape and overflow handling; add your own close control that calls handle.dismiss(). Return null (the default) for the standard toast.

Filter JavaScript

Parameters

$element (HTMLElement|null)

Default null.

$payload (Object)

Toast options.

$handle ({{id: string, element: HTMLElement}})

The toast handle (element is set after this filter).

Example

wp.hooks.addFilter( 'clanbite.toasts.element', 'my-plugin/handler', function ( element, payload, handle ) {
	return element;
} );

Defined in assets/js/clanbite-toasts.js

Changelog

VersionDescription
1.5.0Introduced.