Image Radio
The Image Radio controller allows users to select one option from a list of options displayed on image buttons.

Demonstration
Handy::control( 'image-radio', [
'id' => 'image_radio_id',
'section' => 'layout_section',
'label' => esc_html__( 'Image Radio Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'choices' => [
'bold' => [
'title' => esc_html__( 'Bold', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/bold.png'
],
'italic' => [
'title' => esc_html__( 'Italic', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/italic.png'
],
'allcaps' => [
'title' => esc_html__( 'All Caps', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/allcaps.png'
],
'underline' => [
'title' => esc_html__( 'Underline', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/underline.png'
]
]
]);
TIP
Here's an example using the default parameter. Note the default value must exist in defined choices.
Handy::control( 'image-radio', [
'id' => 'image_radio_id',
'section' => 'layout_section',
'default' => 'bold',
'label' => esc_html__( 'Image Radio Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'choices' => [
'bold' => [
'title' => esc_html__( 'Bold', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/bold.png'
],
'italic' => [
'title' => esc_html__( 'Italic', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/italic.png'
],
'allcaps' => [
'title' => esc_html__( 'All Caps', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/allcaps.png'
],
'underline' => [
'title' => esc_html__( 'Underline', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/underline.png'
]
]
]);
TIP
Here's an example using the display and size parameters. Note the display value accepts only inline or block, while size value accepts only an array data type with two elements the width and height.
Handy::control( 'image-radio', [
'id' => 'image_radio_id',
'section' => 'layout_section',
'default' => 'bold',
'label' => esc_html__( 'Image Radio Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'display' => 'inline',
'size' => [
'width' => '60px',
'height' => '50px'
],
'choices' => [
'bold' => [
'title' => esc_html__( 'Bold', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/bold.png'
],
'italic' => [
'title' => esc_html__( 'Italic', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/italic.png'
],
'allcaps' => [
'title' => esc_html__( 'All Caps', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/allcaps.png'
],
'underline' => [
'title' => esc_html__( 'Underline', 'textdomain' ),
'image' => trailingslashit( get_template_directory_uri() ) . 'images/underline.png'
]
]
]);
Basic Usage
// Return a string.
$value = get_theme_mod( 'image_radio_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. The |
| choices |
The array-based list of predetermined options or choices. Each choice contains the
|
| display |
The image radio's display behavior. Accepts only |
| size |
The image radio's size. Accepts only an |
| 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. |