Download the PHP package digitoimistodude/air-notifications without Composer
On this page you can find all versions of the php package digitoimistodude/air-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download digitoimistodude/air-notifications
More information about digitoimistodude/air-notifications
Files in digitoimistodude/air-notifications
Package air-notifications
Short Description Easy way to create and manage public notifications at the site.
License GPL-3.0+
Homepage https://https://github.com/digitoimistodude/air-notifications
Informations about the package air-notifications
Air notifications
You need Advanced Custom Fields PRO plugin installed to use this plugin.
Creates a custom post type for notifications and adds following ACF fields for it:
- Start time
- End time
- Content of the notification
- Allow closing ( used to check if closing button needs to be added )
- Location ( to have different locations for the notifications on the same page )
- Show on page ( specifying certain pages to show the notification on. Notification will be shown on all pages if nothing is selected )
Registering a notification locations
By default Air notifications has one default notification locations set. You might want to change its name, since most likely wont match your use case( using Finnish and location at top of the page ). You can also add more locations if you need them.
Adding/modifying notification locations is done using filter air_notifications_locations
.
Adding notifications to templates
In order to show notifications on your page, you need to call them in your template. This is done by adding the following action to your template. The action takes notification location as a parameter.
Disabling default notification css
If you want to use the default notification template, but dont want to load its css, you can disable it.
Custom notification templates
Default notification template can be replaced by your own custom one. You will need to name it like notification-template-your-location.php
. So if you are replacing the default location you will need to create file notification-template-default.php
. These templates need to be saved in yourtheme/templates
.
In these templates you have access to the notification data by $notification
variable.
If you want to add the ability to dismiss the notification you will need to make sure you do 3 things.
- Make sure your main wrapper by default has
display: none
, this to prevent the notification from appearing and then disappearing if it had already been closed before. - Add class
air-notification
to your main wrapper - Add data attribute
data-notification-id
to your main wrapper and your button. Value for this should be unique since it will be saved in the users localstorage, when closing a notification.$notification['guid']
is created just for this use.
Also note that the notifications have an option is_dismissable
, this can be used to check if your notification needs the button at all.