Filter uncanny-automator-pro

automator_datetime_conditions_months_options

Filters the available months array for datetime conditions, allowing customization of month options.

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

Description

Filters the array of month options used in Uncanny Automator's datetime conditions. Developers can modify or extend this array to change available months, add custom month names, or prepare options for specific regional calendars before they are displayed in the Uncanny Automator interface.


Usage

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

Parameters

$months (mixed)
This parameter contains an array of month options, where each option is an associative array with a 'text' key for the display name and a 'value' key for the numerical representation of the month.

Return Value

The filtered value.


Examples

add_filter(
	'automator_datetime_conditions_months_options',
	function ( $months ) {
		// This example adds an option for "Any Month" to the beginning of the list.
		// It assumes the original array might contain month names.
		// In a real-world scenario, you'd ensure $months is an array before manipulating it.

		if ( ! is_array( $months ) ) {
			// If it's not an array, just return it as is, or handle as appropriate.
			return $months;
		}

		// Add a new option for 'Any Month' at the beginning.
		array_unshift(
			$months,
			array(
				'text'  => __( 'Any Month', 'my-text-domain' ),
				'value' => '', // Use an empty string to represent 'any'.
			)
		);

		return $months;
	},
	10, // Priority
	1  // Accepted args
);

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/datetime/conditions/datetime-is-specific-month.php:142

public function get_months_options() {
		$months = array(
			array(
				'text'  => __( 'January', 'uncanny-automator-pro' ),
				'value' => '1',
			),
			array(
				'text'  => __( 'February', 'uncanny-automator-pro' ),
				'value' => '2',
			),
			array(
				'text'  => __( 'March', 'uncanny-automator-pro' ),
				'value' => '3',
			),
			array(
				'text'  => __( 'April', 'uncanny-automator-pro' ),
				'value' => '4',
			),
			array(
				'text'  => __( 'May', 'uncanny-automator-pro' ),
				'value' => '5',
			),
			array(
				'text'  => __( 'June', 'uncanny-automator-pro' ),
				'value' => '6',
			),
			array(
				'text'  => __( 'July', 'uncanny-automator-pro' ),
				'value' => '7',
			),
			array(
				'text'  => __( 'August', 'uncanny-automator-pro' ),
				'value' => '8',
			),
			array(
				'text'  => __( 'September', 'uncanny-automator-pro' ),
				'value' => '9',
			),
			array(
				'text'  => __( 'October', 'uncanny-automator-pro' ),
				'value' => '10',
			),
			array(
				'text'  => __( 'November', 'uncanny-automator-pro' ),
				'value' => '11',
			),
			array(
				'text'  => __( 'December', 'uncanny-automator-pro' ),
				'value' => '12',
			),
		);

		return apply_filters( 'automator_datetime_conditions_months_options', $months );
	}

Scroll to Top