Category Archives: WordPress

All about my love for WordPress. BTW, I am self-claimed WordPress Super star.

PHP 4, WordPress 2.5 and BBPress 0.9

I just found a bug in WordPress 2.5, which is exposed when it is run in PHP 4.3.11. I thought of detailing about it here so that it will be useful for others who are seeking solution for the similar problem.

Recently I was trying to integrate WordPress and BBPress to make them share a single database and cookie. The advantage of this integration is that a logged in user can share the session between WordPress and BBPress.

Right now the latest version of BBPress is 0.9 and it can be integrated only with WordPress 2.5. Only BBPress 1.0 (which is in alpha) can be integrated with WordPress 2.7. There is an excellent tutorial by _ck_ which explains the reasons behind this and it also has a step by step guide to integrate them.

I tested this integration in my test server running PHP 5 and was able to do it within minutes. But when I tried to do it in another server running PHP 4.3.11, it was not working. After lot of head banging and hair picking, I found out that there is a bug in WordPress 2.5, which does not allow you to share the cookie with BBPress 0.9 under PHP 4.

The following is the technical detail about the bug. If you are not technically inclined, you can safely skip it. You only need to remember that you cannot integrate WordPress 2.5 and BBPress 0.9 in PHP 4, you have to use WordPress 2.5.1

Well for the brave hearts here is the explanation. ๐Ÿ™‚

In both WordPress and BBPress, the function wp_hash() is used to generate the hash, which is required to encrypt the cookie.

In WordPress 2.5, the function wp_hash() is defined in wp-includes/pluggable.php file as

function wp_hash($data) {
    $salt = wp_salt();

    if ( function_exists('hash_hmac') ) {
        return hash_hmac('md5', $data, $salt);
    } else {
        return md5($data . $salt);
    }
}

It checks whether the function hash_hmac()is present. If not it generates the hash using the function md5(). The problem is that hash_hmac() is present only in PHP 5 and WordPress includes a copy of hash_hmac() function in the wp-includes/compat.php file for backward compatibility.

But in BBPress, wp_hash() function is defined in bb-includes/pluggable.php as

function wp_hash($data) {
    $salt = wp_salt();

    return hash_hmac('md5', $data, $salt);
}

This bug is present in WordPress 2.5 and will only affect servers running PHP 4. So if you are running PHP 4 and want to integrate WordPress and BBPress, then you have to use WordPress 2.5.1 and not 2.5.

Hope this explanation saves some hair for someone somewhere, doing something similar. ๐Ÿ™‚

Posted in WordPress | Tagged , , , | 1 Comment

List of FriendFeed users who talk about WordPress

The nice folks at WPCandy have come up with a great idea to dedicate a day to thank everyone behind WordPress and also to encourage WordPress fans to blog about WordPress and share their favorite tips and tricks.

Today (July 1st ) is known as the unofficial WordPress day, where fans from all over the world can thank the people behind WordPress and also can express their love for WordPress. They are also running an event and have some nice giveaways. All you have to do is to let everyone know why you love WordPress by leaving a comment at WPCandy or write a blog post about WordPress.

So instead of writing a post explaining why and how I love WordPress (which I have already done), I thought of sharing some information which will be useful for people who are interested in WordPress. So here we go.. ๐Ÿ™‚

Sometime ago Weblog Tools Collection published a list of Twitter users whom you can follow to get updated information about WordPress.

Nowdays I use FriendFeed more than Twitter (I have to confess this sometime). So I tried to find their corresponding FriendFeed usernames so that I can subscribe to them. The following is the list with their real names first, followed by their Twitter user names and then followed by their FriendFeed usernames.

The following are some of my additions to the list which was not originally published by Weblog Tools Collection.

I will try to keep the list updated and let me know if you feel I need to add someone else to this list. Till then happy FriendFeeding and my heart felt thanks to Matt and the team for an excellent product without which this site may never exist ๐Ÿ™‚

Posted in WordPress | Tagged , , , | Leave a comment

Happy Birthday, WordPress

Today WordPress (the blogging software which I love) has turned 5. I have been running this site on WordPress for nearly two and a half years now. Thanks to Matt and the other developers for a wonderful product.

PS: Frequent readers of my blog would have noticed that I am not very active these days; things are going fast in my personal life and the posting frequency will soon be normal. ๐Ÿ™‚

Posted in WordPress | Tagged , | 5 Comments

WordPress 2.5 is out

The wait is finally over. ๐Ÿ™‚ The most waited version of WordPress, Version 2.5 is out. WordPress 2.5 was in the making for nearly 6 months now and it has lot of new features and most importantly, changes to the admin screen. You can also view the screencast discussing the new admin pages from the WordPress development blog.

I am going to update my installation now and this blog might appear clunky while I am doing that. I have installed WordPress using svn so it is just a single shell command for me to update. Thanks to Joost, I converted my installation into a svn installation when WordPress 2.2.2 was released.

By the way this will be my last post using the old admin screens, I will post my experience with the new admin screens in a couple of days. Meanwhile if you have a self-hosted WordPress blog, then I highly recommend you to update to WordPress 2.5. Happy upgrading ๐Ÿ˜‰

Posted in WordPress | Tagged , | 7 Comments

Year End Stats for 2007 (Graphs)

When I published my year end stats, little did I know that numbers alone doesn’t matter much, unless they are presented in an easily-to understand manner.

So here I am representing the same numbers but in a much more understandable manner, with some support from the excellent Google Chart API, which I learned during pipesCamp.

Number of posts

You could see that the number of posts has almost dropped by 40% in 2007. There were 64 posts in 2006 where as only 38 in 2007. One reason for this is that lot of unexpected things happened in my personal life which took me away from the computer and the other reason is that I got busy and free time became a rare commodity for me. So this is an area where I should improve.

Number of comments

Again, as with the number of posts, the number of comments was also less by around 40%. There were 394 comments in 2006 but only 220 in 2007. This also includes my own comments; maybe I should represent my comments separately.

Average number of characters in posts

This graph clearly shows that average number of characters in my posts. Even though I have written fewer posts in 2007, the average number of characters has increased, which is good (which also means that I have become very talkative ๐Ÿ˜‰ ). This is very good and is also motivating. In 2008 I should keep up the length of the posts and at the same time should also try to increase their number.

Total number of characters in posts

This graph clearly shows that even though I have written fewer posts, I have almost written the same amount of characters in 2007 when compared with 2006, which is again motivating.

I have really become addicted to stats now and will try to dig more deep into my blog to unearth other valuable information when I get some time. This explains why everybody was soo fascinated by Yuvi’s cool graphs.

Meanwhile you can also publish your yearend stats by using my Year End Stats WordPress Plugin. So what does your yearend stats speak about your blogging habit? Please leave a link to your yearend stats in the comments so that I can have a look at it.

PS: I would really love to see how Yuvi has scaled up this year. May be Yuvi, do it when you find time in between your exams.

Posted in API's/Mashup, WordPress | Tagged , , , | 2 Comments

Year End Stats for 2007

Publishing year end stats seems to be the new fashion and so here are the year end stats for my blog.

  • Total number of posts in 2007: 38 Posts
  • Total number of comments in 2007: 220 comments
  • Average length of posts in 2007: 3048.03 Letters
  • Total length of all posts in 2007: 115825 Letters

By the way this is very low when compared to my previous year (2006) stats

  • Total number of posts in 2006: 64 Posts
  • Total number of comments in 2006: 394 Comments
  • Average length of posts in 2006: 1813.16 Letters
  • Total length of all posts in 2006: 116042 Letters

I guess it is right time that I start writing more on my blog. So here goes my first resolution for the year 2008, write more in my blog. ๐Ÿ™‚

I have also created a WordPress Plugin called WP Year End stats which you can use to get stats for your blog.

Wish you all a happy new year ๐Ÿ™‚

Posted in WordPress | Tagged , , , | 5 Comments

Embedding Flickr Photos in WordPress

I found some great photos on Flickr which were taken during pipesCamp, which I attended last week. I tried to embed them in this blog, but couldn’t figure out how to do it. I have to admit that I am not a Flickr power user. I have been trying for almost an hour now and so I thought of seeking the help of my readers.

Can anyone please let me know how to get the HTML code from Flickr to embed individual photos in other websites? I don’t want to hotlink directly to the picture but want to get the HTML code like youtube. I know picasa provides this option. I could even get hold of a screenshot of the HTML embed code in Flickr, but the author is discussing about a different issue.

So any Flickr power user out there who can help me?

Meanwhile you can check out the pipesCamp photos directly from Flickr.

Posted in Events/Conferences, WordPress | Tagged , , | Leave a comment

WordPress and MySQL character encoding

Recently I moved my WordPress blog to a new server. I took the dump of the old database and imported it into the new MySQL server. Everything was fine except that I stated getting some strange characters in my posts. For instance I was getting (Nov รขโ‚ฌ” 3rd รขโ‚ฌ” 2007) instead of (Nov – 3rd – 2007).

It took me lot of research and googling to find the solution and so I thought of sharing it here so that it would be helpful for others who might face the same problem.

First I raised a support request in WordPress, but didn’t get a reply. After some googling, I found that it was due to wrong character set in my new MySQL server. Instead of having utf8 as the character set the MySQL database server was running in the default latin1 character set.

I changed the character set in the MySQL my.conf file and also in the wp-config.php file of WordPress and re imported the tables. Even this didn’t solve my problem. Later I found that there were certain characters in my wp-posts table which were encoded in latin1 character set even though the table is set to utf8 character set.

I then exported the table using a tool called Heidisql (which is by the way an excellent alternative to the command line MySQL client). I then opened the sql file in a text editor and changed all instances of latin1 to utf8 (basically a find/replace). I saved the file and imported the tables again and the junk characters are gone. ๐Ÿ™‚

So the lesson learned the harder way, KEEP EVERYTHING IN UTF-8, ABSOLUTELY EVERYWHERE, FROM DAY ONE. Youโ€™ll be glad you did some day.

Posted in Database Programming, WordPress | Tagged , , , , | 1 Comment

WordPress 2.1 – More editing options in WYSIWYG editor

Update: This blog post is outdated. Use TinyMCE Advanced WordPress Plugin instead.

Chris Kasten has found an Easter egg in WordPress 2.1 which enables many advanced buttons and options in your WYSIWYG editor. To get these advanced buttons you need to press alt-shift-v in Firefox or alt-v in IE. Pressing the same keys again hides it. Nice find right? But it will only work if you have enabled visual editor in your user profile.

After reading about it I was trying to find out whether it is possible to enable it by default. After some googling I found this thread in WordPress Support forum. To enable these advanced buttons by default, you need to fiddle with some files in the wp-includes folder. The tiny_mce_config.php file in the wp-includes\js\tinymce directory to be exact. You need to open the file directly and remove the ‘wp_adv_start‘ and ‘wp_adv_end‘ present on line 31. (Do this only if you are brave at heart ๐Ÿ˜‰ ).

When I was testing the change I noticed that WordPress 2.1 also missed the ‘Edit HTML source’ button which was available in the previous versions. This made me to search the TinyMCE documentation and there I found that TinyMCE has lot of other formatting options too. And after some fiddling I have picked up all those buttons which I may use.WordPress WYSIWYG Editor buttons

This is how my editor looks now. If you want all these options start editing your tiny_mce_config.php file or just grab my file and put it in the wp-includes\js\tinymce directory. (Be warned I am not responsible if something breaks ๐Ÿ˜‰ and don’t forget to backup your original file). Also remember that next time you update your WordPress installation this file could be over written.

The new buttons which I like are

  • Paste as simple Text
  • Plase from Word
  • Format cleaner
  • Insert Customer Character
  • Subscript, superscript

There are still some more buttons and options available and if you want to use them, then have a look at TinyMCE manual and change your config file accordingly. Meanwhile I will try to find out whether it is possible to have a WordPress plugin do it so that you don’t need to edit your file manually and till then happy hacking ๐Ÿ˜‰

Posted in WordPress | Tagged , , , | 11 Comments

WordPress 2.1 and custom field plugin Gotcha

I found a strange behavior in my blog after my recent upgrade to WordPress 2.1. Every time some one posts a comment the technorati tags for that particular posts were disappearing. After some debugging I found that it was caused by a plugin which I was using and not by WordPress itself.

And a little bit of searching let me to a thread in WordPress support forum, where some other people also were facing the same problem. With a little more digging I found an excellent explanation by Mark, where he describes the exact problem and also the solution. I am not going to explain the problem here because, Mark has already explained it in a very simple and precise manner and I don’t think I can do anything better.

The plugin which I was using to store my technorati tags was Bunny’s Technorati tags (to which I migrated some time back from Simple tags). I incorporated Mark’s fix and re-deployed the plugin and everything is working fine now.

I am going to update the plugin’s page at wp-plugin.org and meanwhile you can also bunny-tags.zip. Please note that this plugin was developed by Stephanie Booth and the full credit goes to her and I have just updated it to work with WordPress 2.1.

Let me know if you still face any issue with it. Happy upgrading ๐Ÿ˜‰

Posted in WordPress | Tagged , , , | 21 Comments