<?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>Designoplasty Web Design and Development Blog &#187; WordPress</title>
	<atom:link href="http://designoplasty.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://designoplasty.com</link>
	<description>HTML, Javascript, PHP, and Me</description>
	<lastBuildDate>Wed, 08 Sep 2010 09:25:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Incredible Challenges</title>
		<link>http://designoplasty.com/2010/09/08/incredible-challenges/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=incredible-challenges</link>
		<comments>http://designoplasty.com/2010/09/08/incredible-challenges/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 09:25:02 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Mac Mini Server]]></category>
		<category><![CDATA[OS X Server]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=1276</guid>
		<description><![CDATA[Recently I made some substantial changes to a customer website. Today I spent searching for issues I didn&#8217;t find in testing. They&#8217;re always there and they always show up as soon as you go live. Luckily they&#8217;re usually not too critical.

One was so bizarre and I never did figure out the root bug. It occurred [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I made some substantial changes to a customer website. Today I spent searching for issues I didn&#8217;t find in testing. They&#8217;re always there and they always show up as soon as you go live. Luckily they&#8217;re usually not too critical.</p>

<p>One was so bizarre and I never did figure out the root bug. It occurred when I did a search for the most recent post with a certain tag. The bug would occur when no post met that criteria. I was incorrectly using the query_posts function instead of the get_posts function and I would fail to check for an empty array but things would still work. But for some reason the page would load twice. Two calls to the WordPress &#8216;init&#8217; action and double everything else. The referrer would change for the second page load (to the page being loaded) but but it didn&#8217;t show obviously in the browser although there were some bizarre symptoms there as well.</p>

<p>The debug messages I was getting were bizarre and would change depending on whether I used curl, Safari, or Firefox. It took me a while to find out it was caused by the array bounds issue, but fixing that fixed the symptoms.</p>

<p>Still I&#8217;ve never seen this bizarre double page load issue. I assume it&#8217;s a WordPress thing but who knows. Once the bug was fixed I didn&#8217;t care much about further root cause analysis especially since with expected data the bug wouldn&#8217;t even show up using the original code.</p>

<p>Add in some issues with my local development server slowing to a crawl for some unknown reason and it was quite a day.</p>

]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2010/09/08/incredible-challenges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing/Updating WordPress with Subversion</title>
		<link>http://designoplasty.com/2010/08/06/installingupdating-wordpress-with-subversion/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=installingupdating-wordpress-with-subversion</link>
		<comments>http://designoplasty.com/2010/08/06/installingupdating-wordpress-with-subversion/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 00:56:59 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=1266</guid>
		<description><![CDATA[Installing/Updating WordPress with Subversion

After a long time of installing WordPress manually on my test machines, I have finally switched to using subversion. It is so much easier.

It wouldn&#8217;t be, except that for some reason WordPress will not update properly if your site is not on the open internet. I don&#8217;t know what their deal is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion#Converting_a_.22Traditional.22_WordPress_Blog_to_a_Subversion_Checkout">Installing/Updating WordPress with Subversion</a></p>

<p>After a long time of installing WordPress manually on my test machines, I have finally switched to using subversion. It is so much easier.</p>

<p>It wouldn&#8217;t be, except that for some reason WordPress will not update properly if your site is not on the open internet. I don&#8217;t know what their deal is with that, but this gets around it easily. If you use subversion for other things and are familiar with it, but don&#8217;t yet use it for your local WordPress installations, I highly recommend making the switch.</p>]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2010/08/06/installingupdating-wordpress-with-subversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Themes: Object Oriented PHP Code is Very Important</title>
		<link>http://designoplasty.com/2010/02/15/wordpress-themes-php-code-is-very-important/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wordpress-themes-php-code-is-very-important</link>
		<comments>http://designoplasty.com/2010/02/15/wordpress-themes-php-code-is-very-important/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 17:41:46 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Object Oriented]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=1180</guid>
		<description><![CDATA[I'm doing a heavy rewrite of my main WordPress theme that all of my other themes are based on. As someone who has spent a lot of time writing code, one of the things that has been bugging me about WordPress themes is all the duplication of HTML.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m doing a heavy rewrite of my main WordPress theme that all of my other themes are based on. As someone who has spent a lot of time writing code, one of the things that has been bugging me about WordPress themes is all the duplication of HTML.</p>

<p>For instance, if all your pages have a format involving a header element, a body element, and a footer element, then you have to duplicate that HTML in single.php, page.php, 404.php, etc. Then if you ever change it you have to edit every one of those files just to make the same changes over and over again. You&#8217;re probably going to forget to do it in some files and you&#8217;re going to do it wrong in others.</p>

<p>Wouldn&#8217;t it be great if you could just call a function that would establish this pattern for you in all files? Then if you needed to change it, you would only have to change it in one place and all your site&#8217;s pages would be effected. But what if you need to tweak the template slightly for different pages? This is exactly why object oriented design is important.</p>

<p>So you have a base class that draws the usual page structure and then provide override-able and abstract methods so that a new class can be created if you need to customize. It works perfectly because it gives you maximum code reuse and there&#8217;s no duplication.</p>

<p>However, it does make the theme very code heavy. There&#8217;s not a ton of code, but enough that would intimidate most people. Plus, if you don&#8217;t have a lot of experience with object oriented design getting the extensibility right is going to be a bit difficult.</p>

<p>But that&#8217;s kind of my point for this post. It&#8217;s not necessarily that you need to do this, because obviously themes can be made without it. But it&#8217;s the fact that object oriented design is important to web applications and even blogs too. If you do a lot of PHP coding but aren&#8217;t yet familiar with the concepts behind object oriented programming, then learning more about that will really be a benefit to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2010/02/15/wordpress-themes-php-code-is-very-important/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the WordPress apply_filters Function for Dynamic Content</title>
		<link>http://designoplasty.com/2010/01/26/using-the-wordpress-apply_filters-function-for-dynamic-content/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-the-wordpress-apply_filters-function-for-dynamic-content</link>
		<comments>http://designoplasty.com/2010/01/26/using-the-wordpress-apply_filters-function-for-dynamic-content/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 04:52:30 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=1159</guid>
		<description><![CDATA[In a WordPress plugin you can filter many values including the title and content of a post using:

add_filter('the_content', 'MyPluginClass::FilterTheContent');

This is pretty handy, but sometimes when you&#8217;re writing a WordPress theme you want to allow plugins to add content, not just filter the usual content. Using apply_filters makes this pretty easy because you can call apply [...]]]></description>
			<content:encoded><![CDATA[<p>In a WordPress plugin you can filter many values including the title and content of a post using:</p>

<pre><code>add_filter('the_content', 'MyPluginClass::FilterTheContent');</code></pre>

<p>This is pretty handy, but sometimes when you&#8217;re writing a WordPress theme you want to allow plugins to add content, not just filter the usual content. Using <code>apply_filters</code> makes this pretty easy because you can call apply filters with custom &#8220;tags&#8221; and it will just work. For instance in your theme you can put:</p>

<pre><code>&lt;?php

    $theMessage = apply_filters('CustomThemeMessage', '' /* default value: empty string */);

    if (!empty($theMessage))
    {
        echo '&lt;div class="Message"&gt;', $theMessage, '&lt;/div&gt;';
    }

?&gt;</code></pre>

<p>If nobody ever filters on the tag &#8216;CustomThemeMessage&#8217; it&#8217;s fine, your theme won&#8217;t break or anything. But plugins that know this tag is available can use it:</p>

<pre><code>add_filter('CustomThemeMessage', 'MyPluginClass::FilterTheContent');</code></pre>

<p>When you&#8217;re developing themes and plugins in tandem, this is incredibly useful and robust. It&#8217;s also not as risky as filtering a tag like &#8216;the_content&#8217; where a mistake can really mess up your site. It will also be more performant when you only need the custom content on one or a few of the pages on your site.</p>]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2010/01/26/using-the-wordpress-apply_filters-function-for-dynamic-content/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress and PHP have Poor Support for Dates and Time Zones</title>
		<link>http://designoplasty.com/2010/01/16/wordpress-and-php-have-poor-support-for-dates-and-time-zones/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wordpress-and-php-have-poor-support-for-dates-and-time-zones</link>
		<comments>http://designoplasty.com/2010/01/16/wordpress-and-php-have-poor-support-for-dates-and-time-zones/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 09:00:00 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Object Oriented]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=1140</guid>
		<description><![CDATA[Today I spent way too much time figuring out how to convert dates and times to different time zones. PHP can barely do it, and WordPress really doesn&#8217;t do anything to make it easier. I would love it if someone would just create a simple function like this:

$string = format_gmt_time_for_time_zone(
    'l, F [...]]]></description>
			<content:encoded><![CDATA[<p>Today I spent way too much time figuring out how to convert dates and times to different time zones. PHP can barely do it, and WordPress really doesn&#8217;t do anything to make it easier. I would love it if someone would just create a simple function like this:</p>

<pre><code>$string = format_gmt_time_for_time_zone(
    'l, F jS g:ia', 
    $myGMTTimestamp,
    'America/Los Angeles');</code></pre>

<p>or even better, using and object oriented approach:</p>

<pre><code>$string = $date->Format(
    'l, F jS g:ia', 
    'America/Los Angeles');</code></pre>

<p>It&#8217;s important because it&#8217;s kind of a &#8220;best practice&#8221; to store dates in the database in GMT (or really UTC) format and then translate them as necessary. Then I want someone in New York to see times in their time zone and also someone in Seattle. It would also help if WordPress had a per user time zone.</p>

<p>I know that PHP 6 is doing some enhanced date stuff, so hopefully that will include this simple functionality. But right now, both WordPress and PHP don&#8217;t seem to imaging a case where someone wants to print out a time for a timezone they&#8217;re not in.</p>

<p>What I ended up doing was this:</p>

<pre><code>$oldTimeZone = date_default_timezone_get();

date_default_timezone_set($requestedTimeZone));
        
$convertedString = date($formatString, $gmtTimestamp);
        
date_default_timezone_set($oldTimeZone);
        
return $convertedString;</code></pre>

<p>It works, but it&#8217;s fairly clunky. From my experience at Microsoft I know sometimes when there&#8217;s a whole category of things that needs improving, it can be hard to find someone to take that on. What has to happen is a person needs to say, &#8220;I&#8217;m going to take on times and dates and make the API better.&#8221; But either people aren&#8217;t interesting or people are too afraid to suggest such a drastic move. Furthermore, the people who wrote the original code will often be offended that someone would suggest it could be better. They will point to something like my code above an say that&#8217;s good enough. It isn&#8217;t.</p>

<p>I&#8217;m actually considering getting involved with WordPress on this, however, I am honestly scared that they will not be into it. I&#8217;d also like to add the per user time zone, but I sense something like that would be controversial.</p>]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2010/01/16/wordpress-and-php-have-poor-support-for-dates-and-time-zones/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Swift Mailer: Awesome PHP Mailer</title>
		<link>http://designoplasty.com/2010/01/02/swift-mailer-awesome-php-mailer/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=swift-mailer-awesome-php-mailer</link>
		<comments>http://designoplasty.com/2010/01/02/swift-mailer-awesome-php-mailer/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 06:44:57 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=1133</guid>
		<description><![CDATA[

Tonight was the first time that I needed to write some code for a business that would send email to customers, or at least email that needed to be reliable and feature rich. I looked at the documentation for the PHP mail function and after a lot of reading realized it was not going to [...]]]></description>
			<content:encoded><![CDATA[<img src="http://photos.smugmug.com/photos/756037510_FDz8e-O.png" class="floatright" style="width: 181px; height: 68px;" alt="Swift Mailer PHP emailer" />

<p>Tonight was the first time that I needed to write some code for a business that would send email to customers, or at least email that needed to be reliable and feature rich. I looked at the documentation for the PHP mail function and after a lot of reading realized it was not going to work. If I wanted to use HTML, that involved a lot of uncertainty, if I wanted to use UTF-8, that involved a lot of uncertainty. There were a lot of unknowns but one thing that was quickly becoming a known was that I was not going to fix this problem.</p>

<p>I knew I could send simple text emails with a URL to details if I had to, but before I did that, I wondered if someone else had solved my problem since what I wanted was reasonable and obvious. To my great surprise a few people had. It came down to two tools, <a href="http://swiftmailer.org/">Swift Mailer</a> and <a href="http://phpmailer.worxware.com/">PHP Mailer</a>.</p>

<p>After doing some Google searches and research, it became clear that <a href="http://swiftmailer.org/">Swift Mailer</a> was probably going to be better for me. And the reasons why are big lessons for PHP Mailer. <a href="http://swiftmailer.org/">Swift Mailer</a> had a nice simple website, they had one product, and they had a download link on the front page. Right off the bat, it was looking simple. On the other hand PHP Mailer has four products which I would have to investigate to find out which one was right for me. Their home page is a mess that for some reason seems to focus on ads for other people&#8217;s products along with tons of text about who knows what. It would take me hours just to parse the homepage.</p>

<p>But, what took it over the edge was that <a href="http://swiftmailer.org/">Swift Mailer</a> has a beautiful object oriented design to their API and they talk about that being a goal, they have full easy to understand documentation, installation is a breeze, as it should be, all while offering an incredibly feature rich product. Swift Mailer wins by a mile.</p>

<p>Was it as easy as it looked? Well, in about an hour I had built a WordPress plugin that would include <a href="http://swiftmailer.org/">Swift Mailer</a>&#8217;s functionality in my blog on demand. I had added code to another plugin to enable Swift Mailer at the right time and send an email from one Gmail account to another using Gmail&#8217;s smtp server with a secure connection over SSL.</p>

<p>One hour.</p>

<p>I literally copied the code over and changed the important bits. I had one issue where Gmail didn&#8217;t like the port the Swift Mailer docs used for SSL, but the Gmail docs listed the alternative port and things worked perfectly.</p>

<p>Furthermore, there are tons of features of <a href="http://swiftmailer.org/">Swift Mailer</a> that will actually inspire me to do more with email.</p>

<p>Kudos to the <a href="http://swiftmailer.org/">Swift Mailer</a> team, you&#8217;ve really created a great product and you are a poster project for open source. Thank you!</p>
]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2010/01/02/swift-mailer-awesome-php-mailer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using PHP Class Methods as WordPress Action Hook Callbacks</title>
		<link>http://designoplasty.com/2009/11/20/using-php-class-methods-as-wordpress-action-hook-callbacks/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-php-class-methods-as-wordpress-action-hook-callbacks</link>
		<comments>http://designoplasty.com/2009/11/20/using-php-class-methods-as-wordpress-action-hook-callbacks/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 08:46:04 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=1058</guid>
		<description><![CDATA[Using object oriented code is a must for me. Object oriented code is more than just organization of the code, it&#8217;s organization of one&#8217;s thinking. I wanted to talk about using static class methods as handlers for WordPress actions. This is important to me because often my plugins are implemented as a class.

add_action('init', 'MyPlugin::Init');

class MyPlugin
{
 [...]]]></description>
			<content:encoded><![CDATA[<p>Using object oriented code is a must for me. Object oriented code is more than just organization of the code, it&#8217;s organization of one&#8217;s thinking. I wanted to talk about using static class methods as handlers for WordPress actions. This is important to me because often my plugins are implemented as a class.</p>

<pre><code>add_action('init', 'MyPlugin::Init');

class MyPlugin
{
    public static function Init()
    {
        // Put Some Code Here
    }
}</code></pre>

<p>Pretty easy. What I really like about this is that the class name acts as a namespace, so I can use the simple function name <code>Init</code> instead of naming my function something annoying like <code>myplugin_init</code>.</p>

<p>I use this pattern all the time to initialize an instance of the class so that it can be used elsewhere, such as in a theme:</p>

<pre><code>add_action('init', 'MyPlugin::Init');

class MyPlugin
{
    private $userName = null;

    public static function Init()
    {
        global $myPlugin;

        $myPlugin = new MyPlugin();

        // The following line would probably go into a 
        // constructor method and get the real current
        // user name.

        $myPlugin->userName = 'bob';
    }

    pubic function GetUserName()
    {
        return $this->userName;
    }
}</code></pre>

<p>Then any other non-plugin code, like a theme for instance, can detect the presence of the plugin and use it.</p>

<pre><code>global $myPlugin;

if (isset($myPlugin))
{
    echo 'MyPlugin is installed, ', $myPlugin->GetUserName();
}</code></pre>

<p>Happy Coding!</p>]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2009/11/20/using-php-class-methods-as-wordpress-action-hook-callbacks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress Function do_action &#8211; Very Useful</title>
		<link>http://designoplasty.com/2009/10/21/wordpress-function-do_action-very-useful/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wordpress-function-do_action-very-useful</link>
		<comments>http://designoplasty.com/2009/10/21/wordpress-function-do_action-very-useful/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 06:01:54 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=1001</guid>
		<description><![CDATA[Today, well, really the last few days have been incredibly productive and incredibly hectic. I finished up some complex code for a customer and ever since then I&#8217;ve had so many epiphanies that I&#8217;ve practically been typing constantly ever since. I will say that I really like when I am inspired like this, but I [...]]]></description>
			<content:encoded><![CDATA[<p>Today, well, really the last few days have been incredibly productive and incredibly hectic. I finished up some complex code for a customer and ever since then I&#8217;ve had so many epiphanies that I&#8217;ve practically been typing constantly ever since. I will say that I really like when I am inspired like this, but I will also say that I kind of don&#8217;t like it. I&#8217;ve had a list of really good ideas forcing their way out and it&#8217;s very hard to keep up with them. This is kind of how software development works, though. You take some time to ponder ideas or let ideas rest and then one day it all comes together into lots of actionable items you want to do all at once.</p>

<p>One of the many things I&#8217;ve found useful over the past couple of days has been the WordPress function <code>do_action</code>. I have a base theme that I repurpose for all of my websites. I really try to keep it flexible enough to do just about anything. Sometimes that can be difficult, but <code>do_action</code> really helps. You can  place <code>do_action</code> calls throughout your theme files in handy places and then customize your theme outside of your standard theme files using the <code>add_action</code> function. If you don&#8217;t customize, everything works fine, but if you do, you can do it in a different file so you don&#8217;t have to modify the core theme files.</p>

<p>Obviously, this paradigm is used throughout WordPress in many different ways, and I have been a &#8220;consumer&#8221; of it many times. But it wasn&#8217;t until recently that I realized how much this could help me with my many different themes and save so much time. Or at least it will, after this exhausting week is over!</p>]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2009/10/21/wordpress-function-do_action-very-useful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JQuery.post Recursion, or not&#8230;</title>
		<link>http://designoplasty.com/2009/09/18/jquery-post-recursion-or-not/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=jquery-post-recursion-or-not</link>
		<comments>http://designoplasty.com/2009/09/18/jquery-post-recursion-or-not/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 08:45:01 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=980</guid>
		<description><![CDATA[Today I spent some time making some data import code work better.

At the start of the process I had a PHP function that I would call to import some data. The problem is, that process would take longer than 30 seconds after which it would time out. A while ago, I changed the function to [...]]]></description>
			<content:encoded><![CDATA[<p>Today I spent some time making some data import code work better.</p>

<p>At the start of the process I had a PHP function that I would call to import some data. The problem is, that process would take longer than 30 seconds after which it would time out. A while ago, I changed the function to stop itself after 20 seconds. The result was an administrative web page where you had to hit an &#8220;update&#8221; button multiple times, waiting for 20 seconds each time.</p>

<p>My dream of dreams was to have this function work via AJAX instead and just update one record, return with status indicating how much work was left and then do another. I did this with the JQuery.post method. This is using the WordPress admin AJAX functionality.</p>

<pre><code>cancelProcess = false;

function ImportOneRecord()
{

    jQuery.post(
        '/wp-admin/admin-ajax.php', 
        {
            'action': 'ImportOneRecord'
        },
        function (data)
        {
            if (data.succeeded 
                &#038;&#038; (data.recordsLeftToImport > 0) 
                &#038;&#038; !cancelProcess)
            {
                // Update Status
                jQuery('#statusBox').html(data.status);

                // Do It Again
                ImportOneRecord();
            }
        },
        'json');

}</code></pre>

<p>My initial concern was one of stack overflows, but then I realized that the asynchronous nature of AJAX takes care of that. When this function runs, it doesn&#8217;t block. It sends the AJAX request that lives out in the ether and when that request receives a response, it runs my event handler. When that event handler runs it doesn&#8217;t block either, meaning it can be released. But when it did run, it created another AJAX request that also lives in the ether. Nothing is hanging onto it.</p>

<p>This function made it through thousands of records and I&#8217;m not sure how big the JavaScript stack is, but it didn&#8217;t overflow. I think it&#8217;s because like I thought, that&#8217;s not an issue here. There is no stack build up. This is just a very very complex loop&hellip; I think.<?p>]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2009/09/18/jquery-post-recursion-or-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Plugins and AJAX</title>
		<link>http://designoplasty.com/2009/09/14/wordpress-plugins-and-ajax/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wordpress-plugins-and-ajax</link>
		<comments>http://designoplasty.com/2009/09/14/wordpress-plugins-and-ajax/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 04:36:55 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=967</guid>
		<description><![CDATA[The last couple of days I&#8217;ve been doing a ton of AJAX programming on some WordPress plugins. Wordpress actually does have one very handy AJAX feature that makes using AJAX just a little easier. I also use jQuery because it&#8217;s really nice for a lot of things including AJAX work.

AJAX is a great technology, and [...]]]></description>
			<content:encoded><![CDATA[<p>The last couple of days I&#8217;ve been doing a ton of AJAX programming on some WordPress plugins. Wordpress actually does have <a href="http://codex.wordpress.org/AJAX_in_Plugins">one very handy AJAX feature</a> that makes using AJAX just a little easier. I also use jQuery because it&#8217;s really nice for a lot of things including AJAX work.</p>

<p>AJAX is a great technology, and while I know what I&#8217;m doing, sometimes even I am amazed at how difficult it is. You&#8217;ve got HTML, Javascript, PHP, and usually database tables to get right. If any one of those isn&#8217;t working it won&#8217;t work.</p>

<p>If you don&#8217;t already have good debugging skills, I wouldn&#8217;t even try it. I very much try to integrate my debugging in with my development to save time. For instance, I have a function that checks to make sure a database call went OK. If not it sends an ajax response with the query and the error string. My calls to AJAX are always prepared to receive and display that error. Even my CSS for the page even handles displaying the returned error string in the most clear way possible. This is code I can use again and again in all my plugins, and if I didn&#8217;t reuse it I would never get anything done..</p>

<p>Now that I&#8217;m getting it down, it&#8217;s so nice. I love AJAX. But the more I work on the web the more I see we need a replacement for JavaScript. I mean most of the language is fine, but it needs to be a real language with the standard object oriented features implemented in the standard way: class, public, private, protected, property getters and setters, etc. The prototype keyword needs to be completely removed from the language. JavaScript and PHP need to align such that AJAX is a natural part of both languages. It&#8217;s possible, but the web is a funny thing and its technologies have a heck of a time moving forward.</p>
]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2009/09/14/wordpress-plugins-and-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forget Trac, The Bug Genie is Awesome</title>
		<link>http://designoplasty.com/2009/09/08/forget-trac-the-bug-genie-is-awesome/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=forget-trac-the-bug-genie-is-awesome</link>
		<comments>http://designoplasty.com/2009/09/08/forget-trac-the-bug-genie-is-awesome/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 04:27:43 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=956</guid>
		<description><![CDATA[
Yes, its a cutsie name, but The Bug Genie is a PHP bug tracking system that is the opposite of Trac in the best possible ways.

First of all you create a MySQL database and copy The Bug Genie files to your web server. Then you go to your website, where The Web Genie greets you [...]]]></description>
			<content:encoded><![CDATA[<img src="http://photos.smugmug.com/photos/643656302_Qv7Fq-O.png" class="floatright" style="width: 333px; height: 64px;" alt="The Bug Genie: PHP and MySQL issue tracking software." />
<p>Yes, its a cutsie name, but <a href="http://www.thebuggenie.com/">The Bug Genie</a> is a PHP bug tracking system that is the opposite of Trac in the best possible ways.</p>

<p>First of all you create a MySQL database and copy The Bug Genie files to your web server. Then you go to your website, where The Web Genie greets you with a short setup. At the end, it gives you an administrator login and password and you&#8217;re ready to go.</p>

<p>It&#8217;s that simple to set up. No command line required.</p>

<p>The help is built right into the system in the form of little question marks strategically placed that you can click on. They usually answer any beginner questions you&#8217;ll have.</p>

<p>How to create users? Well you can do it quite easily, but why bother? Just let your users sign themselves up with their email address and create an account. Just like WordPress.</p>

<p>It&#8217;s very powerful and has Subversion integration. Actually, for my purposes, it&#8217;s a bit too powerful for the minor issue tracking I need, but after having worked at Microsoft and using their bug tracking, The Bug Genie seems better. It&#8217;s certainly prettier, and prettier than everything else out there as well.</p>

<p>I predict great things for The Bug Genie for a lot of great reasons, but maybe for no other reason than nobody can set up any of the other bug trackers without dedicating their life to them.<p>]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2009/09/08/forget-trac-the-bug-genie-is-awesome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Counters</title>
		<link>http://designoplasty.com/2009/09/05/mysql-counters/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mysql-counters</link>
		<comments>http://designoplasty.com/2009/09/05/mysql-counters/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 03:24:22 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=940</guid>
		<description><![CDATA[Today I went to Panera (free wi-fi) to get some work done away from the distraction of my dachshund. I&#8217;m changing a lot of my PHP code to use classes, and needed to focus. After enjoying some soup on a bread bowl (it must be fall) I started working.

I didn&#8217;t get far. I realized what [...]]]></description>
			<content:encoded><![CDATA[<p>Today I went to Panera (free wi-fi) to get some work done away from the distraction of my dachshund. I&#8217;m changing a lot of my PHP code to use classes, and needed to focus. After enjoying some soup on a bread bowl (it must be fall) I started working.</p>

<p>I didn&#8217;t get far. I realized what I needed was a thread-safe counter. Simply a function that spits out numbers one after the other, and absolutely positively guarantees it will not give out the same number more than once. I know how to do this many different ways using many different languages, but I wasn&#8217;t sure of the best way to do it using WordPress, PHP, and MySQL.</p>

<p>MySQL does have auto increment where if you add a row to a table it will make give a field a value that&#8217;s incremented. This is atomic, but I didn&#8217;t need a new row in a table, I just needed the number.</p>

<p>I figured I could store the number in a text file and have PHP use file write protections to do the locking I needed to make it atomic, but the performance would not be that great for such a simple task.</p>

<p>I thought I could create a simple table with the number in a row, and use MySQL table locking to accomplish this. For a while, I had settled on that plan, but something made me think there must be a better way.</p>

<p>I went about researching the MySQL update statement. It turns out that doing this is atomic.</p>

<pre><code>UPDATE plugin_counters
    SET counter_value = counter_value + 1 
    WHERE counter_name = 'invoice_id';</code></pre>

<p>But the problem is how to get that value before this happens again. Apparently you can just add one more expression to the WHERE clause.</p>

<pre><code>UPDATE plugin_counters
    SET counter_value = counter_value + 1 
    WHERE counter_name = 'invoice_id'
        AND @value := counter_value;</code></pre>

<p>This expression will always return true and will place the original value of counter_value into the MySQL variable @value.</p>

<p>I spent a good deal of time trying to verify that this is absolutely positively atomic and it seems to be. Even naysayers were accepting this to be atomic while pointing out that longer updates would not be atomic if the database crashed in the middle of the update. So to me, this means they&#8217;re saying as long as the database doesn&#8217;t crash, it&#8217;s atomic, which is good enough for me.</p>

]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2009/09/05/mysql-counters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snow Leopard Upgrade on my MacBook Very Painful</title>
		<link>http://designoplasty.com/2009/08/29/snow-leopard-upgrade-on-my-macbook-very-painful/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=snow-leopard-upgrade-on-my-macbook-very-painful</link>
		<comments>http://designoplasty.com/2009/08/29/snow-leopard-upgrade-on-my-macbook-very-painful/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 23:46:45 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Apple Inc.]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=925</guid>
		<description><![CDATA[Now, in this case it isn&#8217;t really Apple&#8217;s fault. It&#8217;s sort of everyone&#8217;s fault. There&#8217;s a reason even complex things need to be simplified and it&#8217;s to avoid the situation I&#8217;m in right now.

After installing Snow Leopard on my other machine and thinking I found all the kinks my MacBook still won&#8217;t connect to a [...]]]></description>
			<content:encoded><![CDATA[<p>Now, in this case it isn&#8217;t really Apple&#8217;s fault. It&#8217;s sort of everyone&#8217;s fault. There&#8217;s a reason even complex things need to be simplified and it&#8217;s to avoid the situation I&#8217;m in right now.</p>

<p>After installing Snow Leopard on my other machine and thinking I found all the kinks my MacBook still won&#8217;t connect to a MySQL database from a WordPress installation. I have followed all the instructions, I have found more instructions online and figured those out.</p>

<p>I can connect to my mysql database from either the command line or a database utility program.</p>

<p>My webserver seems to be running fine with php enabled.</p>

<p>But WordPress just won&#8217;t work. Not a big deal? My business is WordPress and this particular machine has at least 10 different WordPress installations on it and none of them work. I literally can&#8217;t work on anything for my customers at this point.</p>

<p>Also there&#8217;s nothing in the error logs to give me any hint as to what&#8217;s happening.</p>

<p>Fun!</p>

<hr/>

<h3>Update:</h3>

<p>Oh My God! For Snow Leopard on my MacBook apparently the host in wp-config.php needs to be &#8216;localhost&#8217; instead of &#8216;127.0.0.1&#8242;. On Leopard it was exactly the opposite. But either should work fine. Whatever. And &#8216;127.0.0.1&#8242; works fine on my other machine running Snow Leopard. This is just truly junk.</p>

<p>I know I tried this before but that my have been before I did all the other MySQL wrangling. Whatever.</p>

<hr/>

<h3>Update:</h3>

<p>I just checked and my other machine also requires &#8216;localhost&#8217; and will not work with &#8216;127.0.0.1&#8242;. However, I don&#8217;t remember changing it. It must have either worked all along on that machine or I changed it in passing. Bizarre.</p>]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2009/08/29/snow-leopard-upgrade-on-my-macbook-very-painful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snow Leopard Install Hazardous to Apache Virtual Hosts, MySQL, and PHP</title>
		<link>http://designoplasty.com/2009/08/28/snow-leopard-install-hazardous-to-apache-virtual-hosts-mysql-and-php/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=snow-leopard-install-hazardous-to-apache-virtual-hosts-mysql-and-php</link>
		<comments>http://designoplasty.com/2009/08/28/snow-leopard-install-hazardous-to-apache-virtual-hosts-mysql-and-php/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 01:57:32 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Apple Inc.]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=917</guid>
		<description><![CDATA[I am using the Apache vhosts feature to run multiple websites on my machine, many of which are running WordPress and therefore also using MySQL. The Snow Leopard installation was almost as disastrous as it could be for this setup.

Pre Snow Leopard Installation Warning

Be sure to back up your

/etc/apache2/extra/httpd-vhosts.conf

file before you install Snow Leopard. It [...]]]></description>
			<content:encoded><![CDATA[<p>I am using the Apache vhosts feature to run multiple websites on my machine, many of which are running WordPress and therefore also using MySQL. The Snow Leopard installation was almost as disastrous as it could be for this setup.</p>

<h3>Pre Snow Leopard Installation Warning</h3>

<p>Be sure to back up your</p>

<pre><code>/etc/apache2/extra/httpd-vhosts.conf</code></pre>

<p>file before you install Snow Leopard. It is going to replace that file without backing up the one you had before. That is not a file that&#8217;s included in Time Machine backups.</p>

<h3>Post Snow Leopard Tasks</h3>

<ol>

<li>
<p>First you need to copy the vhosts file you saved back where it belongs. Otherwise you need to recreate your entries. Luckily I had two computers with this setup so I had the one on the other computer to look at for reference.</p>
</li>

<li>
<p>Next, MySQL probably won&#8217;t be working. In my case the was because the Snow Leopard install deleted the</p>

<pre><code>/usr/local/mysql</code></pre>

<p>symbolic link to my current version of MySQL. You just need to replace this using the following terminal commands:</p>

<pre><code>cd /usr/local
sudo ln -s mysql-5.1.30-osx10.5-x86 mysql</code></pre>

<p>Your current version of MySQL will of course probably be different than that, but you get the idea.</p>
</li>

<li>
<p>There is a bizarre issue where Snow Leopard deletes the php.ini or reacts differently if it isn&#8217;t there. The symptom is that when viewing websites on your local server PHP will complain about not having a time zone set. This <a href="http://johnbeales.com/20090828/get-your-development-server-running-after-upgrading-to-snow-leopard/">web page</a> has the solution for that, and it&#8217;s not difficult, but long enough that I don&#8217;t want to repeat it here.
</p>
</li>

</ol>

<p>For me, these three steps got me working again. Hopefully they will work for you or will at least get you started. Good luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2009/08/28/snow-leopard-install-hazardous-to-apache-virtual-hosts-mysql-and-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Standardizing and Simplifying WordPress Themes</title>
		<link>http://designoplasty.com/2009/08/20/standardizing-and-simplifying-wordpress-themes/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=standardizing-and-simplifying-wordpress-themes</link>
		<comments>http://designoplasty.com/2009/08/20/standardizing-and-simplifying-wordpress-themes/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 05:06:27 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://designoplasty.com/?p=898</guid>
		<description><![CDATA[I&#8217;ve mentioned before that I&#8217;m working on a redesign of this theme. That work is very graphics intensive so it goes slower and has to wait for inspiration.

But the way I work is that I have one common theme for all my sites and then I retheme each site as appropriate. Each time I focus [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve mentioned before that I&#8217;m working on a redesign of this theme. That work is very graphics intensive so it goes slower and has to wait for inspiration.</p>

<p>But the way I work is that I have one common theme for all my sites and then I retheme each site as appropriate. Each time I focus on a theme, I usually make changes that need to go back into the base theme as I learn to make the base theme more flexible and more themeable.</p>

<p>Sometimes a site gets ignored for a while so there are a whole bunch of these changes to bring into it. That&#8217;s one of the things I&#8217;m working on now. And I&#8217;m happy to say that while I&#8217;m practically rewriting the whole stylesheet because he base theme has changed so much, I can also see that it&#8217;s much easier and faster to theme than my old base theme. The style is much smaller than before while accomplishing a lot more.</p>

<p>As a base theme moves forward, it starts to reflect common things that need to happen and takes care of those for you. At the same time I try not to include much that would need to be undone. In fact, there is almost nothing that would ever need to be undone unless I needed to make dramatic changes for a particular theme.</p>

<p>You&#8217;ll see there are a lot of theme designers out there that work this way. However, I am surprised that nobody has taken the time to update the default WordPress themes to be more themable. At the same time, they are good learning themes, so maybe it&#8217;s for the best.</p>
]]></content:encoded>
			<wfw:commentRss>http://designoplasty.com/2009/08/20/standardizing-and-simplifying-wordpress-themes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
