MASTERSTUDY_MARKCOURSECOMPLETE::define_action()

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


Source

File: src/integrations/masterstudy-lms/actions/masterstudy-markcoursecomplete.php

	public function define_action() {

		$args = [
			'post_type'      => 'stm-courses',
			'posts_per_page' => 999,
			'orderby'        => 'title',
			'order'          => 'ASC',
			'post_status'    => 'publish',
		];
		$options = Automator()->helpers->recipe->options->wp_query( $args, false );
		$action = array(
			'author'             => Automator()->get_author_name(),
			'support_link'       => Automator()->get_author_support_link( $this->action_code, 'integration/masterstudy-lms/' ),
			'integration'        => self::$integration,
			'code'               => $this->action_code,
			/* translators: Action - LearnDash */
			'sentence'           => sprintf( esc_attr__( 'Mark {{a course:%1$s}} complete for the user', 'uncanny-automator' ), $this->action_meta ),
			/* translators: Action - LearnDash */
			'select_option_name' => esc_attr__( 'Mark {{a course}} complete for the user', 'uncanny-automator' ),
			'priority'           => 10,
			'accepted_args'      => 3,
			'execution_function' => array( $this, 'mark_course_complete' ),
			'options'            => [
				[
					'option_code'              => $this->action_meta,
					'label'                    => esc_attr__( 'Course', 'uncanny-automator' ),
					'input_type'               => 'select',
					'required'                 => true,
					'options'                  => $options,
					'custom_value_description' => _x( 'Course ID', 'MasterStudy', 'uncanny-automator' ),
				],
			],
		);
		Automator()->register->action( $action );
	}