Filter uncanny-automator

automator_outgoing_webhook_data_types

Filters the available data types for outgoing webhooks, allowing customization of accepted data formats.

add_filter( 'automator_outgoing_webhook_data_types', $callback, 10, 1 );

Description

Filters the available data types for outgoing webhooks. Developers can add custom data types or modify existing ones to extend webhook functionality within Uncanny Automator. This hook fires when the webhook data types are being compiled.


Usage

add_filter( 'automator_outgoing_webhook_data_types', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to add a new data type to outgoing webhooks.
 *
 * This function demonstrates how to hook into the 'automator_outgoing_webhook_data_types'
 * filter to add a custom data type, such as a date, for use in Uncanny Automator's
 * outgoing webhooks.
 *
 * @param array $data_types The existing array of data types.
 * @return array The modified array of data types including the new custom type.
 */
add_filter( 'automator_outgoing_webhook_data_types', 'my_custom_automator_webhook_data_type', 10, 1 );

function my_custom_automator_webhook_data_type( $data_types ) {
	// Add a new data type for 'datetime'.
	$data_types[] = array(
		'value' => 'datetime',
		'text'  => esc_html__( 'Date/Time', 'your-text-domain' ),
	);

	// Add another custom data type for 'json'.
	$data_types[] = array(
		'value' => 'json',
		'text'  => esc_html__( 'JSON String', 'your-text-domain' ),
	);

	return $data_types;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

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

public function get_webhook_data_types() {
		return apply_filters(
			'automator_outgoing_webhook_data_types',
			array(
				array(
					'value' => 'text',
					'text' => esc_html__( 'Text', 'uncanny-automator' ),
				),
				array(
					'value' => 'float',
					'text' => esc_html__( 'Number', 'uncanny-automator' ),
				),
				array(
					'value' => 'bool',
					'text' => esc_html__( 'Boolean', 'uncanny-automator' ),
				),
				array(
					'value' => 'null',
					'text' => esc_html__( 'NULL', 'uncanny-automator' ),
				),
			)
		);
	}

Scroll to Top