ANON_MAILCHIMP_CONTACT_ADDED::setup_trigger()

Define and register the trigger by pushing it into the Automator object


Source Source

File: src/integrations/mailchimp/triggers/anon-mailchimp-contact-added.php

	public function setup_trigger() {

		$this->set_integration( 'MAILCHIMP' );

		$this->set_trigger_code( self::TRIGGER_CODE );

		$this->set_trigger_meta( self::TRIGGER_META );

		$this->set_trigger_type( 'anonymous' );

		$this->set_is_login_required( false );

		$this->set_is_pro( false );

		/* Translators: Trigger sentence */
		$this->set_sentence(
			sprintf(
				/* Translators: Trigger sentence */
				esc_html__( 'A contact is added to {{an audience:%1$s}}', 'uncanny-automator' ),
				$this->get_trigger_meta()
			)
		);

		/* Translators: Trigger sentence */
		$this->set_readable_sentence( esc_html__( 'A contact is added to {{an audience}}', 'uncanny-automator' ) ); // Non-active state sentence to show

		// Which do_action() fires this trigger.
		$this->add_action( 'automator_mailchimp_webhook_received_subscribe' );

		// Set the options field group.
		$this->set_options_callback( array( $this, 'get_trigger_option_fields' ) );

		// Only register the trigger if mailchimp webhook is enabled inside the settings.
		if ( get_option( 'uap_mailchimp_enable_webhook', false ) ) {

			$this->register_trigger();

		}

	}