Automator_Send_Webhook::get_fields( $data, bool $legacy = false, string $data_type = '', array $parsing_args = array(), bool $is_check_sample = false )

Get outgoing Fields and data


Parameters Parameters

$data

(Required)

$legacy

(Optional)

Default value: false

$data_type

(Optional)

Default value: ''

$parsing_args

(Optional)

Default value: array()

$is_check_sample

(Optional)

Default value: false


Top ↑

Return Return

(array|mixed)


Source Source

File: src/core/lib/webhooks/class-automator-send-webhook.php

	public function get_fields( $data, $legacy = false, $data_type = '', $parsing_args = array(), $is_check_sample = false ) {
		$prepared_data = array();
		if ( $legacy ) {
			return $this->prepare_legacy_fields( $data, $parsing_args );
		}
		if ( ! isset( $data['WEBHOOK_FIELDS'] ) ) {
			return $prepared_data;
		}
		$fields = ! is_array( $data['WEBHOOK_FIELDS'] ) ? json_decode( $data['WEBHOOK_FIELDS'], true ) : $data['WEBHOOK_FIELDS'];
		if ( empty( $fields ) ) {
			return $prepared_data;
		}
		foreach ( $fields as $field ) {
			$key   = isset( $field['KEY'] ) ? $this->maybe_parse_tokens( $field['KEY'], $parsing_args ) : null;
			$value = isset( $field['VALUE'] ) ? $this->maybe_parse_tokens( $field['VALUE'], $parsing_args ) : null;
			if ( ! is_null( $key ) && ! is_null( $value ) ) {
				$prepared_data[ $key ] = $value;
			}
		}
		$prepared_data = $this->create_tree( $prepared_data, $data_type );

		return $this->format_outgoing_data( $prepared_data, $data_type, $is_check_sample );
	}