Last active
December 21, 2015 01:39
-
-
Save lloyddavis/6229746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* OPML Feed Template for displaying Posts in Fargo readable format | |
* | |
* @package WordPress | |
*/ | |
$outlined = "<?xml version=\"1.0\"?>\n<opml version=\"2.0\">\n"; | |
// make the file title include today's date | |
$outlined .= " <head> | |
<title>WP Export ".date('Y-m-d')."</title> | |
<dateModified>".date(DATE_RFC822)."</dateModified> | |
</head>\n"; | |
$outlined .=" <body>\n"; | |
while (have_posts()) : the_post(); | |
//open tag for the post title | |
$outlined .= " <outline type=\"outline\" text=\""; | |
// get the post title and remove any html entities | |
$title=get_the_title(); | |
$outlined .= htmlentities($title); | |
// close the post title tag | |
$outlined .= "\">\n"; | |
//get the content | |
$cont=" <outline text=\"".get_the_content(); | |
// turn all paragraphs tags into outlines - opener preceded by newline & tab, closer has newline after | |
$cont = str_replace(array("<p>","</p>"),array("\n\t<outline text=\"","\" />\n"), $cont); | |
// get rid of double opening tags | |
$cont = str_replace("<outline text=\"\n","", $cont); | |
$outlined .= ($cont); | |
// $outlined .= " />"; | |
//close off the title tag | |
$outlined .= "</outline>\n"; | |
endwhile ; | |
// close the body | |
$outlined .= "\n </body>\n"; | |
// close the opml | |
$outlined .= "</opml>\n"; | |
// deal with paragraphs at the start of an outline | |
//get rid of odd entities | |
$outlined = str_replace("&", "&", $outlined); | |
$outlined = str_replace(array(" ","£","°","–","’","'"),array("","£","","-","'","'"), $outlined); | |
//churn it out | |
echo $outlined; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment