Fr_Tokens::fr_possible_tokens( array $tokens = array(), array $args = array() )

Prepare tokens.


Parameters Parameters

$tokens

(array) (Optional) .

Default value: array()

$args

(array) (Optional) .

Default value: array()


Top ↑

Return Return

(array)


Source Source

File: src/integrations/forminator/tokens/fr-tokens.php

	public function fr_possible_tokens( $tokens = array(), $args = array() ) {
		$form_id      = $args['value'];
		$trigger_meta = $args['meta'];

		if ( ! empty( $form_id ) && 0 !== $form_id && is_numeric( $form_id ) ) {
			$form_meta = Forminator_API::get_form_fields( $form_id );
			if ( isset( $form_meta ) && ! empty( $form_meta ) ) {
				$fields = array();
				foreach ( $form_meta as $field ) {
					if ( isset( $field->raw['field_label'] ) ) {
						$input_id    = $field->slug;
						$input_title = $field->raw['field_label'];
						$token_id    = "$form_id|$input_id";
						$fields[]    = [
							'tokenId'         => $token_id,
							'tokenName'       => $input_title,
							'tokenType'       => $field->raw['type'],
							'tokenIdentifier' => $trigger_meta,
						];
					}
				}

				$tokens = array_merge( $tokens, $fields );
			}
		}


		return $tokens;
	}