Figured it out, you have to create a new class extending WP_Customize_Control:
// Add Layout setting
$wp_customize->add_setting(
// ID
'sidebar_left_selection',
// Arguments array
array(
'default' => 'none',
'sanitize_callback' => 'webcodexcustomizer_sanitize_sidebar_selection'
)
);
class customize_sidebar_selection extends WP_Customize_Control {
public function render_content()
{
global $wp_registered_sidebars;
// The actual fields for data entry
$output = "<span>" . esc_html( $this->label ) . "</span>";
$output .= "<select name="custom_sidebar_left">";
// Add a default option
$output .= "<option";
if($val == "default")
$output .= " selected='selected'";
$output .= " value="default">".__('default', $themename)."</option>";
// Fill the select element with all registered sidebars
foreach($wp_registered_sidebars as $sidebar_id => $sidebar)
{
$output .= "<option";
if($sidebar_id == $val)
$output .= " selected='selected'";
$output .= " value="".$sidebar_id."">".$sidebar['name']."</option>";
}
$output .= "</select>";
echo $output;
}
}
// Add Layout control
$wp_customize->add_control(
new customize_sidebar_selection(
$wp_customize, 'sidebar_left_selection', array(
'label' => 'Sidebar Left Selection',
'section' => 'layout_section',
'priority' => 36,
)
)
);