UOG_CREATEUNCANNYGROUP::define_action()

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


Source Source

File: src/integrations/uncanny-groups/actions/uog-createuncannygroup.php

	public function define_action() {



		$args = [
			'post_type'      => 'sfwd-courses',
			'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( $this->action_code ),
			'support_link'       => Automator()->get_author_support_link( $this->action_code, 'integration/uncanny-groups/' ),
			'integration'        => self::$integration,
			'code'               => $this->action_code,
			/* translators: Logged-in trigger - Uncanny Groups */
			'sentence'           => sprintf( esc_attr__( 'Create {{an Uncanny group:%1$s}}', 'uncanny-automator' ), $this->action_meta ),
			/* translators: Logged-in trigger - Uncanny Groups */
			'select_option_name' => esc_attr__( 'Create {{an Uncanny group}}', 'uncanny-automator' ),
			'priority'           => 10,
			'accepted_args'      => 1,
			'execution_function' => array( $this, 'create_uncanny_group' ),
			'options_group'      =>
				[
					$this->action_meta =>
						[
							[
								'option_code' => 'UOGROUPTITLE',
								'label'       => esc_attr__( 'Group name', 'uncanny-automator' ),
								'input_type'  => 'text',
								'required'    => true,
							],
							[
								'option_code'              => 'UOGROUPCOURSES',
								'label'                    => esc_attr__( 'Group courses', 'uncanny-automator' ),
								'input_type'               => 'select',
								'required'                 => true,
								'supports_multiple_values' => true,
								'options'                  => $options,
							],
							[
								'option_code' => 'UOGROUPNUMSEATS',
								'label'       => esc_attr__( 'Number of seats', 'uncanny-automator' ),
								'input_type'  => 'int',
								'required'    => true,

							],
							[
								'input_type'            => 'select',
								'option_code'           => 'GROUP_LEADER_ROLE_ASSIGNMENT',
								/* translators: Uncanny Groups */
								'label'                 => esc_attr__( 'If the user does not currently have the Group Leader role', 'uncanny-automator' ),
								'description'           => '<div class="user-selector__warning">' . esc_attr__( 'Only users with the Group Leader role can be made the leader of a group.', 'uncanny-automator' ) . '</div>',
								'required'              => true,
								'default_value'         => 'do_nothing',
								'options'               => array(
									'do_nothing' => esc_attr__( 'Do nothing', 'uncanny-automator' ),
									'add'        => esc_attr__( 'Add the role to their existing role(s)', 'uncanny-automator' ),
									'replace'    => esc_attr__( 'Replace their existing role(s) with the Group Leader role', 'uncanny-automator' ),
								),
								'supports_custom_value' => false,
								'supports_tokens'       => false,
							],
						],
				],
		);

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