Em_Tokens::parse_em_tokens( $value,  $pieces,  $recipe_id,  $trigger_data,  $user_id,  $replace_args )

Parse the token.


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(Required)

$replace_args

(Required)


Top ↑

Return Return

(null|string)


Source Source

File: src/integrations/events-manager/tokens/em-tokens.php

	public function parse_em_tokens( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {

		if (
			! in_array( 'EMEVENTS', $pieces, true ) &&
			! in_array( 'SELECTEDEVENT', $pieces, true ) &&
			! in_array( 'EVENTREGISTER', $pieces, true ) &&
			! in_array( 'ANONBOOKINGAPPROVED', $pieces, true ) &&
			! in_array( 'ANONEVENTREGISTER', $pieces, true )
		) {
			return $value;
		}
		if ( empty( $trigger_data ) ) {
			return $value;
		}
		foreach ( $trigger_data as $trigger ) {
			if ( empty( $trigger ) ) {
				continue;
			}

			$meta_key       = $pieces[2];
			$trigger_id     = absint( $trigger['ID'] );
			$trigger_log_id = absint( $replace_args['trigger_log_id'] );
			$parse_tokens   = array(
				'trigger_id'     => $trigger_id,
				'trigger_log_id' => $trigger_log_id,
				'user_id'        => $user_id,
			);

			$value = Automator()->db->trigger->get_token_meta( $meta_key, $parse_tokens );
		}

		return $value;
	}