1 | <?php |
||
15 | class AdminNotices { |
||
16 | /** |
||
17 | * Write a persistent message to the admin view. |
||
18 | * Useful to alert the admin to take a certain action. |
||
19 | * The id is a unique ID that can be cleared once the admin |
||
20 | * completes the action. |
||
21 | * |
||
22 | * eg: add_admin_notice('twitter_services_no_api', |
||
23 | * 'Before your users can use Twitter services on this site, you must set up |
||
24 | * the Twitter API key in the <a href="link">Twitter Services Settings</a>'); |
||
25 | * |
||
26 | * @param string $id A unique ID that your plugin can remember |
||
27 | * @param string $message Body of the message |
||
28 | * |
||
29 | * @return bool |
||
30 | */ |
||
31 | function add($id, $message) { |
||
56 | |||
57 | /** |
||
58 | * Remove an admin notice by ID. |
||
59 | * |
||
60 | * eg In actions/twitter_service/save_settings: |
||
61 | * if (is_valid_twitter_api_key()) { |
||
62 | * delete_admin_notice('twitter_services_no_api'); |
||
63 | * } |
||
64 | * |
||
65 | * @param string $id The unique ID assigned in add_admin_notice() |
||
66 | * |
||
67 | * @return bool |
||
68 | */ |
||
69 | function delete($id) { |
||
89 | |||
90 | /** |
||
91 | * Get admin notices. An admin must be logged in since the notices are private. |
||
92 | * |
||
93 | * @param int $limit Limit |
||
94 | * |
||
95 | * @return array Array of admin notices |
||
96 | */ |
||
97 | function find($limit = 10) { |
||
105 | |||
106 | /** |
||
107 | * Check if an admin notice is currently active. |
||
108 | * |
||
109 | * @param string $id The unique ID used to register the notice. |
||
110 | * |
||
111 | * @return bool |
||
112 | * @since 1.8.0 |
||
113 | */ |
||
114 | function exists($id) { |
||
126 | } |