| @@ -1224,8 +1224,38 @@ | ||
| 1224 | 1224 | return true; |
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | /** |
| 1228 | + * Un-hide a MainWP message for the current user. | |
| 1229 | + * | |
| 1230 | + * Removes the notice ID from the saved notice status so the message | |
| 1231 | + * can be displayed again. | |
| 1232 | + * | |
| 1233 | + * @param mixed $notice_id Notice ID. | |
| 1234 | + * | |
| 1235 | + * @return bool True if the notice was un-hidden, otherwise false. | |
| 1236 | + */ | |
| 1237 | + public static function unhide_mainwp_message( $notice_id ) { | |
| 1238 | + $status = get_user_option( 'mainwp_notice_saved_status' ); | |
| 1239 | + | |
| 1240 | + if ( ! is_array( $status ) || ! isset( $status[ $notice_id ] ) ) { | |
| 1241 | + return false; | |
| 1242 | + } | |
| 1243 | + | |
| 1244 | + unset( $status[ $notice_id ] ); | |
| 1245 | + | |
| 1246 | + if ( empty( $status ) ) { | |
| 1247 | + return delete_user_option( get_current_user_id(), 'mainwp_notice_saved_status' ); | |
| 1248 | + } | |
| 1249 | + | |
| 1250 | + return update_user_option( | |
| 1251 | + get_current_user_id(), | |
| 1252 | + 'mainwp_notice_saved_status', | |
| 1253 | + $status | |
| 1254 | + ); | |
| 1255 | + } | |
| 1256 | + | |
| 1257 | + /** | |
| 1228 | 1258 | * Method get_hide_notice_status() |
| 1229 | 1259 | * |
| 1230 | 1260 | * Check whenther or not to show the MainWP Message. |
| 1231 | 1261 | * |