diff --git a/wp-content/plugins/feedwordpress/admin-ui.php b/wp-content/plugins/feedwordpress/admin-ui.php index ed633f58b59770030131de3cb6dff496329656ee..d9ba9c3a62c98bee9c465a6cb5e4d290008a5e40 100644 --- a/wp-content/plugins/feedwordpress/admin-ui.php +++ b/wp-content/plugins/feedwordpress/admin-ui.php @@ -61,7 +61,8 @@ class FeedWordPressAdminPage { print '<div class="updated">'; print "<ul>"; - $delta = $feedwordpress->update($this->link->uri()); + $uri = $this->link->uri(); + $delta = $feedwordpress->update($uri); print "</ul>"; if (!is_null($delta)) : @@ -71,6 +72,7 @@ class FeedWordPressAdminPage { echo "<p><strong>Update complete.</strong>".implode(' and', $mesg)."</p>"; echo "\n"; flush(); else : + $uri = esc_html($uri); echo "<p><strong>Error:</strong> There was a problem updating <a href=\"$uri\">$uri</a></p>\n"; endif; print "</div>\n"; @@ -98,7 +100,15 @@ class FeedWordPressAdminPage { function for_feed_settings () { return (is_object($this->link) and method_exists($this->link, 'found') and $this->link->found()); } function for_default_settings () { return !$this->for_feed_settings(); } - function setting ($names, $fallback_value = NULL, $default = 'default') { + function setting ($names, $fallback_value = NULL, $params = array()) { + if (!is_array($params)) : + $params = array('default' => $params); + endif; + $params = shortcode_atts(array( + 'default' => 'default', + 'fallback' => true, + ), $params); + if (is_string($names)) : $feed_name = $names; $global_name = 'feedwordpress_'.preg_replace('![\s/]+!', '_', $names); @@ -108,7 +118,8 @@ class FeedWordPressAdminPage { endif; if ($this->for_feed_settings()) : // Check feed-specific setting first; fall back to global - $ret = $this->link->setting($feed_name, $global_name, $fallback_value); + if (!$params['fallback']) : $global_name = NULL; endif; + $ret = $this->link->setting($feed_name, $global_name, $fallback_value, $params['default']); else : // Check global setting $ret = get_option($global_name, $fallback_value); endif; @@ -553,6 +564,7 @@ class FeedWordPressAdminPage { // This allows us to provide an alternative set of human-readable // labels for each potential value. For use in Currently: line. if (isset($params['labels'])) : $labels = $params['labels']; + elseif (is_callable($options)) : $labels = NULL; else : $labels = $options; endif; @@ -632,6 +644,8 @@ class FeedWordPressAdminPage { <span class="current-setting">Currently: <strong><?php if (is_callable($labels)) : print call_user_func($labels, $globalSetting, $defaulted, $params); + elseif (is_null($labels)) : + print $globalSetting; else : print $labels[$globalSetting]; endif; ?></strong> (<a href="<?php print $href; ?>">change</a>)</span></li> @@ -736,6 +750,11 @@ function fwp_tags_box ($tags, $object, $params = array()) { $tax_name = (isset($params['taxonomy']) ? $params['taxonomy'] : 'post_tag'); $desc = "<p style=\"font-size:smaller;font-style:bold;margin:0\">Tag $object as...</p>"; + if (isset($params['textarea_name'])) : + $textAreaName = $params['textarea_name']; + else : + $textAreaName = "tax_input[$tax_name]"; + endif; print $desc; $helps = __('Separate tags with commas.'); $box['title'] = __('Tags'); @@ -744,7 +763,7 @@ function fwp_tags_box ($tags, $object, $params = array()) { <div class="jaxtag"> <div class="nojs-tags hide-if-js"> <p><?php _e('Add or remove tags'); ?></p> - <textarea name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]"><?php echo esc_attr(implode(",", $tags)); ?></textarea></div> + <textarea name="<?php echo esc_html($textAreaName); ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]"><?php echo esc_attr(implode(",", $tags)); ?></textarea></div> <div class="ajaxtag hide-if-no-js"> <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label> @@ -865,7 +884,7 @@ function fwp_author_list () { global $wpdb; $ret = array(); - $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY display_name"); + $users = get_users_of_blog(); if (is_array($users)) : foreach ($users as $user) : $id = (int) $user->ID; @@ -908,6 +927,14 @@ class FeedWordPressSettingsUI { function admin_styles () { ?> <style type="text/css"> + #feedwordpress-admin-feeds .link-rss-params-remove .x, .feedwordpress-admin .remove-it .x { + background: url(<?php print admin_url('images/xit.gif') ?>) no-repeat scroll 0 0 transparent; + } + + #feedwordpress-admin-feeds .link-rss-params-remove:hover .x, .feedwordpress-admin .remove-it:hover .x { + background: url(<?php print admin_url('images/xit.gif') ?>) no-repeat scroll -10px 0 transparent; + } + .fwpfs { background-image: url(<?php print admin_url('images/fav.png'); ?>); background-repeat: repeat-x; @@ -950,10 +977,13 @@ class FeedWordPressSettingsUI { } /* FeedWordPressSettingsUI::fix_toggles_js () */ function magic_input_tip_js ($id) { + if (!preg_match('/^[.#]/', $id)) : + $id = '#'.$id; + endif; ?> <script type="text/javascript"> jQuery(document).ready( function () { - var inputBox = jQuery("#<?php print $id; ?>"); + var inputBox = jQuery("<?php print $id; ?>"); var boxEl = inputBox.get(0); if (boxEl.value==boxEl.defaultValue) { inputBox.addClass('form-input-tip'); } inputBox.focus(function() { diff --git a/wp-content/plugins/feedwordpress/categories-page.php b/wp-content/plugins/feedwordpress/categories-page.php index 1c7787c182edee6c9f54d3c4b3f3737971ce9dfc..823713ccb9c29d35b774aff21d65eaa3cc88ee33 100644 --- a/wp-content/plugins/feedwordpress/categories-page.php +++ b/wp-content/plugins/feedwordpress/categories-page.php @@ -457,17 +457,15 @@ blank.</p></td> <td class="secondary"> <h4>Site-wide <?php print $taxonomy->labels->name; ?></h4> <?php if (count($globalCats) > 0) : ?> - <ul class="current-setting"> - <?php - foreach ($globalDogs as $dog) : - ?> - <li><?php $cat = get_term($dog, $tax); print $cat->name; ?></li> - <?php endforeach; ?> - </ul> - </div> - <p> + <ul class="current-setting"> + <?php foreach ($globalDogs as $dog) : ?> + <li><?php $cat = get_term($dog, $tax); print $cat->name; ?></li> + <?php endforeach; ?> + </ul> + </div> + <p> <?php else : ?> - <p>Site-wide settings may also assign categories to syndicated + <p>Site-wide settings may also assign categories to syndicated posts. <?php endif; ?> Should <?php print $page->these_posts_phrase(); ?> be assigned @@ -476,7 +474,7 @@ blank.</p></td> <ul class="settings"> <li><p><label><input type="radio" name="add_global[<?php print $tax; ?>]" value="yes" <?php print $checked['yes']; ?> /> Yes. Place <?php print $page->these_posts_phrase(); ?> under all these categories.</label></p></li> - <li><p><label><input type="radio" name="add_global[<?php print $tax; ?>]" value="no" <?php print $checked['no']; ?> /> No. Only use the categories I set up on the left. Do not ise the global defaults for <?php print $page->these_posts_phrase(); ?></label></p></li> + <li><p><label><input type="radio" name="add_global[<?php print $tax; ?>]" value="no" <?php print $checked['no']; ?> /> No. Only use the categories I set up on the left. Do not use the global defaults for <?php print $page->these_posts_phrase(); ?></label></p></li> </ul> </td> </tr> diff --git a/wp-content/plugins/feedwordpress/compatability.php b/wp-content/plugins/feedwordpress/compatability.php index 1717949e00f6330c9b3d73f8bd4a930a93f83041..0099488a14581ed2c9a88317473912c94ccd1b90 100644 --- a/wp-content/plugins/feedwordpress/compatability.php +++ b/wp-content/plugins/feedwordpress/compatability.php @@ -4,7 +4,17 @@ ################################################################################ class FeedWordPressCompatibility { - // version testing based on database schema version + + /** + * FeedWordPressCompatibility::test_version: test version of WordPress + * based on the database schema version. + * + * @param int $floor The minimum version necessary + * @param mixed $ceiling The first version that is too high. If omitted + * or NULL, no version is too high. + * @return bool TRUE if within the range of versions, FALSE if too low + * or too high. + */ /*static*/ function test_version ($floor, $ceiling = null) { global $wp_db_version; @@ -19,12 +29,23 @@ class FeedWordPressCompatibility { /*static*/ function insert_link_category ($name) { global $wpdb; - $name = $wpdb->escape($name); - // WordPress 2.3+ term/taxonomy API $term = wp_insert_term($name, 'link_category'); - $cat_id = $term['term_id']; - + + // OK: returned array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id) + if (!is_wp_error($term)) : + $cat_id = $term['term_id']; + + // Error: term with this name already exists. Well, let's use that then. + elseif ($term->get_error_code() == 'term_exists') : + // Already-existing term ID is returned in data field + $cat_id = $term->get_error_data('term_exists'); + + // Error: another kind of error, harder to recover from. Return WP_Error. + else : + $cat_id = $term; + endif; + // Return newly-created category ID return $cat_id; } /* FeedWordPressCompatibility::insert_link_category () */ @@ -122,6 +143,38 @@ if (!function_exists('disabled')) { } } /* if */ +// Compat + +if (!function_exists('set_post_field')) { + + /** + * Update data from a post field based on Post ID + * + * Examples of the post field will be, 'post_type', 'post_status', 'post_content', etc. + * + * The context values are based off of the taxonomy filter functions and + * supported values are found within those functions. + * + * @uses sanitize_post_field() + * + * @param string $field Post field name + * @param mixed $value New value for post field + * @param id $post Post ID + * @return bool Result of UPDATE query + * + * Included under terms of GPL from WordPress Ticket #10946 <http://core.trac.wordpress.org/attachment/ticket/10946/post.php.diff> + */ + function set_post_field ($field, $value, $post_id) { + global $wpdb; + + $post_id = absint($post_id); + // sigh ... when FWP is active, I need to avoid avoid_kses_munge + // $value = sanitize_post_field($field, $value, $post_id, 'db'); + return $wpdb->update($wpdb->posts, array($field => $value), array('ID' => $post_id)); + } /* function set_post_field () */ + +} /* if */ + if (!function_exists('term_exists')) { // Fucking WordPress 3.0 wordsmithing. function term_exists ( $term, $taxonomy = '', $parent = 0 ) { @@ -140,7 +193,7 @@ function fwp_category_checklist ($post_id = 0, $descendents_and_self = 0, $selec $taxonomy = (isset($params['taxonomy']) ? $params['taxonomy'] : 'category'); endif; - $walker = new FeedWordPress_Walker_Category_Checklist; + $walker = new FeedWordPress_Walker_Category_Checklist($params); $walker->set_prefix($prefix); $walker->set_taxonomy($taxonomy); wp_terms_checklist(/*post_id=*/ $post_id, array( diff --git a/wp-content/plugins/feedwordpress/diagnostics-page.php b/wp-content/plugins/feedwordpress/diagnostics-page.php index 4e7b845479863347ebe36dab45f2ad17bdc793d6..ad9fe528316c632e3a6e6409fd604e0464d09f3b 100644 --- a/wp-content/plugins/feedwordpress/diagnostics-page.php +++ b/wp-content/plugins/feedwordpress/diagnostics-page.php @@ -39,7 +39,8 @@ class FeedWordPressDiagnosticsPage extends FeedWordPressAdminPage { <div id="post-body"> <?php $boxes_by_methods = array( - 'diagnostics_box' => __('Diagnostics'), + 'info_box' => __('Diagnostic Information'), + 'diagnostics_box' => __('Display Diagnostics'), 'updates_box' => __('Updates'), ); @@ -104,7 +105,53 @@ class FeedWordPressDiagnosticsPage extends FeedWordPressAdminPage { endif; } /* FeedWordPressDiagnosticsPage::accept_POST () */ - /*static*/ function diagnostics_box ($page, $box = NULL) { + function info_box ($page, $box = NULL) { + $link_category_id = FeedWordPress::link_category_id(); + ?> + <table class="edit-form narrow"> + <thead style="display: none"> + <th scope="col">Topic</th> + <th scope="col">Information</th> + </thead> + + <tbody> + <tr> + <th scope="row">Version:</th> + <td>You are using FeedWordPress version <strong><?php print FEEDWORDPRESS_VERSION; ?></strong>.</td> + </tr> + + <tr> + <th scope="row">Link Category:</th> + <td><?php if (!is_wp_error($link_category_id)) : + $term = get_term($link_category_id, 'link_category'); + ?><p>Syndicated feeds are + kept in link category #<?php print $term->term_id; ?>, <strong><?php print $term->name; ?></strong>.</p> + <?php else : ?> + <p><strong>FeedWordPress has been unable to set up a valid Link Category + for syndicated feeds.</strong> Attempting to set one up returned an + <code><?php $link_category_id->get_error_code(); ?></code> error with this + additional data:</p> + <table> + <tbody> + <tr> + <th scope="row">Message:</th> + <td><?php print $link_category_id->get_error_message(); ?></td> + </tr> + <?php $data = $link_category_id->get_error_data(); if (!empty($data)) : ?> + <tr> + <th scope="row">Auxiliary Data:</th> + <td><pre><?php print esc_html(FeedWordPress::val($link_category_id->get_error_data())); ?></pre></td> + </tr> + <?php endif; ?> + </table> + <?php endif; ?></td> + </tr> + </table> + + <?php + } /* FeedWordPressDiagnosticsPage::info_box () */ + + function diagnostics_box ($page, $box = NULL) { $settings = array(); $settings['debug'] = (get_option('feedwordpress_debug')=='yes'); @@ -178,43 +225,50 @@ testing but absolutely inappropriate for a production server.</p> } /* FeedWordPressDiagnosticsPage::diagnostics_box () */ /*static*/ function updates_box ($page, $box = NULL) { - $checked = array( - 'updated_feeds' => '', 'updated_feeds:errors' => '', - 'updated_feeds:errors:persistent' => '', - "syndicated_posts" => '', 'syndicated_posts:meta_data' => '', - 'feed_items' => '', - 'memory_usage' => '', - ); + $hours = get_option('feedwordpress_diagnostics_persistent_errors_hours', 2); + $fields = apply_filters('feedwordpress_diagnostics', array( + 'Update Diagnostics' => array( + 'updated_feeds' => 'as each feed checked for updates', + 'updated_feeds:errors:persistent' => 'when attempts to update a feed have resulted in errors</label> <label>for at least <input type="number" min="1" max="360" step="1" name="diagnostics_persistent_error_hours" value="'.$hours.'" /> hours', + 'updated_feeds:errors' => 'any time FeedWordPress encounters any errors while checking a feed for updates', + 'syndicated_posts' => 'as each syndicated post is added to the database', + 'feed_items' => 'as each syndicated item is considered on the feed', + 'memory_usage' => 'indicating how much memory was used', + ), + 'Syndicated Post Details' => array( + 'syndicated_posts:meta_data' => 'as syndication meta-data is added on the post', + ), + ), $page); + + foreach ($fields as $section => $items) : + foreach ($items as $key => $label) : + $checked[$key] = ''; + endforeach; + endforeach; $diagnostics_show = get_option('feedwordpress_diagnostics_show', array()); if (is_array($diagnostics_show)) : foreach ($diagnostics_show as $thingy) : $checked[$thingy] = ' checked="checked"'; endforeach; endif; - $hours = get_option('feedwordpress_diagnostics_persistent_errors_hours', 2); - // Hey ho, let's go... ?> <table class="edit-form"> -<tr> -<th scope="row">Update diagnostics:</th> -<td><p>Show a diagnostic message...</p> -<ul class="options"> -<li><label><input type="checkbox" name="diagnostics_show[]" value="updated_feeds" <?php print $checked['updated_feeds']; ?> /> as each feed checked for updates</label></li> -<li><label><input type="checkbox" name="diagnostics_show[]" value="updated_feeds:errors:persistent" <?php print $checked['updated_feeds:errors:persistent'] ?> /> when attempts to update a feed have resulted in errors</label> <label>for at least <input type="number" min="1" max="360" step="1" name="diagnostics_persistent_error_hours" value="<?php print $hours; ?>" /> hours</label></li> -<li><label><input type="checkbox" name="diagnostics_show[]" value="updated_feeds:errors" <?php print $checked['updated_feeds:errors']; ?> /> any time FeedWordPress encounters any errors while checking a feed for updates</label></li> -<li><label><input type="checkbox" name="diagnostics_show[]" value="syndicated_posts" <?php print $checked['syndicated_posts']; ?> /> as each syndicated post is added to the database</label></li> -<li><label><input type="checkbox" name="diagnostics_show[]" value="feed_items" <?php print $checked['feed_items']; ?> /> as each syndicated item is considered on the feed</label></li> -<li><label><input type="checkbox" name="diagnostics_show[]" value="memory_usage" <?php print $checked['memory_usage']; ?> /> indicating how much memory was used</label></li> -</ul></td> -</tr> -<tr> -<th>Syndicated post details:</th> -<td><p>Show a diagnostic message...</p> -<ul class="options"> -<li><label><input type="checkbox" name="diagnostics_show[]" value="syndicated_posts:meta_data" <?php print $checked['syndicated_posts:meta_data']; ?> /> as syndication meta-data is added on the post</label></li> -</ul></td> -</tr> + <?php foreach ($fields as $section => $ul) : ?> + <tr> + <th scope="row"><?php print esc_html($section); ?>:</th> + <td><p>Show a diagnostic message...</p> + <ul class="options"> + <?php foreach ($ul as $key => $label) : ?> + <li><label><input + type="checkbox" name="diagnostics_show[]" + value="<?php print esc_html($key); ?>" + <?php print $checked[$key]; ?> /> + <?php print $label; ?></label></li> + <?php endforeach; ?> + </ul></td> + </tr> + <?php endforeach; ?> </table> <?php } /* FeedWordPressDiagnosticsPage::updates_box () */ diff --git a/wp-content/plugins/feedwordpress/feedfinder.class.php b/wp-content/plugins/feedwordpress/feedfinder.class.php index aef508dc098447c67e195977429ed88280c305e9..97a85f58f57fd6671db061c6ad218521fcecf517 100644 --- a/wp-content/plugins/feedwordpress/feedfinder.class.php +++ b/wp-content/plugins/feedwordpress/feedfinder.class.php @@ -165,7 +165,7 @@ class FeedFinder { // Use WordPress API function $client = wp_remote_request($this->uri, array( 'headers' => $headers, - 'timeout' => FEEDWORDPRESS_FETCH_TIME_OUT, + 'timeout' => FeedWordPress::fetch_timeout(), )); $this->_response = $client; diff --git a/wp-content/plugins/feedwordpress/feeds-page.php b/wp-content/plugins/feedwordpress/feeds-page.php index 953ce4d6f80d0c27300b3a7d5e25145b9cc335fa..c96537c504acc68f180fe3ed991571cd5ff8e2bd 100644 --- a/wp-content/plugins/feedwordpress/feeds-page.php +++ b/wp-content/plugins/feedwordpress/feeds-page.php @@ -47,31 +47,10 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage { ); var $updatedPosts = NULL; - /** - * Constructs the Feeds page object - * - * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings - */ - function FeedWordPressFeedsPage ($link = -1) { - if (is_numeric($link) and -1 == $link) : - $link = FeedWordPressAdminPage::submitted_link(); - endif; - - FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressfeeds', $link); - - $this->dispatch = 'feedwordpress_admin_page_feeds'; - $this->pagenames = array( - 'default' => 'Feeds', - 'settings-update' => 'Syndicated feed', - 'open-sheet' => 'Feed and Update', - ); - $this->filename = __FILE__; - $this->updatedPosts = new UpdatedPostsControl($this); - } /* FeedWordPressFeedsPage constructor */ - var $special_settings = array ( /* Regular expression syntax is OK here */ 'cats', 'cat_split', + 'fetch timeout', 'freeze updates', 'hardcode name', 'hardcode url', @@ -84,6 +63,7 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage { 'ping status', 'post status', 'postmeta', + 'query parameters', 'resolve relative', 'syndicated post type', 'tags', @@ -91,12 +71,37 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage { 'unfamliar categories', /* Deprecated */ 'unfamiliar category', 'unfamiliar post_tag', + 'add/.*', 'update/.*', 'feed/.*', 'link/.*', 'match/.*', ); + /** + * Constructs the Feeds page object + * + * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings + */ + function FeedWordPressFeedsPage ($link = -1) { + if (is_numeric($link) and -1 == $link) : + $link = FeedWordPressAdminPage::submitted_link(); + endif; + + FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressfeeds', $link); + + $this->dispatch = 'feedwordpress_admin_page_feeds'; + $this->pagenames = array( + 'default' => 'Feeds', + 'settings-update' => 'Syndicated feed', + 'open-sheet' => 'Feed and Update', + ); + $this->filename = __FILE__; + $this->updatedPosts = new UpdatedPostsControl($this); + + $this->special_settings = apply_filters('syndicated_feed_special_settings', $this->special_settings, $this); + } /* FeedWordPressFeedsPage constructor */ + function display () { global $fwp_post; global $post_source; @@ -106,6 +111,7 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage { 'global_feeds_box' => __('Update Scheduling'), 'updated_posts_box' => __('Updated Posts'), 'custom_settings_box' => __('Custom Feed Settings (for use in templates)'), + 'fetch_settings_box' => __('Settings for Fetching Feeds (Advanced)'), ); if ($this->for_default_settings()) : unset($this->boxes_by_methods['custom_settings_box']); @@ -298,8 +304,47 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage { return sprintf(__($caption), $updateWindow); } /* FeedWordPressFeedsPage::update_window_currently () */ + function fetch_timeout_setting ($setting, $defaulted, $params) { + $timeout = intval($this->setting('fetch timeout', FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT)); + + if ($this->for_feed_settings()) : + $article = 'this'; + else : + $article = 'a'; + endif; + ?> + <p>Wait no more than + than <input name="fetch_timeout" type="number" min="0" size="3" value="<?php print $timeout; ?>" /> + second(s) when trying to fetch <?php print $article; ?> feed to check for updates.</p> + <p>If <?php print $article; ?> source's web server does not respond before time runs + out, FeedWordPress will skip over the source and try again during + the next update cycle.</p> + <?php + } + function fetch_timeout_setting_value ($setting, $defaulted, $params) { + print number_format(intval($setting)) . " " . (($setting==1) ? "second" : "seconds"); + } + + function fetch_settings_box ($page, $box = NULL) { + $this->setting_radio_control( + 'fetch timeout', 'fetch_timeout', + array(&$this, 'fetch_timeout_setting'), + array( + 'global-setting-default' => FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT, + 'input-name' => 'fetch_timeout', + 'default-input-name' => 'fetch_timeout_default', + 'labels' => array(&$this, 'fetch_timeout_setting_value'), + ) + ); + } /* FeedWordPressFeedsPage::fetch_settings_box () */ + function feed_information_box ($page, $box = NULL) { global $wpdb; + $link_rss_params = maybe_unserialize($page->setting('query parameters', '')); + if (!is_array($link_rss_params)) : + $link_rss_params = array(); + endif; + if ($page->for_feed_settings()) : $info['name'] = esc_html($page->link->link->link_name); $info['description'] = esc_html($page->link->link->link_description); @@ -353,7 +398,69 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage { <td><a href="<?php echo esc_html($rss_url); ?>"><?php echo esc_html($rss_url); ?></a> (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($rss_url); ?>" title="Check feed <<?php echo esc_html($rss_url); ?>> for validity">validate</a>) - <input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" /></td> + <input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" /> + + <table id="link-rss-params"> + <tbody> + <?php + $link_rss_params['new'] = array('', ''); + $i = 0; + foreach ($link_rss_params as $index => $pair) : + ?> + <tr class="link-rss-params-row" id="link-rss-params-<?php print $index; ?>"> + <td><label>Parameter: <input type="text" class="link_params_key" + name="link_rss_params_key[<?php print $index; ?>]" value="<?php print esc_html($pair[0]); ?>" + size="5" style="width: 5em" placeholder="name" /></label></td> + <td class="link-rss-params-value-cell"><label class="link_params_value_label">= <input type="text" class="link_params_value" + name="link_rss_params_value[<?php print $index; ?>]" value="<?php print esc_html($pair[1]); ?>" + size="8" placeholder="value" /></label></td> + </tr> + <?php + $i++; + endforeach; + ?> + </tbody> + </table> + + <div><input type="hidden" id="link-rss-params-num" name="link_rss_params_num" value="<?php print $i; ?>" /></div> + + <script type="text/javascript"> + function linkParamsRowRemove (element) { + jQuery(element).closest('tr').fadeOut('slow', function () { + jQuery(this).remove(); + } ); + } + + jQuery('<td><a href="#" class="add-remove link-rss-params-remove"><span class="x">(X)</span> Remove</a></td>').insertAfter('.link-rss-params-value-cell'); + + jQuery('#link-rss-params-new').hide(); + jQuery('<a class="add-remove" id="link-rss-params-add" href="#">+ Add a query parameter</a>').insertAfter('#link-rss-params'); + jQuery('#link-rss-params-add').click( function () { + var next = jQuery('#link-rss-params-num').val(); + var newRow = jQuery('#link-rss-params-new').clone().attr('id', 'link-rss-params-'+next); + newRow.find('.link_params_key').attr('name', 'link_rss_params_key['+next+']'); + newRow.find('.link_params_value').attr('name', 'link_rss_params_value['+next+']'); + + newRow.find('.link-rss-params-remove').click( function () { + linkParamsRowRemove(this); + return false; + } ); + + newRow.appendTo('#link-rss-params'); + newRow.show(); + + // Update counter for next row. + next++; + jQuery('#link-rss-params-num').val(next); + + return false; + } ); + jQuery('.link-rss-params-remove').click( function () { + linkParamsRowRemove(this); + return false; + } ); + </script> + </td> </tr> <?php @@ -735,6 +842,20 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage { function save_settings ($post) { if ($this->for_feed_settings()) : + if (isset($post['link_rss_params_key'])) : + $qp = array(); + foreach ($post['link_rss_params_key'] as $index => $key) : + if (strlen($key) > 0) : + if (isset($post['link_rss_params_value'][$index]) + and strlen($post['link_rss_params_value'][$index])) : + $value = $post['link_rss_params_value'][$index]; + $qp[] = array($key, $value); + endif; + endif; + endforeach; + $this->update_setting('query parameters', serialize($qp)); + endif; + // custom feed settings first foreach ($post['notes'] as $mn) : $mn['key0'] = (isset($mn['key0']) ? trim($mn['key0']) : NULL); @@ -803,6 +924,20 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage { $hardcode = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes'); update_option("feedwordpress_hardcode_{$what}", $hardcode); endforeach; + + endif; + + if (isset($post['fetch_timeout'])) : + if (isset($post['fetch_timeout_default']) and $post['fetch_timeout_default']=='yes') : + $timeout = NULL; + else : + $timeout = $post['fetch_timeout']; + endif; + + if (is_int($timeout)) : + $timeout = intval($timeout); + endif; + $this->update_setting('fetch timeout', $timeout); endif; $this->updatedPosts->accept_POST($post); diff --git a/wp-content/plugins/feedwordpress/feedtime.class.php b/wp-content/plugins/feedwordpress/feedtime.class.php index 2a33d540cbb9043aaab7dea5eb7ae47f03a30fb4..7aab3388fa8d6f9a9243b24fdd98b636119c1c46 100644 --- a/wp-content/plugins/feedwordpress/feedtime.class.php +++ b/wp-content/plugins/feedwordpress/feedtime.class.php @@ -103,13 +103,17 @@ class FeedTime { if ( isset($match[15]) and $match[15] == 'Z' ) : # zulu time, aka GMT else : - $tz_mod = $match[12]; - $tz_hour = $match[13]; - $tz_min = $match[14]; + $tz_mod = (isset($match[12]) ? $match[12] : NULL); + $tz_hour = (isset($match[13]) ? $match[13] : NULL); + $tz_min = (isset($match[14]) ? $match[14] : NULL); # zero out the variables - if ( ! $tz_hour ) { $tz_hour = 0; } - if ( ! $tz_min ) { $tz_min = 0; } + if ( is_null($tz_hour) ) : + $offset = (int) get_option('gmt_offset'); + $tz_hour = abs($offset); + $tz_mod = ((abs($offset) != $offset) ? '-' : '+'); + endif; + if ( is_null($tz_min) ) : $tz_min = 0; endif; $offset_secs = (($tz_hour*60)+$tz_min)*60; diff --git a/wp-content/plugins/feedwordpress/feedwordpress-elements.css b/wp-content/plugins/feedwordpress/feedwordpress-elements.css index 9d5f78475b52c47bb174a343b4c0b8653e02b200..f575a51fb741b8c4dd8c478713f5299730f0b10f 100644 --- a/wp-content/plugins/feedwordpress/feedwordpress-elements.css +++ b/wp-content/plugins/feedwordpress/feedwordpress-elements.css @@ -379,3 +379,36 @@ table.twofer td.secondary { padding-left: 10px; width: 30%; } background-color: #FFFFD0; } +#feedwordpress-admin-feeds .add-remove, .feedwordpress-admin .remove-it { + padding-left: 1.5em; + font-size: 0.80em; + text-transform: uppercase; + text-decoration: none !important; + vertical-align: middle; +} + +#feedwordpress-admin-feeds .link-rss-params-row { vertical-align: middle; } +#feedwordpress-admin-feeds .link-rss-params-remove, .feedwordpress-admin .remove-it { + display: block; + padding-left: 0em !important; + margin-top: 7px; + color: #777; +} + +#feedwordpress-admin-feeds .link-rss-params-remove:hover, .feedwordpress-admin .remove-it:hover { + color: #aa3030; +} + +#feedwordpress-admin-feeds .link-rss-params-remove .x, .feedwordpress-admin .remove-it .x { + cursor: pointer; + display: block; + float: left; + width: 10px; height: 10px; + margin-right: 2px; + overflow: hidden; + text-indent: -9999px; +} + + +#feedwordpress-admin-feeds #link-rss-params td { width: auto !important; } + diff --git a/wp-content/plugins/feedwordpress/feedwordpress-walker-category-checklist.class.php b/wp-content/plugins/feedwordpress/feedwordpress-walker-category-checklist.class.php index b645ca46c0d166a54e96e157d5a7d93616cca544..e78a2099510c9cc199f55d2b2f9c133784b279c6 100644 --- a/wp-content/plugins/feedwordpress/feedwordpress-walker-category-checklist.class.php +++ b/wp-content/plugins/feedwordpress/feedwordpress-walker-category-checklist.class.php @@ -12,8 +12,13 @@ require_once(ABSPATH.'/wp-admin/includes/template.php'); class FeedWordPress_Walker_Category_Checklist extends Walker_Category_Checklist { var $prefix = ''; var $taxonomy = 'category'; - function FeedWordPress_Walker_Category_Checklist () { + var $checkbox_name = NULL; + function FeedWordPress_Walker_Category_Checklist ($params = array()) { $this->set_taxonomy('category'); + + if (isset($params['checkbox_name'])) : + $this->checkbox_name = $params['checkbox_name']; + endif; } function set_prefix ($prefix) { @@ -29,7 +34,9 @@ class FeedWordPress_Walker_Category_Checklist extends Walker_Category_Checklist $taxonomy = 'category'; endif; - if ($taxonomy=='category') : + if (!is_null($this->checkbox_name)) : + $name = $this->checkbox_name; + elseif ($taxonomy=='category') : $name = 'post_category'; else : $name = 'tax_input['.$taxonomy.']'; diff --git a/wp-content/plugins/feedwordpress/feedwordpress.php b/wp-content/plugins/feedwordpress/feedwordpress.php index 57b7d8caca4faa1faf27ffa41310c59634574bf1..32024cff123501a05fdb7af004c70dda5db7d957 100644 --- a/wp-content/plugins/feedwordpress/feedwordpress.php +++ b/wp-content/plugins/feedwordpress/feedwordpress.php @@ -3,7 +3,7 @@ Plugin Name: FeedWordPress Plugin URI: http://feedwordpress.radgeek.com/ Description: simple and flexible Atom/RSS syndication for WordPress -Version: 2010.1007 +Version: 2011.0211.2 Author: Charles Johnson Author URI: http://radgeek.com/ License: GPL @@ -11,7 +11,7 @@ License: GPL /** * @package FeedWordPress - * @version 2010.1007 + * @version 2011.0211.2 */ # This uses code derived from: @@ -34,7 +34,7 @@ License: GPL # -- Don't change these unless you know what you're doing... -define ('FEEDWORDPRESS_VERSION', '2010.1007'); +define ('FEEDWORDPRESS_VERSION', '2011.0211.2'); define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact'); if (!defined('FEEDWORDPRESS_BLEG')) : @@ -86,13 +86,13 @@ if (FEEDWORDPRESS_DEBUG) : // used for more than testing purposes! define('FEEDWORDPRESS_CACHE_AGE', 1); define('FEEDWORDPRESS_CACHE_LIFETIME', 1); - define('FEEDWORDPRESS_FETCH_TIME_OUT', 60); + define('FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT', 60); else : // Hold onto data all day for conditional GET purposes, // but consider it stale after 1 min (requiring a conditional GET) define('FEEDWORDPRESS_CACHE_LIFETIME', 24*60*60); define('FEEDWORDPRESS_CACHE_AGE', 1*60); - define('FEEDWORDPRESS_FETCH_TIME_OUT', 10); + define('FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT', 20); endif; // Use our the cache settings that we want. @@ -105,7 +105,9 @@ if (!class_exists('SimplePie')) : endif; require_once(ABSPATH . WPINC . '/class-feed.php'); -require_once (ABSPATH . WPINC . '/registration.php'); // for wp_insert_user +if (!function_exists('wp_insert_user')) : + require_once (ABSPATH . WPINC . '/registration.php'); // for wp_insert_user +endif; require_once(dirname(__FILE__) . '/admin-ui.php'); require_once(dirname(__FILE__) . '/feedwordpresssyndicationpage.class.php'); @@ -118,7 +120,10 @@ require_once(dirname(__FILE__) . '/feedwordpress-content-type-sniffer.class.php' // Magic quotes are just about the stupidest thing ever. if (is_array($_POST)) : - $fwp_post = stripslashes_deep($_POST); + $fwp_post = $_POST; + if (get_magic_quotes_gpc()) : + $fwp_post = stripslashes_deep($fwp_post); + endif; endif; // Get the path relative to the plugins directory in which FWP is stored @@ -274,7 +279,8 @@ class FeedWordPressDiagnostic { $users = get_users_of_blog($id); $recipients = array(); foreach ($users as $user) : - $dude = new WP_User($user->user_id); + $user_id = (isset($user->user_id) ? $user->user_id : $user->ID); + $dude = new WP_User($user_id); if ($dude->has_cap('administrator')) : if ($dude->user_email) : $recipients[] = $dude->user_email; @@ -674,21 +680,53 @@ function syndication_comments_feed_link ($link) { ################################################################################ function fwp_add_pages () { - global $fwp_path; - - add_menu_page('Syndicated Sites', 'Syndication', 'manage_links', $fwp_path.'/syndication.php', NULL, WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress-tiny.png'); - do_action('feedwordpress_admin_menu_pre_feeds'); - add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Feeds & Updates', 'Feeds & Updates', 'manage_options', $fwp_path.'/feeds-page.php'); - do_action('feedwordpress_admin_menu_pre_posts'); - add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Posts & Links', 'Posts & Links', 'manage_options', $fwp_path.'/posts-page.php'); - do_action('feedwordpress_admin_menu_pre_authors'); - add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Authors', 'Authors', 'manage_options', $fwp_path.'/authors-page.php'); - do_action('feedwordpress_admin_menu_pre_categories'); - add_submenu_page($fwp_path.'/syndication.php', 'Categories'.FEEDWORDPRESS_AND_TAGS, 'Categories'.FEEDWORDPRESS_AND_TAGS, 'manage_options', $fwp_path.'/categories-page.php'); - do_action('feedwordpress_admin_menu_pre_performance'); - add_submenu_page($fwp_path.'/syndication.php', 'FeedWordPress Performance', 'Performance', 'manage_options', $fwp_path.'/performance-page.php'); - do_action('feedwordpress_admin_menu_pre_diagnostics'); - add_submenu_page($fwp_path.'/syndication.php', 'FeedWordPress Diagnostics', 'Diagnostics', 'manage_options', $fwp_path.'/diagnostics-page.php'); + $menu_cap = FeedWordPress::menu_cap(); + $settings_cap = FeedWordPress::menu_cap(/*sub=*/ true); + $syndicationMenu = FeedWordPress::path('syndication.php'); + + add_menu_page( + 'Syndicated Sites', 'Syndication', + $menu_cap, + $syndicationMenu, + NULL, + WP_PLUGIN_URL.'/'.FeedWordPress::path('feedwordpress-tiny.png') + ); + + do_action('feedwordpress_admin_menu_pre_feeds', $menu_cap, $settings_cap); + add_submenu_page( + $syndicationMenu, 'Syndicated Feeds & Updates', 'Feeds & Updates', + $settings_cap, FeedWordPress::path('feeds-page.php') + ); + + do_action('feedwordpress_admin_menu_pre_posts', $menu_cap, $settings_cap); + add_submenu_page( + $syndicationMenu, 'Syndicated Posts & Links', 'Posts & Links', + $settings_cap, FeedWordPress::path('posts-page.php') + ); + + do_action('feedwordpress_admin_menu_pre_authors', $menu_cap, $settings_cap); + add_submenu_page( + $syndicationMenu, 'Syndicated Authors', 'Authors', + $settings_cap, FeedWordPress::path('authors-page.php') + ); + + do_action('feedwordpress_admin_menu_pre_categories', $menu_cap, $settings_cap); + add_submenu_page( + $syndicationMenu, 'Categories'.FEEDWORDPRESS_AND_TAGS, 'Categories'.FEEDWORDPRESS_AND_TAGS, + $settings_cap, FeedWordPress::path('categories-page.php') + ); + + do_action('feedwordpress_admin_menu_pre_performance', $menu_cap, $settings_cap); + add_submenu_page( + $syndicationMenu, 'FeedWordPress Performance', 'Performance', + $settings_cap, FeedWordPress::path('performance-page.php') + ); + + do_action('feedwordpress_admin_menu_pre_diagnostics', $menu_cap, $settings_cap); + add_submenu_page( + $syndicationMenu, 'FeedWordPress Diagnostics', 'Diagnostics', + $settings_cap, FeedWordPress::path('diagnostics-page.php') + ); } /* function fwp_add_pages () */ function fwp_check_debug () { @@ -1036,54 +1074,58 @@ class FeedWordPress { } /* FeedWordPress::init() */ function dashboard_setup () { - // Get the stylesheet - wp_enqueue_style('feedwordpress-elements'); - - $widget_id = 'feedwordpress_dashboard'; - $widget_name = __('Syndicated Sources'); - $column = 'side'; - $priority = 'core'; - - // I would love to use wp_add_dashboard_widget() here and save - // myself some trouble. But WP 3 does not yet have any way to - // push a dashboard widget onto the side, or to give it a default - // location. - add_meta_box( - /*id=*/ $widget_id, - /*title=*/ $widget_name, - /*callback=*/ array(&$this, 'dashboard'), - /*page=*/ 'dashboard', - /*context=*/ $column, - /*priority=*/ $priority - ); - /*control_callback= array(&$this, 'dashboard_control') */ + $see_it = FeedWordPress::menu_cap(); - // This is kind of rude, I know, but the dashboard widget isn't - // worth much if users don't know that it exists, and I don't - // know of any better way to reorder the boxen. - // - // Gleefully ripped off of codex.wordpress.org/Dashboard_Widgets_API + if (current_user_can($see_it)) : + // Get the stylesheet + wp_enqueue_style('feedwordpress-elements'); + + $widget_id = 'feedwordpress_dashboard'; + $widget_name = __('Syndicated Sources'); + $column = 'side'; + $priority = 'core'; + + // I would love to use wp_add_dashboard_widget() here and save + // myself some trouble. But WP 3 does not yet have any way to + // push a dashboard widget onto the side, or to give it a default + // location. + add_meta_box( + /*id=*/ $widget_id, + /*title=*/ $widget_name, + /*callback=*/ array(&$this, 'dashboard'), + /*page=*/ 'dashboard', + /*context=*/ $column, + /*priority=*/ $priority + ); + /*control_callback= array(&$this, 'dashboard_control') */ + + // This is kind of rude, I know, but the dashboard widget isn't + // worth much if users don't know that it exists, and I don't + // know of any better way to reorder the boxen. + // + // Gleefully ripped off of codex.wordpress.org/Dashboard_Widgets_API + + // Globalize the metaboxes array, this holds all the widgets for wp-admin + global $wp_meta_boxes; + + // Get the regular dashboard widgets array + // (which has our new widget already but at the end) + + $normal_dashboard = $wp_meta_boxes['dashboard'][$column][$priority]; - // Globalize the metaboxes array, this holds all the widgets for wp-admin - global $wp_meta_boxes; - - // Get the regular dashboard widgets array - // (which has our new widget already but at the end) - - $normal_dashboard = $wp_meta_boxes['dashboard'][$column][$priority]; + // Backup and delete our new dashbaord widget from the end of the array + if (isset($normal_dashboard[$widget_id])) : + $backup = array(); + $backup[$widget_id] = $normal_dashboard[$widget_id]; + unset($normal_dashboard[$widget_id]); - // Backup and delete our new dashbaord widget from the end of the array - if (isset($normal_dashboard[$widget_id])) : - $backup = array(); - $backup[$widget_id] = $normal_dashboard[$widget_id]; - unset($normal_dashboard[$widget_id]); - - // Merge the two arrays together so our widget is at the - // beginning - $sorted_dashboard = array_merge($backup, $normal_dashboard); - - // Save the sorted array back into the original metaboxes - $wp_meta_boxes['dashboard'][$column][$priority] = $sorted_dashboard; + // Merge the two arrays together so our widget is at the + // beginning + $sorted_dashboard = array_merge($backup, $normal_dashboard); + + // Save the sorted array back into the original metaboxes + $wp_meta_boxes['dashboard'][$column][$priority] = $sorted_dashboard; + endif; endif; } /* FeedWordPress::dashboard_setup () */ @@ -1179,7 +1221,12 @@ class FeedWordPress { function syndicate_link ($name, $uri, $rss) { // Get the category ID# $cat_id = FeedWordPress::link_category_id(); - + if (!is_wp_error($cat_id)) : + $link_category = array($cat_id); + else : + $link_category = array(); + endif; + // WordPress gets cranky if there's no homepage URI if (!is_string($uri) or strlen($uri)<1) : $uri = $rss; endif; @@ -1189,7 +1236,7 @@ class FeedWordPress { "link_rss" => $rss, "link_name" => $name, "link_url" => $uri, - "link_category" => array($cat_id), + "link_category" => $link_category, "link_visible" => 'Y', // reactivate if inactivated )); @@ -1252,10 +1299,14 @@ class FeedWordPress { function syndicated_links ($args = array()) { $contributors = FeedWordPress::link_category_id(); - $links = get_bookmarks(array_merge( - array("category" => $contributors), - $args - )); + if (!is_wp_error($contributors)) : + $links = get_bookmarks(array_merge( + array("category" => $contributors), + $args + )); + else : + $links = array(); + endif; return $links; } // function FeedWordPress::syndicated_links() @@ -1282,9 +1333,10 @@ class FeedWordPress { // make a new one for ourselves. if (!$cat_id) : $cat_id = FeedWordPressCompatibility::insert_link_category(DEFAULT_SYNDICATION_CATEGORY); - - // Stamp it - update_option('feedwordpress_cat_id', $cat_id); + if (!is_wp_error($cat_id)) : + // Stamp it + update_option('feedwordpress_cat_id', $cat_id); + endif; endif; return $cat_id; @@ -1413,17 +1465,43 @@ class FeedWordPress { "); } - /*static*/ function fetch ($url, $force_feed = true) { + /*static*/ function fetch_timeout () { + return apply_filters( + 'feedwordpress_fetch_timeout', + intval(get_option('feedwordpress_fetch_timeout', FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT)) + ); + } + + /*static*/ function fetch ($url, $params = array()) { + $force_feed = true; // Default + + // Allow user to change default feed-fetch timeout with a global setting. Props Erigami Scholey-Fuller <http://www.piepalace.ca/blog/2010/11/feedwordpress-broke-my-heart.html> 'timeout' => + $timeout = FeedWordPress::fetch_timeout(); + + if (!is_array($params)) : + $force_feed = $params; + else : // Parameter array + $args = shortcode_atts(array( + 'force_feed' => $force_feed, + 'timeout' => $timeout + ), $params); + + extract($args); + endif; + $timeout = intval($timeout); + $pie_class = apply_filters('feedwordpress_simplepie_class', 'SimplePie'); $cache_class = apply_filters('feedwordpress_cache_class', 'WP_Feed_Cache'); $file_class = apply_filters('feedwordpress_file_class', 'FeedWordPress_File'); $parser_class = apply_filters('feedwordpress_parser_class', 'FeedWordPress_Parser'); $sniffer_class = apply_filters('feedwordpress_sniffer_class', 'FeedWordPress_Content_Type_Sniffer'); - + $feed = new $pie_class; $feed->set_feed_url($url); $feed->set_cache_class($cache_class); + $feed->set_timeout($timeout); + //$feed->set_file_class('WP_SimplePie_File'); $feed->set_content_type_sniffer_class($sniffer_class); $feed->set_file_class($file_class); @@ -1584,22 +1662,6 @@ class FeedWordPress { function email_diagnostic_log () { $dlog = get_option('feedwordpress_diagnostics_log', array()); - - $ded = get_option('feedwordpress_diagnostics_email_destination', 'admins'); - - // e-mail address - if (preg_match('/^mailto:(.*)$/', $ded, $ref)) : - $recipients = array($ref[1]); - - // userid - elseif (preg_match('/^user:(.*)$/', $ded, $ref)) : - $userdata = get_userdata((int) $ref[1]); - $recipients = array($userdata->user_email); - - // admins - else : - $recipients = FeedWordPressDiagnostic::admin_emails(); - endif; if (isset($dlog['schedule']) and isset($dlog['schedule']['last'])) : if (time() > ($dlog['schedule']['last'] + $dlog['schedule']['freq'])) : @@ -1663,6 +1725,23 @@ $body </html> EOMAIL; + + $ded = get_option('feedwordpress_diagnostics_email_destination', 'admins'); + + // e-mail address + if (preg_match('/^mailto:(.*)$/', $ded, $ref)) : + $recipients = array($ref[1]); + + // userid + elseif (preg_match('/^user:(.*)$/', $ded, $ref)) : + $userdata = get_userdata((int) $ref[1]); + $recipients = array($userdata->user_email); + + // admins + else : + $recipients = FeedWordPressDiagnostic::admin_emails(); + endif; + foreach ($recipients as $email) : add_filter('wp_mail_content_type', array('FeedWordPress', 'allow_html_mail')); wp_mail($email, $subj, $body); @@ -1707,6 +1786,25 @@ EOMAIL; return $prefix; } /* FeedWordPress::log_prefix () */ + function menu_cap ($sub = false) { + if ($sub) : + $cap = apply_filters('feedwordpress_menu_settings_capacity', 'manage_options'); + else : + $cap = apply_filters('feedwordpress_menu_main_capacity', 'manage_links'); + endif; + return $cap; + } /* FeedWordPress::menu_cap () */ + + function path ($filename = '') { + global $fwp_path; + + $path = $fwp_path; + if (strlen($filename) > 0) : + $path .= '/'.$filename; + endif; + return $path; + } + function param ($key, $type = 'REQUEST', $default = NULL) { $where = '_'.strtoupper($type); $ret = $default; @@ -1714,7 +1812,7 @@ EOMAIL; if (isset($GLOBALS[$where][$key])) : $ret = $GLOBALS[$where][$key]; if (get_magic_quotes_gpc()) : - $ret = stripslashes($ret); + $ret = stripslashes_deep($ret); endif; endif; endif; diff --git a/wp-content/plugins/feedwordpress/feedwordpresssyndicationpage.class.php b/wp-content/plugins/feedwordpress/feedwordpresssyndicationpage.class.php index 2d22d1ecdc32a4b11e894ae3da7b221817104df6..99b24d9dfb4980c7691b5143e0edf79b8e75c58b 100644 --- a/wp-content/plugins/feedwordpress/feedwordpresssyndicationpage.class.php +++ b/wp-content/plugins/feedwordpress/feedwordpresssyndicationpage.class.php @@ -1004,7 +1004,9 @@ function fwp_dashboard_update_if_requested ($object) { $tdelta['updated'] += $delta['updated']; endif; else : - echo "<li><p><strong>Error:</strong> There was a problem updating <a href=\"$uri\">$uri</a></p></li>\n"; + $display_uri = esc_html(feedwordpress_display_url($uri)); + $uri = esc_html($uri); + echo "<li><p><strong>Error:</strong> There was a problem updating <code><a href=\"$uri\">${display_uri}</a></code></p></li>\n"; endif; endforeach; echo "</ul>\n"; diff --git a/wp-content/plugins/feedwordpress/readme.txt b/wp-content/plugins/feedwordpress/readme.txt index ec5a052a0539a1d9a2bb7b5905e3608beeb01be5..0219e2fe9a52275b49e7d9d5fdb6423b1ab5f8e6 100644 --- a/wp-content/plugins/feedwordpress/readme.txt +++ b/wp-content/plugins/feedwordpress/readme.txt @@ -3,8 +3,8 @@ Contributors: Charles Johnson Donate link: http://feedwordpress.radgeek.com/ Tags: syndication, aggregation, feed, atom, rss Requires at least: 3.0 -Tested up to: 3.0.1 -Stable tag: 2010.0905 +Tested up to: 3.0.5 +Stable tag: 2011.0211.2 FeedWordPress syndicates content from feeds you choose into your WordPress weblog. diff --git a/wp-content/plugins/feedwordpress/syndicatedlink.class.php b/wp-content/plugins/feedwordpress/syndicatedlink.class.php index 784071308e949f36666da864ef590cc86d4742b8..c1a45732e337ae27f95c277b2f745e9629b765f4 100644 --- a/wp-content/plugins/feedwordpress/syndicatedlink.class.php +++ b/wp-content/plugins/feedwordpress/syndicatedlink.class.php @@ -112,14 +112,34 @@ class SyndicatedLink { endforeach; if (isset($this->settings['terms'])) : - $this->settings['terms'] = explode(FEEDWORDPRESS_CAT_SEPARATOR.FEEDWORDPRESS_CAT_SEPARATOR, $this->settings['terms']); - $terms = array(); - foreach ($this->settings['terms'] as $line) : - $line = explode(FEEDWORDPRESS_CAT_SEPARATOR, $line); - $tax = array_shift($line); - $terms[$tax] = $line; - endforeach; - $this->settings['terms'] = $terms; + // Look for new format + $this->settings['terms'] = maybe_unserialize($this->settings['terms']); + + if (!is_array($this->settings['terms'])) : + // Deal with old format instead. Ugh. + + // Split on two *or more* consecutive breaks + // because in the old format, a taxonomy + // without any associated terms would + // produce tax_name#1\n\n\ntax_name#2\nterm, + // and the naive split on the first \n\n + // would screw up the tax_name#2 list. + // + // Props to David Morris for pointing this + // out. + + $this->settings['terms'] = preg_split( + "/".FEEDWORDPRESS_CAT_SEPARATOR."{2,}/", + $this->settings['terms'] + ); + $terms = array(); + foreach ($this->settings['terms'] as $line) : + $line = explode(FEEDWORDPRESS_CAT_SEPARATOR, $line); + $tax = array_shift($line); + $terms[$tax] = $line; + endforeach; + $this->settings['terms'] = $terms; + endif; endif; if (isset($this->settings['map authors'])) : @@ -163,11 +183,14 @@ class SyndicatedLink { function poll ($crash_ts = NULL) { global $wpdb; - FeedWordPress::diagnostic('updated_feeds', 'Polling feed ['.$this->link->link_rss.']'); + $url = $this->uri(array('add_params' => true)); + FeedWordPress::diagnostic('updated_feeds', 'Polling feed ['.$url.']'); + + $timeout = $this->setting('fetch timeout', 'feedwordpress_fetch_timeout', FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT); $this->simplepie = apply_filters( 'syndicated_feed', - FeedWordPress::fetch($this->link->link_rss), + FeedWordPress::fetch($url, array('timeout' => $timeout)), $this ); @@ -469,11 +492,8 @@ class SyndicatedLink { endforeach; if (isset($to_notes['terms']) and is_array($to_notes['terms'])) : - $tt = array(); - foreach ($to_notes['terms'] as $tax => $terms) : - $tt[] = $tax.FEEDWORDPRESS_CAT_SEPARATOR.implode(FEEDWORDPRESS_CAT_SEPARATOR, $terms); - endforeach; - $to_notes['terms'] = implode(FEEDWORDPRESS_CAT_SEPARATOR.FEEDWORDPRESS_CAT_SEPARATOR, $tt); + // Serialize it. + $to_notes['terms'] = serialize($to_notes['terms']); endif; // Collapse the author mapping rule structure back into a flat string @@ -531,7 +551,7 @@ class SyndicatedLink { * @param mixed $fallback_value If the link setting and the global setting are nonexistent or marked as a use-default value, fall back to this constant value. * @return bool TRUE on success, FALSE on failure. */ - function setting ($name, $fallback_global = NULL, $fallback_value = NULL) { + function setting ($name, $fallback_global = NULL, $fallback_value = NULL, $default = 'default') { $ret = NULL; if (isset($this->settings[$name])) : $ret = $this->settings[$name]; @@ -539,16 +559,19 @@ class SyndicatedLink { $no_value = ( is_null($ret) - or (is_string($ret) and strtolower($ret)=='default') + or (is_string($ret) and strtolower($ret)==$default) ); if ($no_value and !is_null($fallback_global)) : + // Avoid duplication of this correction + $fallback_global = preg_replace('/^feedwordpress_/', '', $fallback_global); + $ret = get_option('feedwordpress_'.$fallback_global, /*default=*/ NULL); endif; $no_value = ( is_null($ret) - or (is_string($ret) and strtolower($ret)=='default') + or (is_string($ret) and strtolower($ret)==$default) ); if ($no_value and !is_null($fallback_value)) : @@ -565,8 +588,33 @@ class SyndicatedLink { endif; } /* SyndicatedLink::update_setting () */ - function uri () { - return (is_object($this->link) ? $this->link->link_rss : NULL); + function uri ($params = array()) { + $params = shortcode_atts(array( + 'add_params' => false, + ), $params); + + $uri = (is_object($this->link) ? $this->link->link_rss : NULL); + if (!is_null($uri) and strlen($uri) > 0 and $params['add_params']) : + $qp = maybe_unserialize($this->setting('query parameters', array())); + + // For high-tech HTTP feed request kung fu + $qp = apply_filters('syndicated_feed_parameters', $qp, $uri, $this); + + $q = array(); + if (is_array($qp) and count($qp) > 0) : + foreach ($qp as $pair) : + $q[] = urlencode($pair[0]).'='.urlencode($pair[1]); + endforeach; + + // Are we appending to a URI that already has params? + $sep = ((strpos('?', $uri)===false) ? '?' : '&'); + + // Tack it on + $uri .= $sep . implode("&", $q); + endif; + endif; + + return $uri; } /* SyndicatedLink::uri () */ function property_cascade ($fromFeed, $link_field, $setting, $simplepie_method) { diff --git a/wp-content/plugins/feedwordpress/syndicatedpost.class.php b/wp-content/plugins/feedwordpress/syndicatedpost.class.php index 4be045296ae9ad28c3585de7a8d95ac5bb6e4331..df96b783ca948564f1decb0beaae01fd790313e2 100644 --- a/wp-content/plugins/feedwordpress/syndicatedpost.class.php +++ b/wp-content/plugins/feedwordpress/syndicatedpost.class.php @@ -24,6 +24,10 @@ class SyndicatedPost { var $post = array (); + var $named = array (); + var $preset_terms = array (); + var $feed_terms = array (); + var $_freshness = null; var $_wp_id = null; @@ -103,7 +107,7 @@ class SyndicatedPost { $this ); $this->item = $changed; - + # Filters can halt further processing by returning NULL if (is_null($this->item)) : $this->post = NULL; @@ -118,7 +122,7 @@ class SyndicatedPost { $this->entry->get_title(), $this ); - $this->post['named']['author'] = apply_filters( + $this->named['author'] = apply_filters( 'syndicated_item_author', $this->author(), $this ); @@ -135,17 +139,16 @@ class SyndicatedPost { if (!empty($excerpt)): $this->post['post_excerpt'] = $excerpt; endif; - - $this->post['epoch']['issued'] = apply_filters('syndicated_item_published', $this->published(), $this); - $this->post['epoch']['created'] = apply_filters('syndicated_item_created', $this->created(), $this); - $this->post['epoch']['modified'] = apply_filters('syndicated_item_updated', $this->updated(), $this); // Dealing with timestamps in WordPress is so fucking fucked. $offset = (int) get_option('gmt_offset') * 60 * 60; - $this->post['post_date'] = gmdate('Y-m-d H:i:s', apply_filters('syndicated_item_published', $this->published(/*fallback=*/ true, /*default=*/ -1), $this) + $offset); - $this->post['post_modified'] = gmdate('Y-m-d H:i:s', apply_filters('syndicated_item_updated', $this->updated(/*fallback=*/ true, /*default=*/ -1), $this) + $offset); - $this->post['post_date_gmt'] = gmdate('Y-m-d H:i:s', apply_filters('syndicated_item_published', $this->published(/*fallback=*/ true, /*default=*/ -1), $this)); - $this->post['post_modified_gmt'] = gmdate('Y-m-d H:i:s', apply_filters('syndicated_item_updated', $this->updated(/*fallback=*/ true, /*default=*/ -1), $this)); + $post_date_gmt = $this->published(array('default' => -1)); + $post_modified_gmt = $this->updated(array('default' => -1)); + + $this->post['post_date_gmt'] = gmdate('Y-m-d H:i:s', $post_date_gmt); + $this->post['post_date'] = gmdate('Y-m-d H:i:s', $post_date_gmt + $offset); + $this->post['post_modified_gmt'] = gmdate('Y-m-d H:i:s', $post_modified_gmt); + $this->post['post_modified'] = gmdate('Y-m-d H:i:s', $post_modified_gmt + $offset); // Use feed-level preferences or the global default. $this->post['post_status'] = $this->link->syndicated_status('post', 'publish'); @@ -300,7 +303,7 @@ class SyndicatedPost { if (is_array($fc)) : $cats = array_merge($cats, $fc); endif; - $this->post['pretax']['category'] = $cats; + $this->preset_terms['category'] = $cats; // Now add categories from the post, if we have 'em $cats = array(); @@ -325,7 +328,7 @@ class SyndicatedPost { endif; endforeach; endif; - $this->post['taxed']['category'] = apply_filters('syndicated_item_categories', $cats, $this); + $this->feed_terms['category'] = apply_filters('syndicated_item_categories', $cats, $this); // Tags: start with default tags, if any $tags = array(); @@ -338,11 +341,11 @@ class SyndicatedPost { if (is_array($ft)) : $tags = array_merge($tags, $ft); endif; - $this->post['pretax']['post_tag'] = $tags; + $this->preset_terms['post_tag'] = $tags; // Scan post for /a[@rel='tag'] and use as tags if present $tags = $this->inline_tags(); - $this->post['taxed']['post_tag'] = apply_filters('syndicated_item_tags', $tags, $this); + $this->feed_terms['post_tag'] = apply_filters('syndicated_item_tags', $tags, $this); $taxonomies = $this->link->taxonomies(); $feedTerms = $this->link->setting('terms', NULL, array()); @@ -366,7 +369,7 @@ class SyndicatedPost { endif; // That's all, folks. - $this->post['pretax'][$tax] = $terms; + $this->preset_terms[$tax] = $terms; endif; endforeach; @@ -636,7 +639,10 @@ class SyndicatedPost { return $permalink; } - function created () { + function created ($params = array()) { + $unfiltered = false; $default = NULL; + extract($params); + $date = ''; if (isset($this->item['dc']['created'])) : $date = $this->item['dc']['created']; @@ -646,13 +652,24 @@ class SyndicatedPost { $date = $this->item['created']; endif; - $epoch = new FeedTime($date); - return $epoch->timestamp(); + $time = new FeedTime($date); + $ts = $time->timestamp(); + if (!$unfiltered) : + apply_filters('syndicated_item_created', $ts, $this); + endif; + return $ts; } /* SyndicatedPost::created() */ - function published ($fallback = true, $default = NULL) { + function published ($params = array(), $default = NULL) { + $fallback = true; $unfiltered = false; + if (!is_array($params)) : // Old style + $fallback = $params; + else : // New style + extract($params); + endif; + $date = ''; - $epoch = null; + $ts = null; # RSS is a fucking mess. Figure out whether we have a date in # <dc:date>, <issued>, <pubDate>, etc., and get it into Unix @@ -672,26 +689,36 @@ class SyndicatedPost { if (strlen($date) > 0) : $time = new FeedTime($date); - $epoch = $time->timestamp(); + $ts = $time->timestamp(); elseif ($fallback) : // Fall back to <updated> / <modified> if present - $epoch = $this->updated(/*fallback=*/ false, /*default=*/ $default); + $ts = $this->updated(/*fallback=*/ false, /*default=*/ $default); endif; # If everything failed, then default to the current time. - if (is_null($epoch)) : + if (is_null($ts)) : if (-1 == $default) : - $epoch = time(); + $ts = time(); else : - $epoch = $default; + $ts = $default; endif; endif; - return $epoch; + if (!$unfiltered) : + $ts = apply_filters('syndicated_item_published', $ts, $this); + endif; + return $ts; } /* SyndicatedPost::published() */ - function updated ($fallback = true, $default = -1) { + function updated ($params = array(), $default = -1) { + $fallback = true; $unfiltered = false; + if (!is_array($params)) : // Old style + $fallback = $params; + else : // New style + extract($params); + endif; + $date = ''; - $epoch = null; + $ts = null; # As far as I know, only dcterms and Atom have reliable ways to # specify when something was *modified* last. If neither is @@ -702,27 +729,30 @@ class SyndicatedPost { $date = $this->item['dcterms']['modified']; elseif (isset($this->item['modified'])): // Atom 0.3 $date = $this->item['modified']; - elseif (isset($this->item['updated'])): // Atom 1.0 + elseif (isset($this->item['updated'])): // Atom 1.0 $date = $this->item['updated']; endif; if (strlen($date) > 0) : $time = new FeedTime($date); - $epoch = $time->timestamp(); + $ts = $time->timestamp(); elseif ($fallback) : // Fall back to issued / dc:date - $epoch = $this->published(/*fallback=*/ false, /*default=*/ $default); + $ts = $this->published(/*fallback=*/ false, /*default=*/ $default); endif; # If everything failed, then default to the current time. - if (is_null($epoch)) : + if (is_null($ts)) : if (-1 == $default) : - $epoch = time(); + $ts = time(); else : - $epoch = $default; + $ts = $default; endif; endif; - return $epoch; + if (!$unfiltered) : + apply_filters('syndicated_item_updated', $ts, $this); + endif; + return $ts; } /* SyndicatedPost::updated() */ function update_hash () { @@ -733,26 +763,43 @@ class SyndicatedPost { $guid = null; if (isset($this->item['id'])): // Atom 0.3 / 1.0 $guid = $this->item['id']; - elseif (isset($this->item['atom']['id'])) : // Namespaced Atom + elseif (isset($this->item['atom']['id'])) : // Namespaced Atom $guid = $this->item['atom']['id']; - elseif (isset($this->item['guid'])) : // RSS 2.0 + elseif (isset($this->item['guid'])) : // RSS 2.0 $guid = $this->item['guid']; - elseif (isset($this->item['dc']['identifier'])) :// yeah, right + elseif (isset($this->item['dc']['identifier'])) : // yeah, right $guid = $this->item['dc']['identifier']; - else : + endif; + + // Un-set or too long to use as-is. Generate a tag: URI. + if (is_null($guid) or strlen($guid) > 250) : + // In case we need to check this again + $original_guid = $guid; + // The feed does not seem to have provided us with a - // unique identifier, so we'll have to cobble together - // a tag: URI that might work for us. The base of the - // URI will be the host name of the feed source ... + // usable unique identifier, so we'll have to cobble + // together a tag: URI that might work for us. The base + // of the URI will be the host name of the feed source ... $bits = parse_url($this->link->uri()); $guid = 'tag:'.$bits['host']; + // Some ill-mannered feeds (for example, certain feeds + // coming from Google Calendar) have extraordinarily long + // guids -- so long that they exceed the 255 character + // width of the WordPress guid field. But if the string + // gets clipped by MySQL, uniqueness tests will fail + // forever after and the post will be endlessly + // reduplicated. So, instead, Guids Of A Certain Length + // are hashed down into a nice, manageable tag: URI. + if (!is_null($original_guid)) : + $guid .= ',2010-12-03:id.'.md5($original_guid); + // If we have a date of creation, then we can use that // to uniquely identify the item. (On the other hand, if // the feed producer was consicentious enough to // generate dates of creation, she probably also was // conscientious enough to generate unique identifiers.) - if (!is_null($this->created())) : + elseif (!is_null($this->created())) : $guid .= '://post.'.date('YmdHis', $this->created()); // Otherwise, use both the URI of the item, *and* the @@ -1164,41 +1211,40 @@ class SyndicatedPost { "); if (!$result) : + $this->_wp_id = NULL; $this->_freshness = 2; // New content else: - $stored_update_hashes = get_post_custom_values('syndication_item_hash', $result->id); - if (count($stored_update_hashes) > 0) : - $stored_update_hash = $stored_update_hashes[0]; - $update_hash_changed = ($stored_update_hash != $this->update_hash()); - else : - $update_hash_changed = true; // Can't find syndication meta-data - endif; - preg_match('/([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):([0-9]+)/', $result->post_modified_gmt, $backref); $last_rev_ts = gmmktime($backref[4], $backref[5], $backref[6], $backref[2], $backref[3], $backref[1]); $updated_ts = $this->updated(/*fallback=*/ true, /*default=*/ NULL); - $frozen_values = get_post_custom_values('_syndication_freeze_updates', $result->id); - $frozen_post = (count($frozen_values) > 0 and 'yes' == $frozen_values[0]); - $frozen_feed = ('yes' == $this->link->setting('freeze updates', 'freeze_updates', NULL)); - // Check timestamps... $updated = ( !is_null($updated_ts) and ($updated_ts > $last_rev_ts) ); - - // Or the hash... - $updated = ($updated or $update_hash_changed); + if (!$updated) : + // Or the hash... + $stored_update_hashes = get_post_custom_values('syndication_item_hash', $result->id); + if (count($stored_update_hashes) > 0) : + $stored_update_hash = $stored_update_hashes[0]; + $updated = ($stored_update_hash != $this->update_hash()); + else : + $updated = true; // Can't find syndication meta-data + endif; + endif; - // But only if the post is not frozen. - $updated = ( - $updated - and !$frozen_post - and !$frozen_feed - ); + $frozen = false; + if ($updated) : // Ignore if the post is frozen + $frozen = ('yes' == $this->link->setting('freeze updates', 'freeze_updates', NULL)); + if (!$frozen) : + $frozen_values = get_post_custom_values('_syndication_freeze_updates', $result->id); + $frozen = (count($frozen_values) > 0 and 'yes' == $frozen_values[0]); + endif; + endif; + $updated = ($updated and !$frozen); if ($updated) : $this->_freshness = 1; // Updated content @@ -1262,7 +1308,7 @@ class SyndicatedPost { $taxonomies = array_filter($taxonomies, 'remove_dummy_zero'); $terms = $this->category_ids ( - $this->post['taxed'][$what], + $this->feed_terms[$what], $this->link->setting("unfamiliar {$what}", "unfamiliar_{$what}", 'create:'.$what), /*taxonomies=*/ $taxonomies, array( @@ -1302,7 +1348,7 @@ class SyndicatedPost { endforeach; // Now let's add on the feed and global presets - foreach ($this->post['pretax'] as $tax => $term_ids) : + foreach ($this->preset_terms as $tax => $term_ids) : if (!isset($this->post['tax_input'][$tax])) : $this->post['tax_input'][$tax] = array(); endif; @@ -1322,9 +1368,16 @@ class SyndicatedPost { endif; if (!$this->filtered() and $freshness > 0) : - unset($this->post['named']); + // Filter some individual fields + + // Allow filters to set post slug. Props niska. + $post_name = apply_filters('syndicated_post_slug', NULL, $this); + if (!empty($post_name)) : + $this->post['post_name'] = $post_name; + endif; + $this->post = apply_filters('syndicated_post', $this->post, $this); - + // Allow for feed-specific syndicated_post filters. $this->post = apply_filters( "syndicated_post_".$this->link->uri(), @@ -1341,24 +1394,22 @@ class SyndicatedPost { /*arguments=*/ 3 ); - if (!$this->filtered() and $freshness == 2) : - // The item has not yet been added. So let's add it. - FeedWordPress::diagnostic('syndicated_posts', 'Inserting new post "'.$this->post['post_title'].'"'); - - $this->insert_new(); - do_action('post_syndicated_item', $this->wp_id(), $this); - - $ret = 'new'; - elseif (!$this->filtered() and $freshness == 1) : - FeedWordPress::diagnostic('syndicated_posts', 'Updating existing post # '.$this->wp_id().', "'.$this->post['post_title'].'"'); + $retval = array(1 => 'updated', 2 => 'new'); + + $ret = false; + if (!$this->filtered() and isset($retval[$freshness])) : + $diag = array( + 1 => 'Updating existing post # '.$this->wp_id().', "'.$this->post['post_title'].'"', + 2 => 'Inserting new post "'.$this->post['post_title'].'"', + ); + FeedWordPress::diagnostic('syndicated_posts', $diag[$freshness]); - $this->post['ID'] = $this->wp_id(); - $this->update_existing(); - do_action('update_syndicated_item', $this->wp_id(), $this); + $this->insert_post(/*update=*/ ($freshness == 1)); + + $hook = array( 1 => 'update_syndicated_item', 2 => 'post_syndicated_item' ); + do_action($hook[$freshness], $this->wp_id(), $this); - $ret = 'updated'; - else : - $ret = false; + $ret = $retval[$freshness]; endif; // Remove add_rss_meta hook @@ -1405,7 +1456,20 @@ class SyndicatedPost { /*priority=*/ -10001, /* very early */ /*arguments=*/ 3 ); + + // WP3 appears to override whatever you give it for + // post_modified. Ugh. + add_action( + /*hook=*/ 'transition_post_status', + /*callback=*/ array(&$this, 'fix_post_modified_ts'), + /*priority=*/ -10000, /* very early */ + /*arguments=*/ 3 + ); + if ($update) : + $this->post['ID'] = $this->wp_id(); + $dbpost['ID'] = $this->post['ID']; + endif; $this->_wp_id = wp_insert_post($dbpost); remove_action( @@ -1414,7 +1478,14 @@ class SyndicatedPost { /*priority=*/ -10001, /* very early */ /*arguments=*/ 3 ); - + + remove_action( + /*hook=*/ 'transition_post_status', + /*callback=*/ array(&$this, 'fix_post_modified_ts'), + /*priority=*/ -10000, /* very early */ + /*arguments=*/ 3 + ); + // Turn off ridiculous fucking kludges #1 and #2 remove_action('_wp_put_post_revision', array($this, 'fix_revision_meta')); remove_filter('content_save_pre', array($this, 'avoid_kses_munge'), 11); @@ -1581,6 +1652,29 @@ class SyndicatedPost { endif; } /* SyndicatedPost::add_terms () */ + /** + * SyndicatedPost::fix_post_modified_ts() -- We would like to set + * post_modified and post_modified_gmt to reflect the value of + * <atom:updated> or equivalent elements on the feed. Unfortunately, + * wp_insert_post() refuses to acknowledge explicitly-set post_modified + * fields and overwrites them, either with the post_date (if new) or the + * current timestamp (if updated). + * + * So, wp_insert_post() is not going to do the last-modified assignments + * for us. If you want something done right.... + * + * @param string $new_status Unused action parameter. + * @param string $old_status Unused action parameter. + * @param object $post The database record for the post just inserted. + */ + function fix_post_modified_ts ($new_status, $old_status, $post) { + global $wpdb; + $wpdb->update( $wpdb->posts, /*data=*/ array( + 'post_modified' => $this->post['post_modified'], + 'post_modified_gmt' => $this->post['post_modified_gmt'], + ), /*where=*/ array('ID' => $post->ID) ); + } /* SyndicatedPost::fix_post_modified_ts () */ + /** * SyndicatedPost::add_rss_meta: adds interesting meta-data to each entry * using the space for custom keys. The set of keys and values to add is @@ -1644,7 +1738,7 @@ class SyndicatedPost { function author_id ($unfamiliar_author = 'create') { global $wpdb; - $a = $this->post['named']['author']; + $a = $this->named['author']; $source = $this->source(); $forbidden = apply_filters('feedwordpress_forbidden_author_names',