<?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>Ed Townend</title>
	<atom:link href="http://www.teamtownend.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.teamtownend.com</link>
	<description>Edward Townend, Web Developer based in Barnsley, South Yorkshire, UK. Likes photography, design, R/C cars and MTB.</description>
	<lastBuildDate>Mon, 11 Mar 2013 16:34:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Custom Metaboxes for WordPress: Front Page show_on filter</title>
		<link>http://www.teamtownend.com/2013/03/custom-metaboxes-for-wordpress-front-page-show_on-filter/</link>
		<comments>http://www.teamtownend.com/2013/03/custom-metaboxes-for-wordpress-front-page-show_on-filter/#comments</comments>
		<pubDate>Fri, 08 Mar 2013 17:51:43 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[cmb]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=574</guid>
		<description><![CDATA[Shows the metabox only if a static front page is set and you&#8217;re editing it. /* Make sure your metabox is set thus: 'pages' => array( 'page' ), // Post 'show_on' => array( 'key' => 'front-page', 'value' => '' ), */ /** * Include metabox on front page * @author Ed Townend * @link https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress/wiki/Adding-your-own-show_on-filters [...]]]></description>
				<content:encoded><![CDATA[<p>Shows the metabox only if a static front page is set and you&#8217;re editing it.</p>
<p><code><br />
/*<br />
Make sure your metabox is set thus:<br />
'pages'      => array( 'page' ), // Post<br />
'show_on' => array( 'key' => 'front-page', 'value' => ''  ),<br />
*/</p>
<p>/**<br />
 * Include metabox on front page<br />
 * @author Ed Townend<br />
 * @link https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress/wiki/Adding-your-own-show_on-filters<br />
 *<br />
 * @param bool $display<br />
 * @param array $meta_box<br />
 * @return bool display metabox<br />
 */<br />
function ed_metabox_include_front_page( $display, $meta_box ) {<br />
     if ( 'front-page' !== $meta_box['show_on']['key'] )<br />
          return $display;</p>
<p>     // Get the current ID<br />
     if ( isset( $_GET['post'] ) ) {<br />
          $post_id = $_GET['post'];<br />
     } elseif ( isset( $_POST['post_ID'] ) ) {<br />
          $post_id = $_POST['post_ID'];<br />
     }</p>
<p>     //return false early if there is no ID<br />
     if( !isset( $post_id ) ) return false;</p>
<p>     //Get ID of page set as front page, 0 if there isn't one<br />
     $front_page = get_option('page_on_front');</p>
<p>     if ( $post_id == $front_page ) {<br />
          //there is a front page set and we're on it!<br />
          return $display;<br />
     }</p>
<p>}<br />
add_filter( 'cmb_show_on', 'ed_metabox_include_front_page', 10, 2 );</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2013/03/custom-metaboxes-for-wordpress-front-page-show_on-filter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get WordPress attachment ID by URL</title>
		<link>http://www.teamtownend.com/2013/02/get-wordpress-attachment-id-by-url/</link>
		<comments>http://www.teamtownend.com/2013/02/get-wordpress-attachment-id-by-url/#comments</comments>
		<pubDate>Fri, 22 Feb 2013 17:47:45 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=566</guid>
		<description><![CDATA[Pass in an (non-resized) attachment URL in WordPress and it returns the ID of the attachment. Doesn&#8217;t work with thumbnails. function ed_get_attachment_id_by_url($url) { global $wpdb; $attachment = $wpdb-&#62;get_col($wpdb-&#62;prepare("SELECT ID FROM {$wpdb-&#62;prefix}posts WHERE guid='%s';", $url)); if ( $attachment ) { return $attachment[0]; } else { return false; } }]]></description>
				<content:encoded><![CDATA[<p>Pass in an (non-resized) attachment URL in WordPress and it returns the ID of the attachment. Doesn&#8217;t work with thumbnails.</p>
<pre>function ed_get_attachment_id_by_url($url) {
    global $wpdb;
    $attachment = $wpdb-&gt;get_col($wpdb-&gt;prepare("SELECT ID FROM {$wpdb-&gt;prefix}posts WHERE guid='%s';", $url));
    if ( $attachment ) {
        return $attachment[0];
    } else {
        return false;
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2013/02/get-wordpress-attachment-id-by-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Protect Content shortcode</title>
		<link>http://www.teamtownend.com/2013/02/wordpress-protect-content-shortcode/</link>
		<comments>http://www.teamtownend.com/2013/02/wordpress-protect-content-shortcode/#comments</comments>
		<pubDate>Thu, 14 Feb 2013 09:54:51 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=562</guid>
		<description><![CDATA[The simplest way to hide content from logged out users by wrapping content in [protect] hide me [/protect] /************* PROTECT SHORTCODE - If user is not logged in, content within [protect] is replaced with a predefined string. *****************/ add_action( 'init', 'dm2_register_protect_shortcode'); function dm2_register_protect_shortcode() { add_shortcode('protect', 'dm2_protect_function'); } function dm2_protect_function($atts, $content = null) { if ( [...]]]></description>
				<content:encoded><![CDATA[<p>The simplest way to hide content from logged out users by wrapping content in [protect] hide me [/protect]</p>
<pre>
/*************
PROTECT SHORTCODE - If user is not logged in, content within [protect] is replaced with a predefined string.
*****************/

add_action( 'init', 'dm2_register_protect_shortcode');

function dm2_register_protect_shortcode() {
   add_shortcode('protect', 'dm2_protect_function');
}

function dm2_protect_function($atts, $content = null) {

     if ( is_user_logged_in() ) {
          $return_string = $content;
     } else {
          $return_string = 'You must be logged in to view this content';
     }

     wp_reset_query();
     return $return_string;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2013/02/wordpress-protect-content-shortcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lesson of the day &#8211; wp_content looks ugly with border-box</title>
		<link>http://www.teamtownend.com/2012/12/lesson-of-the-day/</link>
		<comments>http://www.teamtownend.com/2012/12/lesson-of-the-day/#comments</comments>
		<pubDate>Mon, 10 Dec 2012 21:45:18 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[border-box]]></category>
		<category><![CDATA[box-sizing]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp_editor]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=537</guid>
		<description><![CDATA[One of those hard lessons today that takes way longer to learn than it should. wp_editor() generated TinyMCE boxes were looking awful when used in a template I&#8217;m developing, and I couldn&#8217;t see why. Turns out the WordPress editor does not work with box-sizing: border-box. It was turned on in a recent addition to the excellent [...]]]></description>
				<content:encoded><![CDATA[<p>One of those hard lessons today that takes way longer to learn than it should. wp_editor() generated TinyMCE boxes were looking awful when used in a template I&#8217;m developing, and I couldn&#8217;t see why. Turns out the WordPress editor does not work with box-sizing: border-box. It was turned on in a recent addition to the excellent <a href="http://www.themble.com/bones/">bones starter theme</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2012/12/lesson-of-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Air Display uninstaller leaves kexts behind</title>
		<link>http://www.teamtownend.com/2012/11/air-display-uninstaller-leaves-kexts-behind/</link>
		<comments>http://www.teamtownend.com/2012/11/air-display-uninstaller-leaves-kexts-behind/#comments</comments>
		<pubDate>Thu, 22 Nov 2012 19:11:51 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=535</guid>
		<description><![CDATA[While looking into the course of kernel panics on my iMac, I found that two kexts relating to Avatron&#8217;s Air Display were in /System/Library/Extensions, despite the fact that I uninstalled Air Display using their bundled uninstaller a bit back. The two offending files are AVVideoCard.kext and AVFrameBuffer.kext. Simply moving them outside of the Extensions folder [...]]]></description>
				<content:encoded><![CDATA[<p>While looking into the course of kernel panics on my iMac, I found that two kexts relating to Avatron&#8217;s Air Display were in /System/Library/Extensions, despite the fact that I uninstalled Air Display using their bundled uninstaller a bit back. The two offending files are AVVideoCard.kext and AVFrameBuffer.kext. Simply moving them outside of the Extensions folder and rebooting is enough to get rid of them, and there doesn&#8217;t seem to be any ill effects.</p>
<p>We&#8217;ll see if that fixes the kernel panics.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2012/11/air-display-uninstaller-leaves-kexts-behind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Categories images plugin modified to save image ID</title>
		<link>http://www.teamtownend.com/2012/10/categories-images-plugin-modified-to-save-image-id/</link>
		<comments>http://www.teamtownend.com/2012/10/categories-images-plugin-modified-to-save-image-id/#comments</comments>
		<pubDate>Sat, 06 Oct 2012 20:38:14 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[categories-images]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=520</guid>
		<description><![CDATA[I very quickly (and badly) hacked up Zahlan&#8217;s excellent Categories Images plugin to save image IDs rather than the absolute URL to the image file. This means we can use WordPress&#8217; image resizing as well as its other image meta tools. Download the categories-images plugin (zip) Update (10 Oct 12): The first upload had a bit of [...]]]></description>
				<content:encoded><![CDATA[<p>I very quickly (and badly) hacked up <a href="http://zahlan.net/blog/2012/06/categories-images">Zahlan&#8217;s excellent Categories Images plugin</a> to save image IDs rather than the absolute URL to the image file. This means we can use WordPress&#8217; image resizing as well as its other image meta tools.</p>
<p><a href="http://www.teamtownend.com/wp-content/uploads/2012/10/categories-images1.zip">Download the categories-images plugin (zip)</a></p>
<p>Update (10 Oct 12): The first upload had a bit of code left in from my own use of the plugin that limited it to a certain taxonomy. I&#8217;ve removed it now so the plugin works on all taxonomies as it should.</p>
<p>The key points are:</p>
<ul>
<li>z_edit_taxonomy_field() and z_add_taxonomy_field()  are modified to have a separate button to upload the image rather than clicking the text box. It means the user can manually type the ID if they wish.</li>
<li>z_script() grabs the image ID from thickbox instead of the URL. Because thickbox returns an img tag with the image, the only way to get the ID is to chop it out of the class.</li>
<li>z_save_taxonomy_image() validates the image ID before saving in case the user types an ID in the text box.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2012/10/categories-images-plugin-modified-to-save-image-id/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Add menu li class of item&#8217;s name in WordPress</title>
		<link>http://www.teamtownend.com/2012/09/add-menu-li-class-of-items-name-in-wordpress/</link>
		<comments>http://www.teamtownend.com/2012/09/add-menu-li-class-of-items-name-in-wordpress/#comments</comments>
		<pubDate>Wed, 12 Sep 2012 22:28:49 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=516</guid>
		<description><![CDATA[This adds a class of the item&#8217;s name to each list item in a nav menu in WordPress. So, if the page item is called &#8216;About us&#8217;, the li gets an extra class of &#8216;menu-item-about-us&#8217;. Handy for styling. add_filter('nav_menu_css_class' , 'ed_page_title_class' , 10 , 2); function ed_page_title_class($classes, $item){ $classes[] = sanitize_title('menu-item-' . $item-&#62;title); return $classes; [...]]]></description>
				<content:encoded><![CDATA[<p>This adds a class of the item&#8217;s name to each list item in a nav menu in WordPress. So, if the page item is called &#8216;About us&#8217;, the li gets an extra class of &#8216;menu-item-about-us&#8217;. Handy for styling.</p>
<pre>add_filter('nav_menu_css_class' , 'ed_page_title_class' , 10 , 2);
function ed_page_title_class($classes, $item){
  $classes[] = sanitize_title('menu-item-' . $item-&gt;title);
  return $classes;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2012/09/add-menu-li-class-of-items-name-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add body class if post has a featured image in WordPress</title>
		<link>http://www.teamtownend.com/2012/09/add-body-class-if-post-has-a-featured-image-in-wordpress/</link>
		<comments>http://www.teamtownend.com/2012/09/add-body-class-if-post-has-a-featured-image-in-wordpress/#comments</comments>
		<pubDate>Thu, 06 Sep 2012 10:07:54 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=513</guid>
		<description><![CDATA[This WordPress function adds a body class &#8216;has-featured-image&#8217; if the current post has a featured image assigned. add_action('body_class', 'ed_if_featured_image_class' ); function ed_if_featured_image_class($classes) { if ( has_post_thumbnail() ) { array_push($classes, 'has-featured-image'); } return $classes; }]]></description>
				<content:encoded><![CDATA[<p>This WordPress function adds a body class &#8216;has-featured-image&#8217; if the current post has a featured image assigned.</p>
<pre>add_action('body_class', 'ed_if_featured_image_class' );
function ed_if_featured_image_class($classes) {
 if ( has_post_thumbnail() ) {
 array_push($classes, 'has-featured-image');
 }
 return $classes;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2012/09/add-body-class-if-post-has-a-featured-image-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Christmas Cards for Graphic Designers</title>
		<link>http://www.teamtownend.com/2011/11/christmas-cards-for-graphic-designers/</link>
		<comments>http://www.teamtownend.com/2011/11/christmas-cards-for-graphic-designers/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 17:58:59 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Graphic Design]]></category>
		<category><![CDATA[Christmas]]></category>
		<category><![CDATA[graphic design]]></category>
		<category><![CDATA[xmas]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=495</guid>
		<description><![CDATA[At Townend we&#8217;ve got an Xmas Card tailored for the graphic designers in your life. We&#8217;ve not got many so be quick!]]></description>
				<content:encoded><![CDATA[<p><a href="http://townend.co/blog/townend-christmas-cards/"><img class="alignleft size-large wp-image-501" title="Christmas Card" src="http://www.teamtownend.com/wp-content/uploads/2011/11/20111116-_MG_4658-1024x682.jpg" alt="" width="584" height="388" /></a>At Townend we&#8217;ve got an <a href="http://townend.co/blog/townend-christmas-cards/">Xmas Card</a> tailored for the graphic designers in your life. We&#8217;ve not got many so be quick!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2011/11/christmas-cards-for-graphic-designers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s not quite Helvetidoodle&#8230;</title>
		<link>http://www.teamtownend.com/2011/10/its-not-quite-helvetidoodle/</link>
		<comments>http://www.teamtownend.com/2011/10/its-not-quite-helvetidoodle/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 23:10:11 +0000</pubDate>
		<dc:creator>Edward Townend</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[helvetidoodle]]></category>
		<category><![CDATA[spotted]]></category>

		<guid isPermaLink="false">http://www.teamtownend.com/?p=487</guid>
		<description><![CDATA[But it&#8217;s not far off! Spotted on the homepage of American Apparel.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.teamtownend.com/wp-content/uploads/2011/10/americanapparel.jpg"><img src="http://www.teamtownend.com/wp-content/uploads/2011/10/americanapparel-1024x554.jpg" alt="" title="americanapparel" width="584" height="315" class="alignleft size-large wp-image-493" /></a>But it&#8217;s not far off! Spotted on the homepage of American Apparel.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.teamtownend.com/2011/10/its-not-quite-helvetidoodle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
