mustartt/searchable-dropdown-control

WordPress Customizer Searchable Dropdown Control adds a searchable dropdown

v1.0.2 2021-07-14 20:00 UTC

This package is auto-updated.

Last update: 2025-06-15 04:28:39 UTC


README

A searchable dropdown for wordpress customizer control

Installation

composer require mustartt/searchable-dropdown-control

Or specify custom install location

"require": {
    "mustartt/searchable-dropdown-control": "v1.0"
},
...
"extra": {
    "installer-paths": {
        "inc/{$name}": [
            "mustartt/searchable-dropdown-control"
        ]
    }
}

and run

composer update

Screenshot

What it looks like in the Wordpress Customizer

Screenshot

Example Usage

Include in functions.php if the package is installed under inc

if ( class_exists( 'WP_Customize_Control' ) ) {
    require_once dirname( __FILE__ ) . '/inc/searchable-dropdown-control/searchable-dropdown-control.php';
}

Usage for customizer.php

$wp_customize->add_setting(
    'font',
    array(
        'default'           => 'Roboto',
        'sanitize_callback' => function ( $value ) {
            return $value;
        }
    )
);

$wp_customize->add_control(
    new Customizer_Searchable_Dropdown_Control(
        $wp_customize,
        'font',
        array(
            'label'    => 'Select Font',
            'section'  => 'fonts',
            'settings' => 'font',
            'options'  => array(
                'Roboto', 'Arial', 'Helvetica', 'Calibri'
            )
        )
    )
);