UNCANNYCEUS_EARNS_NUMBER_CEUS::tokens( $value,  $pieces,  $recipe_id,  $trigger_data,  $user_id,  $replace_args = array() )


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(Required)


Top ↑

Return Return

(string|null)


Source Source

File: src/integrations/uncanny-ceus/triggers/uncannyceus-earns-number-ceus.php

	public function tokens( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args = [] ) {

		if ( $pieces ) {
			if (
			in_array( $this->trigger_code, $pieces, true )
			) {

				if ( ! absint( $user_id ) ) {
					return $value;
				}

				if ( ! absint( $recipe_id ) ) {
					return $value;
				}

				$replace_pieces = $replace_args['pieces'];
				$trigger_log_id = $replace_args['trigger_log_id'];
				$run_number     = $replace_args['run_number'];
				$user_id        = $replace_args['user_id'];
				$trigger_id     = absint( $replace_pieces[0] );

				// Verb can be found from trigger meta
				if ( in_array( $this->trigger_meta, $pieces ) ) {
					$value = Automator()->get->maybe_get_meta_value_from_trigger_log( $this->trigger_meta, $trigger_id, $trigger_log_id, $run_number, $user_id );

					return $value;
				}

				// Verb can be found from trigger meta
				if ( in_array( $this->trigger_meta . '_title', $pieces ) ) {
					$value = Automator()->get->maybe_get_meta_value_from_trigger_log( $this->trigger_meta . '_title', $trigger_id, $trigger_log_id, $run_number, $user_id );

					return $value;
				}

				// Verb can be found from trigger meta
				if ( in_array( $this->trigger_meta . '_date', $pieces ) ) {
					$value = Automator()->get->maybe_get_meta_value_from_trigger_log( $this->trigger_meta . '_date', $trigger_id, $trigger_log_id, $run_number, $user_id );

					return date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), absint( $value ) );
				}
			}
		}

		return $value;
	}