
<?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>brandontreb.com &#187; Code</title>
	<atom:link href="http://brandontreb.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://brandontreb.com</link>
	<description>Code, Nerdyness, and Nonsense</description>
	<lastBuildDate>Wed, 07 Jul 2010 00:23:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Feedburner Anywhere Plugin Released</title>
		<link>http://brandontreb.com/feedburner-anywhere-plugin-released/</link>
		<comments>http://brandontreb.com/feedburner-anywhere-plugin-released/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 23:00:49 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[Feedburner]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[subscriber]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=833</guid>
		<description><![CDATA[I have just released another WordPress plugin called Feedburner Anywhere. What it does is allow you to display your RSS subscriber count anywhere on your blog. You have the choice of using the built-in widget, embedding it in your posts/pages, or a combination of both. Check out my sidebar for an example of usage. Download [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;">
<div class="wp-caption aligncenter" style="width: 198px"><a href="http://www.crunchbase.com/company/feedburner"><img title="Image representing FeedBurner as depicted in C..." src="http://www.crunchbase.com/assets/images/resized/0000/3292/3292v1-max-250x250.png" alt="Image representing FeedBurner as depicted in C..." width="188" height="44" /></a><p class="wp-caption-text">Image via CrunchBase</p></div>
</div>
<p>I have just released another WordPress plugin called Feedburner Anywhere.</p>
<p>What it does is allow you to display your RSS subscriber count anywhere on your blog.</p>
<p>You have the choice of using the built-in widget, embedding it in your posts/pages, or a combination of both.</p>
<p>Check out my sidebar for an example of usage.</p>
<p><a href="http://wordpress.org/extend/plugins/feedburner-anywhere/">Download Feedburner Anywhere at WordPress.org</a></p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/a163a219-5486-4b37-b958-bc2e76dc02f2/"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=a163a219-5486-4b37-b958-bc2e76dc02f2" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/feedburner-anywhere-plugin-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HECK YES C Macro, For When Something Is REALLY True</title>
		<link>http://brandontreb.com/heck-yes-c-macro-for-when-something-is-really-true/</link>
		<comments>http://brandontreb.com/heck-yes-c-macro-for-when-something-is-really-true/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 21:01:06 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Nerdyness]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[caffeine]]></category>
		<category><![CDATA[compiler directives]]></category>
		<category><![CDATA[macro]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=828</guid>
		<description><![CDATA[Quite possibly the most useful macro you will ever use. #define HECK_YES true &#38;&#38; true &#160; // Usage if&#40;self.sleepy&#41; &#123; self.needsCoffee = HECK_YES; &#125; Now if only I could replace semi colons with exclamation points&#8230;]]></description>
			<content:encoded><![CDATA[<p>Quite possibly the most useful macro you will ever use.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define HECK_YES true &amp;&amp; true</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Usage</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>self.<span style="color: #202020;">sleepy</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   self.<span style="color: #202020;">needsCoffee</span> <span style="color: #339933;">=</span> HECK_YES<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now if only I could replace semi colons with exclamation points&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/heck-yes-c-macro-for-when-something-is-really-true/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress Coding: Programmatically Add Post Tags (and other meta info)</title>
		<link>http://brandontreb.com/wordpress-coding-programmatically-add-post-tags-and-other-meta-info/</link>
		<comments>http://brandontreb.com/wordpress-coding-programmatically-add-post-tags-and-other-meta-info/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 17:01:45 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[programmatically add tags]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress recipe]]></category>
		<category><![CDATA[wordpress tags]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=812</guid>
		<description><![CDATA[In this tutorial, I will be showing you how to programatically add tags to Wordpress posts.  In addition to tags, I will show you how to update any field for a given post.]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/CategoriesvsTags_833F/561962_price_tag[3].jpg" title="Tags" class="aligncenter" width="600" /><br />
I was recently working on a script that imports from a custom blogging platform into WordPress and had some need to programmatically add post keywords.</p>
<p>The script to do this is actually quite simple and can be used to update any post attribute.</p>
<p>Here is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Create the post array</span>
<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'ID'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'tags_input'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'foo,bar,baz'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
&nbsp;
<span style="color: #666666; font-style: italic;">// Update the post</span>
wp_update_post<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This will assign the keywords &#8220;foo&#8221;, &#8220;bar&#8221;, and &#8220;baz&#8221; to the post with ID 5.  This task seems trivial, however it&#8217;s very powerful when you think about automation.  For example, you could write a script to scrape a google search for your target keyword and find related keywords for each of your posts automatically.  Hrm&#8230; plugin idea?</p>
<p>Give it a shot.  More info on available parameters can be found on <a href="http://codex.wordpress.org/Function_Reference/wp_insert_post">WordPress&#8217; site here</a></p>
<p>Here are some of the other fields that you are able to update this way:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">defaults <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'post_status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'draft'</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'post_author'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$user_ID</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'ping_status'</span> <span style="color: #339933;">=&gt;</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'default_ping_status'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'post_parent'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'menu_order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'to_ping'</span> <span style="color: #339933;">=&gt;</span>  <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'pinged'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'post_password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'guid'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'post_content_filtered'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'post_excerpt'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'import_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Happy WPCoding!</p>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/wordpress-coding-programmatically-add-post-tags-and-other-meta-info/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress Programming Tip: Enable Database Error Reporting For Custom Queries</title>
		<link>http://brandontreb.com/wordpress-programming-tip-enable-database-error-reporting-for-custom-queries/</link>
		<comments>http://brandontreb.com/wordpress-programming-tip-enable-database-error-reporting-for-custom-queries/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 00:00:08 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[error_reporting]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=800</guid>
		<description><![CDATA[In this brief tutorial, I will show you how to enable error reporting when testing your own custom Wordpress database queries.  By default, Wordpress has error reporting disabled so that your visitors will never see raw SQL errors.  We will be enabling this reporting on a per-query basis allow you to test out your custom MySQL queries.]]></description>
			<content:encoded><![CDATA[<p>So this one should seem pretty obvious, but it wasn&#8217;t apparent to me at first. &nbsp;It was only after digging through the wp-db.php file that I discovered how to enable error reporting.</p>
<h4>The Problem</h4>
<p>As you may have discovered, the wp_query() function isn&#8217;t a &#8220;one size fit&#8217;s all&#8221; solution. &nbsp;Often times, you may need to query the WordPress database using a custom MySQL query. &nbsp;Especially &nbsp;if you are using WordPress for anything other than a blog (ie <a href="http://freshapps.com">freshapps.com</a>).</p>
<p>When writing custom queries, it can often be frustrating if you make a mistake in the SQL syntax as WordPress will simply display no results. &nbsp;For example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span> 
   WHERE post_title = 'foo bar baz&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Outputs Array ( )</span></pre></div></div>

<p>Since we have made an error in our SQL statement (I didn&#8217;t add the second single quote), WordPress will suppress it and simply return an empty array. This is not very helpful for debugging.</p>
<h4>The Solution</h4>
<p>The solution is actually quite simple.  The global $wpdb object has a property called show_errors.  Setting this property to true will cause WordPress to output the SQL errors to the screen for a given query.</p>
<p>Here it is with our example above</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Enables Wordpress's DB Error reporting</span>
<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">show_errors</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span> 
   WHERE post_title = 'foo bar baz&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Outputs </span>
<span style="color: #666666; font-style: italic;">// WordPress database error: [You have an error in your </span>
<span style="color: #666666; font-style: italic;">// SQL syntax; check the manual that corresponds to your </span>
<span style="color: #666666; font-style: italic;">// MySQL server version for the right syntax to use near </span>
<span style="color: #666666; font-style: italic;">// ''foo bar baz' at line 1]</span>
<span style="color: #666666; font-style: italic;">// SELECT * FROM wp_posts WHERE post_title = 'foo bar baz</span></pre></div></div>

<p>Now we know what went wrong with our query rather than just receiving empty results.</p>
<p>Let me know if you have any questions or comments.</p>
<p>Happy WPCoding!</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/a1d99446-c73f-4722-97e6-3e584300069e/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=a1d99446-c73f-4722-97e6-3e584300069e" alt="Reblog this post [with Zemanta]" style="border:none;float:right"></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/wordpress-programming-tip-enable-database-error-reporting-for-custom-queries/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress Plugin Development: Your First Plugin</title>
		<link>http://brandontreb.com/wordpress-plugin-development-your-first-plugin/</link>
		<comments>http://brandontreb.com/wordpress-plugin-development-your-first-plugin/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 00:30:33 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress filters]]></category>
		<category><![CDATA[wordpress plugin]]></category>
		<category><![CDATA[wordpress plugin programming]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=778</guid>
		<description><![CDATA[<p>In this tutorial, I will show you the basics of creating a simple Wordpress plugin.  After completing it, you will have the knowledge to expand upon it and create your own Wordpress plugins.</p>


]]></description>
			<content:encoded><![CDATA[<h4>Introduction</h4>
<p>Creating plugins for WordPress seems like a daunting task at first, but the process is actually quite simple.  WordPress&#8217; APIs are very elegant and make plugin development a breeze.</p>
<p>The documentation for writing a plugin can be found <a href="http://codex.wordpress.org/Writing_a_Plugin">here</a>.  Make sure you bookmark it as you will be referring to the documentation quite a bit as you require more functionality.</p>
<h4>WordPress Actions And Filters</h4>
<p>When we talk about creating a plugin for WordPress, it usually refers to extending the functionality.  This could be something as simple as replacing all of the colon-parens with smilies or as complex as doing complete SEO optimization.  Whatever you want to create, chances are you will have to hook into a WordPress Action or Filter.</p>
<p>WordPress Filters are called any time there is data. They are essentially a chain of functions that will be called in order to work on the data in some way.  For example, when WordPress displays the content of your post, rather than it saying &lt;?php echo $content; ?&gt;, it calls the function &lt;?php the_content(); ?&gt;.  Calling this function will invoke the chain of functions to be applied to the content.</p>
<p>To hook a function into this chain, you will use the add_filter function of WordPress.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'myFunc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> myFunc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;">// Do Something to the content</span>
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In the code above our function called myFunc will be called every time the content is displayed in a WordPress post.  I will be explaining the is more detail later in this post.</p>
<p>With the knowlege of actions and filters behind you, you are ready to write your first plugin.</p>
<h4>Setting Up</h4>
<p>The plugin we will be creating is a Word Filter plugin. It could be useful on a blog with multiple authors as a swear word filter.  We will be replace all of the &#8220;naughty words&#8221;, which we define with a substitue.</p>
<p>The first thing you want to do is FTP into your Worpdress site and create the plugin folder.  The location of the folder should be as follows.</p>
<p><strong>/wp-content/plugins/word_filter</strong></p>
<p>Note that any time you create a plugin, it must go inside of the WordPress plugins folder.</p>
<p>Now create a file of the same name in this folder (word_filter.php). This will be the file that will hold all of our plugin code.  Just to reiterate, you should now have a file at this path:</p>
<p><strong>/wp-content/plugins/word_filter/word_filter.php</strong></p>
<p>Now we are ready to begin editing the file&#8230;</p>
<h4>Adding the Meta Information</h4>
<p>In order to identify your plugin (and give you credit for it), you must add the following information to the top of your plugin file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
Plugin Name: Word Filter
Plugin URI: http://brandontreb.com/
Description: This plugin filters out certain words in a post.  Could be used as a swear word filter or just a global find and replace.
Version: 1.0
Author: Brandon Trebitowski
Author URI: http://brandontreb.com
*/</span></pre></div></div>

<p>All of this meta information will be used to identify the plugin.  When the user goes to activate it, all of this info will be displayed in their admin panel.  It will look something like this:</p>
<p><a href="http://brandontreb.com/wp-content/uploads/2010/03/Screen-shot-2010-03-10-at-9.46.09-AM.png"><img src="http://brandontreb.com/wp-content/uploads/2010/03/Screen-shot-2010-03-10-at-9.46.09-AM-500x31.png" alt="" title="Screen shot 2010-03-10 at 9.46.09 AM" width="500" height="31" class="alignleft size-medium wp-image-790" /></a></p>
<p>Coding time&#8230;</p>
<h4>Writing the Code</h4>
<p>The first bit of code for our word filter is the array of words to be replaced.  We will be using associative arrays where the key will be the words we are searching for and the values will be their replacements.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Array of replacements</span>
<span style="color: #000088;">$search_array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'idiot'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'nice person'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'shutup'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'please be quite'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hate'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'love'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As you can see, the word &#8216;idiot&#8217; will be replaced with the words &#8216;nice person&#8217;, etc&#8230;  You could do any amount of replacement here.</p>
<p>The next step is to write our function that will do the replacing.  We will call this function word_filter.  One thing you need to be aware of is the function must take exactly one argument.  This is because we will be hooking into the the_content filter of WordPress.  When our function gets called by the system, it will pass in the post content for every post that gets displayed. Here is what the function will look like.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> word_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$search_array</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Modify the content</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$search_array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$find</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$replace</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$find</span><span style="color: #339933;">,</span><span style="color: #000088;">$replace</span><span style="color: #339933;">,</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Return the content</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Pretty simple ehh? We loop over the $search_array and retrieve its keys and values.  We then substitue the $find string with the $replace string in the post $content.  Finally, we RETURN THE CONTENT.  I emphasized that because it is very important.  Since you are running this function in a chain of others, you must return the content so that the next function can process it.  If you don&#8217;t the chain is broken and your posts won&#8217;t contain any content.</p>
<p>The last thing that must be done is we must hook into the the_content filter of WordPress.  Again, this is how we get our function added to the chain.  To do this, simply add the following line.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Make sure our fn gets called before displaying the content</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'word_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is just one of the many <a href="http://codex.wordpress.org/Plugin_API">Filters</a> that you are able to hook in to.</p>
<h4>Putting it all together</h4>
<p>When reading tutorial, I generally like to see the final source code in once place.  So, here it is in all of it&#8217;s (very simple) glory.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
Plugin Name: Word Filter
Plugin URI: http://brandontreb.com/
Description: This plugin filters out certain words in a post.  Could be used as a swear word filter or just a global find and replace.
Version: 1.0
Author: Brandon Trebitowski
Author URI: http://brandontreb.com
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Array of replacements</span>
<span style="color: #000088;">$search_array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'idiot'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'nice person'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'shutup'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'please be quite'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hate'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'love'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Make sure our fn gets called before displaying the content</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'word_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> word_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$search_array</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Modify the content</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$search_array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$find</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$replace</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$find</span><span style="color: #339933;">,</span><span style="color: #000088;">$replace</span><span style="color: #339933;">,</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Return the content</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>*Note: I omitted the php wrapper tags because they were causing problems in the output. Make sure you add them back in.</p>
<p>There you have it! Your first WordPress plugin.  In a later tutorial I will show you how to create an admin panel that will allow users to configure all of the search and replace words.</p>
<p>If you have any comments or questions, feel free to leave them in the comments section of this post.</p>
<p>You may also download the source for this example <a href='http://brandontreb.com/wp-content/uploads/2010/03/word_filter.zip'>here</a>.</p>
<p>Happy WPCoding!</p>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/wordpress-plugin-development-your-first-plugin/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Programming Tip Of The Day #2 &#8211; Difference Between i++ and ++i</title>
		<link>http://brandontreb.com/programming-tip-of-the-day-2-difference-between-i-and-i/</link>
		<comments>http://brandontreb.com/programming-tip-of-the-day-2-difference-between-i-and-i/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 01:00:20 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Programming Tip Of The Day]]></category>
		<category><![CDATA[decremental operator]]></category>
		<category><![CDATA[i++]]></category>
		<category><![CDATA[incremental operator]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=677</guid>
		<description><![CDATA[Ok, so this should seem obvious and if I am insulting your intelligence by stating it, I am sorry.  One of the main reasons I want to discuss this is, I was asked this exact question in a job interview for Lockheed Martin.]]></description>
			<content:encoded><![CDATA[<p>To some, this should seem a bit obvious and if I am insulting your intelligence by discussing it, I am sorry.  But, one of the main reasons I want to discuss this topic is, I was asked this question in a job interview for Lockheed Martin.</p>
<p><b>What is the difference between i++ and ++i?</b></p>
<p>The answer is actually quite simple.</p>
<h3><span style="color: #00ccff;">i++</span> first evaluates the value of i and then increments it</h3>
<h3><span style="color: #00ccff;">++i</span> increments the value of i and then evaluates it</h3>
<p>Here is a brief example to demonstrate what I mean.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Example: i++ </span>
<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;The value of i is &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span> <span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Output &quot;The value of i is 5&quot;</span>
<span style="color: #666666; font-style: italic;">// i = 6</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Example: ++i </span>
<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;The value of i is &quot;</span> <span style="color: #339933;">.</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Output &quot;The value of i is 6&quot;</span>
<span style="color: #666666; font-style: italic;">// i = 6</span></pre></div></div>

<p>So, now if you are ever asked about this in an interview, you will have a response.</p>
<p>Happy programming!</p>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/programming-tip-of-the-day-2-difference-between-i-and-i/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Programming Tip Of The Day #1 &#8211; Ternary Operator</title>
		<link>http://brandontreb.com/programming-tip-of-the-day-1-ternary-operator/</link>
		<comments>http://brandontreb.com/programming-tip-of-the-day-1-ternary-operator/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 00:30:48 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Programming Tip Of The Day]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[programming tip of the day]]></category>
		<category><![CDATA[programming tips]]></category>
		<category><![CDATA[ptotd]]></category>
		<category><![CDATA[ternary]]></category>
		<category><![CDATA[ternary operator]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=667</guid>
		<description><![CDATA[<p>So, I though I'd start this series called Programming Tip Of The Day to write about useful things I come across in programming.  Both to educate my readers and as a personal archive of ideas and tips.</p>

<p>I will kick it off today with a quick rant about the <strong>ternary operator</strong>.  I &#60;3 the ternary operator.  It's quick, efficient and saves a lot of ugly code.</p>]]></description>
			<content:encoded><![CDATA[<p>So, I though I&#8217;d start this series called Programming Tip Of The Day to write about useful things I come across in programming.  Both to educate my readers and as a personal archive of ideas and tips.</p>
<p>I will kick it off today with a quick rant about the <strong>ternary operator</strong>.  I &lt;3 the ternary operator.  It&#8217;s quick, efficient and saves a lot of ugly code.</p>
<p>For those of you who don&#8217;t know, the ternary operator is made up of 3 elements: The condition and two results.  It is of the form:</p>
<h2>(condition) ? (result if true) : (result if false);</h2>
<p>This is much nicer than an if statement.  So here is a brief example about how a ternary operator can replace an if-statement.</p>
<h3>if-statement</h3>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>isSnowing<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	iMustBe <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;cold&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	iMustBe <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;warm&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Same thing using ternary</h3>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">iMustBe <span style="color: #339933;">=</span> isSnowing <span style="color: #339933;">?</span> <span style="color: #ff0000;">&quot;cold&quot;</span> <span style="color: #339933;">:</span> <span style="color: #ff0000;">&quot;warm&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>That is so much easier to read (IMHO).  You can even do clever things in printing.  Here is a small example in PHP for using the ternary operator when doing an echo.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;I am a &quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>height <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">72</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;tall&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;short&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; person!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Most languages support the ternary operator.  Check out <a href="http://en.wikipedia.org/wiki/Ternary_operation">this wiki page</a> if you want more info.</p>
<p>Happy programming!</p>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/programming-tip-of-the-day-1-ternary-operator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Increase Your Twitter Following Using Your WordPress Blog</title>
		<link>http://brandontreb.com/increase-your-twitter-following-using-your-wordpress-blog/</link>
		<comments>http://brandontreb.com/increase-your-twitter-following-using-your-wordpress-blog/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 15:00:57 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Nerdyness]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[followers]]></category>
		<category><![CDATA[popular]]></category>
		<category><![CDATA[twitlebrity]]></category>
		<category><![CDATA[twitpop]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=655</guid>
		<description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; font-size: 13px; padding: 0px;"><a href="http://brandontreb.com/wp-content/uploads/2009/11/twitter64.png"><img class="size-full wp-image-656 alignnone" title="twitter_bird" src="http://brandontreb.com/wp-content/uploads/2009/11/twitter64.png" alt="twitter_bird" width="562" height="352" /></a></p>
TwitPop is a Wordpress plugin I wrote with one goal...To make you more popular on Twitter. There are sites that spring up from time to time claiming to get you more followers on Twitter if you follow X amount of people on the follow train. Well, now you can create your own Twitter train on your wordpress blog and really get more followers.]]></description>
			<content:encoded><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; font-size: 13px; padding: 0px;"><a href="http://brandontreb.com/wp-content/uploads/2009/11/twitter64.png"><img class="size-full wp-image-656 alignnone" title="twitter_bird" src="http://brandontreb.com/wp-content/uploads/2009/11/twitter64.png" alt="twitter_bird" width="562" height="352" /></a></p>
<p><a href="http://downloads.wordpress.org/plugin/twitpop.zip">Download TwitPop Now</a></p>
<p>TwitPop is a WordPress plugin I wrote with one goal&#8230;To make you more popular on Twitter. There are sites that spring up from time to time claiming to get you more followers on Twitter if you follow X amount of people on the follow train. Well, now you can create your own Twitter train on your wordpress blog and really get more followers.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; font-size: 13px; padding: 0px;">The best part is, you add your username in the admin panel and EVERYONE FOLLOWS YOU! Think of the possibilities&#8230; You could be a Twitlebrity.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; font-size: 13px; padding: 0px;">To add to the excitement, everyone that uses your TwitPop plugin will Tweet a link back to your blog. This promotes your blog as well as your Twitter account. Check out how TwitPop works below.</p>
<p><strong>Instructions</strong></p>
<p>Log in to your Twitter account below.  You will automatically follow the people that have visited this page before you (no more than 20).</p>
<p>Then, your Twitter username will be added to the list and you will be followed by the next 20 people to use this plugin.</p>
<p><a name="twitpop">&nbsp;</a>
		<div id="twitpop">
		<fieldset class="message success" style="display:none;">
			<img src="http://brandontreb.com/wp-content/plugins/twitpop/images/success-icon.png" width="50" height="50">
			<p></p>
		</fieldset>
		<fieldset class="message error" style="display:none;">
			<img src="http://brandontreb.com/wp-content/plugins/twitpop/images/warning-icon.png" width="50" height="50">
			<p></p>
		</fieldset>
		<fieldset class="login">
			<legend>Twitter Login Information</legend>
			<form name="twitpop_form" id="twitpop_form" method="POST" action="#twitpop">
			<div>
				<label for="username">Twitter Username:</label> <input type="text" id="username" name="twitpop_username">
			</div>
			<div>
				<label for="password">Twttier Password:</label> <input type="password" id="password" name="twitpop_password">
			</div>
			<div><label for="password">&nbsp;</label><a href="#" onClick="document.twitpop_form.submit();return false;" class="btn blue"><i></i><span><span></span><i></i>Submit</span></a></div><br />
			</form>
			<p id="powered">Powered by <a href="http://brandontreb.com/twitpop">TwitPop</a></p>
		</fieldset>
	</div>
	</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; font-size: 13px; padding: 0px;"><a href="http://downloads.wordpress.org/plugin/twitpop.zip">Download TwitPop Now</a></p>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/increase-your-twitter-following-using-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Class To Interface With Many URL Shortening Services</title>
		<link>http://brandontreb.com/php-class-to-interface-with-many-url-shortening-services/</link>
		<comments>http://brandontreb.com/php-class-to-interface-with-many-url-shortening-services/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 01:30:35 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[j.mp api]]></category>
		<category><![CDATA[php class]]></category>
		<category><![CDATA[php url shortener class]]></category>
		<category><![CDATA[tr.im api]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=630</guid>
		<description><![CDATA[With the explosion of Twitter and such services, the need to have long URLs shortened has drastically increased.  Naturally, many services to shorten URLs have sprung up as well.

Recently, I had to write a PHP class to work with URL shorteners.  So, I made it support multiple shortening services and have decided to share it with you.j,]]></description>
			<content:encoded><![CDATA[<p>With the explosion of Twitter and such services, the need to have long URLs shortened has drastically increased.  Naturally, many services to shorten URLs have sprung up as well.</p>
<p>Most of these services (that are worth using), have some sort of API that will allow developers to send a long URL to them, have it shortened and then returned.  This type of service allows other developers to write applications that have the ability to shorten URLs right inside of them.</p>
<p>Recently, I had to write a PHP class to work with URL shorteners.  So, I made it support multiple shortening services and have decided to share it with you.</p>
<p>The class is called <a href="http://brandontreb.com/wp-content/uploads/2009/11/URLShortener.class.php_1.zip">URLShortener.class.php</a> and it supports the following shortening services:</p>
<ul>
<li>j.mp (bit.ly)</li>
<li>tr.im</li>
<li>TinyURL</li>
<li>is.gd</li>
<li>u.nu</li>
<li>Linkyy</li>
<li>Your own custom shortening service</li>
</ul>
<p>Here are some examples of how to use the class in your own applications:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	 <span style="color: #666666; font-style: italic;">/* Basic: */</span>
	 <span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> URLShortener<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tr.im'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">shorten</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://brandontreb.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	 <span style="color: #666666; font-style: italic;">/* Using API Key and Login */</span>
	 <span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> URLShortener<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'j.mp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 <span style="color: #000088;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">login</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'brandontreb'</span><span style="color: #339933;">;</span>
	 <span style="color: #000088;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">APIKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'R_2a413ebd15254a72b500ec2ce83f982d'</span><span style="color: #339933;">;</span>
	 <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">shorten</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://brandontreb.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	 <span style="color: #666666; font-style: italic;">/* Custom URL */</span>
	 <span style="color: #666666; font-style: italic;">// Just make sure you put %s and it will be </span>
	 <span style="color: #666666; font-style: italic;">// replaced with the long URL</span>
	 <span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> URLShortener<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'custom'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'http://b1t.me/api/shorten.xml/%s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">shorten</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://brandontreb.com&quot;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You may download my URLShortener PHP class <a href="http://brandontreb.com/wp-content/uploads/2009/11/URLShortener.class.php_1.zip">here</a>.  </p>
<p>Feel free to leave any questions or comments in the comments section.  </p>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/php-class-to-interface-with-many-url-shortening-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>$13 Dollar Discount On Programming Books From Manning Publishing</title>
		<link>http://brandontreb.com/13-dollar-discount-on-programming-books-from-manning-publishing/</link>
		<comments>http://brandontreb.com/13-dollar-discount-on-programming-books-from-manning-publishing/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 16:59:46 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Nerdyness]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[discounts]]></category>
		<category><![CDATA[freebies]]></category>
		<category><![CDATA[programming books]]></category>

		<guid isPermaLink="false">http://brandontreb.com/?p=614</guid>
		<description><![CDATA[<p style="text-align: center;"><a href="http://brandontreb.com/13-dollar-discount-on-programming-books-from-manning-publishing"><img class="size-full wp-image-617 aligncenter" title="manning-logo" src="http://brandontreb.com/wp-content/uploads/2009/11/manning-logo.png" alt="manning-logo" width="500" height="66" /></a></p>

The publishing that I'm writing the book for is having a huge Friday the 13th sale.  They are offering a $13 discount on all of their books.  For those of you who don't know, Manning publishes all of the "In Action" books.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://manning.com"><img class="size-full wp-image-617 aligncenter" title="manning-logo" src="http://brandontreb.com/wp-content/uploads/2009/11/manning-logo.png" alt="manning-logo" width="500" height="66" /></a></p>
<p>The publishing that I&#8217;m writing the book for is having a huge Friday the 13th sale.  They are offering a $13 discount on all of their books.  For those of you who don&#8217;t know, Manning publishes all of the &#8220;In Action&#8221; books.</p>
<p>All you have to do is <a href="http://manning.com">go to the site</a> and enter the coupon code:</p>
<h2>fri13</h2>
<p>when checking out and you will get the discount.  Although my book iPhone In Action 2nd Edition hasn&#8217;t been released yet, Manning has some other killer programming books for sale.</p>
<p>So be sure to <a href="http://manning.com">check it out</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://brandontreb.com/13-dollar-discount-on-programming-books-from-manning-publishing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
