key() ); $notices = is_array( $notices ) ? $notices : array(); $notices[] = array( 'type' => in_array( $type, array( 'success', 'warning', 'error', 'info' ), true ) ? $type : 'info', 'message' => (string) $message, ); set_transient( $this->key(), $notices, 5 * MINUTE_IN_SECONDS ); } /** * Print and clear queued notices. * * @return void */ public function render() { $notices = get_transient( $this->key() ); if ( ! is_array( $notices ) || empty( $notices ) ) { return; } delete_transient( $this->key() ); foreach ( $notices as $notice ) { printf( '

%2$s

', esc_attr( $notice['type'] ), esc_html( $notice['message'] ) ); } } }