PluginProbe
oik / 2.3
oik v2.3
1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.2 1.3 1.3.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.0.1 2.1 2.2 2.3 2.4 2.5 2.5.1 All 71 releases
oik / includes / bw_messages.php

bw_messages.php in oik 2.3, at includes/bw_messages.php

86 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // (C) Copyright Bobbing Wide 2013, 2014
2
3 /**
4 * Issue a message for a particular field
5 *
6 * Similar to add_settings_error() but not restricted to use by admin functions
7 *
8 * @param string $field - field name e.g. _dtib_location
9 * @param string $code - message code e.g. "invalid_location"
10 * @param string $text - the message text e.g. "Invalid Location, please correct"
11 * @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
12 */
13 if ( !function_exists( "bw_issue_message" ) ) {
14 function bw_issue_message( $field, $code, $text, $type='error' ) {
15 bw_trace2();
16 global $bw_messages;
17 if ( !isset( $bw_messages ) ) {
18 $bw_messages = array();
19 }
20 $bw_messages[] = array( "field" => $field
21 , "code" => $code
22 , "text" => $text
23 , "type" => $type
24 );
25 return( false );
26 }
27 }
28
29 /**
30 * Return number of messages to display
31 *
32 * @return integer - number of messages, if any
33 */
34
35 if ( !function_exists( "bw_query_messages" ) ) {
36 function bw_query_messages() {
37 global $bw_messages;
38 $messages = isset( $bw_messages );
39 if ( $messages ) {
40 $messages = count( $bw_messages );
41 }
42 return( $messages );
43 }
44 }
45
46 /**
47 * Display a message
48 *
49 * The message display is similar to the message display for settings errors
50 *
51 * @param array $bw_message - a message field
52 * @return bool - true
53 */
54
55 if ( !function_exists( "bw_display_message" ) ) {
56 function bw_display_message( $bw_message ) {
57 $classes = $bw_message['field'];
58 $classes .= " ";
59 $classes .= $bw_message['type'];
60 sdiv( $classes, $bw_message['code'] );
61 p( $bw_message['text'] );
62 ediv();
63 return( true );
64 }
65 }
66
67 /**
68 * Display the messages
69 *
70 * Display the set of messages in @global $bw_messages
71 *
72 * @TODO - display messages associated with a particular 'field' or area of the form.
73 */
74 if ( !function_exists( "bw_display_messages" ) ) {
75 function bw_display_messages() {
76 global $bw_messages;
77 $displayed = false;
78 sdiv( "bw_messages" );
79 foreach ( $bw_messages as $key => $bw_message ) {
80 $displayed = bw_display_message( $bw_message );
81 }
82 ediv();
83 return( $displayed );
84 }
85 }
86