Skip to content

akirk/cookbook

Repository files navigation

Cookbook

A personal cookbook for WordPress. Store, import, categorize, cook, scale, convert, plan, and shop from your own recipes.

Built on the WpApp framework, so the app lives at /cookbook/ on your site, separate from your theme, with WordPress users, capabilities, and admin bar.

Features

  • Native WordPress storage. Every recipe is a cb-recipes custom post type with recipe_category (hierarchical), recipe_cuisine (hierarchical), recipe_tag (flat), and recipe_ingredient taxonomies, plus structured post meta for ingredients, instructions, optional named recipe parts, servings, prep/cook times, source URL, and notes. Shopping lists and week plans are separate user-authored CPTs.
  • Import from the web. Paste a URL, the plugin extracts schema.org Recipe JSON-LD (handling @graph, HowToSection, and ImageObject) or HTML microdata, preserving named recipe parts when JSON-LD or the visible recipe card exposes them. Plain-text paste import includes a live checklist preview for detected title, ingredients, and instructions. Photos are sideloaded into the WordPress media library and set as the recipe's featured image.
  • Browser-extension import. The Friends browser extension can POST the current page HTML to the site through a "Save as Recipe" action, where the importer turns it into a recipe.
  • Recipe refetch. Imported recipes keep their source URL and can be re-parsed later without replacing notes or tags.
  • Metric ⇄ Imperial. Recipes are stored in their original units; conversion happens on display. Set your preference in /cookbook/settings, or flip the live toggle on any recipe page. Unit aliases cover English and German (EL, TL, Stk, Prise, Bund, ...).
  • Live portion scaling. Type the number of servings you want and every parsed amount rescales and reconverts immediately, client-side. The same scaled quantities flow into shopping-list adds and cooking mode.
  • Cooking mode and history. Recipe pages can open a focused cooking view with a large active step, step navigation, ingredient and step checkoffs, progress state saved in the browser, and screen wake lock where supported. When you finish, Cookbook can save that you cooked the recipe; recipe pages also offer a dated Cooked this button and show when you last cooked it.
  • Ingredient tools. Browse recipes by ingredients you have, allow a configurable number of missing ingredients, browse individual ingredient pages, replace an ingredient from the recipe view, and merge/group/rename ingredient terms.
  • Shopping list. Add a recipe's scaled ingredients to your personal shopping list, combine compatible duplicate items, edit the list at home, and use a focused shop mode with large tap targets, undo, and quick add.
  • Week planner. Plan breakfast, lunch, and dinner for a week, place a recipe into the planner from its recipe page, then add the planned recipes' ingredients to your shopping list.
  • Recipe variations. Link recipes as parent/child variations, browse the variation family from parent or child recipe pages, and use Edit as variation to create a prefilled child recipe from an existing one.
  • Recipe editing. Create recipes manually, edit structured ingredients and instructions, categorize by category/cuisine/tags, add notes, replace photos through file upload or image URL, and remove photos.
  • Abilities API. When available, Cookbook registers abilities for recipe search/read/create/import, recipe variation creation, and week-plan read/save.
  • Dark mode via CSS light-dark(), respects the WpApp masterbar's dark-mode toggle.
  • Translatable with the cookbook text domain.

Install

cd wp-content/plugins
git clone <this-repo> cookbook
cd cookbook
composer install

Then activate Cookbook in WordPress and visit /cookbook/.

Usage

URL Page
/cookbook/ All recipes
/cookbook/new Create a recipe
/cookbook/new?variation_of={id} Create a prefilled recipe variation
/cookbook/import Paste a URL or recipe text to import
/cookbook/shopping-list Personal shopping list
/cookbook/planner Weekly meal planner
/cookbook/cooked Cooking history
/cookbook/by-ingredients Find recipes by ingredients on hand
/cookbook/manage-ingredients Merge, group, and rename ingredients
/cookbook/recipe/{id} View
/cookbook/recipe/{id}/edit Edit
/cookbook/category/{slug} Browse by category
/cookbook/tag/{slug} Browse by tag
/cookbook/ingredient/{slug} Browse by ingredient
/cookbook/settings Choose metric or imperial

Browser-extension import

Install the Friends browser extension, authorise it for your site, and a Save as Recipe action will appear in the popup. Open any recipe page in your browser, click the action, and the importer will create the recipe in Cookbook.

The integration uses the friends_browser_extension_actions filter — same pattern as the Post Collection plugin.

Abilities API

When the WordPress Abilities API is available, Cookbook registers a cookbook category with these abilities:

  • cookbook/search-recipes searches recipes by text, category, tag, ingredient, and limit. When called without parameters, it returns the 10 latest recipes.
  • cookbook/get-recipe returns one structured recipe by post ID, including flat ingredients/instructions, optional named parts for ingredient or instruction subsections, taxonomy terms, source URL, and view_url for linking to the user-facing recipe page.
  • cookbook/save-recipe creates a structured recipe from provided fields, or updates an existing recipe when id is supplied. Passing parts preserves named ingredient or instruction subsections while maintaining flat compatibility fields. Passing image_url sideloads it through the same media path used by recipe edit forms.
  • cookbook/import-recipe imports from source_url or pasted recipe text and optionally sideloads image_url.
  • cookbook/create-recipe-variation copies an existing recipe into a child variation, allowing supplied fields to replace ingredients, instructions, named parts, notes, or other recipe details.
  • cookbook/get-week-plan returns the signed-in user's week planner for a normalized week.
  • cookbook/save-week-plan saves recipe IDs into the signed-in user's breakfast, lunch, and dinner slots for a normalized week.

Cookbook also registers ai_assistant_ability_domains hints for recipe, ingredient, shopping-list, and meal-planning prompts so the AI Assistant knows to inspect Cookbook abilities instead of falling back to generic tools. Cookbook pages provide ai_assistant_welcome_tips prompts for common recipe search, import, variation, and meal-planning tasks.

Architecture

cookbook.php          Plugin bootstrap
src/
  App.php                 BaseApp facade: constants, routes, menu, hook wiring
  AbilitiesService.php    Abilities API registration, schemas, and callbacks
  AbstractService.php     Base class for app domain services
  AccessService.php       Shared owned-post and recipe lookup guards
  CookedHistoryService.php Cooking history dates, queries, and logging
  IngredientAdminService.php Ingredient merge, group, and rename handlers
  ImportService.php       Manual import, refetch, extension import, parse AJAX
  PlannerService.php      Week planner dates, plan storage, and save handler
  RecipeService.php       Recipe payloads, persistence, variation, and form saves
  RegistryService.php     CPT, taxonomy, REST, admin-bar, and activation registration
  ServiceContainer.php    Service container for the app domain objects
  ShoppingListService.php Shopping-list storage, normalization, and handlers
  StaticArchiveService.php Static Archive HTML/Markdown rendering
  UserPreferencesService.php Unit and household ingredient user preferences
  Importer.php            URL fetch + JSON-LD extraction + text-parse fallback
  Units.php               Mass/volume conversion, unit aliases, formatting
templates/
  index.php           Recipe list
  recipe.php          Recipe view (portion scaling, unit toggle, cooking mode, cooking history)
  recipe-edit.php     Edit existing
  new.php             Create new
  _form.php           Shared edit form
  import.php          Paste URL or text
  shopping-list.php   User-authored shopping list CPT view
  planner.php         User-authored week plan CPT view
  cooked.php          User-authored cooking history
  by-ingredients.php  Ingredient-on-hand search
  manage-ingredients.php  Ingredient term maintenance
  settings.php        User preferences
  category.php tag.php ingredient.php  Taxonomy archives

Forms POST to admin-post.php with WordPress nonces. The browser-extension endpoint hooks wp_loaded and reads ?cookbook-collect={url} with body={page_html} in the POST body.

Standards

wp plugin check cookbook       # WordPress.org Plugin Check
composer phpcs                 # WordPress Coding Standards (via wp-app)

License

GPL-2.0-or-later

About

Store your recipes in WordPress

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages