PluginProbe
FeedWordPress / 0.991
FeedWordPress v0.991
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | feedwordpress.php +319 -834 0.9930.991 View file →
@@ -2,13 +2,13 @@
2 2 /*
3 3 Plugin Name: FeedWordPress
4 4 Plugin URI: http://projects.radgeek.com/feedwordpress
5 5 Description: simple and flexible Atom/RSS syndication for WordPress
6 -Version: 0.993
6 +Version: 0.991
7 7 Author: Charles Johnson
8 8 Author URI: http://radgeek.com/
9 9 License: GPL
10 -Last modified: 2008-05-08 4:48 PM PDT
10 +Last modified: 2007-09-25 12:48 PDT
11 11 */
12 12
13 13 # This uses code derived from:
14 14 # - wp-rss-aggregate.php by Kellan Elliot-McCrea <kellan@protest.net>
@@ -26,9 +26,9 @@
26 26 # <http://www.zyx.com/blog/xmlrpc.php>), or see `update-feeds.php`
27 27
28 28 # -- Don't change these unless you know what you're doing...
29 29
30 -define ('FEEDWORDPRESS_VERSION', '0.993');
30 +define ('FEEDWORDPRESS_VERSION', '0.991');
31 31 define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
32 32 define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
33 33
34 34 define ('FEEDWORDPRESS_DEBUG', false);
@@ -42,9 +42,8 @@
42 42
43 43 define ('FWP_SCHEMA_20', 3308); // Database schema # for WP 2.0
44 44 define ('FWP_SCHEMA_21', 4772); // Database schema # for WP 2.1
45 45 define ('FWP_SCHEMA_23', 5495); // Database schema # for WP 2.3
46 -define ('FWP_SCHEMA_25', 7558); // Database schema # for WP 2.5
47 46
48 47 if (FEEDWORDPRESS_DEBUG) :
49 48 // Help us to pick out errors, if any.
50 49 ini_set('error_reporting', E_ALL & ~E_NOTICE);
@@ -83,14 +82,9 @@
83 82 endif;
84 83 endif;
85 84
86 85 if (function_exists('wp_enqueue_script')) :
87 - if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
88 - wp_enqueue_script('post');
89 - wp_enqueue_script('thickbox');
90 - else :
91 - wp_enqueue_script( 'ajaxcat' ); // Provides the handy-dandy new category text box
92 - endif;
86 + wp_enqueue_script( 'ajaxcat' ); // Provides the handy-dandy new category text box
93 87 endif;
94 88
95 89 // Magic quotes are just about the stupidest thing ever.
96 90 if (is_array($_POST)) :
@@ -96,21 +90,9 @@
96 90 if (is_array($_POST)) :
97 91 $fwp_post = stripslashes_deep($_POST);
98 92 endif;
99 93
100 -// Get the path relative to the plugins directory in which FWP is stored
101 -preg_match (
102 - '|/wp-content/plugins/(.+)$|',
103 - dirname(__FILE__),
104 - $ref
105 -);
106 94
107 -if (isset($ref[1])) :
108 - $fwp_path = $ref[1];
109 -else : // Something went wrong. Let's just guess.
110 - $fwp_path = 'feedwordpress';
111 -endif;
112 -
113 95 if (!FeedWordPress::needs_upgrade()) : // only work if the conditions are safe!
114 96
115 97 # Syndicated items are generally received in output-ready (X)HTML and
116 98 # should not be folded, crumpled, mutilated, or spindled by WordPress
@@ -129,15 +111,8 @@
129 111 add_filter('the_content', 'feedwordpress_restore_syndicated_content', 10000);
130 112
131 113 # Filter in original permalinks if the user wants that
132 114 add_filter('post_link', 'syndication_permalink', 1);
133 -
134 - # WTF? By default, wp_insert_link runs incoming link_url and link_rss
135 - # URIs through default filters that include `wp_kses()`. But `wp_kses()`
136 - # just happens to escape any occurrence of & to &amp; -- which just
137 - # happens to fuck up any URI with a & to separate GET parameters.
138 - remove_filter('pre_link_rss', 'wp_filter_kses');
139 - remove_filter('pre_link_url', 'wp_filter_kses');
140 115
141 116 # Admin menu
142 117 add_action('admin_menu', 'fwp_add_pages');
143 118
@@ -165,12 +140,8 @@
165 140 endif;
166 141
167 142 # Cron-less auto-update. Hooray!
168 143 add_action('init', 'feedwordpress_auto_update');
169 -
170 - # Default sanitizers
171 - add_filter('syndicated_item_content', array('SyndicatedPost', 'sanitize_content'), 0, 2);
172 -
173 144 else :
174 145 # Hook in the menus, which will just point to the upgrade interface
175 146 add_action('admin_menu', 'fwp_add_pages');
176 147 endif; // if (!FeedWordPress::needs_upgrade())
@@ -259,51 +230,9 @@
259 230 function sanitize_user ($text, $strict) {
260 231 return $text; // Don't munge it if it wasn't munged going in...
261 232 }
262 233 }
263 -if (!function_exists('wp_insert_user')) {
264 - function wp_insert_user ($userdata) {
265 - #-- Help WordPress 1.5.x quack like a duck
266 - $login = $userdata['user_login'];
267 - $author = $userdata['display_name'];
268 - $nice_author = $userdata['user_nicename'];
269 - $email = $userdata['user_email'];
270 - $url = $userdata['user_url'];
271 234
272 - $wpdb->query (
273 - "INSERT INTO $wpdb->users
274 - SET
275 - ID='0',
276 - user_login='$login',
277 - user_firstname='$author',
278 - user_nickname='$author',
279 - user_nicename='$nice_author',
280 - user_description='$author',
281 - user_email='$email',
282 - user_url='$url'");
283 - $id = $wpdb->insert_id;
284 -
285 - return $id;
286 - }
287 -}
288 -
289 -function fwp_category_checklist ($post_id = 0, $descendents_and_self = 0, $selected_cats = false) {
290 - if (function_exists('wp_category_checklist')) :
291 - wp_category_checklist($post_id, $descendents_and_self, $selected_cats);
292 - else :
293 - global $checked_categories;
294 -
295 - // selected_cats is an array of integer cat_IDs / term_ids for
296 - // the categories that should be checked
297 - $cats = array();
298 - if ($post_id) : $cats = wp_get_post_categories($post_id);
299 - else : $cats = $selected_cats;
300 - endif;
301 -
302 - $checked_categories = $cats;
303 - dropdown_categories();
304 - endif;
305 -}
306 235 ################################################################################
307 236 ## TEMPLATE API: functions to make your templates syndication-aware ############
308 237 ################################################################################
309 238
@@ -438,9 +367,8 @@
438 367 ################################################################################
439 368
440 369 function fwp_add_pages () {
441 370 global $legacy_capability_hack;
442 - global $fwp_path;
443 371
444 372 if ($legacy_capability_hack) :
445 373 // old & busted: numeric user levels
446 374 $manage_links = 5;
@@ -451,131 +379,20 @@
451 379 $manage_options = 'manage_options';
452 380 endif;
453 381
454 382 //add_submenu_page('plugins.php', 'Akismet Configuration', 'Akismet Configuration', 'manage_options', 'syndication-manage-page', 'fwp_syndication_manage_page');
455 - add_menu_page('Syndicated Sites', 'Syndication', $manage_links, $fwp_path.'/'.basename(__FILE__), 'fwp_syndication_manage_page');
456 - add_submenu_page($fwp_path.'/'.basename(__FILE__), 'Syndication Options', 'Options', $manage_options, $fwp_path.'/syndication-options.php');
457 - add_options_page('Syndication Options', 'Syndication', $manage_options, $fwp_path.'/syndication-options.php');
383 + add_menu_page('Syndicated Sites', 'Syndication', $manage_links, 'feedwordpress/'.basename(__FILE__), 'fwp_syndication_manage_page');
384 + add_submenu_page('feedwordpress/'.basename(__FILE__), 'Syndication Options', 'Options', $manage_options, 'feedwordpress/syndication-options.php');
385 + add_options_page('Syndication Options', 'Syndication', $manage_options, 'feedwordpress/syndication-options.php');
458 386 } // function fwp_add_pages () */
459 387
460 -function fwp_linkedit_single_submit ($status = NULL) {
388 +function fwp_category_box ($checked, $object) {
461 389 global $wp_db_version;
462 - if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
463 -?>
464 -<div class="submitbox" id="submitlink">
465 -<div id="previewview"></div>
466 -<div class="inside">
467 -<?php if (!is_null($status)) : ?>
468 - <p><strong>Publication</strong></p>
469 - <p>When a new post is syndicated from this feed...</p>
470 - <select name="feed_post_status">
471 - <option value="site-default" <?php echo $status['post']['site-default']; ?>> Use
472 - Syndication Options setting</option>
473 - <option value="publish" <?php echo $status['post']['publish']; ?>>Publish it immediately</option>
474 -
475 - <?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
476 - <option value="pending" <?php echo $status['post']['pending']; ?>>Hold it Pending Review</option>
477 - <?php endif; ?>
478 -
479 - <option value="draft" <?php echo $status['post']['draft']; ?>>Save it as a draft</option>
480 - <option value="private" <?php echo $status['post']['private']; ?>>Keep it private</option>
481 - </select>
482 -<?php endif; ?>
483 -</div>
484 390
485 -<p class="submit">
486 -<input type="submit" name="submit" value="<?php _e('Save') ?>" />
487 -</p>
488 -</div>
489 -<?php
490 - endif;
491 -}
492 -
493 -function fwp_linkedit_periodic_submit ($caption = NULL) {
494 - global $wp_db_version;
495 - if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) :
496 - if (is_null($caption)) : $caption = __('Save Changes &raquo;'); endif;
391 + if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_20) : // WordPress 2.x
497 392 ?>
498 -<p class="submit">
499 -<input type="submit" name="submit" value="<?php print $caption; ?>" />
500 -</p>
501 -<?php
502 - endif;
503 -}
504 -
505 -function fwp_option_box_opener ($legend, $id, $class = "stuffbox") {
506 - global $wp_db_version;
507 - if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
508 -?>
509 -<div id="<?php print $id; ?>" class="<?php print $class; ?>">
510 -<h3><?php print htmlspecialchars($legend); ?></h3>
511 -<div class="inside">
512 -<?php
513 - else :
514 -?>
515 -<fieldset class="options"><legend><?php print htmlspecialchars($legend); ?></legend>
516 -<?php
517 - endif;
518 -}
519 -
520 -function fwp_option_box_closer () {
521 - global $wp_db_version;
522 - if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
523 -?>
524 - </div> <!-- class="inside" -->
525 - </div> <!-- class="stuffbox" -->
526 -<?php
527 - else :
528 -?>
529 -</fieldset>
530 -<?php
531 - endif;
532 -}
533 -
534 -function fwp_tags_box ($tags) {
535 - if (!is_array($tags)) : $tags = array(); endif;
536 -?>
537 -<div id="tagsdiv" class="postbox">
538 - <h3><?php _e('Tags') ?></h3>
539 - <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p>
540 - <div class="inside">
541 - <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>
542 - <div id="tagchecklist"></div>
543 - </div>
544 -</div>
545 -<?php
546 -}
547 -
548 -function fwp_category_box ($checked, $object, $tags = array()) {
549 - global $wp_db_version;
550 -
551 - if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) : // WordPress 2.5.x
552 -?>
553 -<div id="category-adder" class="wp-hidden-children">
554 - <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
555 - <p id="category-add" class="wp-hidden-child">
556 - <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" />
557 - <?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
558 - <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
559 - <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
560 - <span id="category-ajax-response"></span>
561 - </p>
562 -</div>
563 -
564 -<ul id="category-tabs">
565 - <li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All posts' ); ?></a>
566 - <p style="font-size:smaller;font-style:bold;margin:0">Give <?php print $object; ?> these categories</p>
567 -</li>
568 -</ul>
569 -
570 -<div id="categories-all" class="ui-tabs-panel">
571 - <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
572 - <?php fwp_category_checklist(NULL, false, $checked) ?>
573 - </ul>
574 -</div>
575 -<?php
576 - elseif (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_20) : // WordPress 2.x
577 -?>
393 + <div id="poststuff">
394 +
578 395 <div id="moremeta">
579 396 <div id="grabit" class="dbx-group">
580 397 <fieldset id="categorydiv" class="dbx-box">
581 398 <h3 class="dbx-handle"><?php _e('Categories') ?></h3>
@@ -581,12 +398,13 @@
581 398 <h3 class="dbx-handle"><?php _e('Categories') ?></h3>
582 399 <div class="dbx-content">
583 400 <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p>
584 401 <p id="jaxcat"></p>
585 - <ul id="categorychecklist"><?php fwp_category_checklist(NULL, false, $checked); ?></ul></div>
402 + <ul id="categorychecklist"><?php write_nested_categories($checked); ?></ul></div>
586 403 </fieldset>
587 404 </div>
588 405 </div>
406 + </div>
589 407 <?php
590 408 else : // WordPress 1.5
591 409 ?>
592 410 <fieldset id="categorydiv" style="width: 20%; margin-right: 2em">
@@ -591,9 +409,9 @@
591 409 ?>
592 410 <fieldset id="categorydiv" style="width: 20%; margin-right: 2em">
593 411 <legend><?php _e('Categories') ?></legend>
594 412 <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p>
595 - <div style="height: 20em"><?php fwp_category_checklist(NULL, false, $checked); ?></div>
413 + <div style="height: 20em"><?php write_nested_categories($checked); ?></div>
596 414 </fieldset>
597 415 <?php
598 416 endif;
599 417 }
@@ -692,9 +510,9 @@
692 510 <?php if (!get_option('feedwordpress_automatic_updates')) : ?>
693 511 <p><strong>Note:</strong> Automatic updates are currently turned
694 512 <strong>off</strong>. New posts from your feeds will not be syndicated
695 513 until you manually check for them here. You can turn on automatic
696 - updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication
514 + updates under <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication
697 515 Options</a>.</p>
698 516 <?php endif; ?>
699 517
700 518
@@ -701,9 +519,9 @@
701 519 <div class="submit"><input type="hidden" name="update_uri" value="*" /><input type="submit" name="update" value="Update" /></div>
702 520 </form>
703 521 </div> <!-- class="wrap" -->
704 522
705 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
523 + <form action="admin.php?page=feedwordpress/<?php echo basename(__FILE__); ?>" method="post">
706 524 <div class="wrap">
707 525 <h2>Syndicated Sites</h2>
708 526 <?php $alt_row = true;
709 527 if ($links): ?>
@@ -732,9 +550,9 @@
732 550 .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
733 551 if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
734 552 ?>
735 553 <td>
736 - <strong><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td>
554 + <strong><a href="<?php echo $link->link_rss; ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td>
737 555 <?php
738 556 else:
739 557 $caption='Find Feed';
740 558 ?>
@@ -742,11 +560,11 @@
742 560 feed assigned</strong></p></td>
743 561 <?php
744 562 endif;
745 563 ?>
746 - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=linkedit" class="edit"><?php _e('Edit')?></a></td>
747 - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=feedfinder" class="edit"><?php echo $caption; ?></a></td>
748 - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=Unsubscribe" class="delete"><?php _e('Unsubscribe'); ?></a></td>
564 + <td><a href="admin.php?page=feedwordpress/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=linkedit" class="edit"><?php _e('Edit')?></a></td>
565 + <td><a href="admin.php?page=feedwordpress/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=feedfinder" class="edit"><?php echo $caption; ?></a></td>
566 + <td><a href="admin.php?page=feedwordpress/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=Unsubscribe" class="delete"><?php _e('Unsubscribe'); ?></a></td>
749 567 <td><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></td>
750 568 <?php
751 569 echo "\n\t</tr>";
752 570 endforeach;
@@ -764,9 +582,9 @@
764 582 </div> <!-- class="wrap" -->
765 583 </form>
766 584
767 585 <div class="wrap">
768 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
586 + <form action="admin.php?page=feedwordpress/<?php echo basename(__FILE__); ?>" method="post">
769 587 <h2>Add a new syndicated site:</h2>
770 588 <div>
771 589 <label for="add-uri">Website or newsfeed:</label>
772 590 <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
@@ -811,9 +629,9 @@
811 629 if ($rss):
812 630 $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
813 631 $feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
814 632 ?>
815 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
633 + <form action="admin.php?page=feedwordpress/<?php echo basename(__FILE__); ?>" method="post">
816 634 <fieldset style="clear: both">
817 635 <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
818 636
819 637 <?php if ($link_id===0): ?>
@@ -846,9 +664,9 @@
846 664 <div>
847 665 <h3>Feed Information</h3>
848 666 <ul>
849 667 <li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
850 - <li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> (<a title="Check feed &lt;<?php echo wp_specialchars($f, 'both'); ?>&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li>
668 + <li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> <a title="Check feed &lt;<?php echo wp_specialchars($f, 'both'); ?>&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>"><img src="../wp-images/smilies/icon_arrow.gif" alt="(&rarr;)" /></a></li>
851 669 <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
852 670 <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
853 671 </ul>
854 672 <div class="submit"><input type="submit" name="Use" value="&laquo; Use this feed" /></div>
@@ -864,9 +682,9 @@
864 682 endif;
865 683 ?>
866 684 </div>
867 685
868 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
686 + <form action="admin.php?page=feedwordpress/<?php echo basename(__FILE__); ?>" method="post">
869 687 <div class="wrap">
870 688 <h2>Use another feed</h2>
871 689 <div><label>Feed:</label>
872 690 <input type="text" name="lookup" value="URI" />
@@ -919,9 +737,9 @@
919 737 return true; // Continue
920 738 }
921 739
922 740 function fwp_linkedit_page () {
923 - global $wpdb, $wp_db_version;
741 + global $wpdb;
924 742
925 743 check_admin_referer(); // Make sure we arrived here from the Dashboard
926 744
927 745 $special_settings = array ( /* Regular expression syntax is OK here */
@@ -934,12 +752,9 @@
934 752 'post status',
935 753 'comment status',
936 754 'ping status',
937 755 'unfamiliar author',
938 - 'unfamliar categories', /* Deprecated */
939 - 'unfamiliar category',
940 - 'map authors',
941 - 'tags',
756 + 'unfamliar categories',
942 757 'update/.*',
943 758 'feed/.*',
944 759 'link/.*',
945 760 );
@@ -956,11 +771,11 @@
956 771 if (isset($GLOBALS['fwp_post']['save'])) :
957 772 $alter = array ();
958 773
959 774 $meta = $link->settings;
960 - //if (isset($meta['cats'])):
961 - // $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']);
962 - //endif;
775 + if (isset($meta['cats'])):
776 + $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']);
777 + endif;
963 778
964 779 // custom feed settings first
965 780 foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
966 781 $mn['key0'] = trim($mn['key0']);
@@ -1016,16 +831,8 @@
1016 831 else :
1017 832 unset($meta['cats']);
1018 833 endif;
1019 834
1020 - // Tags
1021 - if (isset($GLOBALS['fwp_post']['tags_input'])) :
1022 - $meta['tags'] = array();
1023 - foreach (explode(',', $GLOBALS['fwp_post']['tags_input']) as $tag) :
1024 - $meta['tags'][] = trim($tag);
1025 - endforeach;
1026 - endif;
1027 -
1028 835 // Post status, comment status, ping status
1029 836 foreach (array('post', 'comment', 'ping') as $what) :
1030 837 $sfield = "feed_{$what}_status";
1031 838 if (isset($GLOBALS['fwp_post'][$sfield])) :
@@ -1040,33 +847,10 @@
1040 847 // Unfamiliar author, unfamiliar categories
1041 848 foreach (array("author", "category") as $what) :
1042 849 $sfield = "unfamiliar_{$what}";
1043 850 if (isset($GLOBALS['fwp_post'][$sfield])) :
1044 - if ('site-default'==$GLOBALS['fwp_post'][$sfield]) :
851 + if ($GLOBALS['fwp_post'][$sfield]=='site-default') :
1045 852 unset($meta["unfamiliar {$what}"]);
1046 - elseif ('newuser'==$GLOBALS['fwp_post'][$sfield]) :
1047 - $newuser_name = trim($GLOBALS['fwp_post']["{$sfield}_newuser"]);
1048 - if (strlen($newuser_name) > 0) :
1049 - $userdata = array();
1050 - $userdata['ID'] = NULL;
1051 -
1052 - $userdata['user_login'] = sanitize_user($newuser_name);
1053 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
1054 -
1055 - $userdata['user_nicename'] = sanitize_title($newuser_name);
1056 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
1057 -
1058 - $userdata['display_name'] = $wpdb->escape($newuser_name);
1059 -
1060 - $newuser_id = wp_insert_user($userdata);
1061 - if (is_numeric($newuser_id)) :
1062 - $meta["unfamiliar {$what}"] = $newuser_id;
1063 - else :
1064 - // TODO: Add some error detection and reporting
1065 - endif;
1066 - else :
1067 - // TODO: Add some error reporting
1068 - endif;
1069 853 else :
1070 854 $meta["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield];
1071 855 endif;
1072 856 endif;
@@ -1071,80 +855,8 @@
1071 855 endif;
1072 856 endif;
1073 857 endforeach;
1074 858
1075 - // Handle author mapping rules
1076 - if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) :
1077 - unset($meta['map authors']);
1078 - foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) :
1079 - // Normalize for case and whitespace
1080 - $name = strtolower(trim($name));
1081 - $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
1082 -
1083 - if (strlen($name) > 0) :
1084 - if ('newuser' == $author_action) :
1085 - $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]);
1086 - if (strlen($newuser_name) > 0) :
1087 - $userdata = array();
1088 - $userdata['ID'] = NULL;
1089 -
1090 - $userdata['user_login'] = sanitize_user($newuser_name);
1091 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
1092 -
1093 - $userdata['user_nicename'] = sanitize_title($newuser_name);
1094 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
1095 -
1096 - $userdata['display_name'] = $wpdb->escape($newuser_name);
1097 -
1098 - $newuser_id = wp_insert_user($userdata);
1099 - if (is_numeric($newuser_id)) :
1100 - $meta['map authors']['name'][$name] = $newuser_id;
1101 - else :
1102 - // TODO: Add some error detection and reporting
1103 - endif;
1104 - else :
1105 - // TODO: Add some error reporting
1106 - endif;
1107 - else :
1108 - $meta['map authors']['name'][$name] = $author_action;
1109 - endif;
1110 - endif;
1111 - endforeach;
1112 - endif;
1113 -
1114 - if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) :
1115 - $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
1116 - $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
1117 - if (strlen($name) > 0) :
1118 - if ('newuser' == $author_action) :
1119 - $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']);
1120 - if (strlen($newuser_name) > 0) :
1121 - $userdata = array();
1122 - $userdata['ID'] = NULL;
1123 -
1124 - $userdata['user_login'] = sanitize_user($newuser_name);
1125 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
1126 -
1127 - $userdata['user_nicename'] = sanitize_title($newuser_name);
1128 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
1129 -
1130 - $userdata['display_name'] = $wpdb->escape($newuser_name);
1131 -
1132 - $newuser_id = wp_insert_user($userdata);
1133 - if (is_numeric($newuser_id)) :
1134 - $meta['map authors']['name'][$name] = $newuser_id;
1135 - else :
1136 - // TODO: Add some error detection and reporting
1137 - endif;
1138 - else :
1139 - // TODO: Add some error reporting
1140 - endif;
1141 - else :
1142 - $meta['map authors']['name'][$name] = $author_action;
1143 - endif;
1144 - endif;
1145 - endif;
1146 -
1147 859 if (isset($GLOBALS['fwp_post']['cat_split'])) :
1148 860 if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) :
1149 861 $meta['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
1150 862 else :
@@ -1154,23 +866,9 @@
1154 866
1155 867 if (is_array($meta['cats'])) :
1156 868 $meta['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['cats']);
1157 869 endif;
1158 - if (is_array($meta['tags'])) :
1159 - $meta['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['tags']);
1160 - endif;
1161 -
1162 - // Collapse the author mapping rule structure back into a flat string
1163 - if (isset($meta['map authors'])) :
1164 - $ma = array();
1165 - foreach ($meta['map authors'] as $rule_type => $author_rules) :
1166 - foreach ($author_rules as $author_name => $author_action) :
1167 - $ma[] = $rule_type."\n".$author_name."\n".$author_action;
1168 - endforeach;
1169 - endforeach;
1170 - $meta['map authors'] = implode("\n\n", $ma);
1171 - endif;
1172 -
870 +
1173 871 $notes = '';
1174 872 foreach ($meta as $key => $value) :
1175 873 $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n";
1176 874 endforeach;
@@ -1204,12 +902,8 @@
1204 902 $comment_status_global = get_option('feedwordpress_syndicated_comment_status');
1205 903 $ping_status_global = get_option('feedwordpress_syndicated_ping_status');
1206 904
1207 905 $status['post'] = array('publish' => '', 'private' => '', 'draft' => '', 'site-default' => '');
1208 - if (SyndicatedPost::use_api('post_status_pending')) :
1209 - $status['post']['pending'] = '';
1210 - endif;
1211 -
1212 906 $status['comment'] = array('open' => '', 'closed' => '', 'site-default' => '');
1213 907 $status['ping'] = array('open' => '', 'closed' => '', 'site-default' => '');
1214 908
1215 909 foreach (array('post', 'comment', 'ping') as $what) :
@@ -1232,13 +926,28 @@
1232 926 endif;
1233 927 $unfamiliar[$what][$key] = ' checked="checked"';
1234 928 endforeach;
1235 929
1236 - if (is_array($meta['cats'])) : $cats = $meta['cats'];
1237 - else : $cats = array();
930 + $dogs = get_nested_categories(-1, 0);
931 + if (is_array($meta['cats'])) :
932 + $cats = array_map('strtolower',
933 + array_map('trim',
934 + $meta['cats']
935 + ));
936 + else:
937 + $cats = array();
1238 938 endif;
939 +
940 + foreach ($dogs as $tag => $dog) :
941 + $found_by_name = in_array(strtolower(trim($dog['cat_name'])), $cats);
942 +
943 + if (isset($dog['cat_ID'])) : $dog['cat_id'] = $dog['cat_ID']; endif;
944 + $found_by_id = in_array('{#'.trim($dog['cat_id']).'}', $cats);
1239 945
1240 - $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
946 + if ($found_by_name or $found_by_id) :
947 + $dogs[$tag]['checked'] = true;
948 + endif;
949 + endforeach;
1241 950 else :
1242 951 die( __('Link not found.') );
1243 952 endif;
1244 953
@@ -1251,25 +960,8 @@
1251 960 o = document.getElementById('basics-hardcode-'+item);
1252 961 if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
1253 962 else { ed.style.display='none'; view.style.display='inline'; }
1254 963 }
1255 - function flip_newuser (item) {
1256 - rollup=document.getElementById(item);
1257 - newuser=document.getElementById(item+'-newuser');
1258 - sitewide=document.getElementById(item+'-default');
1259 - if (rollup) {
1260 - if ('newuser'==rollup.value) {
1261 - if (newuser) newuser.style.display='block';
1262 - if (sitewide) sitewide.style.display='none';
1263 - } else if ('site-default'==rollup.value) {
1264 - if (newuser) newuser.style.display='none';
1265 - if (sitewide) sitewide.style.display='block';
1266 - } else {
1267 - if (newuser) newuser.style.display='none';
1268 - if (sitewide) sitewide.style.display='none';
1269 - }
1270 - }
1271 - }
1272 964 </script>
1273 965
1274 966 <?php if ($updated_link) : ?>
1275 967 <div class="updated"><p>Syndicated feed settings updated.</p></div>
@@ -1274,9 +966,9 @@
1274 966 <?php if ($updated_link) : ?>
1275 967 <div class="updated"><p>Syndicated feed settings updated.</p></div>
1276 968 <?php endif; ?>
1277 969
1278 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
970 +<form action="admin.php?page=feedwordpress/<?php echo basename(__FILE__); ?>" method="post">
1279 971 <div class="wrap">
1280 972 <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
1281 973 <input type="hidden" name="action" value="linkedit" />
1282 974 <input type="hidden" name="save" value="link" />
@@ -1281,96 +973,92 @@
1281 973 <input type="hidden" name="action" value="linkedit" />
1282 974 <input type="hidden" name="save" value="link" />
1283 975
1284 976 <h2>Edit a syndicated feed:</h2>
1285 -<div id="poststuff">
1286 -<?php fwp_linkedit_single_submit($status); ?>
977 +<fieldset><legend>Basics</legend>
978 +<table class="editform" width="100%" cellspacing="2" cellpadding="5">
979 +<tr>
980 +<th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
981 +<td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
982 +<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
983 +title="Check feed &lt;<?php echo wp_specialchars($link_rss_uri, 'both'); ?>&gt; for validity"><img src="../wp-images/smilies/icon_arrow.gif" alt="&rarr;" /></a>
984 +</td>
985 +<td width="20%"><input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" /></td>
986 +</tr>
987 +<tr>
988 +<th scope="row" width="20%"><?php _e('Link Name:') ?></th>
989 +<td width="60%"><input type="text" id="basics-name-edit" name="name"
990 +value="<?php echo $link_name; ?>" style="width: 95%" />
991 +<span id="basics-name-view"><strong><?php echo $link_name; ?></strong></span>
992 +</td>
993 +<td>
994 +<select id="basics-hardcode-name" onchange="flip_hardcode('name')" name="hardcode_name">
995 +<option value="no" <?php echo $link->hardcode('name')?'':'selected="selected"'; ?>>update automatically</option>
996 +<option value="yes" <?php echo $link->hardcode('name')?'selected="selected"':''; ?>>edit manually</option>
997 +</select>
998 +</td>
999 +</tr>
1000 +<tr>
1001 +<th scope="row" width="20%"><?php _e('Short description:') ?></th>
1002 +<td width="60%">
1003 +<input id="basics-description-edit" type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" />
1004 +<span id="basics-description-view"><strong><?php echo $link_description; ?></strong></span>
1005 +</td>
1006 +<td>
1007 +<select id="basics-hardcode-description" onchange="flip_hardcode('description')"
1008 +name="hardcode_description">
1009 +<option value="no" <?php echo $link->hardcode('description')?'':'selected="selected"'; ?>>update automatically</option>
1010 +<option value="yes" <?php echo $link->hardcode('description')?'selected="selected"':''; ?>>edit manually</option>
1011 +</select></td>
1012 +</tr>
1013 +<tr>
1014 +<th width="20%" scope="row"><?php _e('Homepage:') ?></th>
1015 +<td width="60%">
1016 +<input id="basics-url-edit" type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" />
1017 +<a id="basics-url-view" href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td>
1018 +<td>
1019 +<select id="basics-hardcode-url" onchange="flip_hardcode('url')" name="hardcode_url">
1020 +<option value="no"<?php echo $link->hardcode('url')?'':' selected="selected"'; ?>>update automatically</option>
1021 +<option value="yes"<?php echo $link->hardcode('url')?' selected="selected"':''; ?>>edit manually</option>
1022 +</select></td></tr>
1287 1023
1288 -<div id="post-body">
1289 -<?php fwp_option_box_opener('Feed Information', 'feedinformationdiv'); ?>
1290 - <table class="editform" width="100%" cellspacing="2" cellpadding="5">
1291 - <tr>
1292 - <th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
1293 - <td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
1294 - (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
1295 - title="Check feed &lt;<?php echo wp_specialchars($link_rss_uri, 'both'); ?>&gt; for validity">validate</a>)
1296 - </td>
1297 - <td width="20%"><input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" /></td>
1298 - </tr>
1299 - <tr>
1300 - <th scope="row" width="20%"><?php _e('Link Name:') ?></th>
1301 - <td width="60%"><input type="text" id="basics-name-edit" name="name"
1302 - value="<?php echo $link_name; ?>" style="width: 95%" />
1303 - <span id="basics-name-view"><strong><?php echo $link_name; ?></strong></span>
1304 - </td>
1305 - <td>
1306 - <select id="basics-hardcode-name" onchange="flip_hardcode('name')" name="hardcode_name">
1307 - <option value="no" <?php echo $link->hardcode('name')?'':'selected="selected"'; ?>>update automatically</option>
1308 - <option value="yes" <?php echo $link->hardcode('name')?'selected="selected"':''; ?>>edit manually</option>
1309 - </select>
1310 - </td>
1311 - </tr>
1312 - <tr>
1313 - <th scope="row" width="20%"><?php _e('Short description:') ?></th>
1314 - <td width="60%">
1315 - <input id="basics-description-edit" type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" />
1316 - <span id="basics-description-view"><strong><?php echo $link_description; ?></strong></span>
1317 - </td>
1318 - <td>
1319 - <select id="basics-hardcode-description" onchange="flip_hardcode('description')"
1320 - name="hardcode_description">
1321 - <option value="no" <?php echo $link->hardcode('description')?'':'selected="selected"'; ?>>update automatically</option>
1322 - <option value="yes" <?php echo $link->hardcode('description')?'selected="selected"':''; ?>>edit manually</option>
1323 - </select></td>
1324 - </tr>
1325 - <tr>
1326 - <th width="20%" scope="row"><?php _e('Homepage:') ?></th>
1327 - <td width="60%">
1328 - <input id="basics-url-edit" type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" />
1329 - <a id="basics-url-view" href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td>
1330 - <td>
1331 - <select id="basics-hardcode-url" onchange="flip_hardcode('url')" name="hardcode_url">
1332 - <option value="no"<?php echo $link->hardcode('url')?'':' selected="selected"'; ?>>update automatically</option>
1333 - <option value="yes"<?php echo $link->hardcode('url')?' selected="selected"':''; ?>>edit manually</option>
1334 - </select></td></tr>
1335 -
1336 - <tr>
1337 - <th width="20%"><?php _e('Last update') ?>:</th>
1338 - <td colspan="2"><?php
1339 - if (isset($meta['update/last'])) :
1340 - echo strftime('%x %X', $meta['update/last'])." ";
1024 +<tr>
1025 +<th width="20%"><?php _e('Last update') ?>:</th>
1026 +<td colspan="2"><?php
1027 + if (isset($meta['update/last'])) :
1028 + echo strftime('%x %X', $meta['update/last'])." ";
1029 + else :
1030 + echo " none yet";
1031 + endif;
1032 +?></td></tr>
1033 +<tr><th width="20%">Next update:</th>
1034 +<td colspan="2"><?php
1035 + $holdem = (isset($meta['update/hold']) ? $meta['update/hold'] : 'scheduled');
1036 +?>
1037 +<select name="update_schedule">
1038 +<option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
1039 + echo " (";
1040 + if (isset($meta['update/ttl']) and is_numeric($meta['update/ttl'])) :
1041 + if (isset($meta['update/timed']) and $meta['update/timed']=='automatically') :
1042 + echo 'next: ';
1043 + $next = $meta['update/last'] + ((int) $meta['update/ttl'] * 60);
1044 + if (strftime('%x', time()) != strftime('%x', $next)) :
1045 + echo strftime('%x', $next)." ";
1046 + endif;
1047 + echo strftime('%X', $meta['update/last']+((int) $meta['update/ttl']*60));
1341 1048 else :
1342 - echo " none yet";
1049 + echo "every ".$meta['update/ttl']." minute".(($meta['update/ttl']!=1)?"s":"");
1343 1050 endif;
1344 - ?></td></tr>
1345 - <tr><th width="20%">Next update:</th>
1346 - <td colspan="2"><?php
1347 - $holdem = (isset($meta['update/hold']) ? $meta['update/hold'] : 'scheduled');
1348 - ?>
1349 - <select name="update_schedule">
1350 - <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
1351 - echo " (";
1352 - if (isset($meta['update/ttl']) and is_numeric($meta['update/ttl'])) :
1353 - if (isset($meta['update/timed']) and $meta['update/timed']=='automatically') :
1354 - echo 'next: ';
1355 - $next = $meta['update/last'] + ((int) $meta['update/ttl'] * 60);
1356 - if (strftime('%x', time()) != strftime('%x', $next)) :
1357 - echo strftime('%x', $next)." ";
1358 - endif;
1359 - echo strftime('%X', $meta['update/last']+((int) $meta['update/ttl']*60));
1360 - else :
1361 - echo "every ".$meta['update/ttl']." minute".(($meta['update/ttl']!=1)?"s":"");
1362 - endif;
1363 - else:
1364 - echo "next scheduled update";
1365 - endif;
1366 - echo ")";
1367 - ?></option>
1368 - <option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
1369 - <option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
1370 - </select></tr>
1371 - </table>
1372 -<?php fwp_option_box_closer(); ?>
1051 + else:
1052 + echo "next scheduled update";
1053 + endif;
1054 + echo ")";
1055 +?></option>
1056 +<option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
1057 +<option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
1058 +</select></tr>
1059 +</table>
1060 +</fieldset>
1373 1061
1374 1062 <script type="text/javascript">
1375 1063 flip_hardcode('name');
1376 1064 flip_hardcode('description');
@@ -1376,49 +1064,81 @@
1376 1064 flip_hardcode('description');
1377 1065 flip_hardcode('url');
1378 1066 </script>
1379 1067
1380 -<?php fwp_linkedit_periodic_submit(); ?>
1068 +<p class="submit">
1069 +<input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
1070 +</p>
1381 1071
1382 -<?php
1383 -if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) :
1384 - fwp_option_box_opener('Syndicated Posts', 'syndicatedpostsdiv', 'postbox');
1385 -?>
1072 +<fieldset>
1073 +<legend>Syndicated Posts</legend>
1074 +
1075 +<?php fwp_category_box($dogs, 'all syndicated posts from this feed'); ?>
1076 +
1386 1077 <table class="editform" width="75%" cellspacing="2" cellpadding="5">
1387 1078 <tr><th width="27%" scope="row" style="vertical-align:top">Publication:</th>
1388 1079 <td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none">
1389 1080 <li><label><input type="radio" name="feed_post_status" value="site-default"
1390 -<?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>
1081 +<?php echo $status['post']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication Options</a>
1391 1082 (currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li>
1392 1083 <li><label><input type="radio" name="feed_post_status" value="publish"
1393 1084 <?php echo $status['post']['publish']; ?> /> Publish posts from this feed immediately</label></li>
1085 +<li><label><input type="radio" name="feed_post_status" value="private"
1086 +<?php echo $status['post']['private']; ?> /> Hold posts from this feed as private posts</label></li>
1087 +<li><label><input type="radio" name="feed_post_status" value="draft"
1088 +<?php echo $status['post']['draft']; ?> /> Hold posts from this feed as drafts</label></li>
1089 +</ul></td>
1090 +</tr>
1394 1091
1395 -<?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
1396 -<li><label><input type="radio" name="feed_post_status" value="pending"
1397 -<?php echo $status['post']['pending']; ?>/> Hold posts from this feed for review; mark as Pending</label></li>
1398 -<?php endif; ?>
1092 +<tr><th width="27%" scope="row" style="vertical-align:top">Comments:</th>
1093 +<td width="73%"><ul style="margin:0; list-style:none">
1094 +<li><label><input type="radio" name="feed_comment_status" value="site-default"
1095 +<?php echo $status['comment']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication Options</a>
1096 +(currently: <strong><?php echo ($comment_status_global ? $comment_status_global : 'closed'); ?>)</strong></label></li>
1097 +<li><label><input type="radio" name="feed_comment_status" value="open"
1098 +<?php echo $status['comment']['open']; ?> /> Allow comments on syndicated posts from this feed</label></li>
1099 +<li><label><input type="radio" name="feed_comment_status" value="closed"
1100 +<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts from this feed</label></li>
1101 +</ul></td>
1102 +</tr>
1399 1103
1400 -<li><label><input type="radio" name="feed_post_status" value="draft"
1401 -<?php echo $status['post']['draft']; ?> /> Save posts from this feed as drafts</label></li>
1402 -<li><label><input type="radio" name="feed_post_status" value="private"
1403 -<?php echo $status['post']['private']; ?> /> Save posts from this feed as private posts</label></li>
1104 +<tr><th width="27%" scope="row" style="vertical-align:top">Trackback and Pingback:</th>
1105 +<td width="73%"><ul style="margin:0; list-style:none">
1106 +<li><label><input type="radio" name="feed_ping_status" value="site-default"
1107 +<?php echo $status['ping']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication Options</a>
1108 +(currently: <strong><?php echo ($ping_status_global ? $ping_status_global : 'closed'); ?>)</strong></label></li>
1109 +<li><label><input type="radio" name="feed_ping_status" value="open"
1110 +<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts from this feed</label></li>
1111 +<li><label><input type="radio" name="feed_ping_status" value="closed"
1112 +<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts from this feed</label></li>
1404 1113 </ul></td>
1405 1114 </tr>
1406 1115 </table>
1407 -<?php
1408 - fwp_option_box_closer();
1409 - fwp_linkedit_periodic_submit();
1410 -endif;
1116 +</fieldset>
1411 1117
1412 - fwp_option_box_opener(__('Categories'), 'categorydiv', 'postbox');
1413 - fwp_category_box($dogs, 'all syndicated posts from this feed');
1414 -?>
1415 -<table>
1118 +<p class="submit">
1119 +<input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
1120 +</p>
1121 +
1122 +<fieldset>
1123 +<legend>Advanced Feed Options</legend>
1124 +<table class="editform" width="100%" cellspacing="2" cellpadding="5">
1416 1125 <tr>
1126 +<th width="20%" scope="row" style="vertical-align:top">Unfamiliar authors:</th>
1127 +<td width="80%"><ul style="margin: 0; list-style:none">
1128 +<li><label><input type="radio" name="unfamiliar_author" value="site-default"<?php echo $unfamiliar['author']['site-default']; ?> /> use site-wide setting from <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication Options</a>
1129 +(currently <strong><?php echo FeedWordPress::on_unfamiliar('author');; ?></strong>)</label></li>
1130 +<li><label><input type="radio" name="unfamiliar_author" value="create"<?php echo $unfamiliar['author']['create']; ?>/> create a new author account</label></li>
1131 +<li><label><input type="radio" name="unfamiliar_author" value="default"<?php echo $unfamiliar['author']['default']; ?> /> attribute the post to the default author</label></li>
1132 +<li><label><input type="radio" name="unfamiliar_author" value="filter"<?php echo $unfamiliar['author']['filter']; ?> /> don't syndicate the post</label></li>
1133 +</ul></td>
1134 +</tr>
1135 +
1136 +<tr>
1417 1137 <th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
1418 1138 <td width="80%"><ul style="margin: 0; list-style:none">
1419 -<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1420 -(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li>
1139 +<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use site-wide setting from <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication Options</a>
1140 +(currently <strong><?php echo FeedWordPress::on_unfamiliar('category');; ?></strong>)</label></li>
1421 1141 <li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create any categories the post is in</label></li>
1422 1142 <li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories</label></li>
1423 1143 <li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['category']['filter']; ?> /> don't create new categories and don't syndicate posts unless they match at least one familiar category</label></li>
1424 1144 </ul></td>
@@ -1435,117 +1155,16 @@
1435 1155 If the feed does not provide multiple categories in a single element, leave this
1436 1156 blank.</td>
1437 1157 </tr>
1438 1158 </table>
1439 -<?php
1440 - fwp_option_box_closer();
1441 - fwp_linkedit_periodic_submit();
1442 -
1443 -if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
1444 - fwp_tags_box($meta['tags']);
1445 - fwp_linkedit_periodic_submit();
1446 -endif; ?>
1159 +</fieldset>
1447 1160
1448 -<?php fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox'); ?>
1449 -<?php $authorlist = fwp_author_list(); ?>
1450 -<table>
1451 -<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>
1452 -<tr>
1453 - <th style="text-align: left">Posts by new authors</th>
1454 - <td>
1455 - <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
1456 - <option value="site-default"<?php if (!isset($meta['unfamiliar author'])) : ?>selected="selected"<?php endif; ?>>are handled using site-wide settings</option>
1457 - <option value="create"<?php if ('create'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
1458 - <?php foreach ($authorlist as $author_id => $author_name) : ?>
1459 - <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>
1460 - <?php endforeach; ?>
1461 - <option value="newuser">will be assigned to a new user...</option>
1462 - <option value="filter"<?php if ('filter'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>get filtered out</option>
1463 - </select>
1464 - </td>
1465 - <td>
1466 - <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>
1467 - <div id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></div>
1468 - </td>
1469 -</tr>
1161 +<p class="submit">
1162 +<input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
1163 +</p>
1470 1164
1471 -<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>
1472 -
1473 -<?php if (isset($meta['map authors'])) : $i=0; foreach ($meta['map authors'] as $author_rules) : foreach ($author_rules as $author_name => $author_action) : $i++; ?>
1474 -<tr>
1475 - <th style="text-align: left">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" /></th>
1476 - <td>
1477 - <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="flip_newuser('author-rules-<?php echo $i; ?>');">
1478 - <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?>
1479 - <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>
1480 - <?php endforeach; ?>
1481 - <option value="newuser">will be assigned to a new user...</option>
1482 - <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
1483 - </select>
1484 - </td>
1485 - <td><div id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></div></td>
1486 -</tr>
1487 -<?php endforeach; endforeach; endif; ?>
1488 -
1489 -<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>
1490 -
1491 -<tr>
1492 - <th style="text-align: left">Posts by <input type="text" name="add_author_rule_name" /></th>
1493 - <td>
1494 - <select id="add-author-rule" name="add_author_rule_action" onchange="flip_newuser('add-author-rule');">
1495 - <?php foreach ($authorlist as $author_id => $author_name) : ?>
1496 - <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
1497 - <?php endforeach; ?>
1498 - <option value="newuser">will be assigned to a new user...</option>
1499 - <option value="filter">get filtered out</option>
1500 - </select>
1501 - </td>
1502 - <td><div id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></div></td>
1503 -</tr>
1504 -
1505 -</table>
1506 -<?php fwp_option_box_closer(); ?>
1507 -
1508 -<script>
1509 - flip_newuser('unfamiliar-author');
1510 -<?php for ($j=1; $j<=$i; $j++) : ?>
1511 - flip_newuser('author-rules-<?php echo $j; ?>');
1512 -<?php endfor; ?>
1513 - flip_newuser('add-author-rule');
1514 -</script>
1515 -
1516 -<?php
1517 - fwp_linkedit_periodic_submit();
1518 - fwp_option_box_opener('Comments & Pings', 'commentstatusdiv', 'postbox');
1519 -?>
1520 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
1521 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Comments'); ?>:</th>
1522 -<td width="73%"><ul style="margin:0; list-style:none">
1523 -<li><label><input type="radio" name="feed_comment_status" value="site-default"
1524 -<?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>
1525 -(currently: <strong><?php echo ($comment_status_global ? $comment_status_global : 'closed'); ?>)</strong></label></li>
1526 -<li><label><input type="radio" name="feed_comment_status" value="open"
1527 -<?php echo $status['comment']['open']; ?> /> Allow comments on syndicated posts from this feed</label></li>
1528 -<li><label><input type="radio" name="feed_comment_status" value="closed"
1529 -<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts from this feed</label></li>
1530 -</ul></td></tr>
1531 -
1532 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Pings'); ?>:</th>
1533 -<td width="73%"><ul style="margin:0; list-style:none">
1534 -<li><label><input type="radio" name="feed_ping_status" value="site-default"
1535 -<?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>
1536 -(currently: <strong><?php echo ($ping_status_global ? $ping_status_global : 'closed'); ?>)</strong></label></li>
1537 -<li><label><input type="radio" name="feed_ping_status" value="open"
1538 -<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts from this feed</label></li>
1539 -<li><label><input type="radio" name="feed_ping_status" value="closed"
1540 -<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts from this feed</label></li>
1541 -</ul></td></tr>
1542 -
1543 -</table>
1544 -<?php fwp_option_box_closer(); ?>
1545 -<?php fwp_linkedit_periodic_submit(); ?>
1546 -
1547 -<?php fwp_option_box_opener('Custom Settings (for use in templates)', 'postcustom', 'postbox'); ?>
1165 +<fieldset id="postcustom">
1166 +<legend>Custom Settings (for use in templates)</legend>
1548 1167 <div id="postcustomstuff">
1549 1168 <table id="meta-list" cellpadding="3">
1550 1169 <tr>
1551 1170 <th>Key</th>
@@ -1577,13 +1196,14 @@
1577 1196 <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
1578 1197 <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
1579 1198 </tr>
1580 1199 </table>
1581 -<?php fwp_option_box_closer(); ?>
1200 +</fieldset>
1582 1201
1583 -<?php fwp_linkedit_periodic_submit(); ?>
1584 -</div> <!-- id="post-body" -->
1585 -</div> <!-- id="poststuff" -->
1202 +<p class="submit">
1203 +<input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
1204 +</p>
1205 +
1586 1206 </div>
1587 1207 <?php
1588 1208 endif;
1589 1209 return false; // Don't continue
@@ -1588,21 +1208,8 @@
1588 1208 endif;
1589 1209 return false; // Don't continue
1590 1210 }
1591 1211
1592 -function fwp_author_list () {
1593 - global $wpdb;
1594 - $ret = array();
1595 - $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY display_name");
1596 - if (is_array($users)) :
1597 - foreach ($users as $user) :
1598 - $id = (int) $user->ID;
1599 - $ret[$id] = $user->display_name;
1600 - endforeach;
1601 - endif;
1602 - return $ret;
1603 -}
1604 -
1605 1212 function fwp_multidelete_page () {
1606 1213 global $wpdb;
1607 1214
1608 1215 check_admin_referer(); // Make sure the referers are kosher
@@ -1692,9 +1299,9 @@
1692 1299 SELECT * FROM $wpdb->links
1693 1300 WHERE link_id IN (".implode(",",$link_ids).")
1694 1301 ");
1695 1302 ?>
1696 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
1303 +<form action="admin.php?page=feedwordpress/<?php echo basename(__FILE__); ?>" method="post">
1697 1304 <div class="wrap">
1698 1305 <input type="hidden" name="action" value="Unsubscribe" />
1699 1306 <input type="hidden" name="confirm" value="Delete" />
1700 1307
@@ -2015,15 +1622,12 @@
2015 1622
2016 1623 function on_unfamiliar ($what = 'author', $override = NULL) {
2017 1624 $set = array('create', 'default', 'filter');
2018 1625
2019 - if (is_string($override)) :
2020 - $ret = strtolower($override);
2021 - endif;
2022 -
2023 - if (!is_numeric($override) and !in_array($ret, $set)) :
1626 + $ret = strtolower($override);
1627 + if (!in_array($ret, $set)) :
2024 1628 $ret = get_option('feedwordpress_unfamiliar_'.$what);
2025 - if (!is_numeric($ret) and !in_array($ret, $set)) :
1629 + if (!in_array($ret, $set)) :
2026 1630 $ret = 'create';
2027 1631 endif;
2028 1632 endif;
2029 1633
@@ -2229,8 +1833,13 @@
2229 1833
2230 1834 var $_freshness = null;
2231 1835 var $_wp_id = null;
2232 1836
1837 + var $strip_attrs = array (
1838 + array('[a-z]+', 'style'),
1839 + array('[a-z]+', 'target'),
1840 + );
1841 +
2233 1842 function SyndicatedPost ($item, $link) {
2234 1843 global $wpdb;
2235 1844
2236 1845 $this->link = $link;
@@ -2261,14 +1870,14 @@
2261 1870 # That's deliberate. The escaping is done at the point
2262 1871 # of insertion, not here, to avoid double-escaping and
2263 1872 # to avoid screwing with syndicated_post filters
2264 1873
2265 - $this->post['post_title'] = apply_filters('syndicated_item_title', $this->item['title'], $this);
1874 + $this->post['post_title'] = $this->item['title'];
2266 1875
2267 - // This just gives us an alphanumeric representation of
1876 + // This just gives usan alphanumeric representation of
2268 1877 // the author. We will look up (or create) the numeric
2269 1878 // ID for the author in SyndicatedPost::add()
2270 - $this->post['named']['author'] = apply_filters('syndicated_item_author', $this->author(), $this);
1879 + $this->post['named']['author'] = $this->author();
2271 1880
2272 1881 # Identify content and sanitize it.
2273 1882 # ---------------------------------
2274 1883 if (isset($this->item['xhtml']['body'])) :
@@ -2279,9 +1888,24 @@
2279 1888 $content = $this->item['content']['encoded'];
2280 1889 else:
2281 1890 $content = $this->item['description'];
2282 1891 endif;
2283 - $this->post['post_content'] = apply_filters('syndicated_item_content', $content, $this);
1892 +
1893 + # FeedWordPress used to resolve URIs relative to the
1894 + # feed URI. It now relies on the xml:base support
1895 + # baked in to the MagpieRSS upgrade. So all we do here
1896 + # now is to sanitize problematic attributes.
1897 + #
1898 + # This kind of sucks. I intend to replace it with
1899 + # lib_filter sometime soon.
1900 + foreach ($this->strip_attrs as $pair):
1901 + list($tag,$attr) = $pair;
1902 + $content = preg_replace (
1903 + ":(<$tag [^>]*)($attr=(\"[^\">]*\"|[^>\\s]+))([^>]*>):i",
1904 + "\\1\\4",
1905 + $content
1906 + );
1907 + endforeach;
2284 1908
2285 1909 # Identify and sanitize excerpt
2286 1910 $excerpt = NULL;
2287 1911 if ( isset($this->item['description']) and $this->item['description'] ) :
@@ -2291,10 +1915,11 @@
2291 1915 if (strlen($excerpt) > 255) :
2292 1916 $excerpt = substr($excerpt,0,252).'...';
2293 1917 endif;
2294 1918 endif;
2295 - $excerpt = apply_filters('syndicated_item_excerpt', $excerpt, $this);
2296 1919
1920 + $this->post['post_content'] = $content;
1921 +
2297 1922 if (!is_null($excerpt)):
2298 1923 $this->post['post_excerpt'] = $excerpt;
2299 1924 endif;
2300 1925
@@ -2302,11 +1927,11 @@
2302 1927 if (!$this->use_api('wp_insert_post')) :
2303 1928 $this->post['post_name'] = sanitize_title($this->post['post_title']);
2304 1929 endif;
2305 1930
2306 - $this->post['epoch']['issued'] = apply_filters('syndicated_item_published', $this->published(), $this);
2307 - $this->post['epoch']['created'] = apply_filters('syndicated_item_created', $this->created(), $this);
2308 - $this->post['epoch']['modified'] = apply_filters('syndicated_item_updated', $this->updated(), $this);
1931 + $this->post['epoch']['issued'] = $this->published();
1932 + $this->post['epoch']['created'] = $this->created();
1933 + $this->post['epoch']['modified'] = $this->updated();
2309 1934
2310 1935 // Dealing with timestamps in WordPress is so fucking fucked.
2311 1936 $offset = (int) get_option('gmt_offset') * 60 * 60;
2312 1937 $this->post['post_date'] = gmdate('Y-m-d H:i:s', $this->published() + $offset);
@@ -2319,9 +1944,9 @@
2319 1944 $this->post['comment_status'] = $this->link->syndicated_status('comment', 'closed');
2320 1945 $this->post['ping_status'] = $this->link->syndicated_status('ping', 'closed');
2321 1946
2322 1947 // Unique ID (hopefully a unique tag: URI); failing that, the permalink
2323 - $this->post['guid'] = apply_filters('syndicated_item_guid', $this->guid(), $this);
1948 + $this->post['guid'] = $this->guid();
2324 1949
2325 1950 // RSS 2.0 / Atom 1.0 enclosure support
2326 1951 if ( isset($this->item['enclosure#']) ) :
2327 1952 for ($i = 1; $i <= $this->item['enclosure#']; $i++) :
@@ -2326,28 +1951,28 @@
2326 1951 if ( isset($this->item['enclosure#']) ) :
2327 1952 for ($i = 1; $i <= $this->item['enclosure#']; $i++) :
2328 1953 $eid = (($i > 1) ? "#{$id}" : "");
2329 1954 $this->post['meta']['enclosure'][] =
2330 - apply_filters('syndicated_item_enclosure_url', $this->item["enclosure{$eid}@url"], $this)."\n".
2331 - apply_filters('syndicated_item_enclosure_length', $this->item["enclosure{$eid}@length"], $this)."\n".
2332 - apply_filters('syndicated_item_enclosure_type', $this->item["enclosure{$eid}@type"], $this);
1955 + $this->item["enclosure{$eid}@url"]."\n".
1956 + $this->item["enclosure{$eid}@length"]."\n".
1957 + $this->item["enclosure{$eid}@type"];
2333 1958 endfor;
2334 1959 endif;
2335 1960
2336 1961 // In case you want to point back to the blog this was syndicated from
2337 1962 if (isset($this->feed->channel['title'])) :
2338 - $this->post['meta']['syndication_source'] = apply_filters('syndicated_item_source_title', $this->feed->channel['title'], $this);
1963 + $this->post['meta']['syndication_source'] = $this->feed->channel['title'];
2339 1964 endif;
2340 1965 if (isset($this->feed->channel['link'])) :
2341 - $this->post['meta']['syndication_source_uri'] = apply_filters('syndicated_item_source_link', $this->feed->channel['link'], $this);
1966 + $this->post['meta']['syndication_source_uri'] = $this->feed->channel['link'];
2342 1967 endif;
2343 1968
2344 1969 // Store information on human-readable and machine-readable comment URIs
2345 1970 if (isset($this->item['comments'])) :
2346 - $this->post['meta']['rss:comments'] = apply_filters('syndicated_item_comments', $this->item['comments']);
1971 + $this->post['meta']['rss:comments'] = $this->item['comments'];
2347 1972 endif;
2348 1973 if (isset($this->item['wfw']['commentrss'])) :
2349 - $this->post['meta']['wfw:commentRSS'] = apply_filters('syndicated_item_commentrss', $this->item['wfw']['commentrss']);
1974 + $this->post['meta']['wfw:commentRSS'] = $this->item['wfw']['commentrss'];
2350 1975 endif;
2351 1976
2352 1977 // Store information to identify the feed that this came from
2353 1978 $this->post['meta']['syndication_feed'] = $this->feedmeta['link/uri'];
@@ -2353,13 +1978,13 @@
2353 1978 $this->post['meta']['syndication_feed'] = $this->feedmeta['link/uri'];
2354 1979 $this->post['meta']['syndication_feed_id'] = $this->feedmeta['link/id'];
2355 1980
2356 1981 // In case you want to know the external permalink...
2357 - $this->post['meta']['syndication_permalink'] = apply_filters('syndicated_item_link', $this->item['link']);
1982 + $this->post['meta']['syndication_permalink'] = $this->item['link'];
2358 1983
2359 1984 // Feed-by-feed options for author and category creation
2360 1985 $this->post['named']['unfamiliar']['author'] = $this->feedmeta['unfamiliar author'];
2361 - $this->post['named']['unfamiliar']['category'] = $this->feedmeta['unfamiliar category'];
1986 + $this->post['named']['unfamiliar']['category'] = $this->feedmeta['unfamiliar categories'];
2362 1987
2363 1988 // Categories: start with default categories, if any
2364 1989 $fc = get_option("feedwordpress_syndication_cats");
2365 1990 if ($fc) :
@@ -2386,21 +2011,8 @@
2386 2011 $this->post['named']['category'][] = $cat;
2387 2012 endif;
2388 2013 endfor;
2389 2014 endif;
2390 - $this->post['named']['category'] = apply_filters('syndicated_item_categories', $this->post['named']['category'], $this);
2391 -
2392 - // Tags: start with default tags, if any
2393 - $ft = get_option("feedwordpress_syndication_tags");
2394 - if ($ft) :
2395 - $this->post['tags_input'] = explode('FEEDWORDPRESS_CAT_SEPARATOR', $ft);
2396 - else :
2397 - $this->post['tags_input'] = array();
2398 - endif;
2399 -
2400 - if (is_array($this->feedmeta['tags'])) :
2401 - $this->post['tags_input'] = array_merge($this->post['tags_input'], $this->feedmeta['tags']);
2402 - endif;
2403 2015 endif;
2404 2016 } // SyndicatedPost::SyndicatedPost()
2405 2017
2406 2018 function filtered () {
@@ -2530,17 +2142,8 @@
2530 2142 $dbpost[$key] = $value;
2531 2143 endif;
2532 2144 endforeach;
2533 2145
2534 - if (strlen($dbpost['post_title'].$dbpost['post_content'].$dbpost['post_excerpt']) == 0) :
2535 - // FIXME: Option for filtering out empty posts
2536 - endif;
2537 - if (strlen($dbpost['post_title'])==0) :
2538 - $dbpost['post_title'] = $this->post['meta']['syndication_source']
2539 - .' '.gmdate('Y-m-d H:i:s', $this->published() + $offset);
2540 - // FIXME: Option for what to fill a blank title with...
2541 - endif;
2542 -
2543 2146 if ($this->use_api('wp_insert_post')) :
2544 2147 $dbpost['post_pingback'] = false; // Tell WP 2.1 and 2.2 not to process for pingbacks
2545 2148 $this->_wp_id = wp_insert_post($dbpost);
2546 2149
@@ -2545,9 +2148,9 @@
2545 2148 $this->_wp_id = wp_insert_post($dbpost);
2546 2149
2547 2150 // This should never happen.
2548 2151 if (!is_numeric($this->_wp_id) or ($this->_wp_id == 0)) :
2549 - FeedWordPress::critical_bug('SyndicatedPost (_wp_id problem)', array($dbpost, $this), __LINE__);
2152 + FeedWordPress::critical_bug('SyndicatedPost (_wp_id problem)', $this, __LINE__);
2550 2153 endif;
2551 2154
2552 2155 // Unfortunately, as of WordPress 2.3, wp_insert_post()
2553 2156 // *still* offers no way to use a guid of your choice,
@@ -2745,89 +2348,86 @@
2745 2348 $author = $wpdb->escape($author);
2746 2349 $email = $wpdb->escape($email);
2747 2350 $url = $wpdb->escape($url);
2748 2351
2749 - // Check for an existing author rule....
2750 - if (isset($this->link->settings['map authors']['name'][strtolower(trim($author))])) :
2751 - $author_rule = $this->link->settings['map authors']['name'][strtolower(trim($author))];
2752 - else :
2753 - $author_rule = NULL;
2754 - endif;
2755 -
2756 - // User name is mapped to a particular author. If that author ID exists, use it.
2757 - if (is_numeric($author_rule) and get_userdata((int) $author_rule)) :
2758 - $id = (int) $author_rule;
2759 -
2760 - // User name is filtered out
2761 - elseif ('filter' == $author_rule) :
2762 - $id = NULL;
2763 -
2764 - else :
2765 - // Check the database for an existing author record that might fit
2766 -
2352 + // Look for an existing author record that fits...
2353 + if (!isset($wp_db_version)) :
2767 2354 #-- WordPress 1.5.x
2768 - if (!isset($wp_db_version)) :
2769 - $id = $wpdb->get_var(
2770 - "SELECT ID from $wpdb->users
2771 - WHERE
2772 - TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) OR
2773 - (
2774 - LENGTH(TRIM(LCASE(user_email))) > 0
2775 - AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
2776 - ) OR
2777 - TRIM(LCASE(user_firstname)) = TRIM(LCASE('$author')) OR
2778 - TRIM(LCASE(user_nickname)) = TRIM(LCASE('$author')) OR
2779 - TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author')) OR
2780 - TRIM(LCASE(user_description)) = TRIM(LCASE('$author')) OR
2781 - (
2782 - LOWER(user_description)
2783 - RLIKE CONCAT(
2784 - '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
2785 - LCASE('$reg_author'),
2786 - '( |\\t|\\r)*(\\n|\$)'
2787 - )
2355 + $id = $wpdb->get_var(
2356 + "SELECT ID from $wpdb->users
2357 + WHERE
2358 + TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) OR
2359 + (
2360 + LENGTH(TRIM(LCASE(user_email))) > 0
2361 + AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
2362 + ) OR
2363 + TRIM(LCASE(user_firstname)) = TRIM(LCASE('$author')) OR
2364 + TRIM(LCASE(user_nickname)) = TRIM(LCASE('$author')) OR
2365 + TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author')) OR
2366 + TRIM(LCASE(user_description)) = TRIM(LCASE('$author')) OR
2367 + (
2368 + LOWER(user_description)
2369 + RLIKE CONCAT(
2370 + '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
2371 + LCASE('$reg_author'),
2372 + '( |\\t|\\r)*(\\n|\$)'
2788 2373 )
2789 - ");
2790 -
2374 + )
2375 + ");
2376 + elseif ($wp_db_version >= 2966) :
2791 2377 #-- WordPress 2.0+
2792 - elseif ($wp_db_version >= 2966) :
2378 +
2379 + # First try the user core data table.
2380 + $id = $wpdb->get_var(
2381 + "SELECT ID FROM $wpdb->users
2382 + WHERE
2383 + TRIM(LCASE(user_login)) = TRIM(LCASE('$login'))
2384 + OR (
2385 + LENGTH(TRIM(LCASE(user_email))) > 0
2386 + AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
2387 + )
2388 + OR TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author'))
2389 + ");
2793 2390
2794 - // First try the user core data table.
2391 + if (is_null($id)) : # Then look for aliases in the user meta data table
2795 2392 $id = $wpdb->get_var(
2796 - "SELECT ID FROM $wpdb->users
2393 + "SELECT user_id FROM $wpdb->usermeta
2797 2394 WHERE
2798 - TRIM(LCASE(user_login)) = TRIM(LCASE('$login'))
2395 + (meta_key = 'description' AND TRIM(LCASE(meta_value)) = TRIM(LCASE('$author')))
2799 2396 OR (
2800 - LENGTH(TRIM(LCASE(user_email))) > 0
2801 - AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
2397 + meta_key = 'description'
2398 + AND TRIM(LCASE(meta_value))
2399 + RLIKE CONCAT(
2400 + '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
2401 + TRIM(LCASE('$reg_author')),
2402 + '( |\\t|\\r)*(\\n|\$)'
2403 + )
2802 2404 )
2803 - OR TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author'))
2804 2405 ");
2805 -
2806 - // If that fails, look for aliases in the user meta data table
2807 - if (is_null($id)) :
2808 - $id = $wpdb->get_var(
2809 - "SELECT user_id FROM $wpdb->usermeta
2810 - WHERE
2811 - (meta_key = 'description' AND TRIM(LCASE(meta_value)) = TRIM(LCASE('$author')))
2812 - OR (
2813 - meta_key = 'description'
2814 - AND TRIM(LCASE(meta_value))
2815 - RLIKE CONCAT(
2816 - '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
2817 - TRIM(LCASE('$reg_author')),
2818 - '( |\\t|\\r)*(\\n|\$)'
2819 - )
2820 - )
2821 - ");
2822 - endif;
2823 2406 endif;
2407 + endif;
2824 2408
2825 - // ... if you don't find one, then do what you need to do
2826 - if (is_null($id)) :
2827 - if ($unfamiliar_author === 'create') :
2409 + // ... if you don't find one, then do what you need to do
2410 + if (is_null($id)) :
2411 + if ($unfamiliar_author === 'create') :
2412 + if (!isset($wp_db_version)) :
2413 + #-- WordPress 1.5.x
2414 + $wpdb->query (
2415 + "INSERT INTO $wpdb->users
2416 + SET
2417 + ID='0',
2418 + user_login='$login',
2419 + user_firstname='$author',
2420 + user_nickname='$author',
2421 + user_nicename='$nice_author',
2422 + user_description='$author',
2423 + user_email='$email',
2424 + user_url='$url'");
2425 + $id = $wpdb->insert_id;
2426 + elseif ($wp_db_version >= 2966) :
2427 + #-- WordPress 2.0+
2828 2428 $userdata = array();
2829 -
2429 +
2830 2430 #-- user table data
2831 2431 $userdata['ID'] = NULL; // new user
2832 2432 $userdata['user_login'] = $login;
2833 2433 $userdata['user_nicename'] = $nice_author;
@@ -2834,21 +2434,15 @@
2834 2434 $userdata['user_pass'] = substr(md5(uniqid(microtime())), 0, 6); // just something random to lock it up
2835 2435 $userdata['user_email'] = $email;
2836 2436 $userdata['user_url'] = $url;
2837 2437 $userdata['display_name'] = $author;
2838 -
2438 +
2839 2439 $id = wp_insert_user($userdata);
2840 - elseif (is_numeric($unfamiliar_author) and get_userdata((int) $unfamiliar_author)) :
2841 - $id = (int) $unfamiliar_author;
2842 - elseif ($unfamiliar_author === 'default') :
2843 - $id = 1;
2844 2440 endif;
2441 + elseif ($unfamiliar_author === 'default') :
2442 + $id = 1;
2845 2443 endif;
2846 2444 endif;
2847 -
2848 - if ($id) :
2849 - $this->link->settings['map authors']['name'][strtolower(trim($author))] = $id;
2850 - endif;
2851 2445 return $id;
2852 2446 } // function SyndicatedPost::author_id ()
2853 2447
2854 2448 // look up (and create) category ids from a list of categories
@@ -2941,18 +2535,13 @@
2941 2535 } // function SyndicatedPost::category_ids ()
2942 2536
2943 2537 function use_api ($tag) {
2944 2538 global $wp_db_version;
2945 - switch ($tag) :
2946 - case 'wp_insert_post':
2539 + if ('wp_insert_post'==$tag) :
2947 2540 // Before 2.2, wp_insert_post does too much of the wrong stuff to use it
2948 2541 // In 1.5 it was such a resource hog it would make PHP segfault on big updates
2949 2542 $ret = (isset($wp_db_version) and $wp_db_version > FWP_SCHEMA_21);
2950 - break;
2951 - case 'post_status_pending':
2952 - $ret = (isset($wp_db_version) and $wp_db_version > FWP_SCHEMA_23);
2953 - break;
2954 - endswitch;
2543 + endif;
2955 2544 return $ret;
2956 2545 } // function SyndicatedPost::use_api ()
2957 2546
2958 2547 #### EXTRACT DATA FROM FEED ITEM ####
@@ -3109,31 +2698,8 @@
3109 2698 endif;
3110 2699
3111 2700 return $author;
3112 2701 } // SyndicatedPost::author()
3113 -
3114 - var $strip_attrs = array (
3115 - array('[a-z]+', 'style'),
3116 - array('[a-z]+', 'target'),
3117 - );
3118 - function sanitize_content ($content, $obj) {
3119 - # FeedWordPress used to resolve URIs relative to the
3120 - # feed URI. It now relies on the xml:base support
3121 - # baked in to the MagpieRSS upgrade. So all we do here
3122 - # now is to sanitize problematic attributes.
3123 - #
3124 - # This kind of sucks. I intend to replace it with
3125 - # lib_filter sometime soon.
3126 - foreach ($obj->strip_attrs as $pair):
3127 - list($tag,$attr) = $pair;
3128 - $content = preg_replace (
3129 - ":(<$tag [^>]*)($attr=(\"[^\">]*\"|[^>\\s]+))([^>]*>):i",
3130 - "\\1\\4",
3131 - $content
3132 - );
3133 - endforeach;
3134 - return $content;
3135 - }
3136 2702 } // class SyndicatedPost
3137 2703
3138 2704 # class SyndicatedLink: represents a syndication feed stored within the
3139 2705 # WordPress database
@@ -3211,26 +2777,18 @@
3211 2777 $this->settings['link/uri'] = $this->link->link_rss;
3212 2778 $this->settings['link/name'] = $this->link->link_name;
3213 2779 $this->settings['link/id'] = $this->link->link_id;
3214 2780
3215 - // `hardcode categories` and `unfamiliar categories` are deprecated in favor of `unfamiliar category`
2781 + // `hardcode categories` is deprecated in favor of `unfamiliar categories`
3216 2782 if (
3217 - isset($this->settings['unfamiliar categories'])
3218 - and !isset($this->settings['unfamiliar category'])
3219 - ) :
3220 - $this->settings['unfamiliar category'] = $this->settings['unfamiliar categories'];
3221 - endif;
3222 - if (
3223 2783 FeedWordPress::affirmative($this->settings, 'hardcode categories')
3224 - and !isset($this->settings['unfamiliar category'])
2784 + and !isset($this->settings['unfamiliar categories'])
3225 2785 ) :
3226 - $this->settings['unfamiliar category'] = 'default';
2786 + $this->settings['unfamiliar categories'] = 'default';
3227 2787 endif;
3228 -
2788 +
3229 2789 // Set this up automagically for del.icio.us
3230 - $bits = parse_url($this->link->link_rss);
3231 - $tagspacers = array('del.icio.us', 'feeds.delicious.com');
3232 - if (!isset($this->settings['cat_split']) and in_array($bits['host'], $tagspacers)) :
2790 + if (!isset($this->settings['cat_split']) and false !== strpos($this->link->link_rss, 'del.icio.us')) :
3233 2791 $this->settings['cat_split'] = '\s'; // Whitespace separates multiple tags in del.icio.us RSS feeds
3234 2792 endif;
3235 2793
3236 2794 if (isset($this->settings['cats'])):
@@ -3235,27 +2793,8 @@
3235 2793
3236 2794 if (isset($this->settings['cats'])):
3237 2795 $this->settings['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $this->settings['cats']);
3238 2796 endif;
3239 - if (isset($this->settings['tags'])):
3240 - $this->settings['tags'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $this->settings['tags']);
3241 - endif;
3242 -
3243 - if (isset($this->settings['map authors'])) :
3244 - $author_rules = explode("\n\n", $this->settings['map authors']);
3245 - $ma = array();
3246 - foreach ($author_rules as $rule) :
3247 - list($rule_type, $author_name, $author_action) = explode("\n", $rule);
3248 -
3249 - // Normalize for case and whitespace
3250 - $rule_type = strtolower(trim($rule_type));
3251 - $author_name = strtolower(trim($author_name));
3252 - $author_action = strtolower(trim($author_action));
3253 -
3254 - $ma[$rule_type][$author_name] = $author_action;
3255 - endforeach;
3256 - $this->settings['map authors'] = $ma;
3257 - endif;
3258 2797 endif;
3259 2798 } // SyndicatedLink::SyndicatedLink ()
3260 2799
3261 2800 function found () {
@@ -3331,26 +2870,11 @@
3331 2870
3332 2871 if (is_array($to_notes['cats'])) :
3333 2872 $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']);
3334 2873 endif;
3335 - if (is_array($to_notes['tags'])) :
3336 - $to_notes['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['tags']);
3337 - endif;
3338 -
3339 - if (isset($to_notes['map authors'])) :
3340 - $ma = array();
3341 - foreach ($to_notes['map authors'] as $rule_type => $author_rules) :
3342 - foreach ($author_rules as $author_name => $author_action) :
3343 - $ma[] = $rule_type."\n".$author_name."\n".$author_action;
3344 - endforeach;
3345 - endforeach;
3346 - $to_notes['map authors'] = implode("\n\n", $ma);
3347 - endif;
3348 -
3349 2874 unset($to_notes['link/id']); unset($to_notes['link/uri']);
3350 2875 unset($to_notes['link/name']);
3351 2876 unset($to_notes['hardcode categories']); // Deprecated
3352 - unset($to_notes['unfamiliar categories']); // Deprecated
3353 2877
3354 2878 $notes = '';
3355 2879 foreach ($to_notes as $key => $value) :
3356 2880 $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n";
@@ -3375,47 +2899,8 @@
3375 2899 if ( $new !== false ) $new_count[$new]++;
3376 2900 endif;
3377 2901 endforeach;
3378 2902 endif;
3379 -
3380 - // Copy back any changes to feed settings made in the course of updating (e.g. new author rules)
3381 - $to_notes = $this->settings;
3382 -
3383 - if (is_array($to_notes['cats'])) :
3384 - $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']);
3385 - endif;
3386 - if (is_array($to_notes['tags'])) :
3387 - $to_notes['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['tags']);
3388 - endif;
3389 -
3390 - if (isset($to_notes['map authors'])) :
3391 - $ma = array();
3392 - foreach ($to_notes['map authors'] as $rule_type => $author_rules) :
3393 - foreach ($author_rules as $author_name => $author_action) :
3394 - $ma[] = $rule_type."\n".$author_name."\n".$author_action;
3395 - endforeach;
3396 - endforeach;
3397 - $to_notes['map authors'] = implode("\n\n", $ma);
3398 - endif;
3399 -
3400 - unset($to_notes['link/id']); unset($to_notes['link/uri']);
3401 - unset($to_notes['link/name']);
3402 - unset($to_notes['hardcode categories']); // Deprecated
3403 - unset($to_notes['unfamiliar categories']); // Deprecated
3404 -
3405 - $notes = '';
3406 - foreach ($to_notes as $key => $value) :
3407 - $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n";
3408 - endforeach;
3409 -
3410 - $update_set = "link_notes = '".$wpdb->escape($notes)."'";
3411 -
3412 - // Update the properties of the link from the feed information
3413 - $result = $wpdb->query("
3414 - UPDATE $wpdb->links
3415 - SET $update_set
3416 - WHERE link_id='$this->id'
3417 - ");
3418 2903 endif;
3419 2904 return $new_count;
3420 2905 } /* SyndicatedLink::poll() */
3421 2906
@@ -3471,9 +2956,9 @@
3471 2956 endif;
3472 2957 return $ret;
3473 2958 } /* SyndicatedLink::ttl() */
3474 2959
3475 - // SyndicatedLink::flatten_array (): flatten an array. Useful for
2960 + // SyndicatedLink:flatten_array (): flatten an array. Useful for
3476 2961 // hierarchical and namespaced elements.
3477 2962 //
3478 2963 // Given an array which may contain array or object elements in it,
3479 2964 // return a "flattened" array: a one-dimensional array of scalars