Changeset 364759
- Timestamp:
- 03/25/2011 08:52:00 PM (15 years ago)
- Location:
- recipeseo
- Files:
-
- 20 added
- 2 edited
-
tags/1.3 (added)
-
tags/1.3/delete.png (added)
-
tags/1.3/edit.png (added)
-
tags/1.3/readme.txt (added)
-
tags/1.3/recipeseo-placeholder.png (added)
-
tags/1.3/recipeseo.css (added)
-
tags/1.3/recipeseo.gif (added)
-
tags/1.3/recipeseo.php (added)
-
tags/1.3/recipeseo_editor_plugin.js (added)
-
tags/1.3/screenshot-1.png (added)
-
tags/1.3/screenshot-10.png (added)
-
tags/1.3/screenshot-11.png (added)
-
tags/1.3/screenshot-2.png (added)
-
tags/1.3/screenshot-3.png (added)
-
tags/1.3/screenshot-4.png (added)
-
tags/1.3/screenshot-5.png (added)
-
tags/1.3/screenshot-6.png (added)
-
tags/1.3/screenshot-7.png (added)
-
tags/1.3/screenshot-8.png (added)
-
tags/1.3/screenshot-9.png (added)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/recipeseo.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
recipeseo/trunk/readme.txt
r362798 r364759 71 71 1.3 Added ability to choose the format for the lists of ingredients and instructions. Added option to change or remove all of the labels. Added an 'Are you sure you want to delete?' alert when the user clicks on the delete recipe button. Fixed Prep Time, Cook Time, and Total Time so it's easy to select and display the times in proper ISO 8601 formats. 72 72 73 1.3.1 Fixed bugs that were throwing errors if the user isn't running the latest version of PHP. 74 73 75 == Upgrade Notice == 74 76 -
recipeseo/trunk/recipeseo.php
r362798 r364759 4 4 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.3 6 Version: 1.3.1 7 7 Author: Allison Day 8 8 Author URI: http://codeswan.com … … 344 344 345 345 $prep_time_input = ''; 346 try { 347 $prep_time = new DateInterval($recipe->prep_time); 348 $prep_time_seconds = $prep_time->s; 349 $prep_time_minutes = $prep_time->i; 350 $prep_time_hours = $prep_time->h; 351 $prep_time_days = $prep_time->d; 352 $prep_time_months = $prep_time->m; 353 $prep_time_years = $prep_time->y; 354 } catch (Exception $e) { 355 if ($recipe->prep_time != null) { 356 $prep_time_input = '<input type="text" name="prep_time" value="' . $recipe->prep_time . '"/>'; 346 $cook_time_input = ''; 347 $total_time_input = ''; 348 if (class_exists('DateInterval')) { 349 try { 350 $prep_time = new DateInterval($recipe->prep_time); 351 $prep_time_seconds = $prep_time->s; 352 $prep_time_minutes = $prep_time->i; 353 $prep_time_hours = $prep_time->h; 354 $prep_time_days = $prep_time->d; 355 $prep_time_months = $prep_time->m; 356 $prep_time_years = $prep_time->y; 357 } catch (Exception $e) { 358 if ($recipe->prep_time != null) { 359 $prep_time_input = '<input type="text" name="prep_time" value="' . $recipe->prep_time . '"/>'; 360 } 357 361 } 358 } 359 360 try {361 $cook_time = new DateInterval($recipe->cook_time);362 $cook_time_seconds = $cook_time->s;363 $cook_time_minutes = $cook_time->i;364 $cook_time_hours = $cook_time->h;365 $cook_time_days = $cook_time->d;366 $cook_time_months = $cook_time->m;367 $cook_time_years = $cook_time->y;368 } catch (Exception $e) {369 if ($recipe->cook_time != null) {370 $cook_time_input = '<input type="text" name="cook_time" value="' . $recipe->cook_time . '"/>';362 363 try { 364 $cook_time = new DateInterval($recipe->cook_time); 365 $cook_time_seconds = $cook_time->s; 366 $cook_time_minutes = $cook_time->i; 367 $cook_time_hours = $cook_time->h; 368 $cook_time_days = $cook_time->d; 369 $cook_time_months = $cook_time->m; 370 $cook_time_years = $cook_time->y; 371 } catch (Exception $e) { 372 if ($recipe->cook_time != null) { 373 $cook_time_input = '<input type="text" name="cook_time" value="' . $recipe->cook_time . '"/>'; 374 } 371 375 } 372 } 373 374 try { 375 $total_time = new DateInterval($recipe->total_time); 376 $total_time_seconds = $total_time->s; 377 $total_time_minutes = $total_time->i; 378 $total_time_hours = $total_time->h; 379 $total_time_days = $total_time->d; 380 $total_time_months = $total_time->m; 381 $total_time_years = $total_time->y; 382 } catch (Exception $e) { 383 if ($recipe->total_time != null) { 384 $total_time_input = '<input type="text" name="total_time" value="' . $recipe->total_time . '"/>'; 376 377 try { 378 $total_time = new DateInterval($recipe->total_time); 379 $total_time_seconds = $total_time->s; 380 $total_time_minutes = $total_time->i; 381 $total_time_hours = $total_time->h; 382 $total_time_days = $total_time->d; 383 $total_time_months = $total_time->m; 384 $total_time_years = $total_time->y; 385 } catch (Exception $e) { 386 if ($recipe->total_time != null) { 387 $total_time_input = '<input type="text" name="total_time" value="' . $recipe->total_time . '"/>'; 388 } 389 } 390 } else { 391 if (preg_match('(^[A-Z0-9]*$)', $recipe->prep_time) == 1) { 392 preg_match('(\d*S)', $recipe->prep_time, $pts); 393 $prep_time_seconds = str_replace('S', '', $pts[0]); 394 preg_match('(\d*M)', $recipe->prep_time, $ptm, PREG_OFFSET_CAPTURE, strpos($recipe->prep_time, 'T')); 395 $prep_time_minutes = str_replace('M', '', $ptm[0][0]); 396 preg_match('(\d*H)', $recipe->prep_time, $pth); 397 $prep_time_hours = str_replace('H', '', $pth[0]); 398 preg_match('(\d*D)', $recipe->prep_time, $ptd); 399 $prep_time_days = str_replace('D', '', $ptd[0]); 400 preg_match('(\d*M)', $recipe->prep_time, $ptmm); 401 $prep_time_months = str_replace('M', '', $ptmm[0]); 402 preg_match('(\d*Y)', $recipe->prep_time, $pty); 403 $prep_time_years = str_replace('Y', '', $pty[0]); 404 } else { 405 if ($recipe->prep_time != null) { 406 $prep_time_input = '<input type="text" name="prep_time" value="' . $recipe->prep_time . '"/>'; 407 } 408 } 409 410 if (preg_match('(^[A-Z0-9]*$)', $recipe->cook_time) == 1) { 411 preg_match('(\d*S)', $recipe->cook_time, $cts); 412 $cook_time_seconds = str_replace('S', '', $cts[0]); 413 preg_match('(\d*M)', $recipe->cook_time, $ctm, PREG_OFFSET_CAPTURE, strpos($recipe->cook_time, 'T')); 414 $cook_time_minutes = str_replace('M', '', $ctm[0][0]); 415 preg_match('(\d*H)', $recipe->cook_time, $cth); 416 $cook_time_hours = str_replace('H', '', $cth[0]); 417 preg_match('(\d*D)', $recipe->cook_time, $ctd); 418 $cook_time_days = str_replace('D', '', $ctd[0]); 419 preg_match('(\d*M)', $recipe->cook_time, $ctmm); 420 $cook_time_months = str_replace('M', '', $ctmm[0]); 421 preg_match('(\d*Y)', $recipe->cook_time, $cty); 422 $cook_time_years = str_replace('Y', '', $cty[0]); 423 } else { 424 if ($recipe->cook_time != null) { 425 $cook_time_input = '<input type="text" name="cook_time" value="' . $recipe->cook_time . '"/>'; 426 } 427 } 428 429 if (preg_match('(^[A-Z0-9]*$)', $recipe->total_time) == 1) { 430 preg_match('(\d*S)', $recipe->total_time, $tts); 431 $total_time_seconds = str_replace('S', '', $tts[0]); 432 preg_match('(\d*M)', $recipe->total_time, $ttm, PREG_OFFSET_CAPTURE, strpos($recipe->total_time, 'T')); 433 $total_time_minutes = str_replace('M', '', $ttm[0][0]); 434 preg_match('(\d*H)', $recipe->total_time, $tth); 435 $total_time_hours = str_replace('H', '', $tth[0]); 436 preg_match('(\d*D)', $recipe->total_time, $ttd); 437 $total_time_days = str_replace('D', '', $ttd[0]); 438 preg_match('(\d*M)', $recipe->total_time, $ttmm); 439 $total_time_months = str_replace('M', '', $ttmm[0]); 440 preg_match('(\d*Y)', $recipe->total_time, $tty); 441 $total_time_years = str_replace('Y', '', $tty[0]); 442 } else { 443 if ($recipe->total_time != null) { 444 $total_time_input = '<input type="text" name="total_time" value="' . $recipe->total_time . '"/>'; 445 } 385 446 } 386 447 } … … 847 908 } 848 909 if ($recipe->prep_time != null) { 849 try { 850 $prep_time_object = new DateInterval($recipe->prep_time); 851 852 $prep_time = ''; 853 foreach ($duration as $abbr => $name) { 854 if ($prep_time_object->$abbr > 0) { 855 $prep_time .= $prep_time_object->$abbr . ' ' . $name; 856 if ($prep_time_object->$abbr > 1) { 857 $prep_time .= 's'; 910 if (class_exists('DateInterval')) { 911 try { 912 $prep_time_object = new DateInterval($recipe->prep_time); 913 914 $prep_time = ''; 915 foreach ($duration as $abbr => $name) { 916 if ($prep_time_object->$abbr > 0) { 917 $prep_time .= $prep_time_object->$abbr . ' ' . $name; 918 if ($prep_time_object->$abbr > 1) { 919 $prep_time .= 's'; 920 } 921 $prep_time .= ', '; 858 922 } 859 $prep_time .= ', ';860 923 } 861 } 862 924 925 $prep_time = trim($prep_time, ' \t,'); 926 } catch (Exception $e) { 927 $prep_time = $recipe->prep_time; 928 } 929 } else { 930 $arr = explode('T', $recipe->prep_time); 931 $arr[0] = str_replace('M', 'X', $arr[0]); 932 $prep_time = implode('T', $arr); 933 934 $prep_time = str_replace('P', '', $prep_time); 935 $prep_time = str_replace('Y', ' years, ', $prep_time); 936 $prep_time = str_replace('X', ' months, ', $prep_time); 937 $prep_time = str_replace('D', ' days, ', $prep_time); 938 $prep_time = str_replace('T', '', $prep_time); 939 $prep_time = str_replace('H', ' hours, ', $prep_time); 940 $prep_time = str_replace('M', ' minutes, ', $prep_time); 941 $prep_time = str_replace('S', ' seconds', $prep_time); 942 863 943 $prep_time = trim($prep_time, ' \t,'); 864 } catch (Exception $e) {865 $prep_time = $recipe->prep_time;866 944 } 867 945 … … 873 951 } 874 952 if ($recipe->cook_time != null) { 875 try { 876 $cook_time_object = new DateInterval($recipe->cook_time); 877 878 $cook_time = ''; 879 foreach ($duration as $abbr => $name) { 880 if ($cook_time_object->$abbr > 0) { 881 $cook_time .= $cook_time_object->$abbr . ' ' . $name; 882 if ($cook_time_object->$abbr > 1) { 883 $cook_time .= 's'; 953 if (class_exists('DateInterval')) { 954 try { 955 $cook_time_object = new DateInterval($recipe->cook_time); 956 957 $cook_time = ''; 958 foreach ($duration as $abbr => $name) { 959 if ($cook_time_object->$abbr > 0) { 960 $cook_time .= $cook_time_object->$abbr . ' ' . $name; 961 if ($cook_time_object->$abbr > 1) { 962 $cook_time .= 's'; 963 } 964 $cook_time .= ', '; 884 965 } 885 $cook_time .= ', ';886 966 } 887 } 888 967 968 $cook_time = trim($cook_time, ' \t,'); 969 } catch (Exception $e) { 970 $cook_time = $recipe->cook_time; 971 } 972 } else { 973 $arr = explode('T', $recipe->cook_time); 974 $arr[0] = str_replace('M', 'X', $arr[0]); 975 $cook_time = implode('T', $arr); 976 977 $cook_time = str_replace('P', '', $cook_time); 978 $cook_time = str_replace('Y', ' years, ', $cook_time); 979 $cook_time = str_replace('X', ' months, ', $cook_time); 980 $cook_time = str_replace('D', ' days, ', $cook_time); 981 $cook_time = str_replace('T', '', $cook_time); 982 $cook_time = str_replace('H', ' hours, ', $cook_time); 983 $cook_time = str_replace('M', ' minutes, ', $cook_time); 984 $cook_time = str_replace('S', ' seconds', $cook_time); 985 889 986 $cook_time = trim($cook_time, ' \t,'); 890 } catch (Exception $e) {891 $cook_time = $recipe->cook_time;892 987 } 893 988 … … 899 994 } 900 995 if ($recipe->total_time != null) { 901 try { 902 $total_time_object = new DateInterval($recipe->total_time); 903 904 $total_time = ''; 905 foreach ($duration as $abbr => $name) { 906 if ($total_time_object->$abbr > 0) { 907 $total_time .= $total_time_object->$abbr . ' ' . $name; 908 if ($total_time_object->$abbr > 1) { 909 $total_time .= 's'; 996 if (class_exists('DateInterval')) { 997 try { 998 $total_time_object = new DateInterval($recipe->total_time); 999 1000 $total_time = ''; 1001 foreach ($duration as $abbr => $name) { 1002 if ($total_time_object->$abbr > 0) { 1003 $total_time .= $total_time_object->$abbr . ' ' . $name; 1004 if ($total_time_object->$abbr > 1) { 1005 $total_time .= 's'; 1006 } 1007 $total_time .= ', '; 910 1008 } 911 $total_time .= ', ';912 1009 } 913 } 914 1010 1011 $total_time = trim($total_time, ' \t,'); 1012 } catch (Exception $e) { 1013 $total_time = $recipe->total_time; 1014 } 1015 } else { 1016 $arr = explode('T', $recipe->total_time); 1017 $arr[0] = str_replace('M', 'X', $arr[0]); 1018 $total_time = implode('T', $arr); 1019 1020 $total_time = str_replace('P', '', $total_time); 1021 $total_time = str_replace('Y', ' years, ', $total_time); 1022 $total_time = str_replace('X', ' months, ', $total_time); 1023 $total_time = str_replace('D', ' days, ', $total_time); 1024 $total_time = str_replace('T', '', $total_time); 1025 $total_time = str_replace('H', ' hours, ', $total_time); 1026 $total_time = str_replace('M', ' minutes, ', $total_time); 1027 $total_time = str_replace('S', ' seconds', $total_time); 1028 915 1029 $total_time = trim($total_time, ' \t,'); 916 } catch (Exception $e) {917 $total_time = $recipe->total_time;918 1030 } 919 1031
Note: See TracChangeset
for help on using the changeset viewer.