<?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>Archetyped &#8250; Dev</title>
	<atom:link href="http://archetyped.com/tag/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://archetyped.com</link>
	<description>Explore, Experiment, Inspire</description>
	<lastBuildDate>Thu, 26 Aug 2010 23:55:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Lab &#8250; Cornerstone: Now is the Time for Action (and Filters)</title>
		<link>http://archetyped.com/lab/cornerstone-now-is-the-time-for-action-and-filters/</link>
		<comments>http://archetyped.com/lab/cornerstone-now-is-the-time-for-action-and-filters/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 21:47:21 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Feature]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Cornerstone]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Hooks]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://archetyped.com/?p=624</guid>
		<description><![CDATA[<p><em>Content Types finally get some action</em></p>Cornerstone's content types now have the ability to hook into Wordpress with actions and filters, making it easy to fully customize how post fields are retrieved, displayed, and saved.]]></description>
			<content:encoded><![CDATA[<p><em>Content Types finally get some action</em></p><p><a href="http://archetyped.com/tools/cornerstone/" title="Cornerstone">Cornerstone&#8217;s</a> content types now have the ability to hook into WordPress with <a href="http://codex.wordpress.org/Plugin_API/Action_Reference" target="_blank">actions</a> and <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference" target="_blank">filters</a>, making it easy to fully customize how post fields are retrieved, displayed, and saved.</p>
<h3>Background</h3>
<p>With the release of <a href="http://wordpress.org/news/2004/05/heres-the-beef/" target="_blank">WordPress 1.2</a>, customizing WordPress has been greatly simplified by the inclusion of a <a href="http://codex.wordpress.org/Plugin_API" target="_blank">plugin API</a>.  This API is comprised of <strong>actions</strong> and <strong>filters</strong> that provide specific points in WordPress for plugins to &#8220;hook&#8221; into and customize how WordPress functions.  This makes WordPress an incredibly flexible platform for any type of project ranging from simple blogs to complex web applications.</p>
<p>Similarly, Cornerstone&#8217;s content types are like <em>mini plugins</em> that customize <strong>posts</strong> for a particular use or purpose. Thus, content types would also benefit greatly from the ability to hook into WordPress&#8217; actions and filters.</p>
<h3>Explore</h3>
<p>I openly admit that while I had this on my to-do list for a while, I was actually <em>tricked</em> into implementing this functionality into Cornerstone when I wanted to create a rich text (aka <a href="http://wikipedia.org/wiki/WYSIWYG" target="_blank">WYSIWYG</a>) field for use in content types.  This would make it simpler to format content in text fields, since the standard <code>textarea</code> field is simply plain text (no formatting).</p>
<p>Since WordPress uses <a href="http://tinymce.moxiecode.com/" target="_blank">TinyMCE</a> as its rich text editor by default, it was a logical choice for Cornerstone&#8217;s <code>richtext</code> field, so I did some exploratory work to determine how TinyMCE is implemented in WordPress itself.</p>
<p>As I said, I was <em>tricked</em> into enabling actions and filters for content types.  When I started looking into using TinyMCE in a field, I assumed that it would require adding Javascript to a page (since this is how TinyMCE is implemented by default), which Cornerstone&#8217;s content types can already do:</p>
<pre class="brush:php;gutter:false">$field-&gt;add_script($context, $handle, $uri, $dependencies);</pre>
<p>However, WordPress uses an action to call a function that handles all of the configuration and Javascript loading separately:</p>
<pre class="brush:php;gutter:false">add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );</pre>
<p>I was already committed.  Cornerstone&#8217;s content types would need to have access to actions and filters.</p>
<h3>Experiment</h3>
<p>There were a couple of questions that needed to be answered before hooks would be enabled in Cornerstone.</p>
<h4>1. Which content types to register hooks for?</h4>
<p>During initialization, all content types are registered so that WordPress has access to them.  However, not all content types are used in every request, so it would not be a good idea to register the hooks for <em>all</em> content types, but rather only the ones that are used in the current request.  Therefore, the first step is to determine which content types are used in the current request.</p>
<h4>2. When to register hooks for content types?</h4>
<p>Once we&#8217;ve determined which content types are currently in use, we can register the hooks for them.  The issue here is that we need to <em>use</em> a hook to register the hooks for the content types, so we&#8217;ve already lost one potential hook for content types to use.  We also need to make sure that WordPress is far enough along in its initialization process to be able to accept a content type&#8217;s hooks (i.e. environmental variables set, default post types registered, etc.), which may remove yet more hooks from those that content types can use.</p>
<p>After a bit of research and testing, the optimal hook to use for registering actions and filters for content types was <code>init</code>:</p>
<pre class="brush:php;gutter:false">add_action('init', 'add_hooks', 11);</pre>
<p>This means that the <code>init</code> action and any hook that precedes it will not be available for content types.  I&#8217;m not particularly fond of this limitation, but it is mitigated by the fact that there are only a few hooks before <code>init</code> and the vast majority of content types will use hooks that come <em>after</em> <code>init</code>.  Nonetheless, I would be happier if <code>init</code> were available to content types (since it&#8217;s a pretty common hook), so I&#8217;m still looking at some options for bringing it back into the fold.</p>
<p>In the end, enabling action and filter hooks for Cornerstone&#8217;s content types was not as involved as I imagined it would be (hence why it sat on my to-do list for as long as it did), and the ability to hook into WordPress with content types was well worth the time and effort.</p>
<h3>Payoff</h3>
<p>The payoff for the work is that hooking to WordPress is as simple as this:</p>
<pre class="brush:php;gutter:false">$richtext-&gt;add_action('admin_print_footer_scripts', 'wp_tiny_mce', 25);</pre>
<p>Even better is that the possibilities are now endless.  Just as with plugins, it&#8217;s really now down to our imagination to use Cornerstone&#8217;s content types to customize WordPress to the needs of our projects.</p>
<p><a href="http://archetyped.com/lab/cornerstone-now-is-the-time-for-action-and-filters/"> Cornerstone: Now is the Time for Action (and Filters)</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on August 25, 2010 11:47am</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/cornerstone-now-is-the-time-for-action-and-filters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lab &#8250; Cornerstone: Structure Now More Structured</title>
		<link>http://archetyped.com/lab/cornerstone-structure-now-more-structured/</link>
		<comments>http://archetyped.com/lab/cornerstone-structure-now-more-structured/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 04:03:47 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Cornerstone]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://archetyped.com/?p=619</guid>
		<description><![CDATA[Wordpress has a nice little UI element below the post title field that updates to show you the post's permalink after you have entered a title for the post.  This permalink preview is useful because it provides the user with feedback on the post they are in the process of writing.   It's also great because it showed me that Cornerstone had a little bug.]]></description>
			<content:encoded><![CDATA[<p>WordPress has a nice little UI element below the post title field that  updates to show you the post&#8217;s permalink after you have entered a title  for the post.  This permalink preview is useful because it provides the  user with feedback on the post they are in the process of writing.    It&#8217;s also great because it showed me that <a href="http://archetyped.com/tools/cornerstone/" title="Cornerstone">Cornerstone</a> had a little bug.</p>
<p>The other day, I fired up WordPress to write a new post, added the title, and started to write the post&#8217;s content, when I noticed something strange was going on with the permalink preview:</p>
<div id="attachment_622" class="wp-caption alignnone" style="width: 449px"><img class="size-full wp-image-622" title="Permalink Bugg" src="http://archetyped.com/wp-content/uploads/cnr_bug_permalink.gif" alt="" width="439" height="147" /><p class="wp-caption-text">Oops</p></div>
<h3>The Bug</h3>
<p>One of Cornerstone&#8217;s main features is <strong>Structure</strong>.  Structure allows a site to have sections and for authors to add posts to any of these sections.  When a post is added to a section, Structure makes sure the post&#8217;s permalink is logically connected to the section&#8217;s permalink.</p>
<ul>
<li>Section: <code>http://site-name.com/section-name/</code></li>
<li>Post: <code>http://site-name.com/section-name/post-name/</code></li>
</ul>
<p>Cornerstone adds a new permalink structure to <strong>Settings &gt; Permalinks</strong> in the site&#8217;s admin area which lets users enable this type of logical connection between posts and sections.</p>
<ul>
<li>Structured: <code>/%postpath%/%postname%/</code></li>
</ul>
<p>On this particular occasion, I had not yet selected a section for the post, which is was fortuitous because it revealed that Structure&#8217;s permalink modification was not working quite right for drafts.  In truth, it was not working <em>at all</em> because Structure was disabled for drafts.</p>
<pre class="brush:php">function post_link($permalink, $post, $leavename = false) {
	global $wp_query;
	if ( !$this-&gt;using_post_permastruct()
		|| ( !$this-&gt;util-&gt;check_post($post) )
		|| !$this-&gt;util-&gt;property_exists($post, 'post_name')
		|| empty($post-&gt;post_name)
		|| !$this-&gt;util-&gt;property_exists($post, 'post_parent')
		|| 0 == $post-&gt;post_parent )
		return $permalink;

//	...continue modifying permalink...</pre>
<p>According to this code, the custom permalink structure will not be used if any of the following conditions are met:</p>
<ul>
<li>Cornerstone&#8217;s custom permalink structure is not enabled</li>
<li>Valid post not passed to function</li>
<li>Post has no name (e.g. drafts)</li>
<li>Post is not in a section</li>
</ul>
<p>Since the function stopped before making any modifications to the draft post&#8217;s permalink, the permalink generated by WordPress remained.  However, since Cornerstone&#8217;s permalink structure contains a custom <a href="http://codex.wordpress.org/Using_Permalinks#Structure_Tags" target="_blank">structure tag</a> (<code>%postpath%</code>), WordPress did not know what to do with it and simply left it in the permalink (only replacing the standard <code>%postname%</code> tag).</p>
<p>Posts without sections are simply supposed to be located at the site&#8217;s root level (e.g. <code>http://site-name.com/post-name/</code>), but the conditions that were set to determine whether a post&#8217;s permalink should be modified were overly aggressive.  The result was that any post that wasn&#8217;t in a section would have an invalid permalink.</p>
<h3>The Fix</h3>
<p>Thankfully, the solution to this issue was quite apparent&#8211; simplify!</p>
<pre class="brush:php">function post_link($permalink, $post, $leavename = false) {
	global $wp_query, $cnr_content_utilities;

	if ( !$this-&gt;using_post_permastruct()
		|| ( !$this-&gt;util-&gt;check_post($post) )
		|| ( empty($post-&gt;post_name) &amp;&amp; empty($post-&gt;post_title) ) )
		return $permalink;

//	...continue modifying post permalink...</pre>
<p>Now the custom permalink structure would be used for a post except under just a few conditions:</p>
<ul>
<li> Custom permalink structure is not activated by user</li>
<li>Valid post not passed to function</li>
<li> Post has no name <em>or </em>title (e.g. drafts)</li>
</ul>
<p>We check for the existence of the post&#8217;s title if there is no post name (i.e. the post&#8217;s slug) because in certain instances, the post passed to this function may not yet have a slug, but it will have a title (which we can still work with).  Only if the post has neither slug nor title will we halt further processing (since we can&#8217;t build a full permalink without at least one of those values).</p>
<p>Finally, since custom post types made their full debut in WordPress 3.0, we need a small addition to support them as well.  Cornerstone allows putting items with custom post types into sections as well, so the same permalink structure is used for items that have a section selected (i.e. <code>/section-name/post-name/</code>).  However, by default, the permalink structure for items with custom content types is <code>/post-type/post-name/</code>, so if an item is <em>not</em> in a section and it has a custom post type, then the default permalink structure should be used.</p>
<p>So our final conditional statement looks like:</p>
<pre class="brush:php">function post_link($permalink, $post, $leavename = false) {
	global $wp_query, $cnr_content_utilities;

	if ( !$this-&gt;using_post_permastruct()
		|| ( !$this-&gt;util-&gt;check_post($post) )
		|| ( empty($post-&gt;post_name) &amp;&amp; empty($post-&gt;post_title) )
		|| ( !$cnr_content_utilities-&gt;is_default_post_type($post-&gt;post_type) &amp;&amp; empty($post-&gt;post_parent) ) )
		return $permalink;

//	...continue modifying post permalink...</pre>
<p>Now post permalinks work just fine and <a href="http://archetyped.com/tools/cornerstone/" title="Cornerstone">Cornerstone&#8217;s</a> <strong>Structure</strong> is even more structured than before.</p>
<p><a href="http://archetyped.com/lab/cornerstone-structure-now-more-structured/"> Cornerstone: Structure Now More Structured</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on August 20, 2010 06:03pm</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/cornerstone-structure-now-more-structured/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lab &#8250; Favicon Rotator 1.1: Optimized Icons</title>
		<link>http://archetyped.com/lab/favicon-rotator-1-1-optimized-icons/</link>
		<comments>http://archetyped.com/lab/favicon-rotator-1-1-optimized-icons/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 00:10:00 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Favicon]]></category>
		<category><![CDATA[Favicon Rotator]]></category>
		<category><![CDATA[Icon]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Update]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://archetyped.com/?p=617</guid>
		<description><![CDATA[Favicon Rotator received a few updates recently, but the main highlight is that optimized icons are now created for uploaded images.]]></description>
			<content:encoded><![CDATA[<p><a href="http://archetyped.com/tools/favicon-rotator/" title="Favicon Rotator">Favicon Rotator</a> received a few updates recently, but the main highlight is that optimized icons are now created for uploaded images.</p>
<h3>Why?</h3>
<p>The primary purpose of Favicon Rotator was to make it simple to upload a favicon for a WordPress site.  So in version 1.0, the plugin basically loaded the image as it was uploaded by the user.  This works perfectly fine, especially if the user uploads an image <em>meant</em> to be a favicon (i.e. 16&#215;16 resolution).  Larger images were properly loaded as well, but it was left up to the browser to resize the image to fit in the 16&#215;16 space in the browser&#8217;s address bar.  The other issue was that if the user selected a large image to use as a favicon, then the site&#8217;s loading time could be increased since the entire image needed to be downloaded (regardless of how small it was being displayed).</p>
<p>I definitely am not a fan of slower loading, but I was initially hesitant to create additional files since WordPress already automatically creates thumbnail files for all uploaded images, which is a waste of disk space if the user will never use them.  However, due to the potential for increased load times and the hit-or-miss results when letting the browser resize large images, I decided that Favicon Rotator should create an image optimized for use as a favicon.</p>
<p>Thankfully, WordPress is not stupid (quite smart in fact), and it will not create additional intermediate files (thumbnails, etc.) if the original image is smaller than the intermediate sizes.  This means that if a user does upload a 16&#215;16 image file that is already optimized for use as a favicon, no additional files will be created.  Therefore, only images that would benefit from an intermediate file will have one created.</p>
<h3>When?</h3>
<p>Favicon Rotator doesn&#8217;t create favicon-sized files for <em>all </em>images uploaded to WordPress, but rather only when certain criteria are met:</p>
<ul>
<li>Images that are uploaded via Favicon Rotator&#8217;s admin page</li>
<li>Images that were uploaded by other means, but are selected for use as a favicon</li>
</ul>
<p>This minimizes the number of extraneous files in WordPress since optimized icons are created on-demand and saved for future use (so icons for an image are only created once).</p>
<h3>How?</h3>
<p>Adding a new intermediate size for uploaded images is very simple.  It only takes one quick line of code:</p>
<pre class="brush:php;gutter:false">add_image_size($image_size, $width, $height, $crop);</pre>
<p>Then, you simply add a hook to register this new size once WordPress has loaded.  Basically any hook including and beyond <code>init</code> will do, but I chose to hook into <code>intermediate_image_sizes</code> so that the favicon image size is added only when the available intermediate image sizes are requested (otherwise the favicon image size would be added during every request whether it was needed or not).</p>
<pre class="brush:php;gutter:false">add_filter('intermediate_image_sizes', 'add_intermediate_image_size');</pre>
<p>The custom function to add the favicon image size can be very simple:</p>
<pre class="brush:php">function add_intermediate_image_size($sizes) {
	add_image_size('favicon', 16, 16, true);
	$sizes[] = 'favicon';
	return $sizes;
 }</pre>
<p>However, since we only want to create an optimized file when uploading or selecting a file specifically for use as a favicon, we need to add a bit more code:</p>
<pre class="brush:php">function add_intermediate_image_size($sizes) {
	$img = array('width' =&gt; 0, 'height' =&gt; 0, 'crop' =&gt; true);
	if ( $this-&gt;is_custom_media() ) {
		$img['width'] = $this-&gt;icon_dimensions['w'];
		$img['height'] = $this-&gt;icon_dimensions['h'];
	}
	add_image_size($this-&gt;icon_size, $img['width'], $img['height'], $img['crop']);
	$sizes[] = $this-&gt;icon_size;
	return $sizes;
 }</pre>
<p>This updated function does the following:</p>
<ol>
<li>Creates a default array with zeroed-out values for the intermediate image (more on why later)</li>
<li>Checks if the current request is initiated by Favicon Rotator (e.g. uploading/selecting an image via the admin page).  If so, set actual width/height values for favicon image (using object variables)</li>
<li>Adds image size to WordPress</li>
<li>Adds size name (e.g. &#8216;favicon&#8217;) to array of intermediate images sizes (using an object variable)</li>
<li>Return updated array of intermediate image sizes to filter</li>
</ol>
<p>The reason why we create an array with zeroed-out values for the image dimensions is because the intermediate image sizes may be requested in multiple situations (e.g. when deleting an image attachment from WordPress) so we need to add a valid size to the list of intermediate sizes whenever it is requested.  However, since we don&#8217;t want to actually <em>create</em> an additional favicon file for images unless they are uploaded/selected via Favicon Rotator&#8217;s admin page, we set the width/height to 0, which WordPress will then skip when creating intermediate images.</p>
<h3>That&#8217;s a wrap!</h3>
<p>By adding this functionality, favicons from large images look better <em>and</em> load faster, which makes this a worthwhile update for me.  As with most updates, I don&#8217;t really know where I&#8217;m going next (since I usually include everything I want to before updating), so any further updates will likely be based on user feedback.  If you have any requests, make sure to <a href="http://archetyped.com/tools/favicon-rotator/#respond" title="Provide feedback for Favicon Rotator">leave a comment</a> to let me know how Favicon Rotator can be improved.</p>
<p><a href="http://archetyped.com/lab/favicon-rotator-1-1-optimized-icons/"> Favicon Rotator 1.1: Optimized Icons</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on August 20, 2010 02:10pm</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/favicon-rotator-1-1-optimized-icons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lab &#8250; Redactor &#8211; Quality time with TinyMCE</title>
		<link>http://archetyped.com/lab/redactor-quality-time-with-tinymce/</link>
		<comments>http://archetyped.com/lab/redactor-quality-time-with-tinymce/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 08:46:18 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Privacy]]></category>
		<category><![CDATA[Redact]]></category>
		<category><![CDATA[WebDev]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://archetyped.com/?p=595</guid>
		<description><![CDATA[Today I moved on to working on working on implementing redaction in Wordpress' visual editor, otherwise known as TinyMCE.]]></description>
			<content:encoded><![CDATA[<p>Today I moved on to working on working on implementing redaction in WordPress&#8217; visual editor, otherwise known as <a href="http://tinymce.moxiecode.com/">TinyMCE</a>.</p>
<p>In general, I&#8217;m not a huge fan of WYSIWYG editors because what-you-see-is-<strong>not</strong>-always-what-you-get, and TinyMCE is no exception.  It&#8217;s neither the fastest nor the most lightweight editor out there, but it is quite capable and the plugin API is rather robust.  Over time, I have given the visual editor some leeway and have become accustomed to letting it handle my paragraph tags and bolded text.  Honestly, it&#8217;s not half bad and I find myself writing in the visual editor more and more often, only switching to the HTML editor when I need to make sure the proper markup is written.</p>
<p>At any rate, since I use WordPress&#8217; visual editor fairly regularly (along with the majority of WordPress users out there, I&#8217;d assume), I decided to add redaction support to TinyMCE.  I <em>could</em> do it quick and dirty and just add a button that wraps the redact shortcode around the selected text, but that wouldn&#8217;t be fun.  Instead, redacting text in the visual editor will function very similarly to the way you would make text bold or italic.  Basically, click the &#8220;Redact text&#8221; button on the toolbar and the text styling is changed to indicate that it is redacted.  I think this is one of the benefits of the visual editor as visual cues make navigating through a post&#8217;s content far faster for most users than looking at the HTML source.</p>
<p>So far, I&#8217;ve:</p>
<ul>
<li>Added a button to TinyMCE&#8217;s toolbar to activate/deactivate redaction</li>
<li>Setup CSS to provide visual cues to identify redacted text</li>
<li>Started work on wrapping selected text in the redact shortcode</li>
</ul>
<p>The interesting bit about TinyMCE is that you can add additional HTML markup in the post content to help with the visual cues in the visual editor, but when you view the source, you can swap out the presentation markup for the markup you want to be saved with the post content.  This makes it incredibly customizable in terms of presentation <em>and</em> final markup.</p>
<p>The main thing that&#8217;s left is to refine how selected text is wrapped with the shortcode.  Some things to consider when manipulating the selected text:</p>
<ol>
<li>Is the selected text part of a larger chunk of chunk of text that has already been redacted?</li>
<li>Should the selected text be wrapped or unwrapped with the shortcode?</li>
<li>What should happen when no text is selected?</li>
</ol>
<p>We definitely want to avoid nesting redaction shortcodes within each other so I&#8217;m going to take some time on this to make sure it works the way one would expect it to in the different situations.</p>
<p>I&#8217;m planning on putting together a tutorial on making a TinyMCE plugin for WordPress once I&#8217;ve released this plugin.  Even though I&#8217;ve done a fair amount of TinyMCE plugin development specifically for WordPress, I think having a quick step by step reference for creating a plugin for the visual editor would be a nice way to jump start development on the next one.  Hopefully others will find it useful as well.</p>
<p>On a different but related note, I was surprised today when I noticed that WordPress was telling me to update Redactor as a new version has just become available.</p>
<p><img class="alignnone size-full wp-image-598" title="Update Redactor" src="http://archetyped.com/wp-content/uploads/redactor_update_2010-08-09.png" alt="" width="416" height="61" /></p>
<p>I found this perplexing at first because I was sure I hadn&#8217;t published an updated version of the plugin that I didn&#8217;t know about on my own development version of WordPress.  It appears that the &#8220;Updates&#8221; section of WordPress merely looks for matching plugin names on WordPress.org (as opposed to checking the plugin URI as well) as it turns out that I was being notified of a new version of a <a href="http://wordpress.org/extend/plugins/redactor/">different plugin</a> with the same name.</p>
<p>I checked whether there was already a plugin called &#8220;Redactor&#8221; on WordPress&#8217; website last week to avoid confusion when I first started writing about my plugin.  I figured this other plugin must be very new.  It is, it was released <em>today</em>.</p>
<p>What&#8217;s cool is that it has many of the same features that have or am planning to implement in my plugin (from manual shortcodes to automated text replacement).  It&#8217;s always nice to have more than one option.  While Redactor is just a code name for the plugin during development, I was considering the possibility of using it as the official name (since it&#8217;s rather descriptive of it&#8217;s functionality), but I guess the decision has been made for me.  Thanks!</p>
<p><a href="http://archetyped.com/lab/redactor-quality-time-with-tinymce/"> Redactor &#8211; Quality time with TinyMCE</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on August 9, 2010 10:46pm</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/redactor-quality-time-with-tinymce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lab &#8250; Cornerstone: We have compatibility!</title>
		<link>http://archetyped.com/lab/cornerstone-we-have-compatibility/</link>
		<comments>http://archetyped.com/lab/cornerstone-we-have-compatibility/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 09:01:32 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Compatibility]]></category>
		<category><![CDATA[Cornerstone]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://archetyped.com/?p=542</guid>
		<description><![CDATA[<p><em>Compatibility is so (not) overrated</em></p>I made good progress today as I completed far more than expected while working to make Cornerstone compatible with Wordpress 3.0]]></description>
			<content:encoded><![CDATA[<p><em>Compatibility is so (not) overrated</em></p><p>Well that didn&#8217;t take as long as I expected it to.  While I still have some tests to run through, all work has been completed to make <a href="http://archetyped.com/tools/cornerstone/" title="Cornerstone">Cornerstone</a> compatible with WordPress 3.0!  I was expecting this to take at least 2-3 days due to the amount of code I had to check, but after finishing what I had scheduled for today, I decided to just keep chugging along and ended up finishing everything on my list without much delay.</p>
<p>Here&#8217;s a rundown of what I did today:</p>
<h3>Structure</h3>
<h4>Permalink Structure</h4>
<p>The first thing on the list was adjusting the permalink structure for posts with custom post types.  By default, the structure for posts with custom post types is <code>/post-type/post-name/</code>, which doesn&#8217;t cut it when posts can now be added to a specific section regardless of their post type.  What we want is for all posts to use <code>/section-name/post-name/</code> as their permalink structure.  I didn&#8217;t think this would be too difficult to rectify, and thankfully it wasn&#8217;t.  A quick look at <code>get_permalink()</code> (which Cornerstone hooks into to filter a post&#8217;s permalink) revealed that posts with custom post types were processed separately from standard posts:</p>
<pre class="brush:php;first-line:110">elseif ( in_array($post-&gt;post_type, get_post_types( array('_builtin' =&gt; false) ) ) )
	return get_post_permalink($post, $leavename, $sample);</pre>
<p>So in addition to hooking into <code>post_link</code> for standard posts, we also need to hook into <code>post_type_link</code> (which is called in <code>get_post_permalink()</code>).  Thankfully, both filter hooks pass the default permalink along with the current post&#8217;s data (except that <code>post_link</code> supplies the entire post object while <code>post_type_link</code> only supplies the post&#8217;s ID) so the same handler can be used for both:</p>
<pre class="brush:php">add_filter('post_link', $this-&gt;m('post_link'), 10, 2); //Standard posts
add_filter('post_type_link', $this-&gt;m('post_link'), 10, 2);  //Custom post types</pre>
<p>With this additional hook added, posts with custom post types now have <code>/section-name/post-name/</code> as their permalink structure.</p>
<h4>Post Sections</h4>
<p><a href="http://archetyped.com/wp-content/uploads/cnr_structure_section_selec.gif"><img class="alignnone size-full wp-image-549" title="Section Selection" src="http://archetyped.com/wp-content/uploads/cnr_structure_section_selec.gif" alt="" width="327" height="112" /></a></p>
<p>Next on my list was providing the UI on the edit forms for custom post types to select the section the post should be saved to.  Prior to WordPress 3.0, I added the section selector to the edit form sidebar by hooking into the <code>do_meta_boxes</code> action.  This works exactly as it should on the edit form for custom post types in WordPress 3.0, save for one difference&#8211; the action hook now passes the <em>post type</em> of the post currently being edited (as opposed to being hardcoded as &#8220;post&#8221; in earlier versions of WordPress).  Since we only wanted the section selector to be added to the sidebar of the <em>post </em>edit form, that&#8217;s exactly what the handler looked for before adding the section selector meta box:</p>
<pre class="brush:php">if ( 'post' == $type &amp;&amp; 'side' == $context )
	add_meta_box($this-&gt;add_prefix('section'), 'Section', $this-&gt;m('admin_post_sidebar_section'), 'post', 'side', 'high');</pre>
<p>Since the post type can now be variable, the condition for adding a the section selector meta box needed to be expanded a bit:</p>
<pre class="brush:php">$child_types = get_post_types(array('show_ui' =&gt; true, '_builtin' =&gt; false));
$child_types[] = 'post';
$side_context = 'side';
$priority = 'high';
if ( in_array($type, $child_types) &amp;&amp; $side_context == $context )
	add_meta_box($this-&gt;add_prefix('section'), __('Section'), $this-&gt;m('admin_post_sidebar_section'), $type, $context, $priority);</pre>
<p>Basically, all custom post types that would have an edit form are retrieved, the &#8220;post&#8221; post type is added to the array of possible post types, and a check is performed to see if the current post type is included in this array.  If so, the meta box is added and the section selector is displayed on edit form&#8217;s sidebar.  I also took this opportunity to move some of the values in the <code>add_meta_box</code> call out into separate variables to further simplify future maintenance.</p>
<h3>Taxonomies</h3>
<p><a href="http://archetyped.com/wp-content/uploads/cnr_taxonomies.gif"><img class="alignnone size-full wp-image-550" title="Taxonomies" src="http://archetyped.com/wp-content/uploads/cnr_taxonomies.gif" alt="" width="327" height="359" /></a><br />
I honestly thought it would take longer than it did to go through and fix the compatibility issues with permalinks and section selection so that was really all I had intended to work on today.  After finishing them so quickly, I decided that I would work on getting the rest of the edit form for custom post types to work properly.  The first thing was adding access to the standard post taxonomies (specifically, categories and post tags) on custom post type edit forms.</p>
<p>Once again, I thought I was in for some digging through WordPress&#8217; code, and once again, it turned out to be incredibly simple.  WordPress provides the <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type"><code>register_taxonomy_for_object_type()</code></a> function that makes it very simple to connect a previously-registered taxonomy to a post type.  I could have used this, but WordPress <em>also</em> provides the ability to automatically register a taxonomy with a post type at the same time the post type itself is registered.  This is accomplished by adding a single item to the arguments array passed to <code>register_post_type()</code> when registering a new post type:</p>
<pre class="brush:php">//...additional arguments for the post type being registered
'taxonomies' =&gt; get_object_taxonomies('post')
</pre>
<p>By using <code>get_object_taxonomies('post')</code>, we can be sure that any taxonomies registered to the standard &#8220;post&#8221; post type is also registered to our custom content types.  In the future, I may add functionality to enable more control over which custom content types will inherit the taxonomies from WordPress&#8217; built-in post type, but for now this makes the edit form for custom content types functional and useful for those wanting to use the same basic taxonomies with all content types.</p>
<h3>Content Type Fields</h3>
<p><a href="http://archetyped.com/wp-content/uploads/cnr_content_type_fields.gif"><img class="alignnone size-full wp-image-548" title="Content Type Fields" src="http://archetyped.com/wp-content/uploads/cnr_content_type_fields.gif" alt="" width="247" height="327" /></a><br />
The final thing that remained to make Cornerstone compatible with WordPress 3.0 was displaying a content type&#8217;s predefined fields on the edit form.  The implementation prior to WordPress 3.0 employed multiple hooks to make it all work (since custom post type functionality was not as fully fleshed out as it is in 3.0), but now all I needed was one hook:</p>
<pre class="brush:php">add_action('do_meta_boxes', $this-&gt;m('admin_do_meta_boxes'), 10, 3);
//Build UI on post edit form
</pre>
<p>The handler is also very simple.  Once it confirms that the context is appropriate for building the fields for a content type, the processing is handed off to an instance object of the content type definition which has a method to build the fields in meta boxes for output on the edit form:</p>
<pre class="brush:php">function admin_do_meta_boxes($type, $context, $post) {
	//Validate $type. Should be 'post', 'page', or a custom post type for our purposes
	if ( in_array($type, array_merge(array_keys($this-&gt;get_types()), array('post', 'page'))) ) {
		//Get content type definition
		$ct =&amp; $this-&gt;get_type($post);
		//Pass processing to content type instance
		$ct-&gt;admin_do_meta_boxes($type, $context, $post);
	}
}
</pre>
<h3>Coming up next</h3>
<p>With the compatibility work on Cornerstone out of the way, I can now continue where I left off before upgrading to WordPress 3.0 and start developing additional features and functionality for Cornerstone.  Here&#8217;s my basic plan:</p>
<ol>
<li>Complete compatibility testing, fixing any small issues I missed</li>
<li>Develop UI for managing custom content types and their fields</li>
</ol>
<p>The content type/field management UI will be heavy with &#8220;drag and drop&#8221; functionality to make adding and customizing content types very quick and simple.  This is one of the last major milestones I&#8217;m working towards before Cornerstone enters the public beta phase, so I am pretty excited to get started on this.</p>
<p>At the same time, I have a few other ideas for projects that have been dancing around in my head for the past few days and I&#8217;ve been itching to explore some of them.  I don&#8217;t intend to stay away from Cornerstone development for too long, but several of these projects will actually be using Cornerstone as the foundation of their functionality so I&#8217;ll still be working on Cornerstone as I explore these other projects.</p>
<p><a href="http://archetyped.com/lab/cornerstone-we-have-compatibility/"> Cornerstone: We have compatibility!</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on August 2, 2010 11:01pm</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/cornerstone-we-have-compatibility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lab &#8250; Cornerstone: Content Types in WordPress 3.0</title>
		<link>http://archetyped.com/lab/cornerstone-content-types-in-wordpress-3-0/</link>
		<comments>http://archetyped.com/lab/cornerstone-content-types-in-wordpress-3-0/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 08:42:43 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Content Types]]></category>
		<category><![CDATA[Cornerstone]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[WebDev]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://archetyped.com/?p=516</guid>
		<description><![CDATA[<p><em>Work starts on Wordpress 3.0 Compatibility</em></p>Today I began working on making Cornerstone compatible with Wordpress 3.0.  Content types (whose primary role is to allow creation of additional metadata fields for post types) was first on the list.]]></description>
			<content:encoded><![CDATA[<p><em>Work starts on WordPress 3.0 Compatibility</em></p><p>Today I began working on making <a href="http://archetyped.com/tools/cornerstone/" title="Cornerstone">Cornerstone</a> compatible with WordPress 3.0.  Content types (whose primary role is to allow creation of additional metadata fields for post types) was first on the list.</p>
<p>Prior to 3.0, I had developed my own implementation for creating, editing, and managing different post types from the admin menu.  Now that WordPress&#8217; own custom post type functionality was ready for these tasks, my first task was migrating the functionality of my custom implementation to use WordPress&#8217; implementation.  I considered my implementation a stopgap since I knew WordPress would have custom post type management sooner or later, so it wasn&#8217;t an unexpected task.  Nonetheless, I wasn&#8217;t exactly looking forward to it.  In the end, it wasn&#8217;t all that bad.</p>
<h3>Registering Custom Content Types</h3>
<p>The first thing I had to do was integrate my custom content type definitions with WordPress&#8217; own custom post type array.  While they are fairly similar at the base level, Cornerstone&#8217;s content types contain somewhat more data and functionality than WordPress&#8217; custom post type objects (mostly because Cornerstone&#8217;s content types also contain metadata field definitions for the custom content type), so I couldn&#8217;t just use WordPress&#8217; post type implementation.  In the end, it was a simple matter of calling the <code>register_post_type()</code> function during the registration of each custom content type in Cornerstone.  This way, custom post types are registered for each custom content type defined by Cornerstone and some of the work is handed off to WordPress.</p>
<h3>Administration Menus</h3>
<p>One of the main changes to WordPress&#8217; custom post type functionality in 3.0 is that management functionality can now be automatically setup for each custom post type.  Simply put, each custom post type now has a section in the admin menu with functionality to manage, edit, and add new items of the custom post type.  Registering each content type with WordPress (using the same <code>register_post_type()</code> call as above) handled this, and I was able to offload a bunch of custom functionality in Cornerstone onto WordPress itself.</p>
<h3>Content Item Management</h3>
<p>WordPress now handles listing all custom post type items, so displaying all items with a custom post type was fairly straightforward (it mostly consisted of me removing my custom handlers for this functionality).</p>
<p>In my custom implementation, all content items (e.g. posts) with custom content types were still identified as <em>posts</em> in the database as WordPress&#8217; custom post type functionality had not been completely integrated into the core prior to 3.0.  Instead, the custom type of a content item was saved as post metadata, which I felt was safer since I wasn&#8217;t sure how things would be changed in later revisions of the custom post type functionality.</p>
<h3>Tomorrow</h3>
<ol>
<li>
<h4>Including items with custom content types in default post query</h4>
<p>In 3.0, items with custom post types are not retrieved in standard post queries, meaning that they would not be displayed inline with other posts when content items chronologically (e.g. as in a blog).  The primary purpose of custom content types in Cornerstone is to allow different content items to contain specific metadata fields based on their content type.  This means that they should also have the option to be included in the standard post listing on a blog, so I&#8217;ll probably have to hook into the queries to make sure items with custom post types are included in the default post query.</li>
<li>
<h4>Global edit form functionality</h4>
<p>Also, since all content items were basically still defined as <em>posts</em> as far as WordPress was concerned pre-3.0, it was easily possible to assign new functionality to the post edit form that would show up when creating/editing items regardless of content type.  I will have to look into this a bit to determine what best way to add functionality (e.g. extra meta boxes) to the edit form for all items regardless of content type.</li>
</ol>
<p><a href="http://archetyped.com/lab/cornerstone-content-types-in-wordpress-3-0/"> Cornerstone: Content Types in WordPress 3.0</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on July 28, 2010 10:42pm</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/cornerstone-content-types-in-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lab &#8250; Pulling the Trigger</title>
		<link>http://archetyped.com/lab/pulling-the-trigger/</link>
		<comments>http://archetyped.com/lab/pulling-the-trigger/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 06:53:17 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://archetyped.com/?p=476</guid>
		<description><![CDATA[<p><em>Updated plugin development environment to WP 3.0</em></p>I held off on this move for far too long.  Wordpress 3.0 has been out for over a month now so I decided to finally update my plugin development environment with the latest and greatest version of Wordpress.]]></description>
			<content:encoded><![CDATA[<p><em>Updated plugin development environment to WP 3.0</em></p><p>I held off on this move for far too long.  <a title="Wordpress" href="http://wordpress.org/">WordPress 3.0</a> has been out for over a month now so I decided to <em>finally </em>update my plugin development environment with the latest and greatest version of WordPress.</p>
<p>I generally do not upgrade any production sites with the latest version of WordPress immediately just in case there are any zero-day vulnerabilities (e.g. bugs/security issues that were not detected during the beta testing stage), but the main reason I didn&#8217;t update my development environment to 3.0 is because I guessed (correctly) that it would break some of my plugins.  Some of the plugins I&#8217;m currently developing are quite large and hook into many areas of WordPress, so there are a multitude of possible points of failure depending on what has changed in the latest update.  I should have been testing my plugin during the beta phase for 3.0, but I resisted because I didn&#8217;t want to deal with trying to support two versions of WordPress that might have mutually exclusive plugin requirements.</p>
<p>However, since version 3.0 has been out for over a month now with nary a security issue or major bug reported, I decided it was only logical to upgrade my development environment to 3.0 and focus on the future.  Since my large plugins are not even publicly released yet, there&#8217;s no real reason to worry about backwards compatibility with older versions.  These plugins will now only support 3.0+.</p>
<p>Upon upgrading WordPress, I was not surprised (though still a little dismayed) to find that certain parts of my big plugin did break.  It&#8217;s not likely a major issue, and it&#8217;s not all bad because several areas of my plugin are now redundant thanks to some of the new features/functionality of 3.0.  This means I can optimize my code and deliver a smaller, faster, and more future-proof plugin.</p>
<p>The main thing I was dreading (since I was sure there would be some issues after the upgrade) was the huge amount of compatibility testing that would be required for the various features of my plugin on WordPress 3.0.  As I developed the plugin, testing was a regular part of my workflow whenever I updated a certain feature, so testing did not require a lot of time.  However, I now have to test the <em>entire </em>plugin before I can even start to think about continuing development.  This does not sound fun to me, but I hope to have the majority of the testing completed within the next 1-2 days.</p>
<p>A small setback in development, but honestly, it would have to have been done at some point in time anyway.  It&#8217;s better that I do it now rather than after I&#8217;ve developed even <em>more</em> functionality that would need to be tested and modified to be compatible with the latest version.   It&#8217;s also a good lesson for the future as I will now be including betas of upcoming versions of WordPress into my development workflow so that there will be a smoother transition when the next version of WordPress is released.</p>
<p><a href="http://archetyped.com/lab/pulling-the-trigger/"> Pulling the Trigger</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on July 26, 2010 08:53pm</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/pulling-the-trigger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lab &#8250; Simple Lightbox: Adding Options and Automation</title>
		<link>http://archetyped.com/lab/simple-lightbox-adding-options-and-automation/</link>
		<comments>http://archetyped.com/lab/simple-lightbox-adding-options-and-automation/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 03:05:00 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WebDev]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://archetyped.com/?p=401</guid>
		<description><![CDATA[<p><em>It takes work to make something simple</em></p>It takes work to make something simpleI spent some time today updating to make, well, simpler. The three main things I focused on were: Adding a link to the settings page from the plugins page Enabling/disabling lightbox functionality based on the type of page Automatically activating lightbox functionality for image links on a page Adding ...]]></description>
			<content:encoded><![CDATA[<p><em>It takes work to make something simple</em></p><p>I spent some time today updating <a href="http://archetyped.com/tools/simple-lightbox/" title="Simple Lightbox">Simple Lightbox</a> to make, well, simpler.</p>
<p>The three main things I focused on were:</p>
<ol>
<li>Adding a link to the settings page from the plugins page</li>
<li>Enabling/disabling lightbox functionality based on the type of page</li>
<li>Automatically activating lightbox functionality for image links on a page</li>
</ol>
<h3>Adding a link to the settings page from the plugin&#8217;s listing</h3>
<p>While it&#8217;s just a link under the plugin&#8217;s name, adding a link to the plugin&#8217;s settings page greatly enhances usability because it keeps the user from having to search through the sidebar menu for the settings page.  Since Simple Lightbox&#8217;s settings have been added to the built-in <strong>Media</strong> (<code>options-media.php</code>) settings page, it&#8217;s even more important that a direct link to the plugin&#8217;s settings are included so that users can easily customize the plugin after they install and activate it.</p>
<p><img class="alignnone size-full wp-image-417" title="Settings Link" src="http://archetyped.com/wp-content/uploads/simple-lightbox_settings_link.gif" alt="" width="446" height="52" /></p>
<p>I&#8217;ve seen other plugins add the settings link at the end of the list of links, but I think putting it in front of the other links is a better option because it is link most users will want to click for a plugin from the plugins page.</p>
<h3>Enabling/disabling lightbox functionality based on the type of page</h3>
<p>Next up was adding options to allow users to customize what types of pages the lightbox would be loaded on.  Depending on the type of site someone has, they may not have any image links certain pages (e.g. the home page or archive pages), so it would be a waste to load the lightbox on these pages.</p>
<p>I identified three groups of page types that users may or may not want to include Simple Lightbox on:</p>
<ol>
<li>The home page</li>
<li>Archive pages &#8211; Any non-home page that lists posts (e.g. by category, tag, date, search results, etc.)</li>
<li>Single Pages/Posts</li>
</ol>
<p>In my mind, the last group (single pages/posts) was the main use case for this plugin as a post&#8217;s full content is often only displayed on single pages, while excerpts are used for other page types (home page, archive pages, etc.).</p>
<p>Adding support for enabling/disabling the plugin on different page types was fairly straightforward and now users can choose when to load the client-side code.  I also cleaned up the code for building the admin settings UI so that only one function is needed to build the UI for all the setting fields instead of a separate function to build each field.  This extra step will make adding additional options to the settings menu incredibly quick and simple.  Simple for me, simple for you <img src='http://archetyped.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Automatically activating lightbox functionality for image links on a page</h3>
<p>The whole point of Simple Lightbox was for there to be an incredibly <em>simple</em> way to get a lightbox image viewer working on your site.  Version 1.0 greatly simplified the normal process by letting users customize the lightbox&#8217;s behavior from WordPress&#8217; admin menu and keeping users from having to dip into Javascript.  However, though users were free from mucking about in Javascript, version 1.0 still required users to edit their template files and add <code>rel="lightbox"</code> to any image links that they wanted to be displayed in a lightbox image viewer.  I&#8217;m more than confident that most users could handle this, but the plugin just didn&#8217;t feel <em>simple</em> to me with this additional step.  In version 1.1, all links to images on the page are automatically activated to open in a lightbox image viewer.  This is done by adding one line of Javascript to the page:</p>
<pre class="brush:js; light: true;">$$('a[href$=".jpg"]:not([rel~="lightbox"])', 'a[href$=".jpeg"]:not([rel~="lightbox"])', 'a[href$=".gif"]:not([rel~="lightbox"])', 'a[href$=".png"]:not([rel~="lightbox"])').each(function(el){var rel=(el.rel.length &gt; 0) ? el.rel + ' ' : ''; el.rel=rel + 'lightbox';});</pre>
<p>This code is run once the page is loaded and adds the necessary <code>rel="lightbox"</code> attribute to all links on the page that point to image files (e.g. jpg/jpeg, gif, and png files).  I&#8217;ve also added an option to the settings page to let users disable this automation if they want the plugin to keep its dirty hands off their pretty links.</p>
<p>All in all, I think these additional features make Simple Lightbox truly simple.  Check out <a href="http://archetyped.com/tools/simple-lightbox/" title="Simple Lightbox">Simple Lightbox</a> now and let me know if I need to add anything to make it even simpler <img src='http://archetyped.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://archetyped.com/lab/simple-lightbox-adding-options-and-automation/"> Simple Lightbox: Adding Options and Automation</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on June 2, 2010 05:05pm</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/simple-lightbox-adding-options-and-automation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Know &#8250; Scroll though files in Eclipse at light speed</title>
		<link>http://archetyped.com/know/scroll-though-files-in-eclipse-at-light-speed/</link>
		<comments>http://archetyped.com/know/scroll-though-files-in-eclipse-at-light-speed/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 04:23:54 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Speed]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http:/archetyped.com/</guid>
		<description><![CDATA[As your development-related projects get larger, you invariably will find yourself having to work with files with more lines of code.  Even with all of the great keyboard shortcuts for hopping around in a file that are available in Eclipse, there will still be a lot of scrolling involved in large files.  When we&#8217;re talking ...]]></description>
			<content:encoded><![CDATA[<p>As your development-related projects get larger, you invariably will find yourself having to work with files with more lines of code.  Even with all of the great keyboard shortcuts for hopping around in a file that are available in Eclipse, there will still be a lot of scrolling involved in large files.  When we&#8217;re talking about files with 3,000+ lines (not uncommon), scrolling through a file can become a very tedious thing.  You could set your mouse to scroll more than the standard 3 lines at a time, but then you&#8217;d have to live with that setting in <em>all</em> of your applications.</p>
<p>Thankfully, <a title="Eclipse website" href="http://www.eclipse.org/">Eclipse</a> offers an easy way to greatly minimize the amount of scrolling you have to do.  Simply hold down the <code>CTRL</code> key on the keyboard when scrolling with the mouse wheel in an editor and you will now be able to scroll an entire screen at a time.</p>
<p>This simple addition makes scrolling an excellent choice for navigating through a file of any size.</p>
<p><a href="http://archetyped.com/know/scroll-though-files-in-eclipse-at-light-speed/"> Scroll though files in Eclipse at light speed</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on February 3, 2010 06:23pm</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/know/scroll-though-files-in-eclipse-at-light-speed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lab &#8250; WordPress as CMS &#8211; Making the Connection</title>
		<link>http://archetyped.com/lab/wordpress-as-cms-making-the-connection/</link>
		<comments>http://archetyped.com/lab/wordpress-as-cms-making-the-connection/#comments</comments>
		<pubDate>Sat, 03 Feb 2007 21:03:11 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http:/archetyped.com/wordpress/wordpress-as-cms-making-the-connection/</guid>
		<description><![CDATA[One of the things that excited me (and scared me) about being able to create an unlimited number of content types was the connections that could be formed between items of different types. What excited me about this was the &#8220;automatic&#8221; nature of it&#8211; being able to define a connection between one content type and ...]]></description>
			<content:encoded><![CDATA[<p>One of the things that excited me (and scared me) about being able to create an unlimited number of content types was the connections that could be formed between items of different types.  What excited me about this was the &#8220;automatic&#8221; nature of it&#8211; being able to define a connection between one content type and another, and then everything else would take care of itself.  What scared me, was I wasn&#8217;t exactly sure <em>how</em> I was going to do this.</p>
<p>I spent some time yesterday working out the specifics of storing connections between content types and connections between different items (posts) and I&#8217;m pretty happy with the result.</p>
<h5>An example of how connections can be useful:</h5>
<p>Say you have 2 content types:</p>
<ol>
<li>Recipes</li>
<li>Ingredients</li>
</ol>
<p>Of course, all recipes must contain ingredients, so we need to tell the CMS that these two content types are connected.  We can also define the <em>type</em> of connection between these items (&#8220;One to One&#8221; or &#8220;One to Many&#8221;).</p>
<ul>
<li>One to One: One item of one content type can connect to one item of another content type</li>
<li>One to Many: One item of one content type can connect to several items of another content type</li>
</ul>
<p>Will a recipe need to connect to just one ingredient, or will it need to connect to several?  In this case, we would want to be able to connect a recipe to several ingredients, so we&#8217;re going to create a One to Many relationship between Recipes and Ingredients.</p>
<p>Now, when I&#8217;m adding a new recipe, thanks to the connection between these two content types, a list of ingredients will be displayed in the form to select ingredients that the recipe uses.  Since this is a One to Many relationship, each ingredient has a checkbox next to it so that I can select multiple ingredients from the list.  If it were a One to One relationship, the ingredients would be displayed as a drop-down list, which would only allow for one ingredient to be selected.</p>
<p>I really like the possibilities of this feature, but I think the goal now is to make it <em>usable</em>.  In my opinion, it&#8217;s quite powerful as a feature, but it&#8217;s also somewhat abstract.  So I&#8217;ve got to find a way to make it instantly clear how this feature could be useful to a user.</p>
<p><a href="http://archetyped.com/lab/wordpress-as-cms-making-the-connection/"> WordPress as CMS &#8211; Making the Connection</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on February 3, 2007 11:03am</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/wordpress-as-cms-making-the-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
