UNCANNYCEUS_EARNS_NUMBER_CEUS::define_trigger()

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


Source Source

File: src/integrations/uncanny-ceus/triggers/uncannyceus-earns-number-ceus.php

	public function define_trigger() {

		$credit_designation_label_plural = get_option( 'credit_designation_label_plural', __( 'CEUs', 'uncanny-ceu' ) );

		$trigger = array(
			'author'              => Automator()->get_author_name( $this->trigger_code ),
			'support_link'        => Automator()->get_author_support_link( $this->trigger_code, 'integration/uncanny-continuing-education-credits-for-learndash/' ),
			'integration'         => self::$integration,
			'code'                => $this->trigger_code,
			'meta'                => $this->trigger_meta,
			/* translators: Logged-in trigger - Uncanny CEUs. 1. Credit designation label (plural) */
			'sentence'            => sprintf( esc_attr__( 'A user earns {{a number of:%1$s}} %2$s', 'uncanny-automator' ), $this->trigger_meta, $credit_designation_label_plural ),
			/* translators: Logged-in trigger - Uncanny CEUs. 1. Credit designation label (plural) */
			'select_option_name'  => sprintf( esc_attr__( 'A user earns {{a number of}} %1$s', 'uncanny-automator' ), $credit_designation_label_plural ),
			'action'              => 'ceus_after_updated_user_ceu_record',
			'priority'            => 20,
			'accepted_args'       => 7,
			'validation_function' => array( $this, 'updated_user_ceu_record' ),
			'options'             => [
				[
					'option_code'     => $this->trigger_meta,
					/* translators: Uncanny CEUs. 1. Credit designation label (plural) */
					'label'           => sprintf( esc_attr__( 'Number of %1$s', 'uncanny-automator' ), $credit_designation_label_plural ),
					'input_type'      => 'int',
					'validation_type' => 'integer',
					'required'        => true,
					'relevant_tokens' => [
						$this->trigger_meta            => sprintf( esc_attr__( '%1$s amount', 'uncanny-automator' ), $credit_designation_label_plural ),
						$this->trigger_meta . '_title' => sprintf( esc_attr__( 'Course or %1$s title', 'uncanny-automator' ), $credit_designation_label_plural ),
						$this->trigger_meta . '_date'  => esc_attr__( 'Date awarded', 'uncanny-automator' ),
					],
				],
			],
		);

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

		return;
	}