/* ----- add allowable url parameter for urls */ add_filter('query_vars', 'cdb_parameter_queryvars' ); function cdb_parameter_queryvars( $qvars ) // add parameters to be passed in wordpress query strings { $qvars[] = 'blogurl'; // for passing blog url return $qvars; } /* ----- find primary RSS feed for a given blog (all posts only) */ function feedSearch( $url ) { // via Martin Hawksey via from me (@cogdog) if ( $html = @DOMDocument::loadHTML( file_get_contents( $url ) ) ) { $xpath = new DOMXPath($html); $results = array(); // First look for RSS 2.0 feeds $feeds = $xpath->query("//head/link[@href][@type='application/rss+xml']/@href"); foreach($feeds as $feed) { $results[] = $feed->nodeValue; } // Next first for Atom feeds $feeds = $xpath->query("//head/link[@href][@type='application/atom+xml']/@href"); foreach($feeds as $feed) { $results[] = $feed->nodeValue; } // we have somethng if ( count( $results ) ) { // we assume (badly) that the first result is the blog feed return $results[0]; } else { //oops return an error code return -1; } } else { // another error if we are unable to get the source HTML return -1; } } Blog URL missing or invalid - please enter the full URL for your blog. Please test it to make sure it works'; } elseif ( strpos( $blogurl, '/feed' ) ) { $errors[] = 'Is that really your blog\'s web address? It looks like you entered the URL an RSS Feed in the box. Please enter the web address where you blog shows up, the URL that shows your site in a browser.'; } else { // see if we can find a feed $blogrss = feedSearch( $blogurl ); // feed not found by the function if ($blogrss == -1) $errors[] = 'Blog feed cound not be found. Make sure the URL that you typed is the one that displays your web site in a browser. Or maybe it is a web site we cannot work magic on. Please check, edit, and try again, or seek assistance (need link).'; } if ( count($errors) > 0 ) { // form errors, build feedback string to display the errors $feedback_msg = 'Sorry but the Magic Box cannot process your request: '; } else { $feedback_msg = '

' . $blogrss . '

You should first verify the URL (opens in a new window) -- it will show you something like may look like gibberish, but it represents the raw source of information from your blog and in there you should see remnants of your own blog posts. It should show you something like this or maybe this (depending on your browser).

Make sure you copy this RSS Feed URL to a place where you can find it again.

'; } } ?>

Enter the web address for your blog, the one that displays your site.

Success! We have found an RSS Feed for you.

';?>