| @@ -1,11 +1,29 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | function fwp_linkedit_single_submit ($status = NULL) { |
| 3 | - if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : | |
| 3 | + global $wp_db_version; | |
| 4 | + if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) : | |
| 4 | 5 | ?> |
| 5 | 6 | <div class="submitbox" id="submitlink"> |
| 6 | 7 | <div id="previewview"></div> |
| 7 | -<div class="inside"></div> | |
| 8 | +<div class="inside"> | |
| 9 | +<?php if (!is_null($status)) : ?> | |
| 10 | + <p><strong>Publication</strong></p> | |
| 11 | + <p>When a new post is syndicated from this feed...</p> | |
| 12 | + <select name="feed_post_status"> | |
| 13 | + <option value="site-default" <?php echo $status['post']['site-default']; ?>> Use | |
| 14 | + Syndication Options setting</option> | |
| 15 | + <option value="publish" <?php echo $status['post']['publish']; ?>>Publish it immediately</option> | |
| 16 | + | |
| 17 | + <?php if (SyndicatedPost::use_api('post_status_pending')) : ?> | |
| 18 | + <option value="pending" <?php echo $status['post']['pending']; ?>>Hold it Pending Review</option> | |
| 19 | + <?php endif; ?> | |
| 20 | + | |
| 21 | + <option value="draft" <?php echo $status['post']['draft']; ?>>Save it as a draft</option> | |
| 22 | + <option value="private" <?php echo $status['post']['private']; ?>>Keep it private</option> | |
| 23 | + </select> | |
| 24 | +<?php endif; ?> | |
| 25 | +</div> | |
| 8 | 26 | |
| 9 | 27 | <p class="submit"> |
| 10 | 28 | <input type="submit" name="submit" value="<?php _e('Save') ?>" /> |
| 11 | 29 | </p> |
| @@ -14,9 +32,10 @@ | ||
| 14 | 32 | endif; |
| 15 | 33 | } |
| 16 | 34 | |
| 17 | 35 | function fwp_linkedit_periodic_submit ($caption = NULL) { |
| 18 | - if (!fwp_test_wp_version(FWP_SCHEMA_25)) : | |
| 36 | + global $wp_db_version; | |
| 37 | + if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) : | |
| 19 | 38 | if (is_null($caption)) : $caption = __('Save Changes »'); endif; |
| 20 | 39 | ?> |
| 21 | 40 | <p class="submit"> |
| 22 | 41 | <input type="submit" name="submit" value="<?php print $caption; ?>" /> |
| @@ -24,19 +43,8 @@ | ||
| 24 | 43 | <?php |
| 25 | 44 | endif; |
| 26 | 45 | } |
| 27 | 46 | |
| 28 | -function fwp_linkedit_single_submit_closer ($caption = NULL) { | |
| 29 | - if (fwp_test_wp_version(FWP_SCHEMA_27)) : | |
| 30 | - if (is_null($caption)) : $caption = __('Save Changes'); endif; | |
| 31 | -?> | |
| 32 | -<p class="submit"> | |
| 33 | -<input class="button-primary" type="submit" name="submit" value="<?php print $caption; ?>" /> | |
| 34 | -</p> | |
| 35 | -<?php | |
| 36 | - endif; | |
| 37 | -} | |
| 38 | - | |
| 39 | 47 | function fwp_authors_single_submit ($link = NULL) { |
| 40 | 48 | global $wp_db_version; |
| 41 | 49 | |
| 42 | 50 | if (fwp_test_wp_version(FWP_SCHEMA_25)) : |
| @@ -100,9 +108,9 @@ | ||
| 100 | 108 | |
| 101 | 109 | function fwp_category_box ($checked, $object, $tags = array()) { |
| 102 | 110 | global $wp_db_version; |
| 103 | 111 | |
| 104 | - if (fwp_test_wp_version(FWP_SCHEMA_25)) : // WordPress 2.5.x | |
| 112 | + if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) : // WordPress 2.5.x | |
| 105 | 113 | ?> |
| 106 | 114 | <div id="category-adder" class="wp-hidden-children"> |
| 107 | 115 | <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4> |
| 108 | 116 | <p id="category-add" class="wp-hidden-child"> |
| @@ -125,9 +133,9 @@ | ||
| 125 | 133 | <?php fwp_category_checklist(NULL, false, $checked) ?> |
| 126 | 134 | </ul> |
| 127 | 135 | </div> |
| 128 | 136 | <?php |
| 129 | - elseif (fwp_test_wp_version(FWP_SCHEMA_20)) : // WordPress 2.x | |
| 137 | + elseif (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_20) : // WordPress 2.x | |
| 130 | 138 | ?> |
| 131 | 139 | <div id="moremeta"> |
| 132 | 140 | <div id="grabit" class="dbx-group"> |
| 133 | 141 | <fieldset id="categorydiv" class="dbx-box"> |
| @@ -134,10 +142,9 @@ | ||
| 134 | 142 | <h3 class="dbx-handle"><?php _e('Categories') ?></h3> |
| 135 | 143 | <div class="dbx-content"> |
| 136 | 144 | <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p> |
| 137 | 145 | <p id="jaxcat"></p> |
| 138 | - <div id="categorychecklist"><?php fwp_category_checklist(NULL, false, $checked); ?></div> | |
| 139 | - </div> | |
| 146 | + <ul id="categorychecklist"><?php fwp_category_checklist(NULL, false, $checked); ?></ul></div> | |
| 140 | 147 | </fieldset> |
| 141 | 148 | </div> |
| 142 | 149 | </div> |
| 143 | 150 | <?php |
| @@ -142,12 +149,12 @@ | ||
| 142 | 149 | </div> |
| 143 | 150 | <?php |
| 144 | 151 | else : // WordPress 1.5 |
| 145 | 152 | ?> |
| 146 | - <fieldset style="width: 60%;"> | |
| 153 | + <fieldset id="categorydiv" style="width: 20%; margin-right: 2em"> | |
| 147 | 154 | <legend><?php _e('Categories') ?></legend> |
| 148 | 155 | <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p> |
| 149 | - <div style="height: 10em; overflow: scroll;"><?php fwp_category_checklist(NULL, false, $checked); ?></div> | |
| 156 | + <div style="height: 20em"><?php fwp_category_checklist(NULL, false, $checked); ?></div> | |
| 150 | 157 | </fieldset> |
| 151 | 158 | <?php |
| 152 | 159 | endif; |
| 153 | 160 | } |
| @@ -163,117 +170,14 @@ | ||
| 163 | 170 | |
| 164 | 171 | function fwp_author_list () { |
| 165 | 172 | global $wpdb; |
| 166 | 173 | $ret = array(); |
| 167 | - | |
| 168 | - // display_name introduced in WP 2.0 | |
| 169 | - if (fwp_test_wp_version(FWP_SCHEMA_20)) : | |
| 170 | - $name_column = 'display_name'; | |
| 171 | - else : | |
| 172 | - $name_column = 'user_nickname'; | |
| 173 | - endif; | |
| 174 | - | |
| 175 | - $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY {$name_column}"); | |
| 174 | + $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY display_name"); | |
| 176 | 175 | if (is_array($users)) : |
| 177 | 176 | foreach ($users as $user) : |
| 178 | 177 | $id = (int) $user->ID; |
| 179 | - $ret[$id] = $user->{$name_column}; | |
| 180 | - if (strlen(trim($ret[$id])) == 0) : | |
| 181 | - $ret[$id] = $user->user_login; | |
| 182 | - endif; | |
| 178 | + $ret[$id] = $user->display_name; | |
| 183 | 179 | endforeach; |
| 184 | 180 | endif; |
| 185 | 181 | return $ret; |
| 186 | 182 | } |
| 187 | - | |
| 188 | -class FeedWordPressSettingsUI { | |
| 189 | - function instead_of_posts_box ($link_id = null) { | |
| 190 | - fwp_option_box_opener('Syndicated Posts, Comments & Pings', 'syndicatedpostsdiv', 'postbox'); | |
| 191 | - if (!is_null($link_id)) : | |
| 192 | - $from_this_feed = 'from this feed'; | |
| 193 | - $by_default = ''; | |
| 194 | - $id_param = "&link_id=".$link_id; | |
| 195 | - else : | |
| 196 | - $from_this_feed = 'from syndicated feeds'; | |
| 197 | - $by_default = " by default"; | |
| 198 | - $id_param = ""; | |
| 199 | - endif; | |
| 200 | -?> | |
| 201 | -<p>Use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php<?php print $id_param; ?>"><?php _e('Posts'); ?></a> | |
| 202 | -settings page to set up how new posts <?php print $from_this_feed; ?> will be published<?php $by_default; ?>, whether they will accept | |
| 203 | -comments and pings, any custom fields that should be set on each post, etc.</p> | |
| 204 | -<?php | |
| 205 | - fwp_option_box_closer(); | |
| 206 | - } /* FeedWordPressSettingsUI::instead_of_posts_box () */ | |
| 207 | - | |
| 208 | - function instead_of_authors_box ($link_id = null) { | |
| 209 | - if (!is_null($link_id)) : | |
| 210 | - $from_this_feed = 'from this feed'; | |
| 211 | - $by_default = ''; | |
| 212 | - $id_param = "&link_id=".$link_id; | |
| 213 | - else : | |
| 214 | - $from_this_feed = 'from syndicated feeds'; | |
| 215 | - $by_default = " by default"; | |
| 216 | - $id_param = ""; | |
| 217 | - endif; | |
| 218 | - | |
| 219 | - fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox') | |
| 220 | -?> | |
| 221 | -<p>Use the <a | |
| 222 | -href="admin.php?page=<?php print $GLOBALS['fwp_path'] | |
| 223 | -?>/authors-page.php<?php print $id_param; ?>"><?php _e('Authors'); | |
| 224 | -?></a> settings page to set up how new posts | |
| 225 | -<?php print $from_this_feed; ?> will be assigned to | |
| 226 | -authors.</p> | |
| 227 | -<?php | |
| 228 | - fwp_option_box_closer(); | |
| 229 | - } /* FeedWordPressSettingsUI::instead_of_authors_box () */ | |
| 230 | - | |
| 231 | - function instead_of_categories_box ($link_id = null) { | |
| 232 | - if (!is_null($link_id)) : | |
| 233 | - $from_this_feed = 'from this feed'; | |
| 234 | - $by_default = ''; | |
| 235 | - $id_param = "&link_id=".$link_id; | |
| 236 | - else : | |
| 237 | - $from_this_feed = 'from syndicated feeds'; | |
| 238 | - $by_default = " by default"; | |
| 239 | - $id_param = ""; | |
| 240 | - endif; | |
| 241 | - | |
| 242 | - fwp_option_box_opener(__('Categories & Tags'), 'categorydiv', 'postbox'); | |
| 243 | -?> | |
| 244 | -<p>Use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php<?php print $id_param; ?>"><?php _e('Categories & Tags'); ?></a> | |
| 245 | -settings page to set up how new posts <?php print $from_this_feed; ?> are assigned categories or tags<?php print $by_default; ?>.</p> | |
| 246 | -<?php | |
| 247 | - fwp_option_box_closer(); | |
| 248 | - } /* FeedWordPressSettingsUI::instead_of_categories_box () */ | |
| 249 | - | |
| 250 | -} /* class FeedWordPressSettingsUI */ | |
| 251 | - | |
| 252 | -function fwp_insert_new_user ($newuser_name) { | |
| 253 | - global $wpdb; | |
| 254 | - | |
| 255 | - $ret = null; | |
| 256 | - if (strlen($newuser_name) > 0) : | |
| 257 | - $userdata = array(); | |
| 258 | - $userdata['ID'] = NULL; | |
| 259 | - | |
| 260 | - $userdata['user_login'] = sanitize_user($newuser_name); | |
| 261 | - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']); | |
| 262 | - | |
| 263 | - $userdata['user_nicename'] = sanitize_title($newuser_name); | |
| 264 | - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']); | |
| 265 | - | |
| 266 | - $userdata['display_name'] = $wpdb->escape($newuser_name); | |
| 267 | - | |
| 268 | - $newuser_id = wp_insert_user($userdata); | |
| 269 | - if (is_numeric($newuser_id)) : | |
| 270 | - $ret = $newuser_id; | |
| 271 | - else : | |
| 272 | - // TODO: Add some error detection and reporting | |
| 273 | - endif; | |
| 274 | - else : | |
| 275 | - // TODO: Add some error reporting | |
| 276 | - endif; | |
| 277 | - return $ret; | |
| 278 | -} /* fwp_insert_new_user () */ | |
| 279 | 183 | |