You can also use a function like this:
<?php
/* Other stuff */
function sidebarOptions(){
$sidebars = $GLOBALS['wp_registered_sidebars'];
$sidebar_options = array();
foreach ( $sidebars as $sidebar ){
$sidebar_options[] = array(
'name' => $sidebar['name'],
'value' => $sidebar['id']
);
}
return $sidebar_options;
}
/* Other stuff */
/*
* Trying to print the result to check if it is what expect us
* echo '<pre>';
* print_r( sidebarOptions() );
* echo '</pre>';
*/
$meta_boxes[] = array(
'id' => 'WMW_page_layout_meta',
'title' => __( 'Page Layout Options', WMW_ADMIN_TEXTDOMAIN ),
'pages' => get_post_types(),
'context' => 'side',
'priority' => 'default',
'show_names' => false, // Show field names on the left
'fields' => array(
array(
'name' => __( 'Page Layout', WMW_ADMIN_TEXTDOMAIN ),
'desc' => __( 'You can choose between a left, right, or no sidebar layout for your page.', WMW_ADMIN_TEXTDOMAIN ),
'id' => '_layout',
'type' => 'select',
'options' => array(
array('name' => 'Full Width (No Sidebar)', 'value' => 'full_width', ),
array('name' => 'Sidebar on Left, Content on Right', 'value' => 'left_sidebar', ),
array('name' => 'Sidebar on Right, Content on Left', 'value' => 'right_sidebar',)
)
),
array(
'name' => __( 'Page Sidebar', WMW_ADMIN_TEXTDOMAIN ),
'desc' => __( 'Choose the Sidebar to show on this page.', WMW_ADMIN_TEXTDOMAIN ),
'id' => '_page_sidebar',
'type' => 'select',
'options' => sidebarOptions()
)
)
);