MPC_MARKLESSONDONE::define_action()

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


Source Source

File: src/integrations/memberpress-courses/actions/mpc-marklessondone.php

	public function define_action()
	{

		$args = array(
			'post_type'      => 'mpcs-course',
			'posts_per_page' => 999,
			'orderby'        => 'title',
			'order'          => 'ASC',
			'post_status'    => 'publish',
		);

		$options = Automator()->helpers->recipe->options->wp_query( $args );

		$action = array(
			'author'             => Automator()->get_author_name(),
			'support_link'       => Automator()->get_author_support_link( $this->action_code, 'integration/memberpress-courses/' ),
			'integration'        => self::$integration,
			'code'               => $this->action_code,
			/* translators: Action - Memberpress */
			'sentence'           => sprintf( esc_attr__( 'Mark {{a lesson:%1$s}} complete for the user', 'uncanny-automator' ), $this->action_meta ),
			/* translators: Action - Memberpress */
			'select_option_name' => esc_attr__( 'Mark {{a lesson}} complete for the user', 'uncanny-automator' ),
			'priority'           => 10,
			'accepted_args'      => 1,
			'execution_function' => array( $this, 'mark_completes_a_lesson' ),
			'options_group'      => array(
				$this->action_meta => array(
					Automator()->helpers->recipe->field->select_field_ajax(
						'MPCOURSE',
						esc_attr__( 'Course', 'uncanny-automator' ),
						$options,
						'',
						'',
						false,
						true,
						array(
							'target_field' => $this->action_meta,
							'endpoint'     => 'select_lesson_from_course_LESSONDONE',
						),
						''
					),
					Automator()->helpers->recipe->field->select_field( $this->action_meta, esc_attr__( 'Lesson', 'uncanny-automator' ), array(), false, false, false, '' ),
				),
			),
		);

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