jeudi 19 mars 2015

Dynamic Control in customiser

I need to build a select on my theme customise screen from this foreach:



foreach($wp_registered_sidebars as $sidebar_id => $sidebar)
{
if($sidebar_id == $val)

$sidebar_id.$sidebar['name']
}


Here is the code for the setting and control for custom sidebar selection.


The dynamic list would need to go in the 'choices' => array();


Is this even possible?



// Add Layout setting
$wp_customize->add_setting(
// ID
'sidebar_left_selection',
// Arguments array
array(
'default' => 'none',
'type' => 'option',
)
);

// Add Layout control
$wp_customize->add_control(
// ID
'sidebar_left_selection',
// Arguments array
array(
'type' => 'select',
'label' => __( 'Sidebar Left Selection', 'webcodexcustomizer' ),
'section' => 'layout_section',
'choices' => array(
'none' => __( 'None', 'webcodexcustomizer' ),
'sidebar_test' => __( 'Test Sidebar', 'webcodexcustomizer' ),
),
'priority' => 36
)
);

Aucun commentaire:

Enregistrer un commentaire