Automator_Send_Webhook::get_headers( $data, array $parsing_args = array() )

Get outgoing headers


Parameters Parameters

$data

(Required)

$parsing_args

(Optional)

Default value: array()


Top ↑

Return Return

(array)


Source Source

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

	public function get_headers( $data, $parsing_args = array() ) {
		$headers     = array();
		$header_meta = isset( $data['WEBHOOK_HEADERS'] ) ? ! is_array( $data['WEBHOOK_HEADERS'] ) ? json_decode( $data['WEBHOOK_HEADERS'], true ) : $data['WEBHOOK_HEADERS'] : array();
		if ( empty( $header_meta ) ) {
			return $headers;
		}

		//$header_fields = count( $header_meta );
		foreach ( $header_meta as $meta ) {
			$key = isset( $meta['NAME'] ) ? $this->maybe_parse_tokens( $meta['NAME'], $parsing_args ) : null;
			// remove colon if user added in NAME
			$key             = str_replace( ':', '', $key );
			$value           = isset( $meta['VALUE'] ) ? $this->maybe_parse_tokens( $meta['VALUE'], $parsing_args ) : null;
			$headers[ $key ] = $value;
		}

		return array_unique( $headers );
	}