<?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>CMS tutorial site</title>
	<atom:link href="http://blog.cmstutorials.org/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.cmstutorials.org</link>
	<description>Free tutorials and resources</description>
	<lastBuildDate>Thu, 26 Apr 2012 14:21:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to add buttons to the wordpress editor</title>
		<link>http://blog.cmstutorials.org/tutorials/how-to-add-buttons-to-the-wordpress-editor</link>
		<comments>http://blog.cmstutorials.org/tutorials/how-to-add-buttons-to-the-wordpress-editor#comments</comments>
		<pubDate>Thu, 26 Apr 2012 14:21:25 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[buttons]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1559</guid>
		<description><![CDATA[In this quick tip I will show you how to add a button to the wordpress editor which will open a thickerbox modal window similar to the media uploader.]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to add a custom button to the WP editor for your free/personal/commercial plugin? in this quick tip I will guide you through the steps towards this goal. This is what we will be creating:</p>
<p>Tip: Make sure to enqueue jQuery! We will need it later on.</p>
<h2>Freebee</h2>
<p>If you wish to have a more complete version of this plugin go to <a href="http://cmstutorials.org/downloads/item/70" target="_blank">our main site</a> and grab your copy. The freeplugin is based on this tutorial but has a more complete list of the most wanted &amp; popular shortcodes.</p>
<h2>step 1. Create a new plugin</h2>
<p>For this quick tip we will quickly create a new plugin, so in the plugin folder create a new folder named <strong>custom_editor_button </strong>and in that folder create a new file named <strong>index.php</strong>. In that file add the following comment block to the file.</p>
<pre class="brush: php; title: ; notranslate">
 &lt;!--?php &lt;br ?--&gt; /*
 Plugin Name: thickerbox example
 Plugin URI: http://cmstutorials.org
 Description: A simple plugin to add a button to the editor which will open a thickerbox window
 Author: CMS tutorials
 Version: 1.0
 Author URI: http://cmstutorials.org
 */
 </pre>
<p>This is the required infor for every WordPress plugin. WordPress won&#8217;t recognize the plugin without this info.</p>
<p><strong>step 2. Create the actions</strong></p>
<p>We now need to create 2 actions, the first one will add a button to the editor and the second one will provide the content of the thickerbox modal window.</p>
<pre class="brush: php; title: ; notranslate">
 add_action('media_buttons', 'thickbox_shortcodes', 11);
 add_action('admin_footer', 'thickbox_content');
 </pre>
<p>The second parameter links to functions which we still have to create</p>
<h2>step 3. Create the functions</h2>
<p>The first function to create is thickbox_shortcodes, this will add the button to the editor. We talk about a button but it is actually nothing more than an image with a link.</p>
<pre class="brush: php; title: ; notranslate">
 function thickbox_shortcodes() {
     ?&gt;
 &lt;a id=&quot;thickbox_shortcode_button&quot; title=&quot;Available Shortcodes&quot; href=&quot;#TB_inline?width=670&amp;inlineId=thickbox_shortcode_window&quot;&gt;
         &lt;img src=&quot;&lt;?php echo bloginfo('url'); ?&gt;/wp-admin/images/media-button-other.gif&quot; alt=&quot;&quot; width=&quot;18px&quot; height=&quot;18px&quot; /&gt;
     &lt;/a&gt;
 &lt;!--?php  }  </pre>
</pre-->The most important here is the content of the href attribute: inlineId=thickbox_shortcode_window. inlineId matches the id div of the thickerbox content. Which we will create now.</p>
<pre class="brush: php; title: ; notranslate">  function thickbox_content(){  ?&gt;&lt;/pre&gt;
&lt;div id=&quot;thickbox_shortcode_window&quot; style=&quot;display: none;&quot;&gt;    &lt;!-- thickerbox content here --&gt;&lt;/div&gt;
&lt;pre&gt;
 &lt;!--?php &lt;br ?--&gt; }
 </pre>
<p>the id of the div must match the inlineId specified in the href of the button.</p>
<h2>Step 4. add list of shortcodes</h2>
<p>Now let&#8217;s add some content to the thickerbox modal window. We will add a list of simple shortcodes that once clicked will be added in the wordpress editor. Very usefull if you need a quick shortcode but don&#8217;t remember the exact syntac or the number of attributes it provides.</p>
<p>Replace <strong>&lt;!&#8211; thickerbox content here &#8211;&gt;</strong> with</p>
<pre class="brush: php; title: ; notranslate">&lt;/pre&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Shortcode&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a id=&quot;test1&quot; href=&quot;javascript:void(0);&quot;&gt;Test shortcode&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Click to insert the test shortcode&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a id=&quot;test2&quot; href=&quot;javascript:void(0);&quot;&gt;Test2 shortcode&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Click to insert the test2 shortcode&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a id=&quot;test3&quot; href=&quot;javascript:void(0);&quot;&gt;Test3 shortcode&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Click to insert the test3 shortcode&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre&gt;
&lt;script type=&quot;text/javascript&quot;&gt;// &lt;![CDATA[
 jQuery(function($){
 //javascript code here
 });

// ]]&gt;&lt;/script&gt;
 </pre>
<h2>Step 5. insert shortcodes in editor on click</h2>
<p>Now that we have our shortcode list let&#8217;s add the nescessary javascript. What we want to do is insert the shortcode when we click on the link.</p>
<pre class="brush: php; title: ; notranslate">
 //we use unbind to prevent the click event to fire multiple times
 $('.insert_shortcode').unbind('click').bind(&quot;click&quot;,function() {
 //prepare shortcode variabel
 var shortcode = '';

 //get the id of the clicked element and load the correct shortcode
 switch(this.id){
 case 'test1':
 shortcode = '[test1 param=&quot;tester&quot;]Content for shortcode test1[/test1]';
 break;
 case 'test2':
 shortcode = '[test2 param=&quot;tester&quot;]Content for shortcode test2[/test2]';
 break;
 case 'test3':
 shortcode = '[test3 param=&quot;tester&quot;]Content for shortcode test3[/test3]';
 break;
 }

 //check if visual editor is active or not
 is_tinyMCE_active = false;
 if (typeof(tinyMCE) != &quot;undefined&quot;) {
 if (tinyMCE.activeEditor != null) {
 is_tinyMCE_active = true;
 }

 }

//append shortcode to the content of the editor
 if ( is_tinyMCE_active ) {
 tinymce.execCommand('mceInsertContent', false, shortcode);
 } else {
 var wpEditor = $('.wp-editor-area');
 wpEditor.append(shortcode);
 }
 return false;
 });
 </pre>
<p>Let&#8217;s go over the code</p>
<ul>
<li>We track the click event on the class insert_shortcode. We added an unbind event to prevent the click event to fire multiple times on one click</li>
<li>We then get the id using this.id and use it in a switch to get the corresponding shortcode</li>
<li>We add a quick check to see if the visual editor is being used or not</li>
<li>We finally write the shortcode to the editor. For the non visual editor we used the jQuery .append() to avoid overwritting the complete content of your post. but feel free to use whatever method you want</li>
<li>Finally we return false to disable the default behaviour of a link.</li>
</ul>
<h2>Conclussion</h2>
<p>There you go, in only a few steps we added a button to the editor which opens a thickbox modal window from where you can insert shortcodes to the wordpress editor. This is of course only an example of what you can do. The next step for you is to extend this using form elements to, for example, create the shortcode attributes dynamicly. Or you could use it to add something completely different than a shortcode.</p>
<p>Don&#8217;t forget to download our freebee based on this tutorial. It contains a list of the most popular shortcodes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/tutorials/how-to-add-buttons-to-the-wordpress-editor/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Featured tutorial of the week 01/02/2012</title>
		<link>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-01022012-2</link>
		<comments>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-01022012-2#comments</comments>
		<pubDate>Wed, 01 Feb 2012 09:27:54 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Round-Ups]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Node.js]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1552</guid>
		<description><![CDATA[Each week we feature a new tutorial. This weeks featured tutorial is <strong>This time you'll learn Node.js</strong>]]></description>
			<content:encoded><![CDATA[<div class='roundup_post'>
<h3><a href='http://cmstutorials.org/tutorial/view/this_time_you_ll_learn_node_js' target='_blank'>Title here</a></h3><a href='http://cmstutorials.org/tutorial/view/this_time_you_ll_learn_node_js' target='_blank'><img class='floatleft' src='http://cmstutorials.org/sources/tutorials/1326443448-tutimage-777.png' alt='Title here' title='Title here' /></a><p>In this series you will be using Node to create a simple blog engine to give you a real feel for how Node.js works.</p>
<a href='http://cmstutorials.org/tutorial/view/this_time_you_ll_learn_node_js'>View article</a>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-01022012-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create color pickers with frabtastic dynamicly</title>
		<link>http://blog.cmstutorials.org/freebees/how-to-create-color-pickers-with-frabtastic-dynamicly</link>
		<comments>http://blog.cmstutorials.org/freebees/how-to-create-color-pickers-with-frabtastic-dynamicly#comments</comments>
		<pubDate>Sat, 21 Jan 2012 17:07:55 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[Code snippets]]></category>
		<category><![CDATA[Freebees]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[color picker]]></category>
		<category><![CDATA[frabtastic]]></category>
		<category><![CDATA[freebee]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1543</guid>
		<description><![CDATA[A very usefull code snippet to dynamicly create frabtastic color pickers for your Wordpress themes.]]></description>
			<content:encoded><![CDATA[<p>In a previous article (<a href="http://blog.cmstutorials.org/reviews/general/how-to-add-a-color-picker-in-your-wp-theme-using-frabtastic">How to add a color picker in your wp theme using frabtastic</a>) we explained how you could add color pickers using frabtastic in a custom WordPress admin panel for a specific theme. In this article we will provide you with an example on how you could extend this even further. So, instead of copy/pasting the code and markup for each color picker why not create the markup and code just once and reuse it for all other color pickers.</p>
<p>Enjoy this code and if you have any questions drop us a comment below. You can download the entire code as a <a href="http://blog.cmstutorials.org/wp-content/uploads/dynamic_frabtastic_color_pickers.zip">twentyten child theme</a>.</p>
<p>At the top of your functions.php add:</p>
<pre class="brush: php; title: ; notranslate">//define your color pickers
$colorPickers = array(
array('ID' =&gt; 'color_1', 'label' =&gt; 'Color 1', 'default_color' =&gt; '#002c84'),
array('ID' =&gt; 'color_2', 'label' =&gt; 'Color 2', 'default_color' =&gt; '#002c84'),
array('ID' =&gt; 'color_3', 'label' =&gt; 'Color 3', 'default_color' =&gt; '#002c84'),
array('ID' =&gt; 'color_4', 'label' =&gt; 'Color 4', 'default_color' =&gt; '#002c84'),
);</pre>
<p>The Markup:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
foreach($colorPickers as $colorPicker):
$colorOption = get_option($colorPicker['ID']);
if (empty($colorOption) || $colorOption == ''):
add_option($colorPicker['ID'], $colorPicker['default_color']);
endif;
?&gt;
&lt;div&gt;
&lt;label for=&quot;&lt;?php echo $colorPicker['ID']; ?&gt;&quot;&gt;&lt;?php _e($colorPicker['label']); ?&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; id=&quot;&lt;?php echo $colorPicker['ID']; ?&gt;&quot; value=&quot;&lt;?php echo get_option($colorPicker['ID']); ?&gt;&quot; name=&quot;&lt;?php echo $colorPicker['ID']; ?&gt;&quot; /&gt;
&lt;div id=&quot;&lt;?php echo $colorPicker['ID']; ?&gt;_color&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;hr /&gt;
&lt;?php endforeach; ?&gt;</pre>
<p>The jQuery:</p>
<pre class="brush: php; title: ; notranslate">var colorPickers = $('.color-picker');
for (e in colorPickers) {
if (colorPickers[e].id != undefined ) {
var colorPickerID = colorPickers[e].id;
$('#'+ colorPickerID + '_color').farbtastic('#' + colorPickerID);
}
}
</pre>
<p>The function to save it all in the DB:</p>
<pre class="brush: php; title: ; notranslate">function color_picker_option_update()
{
global $colorPickers;
foreach($colorPickers as $colorPicker) {
update_option($colorPicker['ID'], esc_html($_POST[$colorPicker['ID']]));
}
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/freebees/how-to-create-color-pickers-with-frabtastic-dynamicly/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Dynamic website part 4 &#8211; Deleting records</title>
		<link>http://blog.cmstutorials.org/tutorials/dynamic-website-part-4-deleting-records</link>
		<comments>http://blog.cmstutorials.org/tutorials/dynamic-website-part-4-deleting-records#comments</comments>
		<pubDate>Sat, 07 Jan 2012 18:42:57 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[PHP & MYSQL]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[dynamic website]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1530</guid>
		<description><![CDATA[in part 4 of this tutorial serie we have a look on how to delete records from the database.]]></description>
			<content:encoded><![CDATA[<p>In the previous tutorials you learned how to read from the database and how to add new records. This time we will learn how to delete specific records.</p>
<p>First of all we will quickly add some links in the sidebar so we can navigate throught the pages more quickly.</p>
<pre class="brush: php; title: ; notranslate">
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;index.php&quot;&gt;Homepage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;articles.php&quot;&gt;Articles&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;addarticle.php&quot;&gt;Add article&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>Now open the <strong>articles.php</strong> file. Under your article (within the while loop) add a delete link:</p>
<pre class="brush: php; title: ; notranslate">&lt;a href=&quot;&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;?action=delete&amp;article_id=&lt;?php echo  $row['id']; ?&gt;&quot;&gt;Delete&lt;/a&gt;</pre>
<p><a href="http://blog.cmstutorials.org/wp-content/uploads/add-delete-url.jpg" rel="lightbox[1530]" title="add-delete-url"><img class="alignnone size-full wp-image-1536" title="add-delete-url" src="http://blog.cmstutorials.org/wp-content/uploads/add-delete-url.jpg" alt="" /></a></p>
<p>Let&#8217;s go to the top of the page (but under the header include line) and catch our parameters. First we will see if there is a query parameter &#8216;action&#8217; and if it is the delete action. We also prepare our trycatchto check if an error occured.</p>
<pre class="brush: php; title: ; notranslate">
if(isset($_GET['action']) &amp;&amp; $_GET['action'] == 'delete')
{
	try{
		//check if an id was given and if it's a number
		//delete record
	}
	catch(Exception $e){
		echo '&lt;div class=&quot;feedback error&quot;&gt;' . $e-&gt;getMessage() . '&lt;/div&gt;';
	}
}
</pre>
<p>We first check for the id and make sure it is a number, if not we throw an exception. (place this in the trycatch)</p>
<pre class="brush: php; title: ; notranslate">
//if it does not exist
if(!isset($_GET['article_id']))
{
//throw an exception
	throw new exception('No id given');
}
//if it's a number
if(is_numeric($_GET['article_id'])){
	//store it in a variable
	$id = mysqli_real_escape_string($link, $_GET['article_id']);
} else {
	//else throw an exception
	throw new exception('The given id is not valid, only numbers!');
}
</pre>
<p>Now that we have the id of the article to delete we can create our query.</p>
<pre class="brush: php; title: ; notranslate">
if(!mysqli_query($link, 'DELETE FROM article WHERE id = ' . $id)){
	//if there was a problem executing the query throw an exception
	throw new exception('Could not delete record from the database');
} else {
	//display a success message
	echo '&lt;div class=&quot;feedback success&quot;&gt;Query successfully deleted.&lt;/div&gt;';
}
</pre>
<p>When you click the delete action you should now see a success message.<br />
<a href="http://blog.cmstutorials.org/wp-content/uploads/success_message.png" rel="lightbox[1530]" title="success_message"><img class="alignnone size-full wp-image-1537" title="success_message" src="http://blog.cmstutorials.org/wp-content/uploads/success_message.png" alt="" width="670" height="352" /></a></p>
<p>You can then add some styling for the error/success message</p>
<pre class="brush: css; title: ; notranslate">
/*ERROR MESSAGE*/
.error
{
padding: 8px 0px 8px 40px;
margin:5px 0px;
-moz-border-radius:4px;
border:1px solid #BF0008;
background:#FFDFDE url(&quot;../images/single_images/delete.png&quot;) no-repeat;
background-position:10px 10px;
color: #BF0008;
}

.error span
{
	font-weight:bold;
}

.error a:link, .error a:visited
{
color:#BF0008;
font-weight:bold;
text-decoration:underline;
}

.error a:hover, .error a:active
{
color:#FFF;
background:#BF0008;
font-weight:bold;
text-decoration:underline;
}

/*SUCCES MESSAGE*/
.succes
{
padding: 8px 0px 8px 40px;
margin:5px 0px;
-moz-border-radius:4px;
border:1px solid #057100;
background:#DFFFDE url(&quot;../images/single_images/check.png&quot;) no-repeat;
background-position:10px 10px;
color: #057100;
}

.succes span
{
	font-weight:bold;
}

.succes a:link, .succes a:visited
{
color:#057100;
font-weight:bold;
text-decoration:underline;
}

.succes a:hover, .succes a:active
{
color:#FFF;
background:#057100;
font-weight:bold;
text-decoration:underline;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/tutorials/dynamic-website-part-4-deleting-records/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Featured tutorial of the week 09/11/2011</title>
		<link>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-09112011</link>
		<comments>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-09112011#comments</comments>
		<pubDate>Wed, 09 Nov 2011 09:57:26 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Round-Ups]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[psd]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1516</guid>
		<description><![CDATA[Each week we feature a new tutorial. This weeks featured tutorial is <strong>From PSD to HTML: Building a Set of Website Designs Step by Step</strong>]]></description>
			<content:encoded><![CDATA[<div class='roundup_post'>
<h3><a href='http://cmstutorials.org/tutorial/view/from_psd_to_html_building_a_set_of_website_designs_step_by_step' target='_blank'>From PSD to HTML: Building a Set of Website Designs Step by Step</a></h3><a href='http://cmstutorials.org/tutorial/view/from_psd_to_html_building_a_set_of_website_designs_step_by_step' target='_blank'><img class='floatleft' src='http://blog.cmstutorials.org/wp-content/uploads/1319701828-tutimage-318.jpg' alt='From PSD to HTML: Building a Set of Website Designs Step by Step' title='From PSD to HTML: Building a Set of Website Designs Step by Step' /></a><p>This tutorial will take you through the entire process of converting a design in Photoshop to completed HTML template.</p>
<a href='http://cmstutorials.org/tutorial/view/from_psd_to_html_building_a_set_of_website_designs_step_by_step'>View tutorial</a>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-09112011/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Featured tutorial of the week 05/10/2011</title>
		<link>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-05102011</link>
		<comments>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-05102011#comments</comments>
		<pubDate>Wed, 05 Oct 2011 10:45:10 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Round-Ups]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[lookaheads]]></category>
		<category><![CDATA[lookbehinds]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[tutorial of the week]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1508</guid>
		<description><![CDATA[Each week we feature a new tutorial. This weeks featured tutorial is <strong>How to use Lookaheads and Lookbehinds in your Regular Expressions</strong>]]></description>
			<content:encoded><![CDATA[<div class='roundup_post'>
<h3><a href='http://cmstutorials.org/tutorial/view/how_to_use_lookaheads_and_lookbehinds_in_your_regular_expressions' target='_blank'>How to use Lookaheads and Lookbehinds in your Regular Expressions</a></h3><a href='http://cmstutorials.org/tutorial/view/how_to_use_lookaheads_and_lookbehinds_in_your_regular_expressions' target='_blank'><img class='floatleft' src='http://cmstutorials.org/sources/tutorials/1317722561-tutimage-164.jpg' alt='How to use Lookaheads and Lookbehinds in your Regular Expressions' title='How to use Lookaheads and Lookbehinds in your Regular Expressions' /></a><p>This tutorial will teach you how to use positive &#038; negative lookahead and lookbehinds in your regular expressions.</p>
<a href='http://cmstutorials.org/tutorial/view/how_to_use_lookaheads_and_lookbehinds_in_your_regular_expressions'>View tutorial</a>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-05102011/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Featured tutorial of the week 38/08/2011</title>
		<link>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-38082011</link>
		<comments>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-38082011#comments</comments>
		<pubDate>Thu, 01 Sep 2011 08:00:26 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Round-Ups]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[queries]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1502</guid>
		<description><![CDATA[Each week we feature a new tutorial. This weeks featured tutorial is <strong>Advanced WordPress Queries, Part 1</strong>]]></description>
			<content:encoded><![CDATA[<div class='roundup_post'>
<h3><a href='http://cmstutorials.org/tutorial/view/advanced_wordpress_queries_part_1' target='_blank'>Advanced WordPress Queries, Part 1</a></h3><a href='http://cmstutorials.org/tutorial/view/advanced_wordpress_queries_part_1' target='_blank'><img class='floatleft' src='http://blog.cmstutorials.org/wp-content/uploads/figure_1.png' alt='Advanced WordPress Queries, Part 1' title='Advanced WordPress Queries, Part 1' /></a><p>Throughout this series, we’re going to take a look at the advantages of advanced queries, how we interface with the WordPress database, and how we can retrieve, update, and insert new and existing data.</p>
<a href='http://cmstutorials.org/tutorial/view/advanced_wordpress_queries_part_1'>View tutorial</a>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-38082011/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Featured tutorial of the week 13/08/2011</title>
		<link>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-13082011</link>
		<comments>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-13082011#comments</comments>
		<pubDate>Sat, 13 Aug 2011 08:26:50 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Round-Ups]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1499</guid>
		<description><![CDATA[Each week we feature a new tutorial. This weeks featured tutorial is <strong>A Beginner’s Guide to the WordPress Loop</strong>]]></description>
			<content:encoded><![CDATA[<div class='roundup_post'>
<h3><a href='http://cmstutorials.org/tutorial/view/a_beginner_s_guide_to_the_wordpress_loop' target='_blank'>A Beginner’s Guide to the WordPress Loop</a></h3><a href='http://cmstutorials.org/tutorial/view/a_beginner_s_guide_to_the_wordpress_loop' target='_blank'><img class='floatleft' src='' alt='A Beginner’s Guide to the WordPress Loop' title='A Beginner’s Guide to the WordPress Loop' /></a><p>Today, we’re going to lay a foundation for everyone who’s new to the loop or has ever wanted to know a little bit more about exactly how it works.</p>
<a href='http://cmstutorials.org/tutorial/view/a_beginner_s_guide_to_the_wordpress_loop'>View tutorial</a>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/other/featured-tutorial-of-the-week-13082011/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Featured tutorial of the week 04/08/2011</title>
		<link>http://blog.cmstutorials.org/reviews/general/featured-tutorial-of-the-week-04082011</link>
		<comments>http://blog.cmstutorials.org/reviews/general/featured-tutorial-of-the-week-04082011#comments</comments>
		<pubDate>Fri, 05 Aug 2011 09:00:41 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[uploading]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1491</guid>
		<description><![CDATA[Each week we feature a new tutorial. This weeks featured tutorial is <strong>Uploading Files with AJAX</strong>]]></description>
			<content:encoded><![CDATA[<div class='roundup_post'>
<h3><a href='http://cmstutorials.org/tutorial/view/uploading_files_with_ajax' target='_blank'>Uploading Files with AJAX</a></h3><a href='http://cmstutorials.org/tutorial/view/uploading_files_with_ajax' target='_blank'><img class='floatleft' src='http://blog.cmstutorials.org/wp-content/uploads/form.png' alt='Uploading Files with AJAX' title='Uploading Files with AJAX' /></a><p>Today, I’m going to show you how to do something that—until the last while—has been almost unprecedented: uploading files via AJAX.</p>
<a href='http://cmstutorials.org/tutorial/view/uploading_files_with_ajax'>View tutorial</a>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/reviews/general/featured-tutorial-of-the-week-04082011/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add a color picker in your wp theme using frabtastic</title>
		<link>http://blog.cmstutorials.org/reviews/general/how-to-add-a-color-picker-in-your-wp-theme-using-frabtastic</link>
		<comments>http://blog.cmstutorials.org/reviews/general/how-to-add-a-color-picker-in-your-wp-theme-using-frabtastic#comments</comments>
		<pubDate>Fri, 22 Jul 2011 20:27:32 +0000</pubDate>
		<dc:creator>krike</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[color picker]]></category>
		<category><![CDATA[panel]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.cmstutorials.org/?p=1472</guid>
		<description><![CDATA[In this tutorial I will teach you how to add a color picker in the option page of your wordpress theme using the build in frabtastic library.]]></description>
			<content:encoded><![CDATA[<p>Previously I wrote a tutorial on how to add a color picker to your admin theme page. I therefore choose a specific library which I used to create these color pickers. That was before I actually found that wordpress already includes a javascript library to create color pickers. In this quick tutorial I will teach you how to use it.</p>
<div class="info">You can download the result of this tutorial as a <a href="http://blog.cmstutorials.org/wp-content/uploads/color_picker_twentyten-child.zip">twentyten child theme</a></div>
<h2>A brief word about wp_enqueue_script()</h2>
<p>I actually found this when looking at the <code>wp_enqueue_script();</code> in the wordpress codex. When I scrolled down I saw an entire list of javascript libraries that are already present in wordpress, which you could then easily load using the <code>wp_enqueue_script();</code>. I strongly advice you have a look at <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress">all the libraries you can include</a>. And who knows, just like me, you might find out you are including a javascript or jQuery library that is already present in wordpress.</p>
<h2>Before getting started</h2>
<p>Before we start let&#8217;s add a simple link into the theme menu block in the admin area which links to a page which will contain the color picker. Just add the following code in the <code>functions.php</code> of your theme:</p>
<pre class="brush: php; title: ; notranslate">add_action('admin_menu', 'themeoptions_admin_menu'); //action to display the menu
function themeoptions_admin_menu()
{
add_theme_page('color picker', 'color picker', 'read', 'color_picker_option', 'color_picker_option_page');
}
function color_picker_option_page()
{

}</pre>
<p><code>color_picker_option_page()</code> is the function we specified to show the color pickers.</p>
<h2>Add the color picker</h2>
<p>First of all we need to load the farbtastic javascript library and style. Add the following code to your <code>functions.php</code> of your theme:</p>
<pre class="brush: php; title: ; notranslate">add_action('init', 'load_theme_scripts');
function load_theme_scripts() {
    wp_enqueue_style( 'farbtastic' );
    wp_enqueue_script( 'farbtastic' );
}</pre>
<p>We then add a simple form in our <code>color_picker_option_page()</code> function:</p>
<pre class="brush: php; title: ; notranslate">&lt;form method=&quot;POST&quot; action=&quot;&quot;&gt;
     &lt;input type=&quot;text&quot; id=&quot;color1&quot; value=&quot;&lt;?php echo get_option('color1'); ?&gt;&quot; name=&quot;color_picker_color1&quot; /&gt;
     &lt;div id=&quot;color_picker_color1&quot;&gt;&lt;/div&gt;
     &lt;p&gt;&lt;input type=&quot;submit&quot; name=&quot;update_options&quot; value=&quot;Update Options&quot; /&gt;&lt;/p&gt;
&lt;/form&gt;</pre>
<p>Now all that remains is to call the frabtastic function and specify where the color picker should be loaded and which input field will be used to dynamicly update the color value once you select another color. Add the following code in the <code>color_picker_option_page()</code> :</p>
<pre class="brush: jscript; title: ; notranslate">&lt;script type=&quot;text/javascript&quot;&gt;
        jQuery(document).ready(function($){
            $('#color_picker_color1').farbtastic('#color1');            
        });
    &lt;/script&gt;</pre>
<p>You should now have a working color picker:</p>
<p><img class="alignnone size-full wp-image-1478" title="color_picer_preview" src="http://blog.cmstutorials.org/wp-content/uploads/color_picer_preview.png" alt="" width="422" height="226" /></p>
<h2>Saving the color</h2>
<p>The last thing to do is to store the color value in a wordpress option. At the top of the <code>color_picker_option_page()</code> function add:</p>
<pre class="brush: php; title: ; notranslate">if ( isset($_POST['update_options'])) { color_picker_option_update(); }</pre>
<p>So when the form is submitted the <code>color_picker_option_update()</code> function will be called. So let&#8217;s create that function and save the color value:</p>
<pre class="brush: php; title: ; notranslate">function color_picker_option_update()
{
update_option('color1', esc_html($_POST['color_picker_color1']));
}</pre>
<p>So we get the color value using $_POST and we filter it using <code>esc_html()</code> (always filter submitted data!!) and finally it is saved. Update_option() will create the new option if it doesn&#8217;t exist yet.</p>
<h2>Adding a second color picker</h2>
<p>First of all copy/paste a second row for the second color picker</p>
<pre class="brush: php; title: ; notranslate">&lt;tr valign=&quot;top&quot;&gt;
	&lt;th width=&quot;200px&quot; scope=&quot;row&quot;&gt;Color 2&lt;/th&gt;
	&lt;td&gt;
		&lt;input type=&quot;text&quot; id=&quot;color2&quot; value=&quot;&lt;?php echo get_option('color2'); ?&gt;&quot; name=&quot;color_picker_color2&quot; /&gt;
		&lt;div id=&quot;color_picker_color2&quot;&gt;&lt;/div&gt;
	&lt;/td&gt;
&lt;/tr&gt;</pre>
<p>Add a second call to the farbtastic plugin</p>
<pre class="brush: php; title: ; notranslate">$('#color_picker_color2').farbtastic('#color2');</pre>
<p>Finally save the new color picker value in the update functions using the <code>update_option()</code> function</p>
<pre class="brush: php; title: ; notranslate">update_option('color2', esc_html($_POST['color_picker_color2']));</pre>
<p>The see the final code download the twentyeleven child theme at the top of this article.</p>
<h2>That&#8217;s it!</h2>
<p>So that&#8217;s all there is to do. Pretty easy, no? Much easier and faster than using jPicker which I introduced in my previous tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cmstutorials.org/reviews/general/how-to-add-a-color-picker-in-your-wp-theme-using-frabtastic/feed</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.740 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-13 16:51:54 -->

