WP_Error::get_error_messages

Advertisement

Summery Summery

Retrieve all error messages or error messages matching code.

Syntax Syntax

WP_Error::get_error_messages( string|int $code = '' )

Parameters Parameters

$code

(string|int) (Optional) Retrieve messages matching code, if exists.

Default value: ''

Return Return

(array) Error strings on success, or empty array on failure (if using code parameter).

Source Source

File: wp-includes/class-wp-error.php

	public function get_error_messages( $code = '' ) {
		// Return all messages if no code specified.
		if ( empty( $code ) ) {
			$all_messages = array();
			foreach ( (array) $this->errors as $code => $messages ) {
				$all_messages = array_merge( $all_messages, $messages );
			}

			return $all_messages;
		}

		if ( isset( $this->errors[ $code ] ) ) {
			return $this->errors[ $code ];
		} else {
			return array();
		}
	}

Advertisement

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

What are you looking for?