MAILCHIMP_TOKENS::save_token_data( mixed $args, mixed $trigger )

Save the token data.


Parameters Parameters

$args

(Required)

$trigger

(Required)


Top ↑

Return Return

(void)


Source Source

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

	public function save_token_data( $args, $trigger ) {

		if ( ! isset( $args['trigger_args'] ) || ! isset( $args['entry_args']['code'] ) ) {
			return;
		}

		$triggers = array( 'ANON_MAILCHIMP_CONTACT_UNSUBSCRIBED', 'ANON_MAILCHIMP_CONTACT_ADDED', 'ANON_MAILCHIMP_CONTACT_EMAIL_CHANGED' );

		if ( in_array( $args['entry_args']['code'], $triggers, true ) ) {

			$mailchimp_event_data = array_shift( $args['trigger_args'] );

			if ( isset( $mailchimp_event_data['data'] ) && ! empty( $mailchimp_event_data['data'] ) ) {

				Automator()->db->token->save( 'MAILCHIMP_WEBHOOK_EVENT_DATA', wp_json_encode( $mailchimp_event_data['data'] ), $args['trigger_entry'] );

			}
		}

	}