LP_MARKSECTIONDONE::define_action()

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


Source Source

File: src/integrations/learnpress/actions/lp-marksectiondone.php

	public function define_action() {


		$args    = [
			'post_type'      => 'lp_course',
			'posts_per_page' => 999,
			'orderby'        => 'title',
			'order'          => 'ASC',
			'post_status'    => 'publish',
		];
		$options = Automator()->helpers->recipe->options->wp_query( $args, false, esc_attr__( 'Any course', 'uncanny-automator' ) );

		$action = [
			'author'             => Automator()->get_author_name( $this->action_code ),
			'support_link'       => Automator()->get_author_support_link( $this->action_code, 'integration/learnpress/' ),
			'integration'        => self::$integration,
			'code'               => $this->action_code,
			/* translators: Action - LearnPress */
			'sentence'           => sprintf( esc_attr__( 'Mark {{a section:%1$s}} complete for the user', 'uncanny-automator' ), $this->action_meta ),
			/* translators: Action - LearnPress */
			'select_option_name' => esc_attr__( 'Mark {{a section}} complete for the user', 'uncanny-automator' ),
			'priority'           => 10,
			'accepted_args'      => 1,
			'execution_function' => [ $this, 'lp_mark_section_done' ],
			'options_group'      => [
				$this->action_meta => [
					Automator()->helpers->recipe->field->select_field_args( [
						'option_code' => 'LPCOURSE',
						'options'     => $options,
						'label'       => esc_attr__( 'Course', 'uncanny-automator' ),

						'required'                 => true,
						'custom_value_description' => esc_attr__( 'Course ID', 'uncanny-automator' ),

						'is_ajax'      => true,
						'target_field' => 'LPSECTION',
						'endpoint'     => 'select_section_from_course_LPMARKLESSONDONE',
					] ),

					Automator()->helpers->recipe->field->select_field_args( [
						'option_code' => $this->action_meta,
						'options'     => array(),
						'label'       => esc_attr__( 'Section', 'uncanny-automator' ),

						'required'                 => true,
						'custom_value_description' => esc_attr__( 'Section ID', 'uncanny-automator' ),
					] ),
				],
			],
		];

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