Tribe__Events__Community__Main::outputMessage( string $type = null, bool $echo = true )
Output a message to the user.
Contents
Parameters
- $type
-
(string) (Optional) The message type.
Default value: null
- $echo
-
(bool) (Optional) Whether to display or return the message.
Default value: true
Return
(string) The message.
Source
File: src/Tribe/Main.php
public function outputMessage( $type = null, $echo = true ) { if ( ! $type && ! $this->messageType ) { $type = 'updated'; } elseif ( ! $type && $this->messageType ) { $type = $this->messageType; } $errors = array(); if ( isset( $this->messages ) && ! empty( $this->messages ) ) { $errors = array( array( 'type' => $type, 'message' => '<p>' . join( '</p><p>', $this->messages ) . '</p>', ), ); } $errors = apply_filters( 'tribe_community_events_form_errors', $errors ); if ( ! is_array( $errors ) ) { return ''; } // Prevent the undefined property notice $messages on Community Events shortcodes if ( empty( $this->messages ) ) { $this->messages = array(); } ob_start(); $existing_messages = isset( $this->messages ) ? $this->messages : array(); /** * Allows for adding content before the form's various messages. * * @since 4.5.15 * * @param array $existing_messages The current array of messages to display on the form; empty array if none exist. */ do_action( 'tribe_community_events_before_form_messages', $existing_messages ); foreach ( $errors as $error ) { printf( '<div class="tribe-community-notice tribe-community-notice-%1$s">%2$s</div>', esc_attr( $error[ 'type' ] ), wp_kses_post( $error[ 'message' ] ) ); } unset( $this->messages ); if ( $echo ) { echo ob_get_clean(); } else { return ob_get_clean(); } }
Changelog
Version | Description |
---|---|
1.0 | Introduced. |