Time Picker

The Time Picker controller allows users to select a time using a visual picker user interface.

Demonstration

 
Handy::control( 'time-picker', [
    'id'          => 'time_picker_id',
    'section'     => 'layout_section',
    'label'       => esc_html__( 'Time Picker Control', 'textdomain' ),
    'description' => esc_html__( 'Description Here', 'textdomain' ),
    'priority'    => 1
]);

TIP

Here’s an example using the default and format parameters. Note the format value accepts only civilian or military, while the default value depends on format‘s value. For example if format is set to civilian, then the default must use the civilian time format h:i A, while if format is set to military, then the default must use the military time format H:i.

 
// If 'format' is set to 'civilian', then the 'default' value
// must use the civilian time format 'h:i A'.
Handy::control( 'time-picker', [
    'id'          => 'time_picker_id',
    'section'     => 'layout_section',
    'default'     => '12:30 AM',
    'label'       => esc_html__( 'Time Picker Control', 'textdomain' ),
    'description' => esc_html__( 'Description Here', 'textdomain' ),
    'priority'    => 1
]);

// If 'format' is set to 'military', then the 'default' value
// must use the military time format 'H:i'.
Handy::control( 'time-picker', [
    'id'          => 'time_picker_id',
    'section'     => 'layout_section',
    'default'     => '24:00′,
    'label'       => esc_html__( 'Time Picker Control', 'textdomain' ),
    'description' => esc_html__( 'Description Here', 'textdomain' ),
    'priority'    => 1
]);

Basic Usage

 
// Return a string.
$value = get_theme_mod( 'time_picker_id' );

Parameters

NameDescription
id

string required

The unique slug like string used as an ID and also as an index name in storing data in a database.

section

string required

The ID of the section in which the control will be displayed.

default

string optional

The predetermined value of the control. Accepts a valid time, for thorough explaination kindy refer to the demonstration above. Default empty.

format

string optional

The time picker's time format. Accepts only civilian or military. Default civilian.

label

string optional

The label or title of the control to show in the UI. Default empty.

description

string optional

The description of the control to show in the UI. Default empty.

placeholder

string optional

The placeholder of the control to show in the UI. Default empty.

priority

integer optional

The order of control appears in the section. Default 0.

validations

array optional

The set of validations used to validate the value of the control. For further details, read validations. Default empty.

active_callback

callable optional

A callback function that determines the visibility of a control, whether to show or hide depending on a condition. For further details, read active_callback. Default empty.

sanitize_callback

callable optional

A callback function that sanitizes the value of control before storing it in the database. Note that this is only optional since each control is already well sanitized. For further details, read sanitize_callback. Default empty.