<?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>Chris Carvache</title>
	<atom:link href="http://chriscarvache.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://chriscarvache.com</link>
	<description>Home of Computer Nerd Chris Carvache</description>
	<lastBuildDate>Mon, 30 Apr 2012 08:47:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Apply WooCommerce Product Add-on to all Products</title>
		<link>http://chriscarvache.com/2012-04/woocommerce-tricks/apply-woocommerce-product-add-on-to-all-products/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apply-woocommerce-product-add-on-to-all-products</link>
		<comments>http://chriscarvache.com/2012-04/woocommerce-tricks/apply-woocommerce-product-add-on-to-all-products/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 08:47:33 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[WooCommerce Tricks]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[products]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[woocommerce]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://chriscarvache.com/?p=1030</guid>
		<description><![CDATA[<p>I just recently started using the WooCommerce shopping cart.  Its incredibly simple to use and extremely powerful.  One of the best plugins for it in my opinion is called Product Add-ons.  Basically it allows you to add different fields to products.  This gives me the flexibility to create options like an additional charge for gift [...]]]></description>
			<content:encoded><![CDATA[<p>I just recently started using the <a title="WooCommerce" href="http://www.woothemes.com/woocommerce/" target="_blank">WooCommerce shopping cart</a>.  Its incredibly simple to use and extremely powerful.  One of the best plugins for it in my opinion is called <a title="WooCommerce Product Add-ons" href="http://www.woothemes.com/extension/product-addons/" target="_blank">Product Add-ons</a>.  Basically it allows you to add different fields to products.  This gives me the flexibility to create options like an additional charge for gift wrapping.  The one downside of the plugin is that it doesn&#8217;t let you apply the addons to ALL products.  However, all I needed to do is write a script to take care of that!<span id="more-1030"></span></p>
<h3>How we Do this!</h3>
<div id="attachment_1035" class="wp-caption alignright" style="width: 290px"><a href="http://chriscarvache.com/wp-content/uploads/2012/04/addons.jpg"><img class="size-full wp-image-1035" title="Product Add-ons" src="http://chriscarvache.com/wp-content/uploads/2012/04/addons.jpg" alt="Product Add-ons" width="280" height="401" /></a><p class="wp-caption-text">Product Add-ons</p></div>
<p>After downloading and installing the plugin, all your products will now have an additional meta-box in the sidebar.  Take a look to the right to see what it will look like.  In our example I&#8217;m adding a Gift Wrap option to ALL of our products.</p>
<p>It only took a few lines of code to do this.  And best of all, the plugin gives you the non-serialized array you need to use for the script.  Seems like they thought ahead a bit.  Notice the highlighted array.  To see this information, simply click on the left bolded arrow that is directly to the right of the &#8220;+ Add New Product Add-on&#8221; link.</p>
<h3>The Code</h3>
<p>At first I wasn&#8217;t sure if I could easily do this but, after spending a few minutes trolling the database, I found all the necessary information to cook something up.  Check it out&#8230;</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
 * Template Name: Update Product Addons
 */

global $wpdb;
$wpdb-&gt;show_errors();
$wpdb-&gt;print_error();

$productAddonArray = 'a:1:{i:0;a:6:{s:4:&quot;name&quot;;s:9:&quot;Gift Wrap&quot;;s:11:&quot;description&quot;;s:0:&quot;&quot;;s:4:&quot;type&quot;;s:8:&quot;checkbox&quot;;s:8:&quot;position&quot;;s:1:&quot;0&quot;;s:7:&quot;options&quot;;a:1:{i:0;a:2:{s:5:&quot;label&quot;;s:14:&quot;Add Gift Wrap?&quot;;s:5:&quot;price&quot;;s:4:&quot;8.00&quot;;}}s:8:&quot;required&quot;;s:1:&quot;0&quot;;}}';

// Get all the posts that have a product post type
$SQL = &quot;SELECT ID FROM `$wpdb-&gt;posts` WHERE `post_type` = 'product'&quot;;
$rs = $wpdb-&gt;get_results($SQL);

// Output all of our data
foreach ($rs as $r) {
	echo 'Product #' . $r-&gt;ID . ' is a WooCommerce Product and its addon data has been updated.' . '&lt;br /&gt;' . &quot;\n&quot;;
	update_post_meta( $r-&gt;ID, '_product_addons', unserialize($productAddonArray));
}
</pre>
<p>A few things to notice here.  The first is that this is actually a page template.  I created a page template so I could easily write this and not have to worry about bootstrapping WordPress&#8217;s loader.  One this template was created, I created a blank page in the admin section, applied the template to the page and then viewed the newly created page.</p>
<p>Another thing to notice is that we are unserializing our data before inserting it into our database.  Since WordPress automagically serializes post meta data during insertion or updating, we need to make sure that we&#8217;re handing off WordPress unserialized data.  Being that the string in $productAddonArray is already serialized,  we need to make sure that it isn&#8217;t serialized again.  If we didn&#8217;t, we&#8217;d have to use another function ( <a title="maybe_unserialize Function Reference" href="http://codex.wordpress.org/Function_Reference/maybe_unserialize" target="_blank">maybe_unserialize()</a> ) to retrieve the data every time.</p>
<p>Aside from all that, the code is pretty basic.  Find the IDs of all the products based on their meta type and then update all the _product_addons post meta with gift wrap options.</p>
<p>Best thing is that now if we want to globally apply product add-ons, all we have to do is change the value in $productAddonArray and run the script again!</p>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2012-04/woocommerce-tricks/apply-woocommerce-product-add-on-to-all-products/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using PHP Output Buffering</title>
		<link>http://chriscarvache.com/2012-04/php-development/using-php-output-buffering/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-php-output-buffering</link>
		<comments>http://chriscarvache.com/2012-04/php-development/using-php-output-buffering/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 08:45:16 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[output buffering]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://chriscarvache.com/?p=1025</guid>
		<description><![CDATA[<p>PHP is an easy language to learn and use.  With all the frameworks and applications available, developers are able to accomplish tons of cool things in a relatively short amount of time.  One of the coolest things I find myself using more and more is output buffering.  Whenever I start a new project, I usually [...]]]></description>
			<content:encoded><![CDATA[<p>PHP is an easy language to learn and use.  With all the frameworks and applications available, developers are able to accomplish tons of cool things in a relatively short amount of time.  One of the coolest things I find myself using more and more is output buffering.  Whenever I start a new project, I usually use WordPress.  In every circumstance the idea is to develop around the core of the software.  In lots of situations, WordPress will generate some sort of code that I want to change.  Using output buffering allows me to hijack whatever output I need to change and enables me to avoid changing the core of the software.<span id="more-1025"></span></p>
<h3>An easy code sample</h3>
<p>The simplest way to use output buffering is to take whatever output you have, put it in a variable and then manipulate it to some degree.  Before we get to the code, we&#8217;ll need to understand how to use a few functions.  While the whole output buffering concept utilizes several functions, we&#8217;re only going to talk about two.</p>
<ol>
<li><strong>ob_start() -</strong> This function will start the output buffering session.</li>
<li><strong>ob_get_clean() -</strong> This function will return (not echo) the contents from the output buffer and end the output buffering session.</li>
</ol>
<div>Let&#8217;s say we have some output and we want to add some more CSS classes to it.  This becomes easy and able to be accomplished with just a few lines of code.  <strong>PLEASE NOTE</strong> that while the example below includes HTML code, in a realistic situation, this code would be generated via some sort of function that we could only change by changing the core of the software.  Being that aim is to avoid changing the core, here&#8217;s our sample code:</div>
<pre class="brush: php; title: ; notranslate">
&lt;?php
// Let's start our output buffering session!
ob_start();
?&gt;

&lt;div class=&quot;col-300&quot;&gt;
	&lt;h3&gt;My Recent Posts Widget&lt;/h3&gt;
	&lt;ul&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Post 1&lt;/a&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Post 2&lt;/a&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Post 3&lt;/a&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
	&lt;a href=&quot;#&quot;&gt;See all posts &raquo;&lt;/a&gt;
&lt;/div&gt;&lt;!-- .col-300 --&gt;

&lt;div class=&quot;col-300&quot;&gt;
	&lt;h3&gt;My Recent Comments Widget&lt;/h3&gt;
	&lt;ul&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Comment 1&lt;/a&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Comment 2&lt;/a&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Comment 3&lt;/a&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;&lt;!-- .col-300 --&gt;

&lt;?php
// Lets get our output and add some classes to it
$output = ob_get_clean();
$output = str_replace('col-300', 'col-300 recent widget coolfresh', $output);
echo $output;
?&gt;
</pre>
<p>And we did this is just 4 lines of php.  Pretty easy right?  The new output would look like this.</p>
<pre class="brush: php; title: ; notranslate">
&lt;div class=&quot;col-300 recent widget coolfresh&quot;&gt;
	&lt;h3&gt;My Recent Posts Widget&lt;/h3&gt;
	&lt;ul&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Post 1&lt;/a&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Post 2&lt;/a&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Post 3&lt;/a&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
	&lt;a href=&quot;#&quot;&gt;See all posts &raquo;&lt;/a&gt;
&lt;/div&gt;&lt;!-- .col-300 recent widget coolfresh --&gt;

&lt;div class=&quot;col-300 recent widget coolfresh&quot;&gt;
	&lt;h3&gt;My Recent Comments Widget&lt;/h3&gt;
	&lt;ul&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Comment 1&lt;/a&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Comment 2&lt;/a&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Recent Comment 3&lt;/a&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;&lt;!-- .col-300 recent widget coolfresh --&gt;
</pre>
<p>And that&#8217;s it!  Obviously there are many other uses for PHP output buffering but, this technique covers a vast ground.  Can you think of any other uses?  Maybe by utilizing regex?  Maybe we could even nest output buffering sessions?  Be creative!</p>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2012-04/php-development/using-php-output-buffering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Filters to Stop WordPress from Changing Your Code</title>
		<link>http://chriscarvache.com/2012-04/wordpress/using-filters-to-stop-wordpress-from-changing-your-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-filters-to-stop-wordpress-from-changing-your-code</link>
		<comments>http://chriscarvache.com/2012-04/wordpress/using-filters-to-stop-wordpress-from-changing-your-code/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 22:59:23 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress Plugins]]></category>
		<category><![CDATA[Wordpress Tutorials]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://development.chriscarvache.com/?p=985</guid>
		<description><![CDATA[<p>WordPress is a fantastic CMS but, sometimes it can be totally quirky.  For example, when dealing with code snippets, WordPress will sometimes change your code to the point where it is unusable by the user.  On this iteration of the site, that ended up happening to a pretty extensive degree.  Here&#8217;s how I got around [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress is a fantastic CMS but, sometimes it can be totally quirky.  For example, when dealing with code snippets, WordPress will sometimes change your code to the point where it is unusable by the user.  On this iteration of the site, that ended up happening to a pretty extensive degree.  Here&#8217;s how I got around it&#8230;<span id="more-985"></span></p>
<h3>Using Filters</h3>
<p>The easiest way to fix WordPress from going crazy on your code snippets is to use a filter.  This is super easy to do and incredibly effective.  The example below is the code I use in my functions.php file.  However, please note that depending on what WordPress version you are using and what combination of plugins you are using, will effect what kind of code you&#8217;ll need to write in order to compensate.  The goal is to identify what characters are being changed to an incorrect sequence.  Anyway, on to the code!</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
function fixMyCode( $content ) {
	$content = str_replace ('&amp;amp;', '&', $content);
	$content = str_replace ('&amp;lt;br&amp;gt;', &quot;\n&quot;, $content);
	return $content;
}
add_filter('the_content', 'fixMyCode');
?&gt;
</pre>
<p>And that&#8217;s it!  How simple was that?!  You&#8217;ll be able to find that mischievous code if you view the source of your web page.   Its definitely funky looking but, that&#8217;s the whole point of this filter.</p>
<p>Also note&#8230; That in the second text replacement that I&#8217;ve used double quotes for the \n character.  This is CRUCIAL as PHP will only parse the \n character as a new-line break if it appears in double quotes.  If you use single quotes are used PHP will just insert \n as a string.</p>
<p>Hopefully this tip will make your life as easier as its made mine!</p>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2012-04/wordpress/using-filters-to-stop-wordpress-from-changing-your-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using WordPress Custom Fields to Integrate with Other Plugins</title>
		<link>http://chriscarvache.com/2011-07/wordpress/using-wordpress-custom-fields-to-integrate-with-other-plugins/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-wordpress-custom-fields-to-integrate-with-other-plugins</link>
		<comments>http://chriscarvache.com/2011-07/wordpress/using-wordpress-custom-fields-to-integrate-with-other-plugins/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 16:53:18 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://development.newleafwebsolutions.com/?p=423</guid>
		<description><![CDATA[The other day, I was at a client's studio showing them a real world example of how to build a custom Wordpress theme.  The design was simple so it was a perfect crash course.  Everything was going smoothly until we decided to integrate one of the slideshow plugins into the theme.  The idea was simple: have the client be able to select a custom image slider on a per page basis.  This could have been accomplished via shortcodes but given the layout of the site, an ugly CSS hack would need to exist in order to make it work.]]></description>
			<content:encoded><![CDATA[<p>The other day, I was at a client&#8217;s studio showing them a real world example of how to build a custom WordPress theme.  The design was simple so it was a perfect crash course.  Everything was going smoothly until we decided to integrate one of the slideshow plugins into the theme.  The idea was simple: have the client be able to select a custom image slider on a per page basis.  This could have been accomplished via shortcodes but given the layout of the site, an ugly CSS hack would need to exist in order to make it work.</p>
<p>I thought to myself, &#8220;How can I integrate this slideshow into the theme but, outside of the normal WordPress loop?&#8221;  I didn&#8217;t want to have to tell the client, &#8220;Well, we can put the slideshow in the page but, you have to go into HTML mode and add a div everytime you want to do this.&#8221;  That would be completely unacceptable.  After thinking about the problem for a  minute, I realized that using custom fields would be easy to implement and make the process super simple for the client.</p>
<h2>Why Custom Fields?</h2>
<p>Custom fields are a great way to add small bits of information to a page or post.  Even better, depending on the function used to access the custom field(s), you can put custom field data outside of the WordPress loop.  This makes it extremely easy to create powerful template that smoothly integrate with other plugins.</p>
<h2>The Simple Code</h2>
<p>Here&#8217;s what we&#8217;ve got:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$customfield = get_post_meta($post-&gt;ID, 'billboard', true);
the_uds_billboard($customfield);
?&gt;
</pre>
<p>In the first line, we use the get_post_meta function to access the billboard variable.  The first parameter is the id of what page / post is currently being used.  The second parameter is the custom field variable we&#8217;re going to access.  The third parameter means that the function is going to output a single value.  In this situation, whatever the value of billboard is.</p>
<p>The second line is specific to the plugin I used.  In order to output the slideshow, the plugin just needed one parameter: the name of the slideshow.</p>
<p>And that&#8217;s pretty much it.  I know the code is abstract in this example but, the important thing is to understand the concept and how you can use it in your own implementations.</p>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2011-07/wordpress/using-wordpress-custom-fields-to-integrate-with-other-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery AJAX Page Template</title>
		<link>http://chriscarvache.com/2011-07/front-end-development/jquery-ajax-page-template/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jquery-ajax-page-template</link>
		<comments>http://chriscarvache.com/2011-07/front-end-development/jquery-ajax-page-template/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 14:26:29 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://development.newleafwebsolutions.com/?p=416</guid>
		<description><![CDATA[Whenever I make an AJAX powered page, my jQuery skeleton looks pretty much the same.  I have a load function, bind some event handlers and usually make an AJAX request or two.  I got tired of typing the same stuff out all the time so I created a pretty slick template.  Here's what I'm starting off with now.]]></description>
			<content:encoded><![CDATA[<p>Whenever I make an AJAX powered page, my jQuery skeleton looks pretty much the same.  I have a load function, bind some event handlers and usually make an AJAX request or two.  I got tired of typing the same stuff out all the time so I created a pretty slick template.  Here&#8217;s what I&#8217;m starting off with now.</p>
<h2>The Code</h2>
<pre class="brush: php; title: ; notranslate">
/**
 * jQuery AJAX File Template
 * @author New Leaf Web Solutions
 * @version 1.0
 */

jQuery(document).ready(function($){
	/**
	 * Perform Initial Load Tasks
	 */
	function onLoad() {
		// Do stuff
	}

	/**
	 * A Click Event Handler Script
	 */
	function myClickEventHandler() {
		/**
		 * Sample AJAX Call
		 */
		var mydata = $('#myajaxform').serialize();
		$.ajax({
			url: &quot;myurl.php&quot;,
			async: true,
			cache: true,
			type: &quot;POST&quot;,
			data: mydata,
			beforeSend: function(jqXHR, settings) {

			},
			error: function(jqXHR, textStatus, errorThrown) {

			},
			success: function(data, textStatus, jqXHR) {

			},
			complete: function(jqXHR, textStatus) {

			}
		});
	}

	/**
	 * A Change Event Handler Script
	 */
	function myChangeEventHandler() {
		// Do stuff
	}

	/**
	 * Bind Events
	 */
	$('.myclickelement').click(function(){
		myClickEventHandler();
	});

	$('.mychangeelement').change(function(){
		myChangeEventHandler();
	});

	// Run the initial load event
	onLoad();
});
</pre>
<h2>Explanation</h2>
<p>The idea here is simple.  Bind all the events and create functions for their processing.  You might ask&#8230; &#8220;Why not just the code directly inside the event handler?&#8221;.  Great question.  The reason is because using this method the code becomes more modular.  Almost every time I write jQuery I run into the situation where I have to write similar code for multiple event handlers.  That being said, this method sets you up for easy refactoring.  Not to mention it keeps the code looking super clean and makes everything easy to find.</p>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2011-07/front-end-development/jquery-ajax-page-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Staying Productive When Coding (Top-Down Approach)</title>
		<link>http://chriscarvache.com/2011-07/productivity/staying-productive-when-coding-top-down-approach/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=staying-productive-when-coding-top-down-approach</link>
		<comments>http://chriscarvache.com/2011-07/productivity/staying-productive-when-coding-top-down-approach/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 14:37:00 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[Productivity]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://development.newleafwebsolutions.com/?p=409</guid>
		<description><![CDATA[For some, coding can be the most fun part of the job.  For others it can be the design aspect.  For others it can be landing the deal.  Either way, all three are crucial steps to completing a project.  However, being that coding is 100% logic regardless of language or framework, a logical approach should be taken to maximize how productive you are with your text editor / IDE.  After all, the faster you can code, the higher your hourly rate is and the more time you have to spend outside of working.]]></description>
			<content:encoded><![CDATA[<p>For some, coding can be the most fun part of the job. For others it can be the design aspect. For others it can be landing the deal. Either way, all three are crucial steps to completing a project. However, being that coding is 100% logic regardless of language or framework, a logical approach should be taken to maximize how productive you are with your text editor / IDE. After all, the faster you can code, the higher your hourly rate is and the more time you have to spend outside of working.</p>
<p>While this process is in no means set in stone, I’ve found that it works extremely well and keeps me in the zone the entire time. You should experiment and find something that works for you. If you aren’t sure where to start in your own personal process, this is a good starting point.</p>
<h2>General Rules</h2>
<p>I&#8217;ve found that while working on anything, there are several things to keep in mind.  Following these principles keeps the flow going, helps you avoid the &#8220;what should I do next&#8221; question and eliminates feeling overwhelmed by our never ending task lists.</p>
<p><strong>Leave Emotions Behind</strong> &#8211; This can one of the hardest things to do while working.  Its easy to wonder off in a day dream about your last vacation or remember the scorn of a bad breakup.  The simplest way to get over this is to simply tell yourself not to think about it when you catch yourself wandering off.</p>
<p><strong>Create An Awesome Work Environment</strong> &#8211; You will be more productive an environment that you feel most comfortable in.  Look at some of the workspaces other professionals have created.  Some are utterly amazing.  Not to mention, its all a big write-off at the end of the year <img src='http://chriscarvache.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Eliminate Distractions</strong> &#8211; Identify what diverts your attention and remove it.  Even when working in a team environment, there should be a time for collaboration and a time to put your head down.  Avoid being reactive towards situations that occur on a daily basis; this could mean not answering your phone right away, not jumping to respond to an email and telling people no or that your busy.  Although our days never play out exactly the way we want them to, staying agile and integrating daily surprises into our workflow almost never have to be dealt with the second they appear.</p>
<p><strong>Establish Priorities</strong> &#8211; Knowing what to work on and in what order will keep you constantly moving.  When faced with many tasks, it can sometimes be difficult to decide on what should come first.  If this happens, it usually means that the tasks in front of you have the same priority.  In that case, it doesn&#8217;t matter what comes next on your list, just that something comes next and that there is no lag in making a decision.</p>
<p><strong>Set Reasonable Goals</strong> &#8211; I always have at least 10 different things to accomplish, both on a high and low level.  It can be very overwhelming thinking about what I need to do.  Try and set daily, weekly and monthly goals.  This will free your mind and allow you concentrate on what&#8217;s important now.</p>
<p><strong>Focus and Keep Moving</strong> &#8211; Computers are fantastic multi-taskers.  Even the best multi-tasking humans are not by comparison.  I&#8217;ve found that keeping your head locked in on one task yields higher quality work and the satisfaction of being able to cross something off your to-do list.  Only move on to another task when you have finished what you are working on or if you&#8217;ve hit a road block.  Most of the time, freeing yourself from a problem and coming back to it later with a fresh perspective will result in a solution.</p>
<h2>Coding Process</h2>
<p>Being primarily a web development firm, this process represents our industry specific process.</p>
<p><strong>XHTML / HTML 5</strong> &#8211; Create a document with ALL the XHTML / HTML 5 in it first.  Setup your entire page structure from top to bottom.  This includes attaching all ids, classes and such to all the page elements that require them.</p>
<p><strong>CSS / Styling</strong> &#8211; After you&#8217;ve written some rock solid markup, work on the visuals.  This should come quickly if you&#8217;ve structured your markup correctly.  There are great tools out there to help with this process.  <a href="http://www.google.com/chrome/" target="_blank">Google Chrome</a> has a fantastic set of development tools available for rapidly developing CSS.  If you are set on using <a href="http://www.mozilla.com/" target="_blank">Firefox</a>, use tools like <a href="http://getfirebug.com/" target="_blank">Firebug</a> or <a href="https://addons.mozilla.org/en-US/firefox/addon/web-developer/" target="_blank">Web Developer</a>.</p>
<p><strong>Server-Side</strong> &#8211; After your page looks nice, start implementing any server-side code.  While some people may disagree with this approach and say this should be done more towards the beginning of the work flow, remember that this is a top down approach.  Besides, part of making your site / application work the right way is to have a good UI / UX.</p>
<p><strong>AJAX</strong> &#8211; While every project doesn&#8217;t use this technique, it is becoming increasingly difficult to find projects that don&#8217;t.  Being that AJAX is a combination of front-end and server-side code, this step should come last.  Just as with the previous steps of this process, work on doing the font-end tasks first.  This means writing all of your JavaScript first and then worrying about the actual AJAX calls last.  Also, if you&#8217;re not using a framework, stop wasting time and go grab one.  I&#8217;ve tried out several including <a href="http://developer.yahoo.com/yui/" target="_blank">Yahoo User Interface Library</a>, <a href="http://mootools.net/" target="_blank">MooTools</a> and <a href="http://www.prototypejs.org/" target="_blank">Prototype</a> but, since discovering <a href="http://jquery.com/" target="_blank">jQuery</a> 3 or so years ago haven&#8217;t looked back.</p>
<h2>So Now What?</h2>
<p>Time to get to work!  Hopefully these tips and process will help you squeeze more out of your already limited availability.  I also want to thank my good friend Anais Disla for her wise words on the subject.  Check her out on put link here.  Alright!  Now get to work!</p>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2011-07/productivity/staying-productive-when-coding-top-down-approach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Plugin Activation Email</title>
		<link>http://chriscarvache.com/2011-06/web-design-development/wordpress-plugin-activation-email/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress-plugin-activation-email</link>
		<comments>http://chriscarvache.com/2011-06/web-design-development/wordpress-plugin-activation-email/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 03:54:59 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[Marketing]]></category>
		<category><![CDATA[Plugin Development]]></category>
		<category><![CDATA[Web Design & Development]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[marketing]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://development.newleafwebsolutions.com/?p=260</guid>
		<description><![CDATA[While writing some code the other day, I started thinking about marketing.  More specifically, I thought to myself, "How would I get someone to remember me and my company after I created a plugin?".  More importantly, how would I get them to tell their friends.  We all know that referrals are the BEST source of new work.  That said I thought I might go the extra mile.]]></description>
			<content:encoded><![CDATA[<p>While writing some code the other day, I started thinking about <strong>marketing</strong>.  More specifically, I thought to myself, &#8220;How would I get someone to remember me and my company after I created a plugin?&#8221;.  More importantly, how would I get them to tell their friends.  We all know that referrals are the BEST source of new work.  That said I thought I might go the extra mile.</p>
<h2>Saying Hello</h2>
<p>While emailing can be invasive, emailing under the right and proper scenarios is usually highly effective.  With that said here is the concept: email the admin when activating your plugin.  This way the admin has a handy reference of where to find your plugin and its support community.  Not that putting that information in other places in your plugin isn&#8217;t an effective way of communication but, once again going that extra mile is always a help.</p>
<h2>The Code</h2>
<p>This is actually almost a no brainer.  Being a two part process, the first part of the idea is as follows: <strong>register the activation hook</strong>.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
register_activation_hook( __FILE__, 'my_plugin_activation_hook_function' );
?&gt;
</pre>
<p>See!?  Pretty simple right?  I sure hope!  Moving along, the second part: <strong>create the corresponding function.</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
* Plugin activation hook
*/
function my_plugin_activation_hook_function() {
	// Send email to the adminstrator of the site
	$adminemail = get_option('admin_email');
	$subject = &quot;Thank you for installing My Plugin!\n&quot;;
	$message = &quot;Dear Administrator,\n&quot;;
	$message.= &quot;Thank your for installing My plugin.&nbsp; Please visit this plugin's site at http://yoursite.com/myplugin/\n\n&quot;;
	$message.= &quot;All the best,\n&quot;;
	$message.= &quot;Your Web Developer&quot;;
	wp_mail( $adminemail, $subject, $message );
}
?&gt;
</pre>
<p>And there it is!!  Pretty simple eh?  Take as much liberty to customize this process to your liking.  Also as a challenge&#8230; See if you can make this work so that the plugin sends out the welcome on the FIRST time it is activated and first time ONLY.  I have done this with my plugins.  Lets see if you can <img src='http://chriscarvache.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2011-06/web-design-development/wordpress-plugin-activation-email/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress Plugin Template</title>
		<link>http://chriscarvache.com/2011-06/wordpress/wordpress-plugin-template/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress-plugin-template</link>
		<comments>http://chriscarvache.com/2011-06/wordpress/wordpress-plugin-template/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 16:35:06 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[Plugin Development]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://development.newleafwebsolutions.com/?p=231</guid>
		<description><![CDATA[I have written a few Wordpress Plugins.  All of them follow suit to some degree:  the commented template header, creating some globals and initializing a few menu options.  Being that I love to do things in the most time efficient way possible, I came up with a pretty good starting ground that I can constantly reuse.  All I need to do now is change a few things and I'm ready to start writing the real code.  Keep reading to see the code...]]></description>
			<content:encoded><![CDATA[<p>I have written a few <strong>WordPress Plugins</strong>.  All of them follow suit to some degree:  the commented <strong>template </strong>header, creating some globals and initializing a few menu options.  Being that I love to do things in the most time efficient way possible, I came up with a <strong>WordPress Plugin Template</strong> which offers a pretty good starting ground that I can constantly reuse.  All I need to do now is change a few things and I&#8217;m ready to start writing the real code.</p>
<p>While this is a good starting point at the moment, I expect that it will continue to expand as I continue to write plugins.  Eventually it will expand into a full featured plugin framework.  See below for the code.  Note how the majority of the code has been taken directly from the <a href="http://codex.wordpress.org/Writing_a_Plugin" target="_blank">WordPress codex</a>.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
* Plugin Name: Plugin Name Here
* Plugin URI: http://yoursitehere.com/plugin-name
* Description: Plugins brief description here.
* Version: 0.1
* Author: Your Name Here
* Author URI: http://yoursitehere.com/
* License: GPL2
*
* Copyright 2011 PLUGIN_AUTHOR_NAME (email : plugins@yoursitehere.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
 
define('PLUGIN_VERSION', 1);
define('PLUGIN_URL', rtrim(plugin_dir_url(__FILE__)));
define('PLUGIN_DIR', rtrim(plugin_dir_path(__FILE__)));
 
// Hook for adding admin menus
add_action('admin_menu', 'mt_add_pages');
 
function mt_add_pages() {
// Add a new top-level menu (ill-advised):
add_menu_page(__('Test Toplevel','menu-test'), __('Test Toplevel','menu-test'), 'manage_options', 'mt-top-level-handle', 'mt_toplevel_page' );
 
// Add a submenu to the custom top-level menu:
add_submenu_page('mt-top-level-handle', __('Test Sublevel','menu-test'), __('Test Sublevel','menu-test'), 'manage_options', 'sub-page', 'mt_sublevel_page');
 
// Add a second submenu to the custom top-level menu:
add_submenu_page('mt-top-level-handle', __('Test Sublevel 2','menu-test'), __('Test Sublevel 2','menu-test'), 'manage_options', 'sub-page2', 'mt_sublevel_page2');
}
 
// mt_toplevel_page() displays the page content for the custom Test Toplevel menu
function mt_toplevel_page() { ?&gt;
	&lt;div class=&quot;wrap&quot;&gt;
		&lt;div id=&quot;icon-options-general&quot; class=&quot;icon32&quot;&gt;&lt;/div&gt;
		&lt;h2&gt;&lt;?php echo __( 'Test Toplevel', 'menu-test' ); ?&gt; &lt;/h2&gt;
		&lt;p&gt;Content here.&lt;/p&gt;
	&lt;/div&gt;
&lt;?php }
 
// mt_sublevel_page() displays the page content for the first submenu
// of the custom Test Toplevel menu
function mt_sublevel_page() { ?&gt;
&lt;div class=&quot;wrap&quot;&gt;
	&lt;div id=&quot;icon-options-general&quot; class=&quot;icon32&quot;&gt;&lt;/div&gt;
	&lt;h2&gt; &lt;?php echo __( 'Test Sublevel', 'menu-test' ); ?&gt; &lt;/h2&gt;
	&lt;p&gt;Content here.&lt;/p&gt;
&lt;/div&gt;
&lt;?php }
 
// mt_sublevel_page2() displays the page content for the second submenu
// of the custom Test Toplevel menu
function mt_sublevel_page2() { ?&gt;
	&lt;div class=&quot;wrap&quot;&gt;
		&lt;div id=&quot;icon-options-general&quot; class=&quot;icon32&quot;&gt;&lt;/div&gt;
		&lt;h2&gt; &lt;?php echo __( 'Test Sublevel2', 'menu-test' ); ?&gt; &lt;/h2&gt;
		&lt;p&gt;Content here.&lt;/p&gt;
	&lt;/div&gt;
&lt;?php }
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2011-06/wordpress/wordpress-plugin-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Session Variables and Domain Aliases to Change the WordPress URL</title>
		<link>http://chriscarvache.com/2011-03/wordpress/using-session-variables-and-domain-aliases-to-change-the-wordpress-url/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-session-variables-and-domain-aliases-to-change-the-wordpress-url</link>
		<comments>http://chriscarvache.com/2011-03/wordpress/using-session-variables-and-domain-aliases-to-change-the-wordpress-url/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 01:28:11 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Design & Development]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[session variables]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp-config.php]]></category>

		<guid isPermaLink="false">http://chriscarvache.com/?p=325</guid>
		<description><![CDATA[<p>Alright, so I ran into an interesting situation the other day.  Here&#8217;s the scenario&#8230; A client of mine needed a website redesign that basically combined two sites into one.  She had two almost IDENTICAL sites that only differed slightly.  Aside from a couple of different pages and some price changes on the courses she offered, [...]]]></description>
			<content:encoded><![CDATA[<p>Alright, so I ran into an interesting situation the other day.  Here&#8217;s the scenario&#8230; A client of mine needed a website redesign that basically combined two sites into one.  She had two almost IDENTICAL sites that only differed slightly.  Aside from a couple of different pages and some price changes on the courses she offered, the sites were the same.  No need for two sites now is there?  Of course not!  The tricky part was that each site had a different URL.  If a user entered the site from <span style="color: #ff0000;"><strong>www.mysiteA.com</strong></span> they&#8217;d see one thing.  If they entered the site from <span style="color: #ff0000;"><strong>www.mysiteB.com</strong></span> they&#8217;d see another thing.  The challenge was getting WordPress to rewrite the URLs based on the aforementioned criteria.  After thinking about this and bugging <a title="SKC" href="http://scottkclark.com/" target="_blank">SKC</a>, here&#8217;s what I came up with&#8230;<br />
<span id="more-325"></span></p>
<h2>Step 1: Editing the wp.config file</h2>
<p>All that needs to happen here is that this code goes into the top of the <strong>wp-config.php</strong> file.  Obviously you&#8217;ll have to replace the <strong>mysiteA.com</strong>, <strong>mysiteB.com</strong> and session variables with values of you choice but that&#8217;s still pretty simple.  Let&#8217;s check it out.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
session_start();
$url_host = $_SERVER['HTTP_HOST'];

if (!isset($_SESSION['domainReferrer']))
	if ($url_host == 'mysiteA.com' || $url_host == 'www.mysiteA.com') {
		$_SESSION['domainReferrer'] = 'Site A';
		define('WP_SITEURL', 'http://mysiteA.com');
		define('WP_HOME', 'http://mysiteA.com');
	}

	else {
		$_SESSION['domainReferrer'] = 'Site B';
		define('WP_SITEURL', 'http://mysiteB.com');
		define('WP_HOME', 'http://mysiteB.com');
	}

else {
	if ($url_host == 'mysiteA.com' || $url_host == 'www.mysiteA.com'){
		$_SESSION['domainReferrer'] = 'Site A';
		define('WP_SITEURL', 'http://mysiteA.com');
		define('WP_HOME', 'http://mysiteA.com');
	}

	else {
		$_SESSION['domainReferrer'] = 'Site B';
		define('WP_SITEURL', 'http://mysiteB.com');
		define('WP_HOME', 'http://mysiteB.com');
	}
}
?&gt;
</pre>
<h2>Step 2: Conditionally Controlling Presentation / Functionality</h2>
<p>In almost every situation, my code looked something like the code below to conditionally control what was being display.</p>
<pre class="brush: php; title: ; notranslate">

if ($_SESSION['domainReferrer']=='Site A') {
// Put Site A Logic Here
} else {
// Put Site B Logic Here
}
</pre>
<h2>Step 3: Configuring Your Server&#8217;s Virtual Hosts</h2>
<p>This part is going to be different for everyone but basically the idea is to have a main <strong>mysiteA.com</strong> as the virtual host that has <strong>PHYSICAL</strong> hosting on your server and then to map <strong>mysiteB.com</strong> as a domain alias of <strong>mysiteA.com</strong>.  The good thing though is that it doesn&#8217;t matter which site (either mysiteA.com or mysiteB.com) has the physical hosting and which is the domain alias.  This is because they are pretty much the same thing.</p>
<p>Well, that&#8217;s about it!!!  I hope this little hack comes in useful for someone!!</p>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2011-03/wordpress/using-session-variables-and-domain-aliases-to-change-the-wordpress-url/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Automatic WordPress Updates with SVN</title>
		<link>http://chriscarvache.com/2010-10/wordpress/320/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=320</link>
		<comments>http://chriscarvache.com/2010-10/wordpress/320/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 15:07:08 +0000</pubDate>
		<dc:creator>Chris Carvache</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[updates]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://chriscarvache.com/?p=320</guid>
		<description><![CDATA[<p>I just saw this article and wanted to let people know about it.</p> <p>Anything in my opinion that saves time is a winner!</p> <p>http://simpledream.net/2010/10/19/wordpress-auto-updates-svn/</p>]]></description>
			<content:encoded><![CDATA[<p>I just saw this article and wanted to let people know about it.</p>
<p>Anything in my opinion that saves time is a winner!</p>
<p><a href="http://simpledream.net/2010/10/19/wordpress-auto-updates-svn/">http://simpledream.net/2010/10/19/wordpress-auto-updates-svn/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chriscarvache.com/2010-10/wordpress/320/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

