CAMPAIGN_CREATEANDSEND::define_action()

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


Source Source

File: src/integrations/mailchimp/actions/campaign-createandsend.php

	public function define_action() {

		global $uncanny_automator;

		$action = array(
			'author'             => $uncanny_automator->get_author_name( $this->action_code ),
			'support_link'       => $uncanny_automator->get_author_support_link( $this->action_code, 'knowledge-base/mailchimp/' ),
			'is_pro'             => false,
			'integration'        => self::$integration,
			'code'               => $this->action_code,
			'requires_user'      => false,
			'sentence'           => sprintf( __( 'Create and send {{a campaign:%1$s}}', 'uncanny-automator' ), $this->action_meta ),
			'select_option_name' => __( 'Create and send {{a campaign}}', 'uncanny-automator' ),
			'priority'           => 10,
			'accepted_args'      => 1,
			'requires_user'	     => false,
			'execution_function' => array( $this, 'create_send_campaign' ),
			'options_group'      => array(
				$this->action_meta => array(
					$uncanny_automator->helpers->recipe->field->text_field( 'MCCAMPAIGNTITLE', __( 'Campaign name', 'uncanny-automator' ), true, 'text', null ),
					$uncanny_automator->helpers->recipe->mailchimp->options->get_all_lists(
						__( 'Audience', 'uncanny-automator' ),
						'MCLIST',
						array(
							'is_ajax'      => true,
							'target_field' => 'MCLISTTAGS',
							'endpoint'     => 'select_segments_from_list',
						)
					),
					$uncanny_automator->helpers->recipe->mailchimp->options->get_list_tags(
						__( 'Segment or Tag', 'uncanny-automator' ),
						'MCLISTTAGS',
						array(
							'required'    => false,
							'is_ajax'     => true,
							'description' => __( 'If no segment/tag is selected, the campaign will be sent to the entire audience.', 'uncanny-automator' ),
						)
					),
					$uncanny_automator->helpers->recipe->field->text_field( 'MCEMAILSUBJECT', __( 'Email subject', 'uncanny-automator' ), true, 'text', null ),
					$uncanny_automator->helpers->recipe->field->text_field( 'MCPREVIEWTEXT', __( 'Preview text', 'uncanny-automator' ), true, 'text', null, false ),
					$uncanny_automator->helpers->recipe->field->text_field( 'MCFROMNAME', __( 'From name', 'uncanny-automator' ), true, 'text', null ),
					$uncanny_automator->helpers->recipe->field->text_field( 'MCFROMEMAILADDRESS', __( 'From email address', 'uncanny-automator' ), true, 'email', null ),
					$uncanny_automator->helpers->recipe->field->text_field( 'MCTONAME', __( 'To name', 'uncanny-automator' ), true, 'text', null, false, __( 'Supports merge tags such as *|FNAME|*, *|LNAME|*, *|FNAME|* *|LNAME|*, etc.', 'uncanny-automator' ) ),
					$uncanny_automator->helpers->recipe->mailchimp->options->get_all_email_templates(
						__( 'Template', 'uncanny-automator' ),
						'MCEMAILTEMPLATE',
						array(
							'description' => __( 'If a template is selected, the Email Content field below will be ignored.', 'uncanny-automator' ),
						)
					),
					$uncanny_automator->helpers->recipe->field->text_field( 'MCEMAILCONTENT', __( 'Email content', 'uncanny-automator' ), true, 'textarea', null, false ),
				),
			),
		);

		$uncanny_automator->register->action( $action );
	}