Frontend Notifications
This plugin is for developers. The plugin neither has options nor display anything after activation. You have to use hooks to use this plugin.
Display WordPress frontend toast notifications via efn_messages
hook and/or AJAX notifications via 'efn_messages_ajax' hook.
AJAX functionality is disabled by default, you can enable with the efn_enable_ajax
hook.
The plugin check AJAX messages every 10 sec. You can change this with efn_ajax_inerval
hook. Every message will be displyed only once, it will be displayed again after browser reload.
If you want to display the same message multiple times, need to add some field with a unique value per message.
Check for all options and previews: http://lobianijs.com/site/lobibox#notifications
How to use
Only PHP
function my_notifications( $messages ) {
$my_messages = array(
array(
// Every options except msg is optional.
'pauseDelayOnHover' => true,
'continueDelayOnInactiveTab' => false,
// 'closeOnClick' => false,
'delay' => false,
'closable' => false,
'title' => 'No delay',
'msg' => 'Test logged_in',
'roles_users' => 'logged_in',
// Sort messages.
'priority' => 10,
'date' => '2000-12-31 23:59:59',
// Display message in a time frame.
'start' => '2000-12-31 23:59:59',
'end' => '2022-12-31 23:59:59',
),
// ...
);
$messages = array_merge( $messages, $my_messages );
return $messages;
}
add_filter( 'efn_messages', 'my_notifications' );
With AJAX callback
function my_ajax_notifications( $messages ) {
$my_messages = array(
array(
'pauseDelayOnHover' => true,
'continueDelayOnInactiveTab' => false,
// 'closeOnClick' => false,
'delay' => false,
'closable' => false,
'title' => 'No delay',
'msg' => 'Test logged_in',
'roles_users' => 'logged_in',
// This is optional, to react on user dismiss. Only in AJAX available.
'id' => 'some_id',
// Callback function, eg. to remove or react on user dismiss.
'callback' => 'my_ajax_callback_function',
),
// ...
);
$messages = array_merge( $messages, $my_messages );
return $messages;
}
add_filter( 'efn_messages_ajax', 'my_ajax_notifications' );
add_filter( 'efn_enable_ajax', '__return_true' ); // To activate AJAX.
add_filter( 'efn_ajax_inerval', 10000 ); // Change AJAX interval.
function my_ajax_callback_function() {
$element = $_POST['element']; // The options array for the notification.
$my_id = $_POST['element']['id'];
// do something with the infos.
}
add_action('wp_ajax_my_ajax_callback_function', 'my_ajax_callback_function');
add_action('wp_ajax_nopriv_my_ajax_callback_function', 'my_ajax_callback_function');