UOTC_USERATTAINSSCORE::define_trigger()

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


Source Source

File: src/integrations/uncanny-tincanny/triggers/uotc-userattainsscore.php

	public function define_trigger() {

		$modules = Database::get_modules();

		$options       = array();
		$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/tin-canny-reporting/' ),
			'integration'         => self::$integration,
			'code'                => $this->trigger_code,
			/* translators: Logged-in trigger - Uncanny Reporting */
			'sentence'            => sprintf( __( 'A user attains a score {{greater than, less than or equal to:%1$s}} {{a score:%2$s}} on {{a Tin Can module:%3$s}}', 'uncanny-automator' ), 'NUMBERCOND', $this->trigger_meta, 'TCMODULEINTERACTION' ),
			/* translators: Logged-in trigger - Uncanny Reporting */
			'select_option_name'  => __( 'A user attains {{a score}} {{greater than, less than or equal to}} on {{a Tin Can module}}', 'uncanny-automator' ),
			'action'              => 'tincanny_module_result_processed',
			'priority'            => 99,
			'accepted_args'       => 3,
			'validation_function' => array( $this, 'tincan_module_result_processed' ),
			'options'             => array(
				Automator()->helpers->recipe->field->select(
					array(
						'option_code' => 'TCMODULEINTERACTION',
						'label'       => esc_attr__( 'Module', 'uncanny-automator' ),
						'options'     => $options,
					)
				),
				Automator()->helpers->recipe->field->text_field( $this->trigger_meta, esc_attr__( 'Module Score', 'uncanny-automator' ), true, 'text', '0', true ),
				Automator()->helpers->recipe->less_or_greater_than(),
			),
		);

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