PluginProbe
FeedWordPress / 2008.1214
FeedWordPress v2008.1214
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
feedwordpress / compatability.php

compatability.php in FeedWordPress 2008.1214, at compatability.php

172 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 ################################################################################
3 ## LEGACY API: Replicate or mock up functions for legacy support purposes ######
4 ################################################################################
5
6 // version testing
7 function fwp_test_wp_version ($floor, $ceiling = NULL) {
8 global $wp_db_version;
9
10 $ver = (isset($wp_db_version) ? $wp_db_version : 0);
11 $good = ($ver >= $floor);
12 if (!is_null($ceiling)) :
13 $good = ($good and ($ver < $ceiling));
14 endif;
15 return $good;
16 } /* function fwp_test_wp_version () */
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
25 if (!function_exists('get_option')) {
26 function get_option ($option) {
27 return get_settings($option);
28 }
29 }
30 if (!function_exists('current_user_can')) {
31 $fwp_capability['manage_options'] = 6;
32 $fwp_capability['manage_links'] = 5;
33 function current_user_can ($task) {
34 global $user_level;
35
36 $can = false;
37
38 // This is **not** a full replacement for current_user_can. It
39 // is only for checking the capabilities we care about via the
40 // WordPress 1.5 user levels.
41 switch ($task) :
42 case 'manage_options':
43 $can = ($user_level >= 6);
44 break;
45 case 'manage_links':
46 $can = ($user_level >= 5);
47 break;
48 endswitch;
49 return $can;
50 }
51 } else {
52 $fwp_capability['manage_options'] = 'manage_options';
53 $fwp_capability['manage_links'] = 'manage_links';
54 }
55 if (!function_exists('sanitize_user')) {
56 function sanitize_user ($text, $strict = false) {
57 return $text; // Don't munge it if it wasn't munged going in...
58 }
59 }
60 if (!function_exists('wp_insert_user')) {
61 function wp_insert_user ($userdata) {
62 global $wpdb;
63
64 #-- Help WordPress 1.5.x quack like a duck
65 $login = $userdata['user_login'];
66 $author = $userdata['display_name'];
67 $nice_author = $userdata['user_nicename'];
68 $email = $userdata['user_email'];
69 $url = $userdata['user_url'];
70
71 $wpdb->query (
72 "INSERT INTO $wpdb->users
73 SET
74 ID='0',
75 user_login='$login',
76 user_firstname='$author',
77 user_nickname='$author',
78 user_nicename='$nice_author',
79 user_description='$author',
80 user_email='$email',
81 user_url='$url'");
82 $id = $wpdb->insert_id;
83
84 return $id;
85 }
86 }
87
88 function fwp_category_checklist ($post_id = 0, $descendents_and_self = 0, $selected_cats = false) {
89 if (function_exists('wp_category_checklist')) :
90 wp_category_checklist($post_id, $descendents_and_self, $selected_cats);
91 else :
92 // selected_cats is an array of integer cat_IDs / term_ids for
93 // the categories that should be checked
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");
116 endif;
117 else :
118 $ret = strftime('%x %X', $ts);
119 endif;
120 return $ret;
121 }
122
123 ################################################################################
124 ## UPGRADE INTERFACE: Have users upgrade DB from older versions of FWP #########
125 ################################################################################
126
127 function fwp_upgrade_page () {
128 if (isset($GLOBALS['fwp_post']['action']) and $GLOBALS['fwp_post']['action']=='Upgrade') :
129 $ver = get_option('feedwordpress_version');
130 if (get_option('feedwordpress_version') != FEEDWORDPRESS_VERSION) :
131 echo "<div class=\"wrap\">\n";
132 echo "<h2>Upgrading FeedWordPress...</h2>";
133
134 $feedwordpress =& new FeedWordPress;
135 $feedwordpress->upgrade_database($ver);
136 echo "<p><strong>Done!</strong> Upgraded database to version ".FEEDWORDPRESS_VERSION.".</p>\n";
137 echo "<form action=\"\" method=\"get\">\n";
138 echo "<div class=\"submit\"><input type=\"hidden\" name=\"page\" value=\"syndication.php\" />";
139 echo "<input type=\"submit\" value=\"Continue &raquo;\" /></form></div>\n";
140 echo "</div>\n";
141 return;
142 else :
143 echo "<div class=\"updated\"><p>Already at version ".FEEDWORDPRESS_VERSION."!</p></div>";
144 endif;
145 endif;
146 ?>
147 <div class="wrap">
148 <h2>Upgrade FeedWordPress</h2>
149
150 <p>It appears that you have installed FeedWordPress
151 <?php echo FEEDWORDPRESS_VERSION; ?> as an upgrade to an existing installation of
152 FeedWordPress. That's no problem, but you will need to take a minute out first
153 to upgrade your database: some necessary changes in how the software keeps
154 track of posts and feeds will cause problems such as duplicate posts and broken
155 templates if we were to continue without the upgrade.</p>
156
157 <p>Note that most of FeedWordPress's functionality is temporarily disabled
158 until we have successfully completed the upgrade. Everything should begin
159 working as normal again once the upgrade is complete. There's extraordinarily
160 little chance of any damage as the result of the upgrade, but if you're paranoid
161 like me you may want to back up your database before you proceed.</p>
162
163 <p>This may take several minutes for a large installation.</p>
164
165 <form action="" method="post">
166 <div class="submit"><input type="submit" name="action" value="Upgrade" /></div>
167 </form>
168 </div>
169 <?php
170 } // function fwp_upgrade_page ()
171
172