Tokens::is_valid( $meta,  $token )


Parameters Parameters

$meta

(Required)

$token

(Required)


Top ↑

Return Return

(bool)


Source Source

File: src/core/lib/recipe-parts/trait-tokens.php

	public static function is_valid( $meta, $token ) {
		/**
		 * @var mixed $value
		 * @var array $pieces
		 * @var int $recip_id
		 * @var array $trigger_data
		 * @var int $user_id
		 * @var array $replace_args
		 */
		extract( $token ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract

		if ( ! $pieces ) {
			// Token array is empty.
			return false;
		}

		if ( ! array_key_exists( 2, $pieces ) || empty( $pieces[2] ) ) {
			// Token is missing.
			return false;
		}

		if ( $meta !== $pieces[2] ) {
			// Token doesn't match trigger meta.
			return false;
		}

		if ( ! array_key_exists( 0, $trigger_data ) || empty( $trigger_data[0] ) ) {
			// Trigger data is empty.
			return false;
		}

		if ( empty( $trigger_data[0]['meta'] ) ) {
			// Trigger meta is empty.
			return false;
		}

		return true;
	}