PluginProbe
FeedWordPress / 2010.0127
FeedWordPress v2010.0127
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 +101 -9 2009.11112010.0127 View file →
@@ -2,9 +2,9 @@
2 2 /*
3 3 Plugin Name: FeedWordPress
4 4 Plugin URI: http://feedwordpress.radgeek.com/
5 5 Description: simple and flexible Atom/RSS syndication for WordPress
6 -Version: 2009.1111
6 +Version: 2010.0127
7 7 Author: Charles Johnson
8 8 Author URI: http://radgeek.com/
9 9 License: GPL
10 10 */
@@ -27,9 +27,9 @@
27 27 # or use a cron job.
28 28
29 29 # -- Don't change these unless you know what you're doing...
30 30
31 -define ('FEEDWORDPRESS_VERSION', '2009.0803');
31 +define ('FEEDWORDPRESS_VERSION', '2010.0127');
32 32 define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
33 33
34 34 // Defaults
35 35 define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
@@ -59,8 +59,9 @@
59 59 define ('FWP_SCHEMA_25', 7558); // Database schema # for WP 2.5
60 60 define ('FWP_SCHEMA_26', 8201); // Database schema # for WP 2.6
61 61 define ('FWP_SCHEMA_27', 9872); // Database schema # for WP 2.7
62 62 define ('FWP_SCHEMA_28', 11548); // Database schema # for WP 2.8
63 +define ('FWP_SCHEMA_29', 12329); // Database schema # for WP 2.9
63 64
64 65 if (FEEDWORDPRESS_DEBUG) :
65 66 // Help us to pick out errors, if any.
66 67 ini_set('error_reporting', E_ALL & ~E_NOTICE);
@@ -121,13 +122,20 @@
121 122 else : // Something went wrong. Let's just guess.
122 123 $fwp_path = 'feedwordpress';
123 124 endif;
124 125
126 +function feedwordpress_admin_scripts () {
127 + wp_enqueue_script('post'); // for magic tag and category boxes
128 + wp_enqueue_script('admin-forms'); // for checkbox selection
129 +}
130 +
125 131 // If this is a FeedWordPress admin page, queue up scripts for AJAX functions that FWP uses
126 132 // If it is a display page or a non-FeedWordPress admin page, don't.
127 133 if (is_admin() and isset($_REQUEST['page']) and preg_match("|^{$fwp_path}/|", $_REQUEST['page'])) :
128 134 if (function_exists('wp_enqueue_script')) :
129 - if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
135 + if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_29)) :
136 + add_action('admin_print_scripts', 'feedwordpress_admin_scripts');
137 + elseif (FeedWordPressCompatibility::test_version(FWP_SCHEMA_25)) :
130 138 wp_enqueue_script('post'); // for magic tag and category boxes
131 139 wp_enqueue_script('thickbox'); // for fold-up boxes
132 140 wp_enqueue_script('admin-forms'); // for checkbox selection
133 141 else :
@@ -181,8 +189,11 @@
181 189 add_action('admin_notices', 'fwp_check_debug');
182 190 add_action('admin_notices', 'fwp_check_magpie');
183 191 add_action('init', 'feedwordpress_check_for_magpie_fix');
184 192
193 + add_action('admin_menu', 'feedwordpress_add_post_edit_controls');
194 + add_action('save_post', 'feedwordpress_save_post_edit_controls');
195 +
185 196 # Inbound XML-RPC update methods
186 197 add_filter('xmlrpc_methods', 'feedwordpress_xmlrpc_hook');
187 198
188 199 # Outbound XML-RPC ping reform
@@ -271,14 +282,36 @@
271 282 endif;
272 283 } /* feedwordpress_auto_update () */
273 284
274 285 function feedwordpress_update_magic_url () {
286 + global $wpdb;
287 +
275 288 // Explicit update request in the HTTP request (e.g. from a cron job)
276 289 if (FeedWordPress::update_requested()) :
277 290 $feedwordpress =& new FeedWordPress;
278 291 $feedwordpress->update(FeedWordPress::update_requested_url());
279 292
280 - // Magic URL should return nothing but a 200 OK header packet
293 + if (FEEDWORDPRESS_DEBUG and count($wpdb->queries) > 0) :
294 + $mysqlTime = 0.0;
295 + $byTime = array();
296 + foreach ($wpdb->queries as $query) :
297 + $time = $query[1] * 1000000.0;
298 + $mysqlTime += $query[1];
299 + if (!isset($byTime[$time])) : $byTime[$time] = array(); endif;
300 + $byTime[$time][] = $query[0]. ' // STACK: ' . $query[2];
301 + endforeach;
302 + krsort($byTime);
303 +
304 + foreach ($byTime as $time => $querySet) :
305 + foreach ($querySet as $query) :
306 + print "[".(sprintf('%4.4f', $time/1000.0)) . "ms] $query\n";
307 + endforeach;
308 + endforeach;
309 + echo "[feedwordpress] $wpdb->num_queries queries. $mysqlTime seconds in MySQL. Total of "; timer_stop(1); print " seconds.";
310 + endif;
311 +
312 +
313 + // Magic URL should return nothing but a 200 OK header packet
281 314 // when successful.
282 315 exit;
283 316 endif;
284 317 } /* feedwordpress_magic_update_url () */
@@ -530,16 +563,16 @@
530 563 // In a post context....
531 564 if (is_syndicated()) :
532 565 ?>
533 566 <source>
534 - <title><?php the_syndication_source(); ?></title>
535 - <link rel="alternate" type="text/html" href="<?php the_syndication_source_link(); ?>" />
536 - <link rel="self" href="<?php the_syndication_feed(); ?>" />
567 + <title><?php print htmlspecialchars(get_syndication_source()); ?></title>
568 + <link rel="alternate" type="text/html" href="<?php print htmlspecialchars(get_syndication_source_link()); ?>" />
569 + <link rel="self" href="<?php print htmlspecialchars(get_syndication_feed()); ?>" />
537 570 <?php
538 571 $id = get_syndication_feed_guid();
539 572 if (strlen($id) > 0) :
540 573 ?>
541 - <id><?php print $id; ?></id>
574 + <id><?php print htmlspecialchars($id); ?></id>
542 575 <?php
543 576 endif;
544 577 $updated = get_feed_meta('feed/updated');
545 578 if (strlen($updated) > 0) : ?>
@@ -604,9 +637,9 @@
604 637 <?php
605 638 endif;
606 639 } /* function fwp_check_debug () */
607 640
608 -define('EXPECTED_MAGPIE_VERSION', '2009.0725');
641 +define('EXPECTED_MAGPIE_VERSION', '2010.0122');
609 642 function fwp_check_magpie () {
610 643 if (isset($_REQUEST['feedwordpress_magpie_fix'])) :
611 644 if ($_REQUEST['feedwordpress_magpie_fix']=='ignored') :
612 645 ?>
@@ -750,8 +783,65 @@
750 783 endif;
751 784 endif;
752 785 }
753 786
787 + function feedwordpress_add_post_edit_controls () {
788 + add_meta_box('feedwordpress-post-controls', __('Syndication'), 'feedwordpress_post_edit_controls', 'post', 'side', 'high');
789 + } // function FeedWordPress::postEditControls
790 +
791 + function feedwordpress_post_edit_controls () {
792 + global $post;
793 +
794 + $frozen_values = get_post_custom_values('_syndication_freeze_updates', $post->ID);
795 + $frozen_post = (count($frozen_values) > 0 and 'yes' == $frozen_values[0]);
796 +
797 + if (is_syndicated($post->ID)) :
798 + ?>
799 + <p>This is a syndicated post, which originally appeared at
800 + <cite><?php print wp_specialchars(get_syndication_source(NULL, $post->ID)); ?></cite>.
801 + <a href="<?php print wp_specialchars(get_syndication_permalink($post->ID)); ?>">View original post</a>.</p>
802 +
803 + <p><input type="hidden" name="feedwordpress_noncename" id="feedwordpress_noncename" value="<?php print wp_create_nonce(plugin_basename(__FILE__)); ?>" />
804 + <label><input type="checkbox" name="freeze_updates" value="yes" <?php if ($frozen_post) : ?>checked="checked"<?php endif; ?> /> <strong>Manual editing.</strong>
805 + If set, FeedWordPress will not overwrite the changes you make manually
806 + to this post, if the syndicated content is updated on the
807 + feed.</label></p>
808 + <?php
809 + else :
810 + ?>
811 + <p>This post was created locally at this website.</p>
812 + <?php
813 + endif;
814 + } // function feedwordpress_post_edit_controls () */
815 +
816 + function feedwordpress_save_post_edit_controls ( $post_id ) {
817 + global $post;
818 +
819 + if (!isset($_POST['feedwordpress_noncename']) or !wp_verify_nonce($_POST['feedwordpress_noncename'], plugin_basename(__FILE__))) :
820 + return $post_id;
821 + endif;
822 +
823 + // Verify if this is an auto save routine. If it is our form has
824 + // not been submitted, so we don't want to do anything.
825 + if ( defined('DOING_AUTOSAVE') and DOING_AUTOSAVE ) :
826 + return $post_id;
827 + endif;
828 +
829 + // Check permissions
830 + if ( !current_user_can( 'edit_'.$_POST['post_type'], $post_id) ) :
831 + return $post_id;
832 + endif;
833 +
834 + // OK, we're golden. Now let's save some data.
835 + if (isset($_POST['freeze_updates'])) :
836 + update_post_meta($post_id, '_syndication_freeze_updates', $_POST['freeze_updates']);
837 + else :
838 + delete_post_meta($post_id, '_syndication_freeze_updates');
839 + endif;
840 +
841 + return $_POST['freeze_updates'];
842 + } // function feedwordpress_save_edit_controls
843 +
754 844 ################################################################################
755 845 ## class FeedWordPress #########################################################
756 846 ################################################################################
757 847
@@ -1019,8 +1109,10 @@
1019 1109 );
1020 1110
1021 1111 if (is_string($override)) :
1022 1112 $ret = strtolower($override);
1113 + else :
1114 + $ret = NULL;
1023 1115 endif;
1024 1116
1025 1117 if (!is_numeric($override) and !in_array($ret, $set[$what])) :
1026 1118 $ret = get_option('feedwordpress_unfamiliar_'.$what);