Tag: rdf

Feed Tester

Posted on December 4, 2006 in Perishable, WordPress by Jeff Starr

Ignore this post..

[Edit] Note to WP 2.0.5 users: Everything was working fine on this site before upgrading to WP 2.0.5. After upgrading, apparently, our feeds stopped validating* and the BDP RSS Aggregator plugin refused to update our own feeds. After several hours investigating the situation, we determined that the Live Comment Preview plugin was interfering with our feeds validating, while the upgraded WordPress (2.0.5) was responsible for problems with the BDP plugin.

Here is a copy of our recent comment posted at the BDP plugin website:

Comment by m0n on Wednesday 6 December 2006 at 4:28 am

I was running BDPRSS v.0.2.2 just fine before upgrading to WP 2.0.5. After the upgrade, I noticed that feeds from my own site are no longer updated. They are apparently polled, but reflect a ‘last updated’ value of the day I upgraded WP. I have, since the WP upgrade, posted several new articles that appear fine directly, through feedburner, etc.

I have tried just about everything (restoring old BDP databases, deleting and adding new feed entries in the admin panel, deleting cache, you name it, etc.). I have also tried upgrading to BDP 0.4.10, but to no avail. My own feeds will not update either in the BDP admin panel or on the web page itself. Adding different feed formats does not work either.

So, just a note to hopefully garner some more clues concerning this. I realize it may not be an emergency, because who reads their own feeds for crying out loud. Perhaps there are others out there with the same problem. If possible, try adding any of your own feeds (on WP 2.0.5) and see if they work. Well, thanks for listening!

The whole event pretty much zapped the weekend of any free-time, but the good news is that we managed to get everything working properly (according to our needs) once again — feeds all validate and we have previews of our own feeds via the BDP plugin — and we are still running WP 2.0.5! We’ll just bill the incident as another 8-hour "learning experience"..

If anyone is experiencing anything similar to the issues mentioned in this post, we would love to hear about it — drop us a line!

Update: [ May 28th, 2007 ] - Issue resolved! After moving the Perishable Press website to a new server, our WordPress feeds once again began updating directly through our own site (via BDP plugin, et al). Apparently, as our previous host continued to disable important PHP functions (as a solution to potential security vulnerabilities), the various plugins and scripts employing the disabled functions inevitably became useless. Thus, we attribute the source our non-updating feed issue directly to server limitations (and lazy technicians). While we cannot at this point discern exactly the cause of the problem, suffice it to say that our new host provides all the functionality needed for everything to run properly (and smoothly, we might add). So cheers to everyone who helped us with suggestions and ideas for this bizarre dilemma. We now enjoy fully functional and validating WordPress feeds. Case closed.

Footnotes

WordPress RDF Source Makeover

Posted on February 22, 2006 in Websites, WordPress by Jeff Starr

Beautiful Source-Code Output, Part 1: Whip your WordPress RDF Code into Submission

Update: This article applies specifically to WordPress 2.0.2, but may be generalized to any WP 2.0+ version.

I love looking at beautiful source-code output. However WordPress tends to spit code out in random chunks, often leaving spaces, line breaks, and tabs littered throughout the source output. This messes things up. Lists don’t look like lists and logically written code often appears scattered along the page carelessly. Often, this is the result of poorly written PHP, which can be manipulated to write beautifully aligned code that looks as good as it works.

For the first article in this series, we will bring order to the typical RDF chaos that WordPress spits out by default. To see an example of this, check out this source code, taken directly from the output of a default installation of WordPress. Notice how the awkward chunk of code leans, strangely enough, to the right. This type of RDF-code output seems to be the norm for WordPress users who have enabled that particular feature.

Okay, so it looks hideous, and we want to clean it up and make it shine. First thing to do is backup everything, even your database. Don’t trip though — this is a simple “cut-and-paste” procedure, but it is always a good idea to have a recent backup of your data just in case. Next, open the file wp-includes/comment-functions.php and find the function trackback_rdf, which is located about halfway down the page on line #525 (#509 for WP 2.0). Now, replace the following block of PHP code:

function trackback_rdf($timezone = 0) {
	global $id;
	if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) {
	echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
	    xmlns:dc="http://purl.org/dc/elements/1.1/"
	    xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
		<rdf:Description rdf:about="';
	the_permalink();
	echo '"'."\n";
	echo '    dc:identifier="';
	the_permalink();
	echo '"'."\n";
	echo '    dc:title="'.str_replace('--', '&#x2d;&#x2d;', wptexturize(strip_tags(get_the_title()))).'"'."\n";
	echo '    trackback:ping="'.trackback_url(0).'"'." />\n";
	echo '</rdf:RDF>';
	}
}

with our new and improved version1:

function trackback_rdf($timezone = 0) {
	global $id;
	if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) {
	echo '<rdf:RDF ';
	echo "\n";
	echo '   xmlns:dc="http://purl.org/dc/elements/1.1/" ';
	echo "\n";
	echo '   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ';
	echo "\n";
	echo '   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">';
	echo "\n";
	echo '<rdf:Description ';
	echo "\n";
	echo '   dc:creator="';
	the_author();
	echo '" '."\n";
	echo '   dc:date="';
	the_date_xml();
	echo ' @ ';
	the_time('g:i a');
	echo '" '."\n";
	echo '   dc:title="'.str_replace('--', '&#x2d;&#x2d;', wptexturize(strip_tags(get_the_title()))).'" '."\n";
	echo '   rdf:about="';
	the_permalink();
	echo '" '."\n";
	echo '   dc:identifier="';
	the_permalink();
	echo '" '."\n";
	echo '   trackback:ping="'.trackback_url(0);
	echo '" '."\n";
	echo '   dc:description="';
	the_excerpt_rss();
	echo '" />'."\n";
	echo '</rdf:RDF>';
	}
}

Finally, open your WordPress theme’s “index.php” file, find the loop, and add an echoed line break to the commented-out RDF function. Your code should now look like this:

<!--
<?php trackback_rdf(); ?>
<?php echo "\n"; ?>
-->

That’s it — save the two files, upload them, refresh your pages, and check the RDF output in the source code. If all goes well, your RDF code should now resemble this:

<!--
<rdf:RDF 
   xmlns:dc="http://purl.org/dc/elements/1.1/" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description 
   dc:creator="Perishable" 
   dc:date="2006-02-22 @ 11:19 am" 
   dc:title="WordPress RDF Source Makeover" 
   rdf:about="http://perishablepress.com/press/?p=49" 
   dc:identifier="http://perishablepress.com/press/?p=49" 
   trackback:ping="http://perishablepress.com/press/wp-trackback.php?p=49" 
   dc:description="Beautiful Source-Code Output, Part 1: Whip your WordPress RDF Code into Submission
I love looking at beautiful source-code output. [...continued &#187;]" />
</rdf:RDF>
-->

Now that’s much better!

Next time we will look at constructing righteous headings and pimping them for excellence on planet source-code output.

Update: To gain greater control over your WordPress RDF source-code output, replace the native function, the_excerpt_rss(); (located near the last line of the trackback_rdf() function), with the more flexible function, the_content_rss. This function provides five parameters as described in the WordPress Codex:

<?php the_content_rss('more_link_text', strip_teaser, 'more_file', cut, encode_html); ?>

More specifically, here is how we use the function to limit the number of words output in the dc:description attribute, thus optimizing bandwidth while preventing unruly code examples from disrupting document structure (as in the case of JavaScript comments):

the_content_rss('', TRUE, '', 7, 2);

Fin

References