| @@ -14,8 +14,15 @@ | ||
| 14 | 14 | endif; |
| 15 | 15 | return $good; |
| 16 | 16 | } /* function fwp_test_wp_version () */ |
| 17 | 17 | |
| 18 | +if (!function_exists('stripslashes_deep')) { | |
| 19 | + function stripslashes_deep($value) { | |
| 20 | + $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); | |
| 21 | + return $value; | |
| 22 | + } | |
| 23 | +} | |
| 24 | + | |
| 18 | 25 | if (!function_exists('get_option')) { |
| 19 | 26 | function get_option ($option) { |
| 20 | 27 | return get_settings($option); |
| 21 | 28 | } |
| @@ -45,9 +52,9 @@ | ||
| 45 | 52 | $fwp_capability['manage_options'] = 'manage_options'; |
| 46 | 53 | $fwp_capability['manage_links'] = 'manage_links'; |
| 47 | 54 | } |
| 48 | 55 | if (!function_exists('sanitize_user')) { |
| 49 | - function sanitize_user ($text, $strict) { | |
| 56 | + function sanitize_user ($text, $strict = false) { | |
| 50 | 57 | return $text; // Don't munge it if it wasn't munged going in... |
| 51 | 58 | } |
| 52 | 59 | } |
| 53 | 60 | if (!function_exists('wp_insert_user')) { |
| @@ -81,20 +88,37 @@ | ||
| 81 | 88 | function fwp_category_checklist ($post_id = 0, $descendents_and_self = 0, $selected_cats = false) { |
| 82 | 89 | if (function_exists('wp_category_checklist')) : |
| 83 | 90 | wp_category_checklist($post_id, $descendents_and_self, $selected_cats); |
| 84 | 91 | else : |
| 85 | - global $checked_categories; | |
| 86 | - | |
| 87 | 92 | // selected_cats is an array of integer cat_IDs / term_ids for |
| 88 | 93 | // the categories that should be checked |
| 89 | - $cats = array(); | |
| 90 | - if ($post_id) : $cats = wp_get_post_categories($post_id); | |
| 91 | - else : $cats = $selected_cats; | |
| 94 | + global $post_ID; | |
| 95 | + | |
| 96 | + $cats = get_nested_categories(); | |
| 97 | + | |
| 98 | + // Undo damage from usort() in WP 2.0 | |
| 99 | + $dogs = array(); | |
| 100 | + foreach ($cats as $cat) : | |
| 101 | + $dogs[$cat['cat_ID']] = $cat; | |
| 102 | + endforeach; | |
| 103 | + foreach ($selected_cats as $cat_id) : | |
| 104 | + $dogs[$cat_id]['checked'] = true; | |
| 105 | + endforeach; | |
| 106 | + write_nested_categories($dogs); | |
| 107 | + endif; | |
| 108 | +} | |
| 109 | + | |
| 110 | +function fwp_time_elapsed ($ts) { | |
| 111 | + if (function_exists('human_time_diff')) : | |
| 112 | + if ($ts >= time()) : | |
| 113 | + $ret = __(human_time_diff($ts)." from now"); | |
| 114 | + else : | |
| 115 | + $ret = __(human_time_diff($ts)." ago"); | |
| 92 | 116 | endif; |
| 93 | - | |
| 94 | - $checked_categories = $cats; | |
| 95 | - dropdown_categories(); | |
| 117 | + else : | |
| 118 | + $ret = strftime('%x %X', $ts); | |
| 96 | 119 | endif; |
| 120 | + return $ret; | |
| 97 | 121 | } |
| 98 | 122 | |
| 99 | 123 | ################################################################################ |
| 100 | 124 | ## UPGRADE INTERFACE: Have users upgrade DB from older versions of FWP ######### |