| @@ -1,7 +1,50 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 | +require_once(dirname(__FILE__) . '/magpiemocklink.class.php'); | |
| 4 | +require_once(dirname(__FILE__) . '/feedfinder.class.php'); | |
| 3 | 5 | |
| 6 | +$FeedWordPressHTTPStatusMessages = array ( | |
| 7 | + 200 => 'OK. FeedWordPress had no problems retrieving the content at this URL but the content does not seem to be a feed, and does not seem to include links to any feeds.', | |
| 8 | + 201 => 'Created', | |
| 9 | + 202 => 'Accepted', | |
| 10 | + 203 => 'Non-Authoritative information', | |
| 11 | + 204 => 'No Content', | |
| 12 | + 205 => 'Reset Content', | |
| 13 | + 206 => 'Partial Content', | |
| 14 | + 300 => 'Multiple Choices', | |
| 15 | + 301 => 'Moved Permanently', | |
| 16 | + 302 => 'Found', | |
| 17 | + 303 => 'See Other', | |
| 18 | + 304 => 'Not Modified', | |
| 19 | + 305 => 'Use Proxy', | |
| 20 | + 307 => 'Temporary Redirect', | |
| 21 | + 400 => 'Bad Request', | |
| 22 | + 401 => 'Unauthorized. This URL probably needs a username and password for you to access it.', | |
| 23 | + 402 => 'Payment Required', | |
| 24 | + 403 => 'Forbidden. The URL is not made available for the machine that FeedWordPress is running on.', | |
| 25 | + 404 => 'Not Found. There is nothing at this URL. Have you checked the address for typos?', | |
| 26 | + 405 => 'Method Not Allowed', | |
| 27 | + 406 => 'Not Acceptable', | |
| 28 | + 407 => 'Proxy Authentication Required', | |
| 29 | + 408 => 'Request Timeout', | |
| 30 | + 409 => 'Conflict', | |
| 31 | + 410 => 'Gone. This URL is no longer available on this server and no forwarding address is known.', | |
| 32 | + 411 => 'Length Required', | |
| 33 | + 412 => 'Precondition Failed', | |
| 34 | + 413 => 'Request Entity Too Large', | |
| 35 | + 414 => 'Request URI Too Long', | |
| 36 | + 415 => 'Unsupported Media Type', | |
| 37 | + 416 => 'Requested Range Not Satisfiable', | |
| 38 | + 417 => 'Expectation Failed', | |
| 39 | + 500 => 'Internal Server Error. Something unexpected went wrong with the configuration of the server that hosts this URL. You might try again later to see if this issue has been resolved.', | |
| 40 | + 501 => 'Not Implemented', | |
| 41 | + 502 => 'Bad Gateway', | |
| 42 | + 503 => 'Service Unavailable. The server is currently unable to handle the request due to a temporary overloading or maintenance of the server that hosts this URL. This is probably a temporary condition and you should try again later to see if the issue has been resolved.', | |
| 43 | + 504 => 'Gateway Timeout', | |
| 44 | + 505 => 'HTTP Version Not Supported', | |
| 45 | +); | |
| 46 | + | |
| 4 | 47 | ################################################################################ |
| 5 | 48 | ## ADMIN MENU ADD-ONS: implement Dashboard management pages #################### |
| 6 | 49 | ################################################################################ |
| 7 | 50 | |
| @@ -40,13 +83,21 @@ | ||
| 40 | 83 | elseif (isset($_POST['update_uri'])) : |
| 41 | 84 | $update_set[] = $_POST['update_uri']; |
| 42 | 85 | endif; |
| 43 | 86 | |
| 44 | - | |
| 87 | + shuffle($update_set); // randomize order for load balancing purposes... | |
| 45 | 88 | if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line |
| 46 | 89 | $feedwordpress =& new FeedWordPress; |
| 47 | 90 | add_action('feedwordpress_check_feed', 'update_feeds_mention'); |
| 48 | - | |
| 91 | + add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3); | |
| 92 | + | |
| 93 | + $crash_dt = (int) get_option('feedwordpress_update_time_limit'); | |
| 94 | + if ($crash_dt > 0) : | |
| 95 | + $crash_ts = time() + $crash_dt; | |
| 96 | + else : | |
| 97 | + $crash_ts = NULL; | |
| 98 | + endif; | |
| 99 | + | |
| 49 | 100 | if (fwp_test_wp_version(FWP_SCHEMA_25)) : |
| 50 | 101 | echo "<div class=\"youare\">\n"; |
| 51 | 102 | else : |
| 52 | 103 | echo "<div class=\"updated\">\n"; |
| @@ -53,10 +104,15 @@ | ||
| 53 | 104 | endif; |
| 54 | 105 | echo "<ul>\n"; |
| 55 | 106 | $tdelta = NULL; |
| 56 | 107 | foreach ($update_set as $uri) : |
| 108 | + if (!is_null($crash_ts) and (time() > $crash_ts)) : | |
| 109 | + echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>"; | |
| 110 | + break; | |
| 111 | + endif; | |
| 112 | + | |
| 57 | 113 | if ($uri == '*') : $uri = NULL; endif; |
| 58 | - $delta = $feedwordpress->update($uri); | |
| 114 | + $delta = $feedwordpress->update($uri, $crash_ts); | |
| 59 | 115 | if (!is_null($delta)) : |
| 60 | 116 | if (is_null($tdelta)) : |
| 61 | 117 | $tdelta = $delta; |
| 62 | 118 | else : |
| @@ -105,36 +161,97 @@ | ||
| 105 | 161 | if ($cont): |
| 106 | 162 | ?> |
| 107 | 163 | <?php |
| 108 | 164 | $links = FeedWordPress::syndicated_links(); |
| 109 | - | |
| 165 | +?> | |
| 166 | + <div class="wrap"> | |
| 167 | +<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 168 | + <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div> | |
| 169 | + <h2>Syndicated Sites</h2> | |
| 170 | +<?php endif; | |
| 110 | 171 | if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : |
| 111 | 172 | fwp_dashboard_update_if_requested(); |
| 112 | 173 | endif; |
| 113 | 174 | |
| 114 | - if ($links): // only display Update panel if there are some links to update.... | |
| 115 | - ?> | |
| 175 | + if (fwp_test_wp_version(FWP_SCHEMA_27)) : | |
| 176 | +?> | |
| 177 | + <script type="text/javascript"> | |
| 178 | + jQuery(document).ready( function($) { | |
| 179 | + // In case someone got here first. | |
| 180 | + $('.postbox h3, .postbox .handlediv').unbind('click'); | |
| 181 | + $('.hide-postbox-tog').unbind('click'); | |
| 182 | + $('.meta-box-sortables').sortable('destroy'); | |
| 183 | + | |
| 184 | + postboxes.add_postbox_toggles('feedwordpress_syndication'); | |
| 185 | + } ); | |
| 186 | + </script> | |
| 187 | +<?php | |
| 188 | + echo "<form style='display: none' method='get' action=''>\n<p>\n"; | |
| 189 | + wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); | |
| 190 | + wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); | |
| 191 | + echo "</p>\n</form>\n"; | |
| 192 | + | |
| 193 | + if ($links) : | |
| 194 | + add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal'); | |
| 195 | + endif; | |
| 196 | + add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal'); | |
| 197 | +?> | |
| 198 | + <div class="metabox-holder"> | |
| 199 | + <div id="feedwordpress-sortables" class="meta-box-sortables ui-sortable"> | |
| 200 | +<?php | |
| 201 | + do_meta_boxes('feedwordpress_syndication', 'normal', NULL); | |
| 202 | + else : | |
| 203 | + if ($links): // only display Update panel if there are some links to update.... | |
| 204 | + fwp_syndication_manage_page_update_box(); | |
| 205 | + endif; | |
| 206 | + fwp_syndication_manage_page_links_box(); | |
| 207 | +?> | |
| 208 | + </div> <!-- class="wrap" --> | |
| 209 | + | |
| 210 | + <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 211 | + <div class="wrap"> | |
| 212 | + <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> | |
| 213 | + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> | |
| 214 | + <h2>Add a new syndicated site:</h2> | |
| 215 | + <div> | |
| 216 | + <label for="add-uri">Website or feed:</label> | |
| 217 | + <input type="text" name="lookup" id="add-uri" value="URI" size="64" /> | |
| 218 | + <input type="hidden" name="action" value="feedfinder" /> | |
| 219 | + </div> | |
| 220 | + <div class="submit"><input type="submit" value="Syndicate »" /></div> | |
| 221 | + </form> | |
| 222 | + </div> <!-- class="wrap" --> | |
| 223 | + <?php endif; ?> | |
| 224 | + | |
| 225 | + <div style="display: none"> | |
| 226 | + <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug --> | |
| 227 | + </div> | |
| 228 | +<?php | |
| 229 | + endif; | |
| 230 | +endif; | |
| 231 | +} /* function fwp_syndication_manage_page () */ | |
| 232 | + | |
| 233 | +function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) { | |
| 234 | + $updateFeedsNow = __('Update feeds now'); | |
| 235 | +?> | |
| 116 | 236 | <form action="" method="POST"> |
| 117 | - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> | |
| 118 | - <div class="wrap"> | |
| 237 | + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> | |
| 238 | + <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?> | |
| 119 | 239 | <div id="rightnow"> |
| 120 | - <h3 class="reallynow"><span>Update feeds now</span> | |
| 240 | + <h3 class="reallynow"><span><?php print $updateFeedsNow; ?></span> | |
| 121 | 241 | <input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" /> |
| 122 | 242 | <br class="clear"/></h3> |
| 123 | - <?php else : ?> | |
| 124 | - <div class="wrap"> | |
| 125 | - <h2>Update feeds now</h2> | |
| 243 | + <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 244 | + <h2><?php print $updateFeedsNow; ?></h2> | |
| 126 | 245 | <?php endif; ?> |
| 127 | 246 | |
| 128 | - <?php | |
| 247 | +<?php | |
| 129 | 248 | if (fwp_test_wp_version(FWP_SCHEMA_25)) : |
| 130 | 249 | fwp_dashboard_update_if_requested(); |
| 131 | 250 | else : |
| 132 | 251 | ?> |
| 133 | 252 | <p>Check currently scheduled feeds for new and updated posts.</p> |
| 134 | -<?php | |
| 135 | - endif; | |
| 136 | - ?> | |
| 253 | +<?php endif; ?> | |
| 137 | 254 | |
| 138 | 255 | <?php if (!get_option('feedwordpress_automatic_updates')) : ?> |
| 139 | 256 | <p class="youhave"><strong>Note:</strong> Automatic updates are currently turned |
| 140 | 257 | <strong>off</strong>. New posts from your feeds will not be syndicated |
| @@ -142,24 +259,35 @@ | ||
| 142 | 259 | updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication |
| 143 | 260 | Options</a>.</p> |
| 144 | 261 | <?php endif; ?> |
| 145 | 262 | |
| 146 | - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 147 | - <div class="submit"><input type="hidden" name="update_uri" value="*" /><input type="submit" name="update" value="Update" /></div> | |
| 263 | + <?php if (!fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?> | |
| 264 | + <div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div> | |
| 148 | 265 | <?php endif; ?> |
| 149 | - | |
| 150 | - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> | |
| 266 | + | |
| 267 | + <?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 268 | + <br style="clear: both" /> | |
| 269 | + <?php elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?> | |
| 151 | 270 | </div> <!-- id="rightnow" --> |
| 271 | + </div> <!-- class="wrap" --> | |
| 272 | + <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 273 | + </div> <!-- class="wrap" --> | |
| 152 | 274 | <?php endif; ?> |
| 153 | - </div> <!-- class="wrap" --> | |
| 154 | 275 | </form> |
| 155 | 276 | <?php |
| 156 | - endif; | |
| 277 | +} /* function fwp_syndication_manage_page_update_box () */ | |
| 278 | + | |
| 279 | +function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) { | |
| 280 | + $links = FeedWordPress::syndicated_links(); | |
| 157 | 281 | ?> |
| 282 | + <?php if (!fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 283 | + <div class="wrap"> | |
| 284 | + <h2>Syndicated Sites</h2> | |
| 285 | + <?php endif; ?> | |
| 158 | 286 | |
| 159 | - <div class="wrap"> | |
| 160 | 287 | <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 161 | - <h2>Syndicated Sites</h2> | |
| 288 | + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> | |
| 289 | + | |
| 162 | 290 | <?php $alt_row = true; ?> |
| 163 | 291 | |
| 164 | 292 | <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> |
| 165 | 293 | <div class="tablenav"> |
| @@ -202,15 +330,14 @@ | ||
| 202 | 330 | <table width="100%" cellpadding="3" cellspacing="3"> |
| 203 | 331 | <?php endif; ?> |
| 204 | 332 | <thead> |
| 205 | 333 | <tr> |
| 206 | - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : $span = 3; ?> | |
| 207 | - <th class="check-column" scope="col"><input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> /></th> | |
| 208 | - <?php else : $span = 4; ?> | |
| 209 | - <?php endif; ?> | |
| 210 | -<th width="20%" scope="col"><?php _e('Name'); ?></th> | |
| 211 | -<th width="40%" scope="col"><?php _e('Feed'); ?></th> | |
| 212 | -<th class="action-links" scope="col" colspan="<?php print $span; ?>"><?php _e('Action'); ?></th> | |
| 334 | +<th class="check-column" scope="col"><?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> | |
| 335 | +<input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> /> | |
| 336 | +<?php endif; ?></th> | |
| 337 | +<th scope="col"><?php _e('Name'); ?></th> | |
| 338 | +<th scope="col"><?php _e('Feed'); ?></th> | |
| 339 | +<th scope="col"><?php _e('Updated'); ?></th> | |
| 213 | 340 | </tr> |
| 214 | 341 | </thead> |
| 215 | 342 | |
| 216 | 343 | <tbody> |
| @@ -216,16 +343,31 @@ | ||
| 216 | 343 | <tbody> |
| 217 | 344 | <?php if (count($links) > 0): foreach ($links as $link): |
| 218 | 345 | $alt_row = !$alt_row; ?> |
| 219 | 346 | <tr<?php echo ($alt_row?' class="alternate"':''); ?>> |
| 220 | - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> | |
| 221 | 347 | <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th> |
| 222 | - <?php endif; ?> | |
| 223 | - | |
| 224 | -<td><a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></td> | |
| 348 | +<?php | |
| 349 | + if (strlen($link->link_rss) > 0): | |
| 350 | + $caption=__('Switch Feed'); | |
| 351 | + else : | |
| 352 | + $caption=__('Find Feed'); | |
| 353 | + endif; | |
| 354 | +?> | |
| 355 | +<td> | |
| 356 | +<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=linkedit"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></strong> | |
| 357 | +<div class="row-actions"><div><strong>Settings ></strong> | |
| 358 | +<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=linkedit"><?php _e('Feed'); ?></a> | |
| 359 | +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Posts'); ?></a> | |
| 360 | +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/authors-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Authors'); ?></a> | |
| 361 | +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Categories & Tags'); ?></a></div> | |
| 362 | +<div><strong>Actions ></strong> | |
| 363 | +<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=feedfinder"><?php echo $caption; ?></a> | |
| 364 | +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=Unsubscribe"><?php _e('Unsubscribe'); ?></a> | |
| 365 | +| <a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php _e('View')?></a></div> | |
| 366 | +</div> | |
| 367 | +</td> | |
| 225 | 368 | <?php |
| 226 | 369 | if (strlen($link->link_rss) > 0): |
| 227 | - $caption='Switch Feed'; | |
| 228 | 370 | $uri_bits = parse_url($link->link_rss); |
| 229 | 371 | $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']); |
| 230 | 372 | $display_uri = |
| 231 | 373 | (isset($uri_bits['user'])?$uri_bits['user'].'@':'') |
| @@ -234,28 +376,39 @@ | ||
| 234 | 376 | .(isset($uri_bits['path'])?$uri_bits['path']:'') |
| 235 | 377 | .(isset($uri_bits['query'])?'?'.$uri_bits['query']:''); |
| 236 | 378 | if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'…'; endif; |
| 237 | 379 | ?> |
| 238 | - <td> | |
| 239 | - <strong><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td> | |
| 240 | -<?php | |
| 241 | - else: | |
| 242 | - $caption='Find Feed'; | |
| 243 | -?> | |
| 380 | + <td><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></td> | |
| 381 | + <?php else: ?> | |
| 244 | 382 | <td style="background-color:#FFFFD0"><p><strong>no |
| 245 | 383 | feed assigned</strong></p></td> |
| 246 | -<?php | |
| 384 | + <?php endif; ?> | |
| 385 | + | |
| 386 | + <td><?php | |
| 387 | + $sLink =& new SyndicatedLink($link->link_id); | |
| 388 | + if (isset($sLink->settings['update/last'])) : | |
| 389 | + print fwp_time_elapsed($sLink->settings['update/last']); | |
| 390 | + else : | |
| 391 | + _e('None yet'); | |
| 247 | 392 | endif; |
| 393 | + | |
| 394 | + print "<div style='font-style:italic;size:0.9em'>Ready for next update "; | |
| 395 | + if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) : | |
| 396 | + if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') : | |
| 397 | + $next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60); | |
| 398 | + print fwp_time_elapsed($next); | |
| 399 | + else : | |
| 400 | + echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":""); | |
| 401 | + endif; | |
| 402 | + else: | |
| 403 | + echo "as soon as possible"; | |
| 404 | + endif; | |
| 405 | + print "</div>"; | |
| 248 | 406 | ?> |
| 249 | - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=linkedit" class="edit"><?php _e('Edit')?></a></td> | |
| 250 | - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=feedfinder" class="edit"><?php echo $caption; ?></a></td> | |
| 251 | - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=Unsubscribe" class="delete"><?php _e('Unsubscribe'); ?></a></td> | |
| 252 | - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 253 | - <td><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></td> | |
| 407 | + </td> | |
| 408 | + </tr> | |
| 254 | 409 | <?php |
| 255 | - endif; | |
| 256 | - echo "\n\t</tr>"; | |
| 257 | - endforeach; | |
| 410 | + endforeach; | |
| 258 | 411 | else : |
| 259 | 412 | ?> |
| 260 | 413 | <tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr> |
| 261 | 414 | <?php |
| @@ -270,34 +423,14 @@ | ||
| 270 | 423 | <input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div> |
| 271 | 424 | <?php endif; ?> |
| 272 | 425 | |
| 273 | 426 | </form> |
| 274 | - | |
| 275 | - </div> <!-- class="wrap" --> | |
| 276 | - | |
| 277 | - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 278 | - <div class="wrap"> | |
| 279 | - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> | |
| 280 | - <h2>Add a new syndicated site:</h2> | |
| 281 | - <div> | |
| 282 | - <label for="add-uri">Website or newsfeed:</label> | |
| 283 | - <input type="text" name="lookup" id="add-uri" value="URI" size="64" /> | |
| 284 | - <input type="hidden" name="action" value="feedfinder" /> | |
| 285 | - </div> | |
| 286 | - <div class="submit"><input type="submit" value="Syndicate »" /></div> | |
| 287 | - </form> | |
| 288 | - </div> <!-- class="wrap" --> | |
| 289 | - <?php endif; ?> | |
| 290 | - | |
| 291 | -<div style="display: none"> | |
| 292 | -<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug --> | |
| 293 | -</div> | |
| 294 | 427 | <?php |
| 295 | -endif; | |
| 296 | -} | |
| 428 | +} /* function fwp_syndication_manage_page_links_box() */ | |
| 297 | 429 | |
| 298 | 430 | function fwp_feedfinder_page () { |
| 299 | 431 | global $wpdb; |
| 432 | + global $FeedWordPressHTTPStatusMessages; | |
| 300 | 433 | |
| 301 | 434 | $lookup = (isset($_REQUEST['lookup'])?$_REQUEST['lookup']:NULL); |
| 302 | 435 | |
| 303 | 436 | if (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']!=0)): |
| @@ -311,9 +444,9 @@ | ||
| 311 | 444 | else: |
| 312 | 445 | die (__("Cheatin' uh ?")); |
| 313 | 446 | endif; |
| 314 | 447 | else: |
| 315 | - $name = "New Syndicated Feed"; | |
| 448 | + $name = "<code>".htmlspecialchars($lookup)."</code>"; | |
| 316 | 449 | $link_id = 0; |
| 317 | 450 | endif; |
| 318 | 451 | ?> |
| 319 | 452 | <div class="wrap"> |
| @@ -326,10 +459,26 @@ | ||
| 326 | 459 | $rss = fetch_rss($f); |
| 327 | 460 | if ($rss): |
| 328 | 461 | $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link']; |
| 329 | 462 | $feed_link = isset($rss->channel['link'])?$rss->channel['link']:''; |
| 463 | + else : | |
| 464 | + // Give us some sucky defaults | |
| 465 | + $uri_bits = parse_url($lookup); | |
| 466 | + $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']); | |
| 467 | + $display_uri = | |
| 468 | + (isset($uri_bits['user'])?$uri_bits['user'].'@':'') | |
| 469 | + .(isset($uri_bits['host'])?$uri_bits['host']:'') | |
| 470 | + .(isset($uri_bits['port'])?':'.$uri_bits['port']:'') | |
| 471 | + .(isset($uri_bits['path'])?$uri_bits['path']:'') | |
| 472 | + .(isset($uri_bits['query'])?'?'.$uri_bits['query']:''); | |
| 473 | + if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'…'; endif; | |
| 474 | + | |
| 475 | + $feed_title = $display_uri; | |
| 476 | + $feed_link = $lookup; | |
| 477 | + endif; | |
| 330 | 478 | ?> |
| 331 | 479 | <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 480 | + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div> | |
| 332 | 481 | <fieldset style="clear: both"> |
| 333 | 482 | <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend> |
| 334 | 483 | |
| 335 | 484 | <?php if ($link_id===0): ?> |
| @@ -343,16 +492,20 @@ | ||
| 343 | 492 | |
| 344 | 493 | <div> |
| 345 | 494 | <div style="float:right; background-color:#D0D0D0; color: black; width:45%; font-size:70%; border-left: 1px dotted #A0A0A0; padding-left: 0.5em; margin-left: 1.0em"> |
| 346 | 495 | <?php if (count($rss->items) > 0): ?> |
| 347 | - <?php $item = $rss->items[0]; ?> | |
| 496 | + <?php | |
| 497 | + // Prepare to display Sample Item | |
| 498 | + $link =& new MagpieMockLink($rss, $f); | |
| 499 | + $post =& new SyndicatedPost($rss->items[0], $link); | |
| 500 | + ?> | |
| 348 | 501 | <h3>Sample Item</h3> |
| 349 | 502 | <ul> |
| 350 | - <li><strong>Title:</strong> <a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></li> | |
| 351 | - <li><strong>Date:</strong> <?php echo isset($item['date_timestamp']) ? date('d-M-y g:i:s a', $item['date_timestamp']) : 'unknown'; ?></li> | |
| 503 | + <li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li> | |
| 504 | + <li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li> | |
| 352 | 505 | </ul> |
| 353 | 506 | <div class="entry"> |
| 354 | - <?php echo (isset($item['content']['encoded'])?$item['content']['encoded']:$item['description']); ?> | |
| 507 | + <?php print $post->post['post_content']; ?> | |
| 355 | 508 | </div> |
| 356 | 509 | <?php else: ?> |
| 357 | 510 | <h3>No Items</h3> |
| 358 | 511 | <p>FeedWordPress found no posts on this feed.</p> |
| @@ -372,17 +525,39 @@ | ||
| 372 | 525 | </div> |
| 373 | 526 | </div> |
| 374 | 527 | </fieldset> |
| 375 | 528 | </form> |
| 376 | -<?php endif; | |
| 529 | +<?php | |
| 377 | 530 | endforeach; |
| 378 | 531 | else: |
| 379 | - echo "<p><strong>no feed found</strong></p>"; | |
| 532 | + print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>'; | |
| 533 | + print ". ".__('Try another URL').".</p>"; | |
| 534 | + | |
| 535 | + // Diagnostics | |
| 536 | + $httpObject = _wp_http_get_object(); | |
| 537 | + $transports = $httpObject->_getTransport(); | |
| 538 | + print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n"; | |
| 539 | + print "<h3>".__('Diagnostic information')."</h3>\n"; | |
| 540 | + if (!is_null($f->error())) : | |
| 541 | + print "<h4>".__('HTTP request failure')."</h4>\n"; | |
| 542 | + print "<p>".$f->error()."</p>\n"; | |
| 543 | + else : | |
| 544 | + print "<h4>".__('HTTP request completed')."</h4>\n"; | |
| 545 | + print "<p><strong>Status ".$f->status().":</strong> ".$FeedWordPressHTTPStatusMessages[$f->status()]."</p>\n"; | |
| 546 | + endif; | |
| 547 | + print "<h4>".__('HTTP Transports available').":</h4>\n"; | |
| 548 | + print "<ol>\n"; | |
| 549 | + print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n"; | |
| 550 | + print "</ol>\n"; | |
| 551 | + print "</div>\n"; | |
| 380 | 552 | endif; |
| 381 | 553 | ?> |
| 382 | 554 | </div> |
| 383 | 555 | |
| 384 | 556 | <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 557 | + <div><?php | |
| 558 | + FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); | |
| 559 | + ?></div> | |
| 385 | 560 | <div class="wrap"> |
| 386 | 561 | <h2>Use another feed</h2> |
| 387 | 562 | <div><label>Feed:</label> |
| 388 | 563 | <input type="text" name="lookup" value="URI" /> |
| @@ -397,21 +572,22 @@ | ||
| 397 | 572 | |
| 398 | 573 | function fwp_switchfeed_page () { |
| 399 | 574 | global $wpdb, $wp_db_version; |
| 400 | 575 | |
| 401 | - check_admin_referer(); | |
| 576 | + // If this is a POST, validate source and user credentials | |
| 577 | + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links'); | |
| 578 | + | |
| 402 | 579 | if (!isset($_REQUEST['Cancel'])): |
| 403 | - if (!current_user_can('manage_links')): | |
| 404 | - die (__("Cheatin' uh ?")); | |
| 405 | - elseif (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']==0)): | |
| 580 | + if (isset($_POST['link_id']) and ($_POST['link_id']==0)): | |
| 406 | 581 | $link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']); |
| 407 | 582 | if ($link_id): ?> |
| 408 | -<div class="updated"><p><a href="<?php echo $_REQUEST['feed_link']; ?>"><?php echo wp_specialchars($_REQUEST['feed_title'], 'both'); ?></a> | |
| 409 | -has been added as a contributing site, using the newsfeed at <<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>>.</p></div> | |
| 583 | +<div class="updated"><p><a href="<?php echo stripslashes($_REQUEST['feed_link']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed_title']), 'both'); ?></a> | |
| 584 | +has been added as a contributing site, using the feed at <<a href="<?php echo stripslashes($_REQUEST['feed']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed']), 'both'); ?></a>>. | |
| 585 | +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link_id; ?>&action=linkedit">Configure settings</a>.</div> | |
| 410 | 586 | <?php else: ?> |
| 411 | -<div class="updated"><p>There was a problem adding the newsfeed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div> | |
| 587 | +<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div> | |
| 412 | 588 | <?php endif; |
| 413 | - elseif (isset($_REQUEST['link_id'])): | |
| 589 | + elseif (isset($_POST['link_id'])): | |
| 414 | 590 | // Update link_rss |
| 415 | 591 | $result = $wpdb->query(" |
| 416 | 592 | UPDATE $wpdb->links |
| 417 | 593 | SET |
| @@ -437,9 +613,10 @@ | ||
| 437 | 613 | |
| 438 | 614 | function fwp_linkedit_page () { |
| 439 | 615 | global $wpdb, $wp_db_version; |
| 440 | 616 | |
| 441 | - check_admin_referer(); // Make sure we arrived here from the Dashboard | |
| 617 | + // If this is a POST, validate source and user credentials | |
| 618 | + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_linkedit', /*capability=*/ 'manage_links'); | |
| 442 | 619 | |
| 443 | 620 | $special_settings = array ( /* Regular expression syntax is OK here */ |
| 444 | 621 | 'cats', |
| 445 | 622 | 'cat_split', |
| @@ -459,11 +636,9 @@ | ||
| 459 | 636 | 'feed/.*', |
| 460 | 637 | 'link/.*', |
| 461 | 638 | ); |
| 462 | 639 | |
| 463 | - if (!current_user_can('manage_links')) : | |
| 464 | - die (__("Cheatin' uh ?")); | |
| 465 | - elseif (isset($_REQUEST['feedfinder'])) : | |
| 640 | + if (isset($_REQUEST['feedfinder'])) : | |
| 466 | 641 | return fwp_feedfinder_page(); // re-route to Feed Finder page |
| 467 | 642 | else : |
| 468 | 643 | $link_id = (int) $_REQUEST['link_id']; |
| 469 | 644 | $link =& new SyndicatedLink($link_id); |
| @@ -471,13 +646,8 @@ | ||
| 471 | 646 | if ($link->found()) : |
| 472 | 647 | if (isset($GLOBALS['fwp_post']['save'])) : |
| 473 | 648 | $alter = array (); |
| 474 | 649 | |
| 475 | - $meta = $link->settings; | |
| 476 | - //if (isset($meta['cats'])): | |
| 477 | - // $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']); | |
| 478 | - //endif; | |
| 479 | - | |
| 480 | 650 | // custom feed settings first |
| 481 | 651 | foreach ($GLOBALS['fwp_post']['notes'] as $mn) : |
| 482 | 652 | $mn['key0'] = trim($mn['key0']); |
| 483 | 653 | $mn['key1'] = trim($mn['key1']); |
| @@ -488,13 +658,13 @@ | ||
| 488 | 658 | $mn['key1'] = 'user/'.$mn['key1']; |
| 489 | 659 | endif; |
| 490 | 660 | |
| 491 | 661 | if (strlen($mn['key0']) > 0) : |
| 492 | - unset($meta[$mn['key0']]); // out with the old | |
| 662 | + unset($link->settings[$mn['key0']]); // out with the old | |
| 493 | 663 | endif; |
| 494 | 664 | |
| 495 | 665 | if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) : |
| 496 | - $meta[$mn['key1']] = $mn['value']; // in with the new | |
| 666 | + $link->settings[$mn['key1']] = $mn['value']; // in with the new | |
| 497 | 667 | endif; |
| 498 | 668 | endforeach; |
| 499 | 669 | |
| 500 | 670 | // now stuff through the web form |
| @@ -499,22 +669,22 @@ | ||
| 499 | 669 | |
| 500 | 670 | // now stuff through the web form |
| 501 | 671 | // hardcoded feed info |
| 502 | 672 | if (isset($GLOBALS['fwp_post']['hardcode_name'])) : |
| 503 | - $meta['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name']; | |
| 504 | - if (FeedWordPress::affirmative($meta, 'hardcode name')) : | |
| 673 | + $link->settings['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name']; | |
| 674 | + if (FeedWordPress::affirmative($link->settings, 'hardcode name')) : | |
| 505 | 675 | $alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'"; |
| 506 | 676 | endif; |
| 507 | 677 | endif; |
| 508 | 678 | if (isset($GLOBALS['fwp_post']['hardcode_description'])) : |
| 509 | - $meta['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description']; | |
| 510 | - if (FeedWordPress::affirmative($meta, 'hardcode description')) : | |
| 679 | + $link->settings['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description']; | |
| 680 | + if (FeedWordPress::affirmative($link->settings, 'hardcode description')) : | |
| 511 | 681 | $alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'"; |
| 512 | 682 | endif; |
| 513 | 683 | endif; |
| 514 | 684 | if (isset($GLOBALS['fwp_post']['hardcode_url'])) : |
| 515 | - $meta['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url']; | |
| 516 | - if (FeedWordPress::affirmative($meta, 'hardcode url')) : | |
| 685 | + $link->settings['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url']; | |
| 686 | + if (FeedWordPress::affirmative($link->settings, 'hardcode url')) : | |
| 517 | 687 | $alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'"; |
| 518 | 688 | endif; |
| 519 | 689 | endif; |
| 520 | 690 | |
| @@ -519,180 +689,13 @@ | ||
| 519 | 689 | endif; |
| 520 | 690 | |
| 521 | 691 | // Update scheduling |
| 522 | 692 | if (isset($GLOBALS['fwp_post']['update_schedule'])) : |
| 523 | - $meta['update/hold'] = $GLOBALS['fwp_post']['update_schedule']; | |
| 693 | + $link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule']; | |
| 524 | 694 | endif; |
| 525 | 695 | |
| 526 | - // Categories | |
| 527 | - if (isset($GLOBALS['fwp_post']['post_category'])) : | |
| 528 | - $meta['cats'] = array(); | |
| 529 | - foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) : | |
| 530 | - $meta['cats'][] = '{#'.$cat_id.'}'; | |
| 531 | - endforeach; | |
| 532 | - else : | |
| 533 | - unset($meta['cats']); | |
| 534 | - endif; | |
| 696 | + $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'"; | |
| 535 | 697 | |
| 536 | - // Tags | |
| 537 | - if (isset($GLOBALS['fwp_post']['tags_input'])) : | |
| 538 | - $meta['tags'] = array(); | |
| 539 | - foreach (explode(',', $GLOBALS['fwp_post']['tags_input']) as $tag) : | |
| 540 | - $meta['tags'][] = trim($tag); | |
| 541 | - endforeach; | |
| 542 | - endif; | |
| 543 | - | |
| 544 | - // Post status, comment status, ping status | |
| 545 | - foreach (array('post', 'comment', 'ping') as $what) : | |
| 546 | - $sfield = "feed_{$what}_status"; | |
| 547 | - if (isset($GLOBALS['fwp_post'][$sfield])) : | |
| 548 | - if ($GLOBALS['fwp_post'][$sfield]=='site-default') : | |
| 549 | - unset($meta["{$what} status"]); | |
| 550 | - else : | |
| 551 | - $meta["{$what} status"] = $GLOBALS['fwp_post'][$sfield]; | |
| 552 | - endif; | |
| 553 | - endif; | |
| 554 | - endforeach; | |
| 555 | - | |
| 556 | - // Unfamiliar author, unfamiliar categories | |
| 557 | - foreach (array("author", "category") as $what) : | |
| 558 | - $sfield = "unfamiliar_{$what}"; | |
| 559 | - if (isset($GLOBALS['fwp_post'][$sfield])) : | |
| 560 | - if ('site-default'==$GLOBALS['fwp_post'][$sfield]) : | |
| 561 | - unset($meta["unfamiliar {$what}"]); | |
| 562 | - elseif ('newuser'==$GLOBALS['fwp_post'][$sfield]) : | |
| 563 | - $newuser_name = trim($GLOBALS['fwp_post']["{$sfield}_newuser"]); | |
| 564 | - if (strlen($newuser_name) > 0) : | |
| 565 | - $userdata = array(); | |
| 566 | - $userdata['ID'] = NULL; | |
| 567 | - | |
| 568 | - $userdata['user_login'] = sanitize_user($newuser_name); | |
| 569 | - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']); | |
| 570 | - | |
| 571 | - $userdata['user_nicename'] = sanitize_title($newuser_name); | |
| 572 | - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']); | |
| 573 | - | |
| 574 | - $userdata['display_name'] = $wpdb->escape($newuser_name); | |
| 575 | - | |
| 576 | - $newuser_id = wp_insert_user($userdata); | |
| 577 | - if (is_numeric($newuser_id)) : | |
| 578 | - $meta["unfamiliar {$what}"] = $newuser_id; | |
| 579 | - else : | |
| 580 | - // TODO: Add some error detection and reporting | |
| 581 | - endif; | |
| 582 | - else : | |
| 583 | - // TODO: Add some error reporting | |
| 584 | - endif; | |
| 585 | - else : | |
| 586 | - $meta["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield]; | |
| 587 | - endif; | |
| 588 | - endif; | |
| 589 | - endforeach; | |
| 590 | - | |
| 591 | - // Handle author mapping rules | |
| 592 | - if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) : | |
| 593 | - unset($meta['map authors']); | |
| 594 | - foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) : | |
| 595 | - // Normalize for case and whitespace | |
| 596 | - $name = strtolower(trim($name)); | |
| 597 | - $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key])); | |
| 598 | - | |
| 599 | - if (strlen($name) > 0) : | |
| 600 | - if ('newuser' == $author_action) : | |
| 601 | - $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]); | |
| 602 | - if (strlen($newuser_name) > 0) : | |
| 603 | - $userdata = array(); | |
| 604 | - $userdata['ID'] = NULL; | |
| 605 | - | |
| 606 | - $userdata['user_login'] = sanitize_user($newuser_name); | |
| 607 | - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']); | |
| 608 | - | |
| 609 | - $userdata['user_nicename'] = sanitize_title($newuser_name); | |
| 610 | - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']); | |
| 611 | - | |
| 612 | - $userdata['display_name'] = $wpdb->escape($newuser_name); | |
| 613 | - | |
| 614 | - $newuser_id = wp_insert_user($userdata); | |
| 615 | - if (is_numeric($newuser_id)) : | |
| 616 | - $meta['map authors']['name'][$name] = $newuser_id; | |
| 617 | - else : | |
| 618 | - // TODO: Add some error detection and reporting | |
| 619 | - endif; | |
| 620 | - else : | |
| 621 | - // TODO: Add some error reporting | |
| 622 | - endif; | |
| 623 | - else : | |
| 624 | - $meta['map authors']['name'][$name] = $author_action; | |
| 625 | - endif; | |
| 626 | - endif; | |
| 627 | - endforeach; | |
| 628 | - endif; | |
| 629 | - | |
| 630 | - if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) : | |
| 631 | - $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name'])); | |
| 632 | - $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action'])); | |
| 633 | - if (strlen($name) > 0) : | |
| 634 | - if ('newuser' == $author_action) : | |
| 635 | - $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']); | |
| 636 | - if (strlen($newuser_name) > 0) : | |
| 637 | - $userdata = array(); | |
| 638 | - $userdata['ID'] = NULL; | |
| 639 | - | |
| 640 | - $userdata['user_login'] = sanitize_user($newuser_name); | |
| 641 | - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']); | |
| 642 | - | |
| 643 | - $userdata['user_nicename'] = sanitize_title($newuser_name); | |
| 644 | - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']); | |
| 645 | - | |
| 646 | - $userdata['display_name'] = $wpdb->escape($newuser_name); | |
| 647 | - | |
| 648 | - $newuser_id = wp_insert_user($userdata); | |
| 649 | - if (is_numeric($newuser_id)) : | |
| 650 | - $meta['map authors']['name'][$name] = $newuser_id; | |
| 651 | - else : | |
| 652 | - // TODO: Add some error detection and reporting | |
| 653 | - endif; | |
| 654 | - else : | |
| 655 | - // TODO: Add some error reporting | |
| 656 | - endif; | |
| 657 | - else : | |
| 658 | - $meta['map authors']['name'][$name] = $author_action; | |
| 659 | - endif; | |
| 660 | - endif; | |
| 661 | - endif; | |
| 662 | - | |
| 663 | - if (isset($GLOBALS['fwp_post']['cat_split'])) : | |
| 664 | - if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) : | |
| 665 | - $meta['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']); | |
| 666 | - else : | |
| 667 | - unset($meta['cat_split']); | |
| 668 | - endif; | |
| 669 | - endif; | |
| 670 | - | |
| 671 | - if (is_array($meta['cats'])) : | |
| 672 | - $meta['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['cats']); | |
| 673 | - endif; | |
| 674 | - if (is_array($meta['tags'])) : | |
| 675 | - $meta['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['tags']); | |
| 676 | - endif; | |
| 677 | - | |
| 678 | - // Collapse the author mapping rule structure back into a flat string | |
| 679 | - if (isset($meta['map authors'])) : | |
| 680 | - $ma = array(); | |
| 681 | - foreach ($meta['map authors'] as $rule_type => $author_rules) : | |
| 682 | - foreach ($author_rules as $author_name => $author_action) : | |
| 683 | - $ma[] = $rule_type."\n".$author_name."\n".$author_action; | |
| 684 | - endforeach; | |
| 685 | - endforeach; | |
| 686 | - $meta['map authors'] = implode("\n\n", $ma); | |
| 687 | - endif; | |
| 688 | - | |
| 689 | - $notes = ''; | |
| 690 | - foreach ($meta as $key => $value) : | |
| 691 | - $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n"; | |
| 692 | - endforeach; | |
| 693 | - $alter[] = "link_notes = '".$wpdb->escape($notes)."'"; | |
| 694 | - | |
| 695 | 698 | $alter_set = implode(", ", $alter); |
| 696 | 699 | |
| 697 | 700 | // issue update query |
| 698 | 701 | $result = $wpdb->query(" |
| @@ -702,8 +705,11 @@ | ||
| 702 | 705 | "); |
| 703 | 706 | $updated_link = true; |
| 704 | 707 | |
| 705 | 708 | // reload link information from DB |
| 709 | + if (function_exists('clean_bookmark_cache')) : | |
| 710 | + clean_bookmark_cache($link_id); | |
| 711 | + endif; | |
| 706 | 712 | $link =& new SyndicatedLink($link_id); |
| 707 | 713 | else : |
| 708 | 714 | $updated_link = false; |
| 709 | 715 | endif; |
| @@ -711,50 +717,9 @@ | ||
| 711 | 717 | $db_link = $link->link; |
| 712 | 718 | $link_url = wp_specialchars($db_link->link_url, 1); |
| 713 | 719 | $link_name = wp_specialchars($db_link->link_name, 1); |
| 714 | 720 | $link_description = wp_specialchars($db_link->link_description, 'both'); |
| 715 | - $link_notes = wp_specialchars($db_link->link_notes, 'both'); | |
| 716 | 721 | $link_rss_uri = wp_specialchars($db_link->link_rss, 'both'); |
| 717 | - | |
| 718 | - $meta = $link->settings; | |
| 719 | - $post_status_global = get_option('feedwordpress_syndicated_post_status'); | |
| 720 | - $comment_status_global = get_option('feedwordpress_syndicated_comment_status'); | |
| 721 | - $ping_status_global = get_option('feedwordpress_syndicated_ping_status'); | |
| 722 | - | |
| 723 | - $status['post'] = array('publish' => '', 'private' => '', 'draft' => '', 'site-default' => ''); | |
| 724 | - if (SyndicatedPost::use_api('post_status_pending')) : | |
| 725 | - $status['post']['pending'] = ''; | |
| 726 | - endif; | |
| 727 | - | |
| 728 | - $status['comment'] = array('open' => '', 'closed' => '', 'site-default' => ''); | |
| 729 | - $status['ping'] = array('open' => '', 'closed' => '', 'site-default' => ''); | |
| 730 | - | |
| 731 | - foreach (array('post', 'comment', 'ping') as $what) : | |
| 732 | - if (isset($meta["{$what} status"])) : | |
| 733 | - $status[$what][$meta["{$what} status"]] = ' checked="checked"'; | |
| 734 | - else : | |
| 735 | - $status[$what]['site-default'] = ' checked="checked"'; | |
| 736 | - endif; | |
| 737 | - endforeach; | |
| 738 | - | |
| 739 | - $unfamiliar['author'] = array ('create' => '','default' => '','filter' => ''); | |
| 740 | - $unfamiliar['category'] = array ('create'=>'','tag' => '','default'=>'','filter'=>''); | |
| 741 | - | |
| 742 | - foreach (array('author', 'category') as $what) : | |
| 743 | - if (is_string($meta["unfamiliar {$what}"]) and | |
| 744 | - array_key_exists($meta["unfamiliar {$what}"], $unfamiliar[$what])) : | |
| 745 | - $key = $meta["unfamiliar {$what}"]; | |
| 746 | - else: | |
| 747 | - $key = 'site-default'; | |
| 748 | - endif; | |
| 749 | - $unfamiliar[$what][$key] = ' checked="checked"'; | |
| 750 | - endforeach; | |
| 751 | - | |
| 752 | - if (is_array($meta['cats'])) : $cats = $meta['cats']; | |
| 753 | - else : $cats = array(); | |
| 754 | - endif; | |
| 755 | - | |
| 756 | - $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL); | |
| 757 | 722 | else : |
| 758 | 723 | die( __('Link not found.') ); |
| 759 | 724 | endif; |
| 760 | 725 | |
| @@ -767,25 +732,8 @@ | ||
| 767 | 732 | o = document.getElementById('basics-hardcode-'+item); |
| 768 | 733 | if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; } |
| 769 | 734 | else { ed.style.display='none'; view.style.display='inline'; } |
| 770 | 735 | } |
| 771 | - function flip_newuser (item) { | |
| 772 | - rollup=document.getElementById(item); | |
| 773 | - newuser=document.getElementById(item+'-newuser'); | |
| 774 | - sitewide=document.getElementById(item+'-default'); | |
| 775 | - if (rollup) { | |
| 776 | - if ('newuser'==rollup.value) { | |
| 777 | - if (newuser) newuser.style.display='block'; | |
| 778 | - if (sitewide) sitewide.style.display='none'; | |
| 779 | - } else if ('site-default'==rollup.value) { | |
| 780 | - if (newuser) newuser.style.display='none'; | |
| 781 | - if (sitewide) sitewide.style.display='block'; | |
| 782 | - } else { | |
| 783 | - if (newuser) newuser.style.display='none'; | |
| 784 | - if (sitewide) sitewide.style.display='none'; | |
| 785 | - } | |
| 786 | - } | |
| 787 | - } | |
| 788 | 736 | </script> |
| 789 | 737 | |
| 790 | 738 | <?php if ($updated_link) : ?> |
| 791 | 739 | <div class="updated"><p>Syndicated feed settings updated.</p></div> |
| @@ -792,13 +740,19 @@ | ||
| 792 | 740 | <?php endif; ?> |
| 793 | 741 | |
| 794 | 742 | <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 795 | 743 | <div class="wrap"> |
| 744 | +<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_linkedit'); ?> | |
| 796 | 745 | <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" /> |
| 797 | 746 | <input type="hidden" name="action" value="linkedit" /> |
| 798 | 747 | <input type="hidden" name="save" value="link" /> |
| 799 | 748 | |
| 800 | -<h2>Edit a syndicated feed:</h2> | |
| 749 | +<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 750 | + <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div> | |
| 751 | +<?php endif; ?> | |
| 752 | + | |
| 753 | +<h2><?php _e('Feed settings'); ?><?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2> | |
| 754 | + | |
| 801 | 755 | <div id="poststuff"> |
| 802 | 756 | <?php fwp_linkedit_single_submit($status); ?> |
| 803 | 757 | |
| 804 | 758 | <div id="post-body"> |
| @@ -851,10 +805,10 @@ | ||
| 851 | 805 | |
| 852 | 806 | <tr> |
| 853 | 807 | <th width="20%"><?php _e('Last update') ?>:</th> |
| 854 | 808 | <td colspan="2"><?php |
| 855 | - if (isset($meta['update/last'])) : | |
| 856 | - echo strftime('%x %X', $meta['update/last'])." "; | |
| 809 | + if (isset($link->settings['update/last'])) : | |
| 810 | + echo fwp_time_elapsed($link->settings['update/last'])." "; | |
| 857 | 811 | else : |
| 858 | 812 | echo " none yet"; |
| 859 | 813 | endif; |
| 860 | 814 | ?></td></tr> |
| @@ -859,23 +813,23 @@ | ||
| 859 | 813 | endif; |
| 860 | 814 | ?></td></tr> |
| 861 | 815 | <tr><th width="20%">Next update:</th> |
| 862 | 816 | <td colspan="2"><?php |
| 863 | - $holdem = (isset($meta['update/hold']) ? $meta['update/hold'] : 'scheduled'); | |
| 817 | + $holdem = (isset($link->settings['update/hold']) ? $link->settings['update/hold'] : 'scheduled'); | |
| 864 | 818 | ?> |
| 865 | 819 | <select name="update_schedule"> |
| 866 | 820 | <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php |
| 867 | 821 | echo " ("; |
| 868 | - if (isset($meta['update/ttl']) and is_numeric($meta['update/ttl'])) : | |
| 869 | - if (isset($meta['update/timed']) and $meta['update/timed']=='automatically') : | |
| 822 | + if (isset($link->settings['update/ttl']) and is_numeric($link->settings['update/ttl'])) : | |
| 823 | + if (isset($link->settings['update/timed']) and $link->settings['update/timed']=='automatically') : | |
| 870 | 824 | echo 'next: '; |
| 871 | - $next = $meta['update/last'] + ((int) $meta['update/ttl'] * 60); | |
| 825 | + $next = $link->settings['update/last'] + ((int) $link->settings['update/ttl'] * 60); | |
| 872 | 826 | if (strftime('%x', time()) != strftime('%x', $next)) : |
| 873 | 827 | echo strftime('%x', $next)." "; |
| 874 | 828 | endif; |
| 875 | - echo strftime('%X', $meta['update/last']+((int) $meta['update/ttl']*60)); | |
| 829 | + echo strftime('%X', $link->settings['update/last']+((int) $link->settings['update/ttl']*60)); | |
| 876 | 830 | else : |
| 877 | - echo "every ".$meta['update/ttl']." minute".(($meta['update/ttl']!=1)?"s":""); | |
| 831 | + echo "every ".$link->settings['update/ttl']." minute".(($link->settings['update/ttl']!=1)?"s":""); | |
| 878 | 832 | endif; |
| 879 | 833 | else: |
| 880 | 834 | echo "next scheduled update"; |
| 881 | 835 | endif; |
| @@ -895,176 +849,19 @@ | ||
| 895 | 849 | |
| 896 | 850 | <?php fwp_linkedit_periodic_submit(); ?> |
| 897 | 851 | |
| 898 | 852 | <?php |
| 899 | -if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) : | |
| 900 | - fwp_option_box_opener('Syndicated Posts', 'syndicatedpostsdiv', 'postbox'); | |
| 901 | -?> | |
| 902 | -<table class="editform" width="75%" cellspacing="2" cellpadding="5"> | |
| 903 | -<tr><th width="27%" scope="row" style="vertical-align:top">Publication:</th> | |
| 904 | -<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none"> | |
| 905 | -<li><label><input type="radio" name="feed_post_status" value="site-default" | |
| 906 | -<?php echo $status['post']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a> | |
| 907 | -(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li> | |
| 908 | -<li><label><input type="radio" name="feed_post_status" value="publish" | |
| 909 | -<?php echo $status['post']['publish']; ?> /> Publish posts from this feed immediately</label></li> | |
| 853 | + FeedWordPressSettingsUI::instead_of_posts_box($link_id); | |
| 854 | + FeedWordPressSettingsUI::instead_of_authors_box($link_id); | |
| 855 | + FeedWordPressSettingsUI::instead_of_categories_box($link_id); | |
| 910 | 856 | |
| 911 | -<?php if (SyndicatedPost::use_api('post_status_pending')) : ?> | |
| 912 | -<li><label><input type="radio" name="feed_post_status" value="pending" | |
| 913 | -<?php echo $status['post']['pending']; ?>/> Hold posts from this feed for review; mark as Pending</label></li> | |
| 914 | -<?php endif; ?> | |
| 915 | - | |
| 916 | -<li><label><input type="radio" name="feed_post_status" value="draft" | |
| 917 | -<?php echo $status['post']['draft']; ?> /> Save posts from this feed as drafts</label></li> | |
| 918 | -<li><label><input type="radio" name="feed_post_status" value="private" | |
| 919 | -<?php echo $status['post']['private']; ?> /> Save posts from this feed as private posts</label></li> | |
| 920 | -</ul></td> | |
| 921 | -</tr> | |
| 922 | -</table> | |
| 923 | -<?php | |
| 924 | - fwp_option_box_closer(); | |
| 925 | - fwp_linkedit_periodic_submit(); | |
| 926 | -endif; | |
| 927 | - | |
| 928 | - fwp_option_box_opener(__('Categories'), 'categorydiv', 'postbox'); | |
| 929 | - fwp_category_box($dogs, 'all syndicated posts from this feed'); | |
| 857 | + fwp_option_box_opener('Custom Feed Settings (for use in templates)', 'postcustom', 'postbox'); | |
| 930 | 858 | ?> |
| 931 | -<table> | |
| 932 | -<tr> | |
| 933 | -<th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th> | |
| 934 | -<td width="80%"><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p> | |
| 859 | +<p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are | |
| 860 | +syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create | |
| 861 | +custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each | |
| 862 | +individual post from this feed, set up the settings in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php print $link_id; ?>">Syndicated Posts</a>.</p> | |
| 935 | 863 | |
| 936 | -<ul style="margin: 0; list-style:none"> | |
| 937 | -<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use the site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a> | |
| 938 | -(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li> | |
| 939 | -<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create a new category</label></li> | |
| 940 | -<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar['category']['tag']; ?>/> create a new tag</label></li> | |
| 941 | -<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories or tags</label></li> | |
| 942 | -<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['category']['filter']; ?> /> don't create new categories or tags and don't syndicate posts unless they match at least one familiar category</label></li> | |
| 943 | -</ul></td> | |
| 944 | -</tr> | |
| 945 | - | |
| 946 | -<tr> | |
| 947 | -<th width="20%" scope="row" style="vertical-align:top">Multiple categories:</th> | |
| 948 | -<td width="80%"> | |
| 949 | -<input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($meta['cat_split'])) : echo htmlspecialchars($meta['cat_split']); endif; ?>" /><br/> | |
| 950 | -Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> here if the feed provides multiple | |
| 951 | -categories in a single category element. The regular expression should match | |
| 952 | -the characters used to separate one category from the next. If the feed uses | |
| 953 | -spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s". | |
| 954 | -If the feed does not provide multiple categories in a single element, leave this | |
| 955 | -blank.</td> | |
| 956 | -</tr> | |
| 957 | -</table> | |
| 958 | -<?php | |
| 959 | - fwp_option_box_closer(); | |
| 960 | - fwp_linkedit_periodic_submit(); | |
| 961 | - | |
| 962 | -if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) : | |
| 963 | - fwp_tags_box($meta['tags']); | |
| 964 | - fwp_linkedit_periodic_submit(); | |
| 965 | -endif; ?> | |
| 966 | - | |
| 967 | -<?php fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox'); ?> | |
| 968 | -<?php $authorlist = fwp_author_list(); ?> | |
| 969 | -<table> | |
| 970 | -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr> | |
| 971 | -<tr> | |
| 972 | - <th style="text-align: left">Posts by new authors</th> | |
| 973 | - <td> | |
| 974 | - <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');"> | |
| 975 | - <option value="site-default"<?php if (!isset($meta['unfamiliar author'])) : ?>selected="selected"<?php endif; ?>>are handled using site-wide settings</option> | |
| 976 | - <option value="create"<?php if ('create'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>create a new author account</option> | |
| 977 | - <?php foreach ($authorlist as $author_id => $author_name) : ?> | |
| 978 | - <option value="<?php echo $author_id; ?>"<?php if ($author_id==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option> | |
| 979 | - <?php endforeach; ?> | |
| 980 | - <option value="newuser">will be assigned to a new user...</option> | |
| 981 | - <option value="filter"<?php if ('filter'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>get filtered out</option> | |
| 982 | - </select> | |
| 983 | - </td> | |
| 984 | - <td> | |
| 985 | - <div id="unfamiliar-author-default">Site-wide settings can be set in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a></div> | |
| 986 | - <div id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></div> | |
| 987 | - </td> | |
| 988 | -</tr> | |
| 989 | - | |
| 990 | -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by specific authors. Blank out a name to delete the rule.</th></tr> | |
| 991 | - | |
| 992 | -<?php if (isset($meta['map authors'])) : $i=0; foreach ($meta['map authors'] as $author_rules) : foreach ($author_rules as $author_name => $author_action) : $i++; ?> | |
| 993 | -<tr> | |
| 994 | - <th style="text-align: left">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" /></th> | |
| 995 | - <td> | |
| 996 | - <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="flip_newuser('author-rules-<?php echo $i; ?>');"> | |
| 997 | - <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?> | |
| 998 | - <option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option> | |
| 999 | - <?php endforeach; ?> | |
| 1000 | - <option value="newuser">will be assigned to a new user...</option> | |
| 1001 | - <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option> | |
| 1002 | - </select> | |
| 1003 | - </td> | |
| 1004 | - <td><div id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></div></td> | |
| 1005 | -</tr> | |
| 1006 | -<?php endforeach; endforeach; endif; ?> | |
| 1007 | - | |
| 1008 | -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">Fill in to set up a new rule:</th></tr> | |
| 1009 | - | |
| 1010 | -<tr> | |
| 1011 | - <th style="text-align: left">Posts by <input type="text" name="add_author_rule_name" /></th> | |
| 1012 | - <td> | |
| 1013 | - <select id="add-author-rule" name="add_author_rule_action" onchange="flip_newuser('add-author-rule');"> | |
| 1014 | - <?php foreach ($authorlist as $author_id => $author_name) : ?> | |
| 1015 | - <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option> | |
| 1016 | - <?php endforeach; ?> | |
| 1017 | - <option value="newuser">will be assigned to a new user...</option> | |
| 1018 | - <option value="filter">get filtered out</option> | |
| 1019 | - </select> | |
| 1020 | - </td> | |
| 1021 | - <td><div id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></div></td> | |
| 1022 | -</tr> | |
| 1023 | - | |
| 1024 | -</table> | |
| 1025 | -<?php fwp_option_box_closer(); ?> | |
| 1026 | - | |
| 1027 | -<script> | |
| 1028 | - flip_newuser('unfamiliar-author'); | |
| 1029 | -<?php for ($j=1; $j<=$i; $j++) : ?> | |
| 1030 | - flip_newuser('author-rules-<?php echo $j; ?>'); | |
| 1031 | -<?php endfor; ?> | |
| 1032 | - flip_newuser('add-author-rule'); | |
| 1033 | -</script> | |
| 1034 | - | |
| 1035 | -<?php | |
| 1036 | - fwp_linkedit_periodic_submit(); | |
| 1037 | - fwp_option_box_opener('Comments & Pings', 'commentstatusdiv', 'postbox'); | |
| 1038 | -?> | |
| 1039 | -<table class="editform" width="75%" cellspacing="2" cellpadding="5"> | |
| 1040 | -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Comments'); ?>:</th> | |
| 1041 | -<td width="73%"><ul style="margin:0; list-style:none"> | |
| 1042 | -<li><label><input type="radio" name="feed_comment_status" value="site-default" | |
| 1043 | -<?php echo $status['comment']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a> | |
| 1044 | -(currently: <strong><?php echo ($comment_status_global ? $comment_status_global : 'closed'); ?>)</strong></label></li> | |
| 1045 | -<li><label><input type="radio" name="feed_comment_status" value="open" | |
| 1046 | -<?php echo $status['comment']['open']; ?> /> Allow comments on syndicated posts from this feed</label></li> | |
| 1047 | -<li><label><input type="radio" name="feed_comment_status" value="closed" | |
| 1048 | -<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts from this feed</label></li> | |
| 1049 | -</ul></td></tr> | |
| 1050 | - | |
| 1051 | -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Pings'); ?>:</th> | |
| 1052 | -<td width="73%"><ul style="margin:0; list-style:none"> | |
| 1053 | -<li><label><input type="radio" name="feed_ping_status" value="site-default" | |
| 1054 | -<?php echo $status['ping']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a> | |
| 1055 | -(currently: <strong><?php echo ($ping_status_global ? $ping_status_global : 'closed'); ?>)</strong></label></li> | |
| 1056 | -<li><label><input type="radio" name="feed_ping_status" value="open" | |
| 1057 | -<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts from this feed</label></li> | |
| 1058 | -<li><label><input type="radio" name="feed_ping_status" value="closed" | |
| 1059 | -<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts from this feed</label></li> | |
| 1060 | -</ul></td></tr> | |
| 1061 | - | |
| 1062 | -</table> | |
| 1063 | -<?php fwp_option_box_closer(); ?> | |
| 1064 | -<?php fwp_linkedit_periodic_submit(); ?> | |
| 1065 | - | |
| 1066 | -<?php fwp_option_box_opener('Custom Settings (for use in templates)', 'postcustom', 'postbox'); ?> | |
| 1067 | 864 | <div id="postcustomstuff"> |
| 1068 | 865 | <table id="meta-list" cellpadding="3"> |
| 1069 | 866 | <tr> |
| 1070 | 867 | <th>Key</th> |
| @@ -1073,9 +870,9 @@ | ||
| 1073 | 870 | </tr> |
| 1074 | 871 | |
| 1075 | 872 | <?php |
| 1076 | 873 | $i = 0; |
| 1077 | - foreach ($meta as $key => $value) : | |
| 874 | + foreach ($link->settings as $key => $value) : | |
| 1078 | 875 | if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) : |
| 1079 | 876 | ?> |
| 1080 | 877 | <tr style="vertical-align:top"> |
| 1081 | 878 | <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" /> |
| @@ -1099,8 +896,9 @@ | ||
| 1099 | 896 | </table> |
| 1100 | 897 | <?php fwp_option_box_closer(); ?> |
| 1101 | 898 | |
| 1102 | 899 | <?php fwp_linkedit_periodic_submit(); ?> |
| 900 | +<?php fwp_linkedit_single_submit_closer(); ?> | |
| 1103 | 901 | </div> <!-- id="post-body" --> |
| 1104 | 902 | </div> <!-- id="poststuff" --> |
| 1105 | 903 | </div> |
| 1106 | 904 | <?php |
| @@ -1110,16 +908,15 @@ | ||
| 1110 | 908 | |
| 1111 | 909 | function fwp_multidelete_page () { |
| 1112 | 910 | global $wpdb; |
| 1113 | 911 | |
| 1114 | - check_admin_referer(); // Make sure the referers are kosher | |
| 912 | + // If this is a POST, validate source and user credentials | |
| 913 | + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); | |
| 1115 | 914 | |
| 1116 | 915 | $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array()); |
| 1117 | 916 | if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif; |
| 1118 | 917 | |
| 1119 | - if (!current_user_can('manage_links')): | |
| 1120 | - die (__("Cheatin' uh ?")); | |
| 1121 | - elseif (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'): | |
| 918 | + if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'): | |
| 1122 | 919 | foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) : |
| 1123 | 920 | $do_it[$what][] = $link_id; |
| 1124 | 921 | endforeach; |
| 1125 | 922 | |
| @@ -1200,8 +997,9 @@ | ||
| 1200 | 997 | "); |
| 1201 | 998 | ?> |
| 1202 | 999 | <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 1203 | 1000 | <div class="wrap"> |
| 1001 | +<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> | |
| 1204 | 1002 | <input type="hidden" name="action" value="Unsubscribe" /> |
| 1205 | 1003 | <input type="hidden" name="confirm" value="Delete" /> |
| 1206 | 1004 | |
| 1207 | 1005 | <h2>Unsubscribe from Syndicated Links:</h2> |