TC_MODULEINTERACTION::define_trigger()

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


Source Source

File: src/integrations/learndash/triggers/tc-moduleinteraction.php

	public function define_trigger() {



		$options       = array();
		$modules       = Database::get_modules();
		$options['-1'] = esc_attr__( 'Any module', 'uncanny-automator' );

		foreach ( $modules as $module ) {
			$options[ $module->ID ] = $module->file_name;
		}

		$trigger = array(
			'author'              => Automator()->get_author_name( $this->trigger_code ),
			'support_link'        => Automator()->get_author_support_link( $this->trigger_code, 'integration/learndash/' ),
			'integration'         => self::$integration,
			'code'                => $this->trigger_code,
			/* translators: Logged-in trigger - LearnDash */
			'sentence'            => sprintf( esc_attr__( '{{A Tin Can verb:%1$s}} is recorded from {{a Tin Can module:%2$s}}', 'uncanny-automator' ), 'TCVERB', $this->trigger_meta ),
			/* translators: Logged-in trigger - LearnDash */
			'select_option_name'  => esc_attr__( '{{A Tin Can verb}} is recorded from {{a Tin Can module}}', 'uncanny-automator' ),
			'action'              => 'tincanny_module_completed',
			'priority'            => 99,
			'accepted_args'       => 3,
			'validation_function' => array( $this, 'tincanny_module_completed_func' ),
			'options'             => [
				Automator()->helpers->recipe->field->select(
					array(
						'option_code' => $this->trigger_meta,
						'label'       => esc_attr__( 'Module', 'uncanny-automator' ),
						'options'     => $options,
					)
				),
				Automator()->helpers->recipe->field->select(
					array(
						'option_code' => 'TCVERB',
						'label'       => esc_attr_x( 'Verb', 'Tin Can verb', 'uncanny-automator' ),
						'options'     => array(
							'completed'   => 'Completed',
							'passed'      => 'Passed',
							'failed'      => 'Failed',
							'answered'    => 'Answered',
							'attempted'   => 'Attempted',
							'experienced' => 'Experienced',
						),
					)
				),
			],
		);

		Automator()->register->trigger( $trigger );
	}