Zum Inhalt springen

Configuration

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Notice is configured on one screen, WooCommerce → Announcement Bar, with a live preview that updates as you edit. Every value is stored in a single array option, notice_settings. Defaults come from the packaged config/defaults.php and are merged under whatever you save, so a missing key always has a safe value.

The save capability is manage_woocommerce, so shop managers can edit the bar, not just administrators. On save, colours are run through sanitize_hex_color, the message through wp_kses, text fields through sanitize_text_field, and the URL through esc_url_raw.

enabled (boolean, off by default). The master switch. When off, nothing renders on the storefront and no CSS or JavaScript is enqueued. The bar also stays off when enabled but the message is empty.

message (string, default empty). The text shoppers see. A small safe-HTML allow-list is kept on both save and render, using the same map for each: <strong>, <b>, <em>, <i>, <br>, <span>, and <a> (with href, title, target, rel). Anything outside the list is stripped, so the message is always safe to print at the top of every page.

An optional button shown after the message. It only renders when both a label and a URL are set; either one alone is ignored.

  • link_label (string), the button text, e.g. Shop the sale. Blank = no button.
  • link_url (string), the destination, stored with esc_url_raw. Use a full URL including https://.
  • link_new_tab (boolean), open in a new tab. When on, the link gets target="_blank" and rel="noopener noreferrer" automatically.

Three hex colours, each validated with sanitize_hex_color and falling back to its default if blank or invalid:

  • bg_color, bar background, default #1e1e1e.
  • text_color, message text, default #ffffff.
  • link_color, accent colour, default #ffd166. Used for links inside the message and for the CTA button fill.

The colours are written as the inline CSS custom properties --notice-bg, --notice-fg and --notice-link on the bar element, so you can override them from a theme stylesheet without fighting specificity. The bar styles also derive an “on air” signal colour from --notice-link.

The default palette (near-black bar, white text, amber accent) is chosen to read cleanly on any theme, so most stores never touch these.

  • dismissible (boolean, on by default). Adds a close button. The choice is stored in the visitor’s browser via localStorage, no cookies, no personal data. When off, the bar has no close control and the dismissal script is never loaded.
  • dismiss_days (integer, default 7, clamped to 0 or more). How long a dismissal sticks before the bar can reappear. 0 means remember forever.

The localStorage key is versioned with the first eight characters of an MD5 of the message text (notice_dismissed_{bar-id}_{hash}). Changing the message changes the key, so a remembered dismissal no longer matches and the new announcement shows for everyone, no manual reset.

SettingsRepository::isActive() returns true only when a bar is enabled and has a non-empty message (after stripping tags and whitespace). The renderer and the admin preview share this one check, so what you preview is what renders. Out of that state, the front end loads nothing.

All settings live in notice_settings. Nothing leaves your database, Notice makes no external request. Deleting the plugin from the Plugins screen runs uninstall.php, which removes notice_settings and notice_db_version. There is no per-post or per-user data to clean up.

The storefront CSS is built on the --notice-* custom properties, with focus-visible outlines, a small breathing “on air” pip, a one-time light sweep on first reveal, and a collapse-on-dismiss animation, all disabled under prefers-reduced-motion, where the bar simply shows and hides. None of this needs configuration. See Using the announcement bar for the storefront behaviour and the developer filters.