am working on a wordpress admin panel using startbox admin panel, where I want to list all categories with slug and name inside an array but it seems impossible for me to make it work, here is my code
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'category',
'pad_counts' => false
);
$args = array(
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($args);
// This much above code is given by wordpress to get all categories, mine starts below
class sb_slider_settings extends sb_settings {
function sb_slider_settings() {
$this->slug = 'sb_slider_settings';
$this->options = array(
'on_off_news' => array(
'type' => 'select',
'default' => 'true',
'label' => __( 'Enable breaking news', 'startbox' ),
'options' => array(
'false' => __( 'No', 'startbox' ),
'true' => __( 'Yes', 'startbox' ),
)
),
'ticker_text' => array(
'type' => 'select',
'default' => 'true',
'class' => 'ticker_text',
'label' => __( 'Extract posts from', 'startbox' ),
'options' => array(
foreach($categories as $category) {
$category->slug => __( $category->name , 'startbox' ) ;
}
)
)
);
parent::__construct();
}
}
Error it shows,
Parse error: syntax error, unexpected 'foreach' (T_FOREACH), expecting ')'