Affwp_Tokens::parse_affwp_trigger_tokens( $value,  $pieces,  $recipe_id,  $trigger_data, int $user_id,  $replace_args )


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(int) (Required)

$replace_args

(Required)


Top ↑

Return Return

(int|mixed|string)


Source Source

File: src/integrations/affiliate-wp/tokens/affwp-tokens.php

	function parse_affwp_trigger_tokens( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {
		if ( $pieces ) {
			if ( in_array( 'SPECIFICETYPEREF', $pieces ) ||
			     in_array( 'SENTENCE_HUMAN_READABLE', $pieces ) ||
			     in_array( 'AFFWPAPPROVAL', $pieces ) ||
			     in_array( 'APPROVALWAITING', $pieces ) ||
			     in_array( 'APPROVEDAFFILIATE', $pieces ) ||
			     in_array( 'USERBECOMESAFFILIATE', $pieces ) ||
			     in_array( 'NEWAFFILIATE', $pieces ) ||
			     in_array( 'ACCOUNTAPPROVED', $pieces ) ||
			     in_array( 'AFFWPREJECTREFERRAL', $pieces ) ||
			     in_array( 'AFFWPPAIDREFERRAL', $pieces )
			) {
				global $wpdb;
				$trigger_id     = $pieces[0];
				$trigger_meta   = $pieces[2];
				$trigger_log_id = isset( $replace_args['trigger_log_id'] ) ? absint( $replace_args['trigger_log_id'] ) : 0;
				$entry          = $wpdb->get_var( "SELECT meta_value
													FROM {$wpdb->prefix}uap_trigger_log_meta
													WHERE meta_key = '{$trigger_meta}'
													AND automator_trigger_log_id = {$trigger_log_id}
													AND automator_trigger_id = {$trigger_id}
													LIMIT 0,1" );

				$value = maybe_unserialize( $entry );
			}
		}

		return $value;
	}