Gatemi Announcement Bar Developer Reference

Filters — free edition

gmabf_bars

The list of bars after they are read and normalized, before one is chosen.

// Add a bar from code, without touching the settings.
add_filter( 'gmabf_bars', function ( $bars ) {
	array_unshift( $bars, GMABF_Bars::normalize_one( array(
		'id'      => 'maintenance',
		'message' => 'Orders placed today ship on Monday.',
		'ends'    => '2026-12-24',
	) ) );
	return $bars;
} );

A bar returned by the filter still has to pass the schedule and must carry no conditions to be shown in the free edition.

Filters — Full edition

Filter Arguments
gmab_bars array $bars The bars, after normalization
gmab_condition_types array $types The condition vocabulary the editor renders from: id ⇒ label, value kind, help
gmab_evaluate_condition bool $matches, array $condition The answer for a condition type the plugin does not know. Default false, which hides the bar
gmab_max_bars int $max How many bars one page may carry
gmab_settings array $settings The merged settings
gmab_modules array $modules The boot module list
gmab_license_api_url, gmab_update_cache_ttl, gmab_update_retry_ttl, gmab_sync_cache_ttl Licensing and update caching

Action gmab_booted fires after every module has booted.

Adding a condition takes both filters:

add_filter( 'gmab_condition_types', function ( $types ) {
	$types['is_weekend'] = array( 'label' => 'It is the weekend', 'value' => 'none', 'help' => '' );
	return $types;
} );

add_filter( 'gmab_evaluate_condition', function ( $matches, $condition ) {
	if ( 'is_weekend' === $condition['type'] ) {
		return in_array( wp_date( 'N' ), array( '6', '7' ), true );
	}
	return $matches;
}, 10, 2 );

Options

Option
gmab_settings enabled (yes/no); full edition also max_bars
gmab_bars A list of bars (below)
gmab_license Licence state (full edition)

Transient gmab_update_payload and cron gmab_license_check belong to the full edition. No tables, no post, order or user meta.

The bar shape

array(
	'id'           => 'spring-sale',  // sanitize_key; unique
	'message'      => '…',            // wp_kses_post
	'button'       => 'Shop now',
	'url'          => 'https://…',     // esc_url_raw
	'position'     => 'top',          // or 'bottom' (full edition)
	'background'   => '#1e1e1e',      // hex colour
	'text'         => '#ffffff',
	'sticky'       => false,          // full edition
	'dismissible'  => true,
	'dismiss_days' => 7,              // 0–365
	'starts'       => '2026-03-01',   // Y-m-d or ''
	'ends'         => '2026-03-31',
	'conditions'   => array( array( 'type' => 'not_page', 'value' => 'checkout' ) ),
	'enabled'      => true,
)

Both editions normalize to this shape, on read as well as on save.

  • Cookie gmab_closed_<id>: one per closed bar, path /, SameSite=Lax, Secure on HTTPS, written by the browser script with that bar's Stays closed for (days) as its lifetime. The snippet also still reads the legacy shared cookie gmab_closed (ids joined by |).
  • The head snippet adds gmab-closed-<id> to <html> and a style rule hiding [data-gmab-id="<id>"] for each closed id. Free edition: an inline script on the src-less handle gmabf-head. Full edition: printed on wp_head at priority 1. Both carry the same JavaScript.

Hooks used

Hook
wp_body_open Prints the top bar
wp_footer Prints the bottom bar (full edition)
wp_enqueue_scripts Registers and, on pages with a bar, enqueues gmab-bar (CSS and JS)

CSS classes

Class Element
.gmab-bar The bar (carries data-gmab-id and data-gmab-days)
.gmab-bar--top, .gmab-bar--bottom Position
.gmab-bar--sticky A sticky bar (full edition)
.gmab-bar__inner The message-and-button row
.gmab-bar__message The message
.gmab-bar__button The button
.gmab-bar__close The × control
html.gmab-closed-<id> Added by the head snippet for a closed bar

Colours come from the custom properties --gmab-bg and --gmab-fg, set in each bar's own style attribute from its settings. Change colours on the settings screen; use your theme's CSS for everything else:

.gmab-bar__message { font-weight: 600; }
.gmab-bar__button { border-radius: 999px; }
Shopping Cart
Scroll to Top