WPF_USERREPUTATION::define_action()

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


Source Source

File: src/integrations/wpforo/actions/wpf-userreputation.php

	public function define_action() {

		$reputation_options = array();
		$levels             = WPF()->member->levels();
		foreach ( $levels as $level ) {
			$title                                        = esc_attr__( 'Level', 'wpforo' ) . ' ' . $level . ' - ' . WPF()->member->rating( $level, 'title' );
			$reputation_options[ 'L' . strval( $level ) ] = $title;
		}
		$option = [
			'option_code' => $this->action_meta,
			'label'       => esc_attr__( 'Reputation', 'uncanny-automator' ),
			'input_type'  => 'select',
			'required'    => true,
			'options'     => $reputation_options,
		];
		$action = array(
			'author'             => Automator()->get_author_name(),
			'support_link'       => Automator()->get_author_support_link( $this->action_code, 'integration/wpforo/' ),
			'integration'        => self::$integration,
			'code'               => $this->action_code,
			/* translators: Action - wpForo */
			'sentence'           => sprintf( esc_attr__( "Set the user's reputation to {{a reputation:%1\$s}}", 'uncanny-automator' ), $this->action_meta ),
			/* translators: Action - wpForo */
			'select_option_name' => esc_attr__( "Set the user's reputation to {{a reputation}}", 'uncanny-automator' ),
			'priority'           => 10,
			'accepted_args'      => 1,
			'execution_function' => array( $this, 'set_reputation' ),
			'options'            => [
				$option,
			],
		);
		Automator()->register->action( $action );
	}