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

<channel>
	<title>Gavin Smith &#187; Solutions</title>
	<atom:link href="http://gavinsmith.me/category/solutions/feed/" rel="self" type="application/rss+xml" />
	<link>http://gavinsmith.me</link>
	<description>Code, findings, and irrelevant things</description>
	<lastBuildDate>Thu, 29 Sep 2011 19:32:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Forms: Inputs with initial values acting as labels and HTML5&#8242;s placeholder attribute</title>
		<link>http://gavinsmith.me/2011/06/forms-inputs-with-initial-values-acting-as-labels-and-html5s-placeholder-attribute/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=forms-inputs-with-initial-values-acting-as-labels-and-html5s-placeholder-attribute</link>
		<comments>http://gavinsmith.me/2011/06/forms-inputs-with-initial-values-acting-as-labels-and-html5s-placeholder-attribute/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 13:56:59 +0000</pubDate>
		<dc:creator>Gavin Smith</dc:creator>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://gavinsmith.me/?p=278</guid>
		<description><![CDATA[I&#8217;ll be brief. A few years ago, a trend started popping up whereby the label next to a text input (at the time most commonly search fields) would be removed, and instead the default value of the field would be its label. On focus, the input value would be blanked. The result was a cleaner [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be brief. A few years ago, a trend started popping up whereby the label next to a text input (at the time most commonly search fields) would be removed, and instead the default value of the field would be its label. On focus, the input value would be blanked. The result was a cleaner look and really no loss in usability (as well as no loss in accessibility so long as the developer takes care to put the label element in the DOM, but hide it).</p>
<p>The behaviour is common practice now, not only for single-field forms like search inputs, but entire ten-plus field information gathering forms. This is where the problem arrises. If you&#8217;re like me and tab between inputs (&#8216;fill in field, hit tab, fill in next field, hit tab, etc), it&#8217;s very easy to forget that you need to read the value (acting as a label) in the next field before tabbing into it &#8211; as soon as it has focus, you can no longer tell what you&#8217;re supposed to be inputting.</p>
<blockquote class="me"><p>The <code title="attr-input-placeholder"><a href="http://dev.w3.org/html5/spec/Overview.html#attr-input-placeholder">placeholder</a></code> attribute should not be used as an alternative to a <code><a href="http://dev.w3.org/html5/spec/Overview.html#the-label-element">label</a></code>. &#8211;HTML5 Draft Spec</p></blockquote>
<p>Even more recently, the HTML5 spec <a href="http://dev.w3.org/html5/spec/Overview.html#the-placeholder-attribute">introduced</a> the <code title="attr-input-placeholder">placeholder</code> element for inputs. Though the HTML5 spec advises against using a <code>placeholder</code> in place of a <code>label</code> element, it seems common practice to do so, and it tempting even for myself. This would be fine and dandy if it weren&#8217;t for the specific implementation of <code title="attr-input-placeholder">placeholder</code>&#8216;s behaviour in all major browsers: Exactly the same as we saw above, clear on focus. It leads to precisely the same problem as before, but this time natively instead of using a bit of JavaScript.</p>
<p>I&#8217;ve created what I believe is the ideal alternate behaviour multiple times in the past with a tiny bit of JavaScript and CSS:</p>
<ul>
<li>Position the label for an input directly below it with the same borders/padding so that the text lines up perfectly with what is typed in the input</li>
<li>Using JavaScript, bind a function on change for the input that checks to see what the value of the input is (after each keystroke), and if it&#8217;s anything other than blank, hide the label. If the label is hidden and the input is blank on change (you&#8217;ve deleted the contents of the input), show the label.</li>
</ul>
<p>I&#8217;m not completely sure whether the necessary change here is in the behaviour/intended use case of the <code>placeholder</code> attribute or in the code developers are writing in conjunction with their forms. Since it&#8217;s highly unlikely the HTML5 spec will dictate such a change at this point, I think the onus is on developers to be more careful with the aesthetics/usability line. If you implement the above properly and with care, you&#8217;ll have an accessible form that saves clutter and uses no additional markup.</p>
]]></content:encoded>
			<wfw:commentRss>http://gavinsmith.me/2011/06/forms-inputs-with-initial-values-acting-as-labels-and-html5s-placeholder-attribute/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Thought: Apple&#8217;s iMac rear-access ports</title>
		<link>http://gavinsmith.me/2011/03/thought-apples-imac-rear-access-ports/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=thought-apples-imac-rear-access-ports</link>
		<comments>http://gavinsmith.me/2011/03/thought-apples-imac-rear-access-ports/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 20:09:45 +0000</pubDate>
		<dc:creator>Gavin Smith</dc:creator>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[apple]]></category>

		<guid isPermaLink="false">http://gavinsmith.me/?p=239</guid>
		<description><![CDATA[I think the little game or feel-around that one must play in order to plug a pair of headphones into their iMac is Apple&#8217;s cruel little joke on its loving customers. Well, not really, but every time I need to plug something into that 3.5mm jack on the back of my iMac at the office, [...]]]></description>
			<content:encoded><![CDATA[<h3>I think the little game or feel-around that one must play in order to plug a pair of headphones into their iMac is Apple&#8217;s cruel little joke on its loving customers.</h3>
<p><a rel="attachment wp-att-242" href="http://gavinsmith.me/2011/03/thought-apples-imac-rear-access-ports/img_0114/"><img class="aligncenter size-large wp-image-242" title="IMG_0114" src="http://gavinsmith.me/wp-content/uploads/2011/03/IMG_0114-e1299874426906-560x322.jpg" alt="" width="560" height="322" /></a></p>
<p>Well, not really, but every time I need to plug something into that 3.5mm jack on the back of my iMac at the office, I can&#8217;t help but think about why it&#8217;s so difficult. I&#8217;ve pondered putting that port on the side, on the bottom, anything that helps access &#8211; but really, repositioning offers no ideal or substantially improved alternative.</p>
<p>While the same issue is present with the USB ports in the same area, they&#8217;re much more defined and can be felt out with relative ease. the issue with the 3.5mm port is that it&#8217;s so small, so challenging to accurately locate with your index finger, blindly. So I propose a simple solution (the best kind!). Recess it in a small (approx 1cm in diameter) dimple . Around the size of the tip of an average finger. This does two things: Makes the port easier to find blindly, and provides a very small targeting assist &#8211; the plug would slide in with relative ease even if aimed a little bit off.</p>
<p>How&#8217;s that, Steve?</p>
]]></content:encoded>
			<wfw:commentRss>http://gavinsmith.me/2011/03/thought-apples-imac-rear-access-ports/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adjusting the ‘Featured Image’ text for custom post types in WordPress</title>
		<link>http://gavinsmith.me/2010/12/adjusting-the-featured-image-text-for-custom-post-types-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=adjusting-the-featured-image-text-for-custom-post-types-in-wordpress</link>
		<comments>http://gavinsmith.me/2010/12/adjusting-the-featured-image-text-for-custom-post-types-in-wordpress/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 19:32:18 +0000</pubDate>
		<dc:creator>Gavin Smith</dc:creator>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[custom post types]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://gavinsmith.me/?p=67</guid>
		<description><![CDATA[Every time I create a custom post type that requires a thumbnail of some sort, it only make sense to use WordPress&#8217;s built in Featured Image functionality. Problem being, the default &#8216;Featured Image&#8217; meta box isn&#8217;t totally self-explanatory to your clients (and if you&#8217;re mildly OCD like me, it bothers you even for your own [...]]]></description>
			<content:encoded><![CDATA[<p>Every time I create a custom post type that requires a thumbnail of some sort, it only make sense to use WordPress&#8217;s built in Featured Image functionality. Problem being, the default &#8216;Featured Image&#8217; meta box isn&#8217;t totally self-explanatory to your clients (and if you&#8217;re mildly OCD like me, it bothers you even for your own site). Let&#8217;s change that copy on a per-post-type basis.<span id="more-67"></span></p>
<p>All that&#8217;s required is the use of the <code>gettext</code> hook. The below code, in your theme&#8217;s functions.php, will change both &#8216;Featured Image&#8217; to &#8216;Album Cover&#8217; and &#8216;Set a featured image&#8217; to &#8216;Select an image&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> album_featured_image_alttext<span style="color: #009900;">&#40;</span><span style="color: #000088;">$translation</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_type <span style="color: #339933;">==</span> <span style="color: #0000ff;">'album'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        <span style="color: #000088;">$translations</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>get_translations_for_domain<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Featured Image'</span><span style="color: #009900;">&#41;</span>
	            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$translations</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>translate<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Album Cover'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Set featured image'</span><span style="color: #009900;">&#41;</span>
	            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$translations</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>translate<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Select an image'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$translation</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'gettext'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'album_featured_image_alttext'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>It&#8217;s that simple. To take it one step further, depending on how many custom post types you&#8217;re using, you could expedit this change and apply it to all of your post types in one function using a switch:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> swap_featured_image_metabox<span style="color: #009900;">&#40;</span><span style="color: #000088;">$translation</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$translations</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>get_translations_for_domain<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_type <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'album'</span><span style="color: #339933;">:</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Featured Image'</span><span style="color: #009900;">&#41;</span>
	            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$translations</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>translate<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Album Cover'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'banner'</span><span style="color: #339933;">:</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Featured Image'</span><span style="color: #009900;">&#41;</span>
	            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$translations</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>translate<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Banner Image'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Set featured image'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$translations</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>translate<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Select an image'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$translation</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'gettext'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'swap_featured_image_metabox'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://gavinsmith.me/2010/12/adjusting-the-featured-image-text-for-custom-post-types-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Custom, front-end user settings page in WordPress</title>
		<link>http://gavinsmith.me/2010/10/custom-front-end-user-settings-page-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=custom-front-end-user-settings-page-in-wordpress</link>
		<comments>http://gavinsmith.me/2010/10/custom-front-end-user-settings-page-in-wordpress/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 16:36:12 +0000</pubDate>
		<dc:creator>Gavin Smith</dc:creator>
				<category><![CDATA[External]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://gavinsmith.me/?p=46</guid>
		<description><![CDATA[I find as I learn more and more on WordPress as a CMS, the requirement to keep users out of the WordPress dashboard altogether becomes increasingly common. The issue with prohibiting such access is, a user&#8217;s settings are normally handled through a dashboard view. In search of a solution, I found two routes: Theme My Login, a plugin, handles [...]]]></description>
			<content:encoded><![CDATA[<p>I find as I learn more and more on WordPress as a CMS, the requirement to keep users out of the WordPress dashboard altogether becomes increasingly common. The issue with prohibiting such access is, a user&#8217;s settings are normally handled through a dashboard view. In search of a solution, I found two routes:</p>
<ol>
<li><a href="http://wordpress.org/extend/plugins/theme-my-login/">Theme My Login</a>, a plugin, handles this among many other things Its placement in the permalink structure of the page is not ideal, however, but it&#8217;s worth a shot.</li>
<li>On the WordPress.org forums, I eventually encountered <a href="http://wordpress.org/support/topic/custom-edit-profile-page?replies=7#post-1286103">this post</a> by jimzqui. Using a custom template and a lot of additional CSS, this code is the shit to get a front-end settings page going. You&#8217;ll probably encounter an error &#8211; make sure you remove the &#8216;Resume&#8217; field in his code, as chances are you don&#8217;t have one.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://gavinsmith.me/2010/10/custom-front-end-user-settings-page-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple post thumbnail (featured image) sizes in WordPress</title>
		<link>http://gavinsmith.me/2010/10/multiple-post-thumbnail-featured-image-sizes-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=multiple-post-thumbnail-featured-image-sizes-in-wordpress</link>
		<comments>http://gavinsmith.me/2010/10/multiple-post-thumbnail-featured-image-sizes-in-wordpress/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 03:01:20 +0000</pubDate>
		<dc:creator>Gavin Smith</dc:creator>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://gavinsmith.me/?p=21</guid>
		<description><![CDATA[I&#8217;ve needed to, on multiple occasions, output post thumbnails for different content types at different sizes. This is the code you probably have: add_theme_support&#40; 'post-thumbnails' &#41;; set_post_thumbnail_size&#40; 94, 144, true &#41;; At this point, all instances of the_post_thumbnail will output the image at 94&#215;144. There are two main ways to output a different size: using [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve needed to, on multiple occasions, output post thumbnails for different content types at different sizes.</p>
<p>This is the code you probably have:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
set_post_thumbnail_size<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">94</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">144</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>At this point, all instances of <code>the_post_thumbnail</code> will output the image at 94&#215;144. There are two main ways to output a different size: using predefined image sizes, or by specifying your own. Using <code>the_post_thumbnail('thumbnail')</code>, for instance, will display the thumbnail using your install&#8217;s thumbnail settings, in Settings &gt; Media. This too, however, can only be set globally, and isn&#8217;t ideal since the thumbnail size is likely used elsewhere on your site.<span id="more-21"></span></p>
<p>You can also output a thumbnail using an array &#8211; <code>the_post_thumbnail( array( 100,150) )</code>. This is less than ideal as well because the resizing is done on the fly &#8211; either by specifying a size in the HTML or by regenerating it server-side, but either way is unnecessary load on the server.</p>
<p>The best way to approach the problem to create new custom image sizes, essentially in addition to the default &#8216;thumbnail&#8217;, &#8216;medium&#8217;, and &#8216;large&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_image_size<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'author-thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This will add the extra work to the media manager &#8211; when you upload an image, it will resize one additional time to these specifications and that new image will be at the ready using its name, in this case &#8216;author-thumbnail&#8217;. Now, we can simply do this in our template file to output the properly sized thumbnail for the content type:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">the_post_thumbnail<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'author-thumbnail'</span> <span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://gavinsmith.me/2010/10/multiple-post-thumbnail-featured-image-sizes-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

