| @@ -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: 2008.1214 | |
| 6 | +Version: 2008.1105 | |
| 7 | 7 | Author: Charles Johnson |
| 8 | 8 | Author URI: http://radgeek.com/ |
| 9 | 9 | License: GPL |
| 10 | -Last modified: 2008-12-14 4:29pm PST | |
| 10 | +Last modified: 2008-11-05 4:35pm PST | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | # This uses code derived from: |
| 14 | 14 | # - wp-rss-aggregate.php by Kellan Elliot-McCrea <kellan@protest.net> |
| @@ -15,22 +15,20 @@ | ||
| 15 | 15 | # - HTTP Navigator 2 by Keyvan Minoukadeh <keyvan@k1m.com> |
| 16 | 16 | # - Ultra-Liberal Feed Finder by Mark Pilgrim <mark@diveintomark.org> |
| 17 | 17 | # according to the terms of the GNU General Public License. |
| 18 | 18 | # |
| 19 | -# INSTALLATION: see readme.txt or <http://projects.radgeek.com/install> | |
| 19 | +# INSTALLATION: see README.text or <http://projects.radgeek.com/install> | |
| 20 | 20 | # |
| 21 | 21 | # USAGE: once FeedWordPress is installed, you manage just about everything from |
| 22 | -# the WordPress Dashboard, under the Syndication menu. To ensure that fresh | |
| 23 | -# content is added as it becomes available, you can convince your contributors | |
| 24 | -# to put your XML-RPC URI (if WordPress is installed at | |
| 22 | +# the WordPress Dashboard, under Options --> Syndication or Links --> Syndicated | |
| 23 | +# To ensure that fresh content is added as it becomes available, get your | |
| 24 | +# contributors to put your XML-RPC URI (if WordPress is installed at | |
| 25 | 25 | # <http://www.zyx.com/blog>, XML-RPC requests should be sent to |
| 26 | -# <http://www.zyx.com/blog/xmlrpc.php>), or update manually under the | |
| 27 | -# Syndication menu, or set up automatic updates under Syndication --> Settings, | |
| 28 | -# or use a cron job. | |
| 26 | +# <http://www.zyx.com/blog/xmlrpc.php>), or see `update-feeds.php` | |
| 29 | 27 | |
| 30 | 28 | # -- Don't change these unless you know what you're doing... |
| 31 | 29 | |
| 32 | -define ('FEEDWORDPRESS_VERSION', '2008.1214'); | |
| 30 | +define ('FEEDWORDPRESS_VERSION', '2008.1105'); | |
| 33 | 31 | define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact'); |
| 34 | 32 | define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors'); |
| 35 | 33 | |
| 36 | 34 | define ('FEEDWORDPRESS_DEBUG', false); |
| @@ -47,9 +45,8 @@ | ||
| 47 | 45 | define ('FWP_SCHEMA_21', 4772); // Database schema # for WP 2.1 |
| 48 | 46 | define ('FWP_SCHEMA_23', 5495); // Database schema # for WP 2.3 |
| 49 | 47 | define ('FWP_SCHEMA_25', 7558); // Database schema # for WP 2.5 |
| 50 | 48 | define ('FWP_SCHEMA_26', 8201); // Database schema # for WP 2.6 |
| 51 | -define ('FWP_SCHEMA_27', 9872); // Database schema # for WP 2.7 | |
| 52 | 49 | |
| 53 | 50 | if (FEEDWORDPRESS_DEBUG) : |
| 54 | 51 | // Help us to pick out errors, if any. |
| 55 | 52 | ini_set('error_reporting', E_ALL & ~E_NOTICE); |
| @@ -424,27 +421,12 @@ | ||
| 424 | 421 | function fwp_add_pages () { |
| 425 | 422 | global $fwp_capability; |
| 426 | 423 | global $fwp_path; |
| 427 | 424 | |
| 428 | - $menu = array('Syndicated Sites', 'Syndication', $fwp_capability['manage_links'], $fwp_path.'/syndication.php', NULL); | |
| 429 | - if (fwp_test_wp_version(FWP_SCHEMA_27)) : | |
| 430 | - // add icon parameter | |
| 431 | - $menu[] = WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress-tiny.png'; | |
| 432 | - endif; | |
| 433 | - | |
| 434 | - if (fwp_test_wp_version(FWP_SCHEMA_26)) : | |
| 435 | - $options = __('Settings'); | |
| 436 | - $longoptions = __('Syndication Settings'); | |
| 437 | - else : | |
| 438 | - $options = __('Options'); | |
| 439 | - $longoptions = __('Syndication Options'); | |
| 440 | - endif; | |
| 441 | - | |
| 442 | - call_user_func_array('add_menu_page', $menu); | |
| 425 | + add_menu_page('Syndicated Sites', 'Syndication', $fwp_capability['manage_links'], $fwp_path.'/syndication.php'); | |
| 443 | 426 | add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Authors', 'Authors', $fwp_capability['manage_options'], $fwp_path.'/authors.php'); |
| 444 | - add_submenu_page($fwp_path.'/syndication.php', $longoptions, $options, $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php'); | |
| 445 | - | |
| 446 | - add_options_page($longoptions, 'Syndication', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php'); | |
| 427 | + add_submenu_page($fwp_path.'/syndication.php', 'Syndication Options', 'Options', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php'); | |
| 428 | + add_options_page('Syndication Options', 'Syndication', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php'); | |
| 447 | 429 | } // function fwp_add_pages () */ |
| 448 | 430 | |
| 449 | 431 | ################################################################################ |
| 450 | 432 | ## fwp_hold_pings() and fwp_release_pings(): Outbound XML-RPC ping reform #### |
| @@ -712,9 +694,9 @@ | ||
| 712 | 694 | if (function_exists('wp_insert_link')) { // WordPress 2.x |
| 713 | 695 | $link_id = wp_insert_link(array( |
| 714 | 696 | "link_name" => $name, |
| 715 | 697 | "link_url" => $uri, |
| 716 | - "link_category" => (fwp_test_wp_version(0, FWP_SCHEMA_21) ? $cat_id : array($cat_id)), | |
| 698 | + "link_category" => array($cat_id), | |
| 717 | 699 | "link_rss" => $rss |
| 718 | 700 | )); |
| 719 | 701 | } else { // WordPress 1.5.x |
| 720 | 702 | $result = $wpdb->query(" |
| @@ -818,12 +800,12 @@ | ||
| 818 | 800 | if (function_exists('wp_insert_term')) : |
| 819 | 801 | $term = wp_insert_term($cat, 'link_category'); |
| 820 | 802 | $cat_id = $term['term_id']; |
| 821 | 803 | // WordPress 2.1, 2.2 category API. By the way, why the fuck is this API function only available in a wp-admin module? |
| 822 | - elseif (function_exists('wp_insert_category') and !fwp_test_wp_version(FWP_SCHEMA_20, FWP_SCHEMA_21)) : | |
| 804 | + elseif (function_exists('wp_insert_category')) : | |
| 823 | 805 | $cat_id = wp_insert_category(array('cat_name' => $cat)); |
| 824 | 806 | // WordPress 1.5 and 2.0.x |
| 825 | - elseif (fwp_test_wp_version(0, FWP_SCHEMA_21)) : | |
| 807 | + elseif (!isset($wp_db_version) or $wp_db_version < FWP_SCHEMA_21) : | |
| 826 | 808 | $result = $wpdb->query(" |
| 827 | 809 | INSERT INTO $wpdb->linkcategories |
| 828 | 810 | SET |
| 829 | 811 | cat_id = 0, |
| @@ -967,14 +949,8 @@ | ||
| 967 | 949 | echo "\n"; |
| 968 | 950 | echo $varname.": "; var_dump($var); echo "\n"; |
| 969 | 951 | die; |
| 970 | 952 | } |
| 971 | - | |
| 972 | - function noncritical_bug ($varname, $var, $line) { | |
| 973 | - if (FEEDWORDPRESS_DEBUG) : // halt only when we are doing debugging | |
| 974 | - FeedWordPress::critical_bug($varname, $var, $line); | |
| 975 | - endif; | |
| 976 | - } | |
| 977 | 953 | } // class FeedWordPress |
| 978 | 954 | |
| 979 | 955 | class SyndicatedPost { |
| 980 | 956 | var $item = null; |
| @@ -1171,9 +1147,9 @@ | ||
| 1171 | 1147 | |
| 1172 | 1148 | // Tags: start with default tags, if any |
| 1173 | 1149 | $ft = get_option("feedwordpress_syndication_tags"); |
| 1174 | 1150 | if ($ft) : |
| 1175 | - $this->post['tags_input'] = explode(FEEDWORDPRESS_CAT_SEPARATOR, $ft); | |
| 1151 | + $this->post['tags_input'] = explode('FEEDWORDPRESS_CAT_SEPARATOR', $ft); | |
| 1176 | 1152 | else : |
| 1177 | 1153 | $this->post['tags_input'] = array(); |
| 1178 | 1154 | endif; |
| 1179 | 1155 | |
| @@ -1765,9 +1741,9 @@ | ||
| 1765 | 1741 | $cat_ids[] = $cat_id; |
| 1766 | 1742 | elseif (get_category($cat_id)) : |
| 1767 | 1743 | $cat_ids[] = $cat_id; |
| 1768 | 1744 | endif; |
| 1769 | - elseif (strlen($cat_name) > 0) : | |
| 1745 | + else : | |
| 1770 | 1746 | $esc = $wpdb->escape($cat_name); |
| 1771 | 1747 | $resc = $wpdb->escape(preg_quote($cat_name)); |
| 1772 | 1748 | |
| 1773 | 1749 | // WordPress 2.3+ |
| @@ -1789,13 +1765,9 @@ | ||
| 1789 | 1765 | elseif ('tag'==$unfamiliar_category) : |
| 1790 | 1766 | $tags[] = $cat_name; |
| 1791 | 1767 | elseif ('create'===$unfamiliar_category) : |
| 1792 | 1768 | $term = wp_insert_term($cat_name, 'category'); |
| 1793 | - if (is_wp_error($term)) : | |
| 1794 | - FeedWordPress::noncritical_bug('term insertion problem', array('cat_name' => $cat_name, 'term' => $term, 'this' => $this), __LINE__); | |
| 1795 | - else : | |
| 1796 | - $cat_ids[] = $term['term_id']; | |
| 1797 | - endif; | |
| 1769 | + $cat_ids[] = $term['term_id']; | |
| 1798 | 1770 | endif; |
| 1799 | 1771 | |
| 1800 | 1772 | // WordPress 1.5.x - 2.2.x |
| 1801 | 1773 | else : |
| @@ -2515,9 +2487,8 @@ | ||
| 2515 | 2487 | |
| 2516 | 2488 | var $verify = FALSE; |
| 2517 | 2489 | |
| 2518 | 2490 | var $_data = NULL; |
| 2519 | - var $_error = NULL; | |
| 2520 | 2491 | var $_head = NULL; |
| 2521 | 2492 | |
| 2522 | 2493 | # -- Recognition patterns |
| 2523 | 2494 | var $_feed_types = array( |
| @@ -2572,12 +2543,8 @@ | ||
| 2572 | 2543 | $this->_get($uri); |
| 2573 | 2544 | return $this->_data; |
| 2574 | 2545 | } |
| 2575 | 2546 | |
| 2576 | - function error () { | |
| 2577 | - return $this->_error; | |
| 2578 | - } | |
| 2579 | - | |
| 2580 | 2547 | function is_feed ($uri = NULL) { |
| 2581 | 2548 | $data = $this->data($uri); |
| 2582 | 2549 | |
| 2583 | 2550 | return ( |
| @@ -2596,23 +2563,23 @@ | ||
| 2596 | 2563 | if ($uri) $this->uri = $uri; |
| 2597 | 2564 | |
| 2598 | 2565 | // Is the result not yet cached? |
| 2599 | 2566 | if ($this->_cache_uri !== $this->uri) : |
| 2600 | - $headers['Connection'] = 'close'; | |
| 2601 | - $headers['Accept'] = 'application/atom+xml application/rdf+xml application/rss+xml application/xml text/html */*'; | |
| 2602 | - $headers['User-Agent'] = 'feedfinder/1.2 (compatible; PHP FeedFinder) +http://projects.radgeek.com/feedwordpress'; | |
| 2567 | + // Snoopy is an HTTP client in PHP | |
| 2568 | + $client = new Snoopy(); | |
| 2569 | + | |
| 2570 | + // Prepare headers and internal settings | |
| 2571 | + $client->rawheaders['Connection'] = 'close'; | |
| 2572 | + $client->accept = 'application/atom+xml application/rdf+xml application/rss+xml application/xml text/html */*'; | |
| 2573 | + $client->agent = 'feedfinder/1.2 (compatible; PHP FeedFinder) +http://projects.radgeek.com/feedwordpress'; | |
| 2574 | + $client->read_timeout = 25; | |
| 2575 | + | |
| 2576 | + // Fetch the HTML or feed | |
| 2577 | + @$client->fetch($this->uri); | |
| 2578 | + $this->_data = $client->results; | |
| 2603 | 2579 | |
| 2604 | - // Use function provided by MagpieRSS package | |
| 2605 | - $client = _fetch_remote_file($this->uri, $headers); | |
| 2606 | - if (isset($client->error)) : | |
| 2607 | - $this->_error = $client->error; | |
| 2608 | - else : | |
| 2609 | - $this->_error = NULL; | |
| 2610 | - endif; | |
| 2611 | - $this->_data = $client->results; | |
| 2612 | - | |
| 2613 | - // Kilroy was here | |
| 2614 | - $this->_cache_uri = $this->uri; | |
| 2580 | + // Kilroy was here | |
| 2581 | + $this->_cache_uri = $this->uri; | |
| 2615 | 2582 | endif; |
| 2616 | 2583 | } /* FeedFinder::_get () */ |
| 2617 | 2584 | |
| 2618 | 2585 | function _link_rel_feeds () { |