Badgeos_Tokens::parse_token( $value,  $pieces,  $recipe_id,  $trigger_data,  $user_id,  $replace_args )

Parse the token as usual.

Contents


Return Return

(string) the value of the token.


Source Source

File: src/integrations/badgeos/tokens/badgeos-tokens.php

	public function parse_token( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {
		$award_type = $trigger_data[0]['meta']['BOAWARDTYPES'] ?? '';
		$token      = $pieces[2] ?? '';
		if ( ! empty( $token ) && ! empty( $award_type ) ) {
			if ( 'BOAWARDTYPES' === $token ) {
				if ( $award_type != '-1' ) {
					$value = $trigger_data[0]['meta']['BOAWARDTYPES_readable'] ?? '';
				} else {
					global $wpdb;
					$meta_value = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->prefix}uap_trigger_log_meta WHERE meta_key = %s AND automator_trigger_id = %d AND automator_trigger_log_id = %d ORDER BY ID DESC LIMIT 0,1", $token, $trigger_data[0]['ID'], $replace_args['trigger_log_id'] ) );
					if ( ! empty( $meta_value ) ) {
						$value = maybe_unserialize( $meta_value );
					}
				}
			}
		}
		return $value;
	}