Implement the ability to import CSV files #120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements CSV import functionality for recipes, allowing users to bulk import recipes from CSV files. The feature includes support for all major recipe fields including ingredients with substitutions, directions, nutrition data, categories, and tags.
Related Issue
Closes #72
Changes
New CSV Import Handler (
includes/class.cooked-csv-import.php)||)Updated Import Interface (
includes/class.cooked-import.php)field_csv_upload()method for CSV upload formAJAX Handlers (
includes/class.cooked-ajax.php)upload_csv()handler for file uploadprocess_csv()handler for CSV processingJavaScript Updates (
assets/admin/js/cooked-migration.js)CSS Updates (
assets/admin/css/style.css)Translation Support (
includes/class.cooked-admin-enqueues.php)i18n_csv_no_fileandi18n_csv_invalid_filetranslation stringsMock Data (
tests/test_data/*.csv)CSV Format
The CSV import supports the following columns:
title(required) - Recipe titleexcerpt- Recipe descriptionprep_time- Prep time in minutescook_time- Cook time in minutesdifficulty_level- 1=Beginner, 2=Intermediate, 3=Advancedingredients- All ingredients in a single pipe-separated stringamount|measurement|name(e.g.,2|cups|All-Purpose Flour)name(e.g.,Salt and Pepper to taste)#Section Name(e.g.,#Meat Sauce)|||followed by substitution parts1|cup|Butter||1|cup|Margarine(Butter can be substituted with Margarine)amount|measurement|name||sub_amount|sub_measurement|sub_namedirections- Pipe-separated instructions (each step separated by|)#Section Name(e.g.,#For the Sauce)notes- Recipe notescategories- Comma-separated category namestags- Comma-separated tag namesScreenshots
Checklist
Please check if your PR fulfills the following requirements:
Testing Notes
Let me know if you would like any changes!