| @@ -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)) : |
| @@ -83,53 +91,26 @@ | ||
| 83 | 91 | <?php |
| 84 | 92 | endif; |
| 85 | 93 | } |
| 86 | 94 | |
| 87 | -function fwp_tags_box ($tags, $object) { | |
| 95 | +function fwp_tags_box ($tags) { | |
| 88 | 96 | if (!is_array($tags)) : $tags = array(); endif; |
| 89 | - | |
| 90 | - $desc = "<p style=\"font-size:smaller;font-style:bold;margin:0\">Tag $object as...</p>"; | |
| 91 | - | |
| 92 | - if (fwp_test_wp_version(FWP_SCHEMA_28)) : // WordPress 2.8+ | |
| 93 | - fwp_option_box_opener(__('Tags'), 'tagsdiv', 'postbox'); | |
| 94 | 97 | ?> |
| 95 | - <?php print $desc; ?> | |
| 96 | - <div class="tagsdiv" id="post_tag"> | |
| 97 | - <div class="jaxtag"> | |
| 98 | - <div class="nojs-tags hide-if-js"> | |
| 99 | - <p><?php _e('Add or remove tags'); ?></p> | |
| 100 | - <textarea name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]"><?php echo implode(",", $tags); ?></textarea> | |
| 101 | - </div> | |
| 102 | - | |
| 103 | - <span class="ajaxtag hide-if-no-js"> | |
| 104 | - <label class="screen-reader-text" for="new-tag-post_tag"><?php _e('Tags'); ?></label> | |
| 105 | - <input type="text" id="new-tag-post_tag" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php esc_attr_e('Add new tag'); ?>" /> | |
| 106 | - <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" /> | |
| 107 | - </span> | |
| 108 | - </div> | |
| 109 | - <p class="howto"><?php echo __('Separate tags with commas.'); ?></p> | |
| 110 | - <div class="tagchecklist"></div> | |
| 111 | - </div> | |
| 112 | - <p class="tagcloud-link hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php printf( __('Choose from the most used tags in %s'), 'Post Tags'); ?></a></p> | |
| 113 | - </div> | |
| 114 | - </div> | |
| 98 | +<div id="tagsdiv" class="postbox"> | |
| 99 | + <h3><?php _e('Tags') ?></h3> | |
| 100 | + <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p> | |
| 101 | + <div class="inside"> | |
| 102 | + <p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo implode(",", $tags); ?>" /></p> | |
| 103 | + <div id="tagchecklist"></div> | |
| 104 | + </div> | |
| 105 | +</div> | |
| 115 | 106 | <?php |
| 116 | - else : | |
| 117 | - fwp_option_box_opener(__('Tags'), 'tagsdiv', 'postbox'); | |
| 118 | -?> | |
| 119 | - <?php print $desc; ?> | |
| 120 | - <p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo implode(",", $tags); ?>" /></p> | |
| 121 | - <div id="tagchecklist"></div> | |
| 122 | - </div> | |
| 123 | - </div> | |
| 124 | -<?php | |
| 125 | - endif; | |
| 126 | 107 | } |
| 127 | 108 | |
| 128 | 109 | function fwp_category_box ($checked, $object, $tags = array()) { |
| 129 | 110 | global $wp_db_version; |
| 130 | 111 | |
| 131 | - 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 | |
| 132 | 113 | ?> |
| 133 | 114 | <div id="category-adder" class="wp-hidden-children"> |
| 134 | 115 | <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4> |
| 135 | 116 | <p id="category-add" class="wp-hidden-child"> |
| @@ -141,22 +122,20 @@ | ||
| 141 | 122 | </p> |
| 142 | 123 | </div> |
| 143 | 124 | |
| 144 | 125 | <ul id="category-tabs"> |
| 145 | - <?php /* ui-tabs-selected in WP 2.7 CSS = tabs in WP 2.8 CSS. Thank you, o brilliant wordsmiths of the WordPress 2.8 stylesheet... */ ?> | |
| 146 | - <li class="ui-tabs-selected tabs"><a href="#categories-all" tabindex="3"><?php _e( 'All posts' ); ?></a> | |
| 126 | + <li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All posts' ); ?></a> | |
| 147 | 127 | <p style="font-size:smaller;font-style:bold;margin:0">Give <?php print $object; ?> these categories</p> |
| 148 | 128 | </li> |
| 149 | 129 | </ul> |
| 150 | 130 | |
| 151 | -<?php /* ui-tabs-panel in WP 2.7 CSS = tabs-panel in WP 2.8 CSS. Thank you, o brilliant wordsmiths of the WordPress 2.8 stylesheet... */ ?> | |
| 152 | -<div id="categories-all" class="ui-tabs-panel tabs-panel"> | |
| 131 | +<div id="categories-all" class="ui-tabs-panel"> | |
| 153 | 132 | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> |
| 154 | 133 | <?php fwp_category_checklist(NULL, false, $checked) ?> |
| 155 | 134 | </ul> |
| 156 | 135 | </div> |
| 157 | 136 | <?php |
| 158 | - 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 | |
| 159 | 138 | ?> |
| 160 | 139 | <div id="moremeta"> |
| 161 | 140 | <div id="grabit" class="dbx-group"> |
| 162 | 141 | <fieldset id="categorydiv" class="dbx-box"> |
| @@ -163,10 +142,9 @@ | ||
| 163 | 142 | <h3 class="dbx-handle"><?php _e('Categories') ?></h3> |
| 164 | 143 | <div class="dbx-content"> |
| 165 | 144 | <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p> |
| 166 | 145 | <p id="jaxcat"></p> |
| 167 | - <div id="categorychecklist"><?php fwp_category_checklist(NULL, false, $checked); ?></div> | |
| 168 | - </div> | |
| 146 | + <ul id="categorychecklist"><?php fwp_category_checklist(NULL, false, $checked); ?></ul></div> | |
| 169 | 147 | </fieldset> |
| 170 | 148 | </div> |
| 171 | 149 | </div> |
| 172 | 150 | <?php |
| @@ -171,12 +149,12 @@ | ||
| 171 | 149 | </div> |
| 172 | 150 | <?php |
| 173 | 151 | else : // WordPress 1.5 |
| 174 | 152 | ?> |
| 175 | - <fieldset style="width: 60%;"> | |
| 153 | + <fieldset id="categorydiv" style="width: 20%; margin-right: 2em"> | |
| 176 | 154 | <legend><?php _e('Categories') ?></legend> |
| 177 | 155 | <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p> |
| 178 | - <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> | |
| 179 | 157 | </fieldset> |
| 180 | 158 | <?php |
| 181 | 159 | endif; |
| 182 | 160 | } |
| @@ -192,117 +170,14 @@ | ||
| 192 | 170 | |
| 193 | 171 | function fwp_author_list () { |
| 194 | 172 | global $wpdb; |
| 195 | 173 | $ret = array(); |
| 196 | - | |
| 197 | - // display_name introduced in WP 2.0 | |
| 198 | - if (fwp_test_wp_version(FWP_SCHEMA_20)) : | |
| 199 | - $name_column = 'display_name'; | |
| 200 | - else : | |
| 201 | - $name_column = 'user_nickname'; | |
| 202 | - endif; | |
| 203 | - | |
| 204 | - $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"); | |
| 205 | 175 | if (is_array($users)) : |
| 206 | 176 | foreach ($users as $user) : |
| 207 | 177 | $id = (int) $user->ID; |
| 208 | - $ret[$id] = $user->{$name_column}; | |
| 209 | - if (strlen(trim($ret[$id])) == 0) : | |
| 210 | - $ret[$id] = $user->user_login; | |
| 211 | - endif; | |
| 178 | + $ret[$id] = $user->display_name; | |
| 212 | 179 | endforeach; |
| 213 | 180 | endif; |
| 214 | 181 | return $ret; |
| 215 | 182 | } |
| 216 | - | |
| 217 | -class FeedWordPressSettingsUI { | |
| 218 | - function instead_of_posts_box ($link_id = null) { | |
| 219 | - fwp_option_box_opener('Syndicated Posts, Comments & Pings', 'syndicatedpostsdiv', 'postbox'); | |
| 220 | - if (!is_null($link_id)) : | |
| 221 | - $from_this_feed = 'from this feed'; | |
| 222 | - $by_default = ''; | |
| 223 | - $id_param = "&link_id=".$link_id; | |
| 224 | - else : | |
| 225 | - $from_this_feed = 'from syndicated feeds'; | |
| 226 | - $by_default = " by default"; | |
| 227 | - $id_param = ""; | |
| 228 | - endif; | |
| 229 | -?> | |
| 230 | -<p>Use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php<?php print $id_param; ?>"><?php _e('Posts'); ?></a> | |
| 231 | -settings page to set up how new posts <?php print $from_this_feed; ?> will be published<?php $by_default; ?>, whether they will accept | |
| 232 | -comments and pings, any custom fields that should be set on each post, etc.</p> | |
| 233 | -<?php | |
| 234 | - fwp_option_box_closer(); | |
| 235 | - } /* FeedWordPressSettingsUI::instead_of_posts_box () */ | |
| 236 | - | |
| 237 | - function instead_of_authors_box ($link_id = null) { | |
| 238 | - if (!is_null($link_id)) : | |
| 239 | - $from_this_feed = 'from this feed'; | |
| 240 | - $by_default = ''; | |
| 241 | - $id_param = "&link_id=".$link_id; | |
| 242 | - else : | |
| 243 | - $from_this_feed = 'from syndicated feeds'; | |
| 244 | - $by_default = " by default"; | |
| 245 | - $id_param = ""; | |
| 246 | - endif; | |
| 247 | - | |
| 248 | - fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox') | |
| 249 | -?> | |
| 250 | -<p>Use the <a | |
| 251 | -href="admin.php?page=<?php print $GLOBALS['fwp_path'] | |
| 252 | -?>/authors-page.php<?php print $id_param; ?>"><?php _e('Authors'); | |
| 253 | -?></a> settings page to set up how new posts | |
| 254 | -<?php print $from_this_feed; ?> will be assigned to | |
| 255 | -authors.</p> | |
| 256 | -<?php | |
| 257 | - fwp_option_box_closer(); | |
| 258 | - } /* FeedWordPressSettingsUI::instead_of_authors_box () */ | |
| 259 | - | |
| 260 | - function instead_of_categories_box ($link_id = null) { | |
| 261 | - if (!is_null($link_id)) : | |
| 262 | - $from_this_feed = 'from this feed'; | |
| 263 | - $by_default = ''; | |
| 264 | - $id_param = "&link_id=".$link_id; | |
| 265 | - else : | |
| 266 | - $from_this_feed = 'from syndicated feeds'; | |
| 267 | - $by_default = " by default"; | |
| 268 | - $id_param = ""; | |
| 269 | - endif; | |
| 270 | - | |
| 271 | - fwp_option_box_opener(__('Categories & Tags'), 'categorydiv', 'postbox'); | |
| 272 | -?> | |
| 273 | -<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> | |
| 274 | -settings page to set up how new posts <?php print $from_this_feed; ?> are assigned categories or tags<?php print $by_default; ?>.</p> | |
| 275 | -<?php | |
| 276 | - fwp_option_box_closer(); | |
| 277 | - } /* FeedWordPressSettingsUI::instead_of_categories_box () */ | |
| 278 | - | |
| 279 | -} /* class FeedWordPressSettingsUI */ | |
| 280 | - | |
| 281 | -function fwp_insert_new_user ($newuser_name) { | |
| 282 | - global $wpdb; | |
| 283 | - | |
| 284 | - $ret = null; | |
| 285 | - if (strlen($newuser_name) > 0) : | |
| 286 | - $userdata = array(); | |
| 287 | - $userdata['ID'] = NULL; | |
| 288 | - | |
| 289 | - $userdata['user_login'] = sanitize_user($newuser_name); | |
| 290 | - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']); | |
| 291 | - | |
| 292 | - $userdata['user_nicename'] = sanitize_title($newuser_name); | |
| 293 | - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']); | |
| 294 | - | |
| 295 | - $userdata['display_name'] = $wpdb->escape($newuser_name); | |
| 296 | - | |
| 297 | - $newuser_id = wp_insert_user($userdata); | |
| 298 | - if (is_numeric($newuser_id)) : | |
| 299 | - $ret = $newuser_id; | |
| 300 | - else : | |
| 301 | - // TODO: Add some error detection and reporting | |
| 302 | - endif; | |
| 303 | - else : | |
| 304 | - // TODO: Add some error reporting | |
| 305 | - endif; | |
| 306 | - return $ret; | |
| 307 | -} /* fwp_insert_new_user () */ | |
| 308 | 183 | |