> For the complete documentation index, see [llms.txt](https://docs.ninjateam.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ninjateam.org/notibar/developer-zone/hooks-and-filters.md).

# Hooks & Filters

If you need to use code to display a Notibar, we will give you 2 simple snippets. Make sure the Notibar plugin is active on your website.

### 1. Simple Integration

Feel free to edit the content as you need.

```
add_action( 'init', function() {

    // Bail gracefully if Notibar isn't active.
        if ( ! function_exists( 'njt_nofi_register_bar' ) ) {
                return;
        }

        njt_nofi_register_bar( [

                // REQUIRED — stable, unique, charset [A-Za-z0-9_-]. Powers the dismissal
                // cookie + data-bar-id. Invalid/missing id → bar dropped. Colliding with a
                // native (admin) bar id → dropped (native always wins).
                'id'      => 'free-shipping-2026',

                'name'    => 'Free shipping',   // OPTIONAL  string ≤100. Admin label only; not shown on fronten notification bar".
                'enabled' => true,                   // OPTIONAL  bool. Default true. false = registered but not rend
                'order'   => 0,                      // OPTIONAL  int. Default 0. NOTE: no effect for injected bars — render after native, in declaration order.

                // ----- content -----------------------------------------------------
                'content' => [
                        'text'           => 'Free shipping all weekend! 🚚', // OPTIONAL  string, HTML allowed (wp_ks message. Default placeholder text.

                        'button' => [                                        // OPTIONAL  object — desktop CTA button
                                'enabled'    => true,                            // OPTIONAL  bool. Default true. fal
                                'text'       => 'Shop now',                      // OPTIONAL  string ≤200. Default "L
                                'url'        => home_url( '/shop' ),             // OPTIONAL  URL (esc_url_raw). Defa
                                'fontWeight' => 500,                             // OPTIONAL  one of 100,200,300,400,500.
                                'newWindow'  => false,                           // OPTIONAL  bool. Default true. Ope
                        ],
                ],
        ] );

} );
```

### 2. Advanced Integration

You can tweak the code further to make it unique based on your requirements.

```
add_action( 'init', function() {

    // Bail gracefully if Notibar isn't active.
        if ( ! function_exists( 'njt_nofi_register_bar' ) ) {
                return;
        }

        njt_nofi_register_bar( [

                // REQUIRED — stable, unique, charset [A-Za-z0-9_-]. Powers the dismissal
                // cookie + data-bar-id. Invalid/missing id → bar dropped. Colliding with a
                // native (admin) bar id → dropped (native always wins).
                'id'      => 'free-shipping-2026',

                'name'    => 'Free shipping',   // OPTIONAL  string ≤100. Admin label only; not shown on fronten notification bar".
                'enabled' => true,                   // OPTIONAL  bool. Default true. false = registered but not rend
                'order'   => 0,                      // OPTIONAL  int. Default 0. NOTE: no effect for injected bars — render after native, in declaration order.

                // ----- content -----------------------------------------------------
                'content' => [
                        'text'           => 'Free shipping all weekend! 🚚', // OPTIONAL  string, HTML allowed (wp_ks message. Default placeholder text.
                        'textMobile'     => 'Free shipping! 🚚',             // OPTIONAL  string, HTML allowed. Used  mobileSeparate = true.
                        'mobileSeparate' => false,                           // OPTIONAL  bool. Default false. true = text/button below.

                        'button' => [                                        // OPTIONAL  object — desktop CTA button
                                'enabled'    => true,                            // OPTIONAL  bool. Default true. fal
                                'text'       => 'Shop now',                      // OPTIONAL  string ≤200. Default "L
                                'url'        => home_url( '/shop' ),             // OPTIONAL  URL (esc_url_raw). Defa
                                'fontWeight' => 500,                             // OPTIONAL  one of 100,200,300,400,500.
                                'newWindow'  => false,                           // OPTIONAL  bool. Default true. Ope
                        ],

                        'buttonMobile' => [                                  // OPTIONAL  object — used ONLY when mob Same shape as `button`.
                                'enabled'    => true,
                                'text'       => 'Shop',
                                'url'        => home_url( '/shop' ),
                                'fontWeight' => 500,
                                'newWindow'  => false,
                        ],
                ],

                // ----- style -------------------------------------------------------
                'style' => [
                        'bgColor'      => '#0a7d34', // OPTIONAL  hex color. Default #9af4cf.
                        'textColor'    => '#ffffff', // OPTIONAL  hex color. Default #1919cf.
                        'btnBgColor'   => '#ffffff', // OPTIONAL  hex color. Default #1919cf.
                        'btnTextColor' => '#0a7d34', // OPTIONAL  hex color. Default #ffffff.
                        'fontSize'     => 15,        // OPTIONAL  int, clamped 8–72 (px). Default 15.
                        'alignment'    => 'center',  // OPTIONAL  one of: center | left | right | space-around. Defau
                        'contentWidth' => 900,       // OPTIONAL  int, clamped 100–3000 (px). Default 900.
                        'positionType' => 'fixed',   // OPTIONAL  one of: fixed | absolute. Default fixed.
                        'placement'    => 'top',     // OPTIONAL  one of: top | bottom. Default top. PRO ONLY — Lite 
                ],

                // ----- display (targeting) ----------------------------------------
                'display' => [
                        'devices'   => [ 'desktop', 'mobile' ], // OPTIONAL  subset of [desktop, mobile]. Default bot

                        'pageLogic' => 'all',                   // OPTIONAL  one of: all | none | include | exclude. pages/home/archives/shop.
                        'pageIds'   => [],

                        'postLogic' => 'all',                   // OPTIONAL  one of: all | none | include | exclude. posts only.
                        'postIds'   => [],                       // OPTIONAL  array of int post IDs. Default [].

                        'cptTypes'  => [],                       // OPTIONAL  array of CPT slugs. Default []. PRO ONL
                        'cptLogic'  => 'all',                   // OPTIONAL  one of: all | none | include | exclude. 
                        'cptIds'    => [],                       // OPTIONAL  array of int CPT IDs. Default []. PRO O

                        'audience'  => 'all',                   // OPTIONAL  one of: all | loggedin | loggedout | role all. PRO ONLY.
                        'roles'     => [],                       // OPTIONAL  array of role slugs (with audience='role') PRO ONLY.
                        'userIds'   => [],                       // OPTIONAL  array of int user IDs (with audience='user') PRO ONLY.
                ],

                // ----- behavior ----------------------------------------------------
                'behavior' => [
                        'hideCloseButton' => 'close', // OPTIONAL  one of: close (dismiss) | toggle (collapse) | disable. Default close.
                        'reopenAfterDays' => 3,       // OPTIONAL  int, clamped 0–365. Days before a dismissed bar reopens. Default 1.
                ],

                // ----- schedule ----------------------------------------------------
                'schedule' => [
                        'enabled'       => false,                  // OPTIONAL  bool. Default false. Master switch for scheduling. block.
                        'useClientTime' => false,                 // OPTIONAL  bool. Default false. true = visitor browser timezone. false = site timezone.
                        'startAt'       => '2026-06-26T00:00',    // OPTIONAL  "YYYY-MM-DDTHH:MM". Default "" (unboun
                        'endAt'         => '2026-06-29T23:59',    // OPTIONAL  "YYYY-MM-DDTHH:MM". Default "" (unboun
                        'dailyWindow'   => [                       // OPTIONAL  object. Default disabled.
                                'enabled' => false,                   // OPTIONAL  bool. Default false.
                                'start'   => '09:00',                 // OPTIONAL  "HH:MM". Default "". May wrap midn
                                'end'     => '17:00',                 // OPTIONAL  "HH:MM". Default "".
                        ],
                        'daysOfWeek'    => [ 0, 1, 2, 3, 4, 5, 6 ], // OPTIONAL  ints 0–6 (Sun–Sat). Default all 7. E
                ],
        ] );

} );
```

If you still need help, feel free to [contact us](/notibar/other-links/support.md).
