Filter
uncanny-automator
automator_send_webhook_binary_separator
Filters the separator used when sending binary webhook data, allowing customization of how individual fields are delimited.
add_filter( 'automator_send_webhook_binary_separator', $callback, 10, 1 );
Description
This filter hook, `automator_send_webhook_binary_separator`, is used within the core Uncanny Automator webhook sending functionality. It allows developers to modify the separator character used when converting field data into binary format for webhooks. By default, it's a comma. Developers can change this separator to customize binary data transmission.
Usage
add_filter( 'automator_send_webhook_binary_separator', 'your_function_name', 10, 1 );
Parameters
-
$fields(mixed) - This filter allows you to modify the separator character used to join binary data fields when sending a webhook.
Return Value
The filtered value.
Examples
/**
* Filter the separator used when sending webhook data in binary format.
*
* This function modifies the default separator (which is a comma ',')
* to a more distinct separator, such as a newline character, when
* preparing data for binary webhook transmission. This can help in
* scenarios where the comma might be part of the actual data being sent.
*
* @param string $separator The current separator.
* @param array $fields The array of fields being processed for the webhook.
* @return string The modified separator.
*/
add_filter( 'automator_send_webhook_binary_separator', function( $separator, $fields ) {
// Example: If the fields array contains more than 3 items, use a newline as separator.
// Otherwise, stick to the default comma. This is a hypothetical logic.
if ( count( $fields ) > 3 ) {
return "n"; // Use newline as the separator
}
return $separator; // Return the original separator (comma)
}, 10, 2 );
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.php:729
);
}
break;
case 'plain':
$fields = implode( apply_filters( 'automator_send_webhook_plain_text_separator', ',', $fields ), $fields );
break;
case 'binary':
$fields = implode( apply_filters( 'automator_send_webhook_binary_separator', ',', $fields ), $fields );
$fields = $this->string_to_binary_conversion( $fields );
break;
case 'html':
$fields = $this->build_html_table( $fields, $is_check_sample );
break;
case 'xml':
try {