How to add all categories into an array and extract the categories names and use it with a custom meta box

The problem was in how the the categories were stored in the array that didn’t go with the meta box code. To resolve the issue I’ve used a function (kindly provided by Jonathan Kuhn) that wrapped the categories in a way that I could use with the mate box code. Here’s the function:

// Wrap all categories in a function
function wcat2() {
    $out = array();
    $categories = get_categories();
    foreach( $categories as $category ) {
        $out[$category->term_id] = array(
            'label' => $category->slug,
            'value' => $category->term_id
        );
    }
    //return array('options'=>$out);
    return $out;
}

This function should replace this code:

 // Get all categories from WP and create a dropdown
    $categories = get_categories('hide_empty=0&orderby=name');
    $wp_cats = array();
    foreach ($categories as $category_list ) {
           $wp_cats[$category_list->cat_ID] = $category_list->cat_name;
    }
    array_unshift($wp_cats, "Choose a category");

Now all you have to do is call the function from the array in meta box:

    array(
            'label' => 'Category',
            'id'    => $prefix.'category',
            'type'  => 'select',
            'options' => wcat2()
        ),

This way you can have a meta box that will drawn all used categories from WordPress so the user can select the category from the meta box option as opposed to have to write the category name.