Checkbox Pill
The Checkbox Pill controller allows users to select one or more options from a group of related pills.

Demonstration
Handy::control( 'checkbox-pill', [
'id' => 'checkbox_pill_id',
'section' => 'layout_section',
'label' => esc_html__( 'Checkbox Pill Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'priority' => 1,
'choices' => [
'apple' => esc_html__( 'Apple', 'textdomain' ),
'grape' => esc_html__( 'Grape', 'textdomain' ),
'melon' => esc_html__( 'Melon', 'textdomain' ),
'peach' => esc_html__( 'Peach', 'textdomain' ),
'mango' => esc_html__( 'Mango', 'textdomain' ),
'lemon' => esc_html__( 'Lemon', 'textdomain' ),
]
]);
TIP
Here's an example using the default parameter. Note the default value must exist in defined choices.
Handy::control( 'checkbox-pill', [
'id' => 'checkbox_pill_id',
'section' => 'layout_section',
'default' => [ 'apple', 'grape' ],
'label' => esc_html__( 'Checkbox Pill Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'priority' => 1,
'choices' => [
'apple' => esc_html__( 'Apple', 'textdomain' ),
'grape' => esc_html__( 'Grape', 'textdomain' ),
'melon' => esc_html__( 'Melon', 'textdomain' ),
'peach' => esc_html__( 'Peach', 'textdomain' ),
'mango' => esc_html__( 'Mango', 'textdomain' ),
'lemon' => esc_html__( 'Lemon', 'textdomain' ),
]
]);
TIP
Here's an example using the display and shape parameters. Note the display value accepts only inline or block, while shape value accepts only round or square.
Handy::control( 'checkbox-pill', [
'id' => 'checkbox_pill_id',
'section' => 'layout_section',
'default' => [ 'apple', 'grape' ],
'label' => esc_html__( 'Checkbox Pill Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'priority' => 1,
'shape' => 'round',
'display' => 'inline',
'choices' => [
'apple' => esc_html__( 'Apple', 'textdomain' ),
'grape' => esc_html__( 'Grape', 'textdomain' ),
'melon' => esc_html__( 'Melon', 'textdomain' ),
'peach' => esc_html__( 'Peach', 'textdomain' ),
'mango' => esc_html__( 'Mango', 'textdomain' ),
'lemon' => esc_html__( 'Lemon', 'textdomain' ),
]
]);
Basic Usage
// Return an array.
$values = get_theme_mod( 'checkbox_pill_id' );
Parameters
| Name | Description |
|---|---|
| id |
The unique slug like string used as an ID and also as an index name in storing data in a database. |
| section |
The ID of the section in which the control will be displayed. |
| default |
The predetermined value of the control. Accepts values only from defined |
| choices |
The array-based list of predetermined options or choices. |
| display |
The checkbox pill's display behavior. Accepts only |
| shape |
The checkbox pill's visual shape. Accepts only |
| label |
The label or title of the control to show in the UI. Default empty. |
| description |
The description of the control to show in the UI. Default empty. |
| priority |
The order of control appears in the section. Default |
| validations |
The set of validations used to validate the value of the control. For further details, read validations. Default empty. |
| active_callback |
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 |
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. |