$servings = get_post_meta($post->ID, 'user-menus-global-servings', true); $recipes = get_post_meta($post->ID, 'user-menus-recipe-ids'); $recipes = isset($recipes[0]) ? $recipes[0] : null; if (!is_null($recipes) && count($recipes) > 0) { $migrated_recipes = array(); $order = array(); $nbrRecipes = 0; $unitSystem = 0; foreach ($recipes as $recipe_id) { if (get_post_type($recipe_id) == 'recipe') { $recipe = new WPURP_Recipe($recipe_id); $servings_original = $recipe->servings_normalized(); if ($servings_original < 1) { $servings_original = 1; } $migrated = array('id' => $recipe_id, 'name' => $recipe->title(), 'link' => $recipe->link(), 'servings_original' => $servings_original, 'servings_wanted' => $servings); $migrated_recipes[] = $migrated; $order[] = strval($nbrRecipes); $nbrRecipes++; } } update_post_meta($post->ID, 'user-menus-recipes', $migrated_recipes); update_post_meta($post->ID, 'user-menus-order', $order); update_post_meta($post->ID, 'user-menus-nbrRecipes', $nbrRecipes); update_post_meta($post->ID, 'user-menus-unitSystem', $unitSystem); } } } // Successfully migrated to 1.0.8 $migrate_version = '1.0.8'; update_option('wpurp_migrate_version', $migrate_version);