Insert, edit and delete recipes from database in Wordpress admin.
Insert, edit and delete recipes from database in Wordpress by using a custom table with six fields: id (primary key, auto-increment), name (recipe name, tinytext), process (instructions for doing the recipe, tinytext), description (ingredients, tinytext), post_id (Wordpress post ID, defaults to zero, int) and permalink (Wordpress post permalink, tinytext).
When a recipe is created/edited the plugin should sync the row from the custom table with a Wordpress post. If the post_id value is zero then a new Wordpress post is created and the post_id and permalink is updated on the custom table. If post_id is not zero then update the associated post and also update the permalink since the recipe name changes the title of the Wordpress post and hence the permalink.
Post content is "Ingredients for Instructions for ", title is "", author and category in PHP constant (see specific technical requirements).
Specific technical requirements:
- Plugin in one single PHP file.
- Two display pages only: One for listing (one column only - name by ASC order - link for the edit page) recipes with a search form on top to filter recipes by name, ingredients or process. On the bottom of that page is a form with three fields to create a new recipe. The other page is to edit an existing recipe with an option to delete the recipe. If a recipe is removed both the Wordpress post and the row from the custom table should be removed.
- All the Wordpress posts have the category specified in a PHP constant.
- All the Wordpress posts have the author specified in a PHP constant.
- Custom table name specified in a PHP constant.
- No need to create or delete the custom table when the plugin is activated/deactivated.
- Plugin should integrate in the Wordpress menu and be accessible/visible by admin. The two pages are only accessed by admin.