<?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; WebDev</title>
	<atom:link href="http://archetyped.com/tag/webdev/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; Making of: Favicon Rotator</title>
		<link>http://archetyped.com/lab/making-of-favicon-rotator/</link>
		<comments>http://archetyped.com/lab/making-of-favicon-rotator/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 20:46:28 +0000</pubDate>
		<dc:creator>Sol</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Favicon]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Story]]></category>
		<category><![CDATA[WebDev]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://archetyped.com/?p=607</guid>
		<description><![CDATA[From a one-line of hack I was inspired to make a "quick and simple" plugin for Wordpress. This is the story of how Favicon Rotator came to be.]]></description>
			<content:encoded><![CDATA[<p>From a one-line of hack I was inspired to make a <em>&#8220;quick and simple&#8221;</em> plugin for WordPress.  This is the story of how <a href="http://archetyped.com/tools/favicon-rotator/" title="Favicon Rotator">Favicon Rotator</a> came to be.</p>
<h3>Inspiration</h3>
<p>When designing this site, I created several different <a href="http://wikipedia.org/wiki/Favicon" target="_blank">favicons</a>.  I narrowed it down to the icons that I liked best, but in the end, I couldn&#8217;t decide on just one.</p>
<div id="attachment_609" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-609" title="Favorite Favicons" src="http://archetyped.com/wp-content/uploads/favorite_favicons.gif" alt="" width="300" height="70" /><p class="wp-caption-text">Favorite Favicons</p></div>
<p>Then I thought, &#8220;why not both?&#8221; and so with a simple line of code, I rewarded my indecision and setup the site&#8217;s theme to randomly choose between the two different favicons each time the site was loaded.</p>
<pre class="brush:xml;gutter:false">&lt;link rel="icon" type="image/gif" href="&lt;?php bloginfo('template_directory'); ?&gt;/images/favicon_&lt;?php echo rand(1, 2); ?&gt;.gif" /&gt;
</pre>
<p>It was a quick solution and I was happy with the end result, but maintainability is a big thing for me and I had thought that it would be great if a site&#8217;s favicon could be easily added or changed as simply as adding a photo to a post in WordPress.  Even better, if <em>multiple</em> icons were added, it would automatically rotate through them, displaying a random icon each time the site is loaded.  I&#8217;m not sure if anyone else does that or even wanted such an ability, but after adding multiple icons to this site, I knew it was something I dug.</p>
<h3>Exploration</h3>
<p>Once I <a href="http://archetyped.com/lab/cornerstone-we-have-compatibility/" title="Cornerstone: We have compatibility!">reached a milestone</a> in <a href="http://archetyped.com/tools/cornerstone/" title="Cornerstone">Cornerstone</a>, I decided to spend some time exploring some of the other ideas I had swirling around in my head.  Favicon Rotator was one of the ideas I decided to work on because I felt I could finish it quickly and would be good experience for the next phase of Cornerstone (administration UI&#8217;s, etc.).</p>
<h4>Planning</h4>
<p>The first step was planning out the plugin.  The concept was pretty simple (add/manage favicon from admin page) and the ideas I had for implementation (mostly) clear, but I find that it&#8217;s a good first step to get those ideas out on paper or screen.  Doing this helps to clarify the purpose and expectations for the project, making for a much smoother workflow overall.</p>
<p>I manage the majority of my projects using a customized version of <a href="http://www.tiddlywiki.com/" target="_blank">TiddlyWiki</a> (a small and fast self-contained wiki), so the first thing I did was create a new project and set about listing all of the features I envisioned for this project.  <strong>Total time:</strong> 5 minutes.</p>
<div id="attachment_610" class="wp-caption alignnone" style="width: 510px"><img class="size-full wp-image-610" title="Feature List" src="http://archetyped.com/wp-content/uploads/favicon-rotator_features.png" alt="" width="500" height="281" /><p class="wp-caption-text">Feature List: Different colors indicate feature progress</p></div>
<h4>Wireframes</h4>
<p>While not always necessary, <a href="http://en.wikipedia.org/wiki/Website_wireframe" target="_blank">wireframing</a> is a quick way to iterate through ideas to optimize a layout.  The goal was to make it incredibly simple to add a favicon to the site, so sketching out a few wireframes of the admin interface to make it as simple as possible would be time well spent.</p>
<div id="attachment_612" class="wp-caption alignnone" style="width: 160px"><a href="http://archetyped.com/wp-content/uploads/favrot_wf_01.gif"><img class="size-thumbnail wp-image-612" title="Initial Wireframes - Rapid Iteration" src="http://archetyped.com/wp-content/uploads/favrot_wf_01-150x150.gif" alt="" width="150" height="150" /></a><p class="wp-caption-text">Initial Wireframes - Rapid Iteration</p></div>
<p>I drew out the wireframes with a thick sharpie to keep focus on the overall UI design and to keep from getting lost in the little details at this point.  I love to take the time to focus on the tiniest details, but at this phase the big picture was the priority so that I could move to the next phase quickly.  This worked out really well and helped me to arrive at an overall layout that I was happy to move forward with after a few iterations. <strong>Total time:</strong> 45 minutes.</p>
<div id="attachment_611" class="wp-caption alignnone" style="width: 160px"><a href="http://archetyped.com/wp-content/uploads/favrot_wf_02.gif"><img class="size-thumbnail wp-image-611" title="Final Wireframes" src="http://archetyped.com/wp-content/uploads/favrot_wf_02-150x150.gif" alt="" width="150" height="150" /></a><p class="wp-caption-text">Final Wireframes</p></div>
<h3>Experimentation</h3>
<p>Now that I knew what I wanted the plugin to do and how I wanted it to work, it was now time to develop it!  This was the basic order of events during development:</p>
<ol>
<li>Build administration UI
<ul>
<li>Setup layout (based on wireframes)</li>
<li>Add functionality to elements (“add new” button, “remove icon” buttons, “save changes” button, etc.)</li>
</ul>
</li>
<li>Handle retrieving icon(s) from the database</li>
<li>Handle saving icon selection(s) to the database</li>
<li>Handle uploading and selecting images to use as icons</li>
<li>Randomly select an icon and display it when site is loaded</li>
</ol>
<h4>1. Build administration UI</h4>
<p>Building the UI was quick and simple thanks to the wireframes.  I&#8217;ve also used much of WordPress&#8217; own CSS classes for many UI elements (buttons, headers, etc.), which I think is always a good idea because it makes it easier for users to use (since they&#8217;re already familiar with WP&#8217;s UI), it saves time when building the UI, and it will remain consistent with the rest of WordPress&#8217; admin UI if they ever change the official design.  For the icon containers themselves, I&#8217;ve decided to keep the design rather simple, but may decide to make them a bit more &#8220;WordPress-y&#8221; in the future so that it looks fully integrated.</p>
<div id="attachment_602" class="wp-caption alignnone" style="width: 400px"><img class="size-full wp-image-602" title="Favicon Management" src="http://archetyped.com/wp-content/uploads/favicon-rotator_admin-page.png" alt="" width="390" height="230" /><p class="wp-caption-text">Favicon Management UI</p></div>
<h4>2. Handle retrieving icon(s) from the database</h4>
<p>Since the functionality to actually <em>add</em> an icon to the list had not yet been developed (see step 4), I started off by adding some temporary data to the <code>wp_options</code> table where I would be storing the icon selections.  Using that data, I developed the functionality to retrieve those values and build an element with the necessary icon information to be displayed to the user.  Icon data was also added to a hidden form field that was updated whenever the icon selection was changed.</p>
<h4>3. Handle saving icon selection(s) to the database</h4>
<p>Though users added/removed favicons in a very visual &#8220;point and click&#8221; way, saving their changes was a much more straightforward process.  Data for the selected icons are stored in a hidden form field which is updated with a dash of Javascript whenever favicons are added and removed from the list.  When the &#8220;Save changes&#8221; button is clicked, the value from this form field is simply saved to the database.</p>
<h4>4. Handle uploading and selecting images to use as icons</h4>
<p>WordPress already has fairly robust media management capabilities built-in and since I&#8217;ve used it quite a bit in Cornerstone, I decided to use it in Favicon Rotator too.  Mind you, this is not simply plug and play as there are a number of hoops to jump through to place nice with WordPress.  Thankfully, no hacks are needed (mostly) because WordPress&#8217; provides the necessary plugin hooks.</p>
<h5><strong>Launching the media upload UI</strong></h5>
<p>Launching the media upload UI is pretty straightforward.  Just build a link to <code>admin/media_upload.php</code> with the appropriate URL query variables set.</p>
<pre class="brush:html;gutter:false">&lt;a href="http://archetyped.com/wp-admin/media-upload.php?post_id=0&amp;tab=type&amp;type=fvrt_icon&amp;fvrt_action=1&amp;TB_iframe=1" class="thickbox"&gt;Open Upload UI&lt;/a&gt;
</pre>
<p>The necessary URL query variables are:</p>
<ul>
<li><code>post_id</code> &#8211; The ID of the post that the media is being uploaded for.  Media uploads are referred to as &#8220;attachments&#8221; in WordPress because they are <em>attached</em> to other content (posts, pages, etc.).  In this case, we don&#8217;t want to attach the upload icons to a specific post, so we just set this variable to <code>0</code></li>
<li><code>tab</code> &#8211; The media management UI has several tabs, each with a different purpose (upload media, browse library, etc.).  The upload tab is displayed by default, but in this case, this variable is set to <code>type</code>, which will cause the type URL variable to be processed (see below for why)</li>
<li><code>type</code> &#8211; The type of media being uploaded/browsed (image, audio, video, etc.).  When the type is processed, WordPress fires an action formatted as <code>media_upload_{type}</code>, so in our case, an action called <code>media_upload_fvrt_icon</code> will be fired.  I can then hook into this action to gain control over how uploads are handled.</li>
<li><code>fvrt_action</code> &#8211; Specifies that the media upload UI was launched by Favicon Rotator.  This is a custom variable I add so that I can quickly determine whether to hook into the actions and filters fired by the media upload UI (e.g. when the UI is launched to upload images for a post, I don&#8217;t need to hook into it).</li>
<li><code>TB_iframe</code> &#8211; Whether or not the media UI is launched in an iframe (which it is in when used on the post edit form and in Favicon Rotator).</li>
</ul>
<p>Also, by adding class=&#8221;thickbox&#8221; to the link, the resulting link will open in a non-modal popup (a lightbox) without leaving the current page.  I also needed to load the necessary files for the thickbox functionality:</p>
<pre class="brush:php;gutter:false">add_thickbox(); //Adds thickbox files to page header</pre>
<h5>Add an &#8220;Add icon&#8221; button to uploaded media</h5>
<p>Once the media upload UI is displayed, we need a way for the user to select an image and add it to the list of favicons.  To do this, Favicon Rotator hooks into the <code>attachment_fields_to_edit</code> filter to modify the fields/buttons that are displayed when viewing an attachment&#8217;s details in the media management UI.</p>
<p>Using this filter, all extraneous edit fields and buttons are removed (to keep things as simple as possible) and the &#8220;Add icon&#8221; button is added.</p>
<p>The end result is a clean UI with a simple button to add an icon to the list</p>
<div id="attachment_613" class="wp-caption alignnone" style="width: 160px"><a href="http://archetyped.com/wp-content/uploads/media_details_default.png"><img class="size-thumbnail wp-image-613" title="Default Media Details" src="http://archetyped.com/wp-content/uploads/media_details_default-150x150.png" alt="" width="150" height="150" /></a><p class="wp-caption-text">Default Media Details</p></div>
<div id="attachment_614" class="wp-caption alignnone" style="width: 160px"><a href="http://archetyped.com/wp-content/uploads/media_details_favrot.png"><img class="size-thumbnail wp-image-614" title="Media Details for favicon selection" src="http://archetyped.com/wp-content/uploads/media_details_favrot-150x150.png" alt="" width="150" height="150" /></a><p class="wp-caption-text">Media Details for favicon selection</p></div>
<h5>Adding the selected icon to the list</h5>
<p>Once the user has clicked the &#8220;Add icon&#8221; button for an image, the final step is sending the selected icon from the media management UI (in the &#8220;lightbox&#8221; popup) into the favicon list on the admin page.  This is handled in essentially the same way that images are inserted into posts.  The basic methodology is as follows:</p>
<ol>
<li>User clicks &#8220;Add icon&#8221; button for an image.  This submits a form.</li>
<li>The form submission is evaluated to determine which image the &#8220;Add icon&#8221; button was clicked for</li>
<li>The image&#8217;s details (ID, source URL, and file name) are sent via Javascript to the underlying admin page</li>
<li>The media upload UI is closed</li>
</ol>
<p>Once the admin page receives the image data, it builds a new icon container for the image and adds it to the list of icons.  The image&#8217;s ID is then added to the hidden form field that corresponds to the icons in the list.</p>
<p>Finally (phew!), when the user clicks the &#8220;Save changes&#8221; button, the icon ID&#8217;s are saved in the <code>wp_options</code> table for safe-keeping.  This is the other benefit of using WordPress&#8217; built-in media management functionality&#8211; since attachments in WordPress are essentially posts, we can simply save their ID and reference it to retrieve the rest of their data.  As a bonus, WordPress also has several functions specifically for retrieving attachment data (source URL, etc.) which saves us from having to develop those tools ourselves.</p>
<p>Development was clearly the longest phase in the entire process, but it  was sped up greatly by the initial planning and wireframing that gave me  a clear direction for the entire development phase.  <strong>Total time:</strong> 19 hours</p>
<h3>Wrap Up</h3>
<p>The initial motivation for developing Favicon Rotator was to provide others with the capability to display multiple favicons randomly like this site does.  However, during development, I realized that the real value of the plugin was quite a bit simpler and made it useful to a much wider audience.  Favicon Rotator enables anyone to easily add a favicon to their site (regardless of whether or not they want to rotate between multiple icons).  Users no longer need to edit theme files, manually upload images via FTP, or copy/paste URL&#8217;s to favicon files just to simply add a favicon to their site.</p>
<p>This is a capability that is missing in WordPress at the moment, so while I&#8217;m happy that I made a plugin that accomplishes my initial (though obscure) goal of icon randomness, I&#8217;m actually more enthused about the plugin&#8217;s potential to enable users to easily do something that may have been out of reach for them previously.</p>
<p><a href="http://archetyped.com/lab/making-of-favicon-rotator/"> Making of: Favicon Rotator</a> was originally published on <a href="http://archetyped.com">Archetyped</a> on August 17, 2010 10:46am</p>]]></content:encoded>
			<wfw:commentRss>http://archetyped.com/lab/making-of-favicon-rotator/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: 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; 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>
	</channel>
</rss>
