Filter uncanny-automator-pro

automator_datetime_conditions_day_options

Filters the available day options for date and time conditions, allowing for customization of day selections.

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

Description

This filter allows developers to modify the day options available for 'specific weekday' datetime conditions. It fires after the default day options (Sunday-Saturday) are generated. Developers can add, remove, or alter these day values to customize the available choices for users.


Usage

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

Parameters

$months (mixed)
This parameter is not used by the filter and the value passed is ignored.

Return Value

The filtered value.


Examples

add_filter( 'automator_datetime_conditions_day_options', 'my_custom_weekday_options', 10, 1 );

/**
 * Adds custom weekday options to the Uncanny Automator datetime condition.
 *
 * @param array $day_options The default array of day options.
 *
 * @return array The modified array of day options.
 */
function my_custom_weekday_options( $day_options ) {
    // Example: Add a custom option for "Any Day of the Week"
    $custom_option = array(
        'text'  => __( 'Any Day', 'your-text-domain' ),
        'value' => 'any',
    );

    // Add the custom option to the beginning of the array
    array_unshift( $day_options, $custom_option );

    // Example: If you wanted to remove a specific option, you'd find its key and unset it.
    // For instance, to remove Sunday:
    /*
    foreach ( $day_options as $key => $option ) {
        if ( isset( $option['value'] ) && '7' === $option['value'] ) {
            unset( $day_options[ $key ] );
            break;
        }
    }
    $day_options = array_values( $day_options ); // Re-index array if items were removed
    */

    return $day_options;
}

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-weekday.php:122

public function get_weekday_options() {
		$months = array(
			array(
				'text'  => __( 'Monday', 'uncanny-automator-pro' ),
				'value' => '1',
			),
			array(
				'text'  => __( 'Tuesday', 'uncanny-automator-pro' ),
				'value' => '2',
			),
			array(
				'text'  => __( 'Wednesday', 'uncanny-automator-pro' ),
				'value' => '3',
			),
			array(
				'text'  => __( 'Thursday', 'uncanny-automator-pro' ),
				'value' => '4',
			),
			array(
				'text'  => __( 'Friday', 'uncanny-automator-pro' ),
				'value' => '5',
			),
			array(
				'text'  => __( 'Saturday', 'uncanny-automator-pro' ),
				'value' => '6',
			),
			array(
				'text'  => __( 'Sunday', 'uncanny-automator-pro' ),
				'value' => '7',
			),
		);

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

Scroll to Top