Filter
uncanny-automator-pro
automator_pro_formatter_input_date_formats
Filters the available date formats for the date input in the Formatter integration, allowing customization.
add_filter( 'automator_pro_formatter_input_date_formats', $callback, 10, 1 );
Description
Filters the date formats available within Uncanny Automator's date formatter. Developers can use this to add custom date formats or remove existing ones before they are displayed to the user in the recipe builder. This hook fires when the date formatter options are being generated.
Usage
add_filter( 'automator_pro_formatter_input_date_formats', 'your_function_name', 10, 1 );
Parameters
-
$options(mixed) - This parameter contains an array of available date format options, including their display text and corresponding value.
Return Value
The filtered value.
Examples
<?php
/**
* Add a custom date format option to the Uncanny Automator date formatter.
*
* @param array $options An array of existing date format options.
* @return array The modified array of date format options.
*/
function my_custom_automator_date_formats( $options ) {
// Add a new custom date format option.
// For example, let's add a format that displays the day of the week.
$options[] = array(
'text' => __( 'Day of the Week', 'my-text-domain' ),
'value' => 'l', // 'l' is the PHP date format character for the full day of the week
);
// You could also potentially modify existing options or remove them if needed,
// though for this example, we're just adding.
return $options;
}
add_filter( 'automator_pro_formatter_input_date_formats', 'my_custom_automator_date_formats', 10, 1 );
?>
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
uncanny-automator-pro/src/integrations/formatter/actions/date-formatter.php:252
public function input_date_format_options() {
$options = array();
$options[] = array(
'text' => __( 'Automatic format recognition (recommended)', 'uncanny-automator-pro' ),
'value' => 'auto',
);
$options[] = array(
'text' => __( 'Timestamp', 'uncanny-automator-pro' ),
'value' => 'U',
);
return apply_filters( 'automator_pro_formatter_input_date_formats', $options );
}