<?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>professional dilettante</title>
	<atom:link href="http://professionaldilettante.com/feed" rel="self" type="application/rss+xml" />
	<link>http://professionaldilettante.com</link>
	<description>just for a little while</description>
	<lastBuildDate>Sun, 01 Jul 2012 15:35:30 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>create a file from content on your clipboard</title>
		<link>http://professionaldilettante.com/create-a-file-from-content-on-your-clipboard/2012.07.01</link>
		<comments>http://professionaldilettante.com/create-a-file-from-content-on-your-clipboard/2012.07.01#comments</comments>
		<pubDate>Sun, 01 Jul 2012 15:35:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mac terminal]]></category>
		<category><![CDATA[workflow tip]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=764</guid>
		<description><![CDATA[You&#8217;re on github or something, reading code. You need to add some code to your project. You could: curl or wget the file URL clone the repo, extract single file, move it on file system create the file, open an editor, and paste in the content save as Here&#8217;s a terminal command I like. From [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re on github or something, reading code. You need to add some code to your project. You could:</p>
<ul>
<li>curl or wget the file URL</li>
<li>clone the repo, extract single file, move it on file system</li>
<li>create the file, open an editor, and paste in the content</li>
<li>save as</li>
</ul>
<p>Here&#8217;s a terminal command I like. From your project directory, run:</p>
<pre>pbpaste | cat &gt;&gt; foo.js</pre>
<p>If you&#8217;re on linux, replace pbpaste with your terminal paste utility. If you&#8217;re on windows, g-d help you and install a linux vm <img src='http://professionaldilettante.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/create-a-file-from-content-on-your-clipboard/2012.07.01/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>It&#8217;s been a long time, I shouldn&#8217;t have left you, part 1 &#8230;</title>
		<link>http://professionaldilettante.com/its-been-a-long-time-i-shouldnt-have-left-you-part-1/2012.03.17</link>
		<comments>http://professionaldilettante.com/its-been-a-long-time-i-shouldnt-have-left-you-part-1/2012.03.17#comments</comments>
		<pubDate>Sat, 17 Mar 2012 15:54:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[decisions]]></category>
		<category><![CDATA[funny]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=737</guid>
		<description><![CDATA[But now I’m back.All official like.I do social stuff again.I see my friends.I’m moving into my own place again.And all that adult shit.]]></description>
			<content:encoded><![CDATA[<p>Yay! witty-ish blog title! I wanted to make it something more like, &#8220;How I learned to stop spending my weekends coding and get social again&#8221; or &#8220;Coming back to society and reality&#8221;. But the above will have to do.</p>
<p>Been over a year since last blog post! Some updates follow.</p>
<h3><strong>Career</strong></h3>
<p>A year ago, like January 2011, I had just started working as a UI Engineer at a daily deals website called, BuyWithMe. RIP BuyWithMe! That was a great adventure and I met great people and we built awesome shiny stuff!</p>
<p>After BuyWithMe ended in October, 2011, I did some contract work. It was mostly WordPress development. In December 2011, I made the decision to take a hiatus from contract work. In February 2012, I started a new FT gig! Yes, acronyms, everyone knows they are the shit, so deal with it.</p>
<p>Over the past year I&#8217;ve done quite a bit less server-side programming and focused more on UI roles. Learned a lot about JavaScript and some about UX. It&#8217;s such an exciting time to be Front-end developer! I still sometimes write Ruby or PHP or read about Python. And now I work at a .NET shop. But for the most I&#8217;m evolving into a UI developer who has a decent knowledge of server-side programming and databases.</p>
<h3><strong>Personal</strong></h3>
<p>The past year and a half since I moved back to New Jersey has been nuts. Soooo much working. When I started at BuyWithMe as FT, I kept doing contract work on the side. So in 2011, I had my day job and a night and weekend job! Turns out that&#8217;s a bit much. I barely ever saw my friends. I was the worst person. Not worst like indecent, just like, annoyingly busy and absorbed in my own shit.</p>
<p>It got weird/I got weird &#8230; haha maybe weird-er? My friends would likely say I&#8217;ve always been weird. Now, I&#8217;ve sort of grew into like full blown nerd/geek-dom. Seriously, most of my weekends in 2011 were spent in front of a computer, working on &#8230; possibly trivial things. It was more common to find me indoors near a computer, than outside, being social, enjoying life. Sometimes I enjoyed the contracts and the learning. Other times, my heart wasn&#8217;t in it.</p>
<p>So all that, coupled with my general proclivity for not getting in line with the rest of society, I think made some people think that I was super weird haha.</p>
<p>They were like, &#8220;So, you&#8217;re not married, you spend all of your time working, you moved back in with your parents &#8230; that&#8217;s uhhhh, interesting?&#8221;.</p>
<p>And I was like, &#8220;I know right!? I&#8217;m so busy working and doing stuff that isn&#8217;t actually important to me. I don&#8217;t even have time to move out of my parents&#8217; house! No, seriously, I really have to do this work &#8230; b/c I said I would. No, I can&#8217;t hang out this weekend. So &#8230; basically see you in 2012? Siiiiiiick&#8221;.</p>
<p>But now I&#8217;m back.All official like.I do social stuff again.I see my friends.I&#8217;m moving into my own place again.And all that adult shit. Fucking innnntresting.</p>
<h3><strong>Social Media</strong></h3>
<p>That&#8217;s the update for now &#8230; hoping to blog more often. Been doing more micro blogging lately with Twitter, Tumblr and Path since that&#8217;s what all the cool kids are doing, right? Also working on updating and revamping my web Portfolio with my latest work.</p>
<p>Maybe moving this blog to a different domain and platform. You know &#8230; probably use Octopress or some other hip fancy platform, nbd. Some complex platform that is more time consuming than WordPress haha.</p>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/its-been-a-long-time-i-shouldnt-have-left-you-part-1/2012.03.17/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>posting data with curl from the command line</title>
		<link>http://professionaldilettante.com/posting-data-with-curl-from-the-command-line/2011.01.26</link>
		<comments>http://professionaldilettante.com/posting-data-with-curl-from-the-command-line/2011.01.26#comments</comments>
		<pubDate>Wed, 26 Jan 2011 17:58:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[curl]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=733</guid>
		<description><![CDATA[Before i forget, an easy way to test if you can connect to an external api is to use CURL on the command line. This nice as a sanity check/proof of concept to ensure you have the right token, proper field mappings, submitting the right data. This saves you from setting up a test form, [...]]]></description>
			<content:encoded><![CDATA[<p>Before i forget, an easy way to test if you can connect to an external api is to use CURL on the command line. This nice as a sanity check/proof of concept to ensure you have the right token, proper field mappings, submitting the right data. This saves you from setting up a test form, submitting that data, handling that data, etc. E.g.</p>
<pre>
<div id="_mcePaste">curl -d "foo=bar&amp;test=true" https://www.yourapiurl.com</div></pre>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/posting-data-with-curl-from-the-command-line/2011.01.26/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to pass parameters as a query string to your PHP functions</title>
		<link>http://professionaldilettante.com/how-to-pass-parameters-as-query-string-to-your-php-functions/2010.11.22</link>
		<comments>http://professionaldilettante.com/how-to-pass-parameters-as-query-string-to-your-php-functions/2010.11.22#comments</comments>
		<pubDate>Mon, 22 Nov 2010 19:21:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cdia]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=631</guid>
		<description><![CDATA[In PHP, arrays are often used to pass parameters to functions so we don't have to worry about the order or number of params. But there's a simpler way to pass a series of key=>value pairs without typing out the structure of an array each time: use a query string.]]></description>
			<content:encoded><![CDATA[<p>Many programming languages allow one to pass named parameters or keyword arguments to functions. Using named parameters provides the advantage of not having to worry about the order of your parameters. While I find passing an array of named parameters preferable to ordered parameters, query strings are another way to use named parameters and shorten the setup for your function calls. </p>
<p>Many WordPress functions allow you to pass parameters using query strings. What does that mean exactly? Key/pair values, just like you often see in a URL query string, e.g.</p>
<pre>page=5&#038;lang=en</pre>
<p><br/><br />
Below I will show a few examples of options for passing params to functions. Then I will provide a “parse_args()” function that lets me process the query string params in my functions.</p>
<h3 id="ordered_params">Option 1: Ordered parameters</h3>
<pre class="brush:php">
/** ordered parameters */

function get_tweets($var1,$var2,$var3){
    // validate the params and make use of them.
    // Order matters when you pass them in.
}

/** calling it */

get_tweets("arg1","arg2","arg3");

/** OR */

$arg1 = "barackobama";
$arg2 = "10";
$arg3 = "false";

get_tweets($arg1,$arg2,$arg3);

</pre>
<p>You can spice up ordered parameters a bit by using the native PHP functions:</p>
<pre>
func_get_args() // get array of all args
func_num_args() // get length of args 
func_get_arg() // get specific argument from arguments array

</pre>
<p><br/></p>
<h3 id="array_params">Option 2: Pass an array and extract from within</h3>
<p><strong>Advantages:</strong> Unlike ordered params, you don’t need to worry about the order of your arguments. You also can have a varying number of arguments.</p>
<pre class="brush:php">

/**Setup an array of parameters and extract them from inside function.*/

function get_tweets($array){
    extract($array)
    // array keys are exposed now as variables
};

/** Setup */

$array=array(
    "twitter_user" =&gt; "barackobama",
    "number_of_tweets"=&gt;"10",
    "date" =&gt; "2010-11-01"
);

/** Calling it */

get_tweets($array);

</pre>
<p><strong>Note:</strong> If one of your params is an array of data, you need to use the above approach. After passing the associative array of params to your function, you can use the php function extract() to get turn the array keys into variables. The query string params approach below will not work if you are passing an array of data. **Unless you serialize() your array before concatenating the final query string and passing the params to your function. Then inside the parse_args(), you&#8217;d need to revise it to test whether any of the params can be unserialized().</p>
<h3 id="query_string_params">Option 3: Query-string-style params</h3>
<p><strong>Advantages: Less typing and preparation before executing functions()</strong><br />
Using query string parameters gets you the advantages noted for using Arrays – variable length and order of argument list – and also allows you to shorten the preparation required to setup your function calls. </p>
<pre class="brush:php">
function get_tweets($args){

    extract( parse_args($args) );
    // array keys are exposed now as variables

};

/** Setup, store query string args in variable*/

$var = "twitter_user=barackobama&amp;number_of_tweets=3&amp;date=2010-11-01";

get_tweets($var);

/** OR pass directly */

get_tweets("user=zeldman&amp;limit=3&amp;date=2010-11-15");
</pre>
<h3 id="parse_args_function">Implementation: A parse_args() function</h3>
<pre class="brush:php">
/** 
 *
 *  parse_args($args) parses query string style params
 *  and returns array.
 *  @param String Your params as a string.
 *  E.g. 'day=10&amp;month=11'
 *  @uses explode() to separate query string into key/pair
 *  @description Call this function inside your own
 *  functions to get an array of args passed, even
 *  though you didn't pass an array or multiple params.
 *  @return Array
 *
 *
 */
function parse_args($args){

if( empty($args) ):            
    throw new Exception("\n\nfunction parse_args() expects you to pass a param\n\n");    
elseif( !is_string($args) ):
    throw new Exception("\n\nfunction parse_args() expects a string, ". gettype($args). " passed\n\n");
endif;

// array to store our parsed args
$parsed = array();

// confirm there is at least one param, in format we expect
if( !strpos($args,"=") ):
// if not, trigger exception
    $msg="\n\nfunction parse_args() expects query string params. \n\n";
    $msg.="String passed does not contain any assignments using = operator\n\n";
    throw new Exception($msg);
elseif( strpos($args,"&#038;")  ):
// if str contains &#038;, assume multiple params
    $parts = explode("&amp;",$args);
    for( $i=0, $len=count($parts); $i&lt;$len; $i++ ):
        $tmp = explode("=",$parts[$i]);
        $parsed[$tmp[0]] = $tmp[1];
    endfor;
else:
    $tmp = explode("=",$args);
    $parsed[$tmp[0]] = $tmp[1];
endif;

return $parsed;
}
</pre>
<h3 id="using_parse_args">Using parse_args($args)</h3>
<pre class="brush:php">
function get_tweets($args){

/* parse our query string-style params &#038; return 
an array to php's native extract() function */

    extract(parse_args($args) );

/** Now, after calling extract(), following items from this string -
"twitter_user=barackobama&amp;number_of_tweets=3&amp;date=2010-11-01"
- are now available to you as variables:


$user; // 'barackobama'
$number_of_tweets; // 3
$date; // 2010-11-01
*/

}
</pre>
<h3 id="parse_args_array">Modify parse_args() to return early if an array is passed</h3>
<p>The next step I think would be to build in support for arrays, so you can call parse_args() on either query string params or an array of params. This wouldn&#8217;t take much work and would provide even more flexibility and wider application. Here&#8217;s an attempt, seems to work, which tests if an array has been passed in. If an array was passed, we return right away since there is no point in evaluating any more code.</p>
<pre class="brush:php">
function parse_args($args){

if( empty($args) ):       
     
    throw new Exception("\n\nfunction parse_args() expects you to pass a param\n\n");

elseif( is_array( func_get_arg(0) )  ):                 

/* return right away if param itself is an array */

    return func_get_args();        

elseif( !is_string($args) ):

    throw new Exception("\n\nfunction parse_args() expects a string, ". gettype($args). " passed\n\n");

endif;

// array to store our parsed args
$parsed = array();

// confirm there is at least one param, in format we expect
if( !strpos($args,"=") ):

// if not, trigger exception
    $msg="\n\nfunction parse_args() expects query string params. \n\n";
    $msg.="String passed does not contain any assignments using = operator\n\n";
    throw new Exception($msg);

elseif( strpos($args,"&#038;")  ):

// if str contains &#038;, assume multiple params
    $parts = explode("&amp;",$args);

    for( $i=0, $len=count($parts); $i&lt;$len; $i++ ):
        $tmp = explode("=",$parts[$i]);
        $parsed[$tmp[0]] = $tmp[1];
    endfor;

else:

    $tmp = explode("=",$args);
    $parsed[$tmp[0]] = $tmp[1];

endif;

return $parsed;
}
</pre>
<p><cite>Thanks to Ryan Bagwell for helping me formulate this post. Find Ryan: @ryanbagwell, <a href="http://www.ryanbagwell.com/">http://www.ryanbagwell.com/</a></cite></p>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/how-to-pass-parameters-as-query-string-to-your-php-functions/2010.11.22/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rounded corners with or without images</title>
		<link>http://professionaldilettante.com/rounded-corners-with-or-without-images/2010.10.05</link>
		<comments>http://professionaldilettante.com/rounded-corners-with-or-without-images/2010.10.05#comments</comments>
		<pubDate>Tue, 05 Oct 2010 22:58:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cdia]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[xhtml]]></category>
		<category><![CDATA[background-image]]></category>
		<category><![CDATA[background-position]]></category>
		<category><![CDATA[border-radius]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=548</guid>
		<description><![CDATA[Often the websites I build for clients include rounded corners in the design. The border-radius property introduced by CSS3 and supported by most browsers except IE6-8, makes it easy to implement rounded corners.]]></description>
			<content:encoded><![CDATA[<p>For those of you who just want to see the code: <a href="http://professionaldilettante.com/rounded-corners-with-or-without-images/2010.10.05#the_code">Rounded corners with background-images</a> and <a href="http://professionaldilettante.com/rounded-corners-with-or-without-images/2010.10.05#border_radius">Rounded corners using border-radius</a>. Some parts of the code below are pseudo code. </p>
<p><a href="http://portfolio.zhannes.com/demos/php/cdia_blog/css/rounded_corners/">Working demo code is here</a>.</p>
<h3><span style="font-weight: normal;">Before CSS3</span></h3>
<p>Often the websites I build for clients include rounded corners in the design. Prior to <a title="CSS3" href="http://www.css3.info/">CSS3</a>, creating rounded corners ( without JavaScript ) in any browser required creating and slicing up images to be used with html elements and the css property, <a title="HTMLDog css property reference for &quot;background-image&quot;" href="http://htmldog.com/reference/cssproperties/background-image/">background-image</a>. How many images need to be cut? How many elements do we need in our HTML mark-up to properly display the background-image? Other than background-image, what CSS properties are required to display the background-images? Those answers depends on whether you require the content to be able to expand and contract, or whether the height and width are fixed.</p>
<p>E.g., Rounded corners for the chrome of a webpage might need three background images and three HTML divs &#8211; div#top, div#center (repeating vertically), and div#bottom. Repeating the center background image allows for content of varying length. If you have a fixed height and width then you can cut a single background-image.</p>
<p>To boot, IE6 does not include native support for PNG images. So if your rounded corners required transparency, you needed separate background images and CSS rules to specify GIFs for IE6 and PNGs for IE7+ and other browsers. In order to apply rules specifically to IE6, you need detect the browser on the server side, use <a title="Microsoft conditional comments for IE" href="http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx">Microsoft proprietary conditional comments for Internet Explorer</a>, or javascript. Alternatively, you can use the <a title="MS Filters for IE6 to support PNG transparency" href="http://support.microsoft.com/kb/294714">proprietary Microsoft filtering code to add support for transparent PNGs in IE6</a>. Either way it requires adding browser specific CSS, which is generally undesirable but sometimes unavoidable. Below is an example of adding the conditional wrapper div for IE6, which is used primarily for targeting your CSS as well as using different background images between IE6 and &gt; IE6. Also shown is the conditional div for generating the additional markup required for the background images.</p>
<h3 id="the_code">Rounded Corners with background-images</h3>
<pre class="brush:html">
<!--[if lt IE 7]>
<div class="ie6">
<![endif]--> 

<!-- ... The rest of your IE conditional wrapper divs would go here -->

<!--[if lte IE 8]>
<div id="box_bottom">
<![endif]-->


<div id="box">
<textarea></textarea>
</div>
<!--[if lte IE 8]>
</div>
<![endif]-->

<!--[if lt IE 7]>
</div>
<![endif]-->
</pre>
<p>Your CSS for IE browsers would be something like:</p>
<pre class="brush:css;wrap:false">/* IE Browsers: #box_bottom */
.ie6 #box_bottom,
.ie7 #box_bottom,
.ie8 #box_bottom {
background:url("images/bottom.gif") no-repeat bottom left;
width:420px;
height:300px;
padding-bottom:18px;
}

/* For IE7 and IE8, height:auto */
/* IE7+ Use PNG */
.ie7 #box_bottom,
.ie8 #box_bottom {
height:auto;
background:url("images/bottom.png") no-repeat bottom left;
}

/* IE Browsers, #box */
.ie6 #box,
.ie7 #box,
.ie8 #box {
background:url("images/top.gif") no-repeat top left;
width:420px;
height:300px;
padding-top:18px;
}

/* IE7+ Use PNG */
.ie7 #box,
.ie8 #box {
background:url("images/top.png") no-repeat top left;
}

/* IE Browsers, #box textarea */
.ie6 #box textarea,
.ie7 #box textarea,
.ie8 #box textarea {
width:400px;
height:300px;
padding:0px 10px;
overflow:auto;
background-color:#FFF;
background:url("images/mid.gif") repeat-y;
text-align:justified;
}

/* IE7+ Use PNG. */
.ie7 #box textarea,
.ie8 #box textarea {
background:url("images/mid.png") repeat-y center center;
}</pre>
<p>And that&#8217;s just the CSS for IE! You might need something different to get rounded corners with background-images working in Firefox, Safari, Chrome, and Opera.</p>
<h3 id="border_radius">Rounded Corners using CSS3 border-radius</h3>
<p>To the rescue came the CSS3 property, <a title="CSS3 border-radius property" href="http://www.css3.info/preview/rounded-border/">border-radius</a>. Border-radius allowed web developers and designers to easily create rounded corners simply by declaring the &#8220;border-radius:&#8221; property and specifying a value. *The property to be declared actually depends on your browser, and I will get into that later when I show you the code. Currently, the CSS3 border-radius property is supported by recent versions of major browsers such as Firefox (Gecko), Safari (Webkit), Google Chrome (Webkit), and Opera (Presto). However, Internet Explorer versions 6-8 do not support border-radius. For me, the decision on whether to support IE at all, and if so which versions, depends on the project.</p>
<pre class="brush:html">
<div id="box">
<textarea></textarea>
</div>
</pre>
<pre class="brush:css">/* styles for all browsers except the IEs, which won't support border radius until IE9 */
#box textarea {
padding:5px;
border:none;
color:#FFF;
width:420px;
min-height:300px;
background-color:#00bfff;
-moz-border-radius:5px 5px 5px 5px;
-webkit-border-radius:5px 5px 5px 5px;
/* For opera and hopefully other browsers in the future */
border-radius:5px 5px 5px 5px;
}</pre>
<p>Using the border-radius property gives us rounded corners in almost all the popular browsers, while requiring less html mark-up and fewer CSS rules. If you need to support Internet Explorer, you can use the border-radius approach in combination with background-images. <a href="http://portfolio.zhannes.com/demos/php/cdia_blog/css/rounded_corners/">Working demo here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/rounded-corners-with-or-without-images/2010.10.05/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Shortcodes, Actions, Events Manager, TweetBlender</title>
		<link>http://professionaldilettante.com/capturing-wordpress-shortcode-output-for-use-elsewhere/2010.09.15</link>
		<comments>http://professionaldilettante.com/capturing-wordpress-shortcode-output-for-use-elsewhere/2010.09.15#comments</comments>
		<pubDate>Wed, 15 Sep 2010 22:19:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress plugins]]></category>
		<category><![CDATA[wordpress themes]]></category>
		<category><![CDATA[actions api]]></category>
		<category><![CDATA[events manager]]></category>
		<category><![CDATA[global variables]]></category>
		<category><![CDATA[loop_end]]></category>
		<category><![CDATA[shortcodes API]]></category>
		<category><![CDATA[the loop]]></category>
		<category><![CDATA[the_content()]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=533</guid>
		<description><![CDATA[I&#8217;m working on a WordPress project which uses David Benini&#8217;s &#8220;Events Manager&#8221; plugin. The events manager plugin does not use WordPress&#8217; posts for Events. Instead it creates an page with the title &#8220;Events&#8221;, whose URL would be http://yourdomain.com/events. The content rendered on this page varies. The plugin uses the query string to fetch a single event [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a WordPress project which uses <a title="David Benini's Events Manager Plugin" href="http://davidebenini.it/wordpress-plugins/events-manager/">David Benini&#8217;s &#8220;Events Manager&#8221;</a> plugin. The events manager plugin does not use WordPress&#8217; posts for Events. Instead it creates an page with the title &#8220;Events&#8221;, whose URL would be http://yourdomain.com/events. The content rendered on this page varies. The plugin uses the query string to fetch a single event or all the events for a day, etc. The results from it&#8217;s query for events are added as filter to the WordPress function <a title="Wordpress function the_content()" href="http://codex.wordpress.org/Function_Reference/the_content">the_content()</a>.</p>
<h3><span style="font-weight: normal;">Goal</span></h3>
<p>Allow the client to easily specify a Twitter #hash tag when creating a new event. Get those tweets and render them on the events page, beneath the main event details and rsvp form. I found the <a title="TweetBlender WordPress Plugin" href="http://wordpress.org/extend/plugins/tweet-blender/">WordPress TweetBlender plugin</a> to fetch tweets by #hashtag. TweetBlender has a widget function that lets you pass params for the tweets in your WordPress theme code.</p>
<h3><span style="font-weight: normal;">Problem 1 &#8211; How to store and pass the twitter topic</span></h3>
<p><strong> </strong>Typically if I wanted to pass along info such as a twitter hash tag, I would do so using the <a title="Wordpress Custom Fields" href="http://codex.wordpress.org/Custom_Fields">WP Custom Fields</a>. But &#8220;Events Manager&#8221; does not use posts as events so this was not an option. I could have hacked the Events Manager plugin and added another field in the database tables, e.g., event_meta_values. But I always try to find a solution other than hacking plugins. I realized I could use the <a title="Wordpress Shortcode API" href="http://codex.wordpress.org/Shortcode_API">WP Shortcodes API</a> to pass along the info about the twitter hash for each event. E.g.,</p>
<pre> [twitter_hash topic=primary_elections]</pre>
<p>I was easily able to extract the info from the shortcode using WordPress&#8217; shortcode API. Next, I wanted to feed this topic into the tweet blender widget function, which outputs a list of tweets based on the twitter hashtag or username you pass it.</p>
<h3><span style="font-weight: normal;">Problem 2 &#8211; When to output the TweetBlender data</span></h3>
<p>Normally, the value returned by a shortcode handler function is added as a filter to the WordPress function <a title="Wordpress function the_content()" href="http://codex.wordpress.org/Function_Reference/the_content">the_content()</a>. But for my purposes, I wanted the tweets to be at the bottom of the page beneath the main event details and rsvp form. So the question was how to hook into the wordpress <a title="Wordpress' Actions API" href="http://codex.wordpress.org/Plugin_API/Action_Reference">Actions API</a> in order to render the tweet blender output in an appropriate place on the page. Reading the WP Actions API docs, I found an action called &#8220;<a title="Wordpress' Actions loop_end" href="http://codex.wordpress.org/Plugin_API/Action_Reference#Advanced_Actions">loop_end</a>&#8220;. As the name suggests, the docs stated that any function called at that time would run immediately after <a title="Wordpress' the_loop" href="http://codex.wordpress.org/The_Loop">the_loop</a> has ended.</p>
<h3>Implementation</h3>
<p>As is often the case when I code without planning, I went about coding this all the wrong way. Initially I was catching the twitter topic in the shortcode handler function. Then I passed the twitter topic to the TweetBlender Widget function. That function echoes the tweets immediately. And the return value from a shortcode handler function is added to the_content(). So the tweets were showing up in the center of the Events page.</p>
<p>My elaborate attempt to fix this was having the shortcode handler function return FALSE. Then I was capturing the output of TweetBlender using php functions like ob_start(), get_buffer_contents(), and ob_end_clean(). Here is what I ultimately ended up with. Would love some input on if there is an easier way.</p>
<pre class="brush:php">function twitter_hash($atts, $content = null){
    global $topic;

    extract(shortcode_atts(array('topic' =&gt; '#voting',), $atts));

    return FALSE;
}

if (function_exists('twitter_hash')):

    add_shortcode('twitter_hash', 'twitter_hash');

endif;</pre>
<pre class="brush:php">function get_tw_data(){

    global $topic;

    if ( !empty($topic) || !empty($GLOBALS['topic']) ):

        if ( function_exists('tweet_blender_widget') ):

            $args = array(
                'unique_div_id' =&gt; 'tweetblender-t1',
                'sources' =&gt; $topic,
                'refresh_rate' =&gt; 60,
                'tweets_num' =&gt; 5,
                'view_more_url' =&gt; 'http://twitter.com/tweetblender'
                      );
            tweet_blender_widget($args);
            unset($GLOBALS['topic']);
            unset($topic);

        endif;
    else:
        return FALSE;
    endif;

}

if (function_exists('get_tw_data')):

    add_action('loop_end','get_tw_data');

endif;</pre>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/capturing-wordpress-shortcode-output-for-use-elsewhere/2010.09.15/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress&#8217; Built-in Category and Single post Navigation</title>
		<link>http://professionaldilettante.com/wordpress-built-in-category-and-single-post-navigation/2010.09.15</link>
		<comments>http://professionaldilettante.com/wordpress-built-in-category-and-single-post-navigation/2010.09.15#comments</comments>
		<pubDate>Wed, 15 Sep 2010 16:14:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[next_posts_link()]]></category>
		<category><![CDATA[next_post_link()]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[posts_nav_link()]]></category>
		<category><![CDATA[previous_posts_link()]]></category>
		<category><![CDATA[previous_post_link()]]></category>
		<category><![CDATA[wordpress categories]]></category>
		<category><![CDATA[wordpress navigation]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=522</guid>
		<description><![CDATA[For navigating to older and newer posts from a single post page, WordPress gives us some useful functions like previous_post_link() and next_post_link(). Those are easily confused with the similar looking functions, previous_posts_link() and next_posts_link(), used for navigating between pages listing multiple posts, in a category for example. WordPress gives us the category structure. We can use categories and permalinks [...]]]></description>
			<content:encoded><![CDATA[<p>For navigating to older and newer posts from a single post page, WordPress gives us some useful functions like <a title="Wordpress previous_post_link function" href="http://codex.wordpress.org/Template_Tags/previous_post_link">previous_post_link()</a> and <a title="Wordpress' next_post_link()" href="http://codex.wordpress.org/Template_Tags/next_post_link">next_post_link()</a>. Those are easily confused with the similar looking functions, <a title="Wordpress' previous_post_link" href="http://codex.wordpress.org/Template_Tags/previous_posts_link">previous_posts_link()</a> and <a title="Wordpress' next_posts_link function" href="http://codex.wordpress.org/Template_Tags/previous_posts_link">next_posts_link()</a>, used for navigating between pages listing multiple posts, in a category for example.</p>
<p>WordPress gives us the category structure. We can use categories and <a title="Wordpress permalinks " href="http://codex.wordpress.org/Using_Permalinks#mod_rewrite:_.22Pretty_Permalinks.22">permalinks</a> to easily organize our posts. This means we can access our posts in the fictional category named &#8220;foo&#8221; by visiting the following URL:</p>
<pre>http://yourdomain.com/category/foo</pre>
<p>And if the number of posts in your category exceeds the number of posts allowed per page ( specified in Settings -&gt; Reading ), the URL becomes</p>
<pre>
<pre>http://yourdomain.com/category/foo/page/2</pre>
<h3>Navigating multiple pages, each with multiple posts</h3>
<p>Not all of your posts will fit on a single page if you have many posts in a category and your WordPress settings limit the number of posts per page. If you have ten posts in the <strong>press</strong> category, and you&#8217;re settings are two posts per page, the posts in the press category will be spread over 5 pages. To create the navigation links between pages of posts in a category, we can use <a title="Navigating multiple=">posts_nav_link()</a>,  or for more control you can use the individual <a title="Wordpress' previous_post_link" href="http://codex.wordpress.org/Template_Tags/previous_posts_link">previous_posts_link()</a> and <a title="Wordpress' next_posts_link function" href="http://codex.wordpress.org/Template_Tags/previous_posts_link">next_posts_link()</a>. Each of these functions takes options to customize the text of the previous and next buttons, or you can call it with no arguments. e.g.,</p>
<pre class="brush:php">&lt;?php
/* File: archive.php */
posts_nav_link();
?&gt;</pre>
<p>The default function with no args will produce something like:</p>
<p><em><span style="color: #888888;">« Previous Page        Next Page »</span></em></p>
<h3>Navigating between single posts</h3>
<p>On a page that shows a single post, we can create previous and next buttons to get to the next single post. The previous and next buttons in this case will lead to the user to a full post, not a page with multiple posts. We can create these buttons using <a title="Wordpress previous_post_link function" href="http://codex.wordpress.org/Template_Tags/previous_post_link">previous_post_link()</a> and <a title="Wordpress' next_post_link()" href="http://codex.wordpress.org/Template_Tags/next_post_link">next_post_link()</a>. e.g.,</p>
<pre class="brush:php">&lt;?php
/* Files: single.php, page.php */
previous_post_link('&lt;span class="prev_post_link"&gt;%link&lt;/span&gt;','Previous: %title',TRUE);
next_post_link('&lt;span class="next_post_link"&gt;%link&lt;/span&gt;','Next: %title',TRUE);
?&gt;</pre>
<p>Would produce:</p>
<p><em><span style="color: #888888;">Next: Post Title of your Post</span></em></p>
<h3>Paginating a Single Post or Page</h3>
<p>Have a really long page or blog post? WordPress also lets you spread a single page or blog post over several pages. The built in function called <em>nextpage</em> will automatically separate your content into pages where ever you place the tag. <em>Nextpage</em> is a <a title="Wordpress Quicktags" href="http://codex.wordpress.org/Write_Post_SubPanel#Quicktags">WordPress Quicktag</a>, similar to <em>more.</em> Unlike the more quicktag, nextpage is not available by default in WordPress version of TinyMCE. We can easily add a button for &#8220;next page&#8221; to the WordPress editor by using a plugin. I used <a href="http://wordpress.org/extend/plugins/nextpage-buttons/">NextPage Buttons</a>. To get wordpress to properly display the pages and page numbers on single blog posts or pages, you need to use the <a href="http://codex.wordpress.org/Function_Reference/wp_link_pages">wp_link_pages()</a> function inside <a title="The WordPress Loop" href="http://codex.wordpress.org/The_Loop">the loop</a> on <a title="Wordpress Default Page Template" href="http://codex.wordpress.org/Pages#Default_Theme_Page_Templates">page.php</a> or <a title="Wordpress single.php template, the default template for blog posts" href="http://codex.wordpress.org/Theme_Development#Single_Post_.28single.php.29">single.php</a>, e.g.,</p>
<pre class="brush:php">&lt;?php
/* Files: single.php, page.php */
wp_link_pages(array('before' =&gt; '&lt;p&gt;&lt;strong&gt;Pages:&lt;/strong&gt; ', 'after' =&gt; '&lt;/p&gt;', 'next_or_number' =&gt; 'number'));
?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/wordpress-built-in-category-and-single-post-navigation/2010.09.15/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapstraction</title>
		<link>http://professionaldilettante.com/mapstraction/2010.09.05</link>
		<comments>http://professionaldilettante.com/mapstraction/2010.09.05#comments</comments>
		<pubDate>Sun, 05 Sep 2010 14:46:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[map scripting]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=518</guid>
		<description><![CDATA[Reading about Mapstraction, a wrapper for the mapping APIs of Google, Yahoo and ten other JavaScript mapping APIs. Looking forward to diving into some example code and posting more soon.]]></description>
			<content:encoded><![CDATA[<p>Reading about <a title="Mapstraction" href="http://www.mapstraction.com/">Mapstraction</a>, a wrapper for the mapping APIs of Google, Yahoo and ten other JavaScript mapping APIs. Looking forward to diving into some example code and posting more soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/mapstraction/2010.09.05/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gravity Forms</title>
		<link>http://professionaldilettante.com/gravity-forms-wordpress-plugin/2010.09.05</link>
		<comments>http://professionaldilettante.com/gravity-forms-wordpress-plugin/2010.09.05#comments</comments>
		<pubDate>Sun, 05 Sep 2010 14:43:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress plugins]]></category>
		<category><![CDATA[cforms]]></category>
		<category><![CDATA[gravity forms]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=516</guid>
		<description><![CDATA[For a WordPress project I&#8217;ve been getting my time sucked up by messing with the CForms plugin. Being one of several people who have worked on the project, I did not set up CForms. The Admin UI for CForms on this particular WordPress project is pretty messy. I&#8217;ve heard great things about the Gravity Forms [...]]]></description>
			<content:encoded><![CDATA[<p>For a WordPress project I&#8217;ve been getting my time sucked up by messing with the <a title="CForms plugin for WordPress" href="http://www.deliciousdays.com/cforms-plugin/">CForms</a> plugin. Being one of several people who have worked on the project, I did not set up CForms. The Admin UI for CForms on this particular WordPress project is pretty messy. I&#8217;ve heard great things about the <a title="Gravity Forms plugins for WordPress" href="http://www.gravityforms.com/">Gravity Forms</a> plugin for WordPress, so I am giving it a shot.</p>
<p>So far I&#8217;m impressed by the ease with which Gravity Forms &#8220;just works&#8221;. For example, thus far, building a form with a drop down (&lt;select&gt; ) list and associating the &lt;option&gt; tag values with different e-mails has been fairly straightforward. Hopefully I&#8217;ll have a few more posts with updates on <a title="Gravity Forms' features" href="http://www.gravityforms.com/category/features/">Gravity Forms&#8217; features</a> soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/gravity-forms-wordpress-plugin/2010.09.05/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adam DuVander&#8217;s &#8220;Map Scripting 101&#8243; from No Starch Press</title>
		<link>http://professionaldilettante.com/adam-duvander-map-scripting-101-no-starch-press/2010.08.30</link>
		<comments>http://professionaldilettante.com/adam-duvander-map-scripting-101-no-starch-press/2010.08.30#comments</comments>
		<pubDate>Mon, 30 Aug 2010 21:29:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[geolocation]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[map scripting]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[no starch press]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[geoblog]]></category>
		<category><![CDATA[mapscripting]]></category>
		<category><![CDATA[mobile safari]]></category>

		<guid isPermaLink="false">http://professionaldilettante.com/?p=511</guid>
		<description><![CDATA[Very excited to have a copy of Adam DuVander&#8217;s new book on mapscripting: Map Scripting 101. The book was published by No Starch Press, which has also published some of my favorite hands-on programming books, Wicked Cool Ruby Scripts, Wicked Cool PHP, and Ruby By Example. I stumbled across Adam&#8217;s awesome post on geolocation for [...]]]></description>
			<content:encoded><![CDATA[<p>Very excited to have a copy of Adam DuVander&#8217;s new book on mapscripting: <a href="http://mapscripting.com/book">Map Scripting 101</a>. The book was published by No Starch Press, which has also published some of my favorite hands-on programming books, <a title="Wicked Cool Ruby Scripts" href="http://nostarch.com/wcruby.htm">Wicked Cool Ruby Scripts</a>, <a title="Wicked Cool PHP" href="http://nostarch.com/wcphp.htm">Wicked Cool PHP</a>, and <a title="Ruby By Example" href="http://nostarch.com/ruby.htm">Ruby By Example</a>.</p>
<p>I stumbled across Adam&#8217;s awesome post on <a title="Geolocating with mobile safari" href="http://mapscripting.com/how-to-use-geolocation-in-mobile-safari">geolocation for mobile safari</a> while I was working on <a title="GeoBlog by Zach Hannes" href="http://dev.zhannes.com/">my geo blog project</a>, located here: <a title="GeoBlog running on Sinatra" href="http://dev.zhannes.com/">http://dev.zhannes.com/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://professionaldilettante.com/adam-duvander-map-scripting-101-no-starch-press/2010.08.30/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
