Changeset 358037
- Timestamp:
- 03/10/2011 07:45:25 AM (15 years ago)
- Location:
- recipeseo
- Files:
-
- 20 added
- 4 edited
-
tags/1.1.2 (added)
-
tags/1.1.2/readme.txt (added)
-
tags/1.1.2/recipeseo-placeholder.png (added)
-
tags/1.1.2/recipeseo.css (added)
-
tags/1.1.2/recipeseo.gif (added)
-
tags/1.1.2/recipeseo.php (added)
-
tags/1.1.2/screenshot-1.png (added)
-
tags/1.1.2/screenshot-2.png (added)
-
tags/1.1.2/screenshot-3.png (added)
-
tags/1.1.2/screenshot-4.png (added)
-
tags/1.1.2/screenshot-5.png (added)
-
tags/1.1.2/screenshot-6.png (added)
-
tags/1.1.2/screenshot-7.png (added)
-
tags/1.1.2/screenshot-8.png (added)
-
trunk/delete.png (added)
-
trunk/edit.png (added)
-
trunk/readme.txt (modified) (5 diffs)
-
trunk/recipeseo-placeholder.png (modified) (previous)
-
trunk/recipeseo.css (modified) (1 diff)
-
trunk/recipeseo.php (modified) (18 diffs)
-
trunk/recipeseo_editor_plugin.js (added)
-
trunk/screenshot-10.png (added)
-
trunk/screenshot-11.png (added)
-
trunk/screenshot-9.png (added)
Legend:
- Unmodified
- Added
- Removed
-
recipeseo/trunk/readme.txt
r357031 r358037 21 21 It's quick. It's simple. And best of all, your recipes now have a much better chance of showing up in Google's Recipe View, with very little additional work from you! 22 22 23 (If you don't use WordPress.org, or would rather be able to edit the formatted HTML on your own, check out my [RecipeSEO App!](http://recipeseo.com/)) 24 23 25 == Installation == 24 26 … … 30 32 31 33 == Frequently Asked Questions == 34 35 =Why do you put a placeholder image into my Edit Post page, instead of my actual recipe?= 36 37 Because of the way WordPress' text editor works, if you decide to add or remove something from your recipe using the text editor, it can very easily mess up the markup of the code - so the RecipeSEO plugin prevents that from happening by not allowing you to edit the recipe in the text editor. Although currently there is no way to edit an existing recipe, the next version of the RecipeSEO plugin (which will be released in a few days) will have the functionality to do so. 38 39 =What if my site is in HTML5?= 40 41 We will have a version that uses microdata (instead of microformats) for websites that use HTML5 very soon! But for now, the microformats that we use should work just fine for all HTML5 sites. 32 42 33 43 = How can I request a feature to be added in future versions of the RecipeSEO Plugin? = … … 45 55 7. Once you preview or publish the post, your recipe will be there with all your microformats... without any extra work from you! 46 56 8. Voila! Your new recipe can easily be styled with CSS, to look however you would like. 57 9. But what if you want to make changes to the recipe you just entered? All you have to do is click on the placeholder image, and then click on the big fat edit image (the left-hand one). 58 10. Make your changes and click the "Update Recipe" button... 59 11. Edited! Easy as can be. 47 60 48 61 == Changelog == … … 54 67 1.1.2 Fixed the bug that was keeping the plugin from working with the HTML post editor. 55 68 69 1.2 Added edit functionality! 70 56 71 == Upgrade Notice == 57 72 58 No upgrades so far... this is the first version! 73 1.2 Users can now edit recipes that they have already entered. 59 74 60 75 == Coming Soon... == … … 62 77 **Features that will be added in upcoming versions of the RecipeSEO Plugin:** 63 78 64 * The ability to edit existing recipes65 79 * Custom recipe styling options 80 * Ability to change titles ("Ingredients", "Prep time", etc.) 81 * ISO 8601 duration format for prep/cook/total times 66 82 * **Have a suggestion for a feature I should add? [Tell me!](http://sushiday.com/contact/)** -
recipeseo/trunk/recipeseo.css
r355541 r358037 33 33 #amd-recipeseo-uploader #add-another-ingredient { margin-top: 6px; } 34 34 #amd-recipeseo-uploader a { color: #21759B; margin-bottom: 32px; display: block; } 35 #amd-recipeseo-uploader #amd-recipeseo-instructions small { font-weight: normal; display: block; } 35 36 #amd-recipeseo-uploader #amd-recipeseo-instructions textarea { width: 585px; } 36 37 #amd-recipeseo-uploader input[type="submit"] { -moz-border-radius: 11px; -khtml-border-radius: 11px; -webkit-border-radius: 11px; border-radius: 11px -moz-box-sizing: content-box; border-style: solid; cursor: pointer; line-height: 13px; padding: 10px 25px; text-decoration: none; margin: 16px; text-shadow: 0 1px 0 #fff; background-color: #fff; border: 1px solid #bbb; font-size: 123.1%; font-weight: bold; } -
recipeseo/trunk/recipeseo.php
r357031 r358037 2 2 /* 3 3 Plugin Name: RecipeSEO 4 Plugin URI: http://sushiday.com/recipe seo4 Plugin URI: http://sushiday.com/recipe-seo-plugin/ 5 5 Description: A plugin that adds all the necessary microdata to your recipes, so it will show up in Google's Recipe Search 6 Version: 1. 1.26 Version: 1.2 7 7 Author: Allison Day 8 8 Author URI: http://codeswan.com … … 35 35 36 36 add_action('media_buttons', 'amd_recipeseo_add_recipe_button', 30); 37 add_action('init', 'amd_recipeseo_enhance_mce'); 37 38 38 39 if (strpos($_SERVER['REQUEST_URI'], 'media-upload.php') && strpos($_SERVER['REQUEST_URI'], '&type=amd_recipeseo') && !strpos($_SERVER['REQUEST_URI'], '&wrt=')) 39 40 { 40 amd_recipeseo_iframe_content($_POST );41 amd_recipeseo_iframe_content($_POST, $_REQUEST); 41 42 exit; 43 } 44 45 function amd_recipeseo_enhance_mce() { 46 if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) 47 return; 48 if ( get_user_option('rich_editing') == 'true') { 49 add_filter('mce_external_plugins', 'amd_recipeseo_tinymce_plugin'); 50 } 51 } 52 53 function amd_recipeseo_tinymce_plugin($plugin_array) { 54 55 $plugin_array['amdrecipeseo'] = get_option('siteurl') . '/wp-content/plugins/' . dirname(plugin_basename(__FILE__)) . '/recipeseo_editor_plugin.js'; 56 57 return $plugin_array; 42 58 } 43 59 … … 99 115 } 100 116 101 function amd_recipeseo_iframe_content($post_info = null ) {117 function amd_recipeseo_iframe_content($post_info = null, $get_info = null) { 102 118 $recipe_id = 0; 103 if ($post_info) { 104 $recipe_title = htmlentities($post_info["recipe_title"], ENT_QUOTES); 105 $summary = htmlentities($post_info["summary"], ENT_QUOTES); 106 $rating = htmlentities($post_info["rating"], ENT_QUOTES); 107 $prep_time = htmlentities($post_info["prep_time"], ENT_QUOTES); 108 $cook_time = htmlentities($post_info["cook_time"], ENT_QUOTES); 109 $total_time = htmlentities($post_info["total_time"], ENT_QUOTES); 110 $yield = htmlentities($post_info["yield"], ENT_QUOTES); 111 $serving_size = htmlentities($post_info["serving_size"], ENT_QUOTES); 112 $calories = htmlentities($post_info["calories"], ENT_QUOTES); 113 $fat = htmlentities($post_info["fat"], ENT_QUOTES); 114 $ingredients = array(); 115 for ($i = 0; $i < count($post_info["ingredients"]); $i++) { 116 $ingredients[$i]["name"] = htmlentities($post_info["ingredients"][$i]["name"], ENT_QUOTES); 117 $ingredients[$i]["amount"] = htmlentities($post_info["ingredients"][$i]["amount"], ENT_QUOTES); 118 } 119 $instructions = htmlentities($post_info["instructions"], ENT_QUOTES); 120 if ($recipe_title != null && $recipe_title != '' && $ingredients[0]['name'] != null && $ingredients[0]['name'] != '') { 121 $recipe_id = amd_recipeseo_insert_db($post_info); 119 $iframe_title = "Add a Recipe"; 120 $submit = "Add Recipe"; 121 if ($post_info || $get_info) { 122 if ($get_info["post_id"] && !$get_info["add-recipe-button"] && strpos($get_info["post_id"], '-') !== false) { 123 $recipe_id = preg_replace('/[0-9]*?\-/i', '', $get_info["post_id"]); 124 $recipe = amd_recipeseo_select_recipe_db($recipe_id); 125 $ingredients_list = amd_recipeseo_select_ingredients_db($recipe_id); 126 127 $recipe_title = $recipe->recipe_title; 128 $summary = $recipe->summary; 129 $rating = $recipe->rating; 130 $prep_time = $recipe->prep_time; 131 $cook_time = $recipe->cook_time; 132 $total_time = $recipe->total_time; 133 $yield = $recipe->yield; 134 $serving_size = $recipe->serving_size; 135 $calories = $recipe->calories; 136 $fat = $recipe->fat; 137 $ingredients = array(); 138 $i = 0; 139 foreach ($ingredients_list as $ingredient) { 140 $ingredients[$i]["name"] = $ingredient->name; 141 $ingredients[$i]["amount"] = $ingredient->amount; 142 $i++; 143 } 144 $instructions = $recipe->instructions; 145 $iframe_title = "Update Your Recipe"; 146 $submit = "Update Recipe"; 147 } else { 148 $recipe_id = htmlentities($post_info["recipe_id"], ENT_QUOTES); 149 $recipe_title = htmlentities($post_info["recipe_title"], ENT_QUOTES); 150 $summary = htmlentities($post_info["summary"], ENT_QUOTES); 151 $rating = htmlentities($post_info["rating"], ENT_QUOTES); 152 $prep_time = htmlentities($post_info["prep_time"], ENT_QUOTES); 153 $cook_time = htmlentities($post_info["cook_time"], ENT_QUOTES); 154 $total_time = htmlentities($post_info["total_time"], ENT_QUOTES); 155 $yield = htmlentities($post_info["yield"], ENT_QUOTES); 156 $serving_size = htmlentities($post_info["serving_size"], ENT_QUOTES); 157 $calories = htmlentities($post_info["calories"], ENT_QUOTES); 158 $fat = htmlentities($post_info["fat"], ENT_QUOTES); 159 $ingredients = array(); 160 for ($i = 0; $i < count($post_info["ingredients"]); $i++) { 161 $ingredients[$i]["name"] = htmlentities($post_info["ingredients"][$i]["name"], ENT_QUOTES); 162 $ingredients[$i]["amount"] = htmlentities($post_info["ingredients"][$i]["amount"], ENT_QUOTES); 163 } 164 $instructions = htmlentities($post_info["instructions"], ENT_QUOTES); 165 if ($recipe_title != null && $recipe_title != '' && $ingredients[0]['name'] != null && $ingredients[0]['name'] != '') { 166 $recipe_id = amd_recipeseo_insert_db($post_info); 167 } 122 168 } 123 169 } … … 131 177 } 132 178 $addingredients = ''; 133 if (!empty($ingredients) ) {179 if (!empty($ingredients) && count($ingredients) > 5) { 134 180 $num_ingredients = count($ingredients); 135 181 } else { … … 152 198 function amdRecipeseoAddIngredient(count, amount, name) { 153 199 five = true; 200 amount1 = ''; 201 name1 = ''; 154 202 if (count!=undefined) { 155 203 globalCount=count; … … 215 263 <body id="amd-recipeseo-uploader"> 216 264 <form enctype='multipart/form-data' method='post' action='' name='recipe_form'> 217 <h3 class='amd-recipeseo-title'> Add a Recipe</h3>265 <h3 class='amd-recipeseo-title'>$iframe_title</h3> 218 266 <div id='amd-recipeseo-form-items'> 219 267 <input type='hidden' name='post_id' value='$id' /> 268 <input type='hidden' name='recipe_id' value='$recipe_id' /> 220 269 <p id='recipe-title'><label>Recipe Title <span class='required'>*</span></label> <input type='text' name='recipe_title' value='$recipe_title' /></p> 221 270 <span id='amd_recipeseo_ingredients' class='cls'><p><label class='cls'>Ingredients <span class='required'>*</span></label></p> … … 225 274 </span> 226 275 <p id='add-another-ingredient'><a href='#' class='cls'>+ Add more ingredients</a></p> 227 <p id='amd-recipeseo-instructions' class='cls'><label>Instructions </label><textarea name='instructions'>$instructions</textarea></label></p>276 <p id='amd-recipeseo-instructions' class='cls'><label>Instructions <small>(Put each instruction on a separate line. There is no need to number your instructions.)</small></label><textarea name='instructions'>$instructions</textarea></label></p> 228 277 <p><a href='#' id='more-options-toggle'>More options</a></p> 229 278 <div id='more-options'> … … 238 287 <p><label>Fat</label> <input type='text' name='fat' value='$fat' /></p> 239 288 </div> 240 <input type='submit' value=' Add Recipe' name='add-recipe-button' />289 <input type='submit' value='$submit' name='add-recipe-button' /> 241 290 </div> 242 291 </form> … … 247 296 function amd_recipeseo_insert_db($post_info) { 248 297 global $wpdb; 298 299 $recipe_id = $post_info["recipe_id"]; 249 300 250 301 $recipe = array ( … … 263 314 ); 264 315 265 $wpdb->insert( $wpdb->prefix . "amd_recipeseo_recipes", $recipe ); 266 $recipe_id = $wpdb->insert_id; 316 if (amd_recipeseo_select_recipe_db($recipe_id) == null) { 317 $wpdb->insert( $wpdb->prefix . "amd_recipeseo_recipes", $recipe ); 318 $recipe_id = $wpdb->insert_id; 319 } else { 320 $wpdb->update( $wpdb->prefix . "amd_recipeseo_recipes", $recipe, array( 'recipe_id' => $recipe_id )); 321 $wpdb->query("DELETE FROM " . $wpdb->prefix . "amd_recipeseo_ingredients WHERE recipe_id = '" . $recipe_id . "'"); 322 } 267 323 268 324 for ($i = 0; $i < count($post_info["ingredients"]); $i++) { … … 273 329 "name" => $post_info["ingredients"][$i]["name"], 274 330 ); 275 331 276 332 $wpdb->insert( $wpdb->prefix . "amd_recipeseo_ingredients", $ingredient ); 277 333 } … … 282 338 283 339 function amd_recipeseo_plugin_footer() { 340 $url = get_option('siteurl'); 341 $dirname = dirname(plugin_basename(__FILE__)); 342 284 343 echo <<< HTML 344 <style type="text/css" media="screen"> 345 #wp_editrecipebtns { position:absolute;display:block;z-index:999998; } 346 #wp_editrecipebtn { margin-right:20px; } 347 #wp_editrecipebtn,#wp_delrecipebtn { cursor:pointer; padding:12px;background:#010101; -moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px; filter:alpha(opacity=80); -moz-opacity:0.8; -khtml-opacity: 0.8; opacity: 0.8; } 348 #wp_editrecipebtn:hover,#wp_delrecipebtn:hover { background:#000; filter:alpha(opacity=100); -moz-opacity:1; -khtml-opacity: 1; opacity: 1; } 349 </style> 285 350 <script>//<![CDATA[ 351 var baseurl = '$url'; 352 var dirname = '$dirname'; 286 353 function amdRecipeseoInsertIntoPostEditor(rid,getoption,dirname) { 287 354 tb_remove(); … … 291 358 var output = '<img id="amd-recipeseo-recipe-'; 292 359 output += rid; 293 output += '" class="amd-recipeseo-recipe" src="' + getoption + '/wp-content/plugins/' + dirname + '/recipeseo-placeholder.png ?ver=1.0" alt="" />';360 output += '" class="amd-recipeseo-recipe" src="' + getoption + '/wp-content/plugins/' + dirname + '/recipeseo-placeholder.png" alt="" />'; 294 361 295 362 … … 307 374 } 308 375 } 309 310 376 //]]></script> 311 377 HTML; … … 316 382 function amd_recipeseo_convert_to_recipe($post_text) { 317 383 $output = $post_text; 318 $needle = 'id="amd-recipeseo-recipe-'; 319 $preg_needle = '/(id)=("(amd-recipeseo-recipe-)[0-9^"]*")/i'; 320 321 if (strpos($post_text, $needle) !== false) { 322 preg_match_all($preg_needle, $post_text, $matches); 384 $needle_old = 'id="amd-recipeseo-recipe-'; 385 $preg_needle_old = '/(id)=("(amd-recipeseo-recipe-)[0-9^"]*")/i'; 386 $needle = '[amd-recipeseo-recipe:'; 387 $preg_needle = '/\[amd-recipeseo-recipe:([0-9]+)\]/i'; 388 389 if (strpos($post_text, $needle_old) !== false) { 390 // This is for backwards compatability. Please do not delete or alter. 391 preg_match_all($preg_needle_old, $post_text, $matches); 323 392 foreach ($matches[0] as $match) { 324 393 $recipe_id = str_replace('id="amd-recipeseo-recipe-', '', $match); … … 332 401 $output = str_replace('<img id="amd-recipeseo-recipe-' . $recipe_id . '" class="amd-recipeseo-recipe" src="' . get_option('siteurl') . '/wp-content/plugins/' . dirname(plugin_basename(__FILE__)) . '/recipeseo-placeholder.png?ver=1.0" alt="" />', $formatted_recipe, $output); 333 402 } 334 403 } 404 405 if (strpos($post_text, $needle) !== false) { 406 preg_match_all($preg_needle, $post_text, $matches); 407 foreach ($matches[0] as $match) { 408 $recipe_id = str_replace('[amd-recipeseo-recipe:', '', $match); 409 $recipe_id = str_replace(']', '', $recipe_id); 410 411 $recipe = amd_recipeseo_select_recipe_db($recipe_id); 412 $ingredients = amd_recipeseo_select_ingredients_db($recipe_id); 413 414 $formatted_recipe = amd_recipeseo_format_recipe($recipe, $ingredients); 415 416 $output = str_replace('[amd-recipeseo-recipe:' . $recipe_id . ']', $formatted_recipe, $output); 417 } 335 418 } 336 419 … … 354 437 355 438 return $ingredients; 439 } 440 441 function amd_recipeseo_delete_recipe_db($recipe_id) { 442 global $wpdb; 443 444 445 } 446 447 function amd_recipeseo_delete_ingredients_db($recipe_id) { 448 356 449 } 357 450 … … 415 508 $j = 0; 416 509 foreach ($instructions as $instruction) { 417 $output .= '<li id="recipeseo-instruction-' . $j . '" class="instruction">'; 418 $output .= $instruction; 419 $output .= '</li>'; 420 $j++; 510 if (strlen($instruction) > 1) { 511 $output .= '<li id="recipeseo-instruction-' . $j . '" class="instruction">'; 512 $output .= $instruction; 513 $output .= '</li>'; 514 $j++; 515 } 421 516 } 422 517 $output .= '</ol>';
Note: See TracChangeset
for help on using the changeset viewer.