<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><!-- generator="wordpress/2.3.3" --><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Perishable Press</title>
	<link>http://perishablepress.com/press</link>
	<description>Digital Design &amp; Dialogue ~</description>
	<pubDate>Sun, 07 Feb 2010 04:36:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<feedburner:info uri="perishablepress" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /><meta xmlns="http://pipes.yahoo.com" name="pipes" content="noprocess" /><image><link>http://perishablepress.com/</link><url>http://perishablepress.com/link/perishable-press.jpeg</url><title>Perishable Press</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://perishablepress.com/press/feed/" /><feedburner:emailServiceId>perishablepress</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://perishablepress.com/press/feed/" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:browserFriendly>Perishable Press provides high-quality, in-depth articles on web design and development, graphic design, social media, blogging, software, and more. Learn how to use WordPress, PHP, SQL, HTAccess, JavaScript, (X)HTML, and CSS to create beautiful sites that are usable, accessible, and secure.</feedburner:browserFriendly><item>
		<title>Should We Support Old Versions of Good Browsers?</title>
		<link>http://perishablepress.com/press/2010/02/01/support-old-versions-good-browsers/</link>
		<comments>http://perishablepress.com/press/2010/02/01/support-old-versions-good-browsers/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 19:39:00 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Websites]]></category>

		<category><![CDATA[browsers]]></category>

		<category><![CDATA[design]]></category>

		<category><![CDATA[firefox]]></category>

		<category><![CDATA[ie]]></category>

		<category><![CDATA[opera]]></category>

		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2010/02/01/support-old-versions-good-browsers/</guid>
		<description><![CDATA[										I mean, basically anything except for Internet Explorer, which is a debate in and of itself. Here I&#8217;m referring to old versions of good browsers, like Firefox 2, Safari 2, Opera 8, and so on. It seems that older versions of these browsers are not as common as older versions of IE, so should we [...]]]></description>
			<content:encoded><![CDATA[										<p>I mean, basically anything except for Internet Explorer, which is a debate in and of itself. Here I&rsquo;m referring to old versions of <em>good</em> browsers, like Firefox 2, Safari 2, Opera 8, and so on. It seems that older versions of these browsers are not as common as older versions of <acronym title="Internet Explorer">IE</acronym>, so should we bother supporting them when designing our websites?</p>
										<blockquote><p>Most agree that we shouldn&rsquo;t support old versions of crappy browsers like <acronym title="Internet Explorer">IE</acronym>, but what about older versions of good browsers like Firefox, Opera, and Safari?</p></blockquote>
										<h3>Backwards Compatibility</h3>
										<p>One of the cool things about adhering to Web Standards during web development is that, theoretically at least, your designs should look similar on all standards-compliant browsers. This is one of the reasons why we exclude <acronym title="Internet Hater">IE</acronym> from the conversation &#8212; it doesn&rsquo;t speak the language, and requires <a href="http://sixrevisions.com/web-development/definitive-guide-to-taming-the-ie6-beast/" title="Definitive Guide to Taming the IE6 Beast">a whole realm of special support</a> in and of itself. But even for modern browsers like Firefox and Safari, a standards-based design does not always translate to presentational fidelity in older versions. So how far back should we go? Obviously there&rsquo;s no reason to go out of our way to support, say, Firefox 1, but what about more recent versions such as 2 or even 3.0?</p>
										<h3>Rendering Differences</h3>
										<p>For many modern browsers, the older the version, the more inconsistencies you&rsquo;ll find. Older versions of Opera are notorious for borking an otherwise perfect design, and the further back you go, the more borked your design is going to get. And for anyone who <em>does</em> support older Opera, you know how frustrating it can be to target and filter specific versions with <acronym title="Cascading Style Sheets">CSS</acronym>. The same is generally true for other modern browsers: supporting older versions can get messy, costing endless amounts of time and energy. There&rsquo;s no reason to have your designs look identical across browsers, but they should at <em>least</em> be usable. Right?</p>
										<h3>Browser Testing</h3>
										<p>If anything is keeping me from completely ignoring older browsers, it is the ease with which they can be tested. Again excluding everyone&rsquo;s favorite, <acronym title="Internet Explorer">IE</acronym>, installing multiple versions of modern browsers is a breeze. For example, on my machines, I am running the following browsers:</p>
										<ul>
										<li>Firefox 1, 2, 3, and 3.5</li>
										<li>Opera 6 through 10</li>
										<li>Safari 2, 3, and 4</li>
										<li>Chrome 2 and 3</li>
										<li>IE 5, 6, 7, and 8</li>
										<li>Camino 1 and 2</li>
										<li>Various Flocks</li>
										</ul>
										<p>..as well as Lynx and a host of lesser browsers using the Webkit or Mozilla rendering engine. And even if you <em>don&rsquo;t</em> install a million browsers locally, there are plenty of online services and software that make it possible to do cross-browser testing on virtually any browser with a few mouse clicks. But if it&rsquo;s so <em>easy</em> to test all of these zillions of old browsers, does that mean we are obliged to do so?</p>
										<blockquote><p>Where do you draw the line between browser support and design expediency? At what point does market share mandate support for old browsers?</p></blockquote>
										<h3>Market Share</h3>
										<p>When deciding how far back to go, market share is certainly an important factor to consider. With that bastard <acronym title="Internet Explorer">IE</acronym>, most of us have no choice but to support older versions simply because so many losers are still using it. But for <em>good</em> browsers such as Opera and Safari, most users are quite savvy, understanding the game and always keeping their browsers updated with the latest and greatest. This is another reason to love modern browsers: they make the upgrade process a piece of cake &#8212; you don&rsquo;t even need to think about it &#8212; it just <em>happens</em>. Thus, while we are still dealing with <acronym title="Internet Explorer">IE</acronym>6 and lots of <acronym title="Internet Explorer">IE</acronym>7 &#8212; even though <acronym title="Internet Explorer">IE</acronym>8 is the <em>current</em> version &#8212; the percentage of Firefox 2, Opera 8, and Safari 2 users is very small.</p>
										<h3>Baseline Support</h3>
										<p>Given that it <em>is</em> important to maintain usability, presentation, and performance across older versions of modern browsers, where should the baseline be set? Is there some general rule of thumb that will help designers with an optimal support strategy? Perhaps something like this:</p>
										<ul>
										<li><strong>One version back -</strong> complete compatibility and presentational fidelity</li>
										<li><strong>Two versions back -</strong> design should be usable, but doesn&rsquo;t need to look similar</li>
										<li><strong>Three or more back -</strong> don&rsquo;t sweat it &#8212; cost versus reward <strong>not</strong> in your favor</li>
										</ul>
										<p>Personally, I try to support as many browsers as possible, but much of what I do depends on the particular project I am working on. Not every site needs to be checked on every browser, so I try to take into account the stats and projected client-usage data. It&rsquo;s all about context, and varies on a case-by-case basis.</p>
										<p>But support baselines <em>can</em> be useful. A <a href="http://perishablepress.com/" title="Digital Design and Dialogue">Perishable Press</a> reader recently described his support baseline as such:</p>
										<ul>
										<li>IE7+</li>
										<li>Opera 9+</li>
										<li>Safari 4+</li>
										<li>Firefox 3.5+</li>
										</ul>
										<p>His thinking is that older browsers:</p>
										<ul>
										<li>Have security holes by nature, therefore isn&#8217;t it irresponsible to support them?</li>
										<li>Reduce the ability for the site to look good and is bad practice, even within an organization</li>
										<li>Give the website visitor a lower experience than they deserve and what they should expect</li>
										<li>Generally run slower and reduce the appearance of speed for your site</li>
										</ul>
										<p>While I can&rsquo;t agree with everything in this list, he does make some good points. And more importantly, this designer has taken the time to think it out for himself and reach his <em>own</em> conclusions, which I think is very important.</p>
										<h3>It&rsquo;s the User, Stupid</h3>
										<p>Ultimately, it may be argued, that it&rsquo;s all about the <em>user</em>. Sacrificing the user at the altar of design expediency benefits only in the short term. Eventually, those development shortcuts are going to catch up with you one way or another. So if design <em>is</em> all about the user, I guess we&rsquo;re obliged to test for each and every possible scenario <em>regardless of market share</em> &#8212; test every browser on every platform on every machine in the world. Of course this is ludicrous, but it begs the question: where do you draw the line between browser support and design expediency? At what point does market share mandate support for old browsers?</p>
										<p>Food for thought..</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2010/02/01/support-old-versions-good-browsers/" title="Read 'Should We Support Old Versions of Good Browsers?' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/10/07/perishable-press-quintessential-screenshot-gallery/" title="Perishable Press Quintessential Screenshot Gallery (October 7, 2008)">Perishable Press Quintessential Screenshot Gallery</a></li>
					<li><a href="http://perishablepress.com/press/2009/12/13/simple-browser-detection/" title="Really Simple Browser Detection with jQuery (December 13, 2009)">Really Simple Browser Detection with jQuery</a></li>
					<li><a href="http://perishablepress.com/press/2008/11/24/perfect-rounded-corners-with-css/" title="Perfect Rounded Corners with CSS (November 24, 2008)">Perfect Rounded Corners with CSS</a></li>
					<li><a href="http://perishablepress.com/press/2007/10/17/everything-you-ever-wanted-to-know-about-favicons/" title="Everything You Ever Wanted to Know about Favicons (October 17, 2007)">Everything You Ever Wanted to Know about Favicons</a></li>
					<li><a href="http://perishablepress.com/press/2008/07/01/a-sincere-attempt-to-switch-from-firefox-to-opera/" title="A Sincere Attempt to Switch from Firefox to Opera (July 1, 2008)">A Sincere Attempt to Switch from Firefox to Opera</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/10/keep-it-dark-hiding-and-filtering-css/" title="Keep it Dark: Hiding and Filtering CSS (January 10, 2007)">Keep it Dark: Hiding and Filtering CSS</a></li>
					<li><a href="http://perishablepress.com/press/2007/05/01/standards-compliance-throwdown/" title="Standards-Compliance Throwdown: MS-IE5/6 DNS/404 Error-Page Redesign (May 1, 2007)">Standards-Compliance Throwdown: MS-IE5/6 DNS/404 Error-Page Redesign</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=Vwe572wYmTM:oDACWfeePt0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Vwe572wYmTM:oDACWfeePt0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=Vwe572wYmTM:oDACWfeePt0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Vwe572wYmTM:oDACWfeePt0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=Vwe572wYmTM:oDACWfeePt0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Vwe572wYmTM:oDACWfeePt0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=Vwe572wYmTM:oDACWfeePt0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Vwe572wYmTM:oDACWfeePt0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=Vwe572wYmTM:oDACWfeePt0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Vwe572wYmTM:oDACWfeePt0:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Vwe572wYmTM:oDACWfeePt0:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2010/02/01/support-old-versions-good-browsers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>3 Ways to Track Web Pages with Google Analytics</title>
		<link>http://perishablepress.com/press/2010/01/24/3-ways-track-google-analytics/</link>
		<comments>http://perishablepress.com/press/2010/01/24/3-ways-track-google-analytics/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 02:58:13 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Function]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[analytics]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[google]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2010/01/24/3-ways-track-google-analytics/</guid>
		<description><![CDATA[										 Many bloggers, designers, and developers take advantage of Google&#8217;s free Analytics service to track and monitor their site&#8217;s statistics. Along with a Google account, all that&#8217;s needed to use Google Analytics is the addition of a small slice of JavaScript into your web pages. For a long time, there was only one way of [...]]]></description>
			<content:encoded><![CDATA[										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2010/misc-chunks/google-analytics.png" alt="[ Google Analytics ]" /> Many bloggers, designers, and developers take advantage of <a href="http://www.google.com/analytics/" title="Google Analytics">Google&rsquo;s free Analytics service</a> to track and monitor their site&rsquo;s statistics. Along with a Google account, all that&rsquo;s needed to use Google Analytics is the addition of a small slice of JavaScript into your web pages. For a long time, there was only one way of doing this, and then in 2007 Google improved their <acronym title="Google Analytics Tracking Code">GATC</acronym> code and established a new way for including it in your web pages. Many people switched over to the newer optimized method, but may not realize that there are now <em>three</em> different ways to track your pages with Google Analytics. The latest method uses <em>asynchronous tracking</em> to minimize negative impact on user experience. Let&rsquo;s take a look at each of these three methods for tracking your web pages with Google Analytics..</p>
										<h3>Method 1: Old School &ndash; Tracking sites with <code>urchin.js</code></h3>
										<p>Web-design veterans are well familiar with the original, old-school method of <acronym title="Google Analytics Tracking Code">GATC</acronym> inclusion via the <code>urchin.js</code> code:</p>
										<pre><code>&lt;script type="text/javascript"&gt;
_uacct = "UA-XXXXX-X";
urchinTracker();
&lt;/script&gt;</code></pre>
										<p>Ahh yes, those were the days.. This method worked great for years, and continues to work just fine to this very day. Although I personally would recommend using one of the newer methods of including the <acronym title="Google Analytics Tracking Code">GATC</acronym>, you may still use this old-school method by simply copying and pasting the code into the <em>bottom</em> of your web pages, preferably before the closing <code>&lt;body&gt;</code> element. And then don&rsquo;t forget to edit the &ldquo;<code>UA-XXXXX-X</code>&rdquo; string to match your actual <acronym title="Google Analytics">GA</acronym> <acronym title="Identification">ID</acronym>. </p>
										<p>So that&rsquo;s pretty boring &#8212; let&rsquo;s check out something a little newer..</p>
										<h3>Method 2: New School &ndash; Tracking sites with <code>ga.js</code></h3>
										<p>In late 2007 &ndash; after years of using the original <code>urchin.js</code> script &ndash; Google updated and improved the <acronym title="Google Analytics Tracking Code">GATC</acronym> and renamed the tracking file to &ldquo;<code>ga.js</code>&rdquo;. As of now, this new tracking code is the platform on which all new Google Analytics features are deployed.</p>
										<p>Here are some of the benefits of using the new <code>ga.js</code>  tracking script:</p>
										<ul>
										<li>Smaller file size</li>
										<li>Improved performance</li>
										<li>Object-oriented programming conventions</li>
										<li>Namespacing and improved readability</li>
										<li>Easy JavaScript integration</li>
										</ul>
										<p>As with the old <code>urchin.js</code>-based method, using this new method requires inclusion of a small snippet of tracking code on your web pages. Depending on how you deliver your pages &#8212; over <acronym title="Hypertext Transfer Protocol">HTTP</acronym>, <acronym title="Secure Sockets Layer">SSL</acronym>, or a combination of both &#8212; the code used to include the new Google Analytics tracking code will vary:</p>
										<h4>All web pages delivered via standard <acronym title="Hypertext Transfer Protocol">HTTP</acronym> protocol</h4>
										<pre><code>&lt;script src="http://www.google-analytics.com/ga.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var pageTracker = _gat._getTracker("UA-XXXXX-X");
pageTracker._trackPageview();
&lt;/script&gt;</code></pre>
										<h4>All web pages delivered via secure <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (<acronym title="Secure Sockets Layer">SSL</acronym>)</h4>
										<pre><code>&lt;script src="https://ssl.google-analytics.com/ga.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var pageTracker = _gat._getTracker("UA-XXXXX-X");
pageTracker._trackPageview();
&lt;/script&gt;</code></pre>
										<h4>Web pages delivered via combination of standard and secure protocols</h4>
										<pre><code>&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;</code></pre>
										<p>As you can see, each of these methods consists of two parts: the first references the <code>ga.js</code> tracking code and the second executes it. A couple of notes on proper/recommended usage of either of these methods:</p>
										<ul>
										<li>Do not combine different tracking scripts on the same page</li>
										<li>Inlcude the tracking code <strike>after</strike> before the closing <code>&lt;body&gt;</code> element at the bottom of your web pages</li>
										<li>Do not combine the <code>ga.js</code> method with the old <code>urchin.js</code> method</li>
										<li>Don&rsquo;t forget to edit the &ldquo;<code>UA-XXXXX-X</code>&rdquo; string to match your actual <acronym title="Google Analytics">GA</acronym> <acronym title="Identification">ID</acronym></li>
										</ul>
										<p>I think this is the <acronym title="Google Analytics">GA</acronym>-inclusion method that most bloggers and designers are using in their pages. But even so, there is yet another way of including the tracking code that improves the user-experience for your visitors..</p>
										<h3>Method 3: Asynchronous Tracking &ndash; Better tracking with <code>ga.js</code></h3>
										<p>This newer method of <acronym title="Google Analytics">GA</acronym> tracking uses a slice of asynchronous JavaScript to optimize the way in which browsers load the <code>ga.js</code> tracking script. The asynchronous tracking method improves the user experience and allows inclusion of the tracking script closer to the beginning of the web page without delaying subsequent content from rendering. As you might suspect, the asynchronous tracking method requires a slightly more complex inclusion method:</p>
										<pre><code>&lt;script type="text/javascript"&gt;
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
&lt;/script&gt;</code></pre>
										<p>This code represents the <em>minimum</em> configuration required to track a page asynchronously using Google Analytics. To take advantage of this method, you can use this tracking script on your pages by following the simple steps below. To go beyond the basics, check the official <a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApi.html">tracking reference</a> and <a href="http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html">usage guide</a> for information on the <acronym title="Google Analytics">GA</acronym> <acronym title="Application Programming Interface">API</acronym> and proper asynchronous syntax.</p>
										<h4>How to setup asynchronous analytics tracking on your site</h4>
										<ol>
										<li>Important: Remove any existing <code>ga.js</code> tracking code, if present <sup>1</sup></li>
										<li>Insert the asynchronous snippet <strike>before the closing <code>&lt;/head&gt;</code> element</strike> after the opening <code>&lt;body&gt;</code> tag <sup>2</sup></li>
										<li>Edit the &ldquo;<code>UA-XXXXX-X</code>&rdquo; string to match your specific web-property <acronym title="Identification">ID</acronym></li>
										<li>Add any customizations using the <acronym title="Google Analytics">GA</acronym> <acronym title="Application Programming Interface">API</acronym> and asynchronous syntax</li>
										</ol>
										<p>That&rsquo;s all there is to getting asynchronous <acronym title="Google Analytics">GA</acronym> tracking setup on your site. Of course, there are a few important notes that you should keep in mind:</p>
										<ul>
										<li>If you experience content-loading issues, move the tracking code to the bottom of the page</li>
										<li><sup>1</sup> Asynchronous tracking is not available with the old <code>urchin.js</code>-based method.</li>
										<li><sup>2</sup> <strike>The optimal place for the tracking snippet is after the last <code>&lt;script&gt;</code> element in the <code>&lt;head&gt;</code> section</strike> Edit: &ldquo;While it is customary to place JavaScript code in the <code>&lt;head&gt;</code> section, placing the asynchronous snippet there may trigger a parsing bug in Internet Explorer 6 and 7 on some pages. The easiest solution to this problem is to place it at the top of the <code>&lt;body&gt;</code> section.&rdquo; &ndash; <a href="http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html" title="Google Analytics Asynchronous Tracking">Google Analytics Asynchronous Tracking</a></li>
										<li>Do not use more than one tracking snippet on any given page &#8212; you&rsquo;ll break stuff</li>
										</ul>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2010/01/24/3-ways-track-google-analytics/" title="Read '3 Ways to Track Web Pages with Google Analytics' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/02/04/optimizing-google-analytics-performance/" title="Optimizing Google Analytics Performance (February 4, 2008)">Optimizing Google Analytics Performance</a></li>
					<li><a href="http://perishablepress.com/press/2008/11/25/save-bandwidth-by-serving-jquery-mootools-prototype-via-googles-ajax-libraries-api/" title="Save Bandwidth by Serving jQuery, MooTools, Prototype via Google's AJAX Libraries API (November 25, 2008)">Save Bandwidth by Serving jQuery, MooTools, Prototype via Google's AJAX Libraries API</a></li>
					<li><a href="http://perishablepress.com/press/2009/01/25/feedburner-count-fallbacks/" title="PHP and JavaScript Fallbacks for Your Public Feedburner Count (January 25, 2009)">PHP and JavaScript Fallbacks for Your Public Feedburner Count</a></li>
					<li><a href="http://perishablepress.com/press/2006/03/22/javascript-notes-plus/" title="JavaScript Notes Plus (March 22, 2006)">JavaScript Notes Plus</a></li>
					<li><a href="http://perishablepress.com/press/2006/05/23/google-analytics-invitation/" title="Google Analytics Invitation (May 23, 2006)">Google Analytics Invitation</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/29/optimize-convoluted-code-via-javascript/" title="Optimize Convoluted Code via JavaScript (August 29, 2006)">Optimize Convoluted Code via JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2006/10/04/one-link-to-open-them-all/" title="One Link to Open Them All (October 4, 2006)">One Link to Open Them All</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=D9eDlRLuhhI:j-UVNWFOOtI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=D9eDlRLuhhI:j-UVNWFOOtI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=D9eDlRLuhhI:j-UVNWFOOtI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=D9eDlRLuhhI:j-UVNWFOOtI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=D9eDlRLuhhI:j-UVNWFOOtI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=D9eDlRLuhhI:j-UVNWFOOtI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=D9eDlRLuhhI:j-UVNWFOOtI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=D9eDlRLuhhI:j-UVNWFOOtI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=D9eDlRLuhhI:j-UVNWFOOtI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=D9eDlRLuhhI:j-UVNWFOOtI:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=D9eDlRLuhhI:j-UVNWFOOtI:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2010/01/24/3-ways-track-google-analytics/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CSS3 + Progressive Enhancement = Smart Design</title>
		<link>http://perishablepress.com/press/2010/01/11/css3-progressive-enhancement-smart-design/</link>
		<comments>http://perishablepress.com/press/2010/01/11/css3-progressive-enhancement-smart-design/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 22:07:52 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[css3]]></category>

		<category><![CDATA[design]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2010/01/11/css3-progressive-enhancement-smart-design/</guid>
		<description><![CDATA[										Progressive enhancement is a good thing, and CSS3 is even better. Combined, they enable designers to create lighter, cleaner websites faster and easier than ever before..
										 CSS3 can do some pretty amazing stuff: text shadows, rgba transparency, multiple background images, embedded fonts, and tons more. It&#8217;s awesome, but not all browsers are up to snuff. [...]]]></description>
			<content:encoded><![CDATA[										<blockquote><p>Progressive enhancement is a good thing, and <acronym title="Cascading Style Sheets">CSS</acronym>3 is even better. Combined, they enable designers to create lighter, cleaner websites faster and easier than ever before..</p></blockquote>
										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2010/misc-chunks/css3-chunk.png" alt="[ CSS3 ]" /> <acronym title="Cascading Style Sheets">CSS</acronym>3 can do some pretty amazing stuff: <a href="http://www.w3.org/Style/Examples/007/text-shadow" title="W3C - Text shadows">text shadows</a>, <a href="http://www.w3.org/TR/css3-color/" title="W3C - CSS Color Module Level 3">rgba transparency</a>, <a href="http://www.w3.org/TR/2009/CR-css3-background-20091217/" title="W3C - CSS Backgrounds and Borders Module Level 3">multiple background images</a>, <a href="http://dev.w3.org/csswg/css3-fonts/" title="W3C - CSS Fonts Module Level 3">embedded fonts</a>, and <a href="http://www.w3.org/TR/css3-roadmap/" title="W3C - Introduction to CSS3">tons more</a>. It&rsquo;s awesome, but not all browsers are up to snuff. As designers, it&rsquo;s up to us to decide which browsers to support for our projects. While everyone has their own particular strategy, there seem to be three general approaches:</p>
										<ul>
										<li><strong>Support all browsers with perfect fidelity</strong> &ndash; not realistic for most budgets, requires many elaborate workarounds, hacks, etc., also difficult to maintain, upgrade, and extend.</li>
										<li><strong>Support all browsers to some degree</strong> &ndash; focus first on the latest and greatest browsers, and then go back and make sure that older browsers look and work reasonably well.</li>
										<li><strong>Support newer browsers, forget about the older stuff</strong> &ndash; make your sites look pixel-perfect on the newest versions of modern browsers and don&rsquo;t worry about anything else.</li>
										</ul>
										<p>Among these generalized strategies, the second approach comes closest to the concept of progressive enhancement. In practice, progressive enhancement enables designers to design websites according to some predetermined support baseline and then gradually improve and optimize appearance and functionality to accommodate the most advanced browsers. Closely related to this idea is the principle of graceful degradation, which is what should happen when newer design methods aren&rsquo;t understood or supported by certain browsers. Consider the following example..</p>
										<h3>A Quick Example</h3>
										<p>Consider a basic layout done with good &lsquo;ol <acronym title="Cascading Style Sheets">CSS</acronym> 2.1 and <acronym title="Hypertext Markup Language">HTML</acronym> 4.01. We would begin with a clean layout that looks and works good in just about any browser. We&rsquo;re talking <em>basic</em> styles here, stuff like:</p>
										<ul>
										<li>basic layout and composition</li>
										<li>background, border, and font colors</li>
										<li>font families, styles, and transformations</li>
										<li>basic styles for <acronym title="Hypertext Markup Language">HTML</acronym> elements</li>
										<li>decorative graphics, link styles and so on</li>
										</ul>
										<p>The idea here is to begin with a nice, well-styled presentation that looks good in even archaic browsers like <acronym title="Internet Explorer">IE</acronym>6. This is a good thing because even visitors using crappy browsers will be able to read and interact with your content. But instead of stopping there, progressive enhancement says, &ldquo;let&rsquo;s provide some additional features for people using better browsers.&rdquo; After all, people using awesome browsers like Firefox, Safari, and Opera want the best experience possible from the Web. Progressive enhancement says, &ldquo;let&rsquo;s give it to them, but only after the less-capable crowd has been taken care of first.&rdquo;</p>
										<h3>CSS 3 and Progressive Enhancement</h3>
										<p>Progressive enhancement provides a well-defined strategy for implementing <acronym title="Cascading Style Sheets">CSS</acronym>3 into the presentational layer of our designs. Rather than worrying about universal pixel-perfection and trying to accommodate unsupportive browsers with all sorts of filters, hacks, and scripts, we can take advantage of the <acronym title="Cascading Style Sheets">CSS</acronym> cascade and deliver styles according to each browser&rsquo;s capabilities. If <acronym title="Internet Explorer">IE</acronym> doesn&rsquo;t get the whole &ldquo;rounded corners&rdquo; thing, then it&rsquo;s gonna get some square corners instead. Is this a big deal? Only if it interferes with the user&rsquo;s ability to read and use the content. Is it fair? Heck no, but there is nothing stopping people from upgrading to a <em>better browser</em> (they&rsquo;re <em>free</em> after all). Meanwhile Safari 4 is gonna rock those rounded corners just fine.</p>
										<blockquote><p>Progressive enhancement enables us to establish a solid baseline of cross-browser support and then enhance the design with advanced <acronym title="Cascading Style Sheets">CSS</acronym> features for supportive browsers.</p></blockquote>
										<p>The key thing of course is to begin with a solid baseline design that works well in as many browsers as possible. Once this is done, there is no reason to worry about <em>which</em> browsers support <em>which</em> <acronym title="Cascading Style Sheets">CSS</acronym> 3 properties because your site is going to work fine regardless of support. Then, in those situations where some sort of advanced support is desired, you can always go in and fix things up as needed. There are a wide variety of solutions for supporting the latest and greatest <acronym title="Cascading Style Sheets">CSS</acronym>3 tricks, including <a href="http://perishablepress.com/press/2009/12/13/simple-browser-detection/" title="Really Simple Browser Detection with jQuery">browser detection</a>, <a href="http://perishablepress.com/press/2008/05/28/css-hackz-series-png-fix-for-internet-explorer/" title="CSS Hackz Series: PNG Fix for Internet Explorer">proprietary expressions</a>, <a href="http://perishablepress.com/press/2006/09/04/fun-with-downlevel-conditional-comments/" title="Fun with Downlevel Conditional Comments">conditional</a> <a href="http://perishablepress.com/press/2007/07/18/wrapping-your-head-around-downlevel-conditional-comments/" title="Wrapping Your Head around Downlevel Conditional Comments">comments</a>, <a href="http://perishablepress.com/press/tag/hacks/" title="Perishable Press Archive for all posts tagged 'hacks'"><acronym title="Cascading Style Sheets">CSS</acronym> hacks</a> and other workarounds. Indeed, you can go as crazy as you want to, but the whole point of this article is to explain that you can avoid the fuss by <em>progressively enhancing</em> your site instead.</p>
										<h3>Do More with Less Code</h3>
										<p>Why even bother with <acronym title="Cascading Style Sheets">CSS</acronym>3? Because you can <a href="http://perishablepress.com/press/2009/07/19/power-of-html5-css3/" title="The Power of HTML 5 and CSS 3">do more with less code</a>. Take <a href="http://perishablepress.com/press/2008/11/24/perfect-rounded-corners-with-css/" title="Perfect Rounded Corners with CSS">rounded corners</a>, for example. The old way of styling a box with rounded corners involved splicing up images and adding multiple, non-semantic elements to the markup. This method still works, but it is more time-consuming and resource-intensive than simply adding a slice of <acronym title="Cascading Style Sheets">CSS</acronym> to your stylesheet:</p>
										<pre><code>.rounded-corners {
	-webkit-border-radius: 7px;
	-khtml-border-radius: 7px;	
	-moz-border-radius: 7px;
	border-radius: 7px;
	}</code></pre>
										<p>The benefits of using the <acronym title="Cascading Style Sheets">CSS</acronym> technique over the image-based method include:</p>
										<ul>
										<li>Requires less bandwidth usage</li>
										<li>Reduces number of <acronym title="Hypertext Transfer Protocol">HTTP</acronym> requests</li>
										<li>Requires fewer server resources</li>
										<li>Less time required to implement</li>
										<li>Safeguards against browser updates</li>
										<li>Creates a more flexible site design</li>
										</ul>
										<p>Sound good? Now let&rsquo;s get into the practical side of things and learn how to use progressive enhancement to implement some awesome <acronym title="Cascading Style Sheets">CSS</acronym>-3 techniques.</p>
										<h3 id="toc">Table of Contents</h3>
										<ul>
										<li><a href="#css3-01" class="anchor">Multiple Backgrounds</a></li>
										<li><a href="#css3-02" class="anchor">Background Sizing</a></li>
										<li><a href="#css3-03" class="anchor">Border Images</a></li>
										<li><a href="#css3-04" class="anchor">Rounded Corners</a></li>
										<li><a href="#css3-05" class="anchor">Drop Shadows</a></li>
										<li><a href="#css3-06" class="anchor">Text Shadows</a></li>
										<li><a href="#css3-07" class="anchor">Alternate Row Styles</a></li>
										<li><a href="#css3-08" class="anchor">Opacity &amp; Transparency</a></li>
										<li><a href="#css3-09" class="anchor">Custom Fonts</a></li>
										<li><a href="#css3-10" class="anchor">Custom Text-Highlight Styles</a></li>
										<li><a href="#css3-11" class="anchor">Multi-Column Content Display</a></li>
										<li><a href="#css3-12" class="anchor">Box Sizing</a></li>
										<li><a href="#css3-13" class="anchor">RGBa Colors and Transparency</a></li>
										<li><a href="#css3-14" class="anchor">Word Wrap</a></li>
										<li><a href="#css3-15" class="anchor">Resizable Elements</a></li>
										<li><a href="#css3-16" class="anchor">CSS Transitions</a></li>
										<li><a href="#css3-17" class="anchor">CSS Color Gradients</a></li>
										<li><a href="#css3-18" class="anchor">Rotating Elements</a></li>
										</ul>
										<h3 id="css3-01">Multiple Backgrounds <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Multiple background images via <acronym title="Cascading Style Sheets">CSS</acronym> enables us to do some awesome multi-layer graphics without all the extraneous markup to make it work. Using <acronym title="Cascading Style Sheets">CSS</acronym>3&rsquo;s multiple-background functionality is an excellent way to enhance your design while simplifying your markup. Here is the general technique:</p>
										<pre><code>.multiple-bg-images {
	background: url(http://domain.tld/path/layer-01.png) no-repeat 0 0;
	background: url(http://domain.tld/path/layer-01.png) no-repeat 0 0,
		    url(http://domain.tld/path/layer-02.png) no-repeat 0 0,
		    url(http://domain.tld/path/layer-03.png) no-repeat 0 0,
		    url(http://domain.tld/path/layer-04.png) no-repeat 0 0;
	}</code></pre>
										<p>Alternately, we can use the following syntax:</p>
										<pre><code>.multiple-bg-images {
	background: url(http://domain.tld/path/layer-01.png) no-repeat 0 0;
	background-image: url(http://domain.tld/path/layer-01.png), url(http://domain.tld/path/layer-02.png), url(http://domain.tld/path/layer-03.png), url(http://domain.tld/path/layer-04.png);
	background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
	background-position: 0 0, 0 0, 0 0, 0 0;
	}</code></pre>
										<p>This works just like single background images in <acronym title="Cascading Style Sheets">CSS</acronym>2.1, but now we can add up to four background images using additional, comma-separated property values, each of which can have its own specific parameters such as <code>repeat</code> and <code>position</code>. The images will be displayed such that each subsequent image appears <em>beneath</em> the previous one. Unsupportive browsers will ignore the second <code>background</code> property and render the first rule, which should display our baseline, fallback image.</p>
										<h3 id="css3-02">Background Sizing <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Although current support for <acronym title="Cascading Style Sheets">CSS</acronym>3&rsquo;s <code>background-size</code> property exists only through vendor-specific properties, the following technique enables us to size backgrounds in a large percentage of browsers:</p>
										<pre><code>.background-size { 
	background-image: url(http://domain.tld/path/bg.png);
	-webkit-background-size: 50% 50%; /* Safari  */
	-khtml-background-size: 50% 50%;  /* Konquer */
	-moz-background-size: 50% 50%;    /* Firefox */
	-o-background-size: 50% 50%;      /* Opera   */
	background-size: 50% 50%;	  /* CSS3    */
	}</code></pre>
										<p>The <code>background-size</code> property enables us to scale the background image according to our design needs. This is useful for maintaining specific proportions when using background images for <code>&lt;div&gt;</code>s, heading elements, and of course <code>&lt;body&gt;</code> and <code>&lt;html&gt;</code> elements as well.</p>
										<h3 id="css3-03">Border Images <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p><acronym title="Cascading Style Sheets">CSS</acronym>3&rsquo;s <code>border-image</code> property opens the door to many new graphical layout possibilities. The <code>border-image</code> property is complicated, but provides a powerful tool once it is understood. Browser support for <code>border-image</code> is growing, and there is good support for vendor-specific prefix-properties. Here is an example implementation that works in many modern browsers:</p>
										<pre><code>.border-image {
	border: solid transparent;
	border-width: 10px 20px 10px 20px;

	-webkit-border-image: url("http://domain.tld/path/border.png") 10 20 10 20 round round;
	-khtml-border-image:  url("http://domain.tld/path/border.png") 10 20 10 20 round round;
	-icab-border-image:   url("http://domain.tld/path/border.png") 10 20 10 20 round round;
	-moz-border-image:    url("http://domain.tld/path/border.png") 10 20 10 20 round round;
	-o-border-image:      url("http://domain.tld/path/border.png") 10 20 10 20 round round;
	border-image:         url("http://domain.tld/path/border.png") 10 20 10 20 round round;
	}</code></pre>
										<p>First we are specifying our default border. This defines the area in which the border image will be displayed, and also serves as a fallback for unsupportive browsers. The next six declarations specify the <code>border-image</code> property for different browsers. Each of the property values indicates the image location, the slice area, and the repeat style. There are also several additional parameters that further extend the functionality of the <code>border-image</code> property. Here is how we would target each of the four side-images <em>and</em> each of the four corner-images separately:</p>
										<pre><code>.border-image {
	border-top-image:          url("http://domain.tld/path/border-top.png")          10 20 10 20 round round;  
	border-right-image:        url("http://domain.tld/path/border-right.png")        10 20 10 20 round round;  
	border-bottom-image:       url("http://domain.tld/path/border-bottom.png")       10 20 10 20 round round;  
	border-left-image:         url("http://domain.tld/path/border-left.png")         10 20 10 20 round round;  
	border-top-left-image:     url("http://domain.tld/path/border-topleft.png")      10 20 10 20 round round;  
	border-top-right-image:    url("http://domain.tld/path/border-topright.png")     10 20 10 20 round round;  
	border-bottom-left-image:  url("http://domain.tld/path/border-bottom-left.png")  10 20 10 20 round round;  
	border-bottom-right-image: url("http://domain.tld/path/border-bottom-right.png") 10 20 10 20 round round;  
	}</code></pre>
										<p>As you can see, the new <code>border-image</code> property is powerful and flexible, making it possible to design any style of border quickly and efficiently. To get an idea of the possibilities, check out the new <a href="http://www.w3.org/TR/2009/CR-css3-background-20091217/" title="W3C - CSS Backgrounds and Borders Module Level 3"><acronym title="Cascading Style Sheets">CSS</acronym> Backgrounds and Borders Module</a> at the <acronym title="World Wide Web Consortium">W3C</acronym> website.</p>
										<h3 id="css3-04">Rounded Corners <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Rounded corners can enhance the appearance of many designs. For years, designers have been using multiple background images and superfluous markup and/or JavaScript to get the job done. Using <acronym title="Cascading Style Sheets">CSS</acronym>3&rsquo; <code>border-radius</code> property, rounding corners to any radius is a breeze:</p>
										<pre><code>.rounded-corners {
	border: 1px solid #171717;
	-webkit-border-radius: 7px;
	-khtml-border-radius: 7px;	
	-moz-border-radius: 7px;
	border-radius: 7px;
	}</code></pre>
										<p>We can also round specific corners like so:</p>
										<pre><code>.rounded-corner-top-left {
	-webkit-border-top-left-radius: 7px;
	-khtml-border-radius-topleft: 7px;	
	-moz-border-radius-topleft: 7px;
	border-top-left-radius: 7px;
	}</code></pre>
										<p>Combined with multiple background images, border images, and drop shadows, rounded corners makes designing beautiful sites easier than ever before. As discussed previously, browsers that do not support rounded corners will have to suffer with &ndash; <em>gasp!</em> &ndash; square corners. This is a perfect example of how to progressively enhance your designs with <acronym title="Cascading Style Sheets">CSS</acronym>3. Also check out these <a href="http://perishablepress.com/press/2008/11/24/perfect-rounded-corners-with-css/" title="Perfect Rounded Corners with CSS">easy copy-&amp;-paste rounded-corner recipes</a>.</p>
										<h3 id="css3-05">Drop Shadows <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Drop shadows are another great example of a design element that should be applied via progressive enhancement. As cool as they are, there is no reason to splice up a bunch of images, implement a <acronym title="Portable Network Graphics">PNG</acronym> fix, and add extra markup and styles just to ensure that crusty old versions of <acronym title="Internet Explorer">IE</acronym> are gonna get some drop-shadow embellishments. It&rsquo;s like, who cares? With <acronym title="Cascading Style Sheets">CSS</acronym>3, we can deliver customized drop shadows to all good browsers with a few lines of code:</p>
										<pre><code>.single-drop-shadow {
	border: 1px solid #333;
	box-shadow: 1px 1px 7px #999;
	-moz-box-shadow: 1px 1px 7px #999;
	-webkit-box-shadow: 1px 1px 7px #999;
	}</code></pre>
										<p>The <code>box-shadow</code> property accepts four parameter values, <code>x-axis</code>, <code>y-axis</code>, <code>blur</code>, and <code>color</code> (in that order). These parameters control the x-y offset, shadow-blur, and shadow-color, respectively. Note that drop shadows will only be rendered on elements that have a border applied. If we&rsquo;re feeling frisky, we can also throw down multiple drop-shadows on a single element:</p>
										<pre><code>.single-drop-shadow {
	border: 1px solid #333;
	box-shadow: 1px 1px 7px #999, 1px 1px 10px #cc0000;
	-moz-box-shadow: 1px 1px 7px #999, 1px 1px 10px #cc0000;
	-webkit-box-shadow: 1px 1px 7px #999, 1px 1px 10px #cc0000;
	}</code></pre>
										<p>Here we are combining two drop shadows with similar offsets, but with different blurs and colors. And you can even get something similar on <acronym title="Internet Explorer">IE</acronym> using some proprietary <code>Shadow</code> filters:</p>
										<pre><code>.ie-shadow {
	-ms-filter: /* IE8+ */
		"progid:DXImageTransform.Microsoft.Shadow(color=#999999, direction=0, strength=7) 
		 progid:DXImageTransform.Microsoft.Shadow(color=#777777, direction=90, strength=10) 
		 progid:DXImageTransform.Microsoft.Shadow(color=#777777, direction=180, strength=10) 
		 progid:DXImageTransform.Microsoft.Shadow(color=#999999, direction=270, strength=7)";
	filter: /* IE&lt;8 */
		 progid:DXImageTransform.Microsoft.Shadow(color=#999999, direction=0, strength=7) 
		 progid:DXImageTransform.Microsoft.Shadow(color=#777777, direction=90, strength=10) 
		 progid:DXImageTransform.Microsoft.Shadow(color=#777777, direction=180, strength=10) 
		 progid:DXImageTransform.Microsoft.Shadow(color=#999999, direction=270, strength=7);
	}</code></pre>
										<p>Likewise, we could use the <code>dropshadow</code> filter to achieve a similar effect:</p>
										<pre><code>.ie-drop-shadow {
	-ms-filter: /* IE8+ */
		"filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=7, OffY=7, Color=#555, Positive=true)";
	filter: /* IE&lt;8 */
		filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=7, OffY=7, Color=#555, Positive=true);
	}</code></pre>
										<p>This kind of proprietary nonsense makes the concept of progressive enhancement extremely attractive.</p>
										<h3 id="css3-06">Text Shadows <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Another subtle visual enhancement is possible with some strategically placed text shadows. Certainly no need to create image replacements for your shadowed text, just throw down a few lines of <acronym title="Cascading Style Sheets">CSS</acronym>3 for supportive browsers and deliver regular text styles to less-capable browsers:</p>
										<pre><code>.text-shadow {
	text-shadow: 1px 1px 3px #777;
	}</code></pre>
										<p>Nothing to it. The <code>text-shadow</code>&rsquo;s parameters are, in order, x-axis offset, y-axis offset, shadow blur, and shadow color. Multiple shadows are also possible:</p>
										<pre><code>.text-shadow {
	text-shadow: 1px 1px 3px #777, 2px 2px 7px #999;
	}</code></pre>
										<p>Simply separate multiple shadows with commas and you&rsquo;re good to go. If you want to support <acronym title="Internet Exploder">IE</acronym>, add the following filter declarations to your <code>.text-shadow</code> class:</p>
										<pre><code>.ie-text-shadow {
	-ms-filter: /* IE8+ */
		"progid:DXImageTransform.Microsoft.MotionBlur(strength=1, direction=220) 
		 progid:DXImageTransform.Microsoft.Blur(pixelradius=3) 
		 dropshadow(color=#777777, offx=1, offy=1)";
	filter: /* IE&lt;8 */
		 progid:DXImageTransform.Microsoft.MotionBlur(strength=1, direction=220) 
		 progid:DXImageTransform.Microsoft.Blur(pixelradius=3) 
		 dropshadow(color=#777777, offx=1, offy=1);
	}</code></pre>
										<p>Again, this sort of monstrosity is easily avoided by delivering the text shadows to capable browsers and not worrying about the dinosaurs. Seriously, do you think anyone using Internet Explorer is going to notice the difference? Chances are good that they couldn&rsquo;t care less.</p>
										<h3 id="css3-07">Alternate Row Styles <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Before <acronym title="Cascading Style Sheets">CSS</acronym>3, alternating styles for odd and even rows of content required server-side shenanigans or something something JavaScript. Now, <acronym title="Cascading Style Sheets">CSS</acronym>3 makes it easy to style odd, even, or any <em>n</em>th number of rows using a few slices of code.</p>
										<pre><code>li:nth-child(even) {
	background: green;
	}
li:nth-child(odd) { 
	background: yellow;
	}
li:nth-child(3n) {
	background: white;
	}</code></pre>
										<p>As a matter of fact, <acronym title="Cascading Style Sheets">CSS</acronym>3 makes it easy to target just about any specific element:</p>
										<pre><code>li:nth-of-type(3) {
	/* selects the third list element */
	}
ul:nth-child(7) {
	/* selects the seventh list element */
	}
li:first-of-type {
	/* selects the first list element */
	}
li:last-of-type {
	/* selects the last list element */
	}</code></pre>
										<p>99% of the time, alternating and custom element styles are going to be an added usability and/or aesthetic bonus and not required for ancient browsers. If the situation does call for custom row styles in <em>all</em> browsers, just do what everyone has been doing for years: add a class to the element and style accordingly.</p>
										<h3 id="css3-08">Opacity &amp; Transparency <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>This method is widely known, and generally applied in mindless &ldquo;copy-&amp;-paste&rdquo; fashion. The following rules work great together, targeting virtually every browser in use today. Here is how to specify specific degrees of opacity to any element:</p>
										<pre><code>.opacity {
	-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=70)";
	filter: alpha(opacity=70); /* internet explorer */
	-khtml-opacity: 0.7;      /* khtml, old safari */
	-moz-opacity: 0.7;       /* mozilla, netscape */
	opacity: 0.7;           /* fx, safari, opera */
	}</code></pre>
										<p>In case the <code>opacity</code> property is new to you, this code will set the opacity of the target element to 70 percent. A value of &ldquo;<code>1.0</code>&rdquo; specifies complete opacity, while a value of &ldquo;<code>0.0</code>&rdquo; will render the element invisible. For more information, check out <a href="http://perishablepress.com/press/2009/01/27/cross-browser-transparency-via-css/" title="Cross-Browser Transparency via CSS">Cross-Browser Transparency via CSS</a>.</p>
										<h3 id="css3-09">Custom Fonts <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Web designers have pretty much been stuck with an extremely limited set of &ldquo;web-safe&rdquo; fonts, which includes Verdana, Georgia, and the ubiquitous Arial font. There are numerous JavaScript/Flash-based workarounds that enable custom fonts, but the process is laborious, tedious, and full of caveats. Thankfully, <acronym title="Cascading Style Sheets">CSS</acronym>3 is taking us into the future with its piping hot <code>@font-face</code> property. As you have probably heard, <code>@font-face</code> enables you to easily embed any custom font using pure <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>@font-face {
	font-family: "Museo";
	src: url("fonts/Museo.otf") format("opentype");
	}
h1 {
	font-family: Museo, Georgia, serif;
	}</code></pre>
										<p>As with many of <acronym title="Cascading Style Sheets">CSS</acronym>3&rsquo;s new properties, <code>@font-face</code> is going to benefit supportive browsers, which currently includes Firefox 3.1+, Safari 4.0+, and Opera 10+. There are also ways of making it work in Internet Explorer, but I&rsquo;m going to save that for a future article.</p>
										<p>In this example, we specify the font&rsquo;s name and location in the <code>@font-face</code> selector, and then specify its name in the <code>h1</code> selector. It&rsquo;s <em>that</em> easy. And best of all, cool cats using latest versions of Firefox, Safari, Opera, and Chrome are going to enjoy your custom fonts as fluently as if they were installed on their own machine. Unsupportive browsers will simply fall back to either &ldquo;Georgia&rdquo; or the system default serif font.</p>
										<h3 id="css3-10">Custom Text-Highlight Styles <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>By default, most browsers display selected text with a boring blue color. Changing this to a custom color is a good way to improve the overall harmony and thematic consistency of your design. Here at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>, I enhance the aesthetic functionality of the <a href="http://perishablepress.com/press/index.php?wptheme=Serious" title="Skin the site with the 'Serious' theme">Serious Theme</a> using the following slice of <acronym title="Cascading Style Sheets">CSS</acronym>3:</p>
										<pre><code>*::selection {
	background: #E6E5C3; 
	color: #291F16;
	}
*::-moz-selection {
	background: #E6E5C3; 
	color: #291F16;
	}</code></pre>
										<p>If you happen to be visiting via the Serious Theme, you can check this out by highlighting some text. Even works great with <a href="http://perishablepress.com/press/2009/11/09/perfect-pre-tags/" title="Perfect Pre Tags"><code>&lt;pre&gt;</code> code</a>!</p>
										<h3 id="css3-11">Multi-Column Content Display <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Presenting your blog content in single columns is boring, but is certainly acceptable for older browsers. For newer, supportive browsers, you can use <acronym title="Cascading Style Sheets">CSS</acronym>3&rsquo;s multi-column layout properties to format your blocks of text in sleek, magazine-style multi-column format. To improve support for this feature, we throw some browser-specific prefixes into the mix:</p>
										<pre><code>.multiple-columns {

	-moz-column-count: 3;
	-moz-column-gap: 33px;

	-webkit-column-count: 3;
	-webkit-column-gap: 33px;

	column-count: 3;
	column-gap: 33px;
	}</code></pre>
										<p>As is, this sample code will render the content of our target <code>&lt;div&gt;</code> with three columns spaced 33 pixels apart.</p>
										<h3 id="css3-12">Box Sizing <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>This is a new one to me, as I have never actually used it before. The concept is straightforward though, so you can relax. With the conventional level-2.1 box model, applying padding and borders to block-level elements can be unpredictable and frustrating. Now, with <acronym title="Cascading Style Sheets">CSS</acronym>3&rsquo;s <code>box-sizing</code> property, designers have full control over how padding and borders are added to elements. Here&rsquo;s the juice:</p>
										<pre><code>.box-sizing {
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	-ms-box-sizing: border-box;
	box-sizing: border-box;
	}</code></pre>
										<p>Here we are using the <code>border-box</code> value to ensure that padding and borders are subtracted from the existing width/height of the element, such that the specified width/height remain the same in either case. Alternately, we could stick with the classic box model and add the padding/borders to the existing width/height, such that the total width increases according to the total size of the added padding and borders. You definitely want to experiment a little with this method to fully appreciate its potential. Also, of all the techniques in this article, this is probably the <em>least</em> recommended candidate for progressive enhancement because of potential layout discrepancies in non-compliant browsers.</p>
										<h3 id="css3-13">RGBa Colors and Transparency <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Lastly, one of the coolest things about <acronym title="Cascading Style Sheets">CSS</acronym>3 is that it brings alpha-transparency to the <acronym title="Red Green and Blue">RGB</acronym> color palette. This new property is called <code>rgba</code> and is a powerful way to specify the level of opacity or transparency of an element. Here are a couple of examples:</p>
										<pre><code>.transparent-background-color {
	color: rgb(0, 0, 0);
	background-color: rgb(77%, 77%, 77%);
	background-color: rgba(255, 255, 255, 0.7);
	}
.transparent-text-color {
	color: rgb(77%, 77%, 77%);
	color: rgba(0, 0, 0, 0.7);
	background-color: rgb(255, 255, 255);
	}</code></pre>
										<p>This method is superior to the previously discussed <code>opacity</code> property because with <code>rgba</code> we can control the opacity of different properties of specific child elements. With <code>opacity</code>, it&rsquo;s all or nothing. Within either of the <code>rgb</code> or <code>rgba</code> properties, the order of values is red, green, and blue, which are specified as either <code>0-255</code> or <code>0%-100%</code>. Then, for the <code>rgba</code> property, the fourth value specifies the opacity level, which ranges from &ldquo;<code>0.0</code>&rdquo; (transparent) to &ldquo;<code>1.0</code>&rdquo; (opaque).</p>
										<p>Notice that we include a fallback color for unsupportive browsers. This is accomplished by preceding each <code>rgba</code> property with an <code>rgb</code> equivalent. Browsers that don&rsquo;t &ldquo;get&rdquo; the alpha-transparency stuff will fall back to the first declaration. Also note that there is a filter to get alpha transparency working on <acronym title="Internet Explorer">IE</acronym>:</p>
										<pre><code>.ie-transparent-background-color {
	background: transparent;
	filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#FF333333, endColorstr=#FF333333);
	-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#FF333333, endColorstr=#FF333333)";
	zoom: 1;
	}</code></pre>
										<p>..and, you&rsquo;re probably gonna want to include that nasty thing via <a href="http://perishablepress.com/press/2006/09/04/fun-with-downlevel-conditional-comments/" title="Fun with Downlevel Conditional Comments">conditional</a> <a href="http://perishablepress.com/press/2007/07/18/wrapping-your-head-around-downlevel-conditional-comments/" title="Wrapping Your Head around Downlevel Conditional Comments">comments</a>.</p>
										<h3 id="css3-14">Word Wrap <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>If you display a lot of preformatted (&nbsp;<code>&lt;pre&gt;</code>&nbsp;) text, you know how difficult it can be when dealing with continuous character strings. In particular, long <acronym title="Uniform Resource Locator">URL</acronym>s have a nasty habit of breaking layouts, not only from preformatted text, but paragraphs, headings, and just about any other element for that matter. Thankfully,  the <acronym title="World Wide Web Consortium">W3C</acronym> has adopted Microsoft&rsquo;s extremely useful <code>word-wrap</code> property and included it in the <acronym title="Cascading Style Sheets">CSS</acronym>3 specification.</p>
										<pre><code>.break-word {
	word-wrap: break-word;
	}</code></pre>
										<p>When applied to an element, this declaration will break long strings of text and wrap them onto the next line. The <code>word-wrap</code> property accepts one of two values: &ldquo;<code>normal</code>&rdquo; and &ldquo;<code>break-word</code>&rdquo;. Simple and effective.</p>
										<h3 id="css3-15">Resizable Elements <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>This is a sweet little feature that enables the user to grab the corner of any element &#8212; not just <code>&lt;textarea&gt;</code>s &#8212; and resize it according to their needs. Not sure about which browsers support this at the moment, but it&rsquo;s just a matter of time before most of them understand something like this:</p>
										<pre><code>.resize {
	resize: both;
	}</code></pre>
										<p>I think this one of the coolest and most practical new features of <acronym title="Cascading Style Sheets">CSS</acronym>3, and one that designers should begin implementing immediately, especially for smaller-sized <code>&lt;textarea&gt;</code>s.</p>
										<h3 id="css3-16">Transitions <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>One particular <acronym title="Cascading Style Sheets">CSS</acronym>3 feature that is exciting to designers is the <code>transition</code> property, which essentially animates the transition between two display states of an element. Hyperlink hover states make a good example. Consider the following styles applied to your anchor elements:</p>
										<pre><code>a:link, a:visited {
	background: red;
	color: white;
	}
a:hover, a:active {
	background: white;
	color: red;
	}</code></pre>
										<p>With these styles, your links are going to have a red background with white text. When the user hovers over these links, the background is going to change to white and the text is going to change to red. As-is, the transition between these two states happens virtually instantaneously, but with the <code>transition</code> property, we can actually animate the transition between the background and color values:</p>
										<pre><code>a:link, a:visited {
	-webkit-transition: all 1s ease;
	transition: all 1s ease; 
	background: red;
	color: white;
	}
a:hover, a:active {
	background: white;
	color: red;
	}</code></pre>
										<p>With that code in place, supportive browsers will show a one-second &ldquo;<code>ease</code>&rdquo; transition between &ldquo;<code>all</code>&rdquo; properties within the selector (<code>background</code> and <code>color</code> in this example). The transition can also be modified to affect specific properties and specific transition durations. There are also several different types of transitions styles, including <code>ease</code>, <code>linear</code>, <code>ease-in</code>, <code>ease-out</code>, and <code>ease-in-out</code>. Endless possibilities here that are completely suitable for immediate progressive enhancement of your designs.</p>
										<h3 id="css3-17">CSS Color Gradients <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>On the very cutting edge of browser support for <acronym title="Cascading Style Sheets">CSS</acronym>3 is the ability to create color gradients using pure <acronym title="Cascading Style Sheets">CSS</acronym>. Strategically applied, gradients enhance the visual appearance of just about any design, especially when combined with other graphical elements, such as background images, fancy borders, and well-styled text. Creating gradients with <acronym title="Cascading Style Sheets">CSS</acronym> eliminates yet another <acronym title="Hypertext Transfer Protocol">HTTP</acronym> request from the performance equation. Plus they scale better too.</p>
										<pre><code>.color-gradients {
	background-image: -moz-linear-gradient(top, #FFFF00, #FF0000);
	background-image: -webkit-gradient(linear, top, bottom, color-stop(0.00, #FFFF00), color-stop(1.00, #FF0000));
	}</code></pre>
										<p>This code will create a vertical yellow-to-red gradient on the target element in supportive browsers. Each vendor-specific property value specifies a set of directional coordinates. Additionally, we&rsquo;re specifying the type of gradient (linear) for the Webkit property. Instead of <code>linear</code>, we could also do a <code>radial</code> gradient:</p>
										<pre><code>.color-gradients {
	background-image: -moz-radial-gradient(top left, circle farthest-corner, #FFFF00, #FF0000);
	background-image: -webkit-gradient(radial, top, bottom, color-stop(0.00, #FFFF00), color-stop(1.00, #FF0000));
	}</code></pre>
										<p>Notice the difference? Webkit specifies <code>radial</code> as a property value, whereas Mozilla prefers it in the property name itself. Weird, but true. Here&rsquo;s how to get gradients working in <acronym title="Internet Explorer">IE</acronym>:</p>
										<pre><code>filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#FFFF00, endColorstr=#FF0000);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#FFFF00, endColorstr=#FF0000)";</code></pre>
										<p>Use <code>GradientType=0</code> for vertical gradient and <code>GradientType=1</code> for a horizontal gradient. Correct me if I&rsquo;m wrong, but it may also be possible to specify an alpha-transparency value for each color, just as we did for the <acronym title="Internet Explorer">IE</acronym> opacity fix.</p>
										<h3 id="css3-18">Rotating Elements <sup><a href="#toc" title="Return to Table of Contents" class="anchor">&uarr;</a></sup></h3>
										<p>Rotating elements using <acronym title="Cascading Style Sheets">CSS</acronym> is like a dream come true for designers, who have spent years creating endless sequences of images and complex sprite configurations just to get something simple like displaying vertical calendar dates. Well say goodbye to all of <em>that</em> nonsense. Now with the amazing power of <acronym title="Cascading Style Sheets">CSS</acronym>3, we can rotate any element as follows:</p>
										<pre><code>.rotate-this {
	behavior: url(-ms-transform.htc);
	-webkit-transform: rotate(90deg);
	-moz-transform: rotate(90deg);
	-ms-transform: rotate(90deg);
	-o-transform: rotate(90deg);
	transform: rotate(90deg);
	}</code></pre>
										<p>Notice that we are increasing support by catering to browsers via their specifically prefixed selectors. The proprietary Opera support is new as of version 10.5, and that crazy <acronym title="Internet Explorer">IE</acronym> behavior is explained in Samuli Hakoniemi&rsquo;s article on <a href="http://samuli.hakoniemi.net/cross-browser-rotation-transformation-with-css/" title="Cross-browser Rotation Transformation with CSS">cross-browser rotation transformation with CSS</a>. How is this technique used as progressive enhancement? For central design elements, it&rsquo;s not, but for peripheral embellishments such as calendar dates, it&rsquo;s perfect. So long as your design accommodates the date text when it&rsquo;s displayed horizontally, this technique will enhance the presentation for supportive browsers by rotating the design 90 degrees. Better still, as browser support improves, we&rsquo;ll be able to use this &#8212; and the other methods presented in this article &#8212; consistently and reliably anywhere and for any purpose. Nice.</p>
										<h3>Ahhh yeh.</h3>
										<p>Make no mistake, <acronym title="Cascading Style Sheets">CSS</acronym>3 brings <em>plenty</em> of awesome new features to the table. There are many new tricks and techniques to learn, and the time to begin practicing is now. By understanding and following the principles of progressive enhancement and graceful degradation, your web designs can take advantage of all that <acronym title="Cascading Style Sheets">CSS</acronym>3 has to offer while providing practical and aesthetic benefit to your visitors.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2010/01/11/css3-progressive-enhancement-smart-design/" title="Read 'CSS3 + Progressive Enhancement = Smart Design' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2007/09/25/absolute-horizontal-and-vertical-centering-via-css/" title="Absolute Horizontal and Vertical Centering via CSS (September 25, 2007)">Absolute Horizontal and Vertical Centering via CSS</a></li>
					<li><a href="http://perishablepress.com/press/2008/06/10/sharpen-your-site-by-removing-unwanted-link-border-outlines/" title="Sharpen Your Site by Removing Unwanted Link Border Outlines (June 10, 2008)">Sharpen Your Site by Removing Unwanted Link Border Outlines</a></li>
					<li><a href="http://perishablepress.com/press/2008/10/26/css-implementations-of-the-rich-and-famous/" title="CSS Implementations of the Rich and Famous (October 26, 2008)">CSS Implementations of the Rich and Famous</a></li>
					<li><a href="http://perishablepress.com/press/2008/11/24/perfect-rounded-corners-with-css/" title="Perfect Rounded Corners with CSS (November 24, 2008)">Perfect Rounded Corners with CSS</a></li>
					<li><a href="http://perishablepress.com/press/2009/07/19/power-of-html5-css3/" title="The Power of HTML 5 and CSS 3 (July 19, 2009)">The Power of HTML 5 and CSS 3</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/27/crazy-css-underline-effects/" title="Crazy CSS Underline Effects (August 27, 2006)">Crazy CSS Underline Effects</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/30/nifty-css-link-hover-effect/" title="Nifty CSS Link Hover Effect (August 30, 2006)">Nifty CSS Link Hover Effect</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=PSJFWl9tOQI:AuLwN3c_JWA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=PSJFWl9tOQI:AuLwN3c_JWA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=PSJFWl9tOQI:AuLwN3c_JWA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=PSJFWl9tOQI:AuLwN3c_JWA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=PSJFWl9tOQI:AuLwN3c_JWA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=PSJFWl9tOQI:AuLwN3c_JWA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=PSJFWl9tOQI:AuLwN3c_JWA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=PSJFWl9tOQI:AuLwN3c_JWA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=PSJFWl9tOQI:AuLwN3c_JWA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=PSJFWl9tOQI:AuLwN3c_JWA:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=PSJFWl9tOQI:AuLwN3c_JWA:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2010/01/11/css3-progressive-enhancement-smart-design/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Book Giveaway Winner!</title>
		<link>http://perishablepress.com/press/2010/01/11/book-giveaway-winner/</link>
		<comments>http://perishablepress.com/press/2010/01/11/book-giveaway-winner/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 21:09:59 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[books]]></category>

		<category><![CDATA[DiW]]></category>

		<category><![CDATA[giveaways]]></category>

		<category><![CDATA[news]]></category>

		<category><![CDATA[print]]></category>

		<category><![CDATA[publishing]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2010/01/11/book-giveaway-winner/</guid>
		<description><![CDATA[										Congrats to Oliver Edwards for winning the randomly selected book giveaway! Oliver Edwards will receive a complimentary printed edition of Digging into WordPress along with the digital PDF version. Thank you to random.org for the true random number generator.
										Thanks to everyone for entering, and for sharing some great reasons why WordPress is #1.
										Copyright2010PerishablePress
Source: Perishable PressTake [...]]]></description>
			<content:encoded><![CDATA[										<p>Congrats to <a href="http://www.oliver4art.tk/" title="Oliver Arts">Oliver Edwards</a> for winning the randomly selected <a href="http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/" title="Book Giveaway: Print Version of Digging into WordPress">book giveaway</a>! Oliver Edwards will receive a complimentary printed edition of Digging into WordPress along with the digital <acronym title="Portable Document Format">PDF</acronym> version. Thank you to <em>random.org</em> for the <a href="http://www.random.org/" title="random.org">true random number generator</a>.</p>
										<p><strong>Thanks</strong> to everyone for entering, and for sharing some <a href="http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/#comments" title="Comments on 'Book Giveaway: Print Version of Digging into WordPress'">great reasons why WordPress is #1</a>.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2010/01/11/book-giveaway-winner/" title="Read 'Book Giveaway Winner!' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/" title="Book Giveaway: Print Version of Digging into WordPress (January 5, 2010)">Book Giveaway: Print Version of Digging into WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2009/12/29/print-version-digging-into-wordpress/" title="Print Version of Digging into WordPress is Here! (December 29, 2009)">Print Version of Digging into WordPress is Here!</a></li>
					<li><a href="http://perishablepress.com/press/2009/06/16/digging-into-wordpress/" title="Digging Into WordPress (June 16, 2009)">Digging Into WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/" title="It's Here: Digging into WordPress! (November 11, 2009)">It's Here: Digging into WordPress!</a></li>
					<li><a href="http://perishablepress.com/press/2009/02/15/book-review-wordpress-for-business-bloggers/" title="Book Review: WordPress for Business Bloggers (February 15, 2009)">Book Review: WordPress for Business Bloggers</a></li>
					<li><a href="http://perishablepress.com/press/2008/08/18/desktop-publishing-survival-tips-on-demand-book-printing-at-lulucom/" title="Self-Publishing Survival Tips: On-Demand Book Printing at Lulu.com (August 18, 2008)">Self-Publishing Survival Tips: On-Demand Book Printing at Lulu.com</a></li>
					<li><a href="http://perishablepress.com/press/2008/08/19/another-exciting-perishable-news-update/" title="Another Exciting Perishable News Update (August 19, 2008)">Another Exciting Perishable News Update</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=qoGgHgmT0HQ:BI8G2RXz9jo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=qoGgHgmT0HQ:BI8G2RXz9jo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=qoGgHgmT0HQ:BI8G2RXz9jo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=qoGgHgmT0HQ:BI8G2RXz9jo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=qoGgHgmT0HQ:BI8G2RXz9jo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=qoGgHgmT0HQ:BI8G2RXz9jo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=qoGgHgmT0HQ:BI8G2RXz9jo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=qoGgHgmT0HQ:BI8G2RXz9jo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=qoGgHgmT0HQ:BI8G2RXz9jo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=qoGgHgmT0HQ:BI8G2RXz9jo:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=qoGgHgmT0HQ:BI8G2RXz9jo:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2010/01/11/book-giveaway-winner/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Book Giveaway: Print Version of Digging into WordPress</title>
		<link>http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/</link>
		<comments>http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 03:30:30 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[books]]></category>

		<category><![CDATA[DiW]]></category>

		<category><![CDATA[giveaways]]></category>

		<category><![CDATA[news]]></category>

		<category><![CDATA[print]]></category>

		<category><![CDATA[publishing]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/</guid>
		<description><![CDATA[										 I have a free print version of Digging into WordPress to give away to one lucky winner. To qualify for the giveaway, simply leave a comment on this post stating your absolute favorite thing about WordPress. The winner will receive a free printed copy of DiW shipped to their door, plus a lifetime subscription [...]]]></description>
			<content:encoded><![CDATA[										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2010/misc-chunks/wordpress-logo-blue.jpg" alt="[ Digging into WordPress ]" /> I have a <strong>free</strong> <a href="http://perishablepress.com/press/2009/12/29/print-version-digging-into-wordpress/" title="Print Version of Digging into WordPress is Here!">print version of Digging into WordPress</a> to give away to one lucky winner. To qualify for the giveaway, simply leave a comment on this post stating your <em>absolute favorite thing</em> about WordPress. The winner will receive a free printed copy of <acronym title="Digging into WordPress">DiW</acronym> shipped to their door, plus a lifetime subscription to the <a href="http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/" title="It's Here: Digging into WordPress!"><acronym title="Portable Document Format">PDF</acronym> version of the book</a>. I will announce the randomly chosen winner next week. &ndash; Good luck! :)</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/" title="Read 'Book Giveaway: Print Version of Digging into WordPress' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2010/01/11/book-giveaway-winner/" title="Book Giveaway Winner! (January 11, 2010)">Book Giveaway Winner!</a></li>
					<li><a href="http://perishablepress.com/press/2009/12/29/print-version-digging-into-wordpress/" title="Print Version of Digging into WordPress is Here! (December 29, 2009)">Print Version of Digging into WordPress is Here!</a></li>
					<li><a href="http://perishablepress.com/press/2009/06/16/digging-into-wordpress/" title="Digging Into WordPress (June 16, 2009)">Digging Into WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/" title="It's Here: Digging into WordPress! (November 11, 2009)">It's Here: Digging into WordPress!</a></li>
					<li><a href="http://perishablepress.com/press/2009/02/15/book-review-wordpress-for-business-bloggers/" title="Book Review: WordPress for Business Bloggers (February 15, 2009)">Book Review: WordPress for Business Bloggers</a></li>
					<li><a href="http://perishablepress.com/press/2008/08/18/desktop-publishing-survival-tips-on-demand-book-printing-at-lulucom/" title="Self-Publishing Survival Tips: On-Demand Book Printing at Lulu.com (August 18, 2008)">Self-Publishing Survival Tips: On-Demand Book Printing at Lulu.com</a></li>
					<li><a href="http://perishablepress.com/press/2008/08/19/another-exciting-perishable-news-update/" title="Another Exciting Perishable News Update (August 19, 2008)">Another Exciting Perishable News Update</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=yl3DHQAlJEg:1_BPuRrmGP8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=yl3DHQAlJEg:1_BPuRrmGP8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=yl3DHQAlJEg:1_BPuRrmGP8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=yl3DHQAlJEg:1_BPuRrmGP8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=yl3DHQAlJEg:1_BPuRrmGP8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=yl3DHQAlJEg:1_BPuRrmGP8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=yl3DHQAlJEg:1_BPuRrmGP8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=yl3DHQAlJEg:1_BPuRrmGP8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=yl3DHQAlJEg:1_BPuRrmGP8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=yl3DHQAlJEg:1_BPuRrmGP8:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=yl3DHQAlJEg:1_BPuRrmGP8:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Better Image Preloading with CSS3</title>
		<link>http://perishablepress.com/press/2010/01/04/preload-images-css3/</link>
		<comments>http://perishablepress.com/press/2010/01/04/preload-images-css3/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 17:54:58 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Function]]></category>

		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[css3]]></category>

		<category><![CDATA[performance]]></category>

		<category><![CDATA[preload-images]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2010/01/04/preload-images-css3/</guid>
		<description><![CDATA[										I recently added to my growing library of image-preloading methods with a few new-&#38;-improved techniques. After posting that recent preloading article, an even better way of preloading images using pure CSS3 hit me:
										.preload-images {
	background: url(image-01.png) no-repeat -9999px -9999px;
	background: url(image-01.png) no-repeat -9999px -9999px,
		    url(image-02.png) no-repeat -9999px -9999px,
		    url(image-03.png) no-repeat -9999px [...]]]></description>
			<content:encoded><![CDATA[										<p>I recently added to my growing library of <a href="http://perishablepress.com/press/tag/preload-images/" title="Tag Archive for 'preload-images'">image-preloading methods</a> with a few <a href="http://perishablepress.com/press/2009/12/28/3-ways-preload-images-css-javascript-ajax/" title="3 Ways to Preload Images with CSS, JavaScript, or Ajax">new-&amp;-improved techniques</a>. After posting that recent preloading article, an even better way of preloading images using pure <acronym title="Cascading Style Sheets">CSS</acronym>3 hit me:</p>
										<pre><code>.preload-images {
	background: url(image-01.png) no-repeat -9999px -9999px;
	background: url(image-01.png) no-repeat -9999px -9999px,
		    url(image-02.png) no-repeat -9999px -9999px,
		    url(image-03.png) no-repeat -9999px -9999px,
		    url(image-04.png) no-repeat -9999px -9999px,
		    url(image-05.png) no-repeat -9999px -9999px;
	}</code></pre>
										<p>Using <acronym title="Cascading Style Sheets">CSS</acronym>3&rsquo;s new support for multiple background images, we can use a single, existing element to preload <em>all</em> of the required images. Compare this method with the <a href="http://perishablepress.com/press/2008/06/14/a-way-to-preload-images-without-javascript-that-is-so-much-better/" title="A Way to Preload Images without JavaScript that is SO Much Better">old way of using CSS to preload images</a>:</p>
										<pre><code>.preload-01 { background: url(image-01.png) no-repeat -9999px -9999px; }  
.preload-02 { background: url(image-02.png) no-repeat -9999px -9999px; }  
.preload-03 { background: url(image-03.png) no-repeat -9999px -9999px; }
.preload-04 { background: url(image-04.png) no-repeat -9999px -9999px; }
.preload-05 { background: url(image-05.png) no-repeat -9999px -9999px; }</code></pre>
										<p>As you can see, the <acronym title="Cascading Style Sheets">CSS</acronym>3 method is a <em>much</em> cleaner way to preload your images using a single <acronym title="Cascading Style Sheets">CSS</acronym> selector. Note that we&rsquo;re also going to need to ensure the background images aren&rsquo;t being displayed in the preload element. For that, I suppose we could either hide the element using <code>display:none</code> or else position the images far off screen using <code>-9999px</code> positioning.</p>
										<h3>Pros</h3>
										<p>This technique works great in supportive browsers now, and the <strong>support will only get better moving into the future</strong>. Notice that we can include a partial fallback mechanism by preloading one of the images as a single <code>background</code> property value. Browsers that don&rsquo;t get the multiple stuff will fallback to the single-value <code>background</code> property instead.</p>
										<p>Also, browser support for <acronym title="Cascading Style Sheets">CSS</acronym> is much better than for JavaScript, so big improvement there. Beyond these things, the sheer ease of picking an element and adding all of our preload images as backgrounds is simply <em>too</em> easy not to take advantage.</p>
										<h3>Cons</h3>
										<p>Well, let&rsquo;s see.. current browser support is not as good as it could be, mostly because of Internet Explorer. So besides the fact that <acronym title="Internet Exploder">IE</acronym> may <em>never</em> understand multiple background-images, the downsides to using this method are pretty much nil as far as I can tell. Perhaps I am missing something completely obvious..? Maybe someone will elaborate on the non-presentational use of <acronym title="Cascading Style Sheets">CSS</acronym>?&nbsp;;) Chime in!</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2010/01/04/preload-images-css3/" title="Read 'Better Image Preloading with CSS3' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2009/12/28/3-ways-preload-images-css-javascript-ajax/" title="3 Ways to Preload Images with CSS, JavaScript, or Ajax (December 28, 2009)">3 Ways to Preload Images with CSS, JavaScript, or Ajax</a></li>
					<li><a href="http://perishablepress.com/press/2007/07/22/css-throwdown-preload-images-without-javascript/" title="CSS Throwdown: Preload Images without JavaScript (July 22, 2007)">CSS Throwdown: Preload Images without JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2008/04/15/pure-css-better-image-preloading-without-javascript/" title="Pure CSS: Better Image Preloading without JavaScript (April 15, 2008)">Pure CSS: Better Image Preloading without JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2008/06/14/a-way-to-preload-images-without-javascript-that-is-so-much-better/" title="A Way to Preload Images without JavaScript that is SO Much Better (June 14, 2008)">A Way to Preload Images without JavaScript that is SO Much Better</a></li>
					<li><a href="http://perishablepress.com/press/2008/06/16/preventing-the-unpredictable-white-screen-of-death-for-wordpress-sites-with-multiple-themes/" title="Preventing the Unpredictable White Screen of Death for WordPress Sites with Multiple Themes (June 16, 2008)">Preventing the Unpredictable White Screen of Death for WordPress Sites with Multiple Themes</a></li>
					<li><a href="http://perishablepress.com/press/2009/01/18/css-image-caching/" title="Better Image Caching with CSS (January 18, 2009)">Better Image Caching with CSS</a></li>
					<li><a href="http://perishablepress.com/press/2009/05/17/png-image-optimization/" title="5-Minute PNG Image Optimization (May 17, 2009)">5-Minute PNG Image Optimization</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=5H8LOICkkPs:opQWqkE9Q4k:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5H8LOICkkPs:opQWqkE9Q4k:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5H8LOICkkPs:opQWqkE9Q4k:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5H8LOICkkPs:opQWqkE9Q4k:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5H8LOICkkPs:opQWqkE9Q4k:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5H8LOICkkPs:opQWqkE9Q4k:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5H8LOICkkPs:opQWqkE9Q4k:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5H8LOICkkPs:opQWqkE9Q4k:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5H8LOICkkPs:opQWqkE9Q4k:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5H8LOICkkPs:opQWqkE9Q4k:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5H8LOICkkPs:opQWqkE9Q4k:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2010/01/04/preload-images-css3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Print Version of Digging into WordPress is Here!</title>
		<link>http://perishablepress.com/press/2009/12/29/print-version-digging-into-wordpress/</link>
		<comments>http://perishablepress.com/press/2009/12/29/print-version-digging-into-wordpress/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:08:58 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[books]]></category>

		<category><![CDATA[DiW]]></category>

		<category><![CDATA[news]]></category>

		<category><![CDATA[print]]></category>

		<category><![CDATA[publishing]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/12/29/print-version-digging-into-wordpress/</guid>
		<description><![CDATA[										Nearly six weeks after releasing the electronic version of Digging into WordPress, Chris and I are proud to announce that the printed version is now available.
										Beautiful custom design with full-color printing on every page
										Beautiful custom design..
										Make no mistake, this is a beautiful, custom-designed book that makes it fun and easy to soak in the wisdom [...]]]></description>
			<content:encoded><![CDATA[										<p>Nearly six weeks after <a href="http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/" title="It's Here: Digging into WordPress!">releasing the electronic version of Digging into WordPress</a>, Chris and I are proud to announce that the <a href="http://digwp.com/book/" title="Get a printed copy of Digging into WordPress">printed version is now available</a>.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/dig-wp-print/digwp-print_03.jpg" alt="[ Photo: Fanning color page edges ]" /><br /><small>Beautiful custom design with full-color printing on <em>every</em> page</small></p>
										<h3>Beautiful custom design..</h3>
										<p>Make no mistake, this is a <em>beautiful</em>, custom-designed book that makes it fun and easy to soak in the wisdom and advance your WordPress skills. Every detail has been carefully crafted &#8212; from the landscape page-orientation and color-coded chapters to the lay-flat spiral binding and large, easy-to-read text &#8212; this book is truly a <em>pleasure</em> to experience.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/dig-wp-print/digwp-print_05.jpg" alt="[ Photo: Spiral binding stays flat ]" /><br /><small>Spiral binding opens flat and <em>stays</em> flat</small></p>
										<h3>What you&rsquo;ll get..</h3>
										<p>Chris and I have poured ourselves into this book. It is completely packed with 400+ pages of practical WordPress information, tips, tricks, and techniques. Having all of that code and knowledge in a beautiful printed format is a <em>very</em> satisfying feeling. Reading through this book just <em>feels</em> good, and with the free lifetime subscription to the <acronym title="Portable Document Format">PDF</acronym> version, you know that you&rsquo;ll always have all of the latest code in ready-to-use format, all of the book&rsquo;s hyperlinks directly targeting their pages, and all of the book&rsquo;s content in easy-to-search digital text. You get the satisfaction, usability and portability of a printed book while enjoying the technological tools available with the <acronym title="Portable Document Format">PDF</acronym>. It&rsquo;s a <em>complete</em> package featuring the best of both worlds.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/dig-wp-print/digwp-print_01.jpg" alt="[ Photo: Flipping through DiW ]" /><br /><small>The book looks great and <em>feels</em> good</small></p>
										<h3>Get your own copy..</h3>
										<p>You can get your own copy of Digging into WordPress for $67 (plus shipping &amp; handling) through the book&rsquo;s official <a href="http://digwp.com/book/" title="Get the printed version!">Sales Page</a>. Every purchase includes a <acronym title="Portable Document Format">PDF</acronym> version of the book and free lifetime updates. Chris and I are passionate about WordPress, and plan on updating the <acronym title="Portable Document Format">PDF</acronym> with fresh content as WordPress continues to grow and evolve. Here are a few factors determining the price for the printed version:</p>
										<ul>
										<li>The book is 400 pages printed in <em>full-color</em></li>
										<li>As self-publishers, Chris and I are printing smaller quantities of the book</li>
										<li>Everything is hand-crafted and custom-made from start to finish</li>
										<li>A ton of work has went into making this book &#8212; a <em>true</em> <acronym title="Do It Yourself">DIY</acronym> production</li>
										</ul>
										<p>Chris and I have spent an enormous amount of time, energy, and money producing and promoting this book on our own, without relying on a giant book publisher to crank out a million copies. We took this route because we wanted to create the book that <em>we</em> wanted to make &#8212; not some dry, homogenized corporate interpretation. By maintaining control over every aspect of the writing, design, and production process, we were able to stay true to our artistic vision and deliver the book that we feel will be most beneficial to you, the reader. So the print version does cost a little more, but you get what you pay for, and this is definitely an authentic, <em>high-quality</em> production.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/dig-wp-print/digwp-print_06.jpg" alt="[ Photo: DiW folds up nicely to save space ]" /><br /><small>Digging into WordPress folds up nicely to save space</small></p>
										<h3>Discounts, shipping, and affiliate information..</h3>
										<p>Here are some other important things that you should know:</p>
										<h4>Discounts for PDF customers</h4>
										<p>As promised, if you already have purchased a copy of the <acronym title="Portable Document Format">PDF</acronym>, you&rsquo;ll get a nice discount on the printed version. Here&rsquo;s how to do it:</p>
										<ul>
										<li><strong><a href="http://digwp.com/contact/" title="Contact Chris and Jeff">Email us through our contact form</a></strong> or send an email to &ldquo;sales&rdquo; at &ldquo;digwp.com&rdquo; &#8212; either forward us your receipt or send us the name and email used for your purchase.</li>
										<li>We&rsquo;ll then verify your purchase and send you a <strong>discount code</strong> that you can use during the checkout process.</li>
										<li>The discount amount you receive will be valued at your original purchase price <strong>plus an additional $5</strong>. So for example, if you paid $27 for the <acronym title="Portable Document Format">PDF</acronym>, you&rsquo;ll get a discount of $32. This way you&rsquo;ll be getting the book for $35. This helps keep our margins intact and give everyone a fair deal on these printed books.</li>
										</ul>
										<h4>International shipping available</h4>
										<p>Due to demand, we have arranged to make the book available internationally. The cost for shipping and handling will vary according to your location, ranging anywhere from $28 to ship to places like Germany and the United Kingdom, to around $5 for orders shipped within the United States. Also note that Illinois sales are subject to sales tax, and international sales are subject to <acronym title="Value Added Tax">VAT</acronym>. Everything is calculated automatically during the checkout process.</p>
										<h4>Affiliate program for printed copies</h4>
										<p>The <acronym title="Portable Document Format">PDF</acronym> book currently pays 50% for affiliate sales. This gives affiliates a (stellar) commission of $13.50 per <acronym title="Portable Document Format">PDF</acronym> sale. For printed copies of the book, each sale will pay a commission of 20%, which translates into $13.40 per book. Thus, affiliates will earn approximately the same amount for either version of the book. Either way, it&rsquo;s an incredible deal &#8212; we have already paid <em>thousands</em> of dollars to our affiliates&nbsp;:) <a href="http://digwp.com/book/affiliate/" title="DiW Affiliate Program">Learn more about our Affiliate Program</a>.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/dig-wp-print/digwp-print_07.jpg" alt="[ Photo: Front cover of DiW ]" /><br /><small>Digging into WordPress &#8212; 400+ pages of practical WordPress wisdom</small></p>
										<p>If you have any questions about the book, <a href="http://digwp.com/contact/" title="Contact Digging into WordPress">contact us</a> or leave a comment and we&rsquo;ll do our best to help you out. To learn more about Digging into WordPress, check out our <a href="http://digwp.com/book/learn-more/" title="Learn More About the Book"><acronym title="Digging into WordPress">DiW</acronym> Information Page</a>.</p>
										<p><strong class="star"><a href="http://digwp.com/book/" title="Take your WordPress skills to the next level!">Click here to secure your own copy of Digging into WordPress!</a></strong></p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/12/29/print-version-digging-into-wordpress/" title="Read 'Print Version of Digging into WordPress is Here!' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/" title="Book Giveaway: Print Version of Digging into WordPress (January 5, 2010)">Book Giveaway: Print Version of Digging into WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2010/01/11/book-giveaway-winner/" title="Book Giveaway Winner! (January 11, 2010)">Book Giveaway Winner!</a></li>
					<li><a href="http://perishablepress.com/press/2009/06/16/digging-into-wordpress/" title="Digging Into WordPress (June 16, 2009)">Digging Into WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/" title="It's Here: Digging into WordPress! (November 11, 2009)">It's Here: Digging into WordPress!</a></li>
					<li><a href="http://perishablepress.com/press/2009/02/15/book-review-wordpress-for-business-bloggers/" title="Book Review: WordPress for Business Bloggers (February 15, 2009)">Book Review: WordPress for Business Bloggers</a></li>
					<li><a href="http://perishablepress.com/press/2008/08/18/desktop-publishing-survival-tips-on-demand-book-printing-at-lulucom/" title="Self-Publishing Survival Tips: On-Demand Book Printing at Lulu.com (August 18, 2008)">Self-Publishing Survival Tips: On-Demand Book Printing at Lulu.com</a></li>
					<li><a href="http://perishablepress.com/press/2008/08/19/another-exciting-perishable-news-update/" title="Another Exciting Perishable News Update (August 19, 2008)">Another Exciting Perishable News Update</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8aNwMVNMro:7GRpQ3oMzuM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8aNwMVNMro:7GRpQ3oMzuM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=g8aNwMVNMro:7GRpQ3oMzuM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8aNwMVNMro:7GRpQ3oMzuM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=g8aNwMVNMro:7GRpQ3oMzuM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8aNwMVNMro:7GRpQ3oMzuM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=g8aNwMVNMro:7GRpQ3oMzuM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8aNwMVNMro:7GRpQ3oMzuM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=g8aNwMVNMro:7GRpQ3oMzuM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8aNwMVNMro:7GRpQ3oMzuM:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8aNwMVNMro:7GRpQ3oMzuM:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/12/29/print-version-digging-into-wordpress/feed/</wfw:commentRss>
		</item>
		<item>
		<title>3 Ways to Preload Images with CSS, JavaScript, or Ajax</title>
		<link>http://perishablepress.com/press/2009/12/28/3-ways-preload-images-css-javascript-ajax/</link>
		<comments>http://perishablepress.com/press/2009/12/28/3-ways-preload-images-css-javascript-ajax/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 17:22:42 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Function]]></category>

		<category><![CDATA[Optimization]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[images]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[optimize]]></category>

		<category><![CDATA[performance]]></category>

		<category><![CDATA[preload-images]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/12/28/3-ways-preload-images-css-javascript-ajax/</guid>
		<description><![CDATA[										Preloading images is a great way to improve the user experience. When images are preloaded in the browser, the visitor can surf around your site and enjoy extremely faster loading times. This is especially beneficial for photo galleries and other image-heavy sites where you want to deliver the goods as quickly and seamlessly as possible. [...]]]></description>
			<content:encoded><![CDATA[										<p>Preloading images is a great way to improve the user experience. When images are preloaded in the browser, the visitor can surf around your site and enjoy extremely faster loading times. This is especially beneficial for photo galleries and other image-heavy sites where you want to deliver the goods as quickly and seamlessly as possible. Preloading images definitely helps users without broadband enjoy a better experience when viewing your content. In this article, we&rsquo;ll explore three different preloading techniques to enhance the performance and usability of your site.</p>
										<h3>Method 1: Preloading with CSS and JavaScript</h3>
										<p>There are many ways to preload images, including methods that rely on <acronym title="Cascading Style Sheets">CSS</acronym>, JavaScript, and various combinations thereof. As one of my favorite topics here at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>, I have covered image preloading numerous times:</p>
										<ul>
										<li><a href="http://perishablepress.com/press/2009/01/18/css-image-caching/" title="Better Image Caching with CSS">Better Image Caching with CSS</a></li>
										<li><a href="http://perishablepress.com/press/2008/06/14/a-way-to-preload-images-without-javascript-that-is-so-much-better/" title="A Way to Preload Images without JavaScript that is SO Much Better">A Way to Preload Images without JavaScript that is SO Much Better</a></li>
										<li><a href="http://perishablepress.com/press/2008/04/15/pure-css-better-image-preloading-without-javascript/" title="Pure CSS: Better Image Preloading without JavaScript">Pure CSS: Better Image Preloading without JavaScript</a></li>
										<li><a href="http://perishablepress.com/press/2007/07/22/css-throwdown-preload-images-without-javascript/" title="CSS Throwdown: Preload Images without JavaScript">CSS Throwdown: Preload Images without JavaScript</a></li>
										<li><a href="http://perishablepress.com/press/2006/11/14/preloading-images-with-css-and-javascript/" title="Preloading Images with CSS and JavaScript">Preloading Images with CSS and JavaScript</a></li>
										</ul>
										<p>Each of these techniques sort of builds on previous methods and remains quite effective and suitable for a variety of design scenarios. Thankfully, readers always seem to chime in on these posts with suggestions and improvements. Recently, <a href="http://fightingforalostcause.net/techblog/preloading-images/" title="Preloading Images">Ian Dunn posted an article</a> that improves upon my <a href="http://perishablepress.com/press/2008/04/15/pure-css-better-image-preloading-without-javascript/" title="Pure CSS: Better Image Preloading without JavaScript">Better Image Preloading without JavaScript</a> method.</p>
										<p>With that method, images are easily and effectively preloaded using the following <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>#preload-01 { background: url(http://domain.tld/image-01.png) no-repeat -9999px -9999px; }
#preload-02 { background: url(http://domain.tld/image-02.png) no-repeat -9999px -9999px; }
#preload-03 { background: url(http://domain.tld/image-03.png) no-repeat -9999px -9999px; }</code></pre>
										<p>By strategically applying <code>preload</code> IDs to <em>existing</em> <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> elements, we can use <acronym title="Cascading Style Sheets">CSS</acronym>&rsquo; <code>background</code> property to preload select images off-screen in the background. Then, as long as the paths to these images remains the same when they are referred to elsewhere in the web page, the browser will use the preloaded/cached images when rendering the page. Simple, effective, and <em>no</em> JavaScript required.</p>
										<p>As effective as this method is, however, there is room for improvement. As Ian points out, images that are preloaded using this method will be loaded along with the other page contents, thereby increasing overall loading time for the page. To resolve this issue, we can use a little bit of JavaScript to delay the preloading until <em>after</em> the page has finished loading. This is easily accomplished by applying the <acronym title="Cascading Style Sheets">CSS</acronym> <code>background</code> properties using <a href="http://simonwillison.net/2004/May/26/addLoadEvent/" title="Executing JavaScript on page load">Simon Willison&rsquo;s addLoadEvent()</a> script:</p>
										<pre><code>// better image preloading @ http://perishablepress.com/press/2009/12/28/3-ways-preload-images-css-javascript-ajax/
function preloader() {
	if (document.getElementById) {
		document.getElementById("preload-01").style.background = "url(http://domain.tld/image-01.png) no-repeat -9999px -9999px";
		document.getElementById("preload-02").style.background = "url(http://domain.tld/image-02.png) no-repeat -9999px -9999px";
		document.getElementById("preload-03").style.background = "url(http://domain.tld/image-03.png) no-repeat -9999px -9999px";
	}
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
addLoadEvent(preloader);</code></pre>
										<p>In the first part of this script, we are setting up the actual preloading by targeting specific <code>preload</code> elements with <code>background</code> styles that call the various images. Thus, to use this method, you will need to replace the &ldquo;<code>preload-01</code>&rdquo;, &ldquo;<code>preload-02</code>&rdquo;, &ldquo;<code>preload-03</code>&rdquo;, etc., with the IDs that you will be targeting in your markup. Also, for each of the <code>background</code> properties, you will need to replace the &ldquo;<code>image-01.png</code>&rdquo;, &ldquo;<code>image-02.png</code>&rdquo;, &ldquo;<code>image-03.png</code>&rdquo;, etc., with the path and name of your image files. No other editing is required for this technique to work.</p>
										<p>Then, in the second part of the script, we are using the <code>addLoadEvent()</code> function to delay execution of our <code>preloader()</code> function until after the page has loaded.</p>
										<p>SO what happens when JavaScript is not available on the user&rsquo;s browser? Quite simply, the images will not be preloaded and will load as normal when called in the web page. This is exactly the sort of unobtrusive, gracefully degrading JavaScript that we really like&nbsp;:)</p>
										<h3>Method 2: Preloading with JavaScript Only</h3>
										<p>As effective as the previous method happens to be, I generally find it to be too tedious and time-consuming to actually implement. Instead, I generally prefer to preload images using a straight-up slice of JavaScript. Here are a couple of JavaScript-only preloading methods that work beautifully in virtually every modern browser..</p>
										<h4>JavaScript Method #1</h4>
										<p>Unobtrusive, gracefully degrading, and easy to implement, simply edit/add the image paths/names as needed &#8212; no other editing required:</p>
										<pre><code>&lt;div class="hidden"&gt;
	&lt;script type="text/javascript"&gt;
		&lt;!--//--&gt;&lt;![CDATA[//&gt;&lt;!--
			var images = new Array()
			function preload() {
				for (i = 0; i &lt; preload.arguments.length; i++) {
					images[i] = new Image()
					images[i].src = preload.arguments[i]
				}
			}
			preload(
				"http://domain.tld/gallery/image-001.jpg",
				"http://domain.tld/gallery/image-002.jpg",
				"http://domain.tld/gallery/image-003.jpg"
			)
		//--&gt;&lt;!]]&gt;
	&lt;/script&gt;
&lt;/div&gt;</code></pre>
										<p>This method is especially convenient for preloading large numbers of images. On one of my gallery sites, I use this technique to preload almost 50 images. By including this script on the login page as well as internal money pages, most of the gallery images are preloaded by the time the user enters their login credentials. Nice.</p>
										<h4>JavaScript Method #2</h4>
										<p>Here&rsquo;s another similar method that uses unobtrusive JavaScript to preload any number of images. Simply include the following script into any of your web pages and edit according to the proceeding instructions:</p>
										<pre><code>&lt;div class="hidden"&gt;
	&lt;script type="text/javascript"&gt;
		&lt;!--//--&gt;&lt;![CDATA[//&gt;&lt;!--

			if (document.images) {
				img1 = new Image();
				img2 = new Image();
				img3 = new Image();

				img1.src = "http://domain.tld/path/to/image-001.gif";
				img2.src = "http://domain.tld/path/to/image-002.gif";
				img3.src = "http://domain.tld/path/to/image-003.gif";
			}

		//--&gt;&lt;!]]&gt;
	&lt;/script&gt;
&lt;/div&gt;</code></pre>
										<p>As you can see, each preloaded image requires a variable definition, &ldquo;<code>img1</code>&nbsp;<code>=</code>&nbsp;<code>new</code>&nbsp;<code>Image();</code>&rdquo;, as well as a source declaration, &ldquo;<code>img3.src</code>&nbsp;<code>=</code>&nbsp;<code>"../path/to/image-003.gif";</code>&rdquo;. By replicating the pattern, you can preload as many images as necessary. Hopefully this is clear &#8212; if not, please leave a comment and someone will try to help you out.</p>
										<p>We can even improve this method a bit by delaying preloading until <em>after</em> the page loads. To do this, we simply wrap the script in a function and use <code>addLoadEvent()</code> to make it work:</p>
										<pre><code>function preloader() {
	if (document.images) {
		var img1 = new Image();
		var img2 = new Image();
		var img3 = new Image();

		img1.src = "http://domain.tld/path/to/image-001.gif";
		img2.src = "http://domain.tld/path/to/image-002.gif";
		img3.src = "http://domain.tld/path/to/image-003.gif";
	}
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
addLoadEvent(preloader);</code></pre>
										<p>Ahhh, the joys of <a href="http://perishablepress.com/press/tag/javascript/" title="'JavaScript' Archive at Perishable Press">JavaScript</a>!</p>
										<h3>Method 3: Preloading with Ajax</h3>
										<p>As if all of that weren&rsquo;t cool enough, here is a way to preload images using <acronym title="Asynchronous JavaScript XML">Ajax</acronym>. This method was discovered at <a href="http://desgeeksetdeslettres.com/blog/en/programmation-java/2-facons-de-mettre-en-cache-le-javascript-css-et-image-simplement/comment-page-1/" title="2 ways to cache JavaScript, CSS and image only">Of Geeks and letters</a>, and uses the <acronym title="Document Object Model">DOM</acronym> to preload not only images, but <acronym title="Cascading Style Sheets">CSS</acronym>, JavaScript, and just about anything else. The main benefit of using <acronym title="Asynchronous JavaScript XML">Ajax</acronym> over straight JavaScript is that JavaScript and <acronym title="Cascading Style Sheets">CSS</acronym> files can be preloaded without their contents affecting the current page. For images this is not really an issue, but the method is clean and effective nonetheless.</p>
										<pre><code>window.onload = function() {
	setTimeout(function() {
		// XHR to request a JS and a CSS
		var xhr = new XMLHttpRequest();
		xhr.open('GET', 'http://domain.tld/preload.js');
		xhr.send('');
		xhr = new XMLHttpRequest();
		xhr.open('GET', 'http://domain.tld/preload.css');
		xhr.send('');
		// preload image
		new Image().src = "http://domain.tld/preload.png";
	}, 1000);
};</code></pre>
										<p>As is, this code will preload three files: &ldquo;<code>preload.js</code>&rdquo;, &ldquo;<code>preload.css</code>&rdquo;, and &ldquo;<code>preload.png</code>&rdquo;. A timeout of <code>1000ms</code> is also set to prevent the script from hanging and causing issues with normal page functionality.</p>
										<p>To wrap things up, let&rsquo;s look at how this preloading session would look written in plain JavaScript:</p>
										<pre><code>window.onload = function() {

	setTimeout(function() {

		// reference to &lt;head&gt;
		var head = document.getElementsByTagName('head')[0];

		// a new CSS
		var css = document.createElement('link');
		css.type = "text/css";
		css.rel  = "stylesheet";
		css.href = "http://domain.tld/preload.css";

		// a new JS
		var js  = document.createElement("script");
		js.type = "text/javascript";
		js.src  = "http://domain.tld/preload.js";

		// preload JS and CSS
		head.appendChild(css);
		head.appendChild(js);

		// preload image
		new Image().src = "http://domain.tld/preload.png";

	}, 1000);

};</code></pre>
										<p>Here we are preloading our three files upon page load by creating three elements via the <acronym title="Document Object Model">DOM</acronym>. As mentioned in the original article, this method is inferior to the <acronym title="Asynchronous JavaScript XML">Ajax</acronym> method in cases where the preloaded file contents should not be applied to the loading page.</p>
										<h3>Know some triks?</h3>
										<p>I love these preloading tricks so much, I could just squeeze something. If you know of any good preloading tricks, including any improvements to the techniques shared here, kick start my heart with your wise words of preloading wisdom&nbsp;;)</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/12/28/3-ways-preload-images-css-javascript-ajax/" title="Read '3 Ways to Preload Images with CSS, JavaScript, or Ajax' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2007/07/22/css-throwdown-preload-images-without-javascript/" title="CSS Throwdown: Preload Images without JavaScript (July 22, 2007)">CSS Throwdown: Preload Images without JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2006/11/14/preloading-images-with-css-and-javascript/" title="Preloading Images with CSS and JavaScript (November 14, 2006)">Preloading Images with CSS and JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/12/prevent-javascript-elements-from-breaking-page-layout/" title="Prevent JavaScript Elements from Breaking Page Layout when Following Yahoo Performance Tip #6: Place Scripts at the Bottom (November 12, 2007)">Prevent JavaScript Elements from Breaking Page Layout when Following Yahoo Performance Tip #6: Place Scripts at the Bottom</a></li>
					<li><a href="http://perishablepress.com/press/2008/04/15/pure-css-better-image-preloading-without-javascript/" title="Pure CSS: Better Image Preloading without JavaScript (April 15, 2008)">Pure CSS: Better Image Preloading without JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2008/06/14/a-way-to-preload-images-without-javascript-that-is-so-much-better/" title="A Way to Preload Images without JavaScript that is SO Much Better (June 14, 2008)">A Way to Preload Images without JavaScript that is SO Much Better</a></li>
					<li><a href="http://perishablepress.com/press/2008/11/09/the-ultimate-guide-to-swfir-image-replacement/" title="The Ultimate Guide to swfIR Image Replacement (November 9, 2008)">The Ultimate Guide to swfIR Image Replacement</a></li>
					<li><a href="http://perishablepress.com/press/2009/01/18/css-image-caching/" title="Better Image Caching with CSS (January 18, 2009)">Better Image Caching with CSS</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=5kOK4At1xCA:u8ntjryxQGQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5kOK4At1xCA:u8ntjryxQGQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5kOK4At1xCA:u8ntjryxQGQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5kOK4At1xCA:u8ntjryxQGQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5kOK4At1xCA:u8ntjryxQGQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5kOK4At1xCA:u8ntjryxQGQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5kOK4At1xCA:u8ntjryxQGQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5kOK4At1xCA:u8ntjryxQGQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5kOK4At1xCA:u8ntjryxQGQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5kOK4At1xCA:u8ntjryxQGQ:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5kOK4At1xCA:u8ntjryxQGQ:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/12/28/3-ways-preload-images-css-javascript-ajax/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Protect WordPress Against Malicious URL Requests</title>
		<link>http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/</link>
		<comments>http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 19:23:37 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[blacklist]]></category>

		<category><![CDATA[htaccess]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[plugins]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/</guid>
		<description><![CDATA[										A few months ago, many WordPress sites were attacked with some extremely malicious code. While searching for a good solution, I discovered the following gem of a plugin in the pastebin repository:
										&#60;?php /* Plugin Name: Block Bad Queries */

if (strlen($_SERVER['REQUEST_URI']) &#62; 255 &#124;&#124; 
	strpos($_SERVER['REQUEST_URI'], "eval(") &#124;&#124; 
	strpos($_SERVER['REQUEST_URI'], "base64")) {
		@header("HTTP/1.1 414 Request-URI Too Long");
		@header("Status: 414 Request-URI [...]]]></description>
			<content:encoded><![CDATA[										<p>A few months ago, many WordPress sites were attacked with some extremely malicious code. While searching for a good solution, I discovered the following gem of a plugin in the pastebin repository:</p>
										<pre><code>&lt;?php /* Plugin Name: Block Bad Queries */

if (strlen($_SERVER['REQUEST_URI']) &gt; 255 || 
	strpos($_SERVER['REQUEST_URI'], "eval(") || 
	strpos($_SERVER['REQUEST_URI'], "base64")) {
		@header("HTTP/1.1 414 Request-URI Too Long");
		@header("Status: 414 Request-URI Too Long");
		@header("Connection: Close");
		@exit;
} ?&gt;</code></pre>
										<p>This script checks for excessively long request strings (i.e., greater than 255 characters), as well as the presence of either &ldquo;<code>eval(</code>&rdquo; or &ldquo;<code>base64</code>&rdquo; in the request <acronym title="Uniform Resource Identifier">URI</acronym>. These sorts of nefarious requests were implicated in the September 2009 WordPress attacks.</p>
										<p>To protect your site using this lightweight script, save the code as a plugin and activate in the WordPress Admin area. Once active, this plugin will silently and effectively close any connections for these sorts of injection-type attacks.</p>
										<p>For further protection against malicious code, automated attacks, and other cracker nonsense, check out my <a href="http://perishablepress.com/press/2009/03/16/the-perishable-press-4g-blacklist/" title="Perishable Press 4G Blacklist">4G Blacklist</a>.</p>
										<h4>Update to original method</h4>
										<p>As is often the case, Perishable Press readers have helped to improve this plugin by leaving comments, asking questions, and recommending changes. Here is the new, recommended version of the plugin:</p>
										<pre><code>&lt;?php 
/* 
Plugin Name: Block Bad Queries
Plugin URI: http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/
Description: Protect WordPress Against Malicious URL Requests
Author URI: http://perishablepress.com/
Author: Perishable Press
Version: 1.0
*/
global $user_ID; if($user_ID) {
	if(!current_user_can('level_10')) {
		if (strlen($_SERVER['REQUEST_URI']) &gt; 255 || 
			strpos($_SERVER['REQUEST_URI'], "eval(") || 
			strpos($_SERVER['REQUEST_URI'], "CONCAT") || 
			strpos($_SERVER['REQUEST_URI'], "UNION+SELECT") || 
			strpos($_SERVER['REQUEST_URI'], "base64")) {
				@header("HTTP/1.1 414 Request-URI Too Long");
				@header("Status: 414 Request-URI Too Long");
				@header("Connection: Close");
				@exit;
		}
	}
} ?&gt;</code></pre>
										<p>The changes include, in order, proper plugin declaration (thanks <a href="http://www.aldolat.it/2009/wordpress/proteggere-wordpress-da-richieste-url-maligne/" title="Proteggere WordPress da richieste URL maligne">Aldo</a>), exclusion of admin pages, and additional protection against <code>CONCAT</code> and <code>UNION+SELECT</code> requests (thanks <a href="#comment-76422" title="Read comment" class="anchor">John Hoff</a>).</p>
										<p><em>Merry Christmas!</em></p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/" title="Read 'Protect WordPress Against Malicious URL Requests' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/01/02/blacklist-candidate-number-2008-01-02/" title="Blacklist Candidate Number 2008-01-02 (January 2, 2008)">Blacklist Candidate Number 2008-01-02</a></li>
					<li><a href="http://perishablepress.com/press/2007/09/05/comprehensive-reference-for-wordpress-no-nofollow-dofollow-plugins/" title="Comprehensive Reference for WordPress NoNofollow/Dofollow Plugins (September 5, 2007)">Comprehensive Reference for WordPress NoNofollow/Dofollow Plugins</a></li>
					<li><a href="http://perishablepress.com/press/2007/12/18/optimize-wordpress-pure-code-alternatives-for-7-unnecessary-plugins/" title="Optimize WordPress: Pure Code Alternatives for 7 Unnecessary Plugins (December 18, 2007)">Optimize WordPress: Pure Code Alternatives for 7 Unnecessary Plugins</a></li>
					<li><a href="http://perishablepress.com/press/2008/02/10/blacklist-candidate-number-2008-02-10/" title="Blacklist Candidate Number 2008-02-10 (February 10, 2008)">Blacklist Candidate Number 2008-02-10</a></li>
					<li><a href="http://perishablepress.com/press/2008/03/08/blacklist-candidate-number-2008-03-09/" title="Blacklist Candidate Number 2008-03-09 (March 8, 2008)">Blacklist Candidate Number 2008-03-09</a></li>
					<li><a href="http://perishablepress.com/press/2008/04/08/three-unsolved-wordpress-mysteries/" title="Three Unsolved WordPress Mysteries (April 8, 2008)">Three Unsolved WordPress Mysteries</a></li>
					<li><a href="http://perishablepress.com/press/2008/04/27/blacklist-candidate-number-2008-04-27/" title="Blacklist Candidate Number 2008-04-27 (April 27, 2008)">Blacklist Candidate Number 2008-04-27</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=zHIqsPySxAw:JP1alEBSmwk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=zHIqsPySxAw:JP1alEBSmwk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=zHIqsPySxAw:JP1alEBSmwk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=zHIqsPySxAw:JP1alEBSmwk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=zHIqsPySxAw:JP1alEBSmwk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=zHIqsPySxAw:JP1alEBSmwk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=zHIqsPySxAw:JP1alEBSmwk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=zHIqsPySxAw:JP1alEBSmwk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=zHIqsPySxAw:JP1alEBSmwk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=zHIqsPySxAw:JP1alEBSmwk:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=zHIqsPySxAw:JP1alEBSmwk:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Really Simple Browser Detection with jQuery</title>
		<link>http://perishablepress.com/press/2009/12/13/simple-browser-detection/</link>
		<comments>http://perishablepress.com/press/2009/12/13/simple-browser-detection/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 17:35:00 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Function]]></category>

		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[browsers]]></category>

		<category><![CDATA[camino]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[firefox]]></category>

		<category><![CDATA[ie]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[opera]]></category>

		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/12/13/simple-browser-detection/</guid>
		<description><![CDATA[										For my Serious redesign, I push the envelope in terms of CSS&#8217; advanced selector functionality. Stuff like:
										
										p:first-child
										p:first-child:first-letter
										p:first-child:after
										p:first-child:first-line
										
										Plus lots of other stylistic tricks that require CSS3 support in order to display as intended. Fortunately, most of the browsers to which I am catering with this new design have no problems with most of the advanced stuff. [...]]]></description>
			<content:encoded><![CDATA[										<p>For my <a href="http://perishablepress.com/press/2009/11/30/getting-serious-with-a-new-design/" title="Getting Serious with a New Design">Serious redesign</a>, I push the envelope in terms of <acronym title="Cascading Style Sheets">CSS</acronym>&rsquo; advanced selector functionality. Stuff like:</p>
										<ul>
										<li><code>p:first-child</code></li>
										<li><code>p:first-child:first-letter</code></li>
										<li><code>p:first-child:after</code></li>
										<li><code>p:first-child:first-line</code></li>
										</ul>
										<p>Plus lots of other stylistic tricks that require <acronym title="Cascading Style Sheets">CSS</acronym>3 support in order to display as intended. Fortunately, most of the browsers to which I am catering with this new design have no problems with most of the advanced stuff. Of course, Internet Explorer chokes on just about everything, but fortunately <acronym title="Internet Explorer">IE</acronym>&rsquo;s proprietary <a href="http://perishablepress.com/press/2007/07/18/wrapping-your-head-around-downlevel-conditional-comments/" title="Wrapping Your Head around Downlevel Conditional Comments">conditional</a> <a href="http://perishablepress.com/press/2006/09/04/fun-with-downlevel-conditional-comments/" title="Fun with Downlevel Conditional Comments">comments</a> make it easy to fix things up with some &ldquo;special&rdquo; styles:</p>
										<pre><code>&lt;!--[if IE 6]&gt;
	&lt;link rel="stylesheet" type="text/css" media="Screen" href="http://perishablepress.com/press/wp-content/themes/serious/css/ie6.css" /&gt;
&lt;![endif]--&gt;
&lt;!--[if IE 7]&gt;
	&lt;link rel="stylesheet" type="text/css" media="Screen" href="http://perishablepress.com/press/wp-content/themes/serious/css/ie7.css" /&gt;
&lt;![endif]--&gt;
&lt;!--[if IE 8]&gt;
	&lt;link rel="stylesheet" type="text/css" media="Screen" href="http://perishablepress.com/press/wp-content/themes/serious/css/ie8.css" /&gt;
&lt;![endif]--&gt;</code></pre>
										<p><strong>Bam</strong>, just like that. In each of these stylesheets, I essentially &ldquo;undo&rdquo; all of the cool <acronym title="Cascading Style Sheets">CSS</acronym> effects that modern browsers get, including some <a href="http://perishablepress.com/press/2009/11/09/perfect-pre-tags/" title="Perfect Pre Tags">crafty <code>&lt;pre&gt;</code> treatments</a> that you are hopefully enjoying&nbsp;;) Notice that we can specify an additional/alternate stylesheet for <em>any</em> version of <acronym title="Internet Explorer">IE</acronym>. For the <a href="http://perishablepress.com/press/index.php?wptheme=Serious" title="Skin the site with the 'Serious' theme (opens new tab or window)">Serious theme</a>, I provide around 20 remedial rules for <acronym title="Internet Explorer">IE</acronym> 6, 7, and 8. Once <acronym title="Internet Explorer">IE</acronym> 9 is released, we&rsquo;ll need <em>four</em> additional stylesheets. Moving on..</p>
										<p>So that takes care of Microsoft, but there are still other browsers to consider. I designed the new Serious theme to look perfect in the latest version of Firefox (3.5), which uses a different rendering engine than Safari, Opera, and Chrome. Fortunately, I didn&rsquo;t need to change much for older versions of Firefox, but some of the other modern browsers required a few tweaks to get things looking <em>just right</em>. To do this, I could have used a bunch of ugly <a href="http://perishablepress.com/press/tag/hacks/" title="CSS Hacks Archive"><acronym title="Cascading Style Sheets">CSS</acronym> hacks</a>, but there are too many risks and &ldquo;gotchas&rdquo; when it comes to differentiating between Safari and Opera, for example. So I decided to keep things as simple and specific as possible. Here&rsquo;s how I did it..</p>
										<h3>Really Simple Browser Detection for Modern Browsers</h3>
										<p>Before getting into it, let me just acknowledge that browser detection should only be used as a last resort. If you can design a site without needing any hacks or alternate presentational trickery, then good for you, no browser detection needed. When it comes to pushing the envelope and trying new things, however, you&rsquo;ll almost always find presentational discrepancies in modern browsers. In any case, it turns out that I <em>do</em> feel as if browser detection was the ideal solution for the new design, mostly due to the fact that the modifications were few and fairly cosmetic in nature, so no big deal if JavaScript is not available to the user.</p>
										<p>Basically, I want to apply an additional stylesheet to each of the modern browsers. To do this with <acronym title="Internet Explorer">IE</acronym>, conditional comments work perfectly. I almost wish that <em>every</em> browser included some sort of conditional-comment functionality. It would make all this browser-detection stuff unnecessary. In any case, here is a list of browsers that I want to target with <acronym title="Cascading Style Sheets">CSS</acronym> (in no particular order):</p>
										<ul>
										<li>Camino</li>
										<li>Chrome</li>
										<li>Opera</li>
										<li>Safari</li>
										</ul>
										<p>For these four browsers, I created four unique stylesheets and then conditionally link to them with a few snippets of jQuery:</p>
										<pre><code>&lt;div class="altcss"&gt;

	&lt;script type="text/javascript"&gt;$.browser.camino = /camino/.test(navigator.userAgent.toLowerCase()); if ($.browser.camino) { 
	document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/camino.css" type="text/css" media="screen"&gt;'); }&lt;/script&gt;

	&lt;script type="text/javascript"&gt;$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); if ($.browser.chrome) { 
	document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/chrome.css" type="text/css" media="screen"&gt;'); }&lt;/script&gt;

	&lt;script type="text/javascript"&gt;$.browser.opera  = /opera/.test(navigator.userAgent.toLowerCase());  if ($.browser.opera)  { 
	document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/opera.css"  type="text/css" media="screen"&gt;'); }&lt;/script&gt;

	&lt;script type="text/javascript"&gt;$.browser.safari = /safari/.test(navigator.userAgent.toLowerCase()); if ($.browser.safari) { 
	document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/safari.css" type="text/css" media="screen"&gt;'); }&lt;/script&gt;

&lt;/div&gt;</code></pre>
										<p>Basically, each of these snippets tests the client&rsquo;s user-agent string and writes a <code>&lt;link&gt;</code> to any matching stylesheet. Of course JavaScript is required on the user&rsquo;s browser, so it&rsquo;s best not to use this technique for anything beyond minor cosmetic enhancements. </p>
										<p>As for the code itself, I am know there are more elaborate ways of sniffing and detecting browsers, but I wanted to keep things as simple as possible. Also, this code could also be simplified to exist within a single <code>&lt;script&gt;</code> element:</p>
										<pre><code>&lt;div class="altcss"&gt;

	&lt;script type="text/javascript"&gt;

		$.browser.camino = /camino/.test(navigator.userAgent.toLowerCase()); if ($.browser.camino) { 
		document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/camino.css" type="text/css" media="screen"&gt;'); }

		$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); if ($.browser.chrome) { 
		document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/chrome.css" type="text/css" media="screen"&gt;'); }

		$.browser.opera  = /opera/.test(navigator.userAgent.toLowerCase());  if ($.browser.opera)  { 
		document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/opera.css"  type="text/css" media="screen"&gt;'); }

		$.browser.safari = /safari/.test(navigator.userAgent.toLowerCase()); if ($.browser.safari) { 
		document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/safari.css" type="text/css" media="screen"&gt;'); }

	&lt;/script&gt;

&lt;/div&gt;</code></pre>
										<p>And of course, you aren&rsquo;t limited to the browsers specified here. You could easily target another by emulating the pattern according to the user-agent or name of the additional browser. For example, we could add a custom stylesheet for the Flock browser like so:</p>
										<pre><code>&lt;script type="text/javascript"&gt;$.browser.flock = /flock/.test(navigator.userAgent.toLowerCase()); if ($.browser.flock) { 
document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/flock.css" type="text/css" media="screen"&gt;'); }&lt;/script&gt;</code></pre>
										<p>Finally, because this is JavaScript, I place this block of code at the end of my <acronym title="eXtensible Hypertext Markup">XHTML</acronym> document, just before the closing <code>&lt;body&gt;</code> element. It could just as easily be argued that this code should be placed in the document <code>&lt;head&gt;</code> because it&rsquo;s ultimately referring to <acronym title="Cascading Style Sheets">CSS</acronym>, but I will leave it up to you to decide for yourself.</p>
										<p><strong>Update:</strong> in the comments, <a href="#comment-76060" title="Jump to comment" class="anchor">Gustavo</a> informs us that, as of jQuery 1.4, the <code>$.browser</code> variable is replaced by <code>$.support</code>. So if you&rsquo;re using jQuery 1.4 or better, you&rsquo;ll need adjust the code accordingly. Here is an example showing how this would look for the Flock browser:</p>
										<pre><code>&lt;script type="text/javascript"&gt;$.support.flock = /flock/.test(navigator.userAgent.toLowerCase()); if ($.support.flock) { 
document.write('&lt;link rel="stylesheet" href="http://domain.tld/css/flock.css" type="text/css" media="screen"&gt;'); }&lt;/script&gt;</code></pre>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/12/13/simple-browser-detection/" title="Read 'Really Simple Browser Detection with jQuery' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/10/07/perishable-press-quintessential-screenshot-gallery/" title="Perishable Press Quintessential Screenshot Gallery (October 7, 2008)">Perishable Press Quintessential Screenshot Gallery</a></li>
					<li><a href="http://perishablepress.com/press/2008/11/24/perfect-rounded-corners-with-css/" title="Perfect Rounded Corners with CSS (November 24, 2008)">Perfect Rounded Corners with CSS</a></li>
					<li><a href="http://perishablepress.com/press/2010/02/01/support-old-versions-good-browsers/" title="Should We Support Old Versions of Good Browsers? (February 1, 2010)">Should We Support Old Versions of Good Browsers?</a></li>
					<li><a href="http://perishablepress.com/press/2008/09/22/how-to-deal-with-ie-6-after-dropping-support/" title="How to Deal with IE 6 after Dropping Support (September 22, 2008)">How to Deal with IE 6 after Dropping Support</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/10/keep-it-dark-hiding-and-filtering-css/" title="Keep it Dark: Hiding and Filtering CSS (January 10, 2007)">Keep it Dark: Hiding and Filtering CSS</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/16/maximum-and-minimum-height-and-width-in-internet-explorer/" title="Maximum and Minimum Height and Width in Internet Explorer (January 16, 2007)">Maximum and Minimum Height and Width in Internet Explorer</a></li>
					<li><a href="http://perishablepress.com/press/2007/07/24/absolutely-fabulous-browser-bookmarklet-things/" title="Absolutely Fabulous Browser Bookmarklet Things (July 24, 2007)">Absolutely Fabulous Browser Bookmarklet Things</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=Y5F3nJsVBZI:IiPFXIdrq7s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Y5F3nJsVBZI:IiPFXIdrq7s:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=Y5F3nJsVBZI:IiPFXIdrq7s:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Y5F3nJsVBZI:IiPFXIdrq7s:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=Y5F3nJsVBZI:IiPFXIdrq7s:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Y5F3nJsVBZI:IiPFXIdrq7s:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=Y5F3nJsVBZI:IiPFXIdrq7s:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Y5F3nJsVBZI:IiPFXIdrq7s:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=Y5F3nJsVBZI:IiPFXIdrq7s:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Y5F3nJsVBZI:IiPFXIdrq7s:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=Y5F3nJsVBZI:IiPFXIdrq7s:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/12/13/simple-browser-detection/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The New Clearfix Method</title>
		<link>http://perishablepress.com/press/2009/12/06/new-clearfix-hack/</link>
		<comments>http://perishablepress.com/press/2009/12/06/new-clearfix-hack/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 05:47:46 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[hacks]]></category>

		<category><![CDATA[ie]]></category>

		<category><![CDATA[notes]]></category>

		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/12/06/new-clearfix-hack/</guid>
		<description><![CDATA[										Say goodbye to the age-old clearfix hack and hello to the new and improved clearfix method..
										The clearfix hack, or &#8220;easy-clearing&#8221; hack, is a useful method of clearing floats. I have written about the original method and even suggested a few improvements. The original clearfix hack works great, but the browsers that it targets are either [...]]]></description>
			<content:encoded><![CDATA[										<blockquote><p>Say goodbye to the age-old clearfix <em>hack</em> and hello to the <strong>new and improved</strong> clearfix method..</p></blockquote>
										<p>The clearfix hack, or &ldquo;easy-clearing&rdquo; hack, is a useful method of <a href="http://css-tricks.com/the-how-and-why-of-clearing-floats/" title="The How and Why of Clearing Floats">clearing floats</a>. I have written about the <a href="http://perishablepress.com/press/2008/06/18/css-hackz-series-clearing-floats-with-the-clearfix-hack/" title="CSS Hackz Series: Clearing Floats with the Clearfix Hack">original method</a> and even suggested <a href="http://perishablepress.com/press/2008/02/05/lessons-learned-concerning-the-clearfix-css-hack/" title="Lessons Learned Concerning the Clearfix CSS Hack">a few improvements</a>. The original clearfix hack works great, but the browsers that it targets are either obsolete or <a href="http://iedeathmarch.org/" title="IE Death March">well on their way</a>. Specifically, Internet Explorer 5 for Mac is now history, so there is no reason to bother with it when using the clearfix method of clearing floats.</p>
										<p>The original clearfix hack looks something like this:</p>
										<pre><code>.clearfix:after {
	visibility: hidden;
	display: block;
	font-size: 0;
	content: " ";
	clear: both;
	height: 0;
	}
.clearfix { display: inline-table; }
/* Hides from IE-mac \*/
* html .clearfix { height: 1%; }
.clearfix { display: block; }
/* End hide from IE-mac */</code></pre>
										<p>Yes it&rsquo;s ugly, but it works very well, enabling designers to clear floats without hiding overflow and setting a width or floating (nearly) everything to get the job done. The logic behind this hack goes something like this:</p>
										<ul>
										<li>Target compliant browsers with the first declaration block (if all browsers were standards-compliant, this would be the only thing needed) and create a hidden clearing block after the content of the target element.</li>
										<li>The second declaration applies an <code>inline-table</code> display property, exclusively for the benefit of <acronym title="Internet Explorer">IE</acronym>/Mac.</li>
										<li>At this point, we use the comment-backslash hack to hide the remainder of the rules from <acronym title="Internet Explorer">IE</acronym>/Mac. This enables us to do the following:</li>
										<li>Apply a <code>1%</code> height only to <acronym title="Internet Explorer">IE</acronym>6 to trigger hasLayout (which is required for the hack to work)</li>
										<li>Re-apply <code>display:block</code> to everything <em>except</em> <acronym title="Internet Explorer">IE</acronym>/Mac</li>
										<li>The last line is a comment that serves to close the hack for <acronym title="Internet Explorer">IE</acronym>/Mac</li>
										</ul>
										<p>As you can see, that&rsquo;s a <em>lot</em> of fuss over a browser that has been dead for at least the last three or four years. <strong>Nobody uses <acronym title="Internet Explorer">IE</acronym>/Mac anymore, so it is time to drop it from the clearfix hack</strong>. The result is a much cleaner and more efficient slice of <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>/* new clearfix */
.clearfix:after {
	visibility: hidden;
	display: block;
	font-size: 0;
	content: " ";
	clear: both;
	height: 0;
	}
* html .clearfix             { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */</code></pre>
										<p>Stripping out that <acronym title="Internet Explorer">IE</acronym>/Mac cruft cleans things up real nice. Notice that we have further improved the clearfix hack by adding support for <acronym title="Internet Explorer">IE</acronym>7. Neither <acronym title="Internet Explorer">IE</acronym>6 nor <acronym title="Internet Explorer">IE</acronym>7 support the <code>:after</code> pseudo-class used in the first declaration, so we need an alternate method of applying the clearfix. Fortunately, applying <code>zoom:1</code> to either browser triggers <acronym title="Internet Explorer">IE</acronym>&rsquo;s proprietary <a href="http://www.satzansatz.de/cssd/onhavinglayout.html" title="On having layout">hasLayout</a> mechanism, which works just fine to clear the float. For expediency&rsquo;s sake, we accomplish this with a couple of valid browser-specific selectors, but you should be advised that <a href="http://perishablepress.com/press/2007/07/18/wrapping-your-head-around-downlevel-conditional-comments/" title="Wrapping Your Head around Downlevel Conditional Comments">conditional</a> <a href="http://perishablepress.com/press/2006/09/04/fun-with-downlevel-conditional-comments/" title="Fun with Downlevel Conditional Comments">comments</a> are the recommended way to go.</p>
										<p>Fortunately, <acronym title="Internet Explorer">IE</acronym>8 <em>supports</em> the <code>:after</code> pseudo-class, so this new clearfix method will only become more simplified as <acronym title="Internet Explorer">IE</acronym>6 and, eventually, <acronym title="Internet Explorer">IE</acronym>7 finally die off.</p>
										<p><strong>Bottom line:</strong> The new clearfix method applies clearing rules to standards-compliant browsers using the <code>:after</code> pseudo-class. For <acronym title="Internet Explorer">IE</acronym>6 and <acronym title="Internet Explorer">IE</acronym>7, the new clearfix method triggers <code>hasLayout</code> with some proprietary <acronym title="Cascading Style Sheets">CSS</acronym>. Thus, the New Clearfix method effectively clears floats in all <em>currently used</em> browsers <strong>without using any hacks</strong>.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/12/06/new-clearfix-hack/" title="Read 'The New Clearfix Method' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/02/05/lessons-learned-concerning-the-clearfix-css-hack/" title="Lessons Learned Concerning the Clearfix CSS Hack (February 5, 2008)">Lessons Learned Concerning the Clearfix CSS Hack</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/10/keep-it-dark-hiding-and-filtering-css/" title="Keep it Dark: Hiding and Filtering CSS (January 10, 2007)">Keep it Dark: Hiding and Filtering CSS</a></li>
					<li><a href="http://perishablepress.com/press/2008/09/10/series-summary-obsessive-css-code-formatting/" title="Series Summary: Obsessive CSS Code Formatting (September 10, 2008)">Series Summary: Obsessive CSS Code Formatting</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/27/css-hack-dumpster/" title="CSS Hack Dumpster (August 27, 2006)">CSS Hack Dumpster</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/27/crazy-css-underline-effects/" title="Crazy CSS Underline Effects (August 27, 2006)">Crazy CSS Underline Effects</a></li>
					<li><a href="http://perishablepress.com/press/2006/10/31/theme-edits-for-ie7/" title="Theme Edits for IE7 (October 31, 2006)">Theme Edits for IE7</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/16/maximum-and-minimum-height-and-width-in-internet-explorer/" title="Maximum and Minimum Height and Width in Internet Explorer (January 16, 2007)">Maximum and Minimum Height and Width in Internet Explorer</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=R4CjZq6Cxaw:OSD-7Gn-To0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=R4CjZq6Cxaw:OSD-7Gn-To0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=R4CjZq6Cxaw:OSD-7Gn-To0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=R4CjZq6Cxaw:OSD-7Gn-To0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=R4CjZq6Cxaw:OSD-7Gn-To0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=R4CjZq6Cxaw:OSD-7Gn-To0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=R4CjZq6Cxaw:OSD-7Gn-To0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=R4CjZq6Cxaw:OSD-7Gn-To0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=R4CjZq6Cxaw:OSD-7Gn-To0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=R4CjZq6Cxaw:OSD-7Gn-To0:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=R4CjZq6Cxaw:OSD-7Gn-To0:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/12/06/new-clearfix-hack/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Stupid WordPress Tricks</title>
		<link>http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/</link>
		<comments>http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 18:35:57 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/</guid>
		<description><![CDATA[										 One of the most popular articles here at Perishable Press is my January 2005 post, Stupid htaccess Tricks. In that article, I bring together an extensive collection of awesome copy-&#38;-paste HTAccess code snippets. Four years later, people continue to tell me how much they enjoy and use the content as a bookmarked reference for [...]]]></description>
			<content:encoded><![CDATA[										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/misc-chunks/wordpress-tricks.jpg" alt="[ WordPress ]" /> One of the most popular articles here at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a> is my January 2005 post, <a href="http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/" title="Stupid htaccess Tricks">Stupid htaccess Tricks</a>. In that article, I bring together an extensive collection of awesome copy-&amp;-paste <acronym title="Hypertext Access">HTAccess</acronym> code snippets. Four years later, people continue to tell me how much they enjoy and use the content as a bookmarked reference for many of their <acronym title="Hypertext Access">HTAccess</acronym> needs. The article was even published in a book on <a href="http://www.packtpub.com/joomla-web-security-guide/book" title="Joomla! Web Security by Tom Canavan">Joomla! Security</a>.</p>
										<p>This is very inspiring to me, so I have decided to create a similar post for all of the useful <strong>WordPress code snippets, tips and tricks</strong> that I have collected while working on <a href="http://digwp.com/book/" title="Digging into WordPress">Digging into WordPress</a>, the new book by co-author Chris Coyier and myself that really &ldquo;digs&nbsp;in&rdquo; to all of the awesome ways to get the most out of WordPress. While writing the <acronym title="Digging into WordPress">DiW</acronym> book, I collected <em>hundreds</em> of incredibly useful WordPress tips and tricks. After packing the book with as many of these techniques as possible, I decided to share the &ldquo;best of the rest&rdquo; here at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>.</p>
										<p>If you are one of the millions of people who use WordPress, this article will help you improve the appearance, functionality, and performance of your WordPress-powered websites. Each of these &ldquo;stupid WordPress tricks&rdquo; is presented as clearly and succinctly as possible, including as many notes, instructions, and pointers as needed for successful implementation. Of course, keep in mind that we are only <em>scratching the surface</em> here. For a much more <em>complete</em> resource that is <em>packed</em> with tons of tasty techniques, you need to get <a href="http://digwp.com/book/" title="Get the Book!">Digging into WordPress</a>.</p>
										<p>So now, without further ado, here is my personal collection of easy-to-use, copy-&amp;-paste WordPress tricks. Enjoy!&nbsp;:)</p>
										<h3 id="toc">Table of Contents</h3>
										<ol>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_01">WordPress Shortcodes</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_02">WordPress Permalinks Outside of the Loop</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_03">Custom Message to Returning Visitors</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_04">Recently Updated Posts and Pages</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_05">Custom Content to Search Engine Visitors</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_06">Last Modified Time and Date for Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_07">Display Total Number of Trackbacks and Pingbacks</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_08">Display Recently Registered Users</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_09">List all of Your Site&rsquo;s Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_10">List WordPress User Information</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_11">Display List of Scheduled Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_12">Display Private Posts to Logged-in Users</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_13">Display Posts from Exactly One Year Ago</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_14">Custom CSS Styles for Recent Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_15">New WordPress-2.7 Comments Loop</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_16">Backwards-Compatible Comment Templates</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_17">Disable WordPress Post Revisions</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_18">Limit WordPress Post Revisions</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_19">Remove WordPress Post Revisions from the Database</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_20">Reduce Comment Spam by Blocking No-Referrer Requests</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_21">Prevent Google Analytics from Tracking Admin Pages</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_22">Meta Descriptions without a Plugin</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_23">Differentiate Between Posts Depending on Presence of Excerpt</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_24">Modify the wp_options Table via the WordPress Admin</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_25">Alternate Comment Styles</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_26">Automatically Remove Code Mistakes in Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_27">Automatically Disable Comments and Trackbacks in Old Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_28">Access Post Data Outside the Loop</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_29">Display Posts for a Specified Time Period</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_30">Unique Single Post Templates for Different Categories</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_31">Display Performance Statistics for WordPress Pages</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_32">Custom Post Thumbnails in Two Steps</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_33">Highlight Author Comments</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_34">Easy Random Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_35">Display Dates for Groups of Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_36">Display a Sticky Post in the Sidebar</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_37">Display Latest Comments without a Plugin</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_38">Display Most Commented Posts without a Plugin</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_39">Change Permalinks from Date-Based to Post-Date Only</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_40">Test for Sub-Pages</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_41">Multiple Widgetizable Sidebars</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_42">Remove Fancy Quotes from Comments</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_43">Display a List of All Untagged Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_44">Easy Display of Custom Headers, Footers, and Sidebars</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_45">A Better Way for Users to Logout</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_46">Display a Custom Message on a Specific Date</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_47">Display Three Columns of Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_48">Disable WordPress Search Functionality</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_49">Display Posts with Specific Custom Fields</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_50">How to Number Your Comments, Pingbacks, &amp; Trackbacks in 2.7+</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_51">How to Number Your Comments Using the Classic Loop</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_52">Invite Readers to Comment via Feed</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_53">Display the Total Number of Users for Your Blog</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_54">Automatically Insert Content into Your WordPress Post Editor</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_55">How to Prevent Duplicate Content</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_56">Conditionally Display Full Posts or Excerpts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_57">Display Related Posts without a Plugin</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_58">Drop-Dead Easy Styles for Author Comments</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_59">Display Posts Upcoming Scheduled Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_60">Display Automatic TinyURLs for Your Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_61">Implement a Site-Maintenance Page for Your Blog</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_62">Display the First Image from Each of Your Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_63">Display Most Popular Posts without a Plugin</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_64">Automatically Highlight Search Terms</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_65">Automatically Disable Widgets</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_66">Display All Images from Your Post Content</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_67">Display Category List in Two Columns</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_68">Show Ads or Other Content Only in the First Three Posts</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_69">A Better Way to Display Recent Comments without a Plugin</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_70">Selectively Disable Automatic Post Formatting</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_71">Browser Detection via WordPress&rsquo; body_class Function</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_72">Get Post or Page Contents as a PHP Variable</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_73">Simple Example of How to Use WordPress Cron</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_74">Add More Default Avatar Choices to the WordPress Admin</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_75">Add a Private Page to Your Navigation Menu</a></li>
										<li><a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/#swt_76">How to Add Additional Links to wp_list_pages</a></li>
										</ol>
										<h3>WordPress Shortcodes <a id="swt_01" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Save time by replacing your most commonly typed words and phrases with WordPress shortcodes. For example, if you are frequently typing your blog&rsquo;s <acronym title="Uniform Resource Locator">URL</acronym>, you could place the following code your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>function shortURL() {
	return 'http://perishablepress.com/';
}
add_shortcode('myurl', 'shortURL');</code></pre>
										<p>Now whenever I write a post via &ldquo;<acronym title="Hypertext Markup Language">HTML</acronym>-mode&rdquo;, all I need to include my blog&rsquo;s <acronym title="Uniform Resource Locator">URL</acronym> is type &ldquo;<code>[myurl]</code>&rdquo;. Works great in WordPress 2.5 or better.</p>
										<p><strong>Shortcodes with Attributes</strong><br />To create a shortcode for links, we need to include the <code>href</code> attribute information as well as the anchor text for the link itself. We can do this by placing this function in your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>function shortLink($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" =&gt; 'http://' // default URL
	), $atts));
	return '&lt;a href="'.$href.'"&gt;'.$content.'&lt;/a&gt;';
}
add_shortcode('link', 'shortLink');</code></pre>
										<p>Then, when creating a post, emulate the following format to include any links you wish:</p>
										<p><code>[link href="http://perishablepress.com/"]Perishable Press[/link]</code></p>
										<p>..which will output the following code:</p>
										<p><code>&lt;a href="http://perishablepress.com/"&gt;Perishable Press&lt;/a&gt;</code></p>
										<p>When the <code>href</code> attribute is removed from the shortcode, the default <acronym title="Uniform Resource Locator">URL</acronym> will be used. You may specify the default <acronym title="Uniform Resource Locator">URL</acronym> in the third line of the funtion (see comment).</p>
										<p>Source: <a href="http://digwp.com/">Digging into WordPress</a></p>
										<h3>Display WordPress Permalinks Outside of the Loop <a id="swt_02" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Normally, permalink display via <code>the_permalink()</code> requires the loop. To display permalinks <em>outside</em> of the loop, we may use either of the following methods:</p>
										<pre><code>&lt;!-- external permalink via post ID --&gt;
&lt;a href="&lt;?php echo get_permalink(33); ?&gt;" &gt;Permalink&lt;/a&gt;

&lt;!-- external permalink via global $post variable --&gt;
&lt;a href="&lt;?php echo get_permalink($post-&gt;ID); ?&gt;" &gt;Permalink&lt;/a&gt;</code></pre>
										<p>Source: <a href="http://www.webinventif.fr/wordpress-hors-boucle/">Julien Chauvin</a></p>
										<h3>Display Custom Message to Returning Visitors <a id="swt_03" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>We can greet returning commentators with a custom message by extracting their information from the comment cookie left on their machine. Place the following code into the desired location in your theme and customize the message and markup to whatever you wish:</p>
										<pre><code>&lt;?php if(isset($_COOKIE['comment_author_'.COOKIEHASH])) {
	$lastCommenter = $_COOKIE['comment_author_'.COOKIEHASH];

	echo "Welcome Back ". $lastCommenter ."!";

	} else {

	echo "Welcome, Guest!";
} ?&gt;</code></pre>
										<p>Source: <a href="http://ifohdesigns.com/blog/tutorials/wordpress-welcome-back-script">ifohdesigns</a></p>
										<h3>Display Recently Updated Posts and Pages <a id="swt_04" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Easily display a list of recently updated posts by placing the following code into the desired location in your theme:</p>
										<pre><code>&lt;?php 

$today  = current_time('mysql', 1);
$number = 5; // number of posts

if($recentposts = $wpdb-&gt;get_results("SELECT ID, post_title FROM $wpdb-&gt;posts WHERE post_status = 'publish' AND post_modified_gmt &lt; '$today' ORDER BY post_modified_gmt DESC LIMIT $number")):

?&gt;

&lt;h2&gt;&lt;?php _e("Recently Updated"); ?&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;?php

foreach($recentposts as $post) {

	if($post-&gt;post_title == '') $post-&gt;post_title = sprintf(__('Post #%s'), $post-&gt;ID);
	echo '&lt;li&gt;&lt;a href="'.get_permalink($post-&gt;ID).'"&gt;'.the_title().'&lt;/a&gt;&lt;/li&gt;';

} ?&gt;
&lt;/ul&gt;

&lt;?php endif; ?&gt;</code></pre>
										<p>Of course, customize the details as necessary and remember to set the number of posts via the &ldquo;<code>$howMany</code>&rdquo; variable.</p>
										<p>Source: <a href="http://www.tacticaltechnique.com/wordpress/wordpress-recently-updated-pages-or-posts/">Corey</a></p>
										<h3>Display Custom Content to Search Engine Visitors <a id="swt_05" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Display custom content to your search-engine traffic by placing the following code into your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>&lt;?php function scratch99_fromasearchengine() {

	$ref = $_SERVER['HTTP_REFERER'];
	$SE  = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
	
	foreach($SE as $source) {
		if(strpos($ref, $source) !== false) return true;
	}
	return false;
} ?&gt;</code></pre>
										<p>After checking and editing the $SE array with the search-engine referrer information of your choice, place this next chunk of code into the desired display location in your theme file(s):</p>
										<pre><code>&lt;?php if(function_exists('scratch99_fromasearchengine')) {
	if (scratch99_fromasearchengine()) {

		// INSERT YOUR CODE HERE

	}
} ?&gt;</code></pre>
										<p>Add whatever content or code you wish to the specified area and enjoy targeted delivery to search-engine visitors only.</p>
										<p>Source: <a href="http://www.scratch99.com/">Stephen Cronin</a></p>
										<h3>Display Last Modified Time and Date for Posts <a id="swt_06" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Display the &ldquo;last-modified&rdquo; time for your posts by placing this code anywhere within the loop:</p>
										<pre><code>Posted on &lt;?php the_time('F jS, Y') ?&gt;
&lt;?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if($u_modified_time != $u_time) {
	echo "and last modified on ";
	the_modified_time('F jS, Y');
	echo ". ";
} ?&gt;</code></pre>
										<p>Source: <a href="http://wphacks.com/how-to-show-last-modified-wordpress-post/">Kyle Eslick</a></p>
										<h3>Display Total Number of Trackbacks and Pingbacks <a id="swt_07" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Display the trackback/pingback count for each of your posts by first placing this code into your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>function comment_count() {
	global $wpdb;
	$count = "SELECT COUNT(*) FROM $wpdb-&gt;comments WHERE comment_type = 'pingback' OR comment_type = 'trackback'";
	echo $wpdb-&gt;get_var($count);
}</code></pre>
										<p>And then call the number for display anywhere in your theme by adding this code to the desired location:</p>
										<p><code>&lt;?php comment_count(); ?&gt;</code></p>
										<p>Alternately, in WordPress 2.7, you may display the total number of comments by inserting this code directly into your <code>comments.php</code> template:</p>
										<pre><code>&lt;?php if(!empty($comments_by_type['comment'])) : 
	$count = count($comments_by_type['comment']);
	($count !== 1) ? $txt = "Comments" : $txt = "Comment"; 
?&gt;
&lt;h3&gt;&lt;?php echo $count . " " . $txt; ?&gt;&lt;/h3&gt;</code></pre>
										<p>Edit the markup as desired. Will display &ldquo;&rdquo; or &ldquo;&rdquo;, depending on the number of comments.</p>
										<p>Source: <a href="http://wpengineer.com/comment-ping-count/">WPengineer.com</a></p>
										<h3>Display Recently Registered Users <a id="swt_08" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Quick and easy method for displaying a list of recently registered users. Place the following code directly into your theme, wherever you would like to display the list:</p>
										<pre><code>&lt;ul&gt;
	&lt;?php $usernames = $wpdb-&gt;get_results("SELECT user_nicename, user_url FROM $wpdb-&gt;users ORDER BY ID DESC LIMIT 5");

		foreach ($usernames as $username) {
    			echo '&lt;li&gt;&lt;a href="'.$username-&gt;user_url.'"&gt;'.$username-&gt;user_nicename."&lt;/a&gt;&lt;/li&gt;";
		}
	?&gt;
&lt;/ul&gt;</code></pre>
										<p>As-is, this code will spit out the five most recent registered users. This is easily changed to whatever number you wish by simply editing the number &ldquo;5&rdquo; in the first line.</p>
										<p>Source: <a href="http://www.wprecipes.com/how-to-list-latest-registered-users">WPRecipes.com</a></p>
										<h3>List all of Your Site&rsquo;s Posts <a id="swt_09" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>If the default <code>wp_get_archives(type=postbypost&amp;limit=)</code> function doesn&rsquo;t provide enough flexibility to meet your needs, here is another way to list <strong>all</strong> of your site&rsquo;s posts:</p>
										<pre><code>&lt;?php while(have_posts()) : the_post(); ?&gt;
&lt;ul&gt;
	&lt;?php $allposts = get_posts('numberposts=-1&amp;offset=0'); foreach($allposts as $post) : ?&gt;

	&lt;li&gt;&lt;?php the_time('d/m/y'); ?&gt;: &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;

	&lt;?php endforeach; ?&gt;
&lt;/ul&gt;
&lt;?php endwhile; ?&gt;</code></pre>
										<p>In place, that code will display a list of all of your blog&rsquo;s posts. As a bonus, you may use any of the applicable parameters available to the <code>get_posts()</code> function to do just about anything you need with your posts list.</p>
										<p>Source: <a href="http://www.wprecipes.com/">WPRecipes.com</a></p>
										<h3>List WordPress User Information <a id="swt_10" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is an easy way to display flexible lists of your blog&rsquo;s registered users&rsquo; information. In this example, we will list the first and last name of each user registered in the database:</p>
										<pre><code>&lt;ul&gt;
&lt;?php $szSort = "user_nicename";  
$aUsersID = $wpdb-&gt;get_col($wpdb-&gt;prepare("SELECT $wpdb-&gt;users.ID FROM $wpdb-&gt;users ORDER BY %s ASC", $szSort)); 
	foreach($aUsersID as $iUserID) :
		$user = get_userdata($iUserID);
		echo '&lt;li&gt;'.ucwords(strtolower($user-&gt;first_name.' '.$user-&gt;last_name)).'&lt;/li&gt;'; 
	endforeach; 
?&gt;
&lt;/ul&gt;</code></pre>
										<p>The following variables may be used to display different types of user information and also to specify the sort order of the output list:</p>
										<ul>
										<li><code>ID</code> &#8212; User ID number</li>
										<li><code>user_login</code> &#8212; User Login name</li>
										<li><code>user_nicename</code> &#8212; nice version of login name</li>
										<li><code>user_email</code> &#8212; User Email Address</li>
										<li><code>user_url</code> &#8212; User Website URL</li>
										<li><code>user_registered</code> &#8212; User Registration date</li>
										</ul>
										<p>To display any of these different types of user information, call it with <code>$user-&gt;name_of_the_column</code> anywhere within the function&rsquo;s <code>foreach()</code> loop. To change the display order of the output, use any of the above as the value of the <code>$szSort</code> variable in the first line of the function. Note that <code>strtolower</code> and <code>ucwords</code> are used to ensure proper capitalization of the user names.</p>
										<p>Source: <a href="http://www.mattvarone.com/wordpress/list-users/">Matt Varone</a></p>
										<h3>Display List of Scheduled Posts <a id="swt_11" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Got scheduled posts? Cool. Here&rsquo;s how to display them to your readers:</p>
										<pre><code>&lt;ul&gt;
&lt;?php $my_query = new WP_Query('post_status=future&amp;order=DESC&amp;showposts=5');
if ($my_query-&gt;have_posts()) {
	while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); $do_not_duplicate = $post-&gt;ID; ?&gt;

        &lt;li&gt;&lt;?php the_title(); ?&gt;&lt;/li&gt;

	&lt;?php endwhile; } ?&gt;
&lt;/ul&gt;</code></pre>
										<p>Place that code in the desired location of your WordPress template and display a list of scheduled posts to your readers. To change the total number of displayed posts, edit the <code>showposts=5</code> parameter to any number you wish. You may also use other parameters available to the <code>WP_Query()</code> function to further customize the output.</p>
										<p>Source: <a href="http://wp-magazin.ch/2008/11/07/den-leser-in-die-zukunft-blicken-lassen/">Pascal Birchler</a></p>
										<h3>Display Private Posts to Logged-in Users <a id="swt_12" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>To display private posts to your logged-in users, you will need to add a custom field called &ldquo;<code>private</code>&rdquo; for each private post and give it a value of &ldquo;<code>true</code>&rdquo;. Then, replace your default WordPress loop with the following:</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post();

	$private = get_post_custom_values("private");
	if (isset($private[0]) &amp;&amp; $private == "true") {
		if (is_user_logged_in()) {
			// Display private post to logged user
		}
	} else {
		// Display public post to everyone
	}

endwhile; endif; ?&gt;</code></pre>
										<p>This custom loop will check each post for the presence of a custom-field value of <code>true</code>. For each post that has this value, the loop will then check to see if the user is logged into your site. If the user is in fact logged in, the loop will display the private post(s). Public posts will be displayed as usual and regardless of whether the user is logged in or not.</p>
										<p>Source: <a href="http://digwp.com/2009/08/password-protect-more-than-the_content/">Digging into WordPress</a></p>
										<h3>Display Posts from Exactly One Year Ago <a id="swt_13" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Use this code to display posts that are exactly one year old:</p>
										<pre><code>&lt;?php 
$current_day = date('j');
$last_year   = date('Y')-1; 
?&gt;
&lt;?php query_posts('day='.$current_day.'&amp;year='.$last_year); 
	if (have_posts()): while (have_posts()) : the_post(); ?&gt;

	&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
	&lt;?php the_excerpt(); ?&gt;

&lt;?php endwhile; endif; ?&gt;</code></pre>
										<p>To display posts from different days or different years, edit the two variables in the beginning of the method.</p>
										<h3>Custom CSS Styles for Recent Posts <a id="swt_14" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Use some custom CSS styles to highlight your recent posts. To do this, replace your existing loop with the following:</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

	$currentdate = date('Y-m-d',mktime(0,0,0,date('m'),date('d'),date('Y')));
	$postdate = get_the_time('Y-m-d');
	if ($postdate == $currentdate) {

		echo '&lt;div class="post new"&gt;';

	} else {

		echo '&lt;div class="post"&gt;';

	} ?&gt;

		&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
	&lt;/div&gt;

&lt;?php endwhile; endif; ?&gt;</code></pre>
										<p>This new loop will check the date of each post and include a <acronym title="Cascading Style Sheets">CSS</acronym> class of &ldquo;<code>new</code>&rdquo; to any post published within the previous 24-hour time period. Once the new post class is included, you may style it with some custom <acronym title="Cascading Style Sheets">CSS</acronym> such as the following:</p>
										<pre><code>.post{
	/* styles for all posts */
	}
.post.new {
	/* styles for new posts */
	}</code></pre>
										<p>Source: Fred jaillet [via] <a href="http://www.wprecipes.com/how-to-make-your-new-posts-stands-out">WPRecipes.com</a></p>
										<h3>New WordPress-2.7 Comments Loop <a id="swt_15" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Due to the changes made to comment-related functions in WordPress 2.7, you will need to upgrade your comments template in order accomodate for the new functionality. The major changes are the new <code>wp_list_comments()</code> function and the <code>next/previous_comments_link()</code> functions. Here is an example <code>comments.php</code> loop to get you started:</p>
										<pre><code>&lt;?php if (have_comments()) : ?&gt;

	&lt;h4&gt;&lt;?php comments_number('No Comments', 'One Comment', '% Comments' );?&gt;&lt;/h4&gt;
	&lt;ul class="commentlist"&gt;
		&lt;?php wp_list_comments(); ?&gt;
	&lt;/ul&gt;
	&lt;div class="navigation"&gt;
		&lt;div class="alignleft"&gt;&lt;?php previous_comments_link(); ?&gt;&lt;/div&gt;
		&lt;div class="alignright"&gt;&lt;?php next_comments_link(); ?&gt;&lt;/div&gt;
	&lt;/div&gt;

&lt;?php else : // if there are no comments so far ?&gt;

	&lt;?php if ('open' == $post-&gt;comment_status) : ?&gt;

		&lt;p&gt;Comments are open, but there are no comments.&lt;/p&gt;

	&lt;?php else : ?&gt;

		&lt;p&gt;Comments are closed, and there are no comments.&lt;/p&gt;

	&lt;?php endif; ?&gt;

&lt;?php endif; ?&gt;</code></pre>
										<p>As you can see, we are now using the <code>wp_list_comments()</code> function as the method by which our individual comments are displayed. This function wraps each comment with a set of <code>&lt;li&gt;</code> elements, but this may be changed via customized parameters. We are also using the <code>next/previous_comments_link()</code> functions to accommodate the new built-in paged comments feature.</p>
										<p>Source: <a href="http://digwp.com/">Digging into WordPress</a></p>
										<h3>Backwards-Compatible Comment Templates <a id="swt_16" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>The easiest way to accommodate for both old (pre-2.7) and new (2.7+) WordPress comment loops is to create two different versions of the comments template and then use some conditional logic to process the correct file. Place the 2.7-compatible code from the previous section into your default <code>comments.php</code> file, and then place your existing (pre-2.7) comments code into a file called <code>legacy-comments.php</code>. Once you have both of these files setup and included among your theme files, place the following function in your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>&lt;?php add_filter('comments_template', 'legacy_comments');

function legacy_comments($file) {
	if(!function_exists('wp_list_comments')) : // WP 2.7-only check
		$file = TEMPLATEPATH.'/legacy-comments.php';
	endif;
	return $file;
} ?&gt;</code></pre>
										<p>This code will then check for the presence of the new <code>wp_list_comments()</code> function. If it exists, then the version of WordPress is at least 2.7, and the default <code>comments.php</code> file will be used. If the new function doesn&rsquo;t exist, we have a dinosaur on our hands and so the legacy comments file will be used instead.</p>
										<p>Source: <a href="http://justintadlock.com/archives/2008/11/01/making-your-themes-comments-compatible-with-wordpress-27-and-earlier-versions">Justin Tadlock</a></p>
										<h3>Disable WordPress Post Revisions <a id="swt_17" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>One of the new features rolled out in WordPress 2.6 involved post revisions. Revisions are a way for users to keep a working collection of each different version of a post and then revert back to it in the future if necessary. Some people think this is the greatest thing since lightsabers, others (such as myself) find it to be a royal pain in the database. It convolutes the Admin area, gobbles up disk space, and usually doesn&rsquo;t work as intended. Fortunately, we can disable this amazing new &ldquo;feature&rdquo; (which should NOT have been included in the core) by adding the following line to the <code>wp-config.php</code> file:</p>
										<pre><code>/* disable post-revisioning nonsense */ 
define('WP_POST_REVISIONS', FALSE);</code></pre>
										<p>Just place that line above the &ldquo;Happy&nbsp;blogging&rdquo; comment and say goodbye to needless revisioning bloat.</p>
										<p>Source: <a href="http://digwp.com/2009/07/mastering-wordpress-post-revisioning-and-auto-save-features/">Digging into WordPress</a></p>
										<h3>Limit WordPress Post Revisions <a id="swt_18" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>If you like the idea of WordPress-2.6&rsquo;s new post-revisioning feature, but don&rsquo;t want thousands of extra records bloating up your database, here is an easy way to limit the total number of revisions that WordPress is allowed to keep. This code will instruct WordPress to keep only the most recent &ldquo;x&rdquo; number of revisions:</p>
										<pre><code>/* limit number of post revisions */ 
define('WP_POST_REVISIONS', 3);</code></pre>
										<p>Place that line above the &ldquo;Happy&nbsp;blogging&rdquo; comment in the <code>wp-config.php</code> file and enjoy conserved disk space and less Admin clutter. Change the number &ldquo;<code>3</code>&rdquo; to any number you wish. Works a treat.</p>
										<p>Source: <a href="http://digwp.com/2009/07/mastering-wordpress-post-revisioning-and-auto-save-features/">Digging into WordPress</a></p>
										<h3>Remove WordPress Post Revisions from the Database <a id="swt_19" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>In line with the previous two sections, here we will remove all existing post revisions from the WordPress database. This is useful if you have disabled the post-revisioning feature or perhaps even reduced the total number of allowed revisions. The easiest way to do this is to run the following <acronym title="Structured Query Language">SQL</acronym> command via your favorite database interface (such as my personal favorite, phpMyAdmin):</p>
										<pre><code>DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision';</code></pre>
										<p>Note that if you have changed the default WordPress database table prefix to something other than &ldquo;<code>wp_</code>&rdquo;, you will want to edit the command to reflect the correct prefix information. This information is available in your site&rsquo;s <code>wp-config.php</code> file. Also note that you should backup your database before casting any <acronym title="Structured Query Language">SQL</acronym> spells on it.</p>
										<p>Upon successful execution of the above command, all data associated with post revisions will be removed the database. This includes the post revisions themselves and all the meta data associated with each revision.</p>
										<p>Credit: <a href="hhttp://andreineculau.com/blog/2008/07/delete-wordpress-26-revisions/">Andrei Neculau</a></p>
										<h3>Reduce Comment Spam by Blocking No-Referrer Requests <a id="swt_20" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>As explained in my article, <a href="http://perishablepress.com/press/2006/11/20/block-spam-by-denying-access-to-no-referrer-requests/">denying access to no-referrer requests</a>, you can greatly reduce the number of spam comments by eliminating all direct requests for your blog&rsquo;s <code>comments-post.php</code> file. This will block automated spam scripts from bypassing your comments form by hitting the comment processing script directly. Here are two ways to block no-referrer comment requests, one uses <acronym title="Hypertext Access">HTAccess</acronym> and the other uses <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>. Here is the <acronym title="Hypertext Access">HTAccess</acronym> method:</p>
										<pre><code>RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post.php
RewriteCond %{HTTP_REFERER} !domain.tld [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://%{REMOTE_ADDR}/$ [R=301,L]</code></pre>
										<p>Place that code in your site&rsquo;s root <acronym title="Hypertext Access">HTAccess</acronym> file and edit the &ldquo;<code>domain.tld</code>&rdquo; to match your own domain. Once in place, this code will redirect any request for your blog&rsquo;s <code>comments-post.php</code> file that didn&rsquo;t originate from your site back to the <acronym title="Uniform Resource Locator">URL</acronym> from whence it came.</p>
										<p>This may also be accomplished via <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>. Place the following function in your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>function check_referrer() {
	if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == '') {
		wp_die(__('Please do not access this file directly.'));
	}
}
add_action('check_comment_flood', 'check_referrer');</code></pre>
										<p>Source: <a href="http://perishablepress.com/press/2006/11/20/block-spam-by-denying-access-to-no-referrer-requests/">Perishable Press</a></p>
										<h3>Prevent Google Analytics from Tracking Admin Pages <a id="swt_21" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>This handy snippet will prevent Google Analytics from tracking your Admin pages or anything else that you wish. Replace your default Google Analytics code with the following:</p>
										<pre><code>&lt;?php if (!current_user_can('level_10')) { ?&gt;

	/* Google Analytics Code */

&lt;?php } ?&gt;</code></pre>
										<p>This code will then include your Google Analytics code only on non-Admin pages. This in turn will prevent Google Analytics from gathering statistics about your Admin pages. Note that the basic functionality of this method is great for restricting just about anything &#8212; scripts, markup, content &#8212; to logged-in administrators. </p>
										<h3>Meta Descriptions without a Plugin <a id="swt_22" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>We don&rsquo;t need no stinkin&rsquo; plugin for custom meta descriptions. All you need is a custom field named &ldquo;<code>metadescription</code>&rdquo; with the desired meta description for each post. Once you have that going, include the following function to your theme&rsquo;s <code>header.php</code> file (within the <code>&lt;head&gt;</code> section:</p>
										<pre><code>&lt;meta name="description" content="
&lt;?php if ((is_home()) || (is_front_page())) {
	echo ('Your main description goes here');
} elseif(is_category()) {
	echo category_description();
} elseif(is_tag()) {
	echo 'Tag archive page for this blog - ' . single_tag_title();
} elseif(is_month()) {
	echo 'Archive page for this blog - ' . the_time('F, Y');
} else {
	echo get_post_meta($post-&gt;ID, 'metadescription', true);
} ?&gt;" /&gt;</code></pre>
										<p>This function enables you to customize the descriptions for various types of pages, such as the home page, category pages, tag archives, and so on. For single post-view pages, this function will display the value of the <code>metadescription</code> custom field.</p>
										<p>Source: <a href="http://www.malcolmcoles.co.uk/blog/unique-meta-description-and-meta-keywords-in-your-wordpress-themes/">Malcolm Coles</a></p>
										<h3>Differentiate Between Posts Depending on Presence of Excerpt <a id="swt_23" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is a quick conditional snippet that displays different content depending on the presence of an excerpt:</p>
										<pre><code>&lt;?php if(!empty($post-&gt;post_excerpt)) {

	// this post has an excerpt, so display it:
	the_excerpt();

} else {

	// this post has no excerpt, so display something else instead:
	the_content();

} ?&gt;</code></pre>
										<p>Placed inside the loop, this code will check each post for an excerpt. If one is found, the excerpt is displayed; otherwise, the code specified in the <code>else</code> condition is displayed.</p>
										<h3>Modify the wp_options Table via the WordPress Admin <a id="swt_24" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>As you probably know, the <code>wp_options</code> table stores a great deal of useful information, including everything from custom-field values, plugin settings, blog information, and much more. If any table in the WordPress database needs its own friendly user-interface, this would be it. </p>
										<p>Normally, you would access the <code>wp_options</code> table using a database interface such as phpMyAdmin. This certainly works, but there is a much easier way to work with the options table, especially if you are already logged into WordPress. Once logged in to the Admin area, navigate to the following <acronym title="Uniform Resource Locator">URL</acronym>:</p>
										<pre><code>http://domain.tld/wp-admin/options.php</code></pre>
										<p>This will open a &ldquo;secret&rdquo; Admin page that provides editable options fields for every record in the <code>wp_options</code> table. Bookmark this page, and save yourself a trip to phpMyAdmin!</p>
										<p>Source: <a href="http://digwp.com/2009/06/edit-your-database-options-from-the-wordpress-admin/">Digging into WordPress</a></p>
										<h3>Alternate Comment Styles <a id="swt_25" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p><strong>Alternating comments for old versions of WordPress (pre-2.7)</strong><br />This is one of the oldest tricks in the book, but it is still a favorite. Alternating comment styles is a great way to enhance usability and add some stylistic flair to your comments display. The trick is to add an alternating set of classes &#8212; odd or even &#8212; to the containing element of each comment. While there are many ways to do this, here is one of the <em>easiest</em>. Open your <code>comments.php</code> and modify the comments loop as follows:</p>
										<pre><code>&lt;ul&gt;
	&lt;?php $i = 0; ?&gt;
	&lt;?php foreach ($comments as $comment) : ?&gt;
	&lt;?php $i++; ?&gt;

	&lt;li id="comment-&lt;?php comment_ID(); ?&gt;" &lt;?php if($i&amp;1) { echo 'class="odd"'; } else { echo 'class="even"'; } ?&gt;&gt;
		&lt;?php comment_text(); ?&gt;
	&lt;/li&gt;
	&lt;php endforeach; ?&gt;
&lt;/ul&gt;</code></pre>
										<p>With that code in place, your comments will now have alternating <acronym title="Cascading Style Sheets">CSS</acronym> classes with which to apply custom styles to your oddly and evenly numbered comments:</p>
										<pre><code>.odd {
	background: white;
	color: black;
	}
.even {
	background: black;
	color: white;
	}</code></pre>
										<p><strong>Alternating comments for old versions of WordPress (pre-2.7)</strong><br />In WordPress 2.7 and better, comments automagically include &ldquo;<code>odd</code>&rdquo; and &ldquo;<code>even</code>&rdquo; classes for oddly and evenly numbered comments, respectively. This makes it a snap to throw down your own custom CSS styles for each of these classes.</p>
										<p>Credit: <a href="http://wordpressgarage.com/code-snippets/using-php-to-alternate-background-colors-for-comments-or-posts-in-wordpress/">WordPress Garage</a></p>
										<h3>Automatically Remove Code Mistakes in Posts <a id="swt_26" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is a handy trick that will automatically remove basic mistakes in <acronym title="eXtensible Hypertext Markup">XHTML</acronym> markup, such as empty paragraphs, inline font styles, and more. Place this function in your <code>functions.php</code> file:</p>
										<pre><code>function clean_bad_content($bPrint = false) {
	global $post;
	$szPostContent  = $post-&gt;post_content;
	$szRemoveFilter = array("~&lt;p[^&gt;]*&gt;\s?&lt;/p&gt;~", "~&lt;a[^&gt;]*&gt;\s?&lt;/a&gt;~", "~&lt;font[^&gt;]*&gt;~", "~&lt;\/font&gt;~", "~style\=\"[^\"]*\"~", "~&lt;span[^&gt;]*&gt;\s?&lt;/span&gt;~");
	$szPostContent  = preg_replace($szRemoveFilter, '', $szPostContent);
	$szPostContent  = apply_filters('the_content', $szPostContent);
	if ($bPrint == false) return $szPostContent; 
	else echo $szPostContent;
}</code></pre>
										<p>Once in place, use the following function call to display your &ldquo;cleaned&rdquo; content in the loop:</p>
										<pre><code>&lt;?php if (function_exists('clean_bad_content')) clean_bad_content(true); ?&gt;</code></pre>
										<p>Note that the <code>clean_bad_content()</code> accepts a boolean argument (<code>true</code> or <code>false</code>) specifying whether or not to print the function output.</p>
										<p>Credit: <a href="http://www.mattvarone.com/wordpress/useful-functions-for-wordpress/">Matt Varone</a></p>
										<h3>Automatically Disable Comments and Trackbacks in Old Posts <a id="swt_27" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is yet another <a href="http://perishablepress.com/press/2008/07/08/wordpress-tip-disable-comments-in-old-posts-via-php/" title="WordPress Tip: Disable Comments in Old Posts via PHP">method for auto-disabling comments and trackbacks</a> on old posts. This function automatically closes comments and trackbacks after the specified number of days. Add the following to your <code>functions.php</code> file:</p>
										<pre><code>&lt;?php function autoclose_comments() {
	global $wpdb, $tableposts;

	if (!isset($tableposts))
		$tableposts = $wpdb-&gt;posts;

		$age = '21 DAY';
 
		$date = $wpdb-&gt;get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL $age), INTERVAL 1 DAY)");
		$wpdb-&gt;query("UPDATE $tableposts SET comment_status = 'closed' WHERE comment_status = 'open' AND post_status = 'publish' AND post_date &lt; '$date'");
}

function autoclose_trackback() {
	global $wpdb, $tableposts;

	if (!isset($tableposts))
		$tableposts = $wpdb-&gt;posts;

		$age = '21 DAY';
 
		$date = $wpdb-&gt;get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL $age), INTERVAL 1 DAY)");
 		$wpdb-&gt;query("UPDATE $tableposts SET ping_status = 'closed' WHERE comment_status = 'open' AND post_status = 'publish' AND post_date &lt; '$date'");
}

add_action('publish_post',   'autoclose_trackback', 7);
add_action('edit_post',      'autoclose_trackback', 7);
add_action('delete_post',    'autoclose_trackback', 7);
add_action('comment_post',   'autoclose_trackback', 7);
add_action('trackback_post', 'autoclose_trackback', 7);
add_action('pingback_post',  'autoclose_trackback', 7);
add_action('edit_comment',   'autoclose_trackback', 7);
add_action('delete_comment', 'autoclose_trackback', 7);
add_action('template_save',  'autoclose_trackback', 7);
 
add_action('publish_post',   'autoclose_comments', 7);
add_action('edit_post',      'autoclose_comments', 7);
add_action('delete_post',    'autoclose_comments', 7);
add_action('comment_post',   'autoclose_comments', 7);
add_action('trackback_post', 'autoclose_comments', 7);
add_action('pingback_post',  'autoclose_comments', 7);
add_action('edit_comment',   'autoclose_comments', 7);
add_action('delete_comment', 'autoclose_comments', 7);
add_action('template_save',  'autoclose_comments', 7);
?&gt;</code></pre>
										<p>Once in place, you may change the number of days allowed for comments and trackbacks to stay open by editing the two instances of the <code>$age</code> variable to whatever you wish. No other editing or code is required for this function to operate effectively. The function is executed automatically upon various posting actions. Note that this function is included in newer versions of WordPress (2.7 or better), and is therefore only required for older versions.</p>
										<p>Source: <a href="http://wpengineer.com/auto-shutoff-comments-and-trackbacks/" title="WP Engineer">WP Engineer</a><br />Plugin: <a href="http://ajaydsouza.com/wordpress/plugins/autoclose/" title="Autoclose Plugin">Autoclose</a></p>
										<h3>Access Post Data Outside the Loop <a id="swt_28" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>The easiest way to access and display post data outside of the loop is to use the built-in WordPress core function <a href="http://codex.wordpress.org/Function_Reference/get_post" title="WordPress Codex: get_post()">get_post()</a>; however, for more control over the process, check out this nifty little function from <a href="http://www.wprecipes.com/rebellion-asked-how-can-i-access-post-data-outside-the-loop">WP Recipes</a>:</p>
										<pre><code>function get_post_data($postId) {
	global $wpdb;
	return $wpdb-&gt;get_row("SELECT * FROM $wpdb-&gt;posts WHERE ID=$postId");
}</code></pre>
										<p>Place this function in your <code>functions.php</code> and then add this code to the desired location outside of the loop:</p>
										<pre><code>&lt;?php $data = get_post_data(77);
	echo $data-&gt;post_date;     // post date
	echo $data-&gt;post_title;    // post title
	echo $data-&gt;post_content;  // post content
	echo $data-&gt;comment_count; // comments number
?&gt;</code></pre>
										<p>For the argument of the function, specify the post ID for which you would like to display data. The function will return an array containing all of the available fields for the specified post (<code>post_title</code>, <code>date</code>, <code>content</code>, <code>author_id</code>, <code>post_id</code>, etc).</p>
										<h3>Display Posts for a Specified Time Period <a id="swt_29" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is an easy way to create posts that will only be displayed for the duration of a specified time period. Replace your current loop with the following:</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
	$expirationtime = get_post_custom_values('expiration');
	if (is_array($expirationtime)) {
		$expirestring = implode($expirationtime);
	}
	$secondsbetween = strtotime($expirestring)-time();
	if ($secondsbetween &gt; 0) { ?&gt;

		&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
		&lt;?php the_excerpt(); ?&gt;

&lt;?php } endwhile; endif; ?&gt;</code></pre>
										<p>And then add a custom field named &ldquo;<code>expiration</code>&rdquo; to any post that needs an expiration date. For the value of the <code>expiration</code> key, specify the date/time in the following format: <code>mm/dd/yyyy</code>&nbsp;<code>00:00:00</code>. Each post that contains such a custom field will expire after the specified date and time and will no longer appear in the loop.</p>
										<h3>Unique Single Post Templates for Different Categories <a id="swt_30" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is an easy way to display custom post styles depending on the post&rsquo;s category. With the following code, each single-view post will be displayed according to a template that is specific to the post&rsquo;s category:</p>
										<pre><code>&lt;?php $post = $wp_query-&gt;post;
if (in_category('1')) {
	include(TEMPLATEPATH.'/single-01.php');
} elseif (in_category('2')) {
	include(TEMPLATEPATH.'/single-02.php');
} else {
	include(TEMPLATEPATH.'/single-default.php');
} ?&gt;</code></pre>
										<p>This code should be placed in your theme&rsquo;s <code>single.php</code> file. As written, this code will display posts from the first category with the single template, &ldquo;<code>single-01.php</code>&rdquo;; also, posts from the second category will be displayed with a single template named &ldquo;<code>single-02.php</code>&rdquo;; finally, all other posts will be displayed via the default single template, &ldquo;<code>single-default.php</code>&rdquo;. Of course, you will want to customize the category IDs according to your own needs, and also you will want to create the customized single files as they are called. That&rsquo;s all there is to it.</p>
										<p>Having said that, here is an alternate version of the custom-post-template script:</p>
										<pre><code>&lt;?php add_filter('single_template', create_function('$t', 'foreach((array) get_the_category() as $cat) { if (file_exists(TEMPLATEPATH . "/single-{$cat-&gt;term_id}.php")) return TEMPLATEPATH . "/single-{$cat-&gt;term_id}.php"; } return $t;')); ?&gt;</code></pre>
										<p>Placed in your theme&rsquo;s <code>functions.php</code> file, this alternate script checks all categories for the presence of a custom single template. Any category with a custom single-post template will then have its posts displayed with that template. If a post&rsquo;s category does not feature a custom template, the default <code>single.php</code> template will be used. Note that this code will use the template for the <em>first</em> listed category of each post. Even so, you should only create custom post templates for categories that will always be mutually exclusive. That is, make sure that your posts aren&rsquo;t in more than one custom-templated category. </p>
										<p>Source: <a href="http://www.ilfilosofo.com/">Austin Matzko</a></p>
										<h3>Display Performance Statistics for WordPress Pages <a id="swt_31" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Everyone is familair with the following information:</p>
										<pre><code>&lt;!-- 33 queries in 0.333 seconds --&gt;</code></pre>
										<p>These statistics are usually seen in the footer area of individual pages and serve as a general indicator of performance. The &ldquo;queries&rdquo; refer to the number of times WordPress requested information from the database, while the number of seconds indicates the amount of time required for Apache to generate the page. This information is generated by including the following code in your footer template file (or wherever you would like):</p>
										<pre><code>&lt;!-- &lt;?php echo get_num_queries(); ?&gt; queries in &lt;?php timer_stop(3); ?&gt; seconds --&gt;</code></pre>
										<p>Or, if you don&rsquo;t like the idea of sharing this information with the entire world, you can limit its display to logged-in administrators only:</p>
										<pre><code>&lt;?php if (current_user_can('level_10')) {

	echo '&lt;!-- ' . get_num_queries() . ' queries in ' . timer_stop(3) . ' seconds --&gt;';

} ?&gt;</code></pre>
										<p>Easy breezy beautiful!</p>
										<p>Source: <a href="http://digwp.com/2009/08/show-off-your-wordpress-database-statistics/">Digging into WordPress</a></p>
										<h3>Custom Post Thumbnails in Two Steps <a id="swt_32" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Alright, kids. Time for the &lsquo;ol three-step custom-field tutorial. This time we&rsquo;re going to implement post thumbnails. You know, representative images for each of your posts that may be displayed anywhere you wish, including outside of the flow of post content, and even outside of the loop. This is a great trick for advanced page layouts. Ready? Sharpen your keystrokes!</p>
										<p><strong>Step 1:</strong><br />Open your write panel and create a key called &ldquo;thumbnail&rdquo;. Then, for the value of the &ldquo;thumbnail&rdquo; key, enter the <acronym title="Uniform Resource Locator">URL</acronym> of the thumbnail image for that particular post. Write the post and then publish it as normal. Wash, rinse, repeat to get a nice collection of posts with thumbnails. Or, go back to exisiting posts and add a thumbnail as we have just described.</p>
										<p><strong>Step 2:</strong><br />Open your theme template file containing the loop and add the following code to the location where you would like the post thumbnail images to appear:</p>
										<pre><code>&lt;?php $thumbnail = get_post_meta($post-&gt;ID, 'image', true); if ($thumbnail) { ?&gt;

&lt;img src="&lt;?php echo $thumbnail; ?&gt;" alt="" width="100" height="100" /&gt;

&lt;?php } ?&gt;</code></pre>
										<p>That&rsquo;s it! Don&rsquo;t forget to edit the <code>width</code> and <code>height</code> attributes of the <code>&lt;img&gt;</code> element to account for the proper image size.</p>
										<p>Source: <a href="http://perishablepress.com/press/2008/12/17/wordpress-custom-fields-tutorial/">Perishable Press</a></p>
										<h3>Highlight Author Comments <a id="swt_33" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Make your author comments look fabulous darling! Newer versions of WordPress come equipped with a specific &ldquo;<code>author</code>&rdquo; class that may be targeted with the <acronym title="Cascading Style Sheets">CSS</acronym> of your choice. For older versions of WordPress, however, you will need to add the custom class attribute with a little <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> magic.</p>
										<p>First, open your theme&rsquo;s <code>comments.php</code> template and add the following code snippet in the <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> element that contains the comment information:</p>
										<pre><code>&lt;div&lt;?php if ($comment-&gt;comment_author_email == "email@domain.tld") echo ' class="author"'; ?&gt; id="comment-&lt;?php comment_ID(); ?&gt;"&gt;
.
.
.
&lt;/div&gt;</code></pre>
										<p>After changing the email address to that of your own (i.e., the one used for your <acronym title="WordPress">WP</acronym> Admin user profile), style it up with a little <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>.author {
	background: red !important;
	color: yellow   !important;
	}</code></pre>
										<p>You probably don&rsquo;t want your author comments to appear with yellow text on a red background, but you get the idea. Anything is possible.</p>
										<p>For blogs with multiple authors, you can style each of their comments differently as well by using something like this:</p>
										<pre><code>&lt;div&lt;?php if ($comment-&gt;comment_author_email == "email-01@domain.tld") echo ' class="author-01"'; elseif ($comment-&gt;comment_author_email == "email-02@domain.tld") echo ' class="author-02"'; elseif ($comment-&gt;comment_author_email == "email-03@domain.tld") echo ' class="author-03"'; ?&gt; id="comment-&lt;?php comment_ID(); ?&gt;"&gt;
.
.
.
&lt;/div&gt;</code></pre>
										<p>Replace each of the email addresses with those of the various authors. Style to taste.</p>
										<p>Credit: <a href="http://www.nyssajbrown.net/2007/06/19/wordpress-tips-tricks-author-comment-highlighting/">Nyssa Brown</a></p>
										<h3>Easy Random Posts <a id="swt_34" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Newer versions of WordPress enable easy randomizing of posts by using the (relatively) new &ldquo;<code>orderby=rand</code>&rdquo; parameter in any <code>query_posts</code> loop:</p>
										<p><code>&lt;?php query_posts('orderby=rand"); ?&gt;</code></p>
										<p>But for older versions of WordPress, this randomizing functionality must be added manually. Here is a quick and painless plugin that will enable you to randomize post queries in older versions:</p>
										<pre><code>&lt;?php
/*

Plugin Name: Random Posts Query

*/

function query_random_posts($query) {
	return query_posts($query . '&amp;random=true');
}
class RandomPosts {
	function orderby($orderby) {
		if (get_query_var('random') == 'true')
			return "RAND()";
		else
			return $orderby;
	}
	function register_query_var($vars) {
		$vars[] = 'random';
		return $vars;
	}
}
add_filter( 'posts_orderby', array('RandomPosts', 'orderby') );
add_filter( 'query_vars', array('RandomPosts', 'register_query_var') );
?&gt;</code></pre>
										<p>Once activated, invoke the randomness by adding the &ldquo;<code>random=true</code>&rdquo; parameter in your <code>query_posts</code> loop:</p>
										<pre><code>&lt;?php query_posts('cat=11&amp;showposts=11&amp;random=true'); ?&gt;</code></pre>
										<p>Here, we are specifying &ldquo;<code>cat=11</code>&rdquo; for the category and &ldquo;<code>showposts=11</code>&rdquo; for the number of posts to display. There are many other parameters available as well, so knock yourself out.</p>
										<p>Credit: <a href="http://wordpress.org/support/topic/70359#post-444323" title="Via the WordPress Codex">rembem</a></p>
										<h3>Display Dates for Groups of Posts <a id="swt_35" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>In order to display the date that a post was published, you have two options:</p>
										<ul>
										<li><code>&lt;?php the_time(); ?&gt;</code> &#8212; displays the date for each and every post</li>
										<li><code>&lt;?php the_date(); ?&gt;</code> &#8212; displays the date only once for each group of posts published on a certain day</li>
										</ul>
										<p>So, if you want to list the post date next to each post, use the <code>the_time()</code>. If, on the other hand, you have multiple posts on any given day, use <code>the_date()</code> to list the post date only once for each days&rsquo; posts. Something like this:</p>
										<pre><code>// the_time();

	Jan 01, 2009 - Post #1
	Jan 01, 2009 - Post #2
	Jan 01, 2009 - Post #3

	Jan 02, 2009 - Post #4
	Jan 02, 2009 - Post #5
	Jan 02, 2009 - Post #6

	Jan 03, 2009 - Post #7
	Jan 03, 2009 - Post #8
	Jan 03, 2009 - Post #9

// the_date();

	Jan 01, 2009
		Post #1
		Post #2
		Post #3

	Jan 02, 2009
		Post #4
		Post #5
		Post #6

	Jan 03, 2009
		Post #7
		Post #8
		Post #9</code></pre>
										<p>See the difference? Good, because I&rsquo;m not going to explain the concept any further. Instead, I will move on by showing you how to use either template tag in your loop. This really doesn&rsquo;t need explaining either, but for the sake of completeness, here it is. First, <code>the_time()</code> tag:</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

	&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
	&lt;p&gt;&lt;?php the_time(); ?&gt;&lt;p&gt;
	&lt;?php the_content(); ?&gt;

&lt;?php endwhile; ?&gt;
&lt;?php else : ?&gt;
&lt;?php endif; ?&gt;</code></pre>
										<p>This loop will output the post title, date, and content for <em>every</em> post. Alternately, here is how to use <code>the_date</code> tag:</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

	&lt;?php the_date('','&lt;p&gt;','&lt;/p&gt;&lt;hr /&gt;'); ?&gt;
	&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
	&lt;?php the_content(); ?&gt;
 
&lt;?php endwhile; ?&gt;
&lt;?php else : ?&gt;
&lt;?php endif; ?&gt;</code></pre>
										<p>This loop will output the post title and content for every post, and also output the date for each group of posts published on any given day, as explained above. Notice we are adding the paragraph elements for the post date based on whether or not the date is actually output. If it is, then the date will be wrapped in <code>&lt;p&gt;</code> elements; if it&rsquo;s not, no <code>&lt;p&gt;</code> elements will be output, thereby preventing repetitive sets of empty paragraph elements. Make sense? Good. Here are the available parameters for the nifty <code>the_date()</code> template tag:</p>
										<p><code>&lt;?php the_date('date format', 'before the date', 'after the date'); ?&gt;</code></p>
										<p>Source: <a href="http://www.devlounge.net/code/wordpress-tip-group-posts-by-date-in-listings">Devlounge</a></p>
										<h3>Display a Sticky Post in the Sidebar <a id="swt_36" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is a juicy little nugget that displays a &ldquo;sticky&rdquo; post in the sidebar of your theme:</p>
										<pre><code>&lt;?php 
// initialize new query of one post from category 11
$my_query = new WP_Query('cat=11&amp;showposts=1');

// loop through the database to find related information
while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post();

// set expiration time of two days
$goAwayDate = time() - (60 * 60 * 24 * 2);

// get date of sticky post
$postDate = get_the_time('U');

// if post is too old, do nothing
if ($postDate &lt; $goAwayDate) {

// else show the post
} else { ?&gt;

	&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
	&lt;?php the_excerpt(); ?&gt;

&lt;?php } endwhile; ?&gt;</code></pre>
										<p>This method employs a second loop to display the sticky post, so it may be placed just about anywhere in your theme&rsquo;s template files. You can also change the number of days that the post will remain sticky by editing the expiration variable with a number other than <code>"2"</code>. For example, to set a duration period of seven days, you would use this:</p>
										<p><code>$goAwayDate = time() - (60 * 60 * 24 * 7);</code></p>
										<p>Credit: <a href="http://theclosetentrepreneur.com/excluding-posts-and-category-specific-pages-in-wordpress">The Closet Entrepreneur</a></p>
										<h3>Display Latest Comments without a Plugin <a id="swt_37" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Good rule of thumb when working with WordPress: don&rsquo;t use a plugin if you can acheive the same functionality without one. Case in point: displaying latest comments on your blog. Sure, you could always install a plugin to do it for you, but you really don&rsquo;t need to. In fact, it&rsquo;s actually easier to display recent comments <em>without</em> a plugin. SImply add the following code to the desired location within your theme&rsquo;s template files:</p>
										<pre><code>&lt;?php global $wpdb;

$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, 
comment_post_ID, comment_author, comment_date_gmt, comment_approved, 
comment_type,comment_author_url, 
SUBSTRING(comment_content,1,50) // NUMBER OF CHARACTERS
AS com_excerpt FROM $wpdb-&gt;comments 
LEFT OUTER JOIN $wpdb-&gt;posts 
ON ($wpdb-&gt;comments.comment_post_ID = $wpdb-&gt;posts.ID) 
WHERE comment_approved = '1' 
AND comment_type = '' 
AND post_password = '' 
ORDER BY comment_date_gmt 
DESC LIMIT 5"; // NUMBER OF COMMENTS

$comments = $wpdb-&gt;get_results($sql);
$output   = $pre_HTML;
$output  .= "\n&lt;ul&gt;";

foreach ($comments as $comment) {
	$output .= "\n&lt;li&gt;"."&lt;a href=\"" . get_permalink($comment-&gt;ID) . 
	"#comment-" . $comment-&gt;comment_ID . "\" title=\"on " . 
	$comment-&gt;post_title . "\"&gt;" .strip_tags($comment-&gt;comment_author) 
	.":&lt;br/&gt;&lt;div&gt;" . strip_tags($comment-&gt;com_excerpt) 
	."&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;";
}
$output .= "\n&lt;/ul&gt;";
$output .= $post_HTML;

echo $output;
?&gt;</code></pre>
										<p>This code will display the 5 most recent comments in the following <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> output format:</p>
										<pre><code>&lt;ul&gt;
	&lt;li&gt;
		&lt;a href="http://domain.tld/post#comment-01" title="on Post Title"&gt;Comment Author:&lt;br /&gt;
		&lt;div&gt;This is the first 50 characters of the first most recent comment&lt;/div&gt;&lt;/a&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;a href="http://domain.tld/post#comment-01" title="on Post Title"&gt;Comment Author:&lt;br /&gt;
		&lt;div&gt;This is the first 50 characters of the first most recent comment&lt;/div&gt;&lt;/a&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;a href="http://domain.tld/post#comment-01" title="on Post Title"&gt;Comment Author:&lt;br /&gt;
		&lt;div&gt;This is the first 50 characters of the first most recent comment&lt;/div&gt;&lt;/a&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;a href="http://domain.tld/post#comment-01" title="on Post Title"&gt;Comment Author:&lt;br /&gt;
		&lt;div&gt;This is the first 50 characters of the first most recent comment&lt;/div&gt;&lt;/a&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;a href="http://domain.tld/post#comment-01" title="on Post Title"&gt;Comment Author:&lt;br /&gt;
		&lt;div&gt;This is the first 50 characters of the first most recent comment&lt;/div&gt;&lt;/a&gt;
	&lt;/li&gt;
&lt;/ul&gt;</code></pre>
										<p>By editing the commented lines in the <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> script, you may specify alternate number of comments and characters.</p>
										<p>Source: <a href="http://stylizedweb.com/2008/06/20/grab-data-from-wordpress-database/">StylizedWeb</a></p>
										<h3>Display Most Commented Posts without a Plugin <a id="swt_38" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is another trick that will enable you avoid yet another needless plugin. This code results in the display of your most-commented posts in list format:</p>
										<pre><code>&lt;ul&gt;
&lt;?php 
$result = $wpdb-&gt;get_results("SELECT comment_count, ID, post_title FROM $wpdb-&gt;posts ORDER BY comment_count DESC LIMIT 0 , 10"); // NUMBER OF POSTS
foreach ($result as $topten) {
	$postid = $topten-&gt;ID;
	$title = $topten-&gt;post_title;
	$commentcount = $topten-&gt;comment_count;
	if ($commentcount != 0) {
?&gt;

&lt;li&gt;&lt;a href="&lt;?php echo get_permalink($postid); ?&gt;"&gt;&lt;?php echo $title ?&gt;&lt;/a&gt;&lt;/li&gt;

&lt;?php } } ?&gt;
&lt;/ul&gt;</code></pre>
										<p>This code may be modified to display any number of posts by changing the <code>LIMIT</code> from &ldquo;<code>10</code>&rdquo; to whatever you wish. You may also change the display order from <code>DESC</code> (descending order) to <code>ASC</code> (ascending order).</p>
										<p>Once in place, this code will display a list of the 10 most-commented posts in the following <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> output format:</p>
										<pre><code>&lt;ul&gt;
&lt;li&gt;&lt;a href="http://domain.tld/post-01/"&gt;Post Title 01&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://domain.tld/post-02/"&gt;Post Title 02&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://domain.tld/post-03/"&gt;Post Title 03&lt;/a&gt;&lt;/li&gt;
.
.
.
&lt;/ul&gt;</code></pre>
										<p>Source: <a href="http://stylizedweb.com/2008/06/20/grab-data-from-wordpress-database/">StylizedWeb</a></p>
										<h3>Change Permalinks from Date-Based to Post-Date Only <a id="swt_39" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is an <acronym title="Hypertext Access">HTAccess</acronym> method for switching your permalinks from the lengthy date-based format (i.e., <code>http://domain.tld/2009/03/03/post-name/</code>) to the concise post-name format (i.e., <code>http://domain.tld/post-name/</code>).</p>
										<p>To do so, first login to the WordPress Admin and switch your permalink structure from this:</p>
										<pre><code>/%year%/%monthnum%/%day%/%postname%/</code></pre>
										<p>..to this:</p>
										<pre><code>/%postname%/</code></pre>
										<p>This change will ensure that all <em>future</em> posts are located at the new post-name-only <acronym title="Uniform Resource Locator">URL</acronym>, but we still need to redirect all requests for <em>existing</em> posts via the old date-based <acronym title="Uniform Resource Locator">URL</acronym> format. This is easily accomplished with a single directive in your site&rsquo;s root <acronym title="Hypertext Access">HTAccess</acronym> file:</p>
										<pre><code>RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ http://domain.tld/$4</code></pre>
										<p>And that&rsquo;s all there is to it! Remember to test vigorously to convince yourself that everything is working properly.</p>
										<p>Source: <a href="http://perishablepress.com/press/2008/02/06/permalink-evolution-customize-and-optimize-your-dated-wordpress-permalinks/">Perishable Press</a></p>
										<h3>Test for Sub-Pages <a id="swt_40" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Until WordPress includes an <code>is_subpage()</code> function, here is a manual method of testing for sub-pages: </p>
										<pre><code>&lt;?php global $post;

if ( is_page() &amp;&amp; $post-&gt;post_parent ) {

    // subpage content goes here

} else {

    // non-subpage content goes here

} ?&gt;</code></pre>
										<p>Further, here are some other ways to use this method to test for different combinations of pages and sub-pages:</p>
										<pre><code>&lt;?php if (is_page('about') || $post-&gt;post_parent == '1') {

	$banner = 'business.png';

} elseif (is_page('archives') || $post-&gt;post_parent == '2') {	

	$banner = 'pleasure.png';

} elseif (is_page('contact') || $post-&gt;post_parent == '3') {

	$banner = 'personal.png';

} else { 

	$banner = 'default.png';

} ?&gt;</code></pre>
										<p>Note that the numbers &ldquo;<code>1</code>&rdquo;, &ldquo;<code>2</code>&rdquo;, and &ldquo;<code>3</code>&rdquo; represent the <acronym title="Identification">ID</acronym>s of the target parent pages.</p>
										<h3>Multiple Widgetizable Sidebars <a id="swt_41" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Instead of using multiple &ldquo;<code>if</code>&rdquo; statements to include multiple widgetizable areas, WPEngineer shows us how to do it a better way:</p>
										<pre><code>&lt;?php // multiple widgetizable sidebars
if (function_exists('register_sidebar')) {
	$sidebars = array('Home Sidebar', 'Post Sidebar', 'Page Sidebar');
	foreach($sidebars as $name) {
		register_sidebar(array('name'=&gt; $name,
			'before_widget' =&gt; '&lt;div id="%1$s" class="widget %2$s"&gt;',
			'after_widget' =&gt; '&lt;/div&gt;',
			'before_title' =&gt; '&lt;h3 class="widgetTitle"&gt;',
			'after_title' =&gt; '&lt;/h3&gt;',
		));
	}
}
?&gt;</code></pre>
										<p>Source: <a href="http://wpengineer.com/wordpress-and-register_sidebar/">wpengineer</a></p>
										<h3>Remove Fancy Quotes from Comments <a id="swt_42" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Prevent invalid markup and sloppy code by disabling WordPress&rsquo; automatic generation of &ldquo;fancy&rdquo; or &ldquo;curly&rdquo; quotes where they fail the most: your comments area.</p>
										<p>Only one simple line of code is required, placed into your theme&rsquo;s <code>functions.php</code> file:</p>
										<p>remove_filter(&#8217;comment_text&#8217;, &#8216;wptexturize&#8217;);</p>
										<p>Source: <a href="http://www.wprecipes.com/how-to-get-rid-of-curly-quotes-in-your-wordpress-blog">WPRecipes.com</a></p>
										<h3>Display a List of All Untagged Posts <a id="swt_43" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is an easy way to display a list of all untagged posts. All that&rsquo;s required is a custom loop and a quick check of the <code>get_the_tags</code> variable. Here is the code to make it work:</p>
										<pre><code>&lt;?php query_posts('orderby=title&amp;order=asc&amp;showposts=-1'); ?&gt;
&lt;?php if (have_posts()) : ?&gt; 
	&lt;ul&gt;
	&lt;?php while (have_posts()) : the_post(); ?&gt;
	&lt;?php $tag = get_the_tags(); if (!$tag) { ?&gt;

		&lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
		&lt;?php edit_post_link('Edit', ' ',''); ?&gt;&lt;/li&gt;

	&lt;?php } ?&gt;
	&lt;?php endwhile; ?&gt;
	&lt;/ul&gt;
&lt;?php endif; ?&gt;</code></pre>
										<p>Place that snippet into the theme file of your choice and navigate to that page in a browser to see a permlink-linked list of all posts that have not yet been tagged. Even better, next to each post title will be a an easy-access &ldquo;Edit&rdquo; link that will make it easy to quickly edit each of your untagged posts and add some tags, if necessary. Nothing on this planet could be easier. Almost.</p>
										<h3>Easy Display of Custom Headers, Footers, and Sidebars <a id="swt_44" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>WordPress 2.7 includes new functionality that makes it super-easy to include custom headers, footers, and sidebars into your theme. Normally, you include the default files with the following tags:</p>
										<pre><code>&lt;?php get_header(); ?&gt;

&lt;?php get_sidebar(); ?&gt;

&lt;?php get_footer(); ?&gt;</code></pre>
										<p>These will include the files named &ldquo;<code>header.php</code>&rdquo;, &ldquo;<code>sidebar.php</code>&rdquo;, and &ldquo;<code>footer.php</code>&rdquo;, respectively.</p>
										<p>Now, to include alternate versions of these files, simply include the name of the file as a parameter in its associated tag. Here is an example that should illustrate the idea:</p>
										<pre><code>&lt;?php get_header('custom-header'); ?&gt;

&lt;?php get_sidebar('custom-sidebar'); ?&gt;

&lt;?php get_footer('custom-footer'); ?&gt;</code></pre>
										<p>These will include the files named &ldquo;<code>custom-header.php</code>&rdquo;, &ldquo;<code>custom-sidebar.php</code>&rdquo;, and &ldquo;<code>custom-footer.php</code>&rdquo;, respectively.</p>
										<p>We can now use this new functionality to <a href="http://digwp.com/2009/07/getting-more-fine-grained-with-includes/" title="Getting More Fine-Grained with Includes">get fine-grained with includes</a>. For example, if we wanted to display a custom footer for the &ldquo;Bananaz&rdquo; category, we could use the following code:</p>
										<pre><code>&lt;?php if is_category('Bananaz') {
	get_footer('Bananaz');
} else {
	get_footer();
} ?&gt;</code></pre>
										<p>Source: <a href="http://codex.wordpress.org/">WordPress Codex</a></p>
										<h3>A Better Way for Users to Logout <a id="swt_45" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>The old way of displaying a &ldquo;Logout&rdquo; link for your users looks like this:</p>
										<pre><code>&lt;a href="&lt;?php echo get_option('siteurl'); ?&gt;/wp-login.php?action=logout"&gt;Logout&lt;/a&gt;</code></pre>
										<p>Now, since WordPress 2.7, we can simplify this hodgepodge with a sleeker, cleaner, built-in template tag:</p>
										<pre><code>&lt;a href="&lt;?php echo wp_logout_url(); ?&gt;"&gt;Logout&lt;/a&gt;</code></pre>
										<p>Sweetness.</p>
										<h3>Display a Custom Message on a Specific Date <a id="swt_46" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Using a snippet of <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>, we can display a custom message (or any code, markup, or content) on a specific date:</p>
										<pre><code>&lt;?php
if ((date('m') == 4) &amp;&amp; (date('d') == 9)) { ?&gt;

	&lt;p&gt;Today is &lt;a href="http://naked.dustindiaz.com/"&gt;CSS Naked Day&lt;/a&gt;!&lt;/p&gt;

&lt;?php } ?&gt;</code></pre>
										<p>You could even use this technique to join in on <a href="http://naked.dustindiaz.com/">CSS Naked Day</a> by removing your stylesheet on that day. Simply wrap your <acronym title="Cascading Style Sheet">CSS</acronym> <code>&lt;link&gt;</code> as follows:</p>
										<pre><code>&lt;?php // strip for CSS Naked Day
if ((date('m') !== 4) &amp;&amp; (date('d') !== 9)) { ?&gt;

&lt;link rel="stylesheet" href="&lt;?php bloginfo('stylesheet_url'); ?&gt;" type="text/css" media="screen" /&gt;

&lt;?php } ?&gt;</code></pre>
										<p>The possibilities are endless!</p>
										<h3>Display Three Columns of Posts <a id="swt_47" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p><a href="http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/" title="Multiple Loops and Multiple Columns with WordPress, (X)HTML and CSS">Displaying content in multiple columns</a> is a much sought-after WordPress technique. There are some good tutorials around explaining various ways of doing the job, but this one is perhaps the easiest.</p>
										<p>To display your posts in three columns, begin by segmenting your post with some <acronym title="Hypertext markup Language">HTML</acronym> comments:</p>
										<pre><code>Lorem ipsum blah blah. This content appears before the three columns.

&lt;!--column--&gt;

This content will appear in the first column.

&lt;!--column--&gt;

This content will appear in the second column.

&lt;!--column--&gt;

This content will appear in the third column.</code></pre>
										<p>The next step is to create columns based on the markup comments. Open your theme file and include the following code within the loop:</p>
										<pre><code>&lt;?php // multiple columns

$page_columns = explode("&lt;--column--&gt;", $post-&gt;post_content);

echo $page_columns[0]; // before columns

echo '&lt;div class="first column"&gt;'.$page_columns[1].'&lt;/div&gt;'; // first column

echo '&lt;div class="second column"&gt;'.$page_columns[2].'&lt;/div&gt;'; // second column

echo '&lt;div class="third column"&gt;'.$page_columns[3].'&lt;/div&gt;'; // third column

?&gt;</code></pre>
										<p>That&rsquo;s essentially all there is to it. To get the columns to actually <em>look</em> like columns, add something similar to the following in your <acronym title="Cascading Style Sheets">CSS</acronym> file:</p>
										<pre><code>/* column structure */
.column {
	margin-right: 10px;
	float: left;
	width: 33%;
	}
/* column styles */
column.first, column.second, column.third {}</code></pre>
										<p>The cool thing about this method is that you have full control over the layout of each particular post. Each column may contain as much or as little content as desired, and adding or removing columns is straightforward. Even better is that you can easily remove the column functionality and display your content in a single column by simply removing the custom code from the loop. The post markup consists of <acronym title="Hypertext markup Language">HTML</acronym> comments, so they will be ignored if not acted upon from within the loop.</p>
										<p>Source: Enhanced version of <a href="http://wordpress.org/support/topic/260223">krimsly&#8217;s technique (via the WP Codex)</a></p>
										<h3>Disable WordPress Search Functionality <a id="swt_48" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Disabling the WordPress search functionality is as simple as adding the following code to your <code>functions.php</code> file:</p>
										<pre><code>function fb_filter_query($query, $error = true) {
 
	if (is_search()) {
		$query-&gt;is_search = false;
		$query-&gt;query_vars[s] = false;
		$query-&gt;query[s] = false;
 
		// to error
		if ($error == true)
			$query-&gt;is_404 = true;
	}
}
if (!is_admin()) {
	add_action('parse_query', 'fb_filter_query');
	add_filter('get_search_form', create_function('$a', "return null;"));
}</code></pre>
										<p>In place, this code will disable the search form for your theme while leaving search functionality intact for the Admin area. As is, the <code>$error</code> variable is set to <code>TRUE</code>, which causes the function to display the theme&rsquo;s error page. Setting this variable to <code>FALSE</code> will prevent the error message and keep the user on the same page.</p>
										<p>Source: <a href="http://wpengineer.com/disable-wordpress-search/">WPengineer</a></p>
										<h3>Display Posts with Specific Custom Fields <a id="swt_49" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Displaying posts that are associated with a certain custom field is as easy as adding an &ldquo;<code>if</code>&rdquo; condition to your loop. Here is an example that checks for the presence of a custom field called &ldquo;name-of-custom-field&rdquo;. If such a custom field is associated with the post, the entire post is displayed; otherwise, only the excerpt is displayed.</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
&lt;?php $custom_field = get_post_custom_values("name-of-custom-field"); ?&gt;

	&lt;?php if (isset($custom_field[0])) { ?&gt;

		&lt;h1&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;
		&lt;?php the_content(); ?&gt;

	&lt;?php } else { ?&gt;

		&lt;h2&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
		&lt;?php the_excerpt(); ?&gt;

	&lt;?php } ?&gt;

&lt;?php endwhile; endif; ?&gt;</code></pre>
										<p>To get more specific and display only posts associated with a custom-field that is set to a certain value, we simply add an additional parameter to the &ldquo;<code>if</code>&rdquo; condition:</p>
										<p><code>&lt;?php if ((isset($custom_field[0])) &amp;&amp; ($custom_field[0] == "name-of-value")) { ?&gt;</code></p>
										<p>Using that line of code, we modify our previous loop as follows:</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
&lt;?php $custom_field = get_post_custom_values("name-of-custom-field"); ?&gt;

	&lt;?php if ((isset($custom_field[0])) &amp;&amp; ($custom_field[0] == "name-of-value")) { ?&gt;

		&lt;h1&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;
		&lt;?php the_content(); ?&gt;

	&lt;?php } else { ?&gt;

		&lt;h2&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
		&lt;?php the_excerpt(); ?&gt;

	&lt;?php } ?&gt;

&lt;?php endwhile; endif; ?&gt;</code></pre>
										<p>With this code, any post with a custom-field of &ldquo;name-of-custom-field&rdquo; that has a specific value of &ldquo;name-of-value&rdquo; will be displayed in its entirety. All other posts will be displayed as an excerpt.</p>
										<p>Source: <a href="http://perishablepress.com/press/2008/12/22/wordpress-custom-fields-tips-tricks/">Perishable Press</a></p>
										<h3>How to Number Your Comments, Pingbacks, and Trackbacks in 2.7+ <a id="swt_50" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Numbering comments, pingbacks, and trackbacks in WordPress versions 2.7 and greater requires two steps. First, you need to add a couple of parameters to your <code>comments_template</code> tag, which is used to display your comments template and normally located in your <code>single.php</code> file. Edit this tag so that it looks like this:</p>
										<p><code>&lt;?php comments_template('/comments.php',true); ?&gt;</code></p>
										<p>Once this is in place, you can display the number of your comments, pingbacks, trackbacks, and both using the following tags:</p>
										<pre><code>echo count($wp_query-&gt;comments_by_type['comment']); // display comment count
echo count($wp_query-&gt;comments_by_type['pingback']); // display pingback count
echo count($wp_query-&gt;comments_by_type['trackback']); // display trackback count

echo count($wp_query-&gt;comments_by_type['pings']); // display pingback and trackback count

comments_number('No Responses', 'One Response', '% Responses' ); // display total response count</code></pre>
										<p>These tags can be placed anywhere in your comments loop. For more information on how to implement this, check out our in-depth article at <a href="http://digwp.com/">Digging into WordPress</a>.</p>
										<h3>How to Number Your Comments Using the Classic Loop <a id="swt_51" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Before, WordPress added the new comments API in version 2.7, the &ldquo;classic&rdquo; comment-loop mechanism was used. This loop still works in any version of WordPress, and is useful for extreme formatting of the comment display area. Numbering your comments in the classic loop is as easy as it is in the new-fangled loop. Here&rsquo;s how:</p>
										<p>In your <code>comments.php</code> file, add a counter variable (&nbsp;<code>&lt;?php $i = 0; ?&gt;</code>&nbsp;) just above the loop&rsquo;s <code>foreach</code> statement, like so:</p>
										<pre><code>&lt;?php $i = 0; ?&gt;
&lt;?php foreach ($comments as $comment) : ?&gt;</code></pre>
										<p>Then, to increment the counter variable with each iteration of the loop, we add another snippet just below the <code>foreach</code> line, like so:</p>
										<pre><code>&lt;?php $i = 0; ?&gt;
&lt;?php foreach ($comments as $comment) : ?&gt;
&lt;?php $i++; ?&gt;</code></pre>
										<p>Everything is now set. To display the number of comments, simply echo the value of the counter variable anywhere within your comment loop. Here is an example:</p>
										<h3>There are <?php echo $i; ?> comments so far!</h3>
										<p>Source: <a href="http://digwp.com/">Digging into WordPress</a></p>
										<h3>Invite Readers to Comment via Feed <a id="swt_52" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Nice little snippet showing how to invite your readers to leave a comment by clicking on a link within your feed. Just add the following code to your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>// comment invite feed link
function rss_comment_footer($content) {
	if (is_feed()) {
		if (comments_open()) {
			$content .= 'Comments are open! &lt;a href="'.get_permalink().'"&gt;Add yours!&lt;/a&gt;';
		}
	}
	return $content;
}</code></pre>
										<p>In place, this function will output a link that says, &ldquo;Comments are open! <a href="#">Add yours!</a>&rdquo; This message will be displayed at the end of each post for which comments are open. If comments are closed, no invite message is displayed.</p>
										<p>Source: <a href="http://blogbuildingu.com/">Hendry Lee</a></p>
										<h3>Display the Total Number of Users for Your Blog <a id="swt_53" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is a tasty little snippet from WPRecipes that will enable you to display the total number of users for your WordPress-powered blog. All you need to do is place the following code in your theme file(s) where you would like to display your total number of users:</p>
										<pre><code>$users = $wpdb-&gt;get_var("SELECT COUNT(ID) FROM $wpdb-&gt;users");
echo $users." registered users.";</code></pre>
										<p>Source: <a href="http://www.wprecipes.com/display-the-total-number-of-users-of-your-wordpress-blog">WPRecipes.com</a></p>
										<h3>Automatically Insert Content into Your WordPress Post Editor <a id="swt_54" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is a nice way to automatically insert some custom content into your post editor. This makes it easy to add repetitive content to your posts while retaining the ability to make changes before publishing. To try it out, add the following code to your <code>functions.php</code> file:</p>
										<pre><code>&lt;?php // auto-insert content to post editor
function my_editor_content($content) {
	$content = "&lt;h5&gt;Thank you for your generous attention!&lt;/h5&gt;.";
	return $content;
}
add_filter('default_content', 'my_editor_content');
?&gt;</code></pre>
										<p>This code will display a message thanking people for their generous attention, but you can easily edit the message to display whatever content (text/markup) that you wish. After configuring your message, open your WordPress text editor to see the automatically inserted content.</p>
										<p>Source: <a href="http://justintadlock.com/archives/2009/04/05/how-to-preset-text-in-the-wordpress-post-editor">Justin Tadlock</a></p>
										<h3>How to Prevent Duplicate Content <a id="swt_55" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Unless you&rsquo;re using excerpts for non-single page views, your post content is being displayed in your single pages, date-based archives, category archive, tags archives, author archives, and so on. From an <acronym title="Search Engine Optimization">SEO</acronym> perspective, this &ldquo;duplicate&rdquo; content may be detrimental to your search-engine rankings.</p>
										<p>To prevent duplicate content, we can conditionally display one of two <code>&lt;meta&gt;</code> tags depending on the type of page being displayed. Pages that we <em>want</em> to have indexed in the search engines will display a &ldquo;meta-index&rdquo; tag, while duplicate pages will display a &ldquo;meta-<strong>no</strong>index&rdquo; tag.</p>
										<p>To do this, simply add the following code to the <code>&lt;head&gt;</code> section of your theme&rsquo;s <code>header.php</code> file:</p>
										<pre><code>&lt;?php if ((is_home() &amp;&amp; ($paged &lt; 2 )) || is_single() || is_page() || is_category()) {
	echo '&lt;meta name="robots" content="index,archive,follow" /&gt;';
} else {
	echo '&lt;meta name="robots" content="noindex,noarchive,follow" /&gt;';
}</code></pre>
										<p>Once in place, this code effectively stops search engines from indexing all types of pages except for single-post, page-page, category-archive, and the first two index pages. These are considered by many to be the most effective pages to have indexed, but feel free to add or remove anything you see fit to customize the technique.</p>
										<p>Source: <a href="http://perishablepress.com/press/2009/05/10/seo-experiment-let-google-sort-it-out/">Perishable Press</a></p>
										<h3>Conditionally Display Full Posts or Excerpts <a id="swt_56" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>By default, you can either display full-posts or excerpts when displaying your posts. This may be fine for common blogging purposes, but specialized blogs may find it beneficial to exercise control over which type of post format is displayed. Here&rsquo;s how to conditionally display either full-post or excerpt based on the presence of a custom field named &ldquo;full-post-display&rdquo;.</p>
										<p>To implement this technique, setup the following loop in your theme file(s):</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
&lt;?php $customdisplay = get_post_custom_values("full-post-display"); ?&gt;

	&lt;?php if (isset($customdisplay[0])) { ?&gt;
              
		&lt;h1&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;
		&lt;?php the_content(); ?&gt;

	&lt;?php } else { ?&gt;

		&lt;h1&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;
		&lt;?php the_excerpt(); ?&gt;

	&lt;?php } ?&gt;
&lt;?php endwhile; endif; ?&gt;</code></pre>
										<p>Then, for any post that you would like to display with full-post formatting, simply add a custom-field of &ldquo;full-post-display&rdquo; and give it a value of &ldquo;true&rdquo;.</p>
										<h3>Display Related Posts without a Plugin <a id="swt_57" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>We don&rsquo;t need no stinking plugins to display related posts! Here&rsquo;s how to do the job using tags as the associative criteria.</p>
										<p>Place the following code in your loop and take a nap or something:</p>
										<pre><code>&lt;?php // related posts based on first tag of current post
$tags = wp_get_post_tags($post-&gt;ID);
if ($tags) {

	echo '&lt;h3&gt;Related Posts&lt;/h3&gt;';

	$first_tag = $tags[0]-&gt;term_id;
	$args = array(
			'tag__in' =&gt; array($first_tag),
			'post__not_in' =&gt; array($post-&gt;ID),
			'showposts' =&gt; 7, // how many posts?
			'caller_get_posts' =&gt; 1
			);

	$my_query = new WP_Query($args);
  	if ($my_query-&gt;have_posts()) { ?&gt;

		&lt;ul&gt;

		&lt;?php while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt;

			&lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;

		&lt;?php endwhile; ?&gt;

		&lt;/ul&gt;

	&lt;?php } ?&gt;
&lt;?php } ?&gt;</code></pre>
										<p>Customize as needed. To change the number of posts, edit the line that says, &ldquo;how many posts?&rdquo;</p>
										<p>Source: Enhanced version of the code provided by <a href="http://wordpress.org/support/topic/247918">MichaelH (via WP Codex)</a></p>
										<h3>Drop-Dead Easy Styles for Author Comments <a id="swt_58" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>This is almost <em>too</em> easy. To make your Author comments stand out from the crowd in WordPress 2.7 or better, use this code to apply some custom <acronym title="Cascading Style Sheets">CSS</acronym> stylez:</p>
										<pre><code>li.bypostauthor {
	background: red;
	color: white;
	}
li.byuser {
	background: white;
	color: black;
	}</code></pre>
										<h3>Display Upcoming Scheduled Posts <a id="swt_59" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here&rsquo;s an easy way to display a list of posts that are scheduled to be published at some point in the future. Create a page called &ldquo;Upcoming Posts&rdquo; (or whatever), and use this code for the loop:</p>
										<pre><code>&lt;?php query_posts('showposts=7&amp;post_status=future'); ?&gt;

&lt;?php if (have_posts()) : ?&gt;

	&lt;h3&gt;Upcoming Scheduled Posts&lt;/h3&gt;
	&lt;ul&gt;
	&lt;?php while (have_posts()) : the_post(); ?&gt;

		&lt;li&gt;&lt;?php the_title(); ?&gt; &amp;#8212; &lt;?php the_time('l, F j, Y'); ?&gt;&lt;/li&gt;

	&lt;?php endwhile; ?&gt;
	&lt;/ul&gt;

&lt;?php else: ?&gt;

	&lt;p&gt;Nothing new in queue!&lt;/p&gt;

&lt;?php endif; ?&gt;</code></pre>
										<p>In place, this code will output a list of all posts that exist within the database that have a <code>post_status</code> of &ldquo;<code>future</code>&rdquo;. I.e., anything that you have setup in draft mode that is set to auto-publish at a certain point in the future.</p>
										<h3>Display Automatic TinyURLs for Your Posts <a id="swt_60" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Make it super-easy for your visitors to share the <acronym title="Uniform Resource Locator">URL</acronym> of your posts with their favorite social-media service. Providing an alternate &ldquo;short&rdquo; version of your <acronym title="Uniform Resource Locator">URL</acronym>s is possible using the free <a href="http://tinyurl.com/">TinyURL</a> service and a couple snippets of code.</p>
										<p>To display short <acronym title="Uniform Resource Locator">URL</acronym>s at the end of your posts, place this code into your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>function getTinyUrl($url) {
	$tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
	return $tinyurl;
}</code></pre>
										<p>Then, call the function and display the <acronym title="Uniform Resource Locator">URL</acronym> by placing this code into your <code>single.php</code> file in the desired location within the loop:</p>
										<pre><code>&lt;?php $turl = getTinyUrl(get_permalink($post-&gt;ID)); 
echo 'TinyURL for this post: &lt;a href="'.$turl.'"&gt;'.$turl.'&lt;/a&gt;'; ?&gt;</code></pre>
										<p>That&rsquo;s it! Your posts now feature super-short <acronym title="Uniform Resource Locator">URL</acronym>s for all of your tweet-hungry visitors. Tuper Tweet Tude!</p>
										<p>Source: <a href="http://perishablepress.com/press/2009/10/18/stupid-twitter-tricks/">Perishable Press</a></p>
										<h3>Implement a Site-Maintenance Page for Your Blog <a id="swt_61" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Ever do maintenance on your site? Certainly, we all do. Here&rsquo;s an easy way to display a &ldquo;site-maintenance&rdquo; page that will display whatever content you desire. The key here is setting up your <acronym title="Hypertext Access">HTAccess</acronym> file to handle the redirect properly.</p>
										<p>First, you need to create your maintenance page. This can be as simple or as advanced as you would like. At minimum, you could include something like this into a file named &ldquo;maintenance.html&rdquo;:</p>
										<pre><code>&lt;h1&gt;Site Maintenance&lt;/h1&gt;
&lt;p&gt;Please check back in 15 minutes&lt;/p&gt;</code></pre>
										<p>Then, add this bit of voodoo to your site&rsquo;s root htaccess file:</p>
										<pre><code># SITE MAINTENANCE PAGE
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.444
RewriteRule $/maintenance.html [R=302,L]</code></pre>
										<p>Once that&rsquo;s in place, replace the example <acronym title="Internet Protocol">IP</acronym> address with that of your own. Upload to your site and check it out. What you will see is that you have full access to your site, but all other visitors will see the maintenance page.</p>
										<p>Once maintenance is complete, simply comment out the code in your htaccess file to allow visitors back into the site.</p>
										<p>Source: <a href="http://www.catswhocode.com/blog/10-awesome-htaccess-hacks-for-wordpress">Catswhocode</a></p>
										<h3>Display the First Image from Each of Your Posts <a id="swt_62" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>If your posts include an image that you would like to display as a thumbnail elsewhere on your blog, here is an easy way to do it with no custom fields required. Place the following code into your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>function catch_that_image() {
	global $post, $posts;
	$first_img = '';
	ob_start();
	ob_end_clean();
	$output = preg_match_all('/&lt;img.+src=[\'"]([^\'"]+)[\'"].*&gt;/i', $post-&gt;post_content, $matches);
	$first_img = $matches [1] [0];

	if(empty($first_img)){
		$first_img = "/images/default.jpg"; // default image
	}  
	return $first_img;
}</code></pre>
										<p>Then, to call the function and display the images as thumbnails, place the following code into the desired location within your loop:</p>
										<pre><code>&lt;?php echo catch_that_image(); ?&gt;</code></pre>
										<p>That&rsquo;s all there is to it. If you would like to display a default image for posts that may not have one, specify its path in the code (on the line that says &ldquo;default&nbsp;image).</p>
										<p>Source: <a href="http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it">WPRecipes</a></p>
										<h3>Display Most Popular Posts without a Plugin <a id="swt_63" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Simple but effective method of displaying your blog&rsquo;s most popular posts based on comment count. This code snippet may be placed anywhere within your theme&rsquo;s files (i.e., no loop required). Check it out:</p>
										<pre><code>&lt;h3&gt;Popular Posts&lt;/h3&gt;
&lt;ul&gt;
&lt;?php $result = $wpdb-&gt;get_results("
	SELECT comment_count, ID, post_title 
	FROM $wpdb-&gt;posts ORDER BY comment_count DESC LIMIT 0 , 7
	");

foreach ($result as $post) {
	setup_postdata($post);
	$postid = $post-&gt;ID;
	$title = $post-&gt;post_title;
	$commentcount = $post-&gt;comment_count;
	if ($commentcount != 0) { ?&gt;

	&lt;li&gt;&lt;a href="&lt;?php echo get_permalink($postid); ?&gt;"&gt;
	&lt;?php echo $title; ?&gt;&lt;/a&gt; [&lt;?php echo $commentcount ?&gt;]&lt;/li&gt;

	&lt;?php } ?&gt;
&lt;?php } ?&gt;
&lt;/ul&gt;</code></pre>
										<p>Once in place, this code will display the seven most popular posts along with their associated comment count in unordered list format. Customize according to your needs.</p>
										<p>Source: <a href="http://www.problogdesign.com/wordpress/create-your-own-popular-posts-page/">ProBlogDesign</a></p>
										<h3>Automatically Highlight Search Terms <a id="swt_64" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Make things easy for people who are searching your site by applying some custom styling to the search terms that are displayed in the search results. A common way to display search terms is with a yellow background so that users can easily identify locations of the text that may apply to their query. It&rsquo;s all about about usability, and improving the way search results are displayed on your site. Here&rsquo;s how to do it:</p>
										<p>First, replace the <code>the_title()</code> tag in your <code>search.php</code> file with the following:</p>
										<pre><code>&lt;?php // highlight search terms in title
	$title = get_the_title();
	$keys  = explode(" ", $s);
	$title = preg_replace('/('.implode('|',$keys).')/iu','&lt;span class="search-terms"&gt;\0&lt;/span&gt;',$title);
	echo $title;
?&gt;</code></pre>
										<p>This will setup styling for search terms located in the title of each result. Then, for the content, replace the <code>the_excerpt()</code> tag in your <code>search.php</code> file with the following:</p>
										<pre><code>&lt;?php // highlight search terms in content
	$excerpt = get_the_excerpt();
	$keys  = explode(" ", $s);
	$excerpt = preg_replace('/('.implode('|',$keys).')/iu','&lt;span class="search-terms"&gt;\0&lt;/span&gt;',$excerpt);
	echo $excerpt;
?&gt;</code></pre>
										<p>Finally, open your theme&rsquo;s <acronym title="Cascading Style Sheets">CSS</acronym> file and add some custom styles for the search terms. A great way to highlight each term is to display it in bold text with yellow highlighting. Something like this:</p>
										<pre><code>span.search-terms { 
	background: yellow;
	font-weight: bold;
	}</code></pre>
										<p>That&rsquo;s all there is to it! Go run a few searches to see it in action.</p>
										<p>Source: Enhanced version of code provided by <a href="http://yoast.com/wordpress-search/">Yoast.com</a></p>
										<h3>Automatically Disable Widgets <a id="swt_65" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Quick tip to disable all widget functionality from your theme. Add the following to your <code>functions.php</code> file and call it done:</p>
										<pre><code>&lt;?php // disable all widgets
function disable_all_widgets($sidebars_widgets) {

	$sidebars_widgets = array(false);
	return $sidebars_widgets;

}
add_filter('sidebars_widgets', 'disable_all_widgets');
?&gt;</code></pre>
										<p>Source: <a href="http://justintadlock.com/archives/2009/03/06/disable-widget-areas-without-touching-theme-templates">Justin Tadlock</a></p>
										<h3>Display All Images from Your Post Content <a id="swt_66" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Want to display all of the images from each of your posts somewhere on your blog? Easy. Check out this code snippet from Matt Varone:</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

&lt;?php 
$szPostContent = $post-&gt;post_content;
$szSearchPattern = '~&lt;img [^\&gt;]*\ /&gt;~';

// Run preg_match_all to grab all the images and save the results in $aPics
preg_match_all($szSearchPattern, $szPostContent, $aPics);

// Check to see if we have at least 1 image
$iNumberOfPics = count($aPics[0]);

if ($iNumberOfPics &gt; 0) {
	// now here you would do whatever you need to do with the images
	// for this example the images are just displayed
	for ( $i=0; $i &lt; $iNumberOfPics ; $i++ ) {
		echo $aPics[0][$i];
	};
};

endwhile;
endif;
?&gt;</code></pre>
										<p>Just customize the output in the second part of the code (see code comments) and paste the function wherever you would like to display the images. Sweetness.</p>
										<p>Source: <a href="http://www.mattvarone.com/wordpress/images-post-wordpress-regular-expressions/">Matt Varone</a></p>
										<h3>Display Category List in Two Columns <a id="swt_67" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Tired of that boring, single-column category display? Spice things up with a spiffy two-column category list that will get your visitors&rsquo; hearts pumping. Let&rsquo;s deface a WordPress tag, shall we?</p>
										<p>See this bad boy:</p>
										<p><code>&lt;?php wp_list_categories(); ?&gt;</code></p>
										<p>We&rsquo;re going to blow it up, divide its contents into two pieces, and spit it all back out as two unordered lists. Impossible, you say? Nah, just a little <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> to make it all go.</p>
										<p>Wherever you would like to display your categories in two columns, throw down the following code snippet:</p>
										<pre><code>&lt;?php // display categories in columns
$cats = explode("&lt;br /&gt;",wp_list_categories('title_li=&amp;echo=0&amp;depth=1&amp;style=none'));
$cat_n = count($cats) - 1;
for ($i=0;$i&lt;$cat_n;$i++) :
	if ($i&lt;$cat_n/2) :

		$cat_left = $cat_left.'&lt;li&gt;'.$cats[$i].'&lt;/li&gt;';

	elseif ($i&gt;=$cat_n/2):

		$cat_right = $cat_right.'&lt;li&gt;'.$cats[$i].'&lt;/li&gt;';

	endif;
endfor; ?&gt;

&lt;ul class="left"&gt;
	&lt;?php echo $cat_left;?&gt;
&lt;/ul&gt;
&lt;ul class="right"&gt;
	&lt;?php echo $cat_right;?&gt;
&lt;/ul&gt;</code></pre>
										<p>Completely awesome. Now let&rsquo;s add some style to make the columns work:</p>
										<pre><code>.right {
	float: left; 
	width: 140px;
	}
.left {
	float: left; 
	width: 140px;
	}</code></pre>
										<p>You are all set. You should probably fine-tune this business until it&rsquo;s all good. You know.</p>
										<p>Source: <a href="http://www.blogohblog.com/10-wordpress-hacks-to-make-your-life-even-easier/">Blog Oh Blog</a></p>
										<h3>Show Ads or Other Content Only in the First Three Posts <a id="swt_68" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Advertising may require you to limit the number of advertisements on your page to three. For some, this is three too many. For others, it&rsquo;s far too few. Still others feel that it&rsquo;s just the right amount. </p>
										<p>Regardless of your feelings, here is a trick that will enable you to limit the number of posts that displays some specific content &#8212; ads, images, scripts, whatever you want. Check out the three indented lines in the following loop:</p>
										<pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

	&lt;?php if ($wp_query-&gt;current_post &lt; 3) { ?&gt;

	&lt;!-- any content here will be displayed only in first three posts --&gt;

	&lt;?php } ?&gt;

&lt;?php endwhile; else: ?&gt;
&lt;?php endif; ?&gt;</code></pre>
										<p>See what&rsquo;s happening here. We&rsquo;ve got a loop, see. In this loop, we specify a condition that says, &ldquo;if this is one of the first three posts, display this content.&rdquo; And that&rsquo;s the magic. Of course, you can use whatever content you would like, and there is nothing special about the number &ldquo;<code>3</code>&rdquo; either.</p>
										<p>Source: <a href="http://www.blogohblog.com/10-wordpress-hacks-to-make-your-life-even-easier/">Blog Oh Blog</a></p>
										<h3>A Better Way to Display Recent Comments without a Plugin <a id="swt_69" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is a better way to display your recent comments without a plugin. Instead of slapping a bunch of gnarly code into our <code>index.php</code> or <code>sidebar.php</code> file, we are going to slap it right where it belongs: in your theme&rsquo;s <code>functions.php</code> file.</p>
										<p>Here is the code, all exploded for your viewing and analytical pleasure (well, for mine anyway). For a more minified version of this snippet, be sure to check out the source link.</p>
										<pre><code>&lt;?php // display recent comments without a plugin

function recent_comments($src_count=10, $src_length=60, $pre_HTML='&lt;ul&gt;', $post_HTML='&lt;/ul&gt;') {
global $wpdb;
$sql = "
	SELECT DISTINCT 
		ID, 
		post_title, 
		post_password, 
		comment_ID, 
		comment_post_ID, 
		comment_author, 
		comment_date_gmt, 
		comment_approved, 
		comment_type, 
	SUBSTRING(
		comment_content, 1, $src_length
		) 
	AS com_excerpt 
	FROM $wpdb-&gt;comments 
	LEFT OUTER JOIN $wpdb-&gt;posts 
	ON (
		$wpdb-&gt;comments.comment_post_ID = $wpdb-&gt;posts.ID
		) 
	WHERE comment_approved = '1' 
	AND comment_type = '' 
	AND post_password = '' 
	ORDER BY comment_date_gmt 
	DESC
	LIMIT $src_count
";
$comments = $wpdb-&gt;get_results($sql);
$output = $pre_HTML;

foreach ($comments as $comment) {

	$output .= '&lt;li&gt;&lt;a href="'.get_permalink($comment-&gt;ID).'#comment-'.$comment-&gt;comment_ID.'" title="on '.$comment-&gt;post_title.'"&gt;'.strip_tags($comment-&gt;com_excerpt).'...&lt;/a&gt;&lt;/li&gt;';

}
$output .= $post_HTML;
echo $output;

} ?&gt;</code></pre>
										<p>Ah, it&rsquo;s a thing of beauty. Once you have that code in place, rock it out anywhere in your theme with this charming little tag:</p>
										<p><code>&lt;?php recent_comments(); ?&gt;</code></p>
										<p>see also: <a href="#swt_37" class="anchor">Display Latest Comments without a Plugin</a><br />Source: <a href="http://www.blogohblog.com/10-wordpress-hacks-to-make-your-life-even-easier/">Blog Oh Blog</a></p>
										<h3>Selectively Disable Automatic Post Formatting <a id="swt_70" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>This trick is by far my favorite &ldquo;<a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/">stupid WordPress trick</a>.&rdquo; You know how WordPress likes to mangle <acronym title="Hypertext Markup Language">HTML</acronym> comments, empty elements, blockquotes, curly quotes, and other miscellaneous markup elements? Here is a tight little method that will enable you to <em>selectively</em> disable WordPress&rsquo; automatic post formatting.</p>
										<p>Do this: Place the following code into your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>// disable auto-formatting
function my_formatter($content) {
	$new_content = '';
	$pattern_full = '{(\[raw\].*?\[/raw\])}is';
	$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
	$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

	foreach ($pieces as $piece) {
		if (preg_match($pattern_contents, $piece, $matches)) {
			$new_content .= $matches[1];
		} else {
			$new_content .= wptexturize(wpautop($piece));
		}
	}
	return $new_content;
}
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'my_formatter', 99);</code></pre>
										<p>Then do this: Use the <code>[raw]</code> shortcode wherever you would like to disable auto-formatting in your post content. For example, if you wanted to prevent the following sentence from being formatted, you would write this: </p>
										<p><code>[raw]This text will not be automatically formatted.[/raw]</code></p>
										<p>Absolutely brilliant.</p>
										<p>Source: <a href="http://www.wprecipes.com/disable-wordpress-automatic-formatting-on-posts-using-a-shortcode">WPRecipes</a></p>
										<h3>Browser Detection via WordPress&rsquo; body_class Function <a id="swt_71" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>WordPress makes it possible to detect a handful of different browsers using a variety of built-in global variables. WordPress also provides a <code>body_class</code> tag that outputs a variety of class attributes depending on various page properties. Why not combine these two techniques so that the user&rsquo;s detected browser is added to the list of output classes for the body tag? Here&rsquo;s the code that will do it via <code>functions.php</code>:</p>
										<pre><code>// browser detection via body_class
function browser_body_class($classes) {

    global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;

    if($is_lynx)       $classes[] = 'lynx';
    elseif($is_gecko)  $classes[] = 'gecko';
    elseif($is_opera)  $classes[] = 'opera';
    elseif($is_NS4)    $classes[] = 'ns4';
    elseif($is_safari) $classes[] = 'safari';
    elseif($is_chrome) $classes[] = 'chrome';
    elseif($is_IE)     $classes[] = 'ie';
    else               $classes[] = 'unknown';

    if($is_iphone) $classes[] = 'iphone';
    return $classes;

}
add_filter('body_class','browser_body_class');</code></pre>
										<p>This code will output the detected browser along with the other <code>body_class</code> tags. Here is an example:</p>
										<p><code>&lt;body class="home blog logged-in safari"&gt;</code></p>
										<p>Hooked.</p>
										<p>Sources: <a href="http://www.nathanrice.net/blog/browser-detection-and-the-body_class-function/">Nathan Rice</a></p>
										<h3>Get Post or Page Contents as a PHP Variable <a id="swt_72" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is a quick snippet for placing all post or page content into a variable. We&rsquo;re talking the <em>entire</em> page contents here, not just the content of the post. Place this code into your theme&rsquo;s <code>functions.php</code> file:</p>
										<pre><code>// post contents as variable
function callback($buffer) {
	return $buffer;
	}
function buffer_start() {
	ob_start("callback");
	}
function buffer_end() {
	ob_end_flush();
	}
add_action('wp_head', 'buffer_start');
add_action('wp_footer', 'buffer_end');</code></pre>
										<p>Once in place, this function will capture the entire page contents into a variable called &ldquo;<code>$buffer</code>&rdquo;. You may then do whatever you wish to this variable. Filter it, match it, slap it around a little and show it who&rsquo;s boss. That sort of thing.</p>
										<p>Source: <a href="http://www.dagondesign.com/articles/wordpress-hook-for-entire-page-using-output-buffering/">Dagon Design</a><br />See also: <a href="http://digwp.com/2009/07/putting-the_content-into-a-php-variable/">Digging into WordPress</a></p>
										<h3>Simple Example of How to Use WordPress Cron <a id="swt_73" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>I have been meaning to get into WordPress&rsquo; <code>wp-cron</code> functionality, and this looks like a good way to get started with it. This code snippet uses <code>wp-cron</code> to schedule an automatic email that will be sent every hour.</p>
										<pre><code>// send automatic scheduled email
if (!wp_next_scheduled('my_task_hook')) {
	wp_schedule_event(time(), 'hourly', 'my_task_hook');
}
add_action('my_task_hook', 'my_task_function'); 

function my_task_function() {
	wp_mail('you@yoursite.com', 'Automatic email', 'Hello, this is an automatically scheduled email from WordPress.');
}</code></pre>
										<p>Of course, this is meant only as an example. The key here is to schedule and event and then hook into it with some specific function. </p>
										<p>Source: <a href="http://blog.slaven.net.au/archives/2007/02/01/timing-is-everything-scheduling-in-wordpress/">slaven.net</a></p>
										<h3>Add More Default Avatar Choices to the WordPress Admin <a id="swt_74" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is a quick and easy way to add more default avatars to the list of available gravatars in the Settings area of the WordPress Admin. Here is the <code>functions.php</code> code to make it happen:</p>
										<pre><code>// add more default avatars to options
if (!function_exists('fb_addgravatar')) {
	function fb_addgravatar($avatar_defaults) {

		$myavatar1 = get_bloginfo('template_directory').'/images/avatar-01.png';
		$avatar_defaults[$myavatar1] = 'dude';
 
		$myavatar2 = get_bloginfo('template_directory').'/images/avatar-02.png';
		$avatar_defaults[$myavatar2] = 'geek';
 
		$myavatar3 = get_bloginfo('template_directory').'/images/avatar-03.png';
		$avatar_defaults[$myavatar3] = 'cool';

		return $avatar_defaults;
	}
	add_filter('avatar_defaults', 'fb_addgravatar');
}</code></pre>
										<p>See the innermost indented lines of code? There we are specifying three additional default avatars. To use this code, you will need to edit these lines to match your image paths and the name for each avatar. Hopefully the process of editing, adding, or removing avatars is clear. If not, don&rsquo;t hesistate to speak up in the comments and someone will help you out.</p>
										<p>Source: <a href="http://wpengineer.com/add-avatar-to-wordpress-default/">WPEngineer</a></p>
										<h3>Add a Private Page to Your Navigation Menu <a id="swt_75" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>By default, any pages that you classify as &ldquo;Private&rdquo; are not displayed in the menu generated by the <a href="http://digwp.com/2009/07/delicious-recipes-wordpress-page-menus/" title="Delicious Recipes for WordPress Page Menus and Page Listings">wp_list_pages</a> function. In general this is a good idea, but it might be helpful to include the link if the logged in user is able to read private pages. Fortunately, WordPress has a function that will enable us to do exactly that:</p>
										<pre><code>&lt;ul&gt;
&lt;?php // add a private page to your navigation menu
wp_list_pages('depth=1&amp;title_li=0&amp;sort_column=menu_order');
if(current_user_can('read_private_pages')) : ?&gt;

	&lt;li&gt;&lt;a href="&lt;?php echo get_permalink(10); ?&gt;"&gt;For Authors only&lt;/a&gt;&lt;/li&gt;

&lt;?php endif; ?&gt;
&lt;/ul&gt;</code></pre>
										<p>Place this code where you would normally include the <code>wp_list_pages</code> tag and enjoy private-page links displayed in your navigation menus only for those users who are logged in and priviledged enough to see them. The private link will not be displayed for the &ldquo;ordinary&rdquo; folk.</p>
										<p>Make sure you replace the number &ldquo;<code>10</code>&rdquo; in the middle line to match the ID of the private page you would like to include.</p>
										<p>Source: <a href="http://wpengineer.com/adding-a-private-page-into-the-navigation/">WPEngineer</a></p>
										<h3>How to Add Additional Links to wp_list_pages <a id="swt_76" href="#toc" class="anchor"><sup>&uarr;</sup></a></h3>
										<p>Here is a nice way to include additional links to the output of the <code>wp_list_pages</code> tag. All that&rsquo;s needed is the following function in your <code>functions.php</code> file:</p>
										<pre><code>// include additional links
function add_bookmarks_to_menu($output) {
	$bookmarks = (array) get_bookmarks('hide_invisible=0&amp;category_name=wp_list_pages');
	foreach ($bookmarks as $bookmark) {
		$output .= "&lt;li&gt;&lt;a href='{$bookmark-&gt;link_url}'  title='{$bookmark-&gt;link_name}'&gt;{$bookmark-&gt;link_name}&lt;/a&gt;&lt;/li&gt;\n";        

	}
	return $output;
}
add_filter('wp_list_pages', 'add_bookmarks_to_menu');</code></pre>
										<p>Here we are taking advantage of WordPress&rsquo; built-in Links/Bookmarks functionality to assign new links to the output of the <code>wp_list_pages</code> tag. Once this code is in place, login to your WordPress Admin and follow these steps for each link that you would like to add to the page list:</p>
										<ol>
										<li>In the Admin, go to Links > Add New</li>
										<li>Enter a name and URL for your link</li>
										<li>Add the link to a new category called &ldquo;wp_list_pages&rdquo;</li>
										<li>select &ldquo;Keep this link private&rdquo;</li>
										<li>Click &ldquo;Add Link&rdquo;</li>
										<li>Done.</li>
										</ol>
										<p>Using the &ldquo;wp_list_pages&rdquo; category for any/all of our extra links will enable us to include only links from that category. Further, selecting the &ldquo;Keep this link private&rdquo; option will prevent the links from being displayed elsewhere in your site (for example, in the Links/Blogroll/Bookmark sections).</p>
										<p>Source: <a href="http://sivel.net/2009/03/adding-links-to-wp_list_pages-part-2/">sivel.net</a> </p>
										<h3>&ldquo;I&rsquo;ve got blisters on my fingers!&rdquo;</h3>
										<p>..as the man once said.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/" title="Read 'Stupid WordPress Tricks' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/07/21/how-to-generate-perfect-wordpress-title-tags-without-a-plugin/" title="How to Generate Perfect WordPress Title Tags without a Plugin (July 21, 2008)">How to Generate Perfect WordPress Title Tags without a Plugin</a></li>
					<li><a href="http://perishablepress.com/press/2008/08/04/two-column-horizontal-sequence-wordpress-post-order/" title="Horizontally Sequenced Display Order for WordPress Posts in Two Columns (August 4, 2008)">Horizontally Sequenced Display Order for WordPress Posts in Two Columns</a></li>
					<li><a href="http://perishablepress.com/press/2008/08/25/conditional-tags-secrets-wordpress-templates/" title="Secrets of the Conditional Tag Revealed: How to Gain More Control Over Your WP Templates (August 25, 2008)">Secrets of the Conditional Tag Revealed: How to Gain More Control Over Your WP Templates</a></li>
					<li><a href="http://perishablepress.com/press/2008/11/16/wordpress-loop-separate-any-odd-even-posts-any-category/" title="Fruit Loop: Separate any Number of Odd and Even Posts from any Category in WordPress (November 16, 2008)">Fruit Loop: Separate any Number of Odd and Even Posts from any Category in WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2008/12/10/perfect-wordpress-title-tags-redux/" title="Perfect WordPress Title Tags Redux (December 10, 2008)">Perfect WordPress Title Tags Redux</a></li>
					<li><a href="http://perishablepress.com/press/2009/04/26/import-and-display-rss-feeds-in-wordpress/" title="Import and Display RSS Feeds in WordPress (April 26, 2009)">Import and Display RSS Feeds in WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/28/display-total-number-of-posts/" title="Display the Total Number of WordPress Posts, Comments, and Categories (August 28, 2006)">Display the Total Number of WordPress Posts, Comments, and Categories</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=t-GFOKxPYOA:PpwiYvFFLTw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=t-GFOKxPYOA:PpwiYvFFLTw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=t-GFOKxPYOA:PpwiYvFFLTw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=t-GFOKxPYOA:PpwiYvFFLTw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=t-GFOKxPYOA:PpwiYvFFLTw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=t-GFOKxPYOA:PpwiYvFFLTw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=t-GFOKxPYOA:PpwiYvFFLTw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=t-GFOKxPYOA:PpwiYvFFLTw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=t-GFOKxPYOA:PpwiYvFFLTw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=t-GFOKxPYOA:PpwiYvFFLTw:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=t-GFOKxPYOA:PpwiYvFFLTw:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/12/01/stupid-wordpress-tricks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting Serious with a New Design</title>
		<link>http://perishablepress.com/press/2009/11/30/getting-serious-with-a-new-design/</link>
		<comments>http://perishablepress.com/press/2009/11/30/getting-serious-with-a-new-design/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 16:17:34 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Perishable]]></category>

		<category><![CDATA[news]]></category>

		<category><![CDATA[redesign]]></category>

		<category><![CDATA[themes]]></category>

		<category><![CDATA[update]]></category>

		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/11/30/getting-serious-with-a-new-design/</guid>
		<description><![CDATA[										New design in effect at Perishable Press. It&#8217;s sort of a hybrid between some of the things I like about the Quintessential theme and some of the best parts of the subsequent Requiem theme. So this new theme is named Serious because it represents a renewed commitment to design, blogging, and everything I love about [...]]]></description>
			<content:encoded><![CDATA[										<p>New design in effect at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>. It&rsquo;s sort of a hybrid between some of the things I like about the <a href="http://perishablepress.com/press/index.php?wptheme=Quintessential" title="Skin the site with 'Quintessential' theme (opens new tab)" rel="external">Quintessential theme</a> and some of the best parts of the subsequent <a href="http://perishablepress.com/press/index.php?wptheme=Requiem" title="Skin the site with 'Requiem' theme (opens new tab)" rel="external">Requiem theme</a>. So this new theme is named <a href="http://perishablepress.com/press/index.php?wptheme=Serious" title="Skin the site with 'Serious' theme (opens new tab)" rel="external">Serious</a> because it represents a renewed commitment to design, blogging, and everything I love about working on the Web. While I have everything fresh in my mind, here are some of the highlights of the latest incarnation of Perishable Press..</p>
										<h3>Focus on content</h3>
										<p>This is the primary motivation for this new design. My previous Quintessential theme was a colorful, psychedelic, post-modern crowd pleaser, but it was also entirely design-centric. It <strike>said</strike> screamed &ldquo;look at me,&rdquo; which was fun and all, but it&rsquo;s time to get <em>serious</em>, so to speak. With this new design, <strong>the focus remains on the content</strong>, with every aspect of typography, composition, and imagery working to unify and emphasize the high-quality content that I strive to create. As they say:</p>
										<blockquote><p>Good design doesn&rsquo;t say &ldquo;look at me,&rdquo; it says &ldquo;look at this.&rdquo;</p></blockquote>
										<h3>Sidebar or super-footer?</h3>
										<p>Why not <em>both.</em> I absolutely love single-column designs, but there is a certain practicality to having key information available right there next to the article. My Quintessential theme had hundreds of links tucked into the scrolling sidebar panels, and the following Requiem theme went in the opposite direction with only a footer menu and no sidebar at all. With Serious, I wanted to combine the best of both worlds and went with a sidebar for on-site stuff and super-footer for the social-media, friends, and projects stuff.</p>
										<h3>Advertisements?</h3>
										<p>I gave this one a lot of thought. This is the fourth year of Perishable Press and the 19th redesign, and I have never put <em>any</em> advertisements on the site. I think there are pros and cons of doing so. The obvious benefit is the extra income, but the downside is being stuck with a bunch of uncontrollable material appearing on your site. The money is tempting, but for the time being I have decided to retain my commercial-free integrity.</p>
										<h3>New Logo</h3>
										<p>Perhaps the most significant change is the new logo. I tried like the dickens to get that old Rez-font sun logo to fit the bill, but it just wouldn&rsquo;t gel. After some experimentation, I decided to roll with the triple dropped &ldquo;e&rdquo;s and half of the original sun icon. Way back in the days of pen-&amp;-ink drawings and percolated bong hits, the &ldquo;Perishable&rdquo; logo was frequently deployed with either dropped letter &ldquo;e&rdquo;s, backwards &ldquo;e&rdquo;s, or both. Seeing that classic format here on the site is a good reminder.</p>
										<h3>Nice &lsquo;n clean</h3>
										<p>One thing that I really wanted to do with this new design is clean things up and stay focused on what&rsquo;s truly important. Rather than trying to link to <em>everything</em> from the sidebar and footer, I consolidated conceptually related information into second-level pages and just linked to them instead. A good example of this is the site <a href="http://perishablepress.com/press/dungeon/" title="Welcome to Dungeon!">Dungeon</a>, where I give props to friends and software, share my accomplishments, reveal site statistics, and so on. Having all of this stuff on a single page eliminates clutter from the sidebar and footer. There&rsquo;s just <em>too</em> much content on a site this size to connect it all at the top-level of the hierarchy. I think this new theme makes great strides toward a more streamlined organization.</p>
										<h3>Color palette</h3>
										<p>With its white-text on dark-background, the previously active theme (Quintessential) fried a lot of retinas. There is a way to do light on dark, but it&rsquo;s a delicate balance of hue and contrast. Even just a few shades off and it&rsquo;s gonna get painful &#8212; tracers, ghost text, and bleeding eyeballs in general. After much calculation and testing, I think I conjured up a color palette that&rsquo;s much easier on the eyes. Using off-white text against rich tones of brown softens the edge without sacrificing contrast. So the readability is improved, and by sticking with only a handful of colors, the design conveys a sense of unification and harmony.</p>
										<h3>Custom fonts</h3>
										<p>The typography connoisseur will immediately recognize the use of <a href="http://www.josbuivenga.demon.nl/museo.html">Museo</a> for headings and Monaco for <code>&lt;pre&gt;</code> and inline code snippets. This is accomplished by the increasingly supported <code>@font-face</code> <acronym title="Cascading Style Sheets">CSS</acronym> selector, which makes it possible to display custom fonts directly through the stylesheet. No JavaScript required, but support is either hit or miss as newer versions of popular browsers continue to embrace the functionality. Personally, I think the Museo font looks great. It&rsquo;s been used on a number of other highly popular sites (including <a href="http://css-tricks.com/" title="CSS-Tricks">CSS-Tricks</a>), and I predict that it will catch on like wildfire and become the next big font trend.</p>
										<h3>Uniform link styles</h3>
										<p>I think it is important that hyperlinks <em>look</em> like actual links. They should be easy to recognize as links, look uniform in appearance, and exhibit the same behavior. As obvious and simple as this sounds, I always find it challenging to accomplish in my designs. Many of my older themes fail in this regard, but the minimalist Requiem theme goes above and beyond with uniform links that are <em>actually</em> blue. The new Serious theme doesn&rsquo;t go quite <em>that</em> far, but a simple look around shows that the links are definitely uniform.</p>
										<h3>Other bells &amp; whistles</h3>
										<p>Instead of going on and on, I&rsquo;ll try to summarize some of the cool bells &amp; whistles:</p>
										<ul>
										<li>Lots of progressively enhanced visual effects for the header, sidebar, links, code et al</li>
										<li>Super-cool <code>&lt;pre&gt;</code> code areas. Following <a href="http://perishablepress.com/press/2009/11/09/perfect-pre-tags/" title="Perfect Pre Tags">my own advice</a>, I pimped out the pre code with <a href="http://digwp.com/2009/07/making-an-expanding-code-box/" title="Making an Expanding Code Box">auto-expanding boxes</a>, hover effects, and better <acronym title="Utter Rubbish">IE</acronym> support.</li>
										<li>Collapsible Twitter updates with cookies to remember user preference</li>
										<li>Imported latest images from my graphix archive, <a href="http://perishable.biz/" title="Graphical Archives of Jeff Starr">Perishable.biz</a></li>
										<li>Drop caps (in most browsers) on the first paragraph of each article</li>
										<li>Fancy tooltips courtesy of the awesome <a href="http://craigsworks.com/projects/qtip/">qTip jQuery plugin</a></li>
										<li>Toggling informational panels to keep everything nice and tidy</li>
										<li><acronym title="Cascading Style Sheets">CSS</acronym>-based graphical indication for external links</li>
										<li>Auto-clear/restore input fields to make it all sweet</li>
										</ul>
										<p>Plus all sorts of other stuff that I probably shouldn&rsquo;t have bothered with, but it is so much fun playing with <acronym title="Cascading Style Sheets">CSS</acronym> and jQuery that I just couldn&rsquo;t resist&nbsp;;)</p>
										<h3>Performance</h3>
										<p>Of course, all of this fancy-pants design stuff would be pointless if site performance prevents people from participating. To <a href="http://perishablepress.com/press/tag/performance/" title="Explore the 'Performance' Archive here at Perishable Press">optimize performance</a> for the Serious theme, I tried to do as much client-side and server-side optimization as possible, including everything from image sprites and minified code to content compression and expires headers. You can check the results for yourself using YSlow or similar.</p>
										<h3>Cross-browser consistency and validation</h3>
										<p>The most painful part of any decent web design is getting them to look good in as many browsers as possible. To accomplish this, I relied heavily on multiple computers, Adobe Browsershots (which didn&rsquo;t work that great), and the always helpful <a href="http://chriscoyier.net/" title="Chris Coyier's personal site">Chris Coyier</a>. Overall, I think most of the bugs have been ironed out, but definitely let me know if you see something that looks off, broken or whatever.</p>
										<p>As for validation, well I really haven&rsquo;t bothered with it so far. After the theme is active for awhile, I might check a few pages, but honestly I stopped caring about validation once I realized that I don&rsquo;t really need it. Not to sound boastful, but when you can code a site like this with Notepad, you don&rsquo;t need the <acronym title="World Wide Web Consortium">W3C</acronym> to hold your hand along the way. Sure validation is great for double-checking your code, but if everything is doing what you want, there is no need to waste too much time trying to ensure strict obedience to every obscure rule in the book.</p>
										<h3>Feedback appreciated</h3>
										<p>Let me know what you think of the design and please <a href="http://perishablepress.com/" title="Contact Jeff Starr">contact me</a> or leave a comment if you spot anything that looks out of place. Thanks!&nbsp;:)</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/11/30/getting-serious-with-a-new-design/" title="Read 'Getting Serious with a New Design' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/10/01/perishable-press-redesign-2008/" title="Perishable Press Redesign 2008 (October 1, 2008)">Perishable Press Redesign 2008</a></li>
					<li><a href="http://perishablepress.com/press/2009/01/19/time-for-a-new-design/" title="Time for a New Design? (January 19, 2009)">Time for a New Design?</a></li>
					<li><a href="http://perishablepress.com/press/2009/01/27/quintessential-reversion/" title="Quintessential Reversion (January 27, 2009)">Quintessential Reversion</a></li>
					<li><a href="http://perishablepress.com/press/2007/10/21/rocking-the-boat/" title="Rocking the Boat (October 21, 2007)">Rocking the Boat</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/05/site-overhaul-phase-two-switching-default-theme/" title="Site Overhaul, Phase Two: Switching Default Theme (November 5, 2007)">Site Overhaul, Phase Two: Switching Default Theme</a></li>
					<li><a href="http://perishablepress.com/press/2008/03/03/perishable-news-site-upgrades-upcoming-interview-and-pagerank-update/" title="Perishable News: Site Upgrades, Upcoming Interview, and PageRank Update (March 3, 2008)">Perishable News: Site Upgrades, Upcoming Interview, and PageRank Update</a></li>
					<li><a href="http://perishablepress.com/press/2008/04/06/perishable-press-theme-renovations-complete/" title="Perishable Press Theme Renovations Complete (April 6, 2008)">Perishable Press Theme Renovations Complete</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=bdqTQhfFX3o:HXs3tlPb7Qo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=bdqTQhfFX3o:HXs3tlPb7Qo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=bdqTQhfFX3o:HXs3tlPb7Qo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=bdqTQhfFX3o:HXs3tlPb7Qo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=bdqTQhfFX3o:HXs3tlPb7Qo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=bdqTQhfFX3o:HXs3tlPb7Qo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=bdqTQhfFX3o:HXs3tlPb7Qo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=bdqTQhfFX3o:HXs3tlPb7Qo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=bdqTQhfFX3o:HXs3tlPb7Qo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=bdqTQhfFX3o:HXs3tlPb7Qo:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=bdqTQhfFX3o:HXs3tlPb7Qo:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/11/30/getting-serious-with-a-new-design/feed/</wfw:commentRss>
		</item>
		<item>
		<title>It’s Here: Digging into WordPress!</title>
		<link>http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/</link>
		<comments>http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:46:57 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[books]]></category>

		<category><![CDATA[DiW]]></category>

		<category><![CDATA[news]]></category>

		<category><![CDATA[publishing]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/</guid>
		<description><![CDATA[										 After nearly a year of production, Chris Coyier and I are stoked to announce our new book: Digging into WordPress! It&#8217;s nine jam-packed chapters (400 pages!) stuffed with everything you need to take your WordPress skills to the next level and really get the most out of WordPress. We take you through everything &#8212; [...]]]></description>
			<content:encoded><![CDATA[										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/DIW-125-1.png" alt="[ Digging into WordPress ]" /> After nearly a year of production, Chris Coyier and I are stoked to announce our new book: <a href="http://digwp.com/book/" title="Get 'em while they're hot!">Digging into WordPress</a>! It&rsquo;s nine jam-packed chapters (400 pages!) stuffed with everything you need to take your WordPress skills to the <em>next level</em> and really get the <em>most</em> out of WordPress. We take you through everything &#8212; from setting up for success and creating the perfect theme to optimizing performance and tightening security, Digging into WordPress <a href="http://digwp.com/book/testimonials/" title="Read what others are saying about Digging into WordPress">delivers the goods</a>. You&rsquo;ll learn how to harness the full potential of WordPress with all of the tips, tricks, and code you need to make it happen.</p>
										<h3>Special 10-Day Discount</h3>
										<p>For the next ten days, use coupon code <em>DIWPERISHABLE</em> to <strong>save $5 instantly</strong>. The book sells for $27, so with the coupon code you can grab it for a cool 22 bucks. This is a limited-time deal so take <em>advantage</em> and hook it up <em>now</em>. <a href="http://digwp.com/book/" title="Learn more / buy book">Go here to get the scoop and download the book</a>.</p>
										<h3>Living, Breathing PDF Format..</h3>
										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/DIW-125-4.png" alt="[ Learn WordPress Now ]" /> The <acronym title="Portable Document Format">PDF</acronym> version of the book is awesome because we will be able to update and expand it indefinitely. As WordPress changes, the book will evolve with new information, techniques, and code. This is why we call the <acronym title="Digging into WordPress">DiW</acronym> <acronym title="Portable Document Format">PDF</acronym> a &ldquo;living, breathing document&rdquo; &#8212; it will <em>grow</em> with WordPress, and will be updated and improved periodically well into the future.</p>
										<h3>..and a Printed Version Coming Soon</h3>
										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/DIW-125-2.png" alt="[ *Really* Learn It. ]" /> In addition to the <acronym title="Portable Document Format">PDF</acronym>, a printed version of Digging into WordPress will also be available sometime in the near future. Everyone who purchases the <acronym title="Portable Document Format">PDF</acronym> version of the book will receive a fair discount on the printed book when it&rsquo;s released. The printed book will be awesome, but the <acronym title="Portable Document Format">PDF</acronym> is ideal because it&rsquo;s easy to search, easy to zoom, easy to transport, and easy to copy &amp; paste code. It even features actual hyperlinks that make it easy to jump to linked resources (and there&rsquo;s a <em>zillion</em> of &lsquo;em!).</p>
										<h3>Lifetime Subscription</h3>
										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/DIW-125-3.png" alt="[ Take Your WordPress Skills to the Next Level ]" /> All <acronym title="Digging into WordPress">DiW</acronym> customers automatically get a lifetime subscription to all future updates and new versions of the book. Chris and I are <a href="http://digwp.com/" title="Digging into WordPress">crazy about WordPress</a> and plan on sharing our experience as time goes on. There are a few other WordPress books out there, but this one won&rsquo;t get old and outdated as WordPress evolves. Whenever we update the book and release a new version, we&rsquo;ll send you a link for a free download &#8212; <em>fresh</em> WordPress with the <em>click</em> of a button.</p>
										<h3>Affiliate Program</h3>
										<p>To help promote the book, we are also providing an <a href="http://digwp.com/book/affiliate/" title="DiW Affiliate Program">affiliate program</a>. If you like the book and want to help sell it, you can earn money doing so. For the <acronym title="Portable Document Format">PDF</acronym> version of the book, we avoid the substantial costs typically involved with the printing, handling and shipping of a physical product. <strong>So, we are offering an affiliate commission of 50% for all affiliate sales.</strong> You are doing the legwork, and we appreciate it. <a href="http://digwp.com/book/affiliate/" title="DiW Affiliate Program">Learn more here</a>.</p>
										<h3>Thank You</h3>
										<p><strong>Thanks in advance</strong> to anybody who picks up a copy. It goes a long way toward helping both Chris and I create all the <a href="http://css-tricks.com/" title="CSS-Tricks">other</a> <a href="http://perishablepress.com/" title="Perishable Press">free</a> <a href="http://digwp.com/" title="Digging into WordPress">content</a> we love to share.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/digging-into-wordpress_01.jpg" alt="[ Digging into WordPress ]" /><br /><small><a style="border: 0 none;" href="http://digwp.com/book/" title="Get the most out of WordPress!">Digging into WordPress &#8212; packed with yummy WordPress goodness!</a></small></p>
										<h3>Sneak peak..</h3>
										<p>You can <a href="http://digwp.com/book-demo/Digging-Into-WP-DEMO.pdf" title="Download DiW Demo PDF">download a demo of the book here</a>. The demo features the Table of Contents and part of Chapter 3. Here&rsquo;s a little collage showing the general look and feel of what&rsquo;s inside the book..</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/digging-into-wordpress_00.jpg" alt="[ DiW Sneak Peak ]" /><br /><small><a style="border: 0 none;" href="http://digwp.com/book/" title="Take your WordPress Skills to the Next Level">Digging into WordPress &#8212; 9 Chapters, 400 Pages, and <em>tons</em> of great tips, tricks, and code</a></small></p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/" title="Read 'It&#8217;s Here: Digging into WordPress!' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2009/06/16/digging-into-wordpress/" title="Digging Into WordPress (June 16, 2009)">Digging Into WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2009/12/29/print-version-digging-into-wordpress/" title="Print Version of Digging into WordPress is Here! (December 29, 2009)">Print Version of Digging into WordPress is Here!</a></li>
					<li><a href="http://perishablepress.com/press/2010/01/05/book-giveaway-digging-into-wordpress/" title="Book Giveaway: Print Version of Digging into WordPress (January 5, 2010)">Book Giveaway: Print Version of Digging into WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2010/01/11/book-giveaway-winner/" title="Book Giveaway Winner! (January 11, 2010)">Book Giveaway Winner!</a></li>
					<li><a href="http://perishablepress.com/press/2009/02/15/book-review-wordpress-for-business-bloggers/" title="Book Review: WordPress for Business Bloggers (February 15, 2009)">Book Review: WordPress for Business Bloggers</a></li>
					<li><a href="http://perishablepress.com/press/2009/04/15/looking-for-a-publisher/" title="Looking for a Publisher (April 15, 2009)">Looking for a Publisher</a></li>
					<li><a href="http://perishablepress.com/press/2006/11/12/perishable-press-upgrade-to-wordpress-205/" title="Perishable Press Upgrade to WordPress 2.0.5 (November 12, 2006)">Perishable Press Upgrade to WordPress 2.0.5</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:VKEmQ8ozCmE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:VKEmQ8ozCmE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=4QEFGpwQ8e0:VKEmQ8ozCmE:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:VKEmQ8ozCmE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=4QEFGpwQ8e0:VKEmQ8ozCmE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:VKEmQ8ozCmE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=4QEFGpwQ8e0:VKEmQ8ozCmE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:VKEmQ8ozCmE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=4QEFGpwQ8e0:VKEmQ8ozCmE:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:VKEmQ8ozCmE:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:VKEmQ8ozCmE:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Perfect Pre Tags</title>
		<link>http://perishablepress.com/press/2009/11/09/perfect-pre-tags/</link>
		<comments>http://perishablepress.com/press/2009/11/09/perfect-pre-tags/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 16:15:36 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[Structure]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[elements]]></category>

		<category><![CDATA[format]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[tags]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/11/09/perfect-pre-tags/</guid>
		<description><![CDATA[										If you operate a website that features lots of code examples, you know how important it is to spend some quality time styling the &#60;pre&#62; element. When left unstyled, wild &#60;pre&#62; tags will mangle your preformatted content and destroy your site&#8217;s layout. Different browsers treat the &#60;pre&#62; tag quite differently, varying greatly in their default [...]]]></description>
			<content:encoded><![CDATA[										<p>If you operate a website that features lots of code examples, you know how important it is to spend some quality time styling the <code>&lt;pre&gt;</code> element. When left unstyled, wild <code>&lt;pre&gt;</code> tags will mangle your preformatted content and destroy your site&rsquo;s layout. Different browsers treat the <code>&lt;pre&gt;</code> tag quite differently, varying greatly in their default handling of font-sizing, scrollbar-rendering, and word-wrapping. Indeed, getting your preformatted code to look consistent, usable, and stylish across browsers is no easy task, but it certainly can be done. In this article, I&rsquo;ll show you everything you need to create perfect <code>&lt;pre&gt;</code> tags.</p>
										<h3>First thangs first</h3>
										<p>Before getting into it, let&rsquo;s take a moment to ensure we&rsquo;re all on the same page. The <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> <code>&lt;pre&gt;</code> element is used to display preformatted text, code, or just about anything else. <code>pre</code> tags are ideal for multiple lines of code or text that need to retain character spacing, display unformatted characters, keep inherent line breaks, and so on. </p>
										<p>Let&rsquo;s say we have the following code that we want to include in a web page:</p>
										<pre><code>&lt;?php function shortLink($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" =&gt; 'http://' // default URL
	), $atts));
	return '&lt;a href="'.$href.'"&gt;'.$content.'&lt;/a&gt;';
}
add_shortcode('link', 'shortLink'); ?&gt;</code></pre>
										<p>After converting the &ldquo;<code>&lt;</code>&rdquo; characters to their encoded equivalents, &ldquo;<code>&amp;lt;</code>&rdquo;, we would wrap the code in <code>&lt;pre&gt;</code> tags and get this in the browser:</p>
										<pre><code>&lt;?php function shortLink($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" =&gt; 'http://' // default URL
	), $atts));
	return '&lt;a href="'.$href.'"&gt;'.$content.'&lt;/a&gt;';
}
add_shortcode('link', 'shortLink'); ?&gt;</code></pre>
										<p>Looks pretty similar, eh? Notice that the line breaks, spacing, and unencoded characters (besides opening brackets) That&rsquo;s the whole point: the <code>&lt;pre&gt;</code> tag enables you to easily display raw chunks of source code, text (think poetry), and any other content that we don&rsquo;t want the browser to process. Now let&rsquo;s look at that same code when displayed <em>without</em> <code>&lt;pre&gt;</code> tags:</p>
										<p><?php function shortLink($atts, $content = null) {<br />
	extract(shortcode_atts(array(<br />
		"href" => &#8216;http://&#8217; // default URL<br />
	), $atts));<br />
	return &#8216;<a href="#">&#8216;.$content.&#8217;</a>&#8216;;<br />
}<br />
add_shortcode(&#8217;link&#8217;, &#8217;shortLink&#8217;); ?></p>
										<p>As you can see, when not wrapped in <code>&lt;pre&gt;</code> tags, code examples such as this are inaccurate and essentially useless. <code>&lt;pre&gt;</code> elements ensure that the content retains its &ldquo;natural&rdquo; format, which is crucial for displaying code, poetry, equations, and other types of specialized content.</p>
										<p>Also, note that the <code>&lt;code&gt;</code> element is frequently used in conjunction with the <code>&lt;pre&gt;</code> tag when using syntax highlighters and formatting plugins such as the excellent <a href="http://priyadi.net/archives/2005/09/27/wordpress-plugin-code-autoescape/" title="Code Auto Escape">Code Auto Escape</a>. For example, here at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>, all multi-line code examples are wrapped with <code>&lt;pre&gt;&lt;code&gt;</code> and then auto-escaped using the Auto Escape plugin, which automatically escapes <em>all</em> characters within <code>&lt;pre&gt;</code> elements, eliminating the need to manually convert, say, opening brackets to their encoded equivalents. Many other syntax highlighters and code-formatting plugins also provide this functionality, greatly facilitating the post-writing process. Such tools help you streamline production and improve display of your preformatted content.</p>
										<p>One last thing about the <code>&lt;pre&gt;</code> tag before we dive into the good stuff. You should keep in mind that <code>&lt;pre&gt;</code> tags are used for displaying <strong>blocks</strong> of preformatted characters. That is, regardless of how many lines of text or code you use, the <code>&lt;pre&gt;</code> tag is a block-level element and will display its content as such. Conversely, the <code>&lt;code&gt;</code> tag is an <strong>inline</strong> element that is perfect for displaying individual words, characters, and lines of preformatted text <em>within</em> a block-level element. For example, I use the <code>&lt;code&gt;</code> tag all the time &#8212; just check out the source code of the previous couple of sentences to see what I mean.</p>
										<h3>Displaying preformatted content &amp; dealing with overflow</h3>
										<h4>Default behavior: horizontal scrollbars</h4>
										<p>One of the biggest challenges to displaying preformatted content using the <code>&lt;pre&gt;</code> tag is dealing with continuous strings of characters such as <acronym title="Uniform Resource Locator">URL</acronym>s and long chunks of code. By default, the <code>&lt;pre&gt;</code> element handles this by stretching to fit its content. Assuming that no widths have been specified in the <acronym title="Cascading Style Sheets">CSS</acronym>, the <code>&lt;pre&gt;</code> element will expand in length to accomodate its longest line of content. Interesting, but not very practical in most design scenarios. As soon as a constraining width is applied, the <code>&lt;pre&gt;</code> element uses a horizontal scrollbar to accomodate any content that doesn&rsquo;t &ldquo;fit&rdquo; within the display area. This default behavior is deployed in the stylesheet like this:</p>
										<pre><code>pre {
	overflow: auto;
	width: 500px;
	}</code></pre>
										<p>This is a commonly seen way of dealing with oversized <code>&lt;pre&gt;</code> content. It&rsquo;s fast, easy, and effective. Even so, not everyone likes to scroll..</p>
										<h4>Word-wrapping</h4>
										<p>Instead of using a scrollbar to display long lines of preformatted text, some prefer to wrap the content within the display area of the <code>&lt;pre&gt;</code> element. When we wrap preformatted content, any lines that extend beyond the specified width will wrap to the next line. As simple as this sounds, some browsers have real problems when it comes to continuous strings of text such as long <acronym title="Uniform Resource Locator">URL</acronym>s. Many browsers are unable to break up continuous lines of text unless specifically instructed to do so. Fortunately this is possible using a crefully crafted set of <acronym title="Cascading Style Sheets">CSS</acronym> directives.</p>
										<p>To enable word-wrapping for your <code>&lt;pre&gt;</code> content, use the following slice of <acronym title="Cascading Style Sheets">CSS</acronym> and edit the first directive to set the desired width:</p>
										<pre><code>pre {
	width: 500px;                          /* specify width  */
	white-space: pre-wrap;                 /* CSS3 browsers  */
	white-space: -moz-pre-wrap !important; /* 1999+ Mozilla  */
	white-space: -pre-wrap;                /* Opera 4 thru 6 */
	white-space: -o-pre-wrap;              /* Opera 7 and up */
	word-wrap: break-word;                 /* IE 5.5+ and up */
	/* overflow-x: auto; */                /* Firefox 2 only */
	/* width: 99%; */		       /* only if needed */
	}</code></pre>
										<p>Once in place, this code will force your <code>&lt;pre&gt;</code> areas to stay at 500 pixels wide. If any continuous lines extend beyond this width, they will be broken and wrapped accordingly.</p>
										<h4>Auto-expanding code box with CSS</h4>
										<p>If word-wrapping isn&rsquo;t for you, you may want to implement some auto-expansion functionality. Using a small snippet of <acronym title="Cascading Style Sheets">CSS</acronym>, it is possible to style your <code>&lt;pre&gt;</code> tags such that they magically expand whenever the user hovers their mouse. So, for example, your <code>&lt;pre&gt;</code> areas would display normally at 500pixels in width, but as soon as the user hovers their cursor over the area, it would instantly expand to a larger width, say, 700 pixels.</p>
										<p>Setting this up is easy. Just include the following <acronym title="Cascading Style Sheets">CSS</acronym> in your stylesheet and enjoy the results:</p>
										<pre><code>pre {
	overflow: auto;
	width: 500px;
	}
pre:hover {
	position: relative;
	width: 700px;
	z-index: 99;
	}</code></pre>
										<p>Of course, you will want edit the <code>width</code> values according to your needs and customize your <code>&lt;pre&gt;</code> and hover styles to look all sweet. You know.</p>
										<p>There are some pros and cons to this method. Here are some of the pros:</p>
										<ul>
										<li>It works great without requiring any JavaScript.</li>
										<li>Scrollbars appear only when the box is not expanded.</li>
										<li>The boxes expand instantly &#8212; no waiting required.</li>
										<li>Works fine even without an inner <code>&lt;code&gt;</code> wrapper.</li>
										</ul>
										<p>..and of course some of the cons:</p>
										<ul>
										<li>All <code>&lt;pre&gt;</code> tags expand even if it&rsquo;s not necessary (i.e., the code fits)</li>
										<li>The sudden display change may disorient/confuse newer web users.</li>
										<li>Expanding box may interfere with other page elements.</li>
										<li>Even after expansion, the <code>&lt;pre&gt;</code> are may still require horizontal scrollbars to see all of the content.</li>
										</ul>
										<h4>Auto-expanding code box with jQuery et al</h4>
										<p>The <acronym title="Cascading Style Sheets">CSS</acronym> expanding-box method works nice, but it&rsquo;s a bit choppy &#8212; upon hover, it&rsquo;s like, BAM &#8212; suddenly you&rsquo;re staring at a full-size code box. Using a little bit of jQuery, we can create a much smoother <a href="http://digwp.com/2009/07/making-an-expanding-code-box/" title="Making an Expanding Code Box">expanding code box</a>, as originally shared by Chris Coyier at <a href="http://digwp.com/" title="Get the most out of WordPress!">Digging into WordPress</a>.</p>
										<p>The jQuery method is an improvement over the <acronym title="Cascading Style Sheets">CSS</acronym> method, behaving more elegantly:</p>
										<ul>
										<li>Expands only when hovered over</li>
										<li>Expands only as wide as necessary</li>
										<li>Expands with some nice animation</li>
										</ul>
										<p>To implement, begin by styling the <code>&lt;pre&gt;</code> element with a little <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>pre {
	overflow: auto;
	width: 500px; 
	}</code></pre>
										<p>This will prepare the <code>&lt;pre&gt;</code> element for the following JavaScript:</p>
										<pre><code>$(function(){
	$("pre").hover(function() {
		var codeInnerWidth = $("code", this).width() + 10;
		if (codeInnerWidth &gt; 500) {
			$(this).stop(true, false).css({zIndex:"99",position:"relative",overflow:"hidden"}).animate({width:codeInnerWidth+"px"});
		}
	}, function() {
		$(this).stop(true, false).animate({width:500});
	});
});</code></pre>
										<p>And that&rsquo;s pretty much it. You&rsquo;ll want to customize the <acronym title="Cascading Style Sheets">CSS</acronym> and jQuery to fit your needs, but the main thing is getting all of the widths to match up (both in the <acronym title="Cascading Style Sheets">CSS</acronym> and JavaScript). When JavaScript is unavailable on the user&rsquo;s browser, this method degrades gracefully to default <code>&lt;pre&gt;</code> elements with auto-scrollbars.</p>
										<p>As discussed at Digging into WordPress, this method requires that your preformatted content is wrapped in both <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> tags. For complete information, check out the <a href="http://digwp.com/2009/07/making-an-expanding-code-box/" title="Making an Expanding Code Box">the original article</a>.</p>
										<h3>Whipping scrollbars into shape</h3>
										<h4>Vertical scrollbars, height, and Internet Explorer</h4>
										<p>If you do decide to use scrollbars to display overflow content, you will discover many inconsistencies across browsers, especially (surprise surprise) Internet Exploder. The first thing to understand is that, on standards-compliant browsers (i.e., anything other than IE) <strong>vertical</strong> scrollbars will only appear if an explicit <code>height</code> is specified for the <code>&lt;pre&gt;</code> element. If it is, vertical scrollbars will appear whenever the preformatted content contains more lines than is viewable within the specified height.</p>
										<p>Why is this important? Because it makes eliminating vertical scrollbars rather easy. As a general rule of thumb, I never specify heights for preformatted content, but there are situations where you might want to do so. </p>
										<p>As for our &lsquo;ol friend <acronym title="Internet Explorer">IE</acronym>, you are pretty much going to get vertical scrollbars regardless of whether or not you declare a height. They just appear on their own. Like friends of that squatter you mistakenly let stay with you for awhile.</p>
										<p>Fortunately, there are effective ways to exterminate those stinky vertical scrollbars in <acronym title="Internet Explorer">IE</acronym>. Here is the method I use on many of my sites:</p>
										<pre><code>/* no vertical scrollbars for standards-compliant browsers */
pre {
	overflow: auto; 
	width: 500px;
	}
/* no vertical scrollbars for IE 7 */
*:first-child+html pre {
	padding-bottom: 20px;
	overflow-y: hidden;
	overflow: visible;
	overflow-x: auto; 
	}
/* no vertical scrollbars for IE 6 */
* html pre { 
	padding-bottom: 20px;
	overflow: visible;
	overflow-x: auto;
	}</code></pre>
										<p>That code is pretty much plug-n-play with only the essentials, but you will want to customize the <code>width</code> in the first declaration block and add other styles as desired. What&rsquo;s happening with this code? Glad you axed. Lemme break it down:</p>
										<ol>
										<li><strong>first block</strong> &#8212; sets default scrolling for standards-compliant browsers; no vertical scrollbars unless explicit <code>height</code> is set.</li>
										<li><strong>second block</strong> &#8212; hack for IE 7 that removes the vertical scrollbar and adds a bit of padding to make room for any <em>horizontal</em> scrollbar that might be present.</li>
										<li><strong>third block</strong> &#8212; hack for IE 6 that removes the vertical scrollbar and also adds some padding.</li>
										</ol>
										<p>Of course, rather than using unsightly <acronym title="Cascading Style Sheets">CSS</acronym> hacks for <acronym title="Internet Explorer">IE</acronym>, it&rsquo;s best practice to summon them via <a href="http://perishablepress.com/press/2007/07/18/wrapping-your-head-around-downlevel-conditional-comments/" title="Wrapping Your Head around Downlevel Conditional Comments">conditional comments</a>. Once in place, this code will neutralize and eliminate those nasty vertical scrollbars in <acronym title="Internet Explorer">IE</acronym> and provide some extra bottom-padding to make room for horizontal scrollbars when they appear. This code is effective, but the additional padding is not needed when the content fits within the <code>&lt;pre&gt;</code> area and the horizontal scrollbar does not appear, resulting in an awkward blank line. Fortunately we can turn to JavaScript to account for this dynamic display property.</p>
										<h4>Fixing IE&rsquo;s funky inside scrollbars with JavaScript</h4>
										<p>&ldquo;<acronym title="Internet Explorer">IE</acronym> is <em>so</em> bad..&rdquo; &#8212; <em>how</em> bad is it? It renders horizontal <code>&lt;pre&gt;</code> scrollbars on the <strong>inside</strong> of the element. This sucks because it interferes with content, pushes everything up about 20 pixels, and invokes display of the unnecessary vertical scrollbar.</p>
										<p>We saw how to remedy this display deficiency using <acronym title="Cascading Style Sheets">CSS</acronym> in the previous section, but it wasn&rsquo;t quite ideal because of the extra bottom padding that is used to ensure content display when horizontal scrollbars appear. A better way to handle it is to use a little JavaScript to do the following:</p>
										<ol>
										<li>Check if the browser is Internet Explorer</li>
										<li>Find all <code>&lt;pre&gt;</code> elements with overflowing horizontal content</li>
										<li>Add 20 pixels of bottom padding to account for the horizontal scrollbar</li>
										<li>Remove the vertical scrollbar</li>
										</ol>
										<p>Thankfully, <a href="http://remysharp.com/2008/01/21/fixing-ie-overflow-problem/" title="Fixing IE overflow problem">Remy Sharp</a> delivers this functionality with the following slice of JavaScript:</p>
										<pre><code>window.onload = function () {  
	// only apply to IE  
	if (!/*@cc_on!@*/0) return;  
	// find every element to test  
	var all = document.getElementsByTagName('*'), i = all.length;  
	// fast reverse loop  
	while (i--) {    
		// if the scrollWidth (the real width) is greater than 
		// the visible width, then apply style changes    
		if (all[i].scrollWidth &gt; all[i].offsetWidth) {
			all[i].style['paddingBottom'] = '20px';
			all[i].style['overflowY'] = 'hidden';
		}
	}
};</code></pre>
										<p>..and as if that weren&rsquo;t cool enough, here&rsquo;s the same functionality via jQuery:</p>
										<pre><code>(function ($) {
	$.fn.fixOverflow = function () {
		if ($.browser.msie) {
			return this.each(function () {
				if (this.scrollWidth &gt; this.offsetWidth) {
					$(this).css({ 'padding-bottom' : '20px', 'overflow-y' : 'hidden' });
				}
			});
		} else {
			return this;
		}
	};
})(jQuery);
// usage
$('pre').fixOverflow().doOtherPlugin();</code></pre>
										<p>Either of these methods will do the job nicely, making <acronym title="Internet Explorer">IE</acronym> appear to display any horizontal scrollbars on the <em>outside</em> of the <code>&lt;pre&gt;</code> element.</p>
										<p>Interestingly enough, we can also execute this dynamic functionality from within the stylesheet and eliminate the need for any JavaScript. By using one of <acronym title="Internet Explorer">IE</acronym>&rsquo;s proprietary <code>expression</code> properties, we can include the following directly in our <acronym title="Internet Explorer">IE</acronym>-only stylesheet:</p>
										<pre><code>pre {
	width: 500px;
	overflow-x: auto;
	overflow-y: hidden;
	padding-bottom: expression(this.scrollWidth &gt; this.offsetWidth ? 20 : 0);
	}</code></pre>
										<p>Just specify the width and you&rsquo;re off to the races. For either of these dynamic methods (i.e., JavaScript, jQuery, or CSS expression), keep in mind that we are treating <em>horizontal</em> overflow issues when an explicit vertical height has not been specified.</p>
										<h3>Bonus tip: displaying a name for each class of <code>&lt;pre&gt;</code> text</h3>
										<p>If you have different types of preformatted content, you can output the name of each one within the content itself. To illustrate, let&rsquo;s say you provide different types of code snippets at your site, such as <acronym title="Cascading Style Sheets">CSS</acronym>, <acronym title="Hypertext Markup Language">HTML</acronym>, and <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>. By adding a class to an inner <code>&lt;code&gt;</code> element, you can combine <acronym title="Cascading Style Sheets">CSS</acronym>-2.1&rsquo;s attribute selector and <code>:after</code> pseudo-element selector to display the class name within the preformatted content area.</p>
										<pre><code>pre code[class]:after {
  content: 'highlight: ' attr(class);
  display: block; text-align: right;
  font-size: smaller;
  padding-top: 5px;
}</code></pre>
										<p>Then, you set up your preformatted code like so:</p>
										<pre><code>&lt;pre&gt;&lt;code class="CSS"&gt;</code></pre>
										<p>The class name you specify for each type of code block will then be displayed to the bottom-right of the preformatted content area. Shouts out to <a href="http://css-tricks.com/">Chris Coyier</a> for this awesome trick.</p>
										<h3>Styling preformatted content</h3>
										<p>Now that we know how to improve the physical properties of the <code>&lt;pre&gt;</code> element, let&rsquo;s wrap things up with a few ideas for styling the actual preformatted content.</p>
										<h4>Fonts</h4>
										<p>When styling your preformatted content, employ fonts suitable to its purpose. For example, if your site is mostly sporting code snippets, throw down with some tough monospace typography:</p>
										<ul>
										<li><code>monospace</code></li>
										<li><code>"Courier new", Courier, "Andale Mono", monospace</code></li>
										<li><code>Consolas, "Lucida Console", Monaco, monospace</code></li>
										<li><code>Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace</code></li>
										</ul>
										<p>To create the perfect monospace font stack, you really should be testing on as many different browsers as possible. Check different operating systems, browsers, zoom settings, and types of preformatted content. A couple of notes: <em>Courier</em> is an incredibly tight-looking font that, unfortunately, does not scale well on all browsers/systems. Particularly, there seems to be a lower-limit to the display size of the Courier font. Also, to get things looking right on both PC and Mac without all the fuss, simply declare &ldquo;<code>monospace</code>&rdquo; for your <code>&lt;pre&gt;</code> font and you&rsquo;ll get a great-looking font on both systems.</p>
										<h4>Borders</h4>
										<p>While maybe not beneficial to <em>every</em> block of preformatted text, a nice set of borders can really help accent and emphasize your content. Especially for code snippets, adding a border around the area can help users discern easily between it and the post content.</p>
										<p>The are many cool things that can be done with <code>&lt;pre&gt;</code> borders:</p>
										<ul>
										<li>Place a border on only one or two sides of the <code>&lt;pre&gt;</code> text</li>
										<li>Use varying widths and/or styles (e.g., dotted or custom image)</li>
										<li>Get all &ldquo;Web-2.0&rdquo; and <a href="http://perishablepress.com/press/2008/11/24/perfect-rounded-corners-with-css/" title="Perfect Rounded Corners with CSS">round your corners</a></li>
										</ul>
										<h4>Colors</h4>
										<p>Colors are another inspiring thing to play with when it comes to styling the presentation of your <code>&lt;pre&gt;</code> elements. You can color the text itself, the background, and the borders. Anything is possible here, I just wanted to point out that a good combination of colors for these different properties can really help your <code>&lt;pre&gt;</code> areas &ldquo;pop.&rdquo; Also fun to play with when choosing the perfect color combination is transparency, which might be used to let the background show through just a bit. Background images also present unlimited possibilities, such as adding a personal logo/icon or even a nice drop shadow for the upper/left border.</p>
										<h4>How I roll..</h4>
										<p>Last but not least, here is the template snippet that I use as a base for styling <code>&lt;pre&gt;</code> tags. After splicing this little snippet into my stylesheet, I proceed to tweak and fuss &lsquo;til everything&rsquo;s <em>just</em> right..</p>
										<pre><code>code, samp, kbd {
	font-family: "Courier New", Courier, monospace, sans-serif;
	text-align: left;
	color: #555;
	}
pre code {
	line-height: 1.6em;
	font-size: 11px;
	}
pre {
	padding: 0.1em 0.5em 0.3em 0.7em;
	border-left: 11px solid #ccc;
	margin: 1.7em 0 1.7em 0.3em;
	overflow: auto;
	width: 93%;
	}
/* target IE7 and IE6 */
*:first-child+html pre {
	padding-bottom: 2em;
	overflow-y: hidden;
	overflow: visible;
	overflow-x: auto; 
	}
* html pre { 
	padding-bottom: 2em;
	overflow: visible;
	overflow-x: auto;
	}</code></pre>
										<p>Rather than another long-winded diatribe exploring the manifold intricacies and subtleties of this particular stylistic strategy, I defer to your currently established comprehension of <acronym title="Cascading Style Sheets">CSS</acronym> and invite subsequent analysis of its constituent declarations. Or, in the parlance of the day: &ldquo;<em>it&rsquo;s plug-n-play, dude - I&rsquo;m outta here!!!</em>&rdquo;</p>
										<h3>Hungry for more</h3>
										<p>As mentioned, I post a lot of code here at Perishable Press. So much so, that I have become rather obsessed with the fine art of formatting and styling preformatted content. As <a href="http://twitter.com/perishable/status/5402269338" title="Lettin' em know">tweeted the other day</a>, I could spend all day just fussing over <code>&lt;pre&gt;</code> code. To me, it really is <em>that</em> important. In this article, I have shared many different techniques for creating perfect <code>&lt;pre&gt;</code> tags, but these methods are far from exhaustive. I am always on the lookout for new and useful ways to improve the appearance and functionality of my preformatted code examples, so if you happen to know any sweet tricks that I missed, share them and I will update the article with the method and link to your site.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2010PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/11/09/perfect-pre-tags/" title="Read 'Perfect Pre Tags' at Perishable Press">Perishable Press</a></p><p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Take your WordPress skills to the next level with <a href="http://digwp.com/book" title="Get the Book!">Digging into WordPress</a>!</p><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2006/08/21/a-complete-css-template-file/" title="A Complete CSS Template File (August 21, 2006)">A Complete CSS Template File</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/29/embed-flash-and-video-via-the-object-tag/" title="Embed Flash and Video via the object Tag (January 29, 2007)">Embed Flash and Video via the object Tag</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/12/prevent-javascript-elements-from-breaking-page-layout/" title="Prevent JavaScript Elements from Breaking Page Layout when Following Yahoo Performance Tip #6: Place Scripts at the Bottom (November 12, 2007)">Prevent JavaScript Elements from Breaking Page Layout when Following Yahoo Performance Tip #6: Place Scripts at the Bottom</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/29/optimize-convoluted-code-via-javascript/" title="Optimize Convoluted Code via JavaScript (August 29, 2006)">Optimize Convoluted Code via JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/30/xhtml-document-header-resource/" title="XHTML Document Header Resource (August 30, 2006)">XHTML Document Header Resource</a></li>
					<li><a href="http://perishablepress.com/press/2006/10/04/one-link-to-open-them-all/" title="One Link to Open Them All (October 4, 2006)">One Link to Open Them All</a></li>
					<li><a href="http://perishablepress.com/press/2006/12/04/auto-focus-form-elements-with-javascript/" title="Auto-Focus Form Elements with JavaScript (December 4, 2006)">Auto-Focus Form Elements with JavaScript</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:c622HmKNVhY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:c622HmKNVhY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=7lQdqHh83IA:c622HmKNVhY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:c622HmKNVhY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=7lQdqHh83IA:c622HmKNVhY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:c622HmKNVhY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=7lQdqHh83IA:c622HmKNVhY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:c622HmKNVhY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=7lQdqHh83IA:c622HmKNVhY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:c622HmKNVhY:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:c622HmKNVhY:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/11/09/perfect-pre-tags/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
