ID); } } } function remove_all_categories() { foreach (get_all_category_ids() as $id) { wp_delete_category($id); } } function process_data($data) { $posts = $data; $categories = array(); foreach ($data as $post) { if (isset($post['categories'])) { $categories = array_merge($categories, $post['categories']); } } return compact('posts', 'categories'); } function create_categories($categories) { $category_ids_by_slug = array(); if (is_array($categories)) { foreach ($categories as $category) { $category_ids_by_slug[$category] = wp_insert_category(array('slug' => $category)); } } return $category_ids_by_slug; } }