<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Anthology of Ideas &#187; WordPress</title>
	<atom:link href="http://anthologyoi.com/tag/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://anthologyoi.com</link>
	<description>Anthology of Ideas is an archive of thoughts and form.</description>
	<lastBuildDate>Sat, 03 Mar 2012 11:16:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Predicting an Eventual Return</title>
		<link>http://anthologyoi.com/blogish/asides/predicting-an-eventual-return.html</link>
		<comments>http://anthologyoi.com/blogish/asides/predicting-an-eventual-return.html#comments</comments>
		<pubDate>Sun, 25 Jul 2010 01:46:31 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/?p=597</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>So, it has been quite a while since I posted on my own website. In the past 2 years, there have been what 2 posts? I&#8217;ve barely even looked at it just dropping in long enough to clear out some spam comments or deal with someone who thinks this is the perfect platform to be hateful on. Where have I been? Well, I&#8217;m in the process of moving all of my WordPress Plugins and content over to my business website at <a href="http://aahacreative.com/">AaHa Creative</a> and I&#8217;ve started a <a href="http://aahacreative.com/blog/">web development blog</a> there.</p>
<p>I&#8217;m moving all my business and work related content there and will be actually taking posts down off this site and reposting things there. I&#8217;ve also made new pages for and updated many of my <a href="http://aahacreative.com/our-projects/">wordpress plugins</a> there.</p>
<p>From now on, business and programming related content will go there, and when I am ready to start posting on literature, history, philosophy and related topics again, the new content will be posted here. </p>
<p>I&#8217;ve had to let a few of my personal projects like <a href="http://ajaxedwp.com/">AJAXed WordPress</a> fall to the wayside as I had too many other things dividing my time into itsy-bitsy little fragments.</p>
<p>Things are slowing down now and the craziness of the past year or two has begun to ebb, so eventually, I&#8217;m going to start posting here again, but for now, if you read the website for WordPress related stuff, head over to my business website. And heck, if you need some web development done too, I&#8217;m pretty sure you won&#8217;t have a hard time finding a nice contact form. <img src='http://anthologyoi.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/blogish/asides/predicting-an-eventual-return.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress 2.5 is out, and WordPress.org is dressed to match.</title>
		<link>http://anthologyoi.com/blogish/asides/wordpress-25-is-out-and-wordpressorg-is-dressed-to-match.html</link>
		<comments>http://anthologyoi.com/blogish/asides/wordpress-25-is-out-and-wordpressorg-is-dressed-to-match.html#comments</comments>
		<pubDate>Sat, 29 Mar 2008 15:32:07 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/?p=550</guid>
		<description><![CDATA[New and shiny WordPress.org for a new and shiny version of WordPress. This website is officially not running beta software now, so yay! [geek]I upgraded after it was released for only 10 &#8211; 30 minutes. That has to be a &#8230; <a href="http://anthologyoi.com/blogish/asides/wordpress-25-is-out-and-wordpressorg-is-dressed-to-match.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>New and shiny <a href="http://wordpress.org/">WordPress.org</a> for a new and shiny version of <a href="http://wordpress.org/download/">WordPress</a>.</p>
<p>This website is officially not running beta software now, so yay!</p>
<p>[geek]I upgraded after it was released for only 10 &#8211; 30 minutes. That has to be a record.[/geek]</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/blogish/asides/wordpress-25-is-out-and-wordpressorg-is-dressed-to-match.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress Dashboard Editor</title>
		<link>http://anthologyoi.com/wordpress/plugins/wordpress-dashboard-editor.html</link>
		<comments>http://anthologyoi.com/wordpress/plugins/wordpress-dashboard-editor.html#comments</comments>
		<pubDate>Tue, 18 Mar 2008 20:20:58 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[dashboard editor]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/wordpress/plugins/wordpress-dashboard-editor.html</guid>
		<description><![CDATA[Of the entire website the Dashboard is seen by administrators the most, but it is the hardest part of WordPress to customize. Well not anymore. This plugin allows you to add whatever you want to the Dashboard through PHP and &#8230; <a href="http://anthologyoi.com/wordpress/plugins/wordpress-dashboard-editor.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Of the entire website the Dashboard is seen by administrators the most, but it is the hardest part of WordPress to customize. Well not anymore. This plugin allows you to add whatever you want to the Dashboard through PHP and HTML and allows you to <strong>even add Sidebar Widgets</strong>. You may also wipe the entire dashboard or  individually remove some of the more irritating sections like the Dev news, Planet WordPress and the getting started section. </p>
<p>In WordPress 2.5, the code is cleaner, the plugin is more responsive and you can add both &#8220;real&#8221; sidebar widgets, or add &#8220;fake&#8221; ones to match the dashboard.</p>
<p>This plugin is currently intended for 2.5, but it also works in  WordPress 2.1 &#8211; 2.3 and can work in WordPress 2.0.x if you use the Completely Wipe Dashboard option.</p>
<p><a href='http://anthologyoi.com/wp-content/uploads/2008/03/wordpress-25-dashboard.png'><img src="http://anthologyoi.com/wp-content/uploads/2008/03/wordpress-25-dashboard-300x148.png" alt="" title="wordpress-25-dashboard" width="300" height="148" class="aligncenter size-medium attachment wp-att-535" /></a></p>
<p><strong>Installation is a breeze:</strong></p>
<ol>
<li> <a href='http://downloads.wordpress.org/plugin/wordpress-dashboard-editor.zip' title='Wordpress Dashboard Editor'> Download the zip file for WordPress Dashboard Editor</a></li>
<li>Unzip and upload dashboard.php to your wp-content/plugins/ folder.</li>
<li>Go to your dashboard. There will be a new sub-menu item. </li>
<li>Select any options you want and add any PHP or HTML code that you want to the textbox. </li>
</ol>
<p><strong>Code Examples:</strong></p>
<p>To add a sidebar widget to your dashboard (after selecting the option from the Dashboard management page) use the code:<br />
<span class="inline-code">&lt;?php dynamic_sidebar(&#039;admin&#039;);?&gt;</span><br />
The Admin sidebar is modified and controlled the exact same way as any other sidebar.</p>
<p>If you use the WP-UserOnline plugin you can use:<br />
<span class="inline-code">&lt;?php echo useronline_page();?&gt;</span></p>
<p>In WordPress 2.1-2.3 f you find that your new content doesn&#8217;t align nicely you can add:<br />
<pre class="brush: php">&lt;div style=&quot;float:left; width:460px;&quot;&gt;
//
//Add all other content here
//
&lt;/div&gt;</pre></p>
<p>Any code that can be used in your WordPress Theme can be used in the dashboard. This means that you can have different information appear for the <a href="http://codex.wordpress.org/Roles_and_Capabilities">different user roles</a> among other things.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/plugins/wordpress-dashboard-editor.html/feed</wfw:commentRss>
		<slash:comments>181</slash:comments>
		</item>
		<item>
		<title>I&#8217;m running WordPress 2.5, and so far so good.</title>
		<link>http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html</link>
		<comments>http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html#comments</comments>
		<pubDate>Sat, 15 Mar 2008 07:01:29 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/?p=522</guid>
		<description><![CDATA[There are still some issues, but for the most part, everything seems pretty good. The automatic upgrading is nice, but it still has a couple kinks in it: it says one or two plugins are at the latest version even &#8230; <a href="http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are still some issues, but for the most part, everything seems pretty good.</p>
<ol>
<li>The automatic upgrading is nice, but it still has a couple kinks in it: it says one or two plugins are at the latest version even though it says they aren&#8217;t, it died when upgrading wp-phpmyadmin but not until it deleted it, and it upgraded me to a bum copy of Redirection which wasted two hours of time while I thought that <a href="http://anthologyoi.com/awp">AWP</a> was broken.</li>
<li> I still think the Admin panel is way too washed out. If it stays this way, one of my first tasks will be to release an Admin theme. I think everything has a cartoony feel to it, and it is way too bright. (As well as difficult to see.)</li>
<li><del datetime="2008-03-15T07:25:53+00:00">For some odd reason the Gravatars aren&#8217;t working even though they were on the test install.</del><ins datetime="2008-03-15T07:25:53+00:00">There is a reason you should allow at least 24 hours between hitting the save button and hitting the publishing. I just forgot to echo it.</ins></li>
<li>Love the new media library. It alone will be worth the upgrade for some people. It auto generates galleries, and makes uploading and editing several pictures extremely easy. </li>
</ol>
<p>Check out the gallery of screenshots below the fold.<br />
<span id="more-522"></span><br />

<a href='http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/attachment/dashboard' title='dashboard'><img width="150" height="150" src="http://anthologyoi.com/files/2008/03/dashboard-150x150.jpg" class="attachment-thumbnail" alt="dashboard" title="dashboard" /></a>
<a href='http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/attachment/edit-post' title='edit-post'><img width="150" height="150" src="http://anthologyoi.com/files/2008/03/edit-post-150x150.jpg" class="attachment-thumbnail" alt="edit-post" title="edit-post" /></a>
<a href='http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/attachment/manage-comment' title='manage-comment'><img width="150" height="150" src="http://anthologyoi.com/files/2008/03/manage-comment-150x150.jpg" class="attachment-thumbnail" alt="manage-comment" title="manage-comment" /></a>
<a href='http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/attachment/manage-media' title='manage-media'><img width="150" height="150" src="http://anthologyoi.com/files/2008/03/manage-media-150x150.jpg" class="attachment-thumbnail" alt="manage-media" title="manage-media" /></a>
<a href='http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/attachment/inline-uploader' title='inline-uploader'><img width="150" height="150" src="http://anthologyoi.com/files/2008/03/inline-uploader-150x150.jpg" class="attachment-thumbnail" alt="inline-uploader" title="inline-uploader" /></a>
<a href='http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/attachment/inline-uploader-dispaly-bug' title='inline-uploader-display-bug'><img width="150" height="150" src="http://anthologyoi.com/files/2008/03/inline-uploader-dispaly-bug-150x150.jpg" class="attachment-thumbnail" alt="inline-uploader-display-bug" title="inline-uploader-display-bug" /></a>
<a href='http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/attachment/manage-posts' title='manage-posts'><img width="150" height="150" src="http://anthologyoi.com/files/2008/03/manage-posts-150x150.jpg" class="attachment-thumbnail" alt="manage-posts" title="manage-posts" /></a>
<a href='http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/attachment/manage-posts-2' title='manage-posts'><img width="150" height="150" src="http://anthologyoi.com/files/2008/03/manage-posts-150x150.jpg" class="attachment-thumbnail" alt="manage-posts" title="manage-posts" /></a>
<a href='http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/attachment/widgets' title='widgets'><img width="150" height="150" src="http://anthologyoi.com/files/2008/03/widgets-150x150.jpg" class="attachment-thumbnail" alt="widgets" title="widgets" /></a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/blogish/asides/im-running-wordpress-25.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom Category Templates on a Archive or Index page.</title>
		<link>http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html</link>
		<comments>http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html#comments</comments>
		<pubDate>Wed, 23 Jan 2008 21:00:01 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html</guid>
		<description><![CDATA[On my home page and in my archives, I use a custom category template to display asides and news articles. This is very easy to do and it only takes a couple seconds of work to create custom category templates &#8230; <a href="http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On <a href="http://anthologyoi.com/">my home page</a> and in my archives, I use a custom category template to display <a href="http://anthologyoi.com/archive/blogish/asides">asides</a> and <a href="http://anthologyoi.com/archive/news-briefs">news</a> articles. This is very easy to do and it only takes a couple seconds of work to create custom category templates in any WordPress theme. </p>
<p>The first step is to add the following to your current theme&#8217;s index.php loop after the line that looks like <span class="inline-code">&lt;?php while (have_posts()) : the_post(); ?&gt;</span>, but before any other code.<br />
<pre class="brush: php">&lt;?php $cat_temp = cat_loop();?&gt;
	&lt;?php if($cat_temp &amp;&amp; is_numeric($cat_temp)){?&gt;
		&lt;?php include(&#039;loops/cat_&#039;.$cat_temp.&#039;.php&#039;);?&gt;
	&lt;?php }else{ ?&gt;</pre></p>
<p>Then add <span class="inline-code">}</span> just before the line <span class="inline-code">endwhile</span>.</p>
<p>The next step is to add the following to your theme&#8217;s functions.php file (you may have to create a file with the same name):</p>
<p><pre class="brush: php">function cat_loop(){
	global $blog_id,$post, $wp_version;
		if($wp_version &gt;= 2.3){
			global $object_term_cache;
			$array = $object_term_cache[$blog_id][$post-&gt;ID][&#039;category&#039;];
		}else{
			global $category_cache;
			$array = $category_cache[$blog_id][$post-&gt;ID];
		}
		while (list($cat) = each($array)) {
			if(file_exists(dirname(__FILE__).&#039;/loops/cat_&#039;.$cat.&#039;.php&#039;)){
				return $cat;
			}
		}
	}</pre></p>
<p>This can be modified to look at author&#8217;s also. Now the only thing you have to do is to create a folder named &#8220;loops&#8221; in your theme&#8217;s folder, and then create a new file with a new &#8220;loop&#8221; &#8212; excluding the while and endwhile parts &#8212; and name it cat_xxx.php where xxx is the id of the category the loops is for. </p>
<p>This can be repeated for single.php, archive.php, or anywhere else a custom loop is useful. You can even use something similar for individual posts or pages.</p>
<p>A post may be in multiple categories, but it will only use the first custom template it finds, so make sure the post is in only one specially styled category at a time.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Displaying WordPress categories in a horizontal dropdown menu.</title>
		<link>http://anthologyoi.com/wordpress/displaying-wordpress-categories-in-a-horizontal-dropdown-menu.html</link>
		<comments>http://anthologyoi.com/wordpress/displaying-wordpress-categories-in-a-horizontal-dropdown-menu.html#comments</comments>
		<pubDate>Wed, 16 Jan 2008 18:05:51 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[drop-down menus]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/wordpress/displaying-wordpress-categories-in-a-horizontal-dropdown-menu.html</guid>
		<description><![CDATA[One of my readers recently asked how I created my horizontal menu bar: the short answer is by mixing CSS and Javascript. The first step is to get WordPress to display the menu as a hierarchical list without a title. &#8230; <a href="http://anthologyoi.com/wordpress/displaying-wordpress-categories-in-a-horizontal-dropdown-menu.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p> One of my readers recently asked how I created my horizontal menu bar: the short answer is by mixing CSS and Javascript.</p>
<p>The first step is to get WordPress to display the menu as a hierarchical list without a title. <span class="inline-code">&lt;?php wp_list_categories(&#039;sort_column=name&amp;sort_order=asc&amp;style=list&amp;children=true&amp;hierarchical=true&amp;title_li=0&#039;); ?&gt;</span></p>
<p>We then wrap this WordPress code in the following so we can style it.<br />
<pre class="brush: php">&lt;div style=&quot;text-align:center;&quot;&gt;
    &lt;ul id=&quot;menu&quot; style=&quot;padding:0; margin:0;&quot;&gt;
        &lt;?php wp_list_categories(&#039;sort_column=name&amp;sort_order=asc&amp;style=list&amp;children=true&amp;hierarchical=true&amp;title_li=0&#039;); ?&gt;
    &lt;/ul&gt;
&lt;/div&gt;</pre></p>
<p>I added this to my header.php, but you can add it anywhere you want it to appear.</p>
<p>The CSS is fairly simple and you just need to add it to your theme&#8217;s <u>style.css</u> file.</p>
<p><pre class="brush: php">ul#menu {
	margin: 0;
	padding: 0;
	list-style: none;
	width: 100%;
	font-size:1.2em;
}

ul#menu li {
	float: left;
	padding: 0;
	margin: 0;
	border-right:solid 1px #fff;
}

ul#menu ul li {
	float: none;
	position: relative;
	border-bottom: 1px solid #7EAED7; /* fixes gap problem in IE */
	border-left: 1px solid #FFF;
	z-index:1000;
}

ul#menu li ul {
	margin: 0;
	padding: 0;
	display:none;
	list-style: none;
	position: absolute;
	background: #9CC;
}
ul#menu ul ul{
	margin-left: .2em;
	position: absolute;
	top: 0; /* if using borders, -1px to align top borders */
	left: 100%;
}

ul#menu * a:hover, ul#menu li a:active{
background:#7EAED7 !important;
color: #FFFFFF;
}

ul#menu li a:link,
ul#menu li a:visited,
ul#menu li a:hover,
ul#menu  li a:active{
	display: block;
	padding: .2em .3em;
	text-decoration: none;
	background: #5587B3;
	 color: #FFFFFF;
}


ul#menu ul li a:link,
ul#menu ul li a:visited,
ul#menu ul li a:hover,
ul#menu ul li a:active {
	width: 8em;
}</pre></p>
<p>Of course you will need to change the colors and text sizes to ensure it blends with the rest of the theme.</p>
<p>Now the last step is the to make it work as a drop-down list on all browsers. This could be done in Firefox with a simple CSS declaration, but Internet Explorer doesn&#8217;t understand the :hover pseudo classes, so we mimic this in Javascript.</p>
<p><pre class="brush: php">&lt;script type=&quot;text/javascript&quot;&gt;
 /*&lt;![CDATA[*/

var mbA,mbT,mbTf,mbSf;
var mbR = [];

function mbSet(m) {
if (document.getElementById&amp;&amp;document.createElement) {
	var m=document.getElementById(m);
	mbR[mbR.length] = m;
	var i;

	e=m.getElementsByTagName(&#039;a&#039;);
	if (!mbTf) mbTf=new Function(&#039;mbHT();&#039;);
	if (!mbSf) mbSf=new Function(&#039;mbS(this);&#039;);
	for (i=0;i&lt;e.length;i++) {
		e[i].onmouseout=e[i].onblur=mbTf;
		e[i].onmouseover=e[i].onfocus=mbSf;
	}

	m=m.getElementsByTagName(&#039;ul&#039;);
	for (i=0;i&lt;m.length;i++) {
		mbH(mbL(m[i]));
	}
}}

function mbHA() {
	if (mbA) {
		while (mbA) mbH(mbA);
		mbHE(&#039;block&#039;);
	}
}

function mbHT() {
	if (!mbT) mbT=setTimeout(&#039;mbHA();&#039;, 0);
}

function mbTC() {
	if (mbT) {
		clearTimeout(mbT);
		mbT=null;
	}
}

function mbS(m) {
	mbTC();
	if (mbA) while (mbA&amp;&amp;m!=mbA&amp;&amp;mbP(m)!=mbA) mbH(mbA);
	else mbHE(&#039;none&#039;);

	if (mbM(m)) {
		mbSH(m,&#039;block&#039;);
		mbA=m;
	}
}

function mbH(m) {
	if (m==mbA) mbA=mbP(m);
	mbSH(m,&#039;none&#039;);
	mbT=null;
}

function mbL(m) {
	while (m &amp;&amp; m.tagName != &#039;A&#039;) m = m.previousSibling;
	return m;
}

function mbM(l) {
	while (l &amp;&amp; l.tagName != &#039;UL&#039;) l = l.nextSibling;
	return l;
}

function mbP(m) {
	var p = m.parentNode.parentNode;
	if (p.tagName == &#039;UL&#039;) {
		var i = 0;
		while (i &lt; mbR.length) {
			if (mbR[i] == p) return null;
			i++;
		}
	} else {
		return null;
	}
	return mbL(p);
}

function mbSH(m,v) {
	m.className=v;
	mbM(m).style.display=v;
}

function mbHE(v) {
	mbHEV(v,document.getElementsByTagName(&#039;select&#039;));
}

function mbHEV(v,e) {
	for (var i=0;i&lt;e.length;i++) e[i].style.display=v;
}
/*]]&gt;*/
&lt;/script&gt;</pre></p>
<p>A couple notes on the previous code. </p>
<ol>
<li>To activate it, change your theme&#8217;s &lt;body> tag to &lt;body onload=&#8221;mbSet(&#8216;menu&#8217;);></li>
<li>It was not written by me, but I&#8217;ve been using it for a long time and don&#8217;t remember where I got it. </li>
<li>It can occasionally create a JavaScript error, and I&#8217;ve intended to rewrite it for a long time, but it usually works fine. </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/displaying-wordpress-categories-in-a-horizontal-dropdown-menu.html/feed</wfw:commentRss>
		<slash:comments>323</slash:comments>
		</item>
		<item>
		<title>Tag Management for WordPress 2.3</title>
		<link>http://anthologyoi.com/wordpress/plugins/tag-management-for-wordpress-23.html</link>
		<comments>http://anthologyoi.com/wordpress/plugins/tag-management-for-wordpress-23.html#comments</comments>
		<pubDate>Mon, 22 Oct 2007 05:47:05 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/wordpress/plugins/tag-management-for-wordpress-23.html</guid>
		<description><![CDATA[Now that you have gotten used to WP 2.3 and had time to fiddle around with all those tags, you are probably finding that you need to edit, rename or delete tags. While I was going to write my own &#8230; <a href="http://anthologyoi.com/wordpress/plugins/tag-management-for-wordpress-23.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>   Now that you have gotten used to WP 2.3 and had time to fiddle around with all those tags, you are probably finding that you need to edit, rename or delete tags. While I was going to write my own Plugins for this for a while, I found the perfect Plugins to do the work for me &#8212; and by perfect I mean really good, so I take no responsibility if they eat your dog.</p>
<p>The <a href="http://www.herewithme.fr/wordpress-plugins/simple-tags">Simple Tags</a> has been around for a long time, but now it works perfectly with WordPress tagging. What does it do? Most everything you could want (I could retype the list, but I&#8217;m going to borrow it straight from the Simple Tags website):</p>
<blockquote><ul>
<li><strong>type-ahead input tags</strong></li>
<li>auto suggestion of tags</li>
<li>tags management (rename, delete, amalgamate, search and add tags, edit tags ID)</li>
<li>List of non tagged contents</li>
<li><strong>Edit mass tags</strong></li>
<li><strong>Possibility to tag pages (not only posts) and include them inside the tags results</strong></li>
<li>Related content since common tags</li>
<li>Possibility to add related posts inside RSS</li>
<li><strong>Dynamic Tag Clouds with colors with Widgets</strong></li>
<li>Tags inside your header&#8217;s blog</li>
<li>Embedded tags ([tags]tag1, tag2[/tags]) for retro compatibility</li>
</ul>
</blockquote>
<p>I use <a href="http://anthologyoi.com/about/used-plugins">a lot of Plugins</a> and <a href="http://anthologyoi.com/tag/plugin/">write a lot of Plugins</a>, so the fact that I even use one usually means it is really well made or very useful, but this one is one of the very few that I thought was good enough to promote. Remember, if you have a favorite Plugin, do the author a favor and mention it once or twice. </p>
<p>Oh and what would be really nice is if it had a feature that would suggest related keywords based on the text (there used to be a Yahoo API that did this.) Wink Wink.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/plugins/tag-management-for-wordpress-23.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysql Search and Replace.</title>
		<link>http://anthologyoi.com/wordpress/mysql-search-and-replace.html</link>
		<comments>http://anthologyoi.com/wordpress/mysql-search-and-replace.html#comments</comments>
		<pubDate>Fri, 31 Aug 2007 06:53:16 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replace]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/wordpress/mysql-search-and-replace.html</guid>
		<description><![CDATA[I&#8217;ve been getting ready for WordPress 2.3, so in preparation I&#8217;ve started cleaning up my database. My first order of business was to clean up the tags database. Over time I&#8217;ve used several different methods of separating words: all spaces, &#8230; <a href="http://anthologyoi.com/wordpress/mysql-search-and-replace.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been getting ready for WordPress 2.3, so in preparation I&#8217;ve started cleaning up my database. My first order of business was to clean up the tags database. Over time I&#8217;ve used several different methods of separating words: all spaces, hyphens and underscores have all been used which really makes the nice names ugly. Fixing this was easy, I just used the MYSQL replace command:</p>
<p><span class="inline-code">UPDATE `table` SET `field` = REPLACE(Field,&#039;change_me&#039;,&#039;to_me&#039;);</span></p>
<p>Or specifically for the tags:</p>
<p><span class="inline-code">UPDATE `wp_tags` SET `tag` = REPLACE(tag,&#039;_&#039;,&#039; &#039;);</span></p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/mysql-search-and-replace.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Designing flexible WordPress themes.</title>
		<link>http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html</link>
		<comments>http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html#comments</comments>
		<pubDate>Wed, 29 Aug 2007 07:07:43 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[custom templates]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/dev/theme-designers-code-less-do-more.html</guid>
		<description><![CDATA[The average WordPress theme has different files for pages, single posts, archives and the front page; however, most of them are almost exactly the same except for inside the_loop. This is a quick tutorial on how to do the most &#8230; <a href="http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The average WordPress theme has different files for pages, single posts, archives and the front page; however, most of them are almost exactly the same except for inside the_loop. This is a quick tutorial on how to do the most with the fewest files, and includes a few methods to have custom templates by separating content display from structural elements.</p>
<p>WordPress looks first for special files and then defaults to the index.php file (<a href="http://wpbits.wordpress.com/2007/08/22/making-wordpress-themes-iii-template-hierarchy/">as shown in this diagram</a>). We can take advantage of this by using only an index.php file and then using conditionals to modify it. While it seems that this method would render the code less readable, it is actually far more readable, and far easier to modify.</p>
<p>Your theme should start off a header.php, footer.php, sidebar.php and an index.php. These files are <a href="http://kahi.cz/wordpress/template-structure-graphically-clearly/">the &#8220;code&#8221; files</a> and are fairly self-explanatory, and at this point the only question should be whether you add just the header portion of the file to the header.php or everything including the calls to get_sidebar()&#8212;the same goes for the footer.php depending on your theme. This depends on how you use your them, if you plan to integrate it with bbPress and use the same header and sidebars, you should add everything before the normal loop to the header. However, we will focus on things outside of the header (this includes the navigation menus and such) and just focus on <a href="http://codex.wordpress.org/the_loop">the_loop</a>.</p>
<p>A &#8220;normal&#8221; index page looks a little like this. (Taken from the default WordPress theme.)</p>
<p><pre class="brush: php">&lt;?php get_header(); ?&gt;

	&lt;div id=&quot;content&quot; class=&quot;narrowcolumn&quot;&gt;

	&lt;?php if (have_posts()) : ?&gt;

		&lt;?php while (have_posts()) : the_post(); ?&gt;

			&lt;div class=&quot;post&quot; id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;
				&lt;h2&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to &lt;?php the_title(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
				&lt;small&gt;&lt;?php the_time(&#039;F jS, Y&#039;) ?&gt; &lt;!-- by &lt;?php the_author() ?&gt; --&gt;&lt;/small&gt;

				&lt;div class=&quot;entry&quot;&gt;
					&lt;?php the_content(&#039;Read the rest of this entry &amp;raquo;&#039;); ?&gt;
				&lt;/div&gt;

				&lt;p class=&quot;postmetadata&quot;&gt;Posted in &lt;?php the_category(&#039;, &#039;) ?&gt; | &lt;?php edit_post_link(&#039;Edit&#039;, &#039;&#039;, &#039; | &#039;); ?&gt;  &lt;?php comments_popup_link(&#039;No Comments &amp;#187;&#039;, &#039;1 Comment &amp;#187;&#039;, &#039;% Comments &amp;#187;&#039;); ?&gt;&lt;/p&gt;
			&lt;/div&gt;

		&lt;?php endwhile; ?&gt;

		&lt;div class=&quot;navigation&quot;&gt;
			&lt;div class=&quot;alignleft&quot;&gt;&lt;?php next_posts_link(&#039;&amp;laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;
			&lt;div class=&quot;alignright&quot;&gt;&lt;?php previous_posts_link(&#039;Next Entries &amp;raquo;&#039;) ?&gt;&lt;/div&gt;
		&lt;/div&gt;

	&lt;?php else : ?&gt;

		&lt;h2 class=&quot;center&quot;&gt;Not Found&lt;/h2&gt;
		&lt;p class=&quot;center&quot;&gt;Sorry, but you are looking for something that isn&#039;t here.&lt;/p&gt;
		&lt;?php include (TEMPLATEPATH . &quot;/searchform.php&quot;); ?&gt;

	&lt;?php endif; ?&gt;

	&lt;/div&gt;

&lt;?php get_sidebar(); ?&gt;

&lt;?php get_footer(); ?&gt;</pre></p>
<p>For most themes, the page and single pages look the same: the only part that really changes is the_loop itself, and even then the changes are usually minor, so if you want to change something outside the_loop, you have to change it in all files. However, by operating the majority of display elements out of the main files, we can make it infinitely extensible without overloading the end-user with large amounts of code to sort through.</p>
<p>The index.php file for the theme I use is very short and easily read.</p>
<p><pre class="brush: php">&lt;?php get_header(); ?&gt;
	&lt;div id=&quot;wrap&quot;&gt;

		&lt;div id=&quot;content&quot;&gt;

			&lt;?php if (have_posts()) : ?&gt;

				&lt;?php
					if(is_home()){

						include (TEMPLATEPATH . &#039;/index-loop.php&#039;);

					}elseif(is_page() || is_single()){

						include (TEMPLATEPATH . &#039;/single-loop.php&#039;);

					}else{

						include (TEMPLATEPATH . &#039;/archive-loop.php&#039;);

					}
				?&gt;

			&lt;?php else :?&gt;
				&lt;h2 class=&quot;center&quot;&gt;Not Found&lt;/h2&gt;
				&lt;?php include (TEMPLATEPATH . &#039;/not-found.php&#039;);?&gt;
			&lt;?php endif; ?&gt;

		&lt;/div&gt;

		&lt;?php get_sidebar(); ?&gt;

	&lt;/div&gt;

&lt;?php get_footer(); ?&gt;</pre></p>
<p>If we break it down: it calls the header, adds the two structural divs, and checks to see if there are any posts (of any kind). If there are no posts it includes an error page before including the sidebar, closing the divs and calling the footer. This part of the page is fairly normal and is used in most themes&#8212;not only is it used in most themes, but most of the main files all have this same code&#8211;every single theme file calls the footer, sidebar and header, shows an error message if there are no posts to display. This is a lot of wasted space. If you suddenly want to change the name of something or move the sidebars, you have to change every file which is just pointless. The difference in my index.php file is that there isn&#8217;t a full loop. It checks if there are posts using have_posts(), but where you would normally see a loop it just has some <a href="http://codex.wordpress.org/Conditional_Tags">conditional statements</a>, and for each condition, a different loop is included. </p>
<p>Each of the loops is in a different included file. (The loops are shown below, but just notice the similarities and major differences.)</p>
<p>Index loop:</p>
<p><pre class="brush: php">&lt;?php while (have_posts()) : the_post(); ?&gt;
		&lt;h2 id=&quot;post-&lt;?php the_ID(); ?&gt;&quot; class=&quot;b&quot;&gt;
			&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to &lt;?php the_title(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt; &lt;/a&gt;
		&lt;/h2&gt;

		&lt;div class=&quot;main main_border&quot;&gt;

			&lt;small&gt;
				Posted on &lt;?php /*backslashes escape chars*/ the_time(&#039;l \t\h\e jS \o\f F, Y \a\t g:i a &#039;) ?&gt; in &lt;?php the_category(&#039;, &#039;) ?&gt; &lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;
			&lt;/small&gt;

				&lt;?php the_content(&#039;Continue reading &quot;&#039;.the_title(&#039;&#039;, &#039;&#039;, false).&#039;&quot;&#039;)?&gt;

			&lt;div class=&quot;small box&quot;&gt;
				//Some comment and UTW stuff				
			&lt;/div&gt;	
		&lt;/div&gt;
&lt;?php endwhile; ?&gt;

&lt;div class=&quot;main&quot; style=&quot;width:99%;&quot;&gt;
	&lt;div class=&quot;main-nav-left&quot; style=&quot;float:left;width:49%;&quot;&gt;&lt;?php posts_nav_link(&#039;&#039;,&#039;&#039;,&#039;&amp;laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;
	&lt;div class=&quot;main-nav-right&quot; style=&quot;float:right;width:49%; text-align:right;&quot;&gt;&lt;?php posts_nav_link(&#039;&#039;,&#039;Next Entries &amp;raquo;&#039;,&#039;&#039;) ?&gt;&lt;/div&gt;
&lt;/div&gt;</pre></p>
<p>single-loop.php (handles both singles and pages because there is only a tiny difference between the two)</p>
<p><pre class="brush: php">&lt;?php while (have_posts()) : the_post(); ?&gt;

	&lt;h2&gt;&lt;?php the_title();?&gt;&lt;/h2&gt;


	&lt;small&gt;
		&lt;?php if(!is_page()){ /*Only difference between pages and singles*/?&gt;

			Posted on &lt;?php /*backslashes escape chars*/ the_time(&#039;l \t\h\e jS \o\f F, Y \a\t g:i a &#039;) ?&gt; &lt;!-- by &lt;?php the_author() ?&gt; --&gt;in &lt;?php the_category(&#039;, &#039;) ?&gt; &lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;

		&lt;?php }else{?&gt;

			&lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;

		&lt;?php } ?&gt;
	&lt;/small&gt;

	&lt;div class=&quot;main&quot;&gt;

		&lt;?php the_content(&#039;Read the rest of this entry &amp;raquo;&#039;); ?&gt;

		&lt;?php wp_link_pages(); ?&gt;

		&lt;div class=&quot;small box&quot;&gt;

			//some comment and UTW stuff

		&lt;/div&gt;

		&lt;?php posts_nav_link(&#039; &amp;#8212; &#039;, __(&#039;&amp;laquo; Previous Page&#039;), __(&#039;Next Page &amp;raquo;&#039;)); ?&gt;

	&lt;/div&gt;

&lt;?php endwhile; ?&gt;</pre></p>
<p>And the archive-loop.php which handles categories, date archives, tags, searches etc.</p>
<p><pre class="brush: php">&lt;?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?&gt;

	&lt;?php /* If this is a category archive */ if (is_category()) { ?&gt;

		&lt;h2&gt; Reading about &lt;?php single_cat_title(); ?&gt;&lt;/h2&gt;

 	&lt;?php /* If this is a daily archive */ } elseif (is_day()) { ?&gt;

		&lt;h2&gt;Archive for &lt;?php the_time(&#039;F jS, Y&#039;); ?&gt;&lt;/h2&gt;

	&lt;?php /* If this is a monthly archive */ } elseif (is_month()) { ?&gt;

		&lt;h2&gt;Archive for &lt;?php the_time(&#039;F, Y&#039;); ?&gt;&lt;/h2&gt;

	&lt;?php /* If this is a yearly archive */ } elseif (is_year()) { ?&gt;

		&lt;h2&gt;Archive for &lt;?php the_time(&#039;Y&#039;); ?&gt;&lt;/h2&gt;

	&lt;?php /* If this is a search */ } elseif (is_search()) { ?&gt;

		&lt;h2&gt;The Search Results For &quot;&lt;?php echo $s;?&gt;&quot;&lt;/h2&gt;

	&lt;?php /* If this is an author archive */ } elseif (is_author()) { ?&gt;

		&lt;h2&gt;Author Archive&lt;/h2&gt;

	&lt;?php /* If this is a paged archive */ } elseif (isset($_GET[&#039;paged&#039;]) &amp;&amp; !empty($_GET[&#039;paged&#039;])) { ?&gt;

		&lt;h2&gt;Archives&lt;/h2&gt;

	&lt;?php } ?&gt;


	&lt;div class=&quot;main&quot; style=&quot;width:99%;&quot;&gt;
		&lt;div class=&quot;main-nav-left&quot; style=&quot;float:left;width:40%;&quot;&gt;&lt;?php previous_posts_link(&#039;&amp;laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;
		&lt;div class=&quot;main-nav-right&quot; style=&quot;float:right;width:40%; text-align:right;&quot;&gt;&lt;?php next_posts_link(&#039;Next Entries &amp;raquo;&#039;) ?&gt;&lt;/div&gt;
	&lt;/div&gt;


	&lt;?php while (have_posts()) : the_post(); ?&gt;

	&lt;h3 class=&quot;b&quot;&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link a &lt;?php the_title(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h3&gt;

	&lt;div class=&quot;main main_border &lt;?php echo anth::styles();?&gt;&quot;&gt;

		&lt;small&gt;
			&lt;!-- Posted &lt;?php the_time(&#039;j F Y&#039;) ?&gt;  by &lt;?php the_author() ?&gt; --&gt;
			&lt;?php if(function_exists(&#039;UTW_ShowTagsForCurrentPost&#039;)){?&gt;
				&lt;span class=&quot;utwtags&quot;&gt;Keywords: &lt;?php UTW_ShowTagsForCurrentPost(&quot;commalist&quot;) ?&gt;&lt;/span&gt;
			&lt;?php } ?&gt;
			&lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;
		&lt;/small&gt;

			&lt;?php the_excerpt() ?&gt;

	&lt;/div&gt;

&lt;?php endwhile; ?&gt;

&lt;br/&gt;

	&lt;div class=&quot;main&quot; style=&quot;width:99%;&quot;&gt;
		&lt;div class=&quot;main-nav-left&quot; style=&quot;float:left;width:40%;&quot;&gt;&lt;?php previous_posts_link(&#039;&amp;laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;
		&lt;div class=&quot;main-nav-right&quot; style=&quot;float:right;width:40%; text-align:right;&quot;&gt;&lt;?php next_posts_link(&#039;Next Entries &amp;raquo;&#039;) ?&gt;&lt;/div&gt;
	&lt;/div&gt;</pre></p>
<p>The actual loops in each of these files starts with <span class="inline-code">&lt;?php while (have_posts()) : the_post(); ?&gt;</span>, and you will notice that all the loops are similar with only a few cosmetic changes, the major difference is in the archive page which uses a large conditional block to set the title text, but this could have been done on the index.php page and used a completely different loop if you needed it.</p>
<p>Okay, so you get down to here and wonder why you haven&#8217;t heard anything new. well once we start using custom loops the possibilities are endless.</p>
<p>For example, as <a href="http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html">I posted about recently</a>, on my index I use a special loop for items that are in the <a href="http://anthologyoi.com/archive/blogish/asides/">Asides category</a>, but only on the index page, so inside of my is_home) conditional statement I also add the code:</p>
<p><pre class="brush: php">&lt;?php $in_cat = cat_loop();?&gt;
	&lt;?php if($in_cat){?&gt;
		&lt;?php include(&#039;cat_&#039;.$in_cat.&#039;.php&#039;);?&gt;
	&lt;?php } ?&gt;</pre></p>
<p>Which calls the function: (added to the functions.php file)<br />
<pre class="brush: php">function cat_loop(){
	global $blog_id,$post, $wp_version;
		if($wp_version &gt;= 2.3){
			global $object_term_cache;
			$array = $object_term_cache[$blog_id][$post-&gt;ID][&#039;category&#039;];
		}else{
			global $category_cache;
			$array = $category_cache[$blog_id][$post-&gt;ID];
		}
		while (list($cat) = each($array)) {
			if(file_exists(dirname(__FILE__).&#039;/cat_&#039;.$cat.&#039;.php&#039;)){
				return $cat;
			}
		}
	}</pre></p>
<p>Basically the function loops through all the categories a post is in and if there is a custom loop for a category it uses it. This can easily be extended for author ids, name or anything else that you can test.</p>
<p>Let&#8217;s review: use as little repeated code as possible because when you do lots of tricks are available to you. </p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Trapping WordPress errors with output buffering.</title>
		<link>http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html</link>
		<comments>http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html#comments</comments>
		<pubDate>Wed, 15 Aug 2007 17:05:21 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[die]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[output buffering]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html</guid>
		<description><![CDATA[If you have tried to use AJAX with WordPress, most likely you have stumbled upon the wp_die() function which completely kills the response you expect to get. However, we can trap the wp_die() by using PHP&#8217;s output buffering and the &#8230; <a href="http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you have tried to use AJAX with WordPress, most likely you have stumbled upon the wp_die() function which completely kills the response you expect to get. However, we can trap the wp_die() by using PHP&#8217;s output buffering and the ob_start callback function to process the output of wp_die() even though a die() is called. This is a very special case, and will only work when you are able to ensure output buffering can be called before the die is called. </p>
<p>The easiest way to get a non-fatal wp_die() error (an error that shouldn&#8217;t cause the entire application to stop)  is when submitting comments: non-fatal errors occur whenever someone posts too quickly or submits a duplicate comment, so this can be a problem when creating an AJAX app to submit comments (I ran into this problem with <a href="http://anthologyoi.com/inap/">INAP</a>.) </p>
<p>Since AJAX makes the entire submit process very quick, so it is easy to trigger the &#8220;Posting too quickly&#8221; error if the user make short comments, and when this happens an entire page &#8211;complete with CSS and headers&#8211; is returned as the AJAX response. Originally, I detected this by updating the element and then doing doing a regex test on it. If it was an error, I would use another Regex to strip out the error message and update the element again, but because of the CSS, if the same user triggered an error multiple times (eg testing to see if they could submit the comment yet) there would be a momentary flash. I fixed this problem by updating a variable instead of going straight to the element, but it still required using client-side code to process it. </p>
<p>The Setup:<br />
 Some data is posted through AJAX to the server-side script. This script then calls a function (submit_data) which then passes on the data to WordPress. (There is of course PHP and JavaScript that isn&#8217;t shown here.)</p>
<p>The Original Function:<br />
<pre class="brush: php">function submit_form(){
global $wpdb, $post,$id;
	require_once(&#039;../../../../wp-comments-post.php&#039;);
	echo &#039;Comment submitted&#039;;
}</pre><br />
The original function just includes the WordPress file that processes the comments. If the Comment is a success WordPress doesn&#8217;t output any data and the &#8220;Comment submitted&#8221; message is echo&#8217;d. However if there is an error, the error message is outputted and the die() is called before the echo occurs. </p>
<p>The new function that traps the error:<br />
<code title="example code"><br />
function submit_form(){<br />
global $wpdb, $post,$id;<br />
	ob_start("nodie");<br />
		require_once('../../../../wp-comments-post.php');<br />
	ob_end_clean();<br />
	echo 'Comment submitted';<br />
}</p>
<p>function nodie($error){<br />
	return $error;<br />
}<br />
[/sourcecode]</p>
<p>Now we have added the lines line 3 and line 5, plus a new function nodie(). The ob_start callback function (the string we pass to it) is only called if that specific ob_start() is supposed to output text. This only happens two times:  when ob_end_flush() is called or if something inside the ob_start function outputs texts and then a die() is called. When the callback function is called the contents of the output buffer is passed as a string and a string should be returned. </p>
<p>In our function we use ob_end_clean() instead of ob_end_flush() which means the contents of the output buffer is destroyed, not echo'd, so the only time the call back function is called is when, you guessed it, we have an error and WordPress die()'s inside the ob_start().</p>
<p>Now the nodie() function doesn't do anything, but with a little RegEX magic it will return just the error string. Because submitting comments only returns a single error we can just look for the &lt;p&gt;, but if multiple errors may be returned you may want to look for a &lt;ul> also. </p>
<p><pre class="brush: php">function nodie($error){
	preg_match(&#039;@&lt;p&gt;(.*?)&lt;/p&gt;@&#039;, $error,$errs);
	return $errs[1];
}</pre></p>
<p>A couple final notes. Inside the nodie function anything that is outputted will not be returned (eg no echo's or print_r's), but you can call other functions and return their output as a string, so you can create an entire error handling application. Alao, WordPress adds a header to the wp_die() page of text/html if this is inappropriate for your application you can block this by adding the following lines to your function that could cause the error.</p>
<p><pre class="brush: php">Global  $wp_actions;
 $wp_actions[] = &#039;admin_head&#039;;</pre></p>
<p>It is rather hackish, but it works. You then can set the header you need in your callback function.</p>
<p>Of course this technique can be used on a larger scale to completely transform the wp_die page, but in the process, it will require that you trap all content in output buffering, and this method can be used with any other PHP program that you don't have direct control over.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

