Updating WordPress while using memcached object caching.

I recently updated a site running WordPress that is using the memcached object cache plugin and got stuck in a loop where any time I would go to the admin it would show me this page.

I’d click continue and it would send me to the homepage and I couldn’t get into the dashboard. It seems as though the version number of the database is being stored in the memcache so in order to flush the cache you can just put this code somewhere in your functions file and then load the site once.

$memcache_obj = memcache_connect('localhost', 11211);
memcache_flush($memcache_obj);

This will clear out the existing cache and your new database version number will be written to the cache.

Posted in General | Leave a comment

FireMobileSimulator – Another good tool for developing websites for Japanese Cell Phones

My associates here introduced me to FireMobileSimulator. It allows me to use FireFox to test sites with the major cellular networks here and some of the more popular phones. Good stuff!

Posted in General | Leave a comment

User Agents for Japanese Cell Phones

I’ve been working on some themes using the ktai style plugin. This plugin allows you to use different themes for Japanese cell phones. I have been configuring it to work on the WordPress VIP platform. Since the original plugin creates additional database tables in order to store sessions I had to modify it to store the sessions in the WP Object Cache instead.

In order to test out the layouts I needed to modify the User Agent for Firefox. I downloaded a plugin called User Agent Switcher and then went searching for an file containing Japanese User Agents. I found this page, which was made by a web developer I know here in Fukuoka. He said he gets quite a bit of search traffic for that page. So if you need Japanese User Agents for User Agent Switcher, now you know where to go.

Posted in General | Leave a comment

The Head Cleaner Plugin for WordPress is great for your SEO

I visited Japan in February for WordCamp Fukuoka and met a developer there who created a great WordPress plugin - Head Cleaner. It parses the output of the head element of your pages and cleans it up.  It puts all of the tags in an order which I believe is good for SEO. Meta tags are moved to the beginning of the head element. After the meta elements it outputs the title, followed by your link tags. Then it puts in the script tags. It also removes any unneeded space between elements. Continue reading

Posted in General | Leave a comment

Vodpod Embedder Version 0.2 released

I set up this version last night. I shoved all the php into one file and used the Plugin Settings API properly. It was quite painful to figure out but now I have a good model for future use. This tutorial explained some concepts but was a little hard to follow.

Another tutorial came out on the 22nd and cleared up some things for me. I’ll probably end up writing something explaining my code in the near future. The current version of it has a lot of comments in there.

Check out the plugin at the code page.

Posted in Releases | Leave a comment

Vodpod Plugin released

After sitting on it for a little while I have finally completed the first release version of the Vodpod Embedder plugin. It allows you to easily add videos from Vodpod into your WordPress pages and posts.

I’ll be updating the plugin based on feedback. This is the initial release but I have been using this plugin personally for quite a while and I am happy with the functionality.

You can read it about it here or download it directly.

Posted in General | 1 Comment

Converting PHP to JSONP with json_encode

PHP has a nice function called json_encode that will transform a PHP array into a JSON object. This is very useful for converting data and publishing it for use with AJAX requests.

When you want your data to be accessible from a different domain you must take your JSON and turn it into a callback function in order to let the data be read inside the browser. The easiest way to do this is by reading the callback value from the get and putting it around the JSON output.

<?php
$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
$json = json_encode($arr);
$callback = $_GET[callback];
echo $callback . '(' . $json . ')';
?>

If you do this you’ll have no problems interacting with jQuery’s getJSON function and you’ll be publishing your data in a very portable format.

Posted in Code, General | Tagged , , , | 1 Comment

Using wp_enqueue_script and wp_enqueue_style with your WordPress Theme header

For the longest time I was including my Javascript files in WordPress with a simple Javascript statement in the header.php file. I’d reference the theme directory like this to make it portable.

<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/1080d.js"></script>

Unfortunately this method isn’t compatible with some plugins. If you have a plugin that wants to use jQuery it has no way of knowing you have already included it on the page.

The proper way to add your Javascript is to use the wp_enqueue_script function. This is how I add it now.

wp_enqueue_script('jquery');
wp_enqueue_script('1080djs', get_bloginfo('stylesheet_directory') . '/js/1080d.js', array('jquery'), '20091014' );

If you want to be really fancy and put your Javascript at the bottom of the page in order to make YSlow happy, you can set it up like this:

wp_enqueue_script('jquery', '', '', '', '', TRUE);
wp_enqueue_script('1080djs', get_bloginfo('stylesheet_directory') . '/js/1080d.js', array('jquery'), '20091014', TRUE);

Then your Javascript files will be included when the wp_footer(); function is called. Otherwise they are included when wp_head(); is called.

CSS files can also be managed the same way with the wp_enqueue_style function. Using both of these methods will help you make sure your themes more portable and compatible with plugins.

Posted in Code, General | Tagged , , | Leave a comment

Platform Ubiquity

I spend a good chunk of time reading about CMS platforms and I usually find myself amazed at how much organizations are willing to pay for proprietary software and the licenses associated with proprietary software. I’ve worked with .Net based CMS platforms which require a Microsoft SQL Server license along with the CMS license. I’ve worked with Java based CMS platforms which require an additional Oracle license. Once an organization adopts a closed platform they end up finding themselves married to their vendors.

One of the reasons I am such a fan of WordPress is the ubiquity of the platform it runs on. The large majority of hosting providers have low cost PHP hosting. The LAMP stack is most widely supported platform on the web. While this may mean a greater chance of running into an exploit, a solid provider should keep their environment properly maintained with the most stable and secure versions of each application.

Because there are no license fees involved with WordPress you only have to worry about relationships with two vendors – Your developer and your hosting company. If you use a cpanel based hosting solution then picking up your entire site and moving it to another hosting provider that supports cpanel is incredibly easy. If your relationship with your developer turns sour there are many competent WordPress developers out there.

A ubiquitous platform leads to choices and freedom. You don’t have to worry about paying for expensive “enterprise” software. You just hit the ground running and customize your platform and focus on making it the perfect fit for organizations of any size.

Posted in General | Leave a comment

Small, cheap apartments for the Indian middle class

Time Magazine had a small article about a a housing complex with small, low cost apartments ranging from 280 to 470 square feet. It is being funded by Tata, The indian conglomerate responsible for the $2,000 car – the Nano.

These types of apartments should sell well. People can be quite comfortable in smaller apartments if they are designed well. Computers and technology a small apartment convenient and entertaining.

Posted in General | Tagged | Leave a comment