function post($key, $default = NULL) { return FeedWordPress::param($key, 'POST'); }
function display_feedfinder() { global $wpdb; $lookup = isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL; $auth = FeedWordPress::param('link_rss_auth_method'); $username = FeedWordPress::param('link_rss_username'); $password = FeedWordPress::param('link_rss_password'); $credentials = array("authentication" => $auth, "username" => $username, "password" => $password); $feeds = array(); $feedSwitch = false; $current = null; if ($this->for_feed_settings()) { // Existing feed? $feedSwitch = true; if (is_null($lookup)) { // Switch Feed without a specific feed yet suggested // Go to the human-readable homepage to look for // auto-detection links $lookup = $this->link->link->link_url; $auth = $this->link->setting('http auth method'); $username = $this->link->setting('http username'); $password = $this->link->setting('http password'); // Guarantee that you at least have the option to // stick with what works. $current = $this->link->link->link_rss; $feeds[] = $current; } $name = esc_html($this->link->link->link_name); } else { // Or a new subscription to add? $name = "Subscribe to <code>" . esc_html(feedwordpress_display_url($lookup)) . "</code>"; } ?> <div class="wrap" id="feed-finder"> <h2>Feed Finder: <?php echo $name; ?> </h2> <?php if ($feedSwitch) { $this->display_alt_feed_box($lookup); } $finder = array(); if (!is_null($current)) { $finder[$current] = new FeedFinder($current); } $finder[$lookup] = new FeedFinder($lookup); foreach ($finder as $url => $ff) { $feeds = array_merge($feeds, $ff->find(NULL, $credentials)); } $feeds = array_values($feeds); if (count($feeds) > 0) { if ($feedSwitch) { ?> <h3>Feeds Found</h3> <?php } if (count($feeds) > 1) { $option_template = 'Option %d: '; $form_class = ' class="multi"'; ?> <p><strong>This web page provides at least <?php print count($feeds); ?> different feeds.</strong> These feeds may provide the same information in different formats, or may track different items. (You can check the Feed Information and the Sample Item for each feed to get an idea of what the feed provides.) Please select the feed that you'd like to subscribe to.</p> <?php } else { $option_template = ''; $form_class = ''; } global $fwp_credentials; foreach ($feeds as $key => $f) { $ofc = $fwp_credentials; $fwp_credentials = $credentials; // Set $pie = FeedWordPress::fetch($f); $fwp_credentials = $ofc; // Re-Set $rss = is_wp_error($pie) ? $pie : new MagpieFromSimplePie($pie); if ($this->url_for_401($pie)) { $this->display_alt_feed_box($lookup, array("err" => $pie, "auth" => $auth, "username" => $username, "password" => $password)); continue; } if ($rss and !is_wp_error($rss)) { $feed_link = isset($rss->channel['link']) ? $rss->channel['link'] : ''; $feed_title = isset($rss->channel['title']) ? $rss->channel['title'] : $feed_link; $feed_type = $rss->feed_type ? $rss->feed_type : 'Unknown'; $feed_version_template = '%.1f'; $feed_version = $rss->feed_version; } else { // Give us some sucky defaults $feed_title = feedwordpress_display_url($lookup); $feed_link = $lookup; $feed_type = 'Unknown'; $feed_version_template = ''; $feed_version = ''; } ?> <form<?php print $form_class; ?> action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?> /syndication.php" method="post"> <div class="inside"><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?> <?php $classes = array('feed-found'); $currentFeed = ''; if (!is_null($current) and $current == $f) { $classes[] = 'current'; $currentFeed = ' (currently subscribed)'; } if ($key % 2) { $classes[] = 'alt'; } ?> <fieldset class="<?php print implode(" ", $classes); ?> "> <legend><?php printf($option_template, $key + 1); print $feed_type . " "; printf($feed_version_template, $feed_version); ?> feed<?php print $currentFeed; ?> </legend> <?php $this->stamp_link_id(); // No feed specified = add new feed; we // need to pass along a starting title // and homepage URL for the new Link. if (!$this->for_feed_settings()) { ?> <input type="hidden" name="feed_title" value="<?php echo esc_html($feed_title); ?> " /> <input type="hidden" name="feed_link" value="<?php echo esc_html($feed_link); ?> " /> <?php } ?> <input type="hidden" name="feed" value="<?php echo esc_html($f); ?> " /> <input type="hidden" name="action" value="switchfeed" /> <div> <div class="feed-sample"> <?php $link = NULL; $post = NULL; if (!is_wp_error($rss) and count($rss->items) > 0) { // Prepare to display Sample Item $link = new MagpieMockLink(array('simplepie' => $pie, 'magpie' => $rss), $f); $post = new SyndicatedPost(array('simplepie' => $rss->originals[0], 'magpie' => $rss->items[0]), $link); ?> <h3>Sample Item</h3> <ul> <li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?> "><?php echo $post->post['post_title']; ?> </a></li> <li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?> </li> </ul> <div class="entry"> <?php print $post->post['post_content']; ?> </div> <?php do_action('feedwordpress_feed_finder_sample_item', $f, $post, $link); } else { if (is_wp_error($rss)) { print '<div class="feed-problem">'; print "<h3>Problem:</h3>\n"; print "<p>FeedWordPress encountered the following error\n\t\t\t\t\t\t\twhen trying to retrieve this feed:</p>"; print '<p style="margin: 1.0em 3.0em"><code>' . $rss->get_error_message() . '</code></p>'; print "<p>If you think this is a temporary problem, you can still force FeedWordPress to add the subscription. FeedWordPress will not be able to find any syndicated posts until this problem is resolved.</p>"; print "</div>"; } ?> <h3>No Items</h3> <p>FeedWordPress found no posts on this feed.</p> <?php } ?> </div> <div> <h3>Feed Information</h3> <ul> <li><strong>Homepage:</strong> <a href="<?php echo $feed_link; ?> "><?php echo is_null($feed_title) ? '<em>Unknown</em>' : $feed_title; ?> </a></li> <li><strong>Feed URL:</strong> <a title="<?php echo esc_html($f); ?> " href="<?php echo esc_html($f); ?> "><?php echo esc_html(feedwordpress_display_url($f, 40, 10)); ?> </a> (<a title="Check feed <<?php echo esc_html($f); ?> > for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?> ">validate</a>)</li> <li><strong>Encoding:</strong> <?php echo isset($rss->encoding) ? esc_html($rss->encoding) : "<em>Unknown</em>"; ?> </li> <li><strong>Description:</strong> <?php echo isset($rss->channel['description']) ? esc_html($rss->channel['description']) : "<em>Unknown</em>"; ?> </li> </ul> <?php $this->display_authentication_credentials_box(array('username' => $username, 'password' => $password, 'method' => $auth)); ?> <?php do_action('feedwordpress_feedfinder_form', $f, $post, $link, $this->for_feed_settings()); ?> <div class="submit"><input type="submit" class="button-primary" name="Use" value="« Use this feed" /> <input type="submit" class="button" name="Cancel" value="× Cancel" /></div> </div> </div> </fieldset> </div> <!-- class="inside" --> </form> <?php unset($link); unset($post); } } else { foreach ($finder as $url => $ff) { $url = esc_html($url); print "<h3>Searched for feeds at {$url}</h3>\n"; print "<p><strong>" . __('Error') . ":</strong> " . __("FeedWordPress couldn't find any feeds at") . ' <code><a href="' . htmlspecialchars($lookup) . '">' . htmlspecialchars($lookup) . '</a></code>'; print ". " . __('Try another URL') . ".</p>"; // Diagnostics print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n"; print "<h3>" . __('Diagnostic information') . "</h3>\n"; if (!is_null($ff->error()) and strlen($ff->error()) > 0) { print "<h4>" . __('HTTP request failure') . "</h4>\n"; print "<p>" . $ff->error() . "</p>\n"; } else { print "<h4>" . __('HTTP request completed') . "</h4>\n"; print "<p><strong>Status " . $ff->status() . ":</strong> " . $this->HTTPStatusMessages[(int) $ff->status()] . "</p>\n"; } // Do some more diagnostics if the API for it is available. if (function_exists('_wp_http_get_object')) { $httpObject = _wp_http_get_object(); if (is_callable(array($httpObject, '_getTransport'))) { $transports = $httpObject->_getTransport(); print "<h4>" . __('HTTP Transports available') . ":</h4>\n"; print "<ol>\n"; print "<li>" . implode("</li>\n<li>", array_map('get_class', $transports)) . "</li>\n"; print "</ol>\n"; } elseif (is_callable(array($httpObject, '_get_first_available_transport'))) { $transport = $httpObject->_get_first_available_transport(array(), $url); print "<h4>" . __("HTTP Transport") . ":</h4>\n"; print "<ol>\n"; print "<li>" . FeedWordPress::val($transport) . "</li>\n"; print "</ol>\n"; } print "</div>\n"; } } } if (!$feedSwitch) { $this->display_alt_feed_box($lookup, true); } ?> </div> <!-- class="wrap" --> <?php return false; // Don't continue }
function display () { global $wpdb; global $fwp_post; if (FeedWordPress::needs_upgrade()) : fwp_upgrade_page(); return; endif; $cont = true; $dispatcher = array( "feedfinder" => 'fwp_feedfinder_page', FWP_SYNDICATE_NEW => 'fwp_feedfinder_page', "switchfeed" => 'fwp_switchfeed_page', FWP_UNSUB_CHECKED => 'multidelete_page', FWP_DELETE_CHECKED => 'multidelete_page', 'Unsubscribe' => 'multidelete_page', FWP_RESUB_CHECKED => 'multiundelete_page', ); $act = FeedWordPress::param('action'); if (isset($dispatcher[$act])) : $method = $dispatcher[$act]; if (method_exists($this, $method)) : $cont = $this->{$method}(); else : $cont = call_user_func($method); endif; elseif (isset($fwp_post['multiadd']) and $fwp_post['multiadd']==FWP_SYNDICATE_NEW) : $cont = $this->accept_multiadd($fwp_post); endif; if ($cont): $links = $this->sources('Y'); $potential_updates = (!$this->show_inactive() and (count($this->sources('Y')) > 0)); $this->open_sheet('Syndicated Sites'); ?> <div id="post-body"> <?php if ($potential_updates or (count($this->updates_requested()) > 0)) : add_meta_box( /*id=*/ 'feedwordpress_update_box', /*title=*/ __('Update feeds now'), /*callback=*/ 'fwp_syndication_manage_page_update_box', /*page=*/ $this->meta_box_context(), /*context =*/ $this->meta_box_context() ); endif; add_meta_box( /*id=*/ 'feedwordpress_feeds_box', /*title=*/ __('Syndicated sources'), /*callback=*/ array($this, 'syndicated_sources_box'), /*page=*/ $this->meta_box_context(), /*context =*/ $this->meta_box_context() ); do_action('feedwordpress_admin_page_syndication_meta_boxes', $this); ?> <div class="metabox-holder"> <?php fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this); ?> </div> <!-- class="metabox-holder" --> </div> <!-- id="post-body" --> <?php $this->close_sheet(/*dispatch=*/ NULL); ?> <div style="display: none"> <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug --> </div> <?php endif; } /* FeedWordPressSyndicationPage::display () */