<?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>Shoultes.net &#187; PHP Developer News</title>
	<atom:link href="http://shoultes.net/category/php-developer-news/feed/" rel="self" type="application/rss+xml" />
	<link>http://shoultes.net</link>
	<description>Seth Shoultes PHP Website</description>
	<lastBuildDate>Tue, 31 Aug 2010 05:58:22 +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>Would you download a pirated premium plugin or theme?</title>
		<link>http://shoultes.net/download-pirated-premium-plugin-theme/</link>
		<comments>http://shoultes.net/download-pirated-premium-plugin-theme/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 18:24:11 +0000</pubDate>
		<dc:creator>Seth</dc:creator>
				<category><![CDATA[My Plugins]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Developer News]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[Website Security]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://shoultes.net/?p=2012</guid>
		<description><![CDATA[Beware of &#8220;pirated&#8221; premium plugins and themes that may add malicious scripts and open back doors into your server and/or your WordPress installations. Apparently several people have had the misfortune of downloading a pirated version of my Advanced Events Registration plugin from some file sharing websites. One person&#8217;s site was entirely overwritten with spam posts [...]]]></description>
			<content:encoded><![CDATA[<p>Beware of &#8220;pirated&#8221; premium plugins and themes that may <a href="http://shoultes.net/wordpresswebsite-security-exploits/">add malicious scripts and open back doors</a> into your server and/or your WordPress installations.</p>
<p>Apparently several people have had the misfortune of downloading a pirated version of my Advanced Events Registration plugin from some file sharing websites. One person&#8217;s site was entirely overwritten with spam posts and links pirated software. While another persons entire website was completely wiped out.</p>
<p>The website owner (whom I wont mention here) actually threatened to sue me because five years worth of content was completely removed from their blog. When I asked for a copy of their receipt from the purchase of the premium plugin. The person stated they had downloaded it from a free file hosting website. Can you believe it! So I stated the obvious, &#8220;You didn&#8217;t purchase the plugin from my website, so you will need to contact whomever you received the files from. I am not responsible for code that may be distributed by outside sources.&#8221;</p>
<p><strong>Moral of the story:</strong></p>
<p>Premium plugins and themes may be <a href="http://ma.tt/2010/07/theme-are-gpl-too/" target="_blank">GPL licensed</a> (or<a href="http://www.andrewnacin.com/2010/07/15/thesis-gpl/" target="_blank"> not in some cases</a>.) Unless you get them from a trusted source, you may be taking a major risk using them.</p>
<p><strong>Related information:</strong></p>
<p><a href="http://www.studiopress.com/wordpress-tips/how-downloading-a-premium-themeplugin-from-the-wrong-place-can-ruin-your-site.htm" target="_blank">How Downloading a Premium Theme/Plugin  From the Wrong Place Can Ruin Your Site</a></p>
<p><a href="http://www.der-prinz.com/premium-theme-wrong-place-expensive-1069" target="_blank">Downloading a Premium Theme from the Wrong Site can be Expensive</a></p>
<p><a href="http://www.shoutmeloud.com/download-free-premium-wordpress-theme-whats-the-catch.html" target="_blank">Download Free Premium WordPress theme :What’s  the Catch?</a></p>
<p><a href="http://stuartduff.com/wordpress-premium-developer-and-author-piracy-my-thoughts-24122009/" target="_blank">WordPress Premium  Developer and Author Piracy My Thoughts</a></p>
<p><a href="http://themeshaper.com/the-ethics-of-premium-wordpress-themes/" target="_blank">The Ethics of WordPress Themes at a Premium</a></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Would+you+download+a+pirated+premium+plugin+or+theme%3F+-+http://bit.ly/cjjJHt&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;t=Would+you+download+a+pirated+premium+plugin+or+theme%3F" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;title=Would+you+download+a+pirated+premium+plugin+or+theme%3F" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;title=Would+you+download+a+pirated+premium+plugin+or+theme%3F" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;title=Would+you+download+a+pirated+premium+plugin+or+theme%3F" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;title=Would+you+download+a+pirated+premium+plugin+or+theme%3F" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Would+you+download+a+pirated+premium+plugin+or+theme%3F&amp;body=Link: http://shoultes.net/download-pirated-premium-plugin-theme/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Beware%20of%20%22pirated%22%20premium%20plugins%20and%20themes%20that%20may%20add%20malicious%20scripts%20and%20open%20back%20doors%20into%20your%20server%20and%2For%20your%20WordPress%20installations.%0D%0A%0D%0AApparently%20several%20people%20have%20had%20the%20misfortune%20of%20downloading%20a%20pirated%20version%20of%20my%20Advanced%20Events%20Registration%20plugin%20from%20some%20file%20shari" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;title=Would+you+download+a+pirated+premium+plugin+or+theme%3F" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;n=Would+you+download+a+pirated+premium+plugin+or+theme%3F&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://shoultes.net/download-pirated-premium-plugin-theme/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;title=Would+you+download+a+pirated+premium+plugin+or+theme%3F&amp;description=Beware%20of%20%22pirated%22%20premium%20plugins%20and%20themes%20that%20may%20add%20malicious%20scripts%20and%20open%20back%20doors%20into%20your%20server%20and%2For%20your%20WordPress%20installations.%0D%0A%0D%0AApparently%20several%20people%20have%20had%20the%20misfortune%20of%20downloading%20a%20pirated%20version%20of%20my%20Advanced%20Events%20Registration%20plugin%20from%20some%20file%20shari" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;title=Would+you+download+a+pirated+premium+plugin+or+theme%3F&amp;srcUrl=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;srcTitle=Would+you+download+a+pirated+premium+plugin+or+theme%3F&amp;snippet=Beware%20of%20%22pirated%22%20premium%20plugins%20and%20themes%20that%20may%20add%20malicious%20scripts%20and%20open%20back%20doors%20into%20your%20server%20and%2For%20your%20WordPress%20installations.%0D%0A%0D%0AApparently%20several%20people%20have%20had%20the%20misfortune%20of%20downloading%20a%20pirated%20version%20of%20my%20Advanced%20Events%20Registration%20plugin%20from%20some%20file%20shari" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;title=Would+you+download+a+pirated+premium+plugin+or+theme%3F&amp;summary=Beware%20of%20%22pirated%22%20premium%20plugins%20and%20themes%20that%20may%20add%20malicious%20scripts%20and%20open%20back%20doors%20into%20your%20server%20and%2For%20your%20WordPress%20installations.%0D%0A%0D%0AApparently%20several%20people%20have%20had%20the%20misfortune%20of%20downloading%20a%20pirated%20version%20of%20my%20Advanced%20Events%20Registration%20plugin%20from%20some%20file%20shari&amp;source=Shoultes.net" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22Would%20you%20download%20a%20pirated%20premium%20plugin%20or%20theme%3F%22&amp;body=Link: http://shoultes.net/download-pirated-premium-plugin-theme/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Beware%20of%20%22pirated%22%20premium%20plugins%20and%20themes%20that%20may%20add%20malicious%20scripts%20and%20open%20back%20doors%20into%20your%20server%20and%2For%20your%20WordPress%20installations.%0D%0A%0D%0AApparently%20several%20people%20have%20had%20the%20misfortune%20of%20downloading%20a%20pirated%20version%20of%20my%20Advanced%20Events%20Registration%20plugin%20from%20some%20file%20shari" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://shoultes.net/download-pirated-premium-plugin-theme/" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://shoultes.net/download-pirated-premium-plugin-theme/&amp;submitHeadline=Would+you+download+a+pirated+premium+plugin+or+theme%3F&amp;submitSummary=Beware%20of%20%22pirated%22%20premium%20plugins%20and%20themes%20that%20may%20add%20malicious%20scripts%20and%20open%20back%20doors%20into%20your%20server%20and%2For%20your%20WordPress%20installations.%0D%0A%0D%0AApparently%20several%20people%20have%20had%20the%20misfortune%20of%20downloading%20a%20pirated%20version%20of%20my%20Advanced%20Events%20Registration%20plugin%20from%20some%20file%20shari&amp;submitCategory=business&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=Would+you+download+a+pirated+premium+plugin+or+theme%3F&amp;body=Link: http://shoultes.net/download-pirated-premium-plugin-theme/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Beware%20of%20%22pirated%22%20premium%20plugins%20and%20themes%20that%20may%20add%20malicious%20scripts%20and%20open%20back%20doors%20into%20your%20server%20and%2For%20your%20WordPress%20installations.%0D%0A%0D%0AApparently%20several%20people%20have%20had%20the%20misfortune%20of%20downloading%20a%20pirated%20version%20of%20my%20Advanced%20Events%20Registration%20plugin%20from%20some%20file%20shari" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://shoultes.net/download-pirated-premium-plugin-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function for Creating Tables with WordPress Plugins</title>
		<link>http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/</link>
		<comments>http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 07:41:23 +0000</pubDate>
		<dc:creator>Seth</dc:creator>
				<category><![CDATA[My Plugins]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP Code Samples]]></category>
		<category><![CDATA[PHP Developer News]]></category>
		<category><![CDATA[PHP Everywhere]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress Plugins]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[dbDelta]]></category>
		<category><![CDATA[installing tables]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://shoultes.net/?p=1807</guid>
		<description><![CDATA[Here is a very useful function I have written to install/update the database tables in your custom WordPress plugin. Basically I have used the examples given on the &#8220;Creating Tables with Plugins&#8221; page at WordPress.org. In your main plugin file (ex. my_plugin.php) I define my plugin version: define&#40;&#34;MY_PLUGIN_VERSION&#34;, &#34;2.16&#34; &#41;; //Declare the plugin version. This [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a very useful function I have written to install/update the database tables in your custom WordPress plugin. Basically I have used the <a href="http://codex.wordpress.org/Creating_Tables_with_Plugins">examples</a> given on the &#8220;<a href="http://codex.wordpress.org/Creating_Tables_with_Plugins">Creating Tables with Plugins</a>&#8221; page at <a href="http://wordpress.org/">WordPress.org</a>.</p>
<p>In your main plugin file (ex. my_plugin.php) I define my plugin version:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MY_PLUGIN_VERSION&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;2.16&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Declare the plugin version. This way we know the tables are always up to date. I usually declare this in my main plugin file.</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;includes/functions.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;includes/database_install.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
register_activation_hook<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'my_plugin_data_tables_install'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Then in my functions.php file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> my_plugin_run_install <span style="color: #009900;">&#40;</span><span style="color: #000088;">$table_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table_version</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sql</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;">$wpdb</span><span style="color: #339933;">;</span>
		   <span style="color: #000088;">$wp_table_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>prefix <span style="color: #339933;">.</span> <span style="color: #000088;">$table_name</span><span style="color: #339933;">;</span>
		   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLES LIKE '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$table_name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$sql_create_table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CREATE TABLE &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_table_name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; ( &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$sql</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; ) ;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wp-admin/includes/upgrade.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				dbDelta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql_create_table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//create option for table version</span>
				<span style="color: #000088;">$option_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$table_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_tbl_version'</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$newvalue</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$table_version</span><span style="color: #339933;">;</span>
				  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$option_name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					    update_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$option_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newvalue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
					    <span style="color: #000088;">$deprecated</span><span style="color: #339933;">=</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
					    <span style="color: #000088;">$autoload</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'no'</span><span style="color: #339933;">;</span>
					    add_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$option_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newvalue</span><span style="color: #339933;">,</span> <span style="color: #000088;">$deprecated</span><span style="color: #339933;">,</span> <span style="color: #000088;">$autoload</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				  <span style="color: #009900;">&#125;</span>
			<span style="color: #666666; font-style: italic;">//create option for table name</span>
				<span style="color: #000088;">$option_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$table_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_tbl'</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$newvalue</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_table_name</span><span style="color: #339933;">;</span>
				  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$option_name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					    update_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$option_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newvalue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
					    <span style="color: #000088;">$deprecated</span><span style="color: #339933;">=</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
					    <span style="color: #000088;">$autoload</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'no'</span><span style="color: #339933;">;</span>
					    add_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$option_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newvalue</span><span style="color: #339933;">,</span> <span style="color: #000088;">$deprecated</span><span style="color: #339933;">,</span> <span style="color: #000088;">$autoload</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				  <span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Code here with new database upgrade info/table Must change version number to work.</span>
	<span style="color: #000088;">$installed_ver</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$table_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_tbl_version'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	     <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$installed_ver</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$table_version</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		  <span style="color: #000088;">$sql_create_table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CREATE TABLE &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_table_name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; ( &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$sql</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; ) ;&quot;</span><span style="color: #339933;">;</span>
	      <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wp-admin/includes/upgrade.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	      dbDelta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql_create_table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	      update_option<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$table_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_tbl_version'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table_version</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	      <span style="color: #009900;">&#125;</span>
	    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Using the function is quite simple and can save a few lines of code. especially if you need to install several new tables.</p>
<p>Here is an example of database_install.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> my_plugin_data_tables_install <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$table_version</span> <span style="color: #339933;">=</span> MY_PLUGIN_VERSION<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Call the plugin version.</span>
<span style="color: #666666; font-style: italic;">//Install the first table</span>
<span style="color: #000088;">$table_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;my_first_plugin_tbl&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;id mediumint(9) NOT NULL AUTO_INCREMENT,
	  time bigint(11) DEFAULT '0' NOT NULL,
	  name tinytext NOT NULL,
	  text text NOT NULL,
	  url VARCHAR(100) NOT NULL,
	  UNIQUE KEY id (id)&quot;</span><span style="color: #339933;">;</span>
my_plugin_run_install  <span style="color: #009900;">&#40;</span><span style="color: #000088;">$table_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table_version</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Install the second table</span>
<span style="color: #000088;">$table_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;my_second_plugin_tbl&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;id mediumint(9) NOT NULL AUTO_INCREMENT,
	   category_name VARCHAR(100) DEFAULT NULL,
	   category_identifier VARCHAR(45) DEFAULT NULL,
	   category_desc TEXT,
	   display_desc VARCHAR (4) DEFAULT NULL,
	  UNIQUE KEY id (id)&quot;</span><span style="color: #339933;">;</span>
my_plugin_run_install  <span style="color: #009900;">&#40;</span><span style="color: #000088;">$table_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table_version</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I hope this helps some of the WordPress plugin authors out there.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Function+for+Creating+Tables+with+Wordpress+Plugins+-+http://b2l.me/ugq7n&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;t=Function+for+Creating+Tables+with+Wordpress+Plugins" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;title=Function+for+Creating+Tables+with+Wordpress+Plugins" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;title=Function+for+Creating+Tables+with+Wordpress+Plugins" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;title=Function+for+Creating+Tables+with+Wordpress+Plugins" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;title=Function+for+Creating+Tables+with+Wordpress+Plugins" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Function+for+Creating+Tables+with+Wordpress+Plugins&amp;body=Link: http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Here%20is%20a%20very%20useful%20function%20I%20have%20written%20to%20install%2Fupdate%20the%20database%20tables%20in%20your%20custom%20Wordpress%20plugin.%20Basically%20I%20have%20used%20the%20examples%20given%20on%20the%20%22Creating%20Tables%20with%20Plugins%22%20page%20at%20Wordpress.org.%0D%0A%0D%0AIn%20your%20main%20plugin%20file%20%28ex.%20my_plugin.php%29%20I%20define%20my%20plugin%20version%3A%0D%0Adefi" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;title=Function+for+Creating+Tables+with+Wordpress+Plugins" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;n=Function+for+Creating+Tables+with+Wordpress+Plugins&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;title=Function+for+Creating+Tables+with+Wordpress+Plugins&amp;description=Here%20is%20a%20very%20useful%20function%20I%20have%20written%20to%20install%2Fupdate%20the%20database%20tables%20in%20your%20custom%20Wordpress%20plugin.%20Basically%20I%20have%20used%20the%20examples%20given%20on%20the%20%22Creating%20Tables%20with%20Plugins%22%20page%20at%20Wordpress.org.%0D%0A%0D%0AIn%20your%20main%20plugin%20file%20%28ex.%20my_plugin.php%29%20I%20define%20my%20plugin%20version%3A%0D%0Adefi" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;title=Function+for+Creating+Tables+with+Wordpress+Plugins&amp;srcUrl=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;srcTitle=Function+for+Creating+Tables+with+Wordpress+Plugins&amp;snippet=Here%20is%20a%20very%20useful%20function%20I%20have%20written%20to%20install%2Fupdate%20the%20database%20tables%20in%20your%20custom%20Wordpress%20plugin.%20Basically%20I%20have%20used%20the%20examples%20given%20on%20the%20%22Creating%20Tables%20with%20Plugins%22%20page%20at%20Wordpress.org.%0D%0A%0D%0AIn%20your%20main%20plugin%20file%20%28ex.%20my_plugin.php%29%20I%20define%20my%20plugin%20version%3A%0D%0Adefi" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;title=Function+for+Creating+Tables+with+Wordpress+Plugins&amp;summary=Here%20is%20a%20very%20useful%20function%20I%20have%20written%20to%20install%2Fupdate%20the%20database%20tables%20in%20your%20custom%20Wordpress%20plugin.%20Basically%20I%20have%20used%20the%20examples%20given%20on%20the%20%22Creating%20Tables%20with%20Plugins%22%20page%20at%20Wordpress.org.%0D%0A%0D%0AIn%20your%20main%20plugin%20file%20%28ex.%20my_plugin.php%29%20I%20define%20my%20plugin%20version%3A%0D%0Adefi&amp;source=Shoultes.net" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22Function%20for%20Creating%20Tables%20with%20Wordpress%20Plugins%22&amp;body=Link: http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Here%20is%20a%20very%20useful%20function%20I%20have%20written%20to%20install%2Fupdate%20the%20database%20tables%20in%20your%20custom%20Wordpress%20plugin.%20Basically%20I%20have%20used%20the%20examples%20given%20on%20the%20%22Creating%20Tables%20with%20Plugins%22%20page%20at%20Wordpress.org.%0D%0A%0D%0AIn%20your%20main%20plugin%20file%20%28ex.%20my_plugin.php%29%20I%20define%20my%20plugin%20version%3A%0D%0Adefi" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/&amp;submitHeadline=Function+for+Creating+Tables+with+Wordpress+Plugins&amp;submitSummary=Here%20is%20a%20very%20useful%20function%20I%20have%20written%20to%20install%2Fupdate%20the%20database%20tables%20in%20your%20custom%20Wordpress%20plugin.%20Basically%20I%20have%20used%20the%20examples%20given%20on%20the%20%22Creating%20Tables%20with%20Plugins%22%20page%20at%20Wordpress.org.%0D%0A%0D%0AIn%20your%20main%20plugin%20file%20%28ex.%20my_plugin.php%29%20I%20define%20my%20plugin%20version%3A%0D%0Adefi&amp;submitCategory=business&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=Function+for+Creating+Tables+with+Wordpress+Plugins&amp;body=Link: http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Here%20is%20a%20very%20useful%20function%20I%20have%20written%20to%20install%2Fupdate%20the%20database%20tables%20in%20your%20custom%20Wordpress%20plugin.%20Basically%20I%20have%20used%20the%20examples%20given%20on%20the%20%22Creating%20Tables%20with%20Plugins%22%20page%20at%20Wordpress.org.%0D%0A%0D%0AIn%20your%20main%20plugin%20file%20%28ex.%20my_plugin.php%29%20I%20define%20my%20plugin%20version%3A%0D%0Adefi" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://shoultes.net/function-for-creating-tables-with-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
