Group

PRO

The Group controller allows users to structure multiple controls into a single group.

Demonstration

 
Handy::control( 'group', [
    'id'          => 'group_id',
    'section'     => 'layout_section',
    'label'       => esc_html__( 'Group Control', 'textdomain' ),
    'description' => esc_html__( 'Description Here', 'textdomain' ),
    'priority'    => 1,
    'controls'    => [
        'image_id' => [
            'type'        => 'image-uploader',
            'label'       => 'Image Uploader Control',
            'placeholder' => 'Upload Image Here',
        ],
        'text_id'  => [
            'type'        => 'text',
            'label'       => 'Text Control',
            'placeholder' => 'Enter Text',
        ],
        'url_id'   => [
            'type'        => 'url',
            'label' 	  => 'URL Control',
            'placeholder' => 'Enter URL',
        ],
    ]
]);

TIP

Here's an example using the default and reset_button parameters. Note the default value will be depending on the type of control defined in controls, while the reset_button value accepts a string data type that is used as label of the reset button.

 
Handy::control( 'group', [
    'id'           => 'group_id',
    'section'      => 'layout_section',
    'label'        => esc_html__( 'Group Control', 'textdomain' ),
    'description'  => esc_html__( 'Description Here', 'textdomain' ),
    'reset_button' => esc_html__( 'Set Default', 'textdomain' )
    'priority'     => 1,
    'controls'     => [
        'image_id' => [
            'type'        => 'image-uploader',
            'default'     => 100,
            'label'       => 'Image Uploader Control',
            'placeholder' => 'Upload Image Here',
        ],
        'text_id'  => [
            'type'        => 'text',
            'default'     => 'Content…',
            'label'       => 'Text Control',
            'placeholder' => 'Enter Text',
        ],
        'url_id'   => [
            'type'        => 'url',
            'default'     => 'https://www.google.com',
            'label' 	  => 'URL Control',
            'placeholder' => 'Enter URL',
        ],
    ]
]);

Supported Controls

Here is the list of the group's supported controls.

Basic Usage

 
// Return an array.
$values = get_theme_mod( 'group_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.

controls

array required

The array-based list of predetermined fields or controls.

reset_button

string optional

The group's reset button label. Default Reset.

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.

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.