<?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>Clifton Griffin&#187; Code</title>
	<atom:link href="http://clifgriffin.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://clifgriffin.com</link>
	<description>I develop simple solutions to complex problems.</description>
	<lastBuildDate>Sat, 30 Mar 2013 16:04:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Switching WordPress Databases and Git Branches Simultaneously</title>
		<link>http://clifgriffin.com/2011/12/15/switching-wordpress-database-and-git-branches-simultaneously/</link>
		<comments>http://clifgriffin.com/2011/12/15/switching-wordpress-database-and-git-branches-simultaneously/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 14:55:08 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=1366</guid>
		<description><![CDATA[I&#8217;ve recently switched to a rather rad workflow involving a local copy of our website run through MAMP using a git repository. We&#8217;ve recently started working on a bigger set of changes that require a feature branch. But, these changes also will require WordPress to be upgraded to 3.3, requiring database changes.  Making it impossible [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve recently switched to a rather rad workflow involving a local copy of our website run through MAMP using a git repository.</p>
<p>We&#8217;ve recently started working on a bigger set of changes that require a feature branch. But, these changes also will require WordPress to be upgraded to 3.3, requiring database changes.  Making it impossible to use the same database.</p>
<p>I was able to come up with this nifty technique for determining which DB to use.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$stringfromfile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.git/HEAD'</span><span style="color: #339933;">,</span> FILE_USE_INCLUDE_PATH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$stringfromfile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$stringfromfile</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//get the string from the array</span>
<span style="color: #000088;">$explodedstring</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$stringfromfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//separate out by the &quot;/&quot; in the string</span>
<span style="color: #000088;">$branchname</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$explodedstring</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//get the one that is always the branch name</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ** MySQL settings - You can get this info from your web host ** //</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$branchname</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;master&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #009933; font-style: italic;">/** The name of the database for WordPress */</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wordpress_local'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wordpress_new'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>That&#8217;s all there is to it. It works flawlessly.</p>
<p>Happy coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2011/12/15/switching-wordpress-database-and-git-branches-simultaneously/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding Autocomplete Search To Shopp</title>
		<link>http://clifgriffin.com/2011/10/11/adding-autocomplete-search-to-shopp/</link>
		<comments>http://clifgriffin.com/2011/10/11/adding-autocomplete-search-to-shopp/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 16:35:22 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=1360</guid>
		<description><![CDATA[This week I tackled another long term todo: autocomplete. It was a fun project with the right amount of difficulties and surprises along the way. To make this possible, I used jQuery Marco Polo, a very nice autocomplete plugin available here: https://github.com/jstayton/jquery-marcopolo I had to modify it to make it work exactly how I wanted, [...]]]></description>
				<content:encoded><![CDATA[<p>This week I tackled another long term todo: autocomplete. It was a fun project with the right amount of difficulties and surprises along the way.</p>
<p>To make this possible, I used jQuery Marco Polo, a very nice autocomplete plugin available here: <a href="https://github.com/jstayton/jquery-marcopolo">https://github.com/jstayton/jquery-marcopolo</a></p>
<p>I had to modify it to make it work exactly how I wanted, but it does the job.</p>
<p>Basically, jQuery Marco Polo takes input into a search field and runs it against a URL in realtime using AJAX.  It expects a JSON response from this URL.  It has many options on how to display items and what to do when items are clicked.</p>
<p>The first challenge was getting the results into JSON. To do this, I created a function to intercept requests that match a certain format: /q=?somesearchterm&#038;ajax=true</p>
<p>Pretty basic.  Here is the function:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ajax_autocomplete_search'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> ajax_autocomplete_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'q'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ajax'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ajax'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;true&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'q'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$q</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'q'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'search-products'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;load=true&amp;search=<span style="color: #006699; font-weight: bold;">$q</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'has-products'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$Shopp</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$filter_cat</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$used_products</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'products'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$count</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000088;">$product_id</span> <span style="color: #339933;">=</span> shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'return=true'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'product'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;id=<span style="color: #006699; font-weight: bold;">$product_id</span>&amp;load=true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'/name-vars.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$first_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$used_products</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$used_products</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$first_name</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'coverimage'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'width=60&amp;height=60'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$image_tag</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ob_get_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #000088;">$summary</span> <span style="color: #339933;">=</span> shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'summary'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'return=true'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$slug</span> <span style="color: #339933;">=</span> shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'slug'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'return=true'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$summary</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$summary</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$summary</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$summary</span><span style="color: #339933;">,</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;…&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">else</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$summary</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$summary</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'in-category'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;name=<span style="color: #006699; font-weight: bold;">$filter_cat</span>&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filter_cat</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$filter_cat</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Everything&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$results</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$first_name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'summary'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$summary</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'image'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$image_tag</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'slug'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$slug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000088;">$count</span><span style="color: #339933;">++;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$Shopp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">products</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$results</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'summary'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'See All Search Results'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'search'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'s'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'category'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #990000;">die</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now, you&#8217;re going to notice right away that there are a lot of specific things going on here that cater to the specific way I implemented this.  For instance, I only show the first 3 results with a &#8220;See All Results&#8221; footer.  This also assumes that you, like me, have implemented a category filtered search <a href="http://clifgriffin.com/2011/10/07/search-by-category-in-shopp/">as described here.</a>  There is also some custom stuff in there based on the way we name things. (that&#8217;s the name-vars.php and $first_name stuff&#8230;I won&#8217;t go into that)</p>
<p>No matter.  You should be able to see what I&#8217;m doing and modify it as necessary.</p>
<p>So that, with some modification, should throw some nice JSON responses out.</p>
<p>Other than that, I just used the following JavaScript:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#category-dropdown&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input.search'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">marcoPolo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				  url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'/?wp-minify-off=1&amp;category='</span> <span style="color: #339933;">+</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#category-dropdown&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&amp;x=0&amp;y=0&amp;ajax=true'</span><span style="color: #339933;">,</span>
				  param<span style="color: #339933;">:</span> <span style="color: #3366CC;">'q'</span><span style="color: #339933;">,</span>
				  formatItem<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>data<span style="color: #339933;">,</span> $item<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				  	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">name</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;footer&quot;</span><span style="color: #009900;">&#41;</span>
				  	<span style="color: #009900;">&#123;</span>
				   		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'&lt;h2&gt;'</span> <span style="color: #339933;">+</span> data.<span style="color: #660066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/h2&gt;'</span> <span style="color: #339933;">+</span> data.<span style="color: #660066;">image</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;p&gt;'</span> <span style="color: #339933;">+</span> data.<span style="color: #660066;">summary</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
				   	<span style="color: #009900;">&#125;</span>
				   	<span style="color: #000066; font-weight: bold;">else</span>
				   	<span style="color: #009900;">&#123;</span>
				   		$item.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'footer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				   		<span style="color: #000066; font-weight: bold;">return</span> data.<span style="color: #660066;">summary</span><span style="color: #339933;">;</span>
				   	<span style="color: #009900;">&#125;</span>
				  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				  onSelect<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>data<span style="color: #339933;">,</span> $item<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				  	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">name</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;footer&quot;</span><span style="color: #009900;">&#41;</span>
				  	<span style="color: #009900;">&#123;</span>
				    	window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'/shop/'</span> <span style="color: #339933;">+</span> data.<span style="color: #660066;">slug</span><span style="color: #339933;">;</span>
				    <span style="color: #009900;">&#125;</span>
				    <span style="color: #000066; font-weight: bold;">else</span>
				    <span style="color: #009900;">&#123;</span>
				    	window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'/?s='</span> <span style="color: #339933;">+</span> data.<span style="color: #660066;">search</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&amp;category='</span> <span style="color: #339933;">+</span> data.<span style="color: #660066;">category</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&amp;catalog=true'</span><span style="color: #339933;">;</span>
				    <span style="color: #009900;">&#125;</span>
				  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				  formatNoResults<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>q<span style="color: #339933;">,</span> $item<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				  	$item.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mp_selectable&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				  	$item.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				  		window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'/?s='</span> <span style="color: #339933;">+</span> q <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&amp;category=Everything&amp;catalog=true'</span><span style="color: #339933;">;</span>
				  	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				  	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'&lt;em&gt;No results for &lt;strong&gt;'</span> <span style="color: #339933;">+</span> q <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/strong&gt; in '</span> <span style="color: #339933;">+</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#category-dropdown&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.&lt;br /&gt;&lt;br /&gt; Try your search again in Everything?&lt;/em&gt;'</span><span style="color: #339933;">;</span>
				  <span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#category-dropdown&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Again, not the briefest example. It&#8217;s either show all or show nothing. You&#8217;re going to have to work around my particular usage of all of these things.  I instantiate Marco Polo when the dropdown is changed because the search URL depends on the drop down selection.</p>
<p>I modified Marco Polo to get rid of it&#8217;s hijacking of the ENTER key, etc.  I just removed all of the key binding because it didn&#8217;t support the way I wanted to use it.</p>
<p>You can see this fully working here: <a href="http://www.mooreandgiles.com">Moore and Giles, Inc.</a></p>
<p>Type in Brompton, for example.</p>
<p>That&#8217;s it.  Feel free to ask questions.<br />
Clif</p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2011/10/11/adding-autocomplete-search-to-shopp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Search by Category in Shopp</title>
		<link>http://clifgriffin.com/2011/10/07/search-by-category-in-shopp/</link>
		<comments>http://clifgriffin.com/2011/10/07/search-by-category-in-shopp/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 20:56:17 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=1357</guid>
		<description><![CDATA[Today I saw a thread on the Shopp forums asking how to limit a search to a particular category. As this was on my big list, I decided to tackle it. It turns out to not be very difficult, once you understand the way Shopp handles searches. The trick is that the category template (i.e., [...]]]></description>
				<content:encoded><![CDATA[<p>Today I saw a thread on the Shopp forums asking how to limit a search to a particular category.  As this was on my big list, I decided to tackle it.</p>
<p>It turns out to not be very difficult, once you understand the way Shopp handles searches.</p>
<p>The trick is that the category template (i.e., theme/shopp/category.php) is used to display searches.  This allows you to easily jump in and decide how it is displayed, based on your own criteria.</p>
<p>So, you will want to create a copy of your category.php file named something like category-default.php.  Then create a separate file named category-search.php. The former file will handle the default category page functionality.  The second will handle searches only.</p>
<p>In category.php,  do something like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'s'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'catalog'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category-search.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category-default.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Basically, if the URL parameters for a search exist, use the search template, otherwise, stick to the normal game plan.</p>
<p>Then in category-search.php, you&#8217;re going to want to use your own loop to exclude every category but the one you&#8217;re interested in:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'has-products'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'products'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	 	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>shopp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'in-category'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;name=<span style="color: #006699; font-weight: bold;">$category</span>&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$category</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Everything&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		// your code to display in your own html using the product tags (model it after the default category template, for example)
&nbsp;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Lastly, you&#8217;ll want to render the search form yourself instead of using the default widget. For example:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">			&lt;form id=&quot;search&quot; action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; method=&quot;get&quot; accept-charset=&quot;utf-8&quot;&gt;
				&lt;div class=&quot;search-perimeter&quot;&gt;
					&lt;input autocomplete=&quot;off&quot; class=&quot;search&quot; type=&quot;text&quot; name=&quot;s&quot; value=&quot;&quot; id=&quot;find&quot; /&gt;
					&lt;select size=1 name=&quot;category&quot; id=&quot;category-dropdown&quot; title=&quot;Search in&quot;&gt;
						&lt;option value=&quot;Category 1 Name&quot;&gt;Category 1 Name&lt;/option&gt;
						&lt;option value=&quot;Category 2 Name&quot;&gt;Category 2 Name&lt;/option&gt;
						&lt;option value=&quot;Everything&quot;&gt;Everything&lt;/option&gt;
					&lt;/select&gt;
					&lt;input type=&quot;image&quot; class=&quot;search-button&quot; src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'template_url'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/images/search.png&quot; /&gt;
				&lt;/div&gt;
				&lt;input type=&quot;hidden&quot; name=&quot;catalog&quot; value=&quot;true&quot; id=&quot;catalog&quot; /&gt;
			&lt;/form&gt;</pre></td></tr></table></div>

<p>That&#8217;s about all there is to it. You&#8217;ll have to get in deep with the templates, but I think you&#8217;ll agree this is conceptually pretty simple.</p>
<p>Lastly, you should note: Category names seem to be case sensitive. &#8220;Bags&#8221; != &#8220;bags&#8221;</p>
<p>Good luck,<br />
Clif</p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2011/10/07/search-by-category-in-shopp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Improve HTML E-mails from WordPress, automagically</title>
		<link>http://clifgriffin.com/2011/10/07/improve-html-e-mails-from-wordpress-automagically/</link>
		<comments>http://clifgriffin.com/2011/10/07/improve-html-e-mails-from-wordpress-automagically/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 13:27:36 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=1353</guid>
		<description><![CDATA[HTML e-mails are like wild stallions.  They are really hard to tame. I have been frustrated by the vastly different ways e-mails from my company&#8217;s site (http://www.mooreandgiles.com) render in different clients.  After some research, I decided the trick to fix this would be inlining all CSS styles, as various clients will haphazardly abort style blocks you [...]]]></description>
				<content:encoded><![CDATA[<p>HTML e-mails are like wild stallions.  They are really hard to tame.</p>
<p>I have been frustrated by the vastly different ways e-mails from my company&#8217;s site (http://www.mooreandgiles.com) render in different clients.  After some research, I decided the trick to fix this would be inlining all CSS styles, as various clients will haphazardly abort style blocks you include in your e-mails.</p>
<p>Being lazy and wanting to the greatest flexibility for modifying templates in the future, I came up with a way to automatically process e-mails and inline their styles as they leave.   As this hooks into wp_mail, it should work with most plugins that send HTML e-mails.  Some may go around WordPress and use PHP mail&#8230;I can&#8217;t help you there.</p>
<p>In your theme functions file, add this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_mail'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'html_email_prep'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> html_email_prep<span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'headers'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;html&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$email</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Grab CSS block</span>
		<span style="color: #b1b100;">require_once</span> TEMPLATEPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'/css_to_inline_styles.php'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$cssConverter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CSSToInlineStyles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$cssConverter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCleanup</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$cssConverter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setHTML</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$cssConverter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUseInlineStylesBlock</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$new_html</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cssConverter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">convert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$email</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new_html</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$email</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And, simply dropp css_to_inline_styles.php in your theme folder.   You may download it here: <a href="http://blog.verkoyen.eu/blog/p/detail/convert-css-to-inline-styles-with-php">http://blog.verkoyen.eu/blog/p/detail/convert-css-to-inline-styles-with-php</a></p>
<p>With this in place, it will automatically parse outgoing e-mail messages.  It will find the style block and inline each style, automagically. This instantly fixed most of the rendering problems I was having in various clients.</p>
<p>It automatically excludes e-mails that don&#8217;t have HTML.  I have seen the class bork up one HTML template, but making a minor change to the markup avoided the problem easily.  Make sure you test. </p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2011/10/07/improve-html-e-mails-from-wordpress-automagically/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Twitch for Blinksale</title>
		<link>http://clifgriffin.com/2011/04/15/twitch-for-blinksale/</link>
		<comments>http://clifgriffin.com/2011/04/15/twitch-for-blinksale/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 01:40:06 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=1295</guid>
		<description><![CDATA[After many late nights, long weekends, and a couple of months I am finally finished with version 1.0 of Twitch for Blinksale. Twitch for Blinksale is the first native iPhone/iOS client for the popular invoicing service Blinksale. With Twitch, you can manage all of your invoicing needs right from your iPhone. Its clean, professional design [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1315" style="clear: both;" title="Twitch for Blinksale" src="http://clifgriffin/wp-content/uploads/2011/04/twitch_rounded.png" alt="Twitch for Blinksale - An iPhone app for Blinksale" width="191" height="190" />After many late nights, long weekends, and a couple of months I am finally finished with version 1.0 of Twitch for Blinksale.</p>
<p>Twitch for Blinksale is the first native iPhone/iOS client for the popular invoicing service Blinksale.  With Twitch, you can manage all of your invoicing needs right from your iPhone.</p>
<p>Its clean, professional design highlights the information you need. Updating invoices on-the-go has never been easier.</p>
<p>Invoices Features:</p>
<ul>
<li>View, add, update invoices.</li>
<li>Send invoices to clients with or without payment link.</li>
<li>Receive payment for invoices.</li>
</ul>
<p>Client Features:</p>
<ul>
<li>View and add clients.</li>
<li>Add people to clients.</li>
<li>Contact clients directly from phone (using the iPhone&#8217;s phone and mail apps)</li>
</ul>
<p>More:</p>
<ul>
<li>Convenient, &#8220;Pull To Refresh&#8221; design on invoice and client views makes reloading data a cinch.</li>
<li>Tested on multiple iPhone devices and OS versions.</li>
<li>Very stable.</li>
<li>Secure credential storage in keychain.</li>
</ul>
<p>Screenshots:</p>
<p><a href="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-58-50-PM.jpg"><img class="alignnone size-medium wp-image-1297" title="Invoice Detail View" src="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-58-50-PM-200x300.jpg" alt="" width="200" height="300" /></a><a href="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-59-03-PM.jpg"><img class="alignnone size-medium wp-image-1298" title="Invoice Detail View" src="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-59-03-PM-200x300.jpg" alt="" width="200" height="300" /></a><a href="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-59-13-PM.jpg"><img class="alignnone size-medium wp-image-1299" title="Invoice Action menu.  Lots of options." src="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-59-13-PM-200x300.jpg" alt="" width="200" height="300" /></a><br/><img class="alignnone size-medium wp-image-1300" title="Invoice Creation View" src="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-59-22-PM-200x300.jpg" alt="" width="200" height="300" /><img class="alignnone size-medium wp-image-1301" title="Client List View" src="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-59-31-PM-200x300.jpg" alt="" width="200" height="300" /><img class="alignnone size-medium wp-image-1302" title="Client Detail View" src="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-59-40-PM-200x300.jpg" alt="" width="200" height="300" /></p>
<p>&nbsp;</p>
<p><a href="http://clifgriffin/wp-content/uploads/2011/04/Photo-Apr-09-3-59-31-PM.jpg"></a></p>
<p>Twitch for Blinksale is <a href="itunes.apple.com/us/app/twitch-for-blinksale/id431491955?mt=8&amp;ls=1">available for purchase in the App Store</a>.</p>
<p><a href="itunes.apple.com/us/app/twitch-for-blinksale/id431491955?mt=8&amp;ls=1"><img class="alignnone size-full wp-image-1317" title="Twitch for Blinksale" src="http://clifgriffin/wp-content/uploads/2011/04/available_on_appstore_11.png" alt="Available in the iPhone app store" width="150" height="50" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2011/04/15/twitch-for-blinksale/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Bulk Updating Image Sizes in @ShopPlugin</title>
		<link>http://clifgriffin.com/2011/03/30/bulk-updating-image-sizes-in-shopplugin/</link>
		<comments>http://clifgriffin.com/2011/03/30/bulk-updating-image-sizes-in-shopplugin/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 19:01:37 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=1291</guid>
		<description><![CDATA[This will be two helper scripts I&#8217;ve written in a row for Shopp. We found a situation recently where we had images with different sizes in Shopp, making uniform usage difficult at times. To compensate for this, we exported the images again. Since we use a consistent naming scheme, we didn&#8217;t have to worry about [...]]]></description>
				<content:encoded><![CDATA[<p>This will be two helper scripts I&#8217;ve written in a row for Shopp.</p>
<p>We found a situation recently where we had images with different sizes in Shopp, making uniform usage difficult at times.  To compensate for this, we exported the images again.  Since we use a consistent naming scheme, we didn&#8217;t have to worry about names.</p>
<p>We then uploaded these new images over the existing images in the /wp-content/uploads/shopp folder.</p>
<p>In a perfect world, this would be all there was to it, but unfortunately Shopp stores width and height information about an image in the database.  This meant each table entry had to be updated.  Enter this script.</p>
<p>It automatically scans your uploads directory and looks for images that have a different size than is stored in the database.  It then updates the size.</p>
<p><strong><span style="color: #ff0000;">WARNING: This script is DESTRUCTIVE.  It can potentially screw up your database so PLEASE make sure you have a full backup.  This is provided without any warranty whatsoever. I have only tested this on Shopp 1.1.17 and have no idea how it will work/not work on other versions.</span></strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//Adjust to point to root from where this script is located</span>
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">'../wp-load.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Edit this path</span>
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/var/www/vhosts/domain/httpdocs/wp-content/uploads/shopp'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// END EDITS. You shouldn't have to edit below this line.</span>
&nbsp;
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: text/plain&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;auto_detect_line_endings&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dir_handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$csv_data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir_handle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$width_regex</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/((?&lt;=width\&quot;;i:)[0-9]{1,4})|((?&lt;=width=\&quot;)[0-9]{1,4})/'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$height_regex</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/((?&lt;=height\&quot;;i:)[0-9]{1,4})|((?&lt;=height=\&quot;)[0-9]{1,4})/'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select value from wp_shopp_meta where value LIKE '%&quot;</span><span style="color: #0000ff;">&quot;.<span style="color: #006699; font-weight: bold;">$file</span>.&quot;</span><span style="color: #0000ff;">&quot;%'&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <span style="color: #990000;">getimagesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$existing_properties</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_var</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$existing_properties</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$new_width</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$new_height</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width_regex</span><span style="color: #339933;">,</span> <span style="color: #000088;">$existing_properties</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_width</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$height_regex</span><span style="color: #339933;">,</span> <span style="color: #000088;">$existing_properties</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_width</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$old_width</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$new_height</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$old_height</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_width</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_height</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Updating <span style="color: #006699; font-weight: bold;">$file</span>. Old width/height: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$old_width</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$old_height</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; New width/height: <span style="color: #006699; font-weight: bold;">$new_width</span>/<span style="color: #006699; font-weight: bold;">$new_height</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000088;">$new_properties</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width_regex</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$existing_properties</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$new_properties</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$height_regex</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_height</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_properties</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_properties</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$query_update</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;update wp_shopp_meta set value = '&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_properties</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' where value LIKE '%&quot;</span><span style="color: #0000ff;">&quot;.<span style="color: #006699; font-weight: bold;">$file</span>.&quot;</span><span style="color: #0000ff;">&quot;%'&quot;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #666666; font-style: italic;">//echo &quot;Query update: &quot;.$query_update.&quot;n&quot;;</span>
&nbsp;
					<span style="color: #000088;">$update</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query_update</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$update</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; --- FAILED. No rows changed. Didn't update.n&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$update</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; --- POSSIBLE FAILURE. Updated too many rows.(<span style="color: #006699; font-weight: bold;">$update</span>)n&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">else</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; --- SUCCESSn&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;--- FAILED. New properties string suspiciously short.&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Hope it helps.  Let me know if there are questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2011/03/30/bulk-updating-image-sizes-in-shopplugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Shopp&#039;s Image Storage From Database to File System</title>
		<link>http://clifgriffin.com/2011/03/21/converting-shopps-image-storage-from-database-to-file-system/</link>
		<comments>http://clifgriffin.com/2011/03/21/converting-shopps-image-storage-from-database-to-file-system/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 18:34:43 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=1283</guid>
		<description><![CDATA[I have been searching for a little while for an easy way to convert a Shopp install from using the database for image storage to using the file system. The advantages for this are obvious, especially when you have 3000 images and your database has bloomed to several hundred MB. Failing to find one, I [...]]]></description>
				<content:encoded><![CDATA[<p>I have been searching for a little while for an easy way to convert a Shopp install from using the database for image storage to using the file system.</p>
<p>The advantages for this are obvious, especially when you have 3000 images and your database has bloomed to several hundred MB.</p>
<p>Failing to find one, I decided to write my own.  Shopp&#8217;s image store rules (at least in 1.0.14) seem to follow this model:</p>
<ul>
<li>Check wp_shopp_asset table to see if an image has been stored in the data column.</li>
<li>If it isn&#8217;t there, assume it&#8217;s in the filesystem path.</li>
</ul>
<p>After about an hour, I came up with this solution (<strong><span style="color: #ff0000;">WARNING: This script is DESTRUCTIVE.  It will delete all of your images from the database so PLEASE make sure you have a full backup.  This is provided without any warranty whatsoever. I have only tested this on Shopp 1.0.14 and have no idea how it will work/not work on other versions.</span></strong>):</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Copyright 2011, Clifton H. Griffin II</span>
<span style="color: #666666; font-style: italic;">// This script is DESTRUCTIVE.  It will delete all images in your database!</span>
<span style="color: #666666; font-style: italic;">// Run at your own risk. It is provided with NO WARRANTY WHATSOEVER.</span>
<span style="color: #666666; font-style: italic;">// Please read carefully and do a full backup before using!</span>
<span style="color: #666666; font-style: italic;">// Test with Shopp 1.0.14</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//EDIT THIS LINE (this directory must be writeable)</span>
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/var/www/vhosts/domain.com/httpdocs/wp-content/uploads/shopp&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Load WP data objects</span>
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">'wp-load.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Get list of rows from shopp</span>
<span style="color: #000088;">$sql</span>    <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT id FROM wp_shopp_asset&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ARRAY_A&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Loop through them, grabbing images</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$therow</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_row</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT name, data FROM wp_shopp_asset WHERE id = <span style="color: #006699; font-weight: bold;">$id</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ARRAY_A&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$therow</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;data&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$therow</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;File name: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$path</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$name</span> &lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$name</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Clear image from DB</span>
	<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UPDATE wp_shopp_asset SET data = null WHERE id = <span style="color: #006699; font-weight: bold;">$id</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//Optimize the table to clear unused space</span>
<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;OPTIMIZE TABLE wp_shopp_asset&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>It should be fairly self-explanatory.   Use at your own risk.  I create a public github repository to host the file, on the off chance others want to add to it: <a href="https://github.com/clifgriffin/Shopp-Image-Export">https://github.com/clifgriffin/Shopp-Image-Export</a></p>
<p>Let me know if it helps you out. </p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2011/03/21/converting-shopps-image-storage-from-database-to-file-system/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Simple LDAP Login 1.4.0.1 for WordPress</title>
		<link>http://clifgriffin.com/2009/05/13/simple-ldap-login-13-for-wordpress/</link>
		<comments>http://clifgriffin.com/2009/05/13/simple-ldap-login-13-for-wordpress/#comments</comments>
		<pubDate>Wed, 13 May 2009 19:05:40 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[adLDAP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Simple LDAP Login]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=921</guid>
		<description><![CDATA[This article only deals with version 1.3 and later. To view and discuss issues pertaining to version 1.2 and prior, click here. Integrating WordPress with LDAP shouldn&#8217;t be difficult. Now it isn&#8217;t. Simple LDAP Login provides the features you need with the simple configuration you want. It has everything you need to get started today. [...]]]></description>
				<content:encoded><![CDATA[<p><em>This article only deals with version 1.3 and later. To view and discuss issues pertaining to version 1.2 and prior, <a href="http://clifgriffin.com/2008/10/28/simple-ldap-login-wordpress-plugin/">click here</a>.</em></p>
<h4>Integrating WordPress with LDAP shouldn&#8217;t be difficult. Now it isn&#8217;t.</h4>
<h5>Simple LDAP Login provides the features you need with the simple configuration you want. It has everything you need to get started today.</h5>
<hr />
<h5><strong>Features</strong></h5>
<ul>
<li>Supports Active Directory and OpenLDAP (and other directory systems which comply to the LDAP standard, such as OpenDS)</li>
<li>Supports TLS</li>
<li>Uses up-to-date methods for WordPress 3+ authentication routines.</li>
<li>Includes three login modes:
<ul>
<li><strong>Normal Mode:</strong> Authenticates existing wordpress usernames against LDAP. This requires you to create all WordPress accounts manually using the same usersnames as those in your LDAP directory.</li>
<li><strong>Account Creation Mode 1:</strong> Creates WordPress accounts automatically for any LDAP user.</li>
<li><strong>Account Creation Mode 2: </strong>Creates WordPress accounts automatically for LDAP users in a specific Group you specify.</li>
</ul>
</li>
<li>Intuitive control panel.</li>
</ul>
<h5>Architecture</h5>
<p>Simple LDAP Login adds an authentication filter to WordPress that authentication requests must pass. In doing so, it makes several decisions.</p>
<ul>
<li>Can the provided credentials be authenticated against LDAP?
<ul>
<li>If so, is the username a valid WP username?
<ul>
<li>If not, can we create a WP user?
<ul>
<li>If we can, does the user belong to the right (if any) group?
<ul>
<li>If the user does, create the WordPress user and log the user in.</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>If the username is already valid wordpress user, are they in the right group?
<ul>
<li>Is so, log the user in.</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>This is simply a high level overview. The actual logic the plugin employs is more complex, but hopefully this gives you an idea, philosophically, about how the plugin accomplishes what it does.</p>
<h5>Installation</h5>
<ol>
<li>Use the WordPress plugin directory to install the plugin or upload the directory “simple-ldap-login” to the `/wp-content/plugins/` directory</li>
<li> Activate the plugin through the ‘Plugins’ menu in WordPress</li>
<li>Immediately update the settings to those that best match your environment by going to <strong>Settings -&gt; Simple LDAP Login</strong></li>
<li>If you don’t get the settings right the first time…don’t fret! Just use your wordpress credentials…<em>they will always work in low security mode.</em></li>
<li>Once you have the settings correct, you can change the security mode to High Security (if you so desire).</li>
<li>To make your life easier, consider using two different browsers (e.g., IE and Firefox) to do testing.  Change settings in one. Test in the other. This will prevent any chance of being locked out.</li>
</ol>
<div id="attachment_1141" class="wp-caption aligncenter" style="width: 667px"><a href="http://clifgriffin.com/wp-content/uploads/2009/05/sll14.png"><img class="size-full wp-image-1141 " title="Control panel." src="http://clifgriffin.com/wp-content/uploads/2009/05/sll14.png" alt="" width="657" height="505" /></a><p class="wp-caption-text">Control panel.</p></div>
<h5>Frequently Asked Questions</h5>
<h6>Other than WordPress, what does my system require?</h6>
<p>If you are using Active Directory, you will probably need PHP 5. This is because I&#8217;m using <a href="http://adldap.sourceforge.net/" target="_blank">adLDAP</a> 3.0 to do my Active Directory integration.  As far as I know, the rest of the code should work with PHP 4. It is also possible that the functionality I&#8217;m using with adLDAP 3.0 does not depend directly on PHP 5.  Your mileage may vary.</p>
<p><em>Other than that, it is imperative that your installation of PHP be compiled with LDAP. </em>Without it you may see errors referencing undefined functions like &#8220;ldap_connect&#8221;.  You can view <a href="http://us.php.net/manual/en/ldap.installation.php">more information about PHP and LDAP here</a>.</p>
<h6>How do I know what the correct settings are?</h6>
<p>I have tried to make the settings as self-explanatory as possible.  If you are struggling figuring them out, you may need to speak with your LDAP administrator.  I realize this is an obnoxious response, but there is no good, fail proof way to help you discover these settings.  A good place to start, if you&#8217;re feeling daring, might be to use <a href="http://technet.microsoft.com/en-us/library/cc773354.aspx" target="_blank">ADSIEdit</a> for Windows and Active Directory, or <a href="http://freshmeat.net/projects/gq/" target="_blank">GQ</a> for Linux and OpenLDAP.</p>
<h6>It&#8217;s still not working, what other things can I try?</h6>
<p>If you are confident your settings are correct and it still does not work, it may be time to check for port or firewall issues. If your LDAP server is running on a non-standard port or an obsolete version of the LDAP protocol you are going to have issues.  Port 389 is the port this plugin, and nearly every other LDAP enabled software expects. They are also expecting protocol version 3.  If you are using an old version of LDAP or running a non-standard port you may need to modify the code that the plugin runs or update your LDAP installation.</p>
<p>Unfortunately I can&#8217;t be relied upon to assist with these types of requests. I chose not to support these scenarios because they are infrequent and because they confuse everyone else.</p>
<h6>I took all of your advice, it&#8217;s still not working!</h6>
<p>Post your question in the comments below, or e-mail me: <strong>me[at]clifgriffin.com</strong></p>
<p>I&#8217;ll do my best to get you up and running!</p>
<h6>How can I donate?</h6>
<p>If you would like to donate to this project, please visit the <a href="http://clifgriffin.com/code/donate" target="_blank">donations page</a>.</p>
<h5>Download Now &#8211; Updated 9/09/2010</h5>
<p><a href="http://downloads.wordpress.org/plugin/simple-ldap-login.1.4.0.1.zip" target="_blank">Click here to download Simple LDAP Login 1.4.0.1 from the WordPress plugin directory.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2009/05/13/simple-ldap-login-13-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>310</slash:comments>
		</item>
		<item>
		<title>Disable RSS Plugin for WordPress</title>
		<link>http://clifgriffin.com/2008/12/02/disable-rss-plugin-for-wordpress/</link>
		<comments>http://clifgriffin.com/2008/12/02/disable-rss-plugin-for-wordpress/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 19:32:00 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Disable RSS]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=600</guid>
		<description><![CDATA[Smashing Magazing did a post today including several RSS related WordPress hacks.   One of them featured a method to disable all RSS feeds. As they say: &#8220;Let’s say you’re using WordPress as a CMS to manage your online portfolio or your company’s website. In such cases, the RSS feed isn’t that useful, and some [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.smashingmagazine.com/2008/12/02/10-useful-rss-hacks-for-wordpress/" target="_blank">Smashing Magazing did a post today</a> including several RSS related WordPress hacks.   One of them featured a method to disable all RSS feeds. As they say:</p>
<blockquote><p>&#8220;Let’s say you’re using WordPress as a CMS to manage your online portfolio or your company’s website. In such cases, the RSS feed isn’t that useful, and some people would probably want to remove it.&#8221;</p></blockquote>
<p>Notably, they did not encapsulate the functionality in a plugin. So I will be converting the ones without a associated plugin into plugins over the coming days. This is the first one.</p>
<p>Simply put, all you have to do is upload the plugin, activate it, and viola! No more RSS feeds. You can edit the error message users receive by editing the actual plugin file. (disable-rss.php)</p>
<p>The code:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'do_feed'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_disable_feed'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'do_feed_rdf'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_disable_feed'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'do_feed_rss'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_disable_feed'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'do_feed_rss2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_disable_feed'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'do_feed_atom'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_disable_feed'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> fb_disable_feed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_die<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No feed available,please visit our &lt;a href=&quot;'</span><span style="color: #339933;">.</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;homepage&lt;/a&gt;!'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Download Disable RSS 1.0 for WordPress 2.7-RC1 Now&#8230;</strong><br />
<a href="http://downloads.wordpress.org/plugin/disable-rss.1.0.zip">Disable RSS 1.0 for WordPress 2.7-RC1</a></p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2008/12/02/disable-rss-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>Converting HTML to a C# String</title>
		<link>http://clifgriffin.com/2008/11/24/converting-html-to-a-c-string/</link>
		<comments>http://clifgriffin.com/2008/11/24/converting-html-to-a-c-string/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 23:16:33 +0000</pubDate>
		<dc:creator>clifgriffin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://clifgriffin.com/?p=577</guid>
		<description><![CDATA[Today I was working on a project where it became useful to convert an HTML file into two C# strings.  As I only intended to do this one time, I opted to not do all of the string replacements necessary and decided to look for someone else who had already done the heavy lifting.  In [...]]]></description>
				<content:encoded><![CDATA[<p>Today I was working on a project where it became useful to convert an HTML file into two C# strings.  As I only intended to do this one time, I opted to not do all of the string replacements necessary and decided to look for someone else who had already done the heavy lifting. </p>
<p>In short time I found a singularly useful tool to do exactly what I needed.   The tool is named <a href="http://www.comonto.dk/sider/html-to-c-sharp-string_150.aspx" target="_blank">HTML To C# String</a> and is published as an open source project under the GPL (or MIT) license. (<a href="http://www.comonto.dk/sider/comonto-open-source-site_138.aspx" target="_blank">it isn&#8217;t extremely clear which</a>)</p>
<div id="attachment_579" class="wp-caption aligncenter" style="width: 279px"><img src="http://clifgriffin.com/wp-content/uploads/2008/11/htmlscreen.png" alt="It&#039;s simple." title="HTML To C# String" width="269" height="131" class="size-full wp-image-579" /><p class="wp-caption-text">It's simple.</p></div>
<p>The only limitation I found was that this project does not preserve whitespace or line breaks. That&#8217;s not a problem if you&#8217;re dealing with simple html, but if you have anything fancy&#8211;like javascript, you might run into troubles. For example this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> something <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;This is such a cool var!&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//A comment about this var</span>
<span style="color: #000066; font-weight: bold;">var</span> somethingElse <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;blah&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>becomes this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> something <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;This is such a cool var!&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//A comment about this var var somethingElse = &quot;blah&quot;;</span></pre></td></tr></table></div>

<p>This will obviously not work.  I converted his project (which is only a few lines of code) into a Visual Studio 2008 project and tweaked it slightly.  You can download the result below.  I did not compile it with a setup as this utility is too simple to warrant an installation in my humble opinion.  Just run the executable in bin/Release. </p>
<p><strong>Download it now&#8230;</strong><br />
<a href="http://clifgriffin.com/downloads/HTMLtoCstring-Mod.rar">HTML To C# String-Mod</a></p>
]]></content:encoded>
			<wfw:commentRss>http://clifgriffin.com/2008/11/24/converting-html-to-a-c-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
