Filter
uncanny-automator
automator_google_calendar_time_format
Filter the time format. Filters the time format used for Google Calendar events, allowing customization of how times are displayed.
add_filter( 'automator_google_calendar_time_format', $callback, 10, 2 );
Description
Fires when Google Calendar event actions format time. Developers can modify the time display format using this filter. It allows for customization of how event times are presented, ensuring flexibility in date and time representation.
Usage
add_filter( 'automator_google_calendar_time_format', 'your_function_name', 10, 2 );
Parameters
-
$time_format(string) - The time format.
-
$this(GCALENDAR_ADDEVENT) - The current instance.
Return Value
string The time format.
Examples
/**
* Change the Google Calendar time format to use 24-hour format with minutes.
*
* This filter allows developers to customize the time format sent to Google Calendar
* when adding events via the Automator plugin.
*/
add_filter( 'automator_google_calendar_time_format', function( $time_format, $gcalendar_instance ) {
// Check if the current instance is specifically for adding events and if the
// original format is not already in a 24-hour format.
// We can infer this check is relevant if $gcalendar_instance is an object
// that might have properties or methods we can inspect. For realism,
// let's assume it might have a property like 'is_adding_event'.
// In a real scenario, you might inspect $gcalendar_instance more deeply.
// For this example, let's assume we always want to force a 24-hour format.
// You might conditionally change it based on other factors if needed.
return 'H:i';
}, 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/integrations/google-calendar/actions/gcalendar-addevent.php:507
protected function get_time_format() {
/**
* Filter the time format.
*
* @param string $time_format The time format.
* @param GCALENDAR_ADDEVENT $this The current instance.
*
* @return string The time format.
* @example
* add_filter( 'automator_google_calendar_time_format', function ( $time_format, $this ) {
* return 'H:i';
* }, 10, 2 );
*/
return apply_filters( 'automator_google_calendar_time_format', get_option( 'time_format', 'g:i a' ), $this );
}
Internal Usage
Found in src/integrations/google-calendar/actions/gcalendar-addevent.php:503:
* add_filter( 'automator_google_calendar_time_format', function ( $time_format, $this ) {