WP Manifestindependent plugin directory
manifest / utilities / go-messagearea

Gigaom MessageArea

Provides a hook-able message area widget for...messages

★ 1stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/gigaom/go-messagearea/archive/refs/heads/master.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Provide a hook-able message area

Instructions

Adding this widget to your layout gives you an area to inject messages (sorted by priority) onto your site. Here's how:

Add a message

PHP

$message = array(
    'id' => 'bacon-is-tasty',
    'type' => 'success',
    'contents' => '<h2>Bacon is tasty!</h2><p>This is a known fact.</p>',
);

$priority = 10;

// inserts the message
do_action( 'go_messagearea_add', $message, $priority );

// replaces all messages with the provided message
do_action( 'go_messagearea_replace', $message, $priority );

JS

var message = {
    id: 'bacon-is-tasty',
    type: 'success',
    contents: '<h2>Bacon is tasty!</h2><p>This is a known fact.</p>'
};

var priority = 10;

// inserts a message
$( document ).trigger( 'go-messagearea-add', message, priority );
// or
go_messagearea.insert( message, priority );

// replaces messages with provided message
$( document ).trigger( 'go-messagearea-replace', message, priority );
// or
go_messagearea.replace( message, priority );

Remove messages

PHP

// delete any message with the provided message id
do_action( 'go_messagearea_remove', $message_id );

// delete any message with the provided message id in the specific priority order
do_action( 'go_messagearea_remove', $message_id, $priority );

JS

$( document ).trigger( 'go-messagearea-remove', message_code );

// or

go_messagearea.remove( message_code );

Get messages

PHP

$messages = apply_filters( 'go_messagearea_get', array() );

JS

console.log( go_messagearea.messages );

Add element that closes the message area

Any element within a message area that has the class go-messagearea-close will, when clicked, close the message.