PluginProbe
FeedWordPress / 2009.0613
FeedWordPress v2009.0613
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | compatability.php +72 -10 2008.11052009.0613 View file →
@@ -14,8 +14,43 @@
14 14 endif;
15 15 return $good;
16 16 } /* function fwp_test_wp_version () */
17 17
18 +class FeedWordPressCompatibility {
19 + /*static*/ function validate_http_request ($action = -1, $capability = null) {
20 + // Only worry about this if we're using a method with significant side-effects
21 + if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') :
22 + // Limit post by user capabilities
23 + if (!is_null($capability) and !current_user_can($capability)) :
24 + wp_die(__('Cheatin’ uh?'));
25 + endif;
26 +
27 + // If check_admin_referer() checks a nonce.
28 + if (function_exists('wp_verify_nonce')) :
29 + check_admin_referer($action);
30 +
31 + // No nonces means no checking nonces.
32 + else :
33 + check_admin_referer();
34 + endif;
35 + endif;
36 + } /* FeedWordPressCompatibility::validate_http_request() */
37 +
38 + /*static*/ function stamp_nonce ($action = -1) {
39 + // stamp form with hidden fields for a nonce in WP 2.0.3 & later
40 + if (function_exists('wp_nonce_field')) :
41 + wp_nonce_field($action);
42 + endif;
43 + } /* FeedWordPressCompatibility::stamp_nonce() */
44 +} /* class FeedWordPressCompatibility */
45 +
46 +if (!function_exists('stripslashes_deep')) {
47 + function stripslashes_deep($value) {
48 + $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
49 + return $value;
50 + }
51 +}
52 +
18 53 if (!function_exists('get_option')) {
19 54 function get_option ($option) {
20 55 return get_settings($option);
21 56 }
@@ -37,8 +72,11 @@
37 72 break;
38 73 case 'manage_links':
39 74 $can = ($user_level >= 5);
40 75 break;
76 + case 'edit_files':
77 + $can = ($user_level >= 9);
78 + break;
41 79 endswitch;
42 80 return $can;
43 81 }
44 82 } else {
@@ -45,9 +83,9 @@
45 83 $fwp_capability['manage_options'] = 'manage_options';
46 84 $fwp_capability['manage_links'] = 'manage_links';
47 85 }
48 86 if (!function_exists('sanitize_user')) {
49 - function sanitize_user ($text, $strict) {
87 + function sanitize_user ($text, $strict = false) {
50 88 return $text; // Don't munge it if it wasn't munged going in...
51 89 }
52 90 }
53 91 if (!function_exists('wp_insert_user')) {
@@ -75,26 +113,49 @@
75 113 $id = $wpdb->insert_id;
76 114
77 115 return $id;
78 116 }
79 -}
117 +} /* if (!function_exists('wp_insert_user')) */
80 118
119 +if (!function_exists('wp_die')) {
120 + function wp_die ( $message, $title = '', $args = array() ) {
121 + die($message);
122 + } /* wp_die() */
123 +} /* if */
124 +
81 125 function fwp_category_checklist ($post_id = 0, $descendents_and_self = 0, $selected_cats = false) {
82 126 if (function_exists('wp_category_checklist')) :
83 127 wp_category_checklist($post_id, $descendents_and_self, $selected_cats);
84 128 else :
85 - global $checked_categories;
86 -
87 129 // selected_cats is an array of integer cat_IDs / term_ids for
88 130 // 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;
131 + global $post_ID;
132 +
133 + $cats = get_nested_categories();
134 +
135 + // Undo damage from usort() in WP 2.0
136 + $dogs = array();
137 + foreach ($cats as $cat) :
138 + $dogs[$cat['cat_ID']] = $cat;
139 + endforeach;
140 + foreach ($selected_cats as $cat_id) :
141 + $dogs[$cat_id]['checked'] = true;
142 + endforeach;
143 + write_nested_categories($dogs);
144 + endif;
145 +}
146 +
147 +function fwp_time_elapsed ($ts) {
148 + if (function_exists('human_time_diff')) :
149 + if ($ts >= time()) :
150 + $ret = __(human_time_diff($ts)." from now");
151 + else :
152 + $ret = __(human_time_diff($ts)." ago");
92 153 endif;
93 -
94 - $checked_categories = $cats;
95 - dropdown_categories();
154 + else :
155 + $ret = strftime('%x %X', $ts);
96 156 endif;
157 + return $ret;
97 158 }
98 159
99 160 ################################################################################
100 161 ## UPGRADE INTERFACE: Have users upgrade DB from older versions of FWP #########
@@ -138,8 +199,9 @@
138 199
139 200 <p>This may take several minutes for a large installation.</p>
140 201
141 202 <form action="" method="post">
203 +<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_upgrade'); ?>
142 204 <div class="submit"><input type="submit" name="action" value="Upgrade" /></div>
143 205 </form>
144 206 </div>
145 207 <?php