Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/humanmade/hm-messages
A simple error / success messages API for WordPress
https://github.com/humanmade/hm-messages
Last synced: about 2 months ago
JSON representation
A simple error / success messages API for WordPress
- Host: GitHub
- URL: https://github.com/humanmade/hm-messages
- Owner: humanmade
- Created: 2013-02-28T15:05:15.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-01-19T04:04:23.000Z (over 7 years ago)
- Last Synced: 2024-04-03T15:31:33.338Z (6 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 14
- Watchers: 21
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
hm-messages
===========A simple error / success messages API for WordPress
hm-messages provides an API to send / display success or failure messages in a WordPress theme or wp-admin. Each message is only shown once to the user; hm-messages uses cookies to pass messages between page reqyuests.
To send a message:
```
hm_error_message( 'Please enter a title' );
```To then display any messages, place the following whereever you want the messages to show:
```
hm_the_messages();
```Messaging also supports contexts so it is possible to show different messages in different places. For example, to display messages to do with login above a login form:
```
hm_success_message( 'You have been emailed your password', 'login' );
```And output `login` messsages:
```
hm_the_messages( 'login' );
```### Functions
```
hm_error_message( $message, $context ); // display an error message
hm_success_message( $message, $context ); // display an success messagehm_the_messages( $context ); // display all messages (optionally from a given context)
hm_get_the_messages( $context ); // get all messages as a html string (optionally from a given context)hm_get_messages( $context, $clear_messages = true ); // get the messages as an array, optionally clearing the messages once retreived
```### Gotcha's
You must have a call to `wp_footer` in your theme's `footer.php`.
Styling for messages is not provided, style `.message.error` and `.message.success` in your theme's CSS file.
## Contribution guidelines ##
see https://github.com/humanmade/hm-messages/blob/master/CONTRIBUTING.md