Category Archives: WordPress

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

Developing WordPress Plugins in Github

As most of you know, I actively develop and main more than 20 WordPress Plugins. All of them are hosted in the official WordPress Plugin repository.

Until recently I was using the official WordPress repository’s svn to do the development. All my non-WordPress pet projects are hosted in my github account.

I was thinking of moving all my WordPress Plugins to github for quite sometime now, but didn’t do it thinking that it might involve huge effort to keep both the repos in sync.

After reading about how a couple of people moved (and didn’t face much problem afterwards), I decided to try it out for a couple of my Plugins. The following is what I did and in the end, figured out that it was worth the effort.

Github – more than just code

To be fair to official WordPress Plugin repository, there is nothing anything wrong with the way it works or with svn.

It is just that github as a platform is more suited if you are interested in collaboration and receiving contributions from users. It reduces the barrier to entry for people to contribute to projects and also it provides enough tools for project owners to easily merge (or reject) contributions from users.

I was more interested in this aspect of github rather than the ‘git’ part.

Using github for hosting WordPress Plugins

When I decided to move from svn to github, I wanted to do the following things.

  • I wanted to maintain the entire check-in history from svn. Some of my Plugins are more than 4 years old and have gone through lot of revisions and I didn’t wanted to loose them.
  • I also wanted to do the development in github (read doing atomic check-ins) and then upload to WordPress repository only when I tag the changes for release after testing them.
  • I also didn’t wanted to manually check-in in both the places to do the sync.

For the first I found that git-svn can fetch all the check-in history.

For the second and third point, keeping pragmatism in mind, I ended up creating shell scripts so that I don’t have to do anything manual.

Automation scripts

You can get the scripts that I wrote from my github account. The project consists of two scripts.

  • clone-from-svn-to-git.sh – Use this script to clone your WordPress Plugins from SVN into git/github
  • deploy-plugin.sh – Use this script to push your WordPress Plugin updates to SVN from gi/github

Right now the documentation is pretty sparse. I will fix it when I get some free time 🙂

Things to improve

The scripts pretty much do the job. Going forward, I want to improve the following to make it more useful.

  • The readme.txt file used by WordPress repository is not fully in markdown. Because of which the readme file displayed in github is slightly broken.
  • Ability to auto update the .pot file before releasing the new version
  • WordPress repository allows you to add a banner using the assests/ directory. Need to add support for that.

Update: All the above features are added. Check out the latest code in github.

Is it worth the effort?

So far I have moved the following Plugins to github. Will be moving the other ones as well when even I get some free time.

So now the real question. Is it worth the effort? It is worth every second that I spent on it.

You should check the pull requests I have received so far. I have received more contributions to my Plugins in the last couple of weeks than the last 5 years 🙂

If you are a WordPress Plugin developer, then try out my script and let me know if you have any feedback.

Posted in WordPress | Tagged , , , , | 8 Comments

Writing efficient JavaScript for V8

Daniel Clifford from the V8 team, gave a presentation in Google I/O 2012 about optimizing JavaScript for V8 to make it run faster. I am posting notes which I took while watching the video, so that I can refer to them at a later point of time (It is easier to search when it is not on paper 🙂 ). Also it might help someone to get the outline of the talk before actually watching the video. The original video runs for about 45 minutes.

Also be warned that the following is my own interpretation of the video and I might have missed or could have interpreted some point differently 🙂

Breaking the JavaScript speed limit for V8

The talk was basically built on the premises that if you understand how V8 compiles and optimizes your JavaScript code then you can write efficient JavaScript code (at least for V8). Daniel explained a few optimization techniques that V8 uses and also gave suggestions for writing JavaScript code that will make use of these optimization techniques employed by V8.

I am not going to get into the details of these optimization techniques, but just going to give the list the suggestions.

Classes

V8 internally creates hidden classes for each JavaScript object at runtime. Objects with the same hidden class can use the same optimized generated code. So the suggestions are

  • Initialize all object members in the constructor functions
  • Initialize all object members in the same order.
  • Avoid adding new properties at runtime

Code sample

Numbers

V8 internally uses 31 bit signed integers (refer to the video for the full explanation). So the suggestion is

  • Prefer numeric values that can be represented as 31 bit signed integers

Arrays

V8 uses two types of objects to represent arrays

  • Fast Elements – linear storage for compact key sets
  • Dict Elements – hash table storage.

Out of these two, Fast Elements are generally preferred. So the suggestions are

  • Use contiguous keys starting at 0 for arrays
  • Don’t pre-allocate large arrays, instead grow them
  • Don’t delete elements in an array if possible
  • Don’t load uninitialized or deleted elements
  • Use array literals instead for small fixed arrays
  • Preallocate small arrays to correct size before using them
  • Don’t store non-numeric values (objects) in numeric arrays

Code sample

Other suggestions

  • Prefer monomorphic operations over polymorphic operations
  • Don’t have performance sensitive code inside a try..catch block. Instead use a separate function and then enclose the function inside try..catch block.

Some V8 logging commands

Video

And finally here is the full video.

So my dear readers what you think about my notes. Also let me know if you like notes for videos in this format. If there is a demand, then I can post some of my notes on other videos which I have already viewed.

Links

Posted in WordPress | Tagged | 2 Comments

Started tracking time spend on my pet projects

Regular readers of my blog will know that I have lot of pet projects. WordPress Plugins, Android Apps, Arduino projects, jQuery Plugins and a whole variety of other hobbies as well.

Some of them are really popular. For instance my Bulk Delete WordPress Plugin has been downloaded for nearly 100,000 times. The flip side of it is that these pet projects have some additional baggage as well. Support questions, regular updates, feature requests etc can be sometimes very time consuming.

I always wanted to know the projects, which takes up most of my free time, but didn’t had any metrics or logs. So I have started to track the amount of time I am spending on each of these projects.

The advantage of this is that, now I know which project are real time hogs and can have some metrics to decide on whether it is worth spending time on those projects or not. I am also going to add this data to the project readme files, so that people who use it might also know the amount of time and effort I have put it on those projects 🙂

I have already started this and the recent release of my Bulk Delete WordPress Plugin had this metrics. I have spent close to 11 hours for releasing the update to the Plugin.

Let’s see how this new experiment turns out to be.

BTW do you guys also track your time spent on pet projects? If yes, then share your experiences as well.

 

Posted in Random/Personal, WordPress | Tagged , , | 3 Comments

Phishing attempts to get your wordpress.org password

Recently, I received an email, claiming to be from WordPress.org, notifying that one of my Plugins have been taken down. It also provided a link where I was supposed to check the status of my Plugin. Clicking on this link took me to a website which looked like wordpress.org and was asking for my username and password.

Even though it looked like a WordPress.org website, the url was different. I posted about it the wp-hackers mailing list and got the confirmation that is a phishing attempt to get your WordPress.org username and password.

If you get an email like below, be careful and don’t click the link or enter your username and password.

wordpress.org-phishing-attempt-email

In addition follow the following steps to make sure you don’t compromise your account.

  • Check the sending email address. It will always have a wordpress.org email address
  • Check if the link text and the actual link are different.
  • Make sure that the url of the page where you enter your password is always wordpress.org

You can also find more information about it from this forum thread.

WordPress.org has also sent the following email to all the Plugin developers regarding this issue.

wordpress.org-email-png

Be vigilant and stay safe.

Posted in WordPress | Tagged , , , | 4 Comments

Fixing WordPress Feed timeout issues

Recently I got an email from my friend Sudheer, saying that the feedburner feed of my blog is not working. I thought it might be some small issue, but it took me more than a couple of hours to fix it. As usual, I thought of documenting it since it was an interesting problem and also someone who has the same problem might also find it useful.

WordPress feed timeout

I started the debug process by logging into Feedburner dashboard. Feedburner reported that it is not able to fetch my blog’s feed url. When I tried to open the feed url directly in browser it was loading, but it took a couple of minutes for WordPress to generate it. But both feedvalidator and feedburner said that the feed times out.

My website was loading properly and my error log was empty. I tried lot of different things but was not able to figure out why the feed was timing out.

Increasing memory used by WordPress

After a couple of web searches, I landed on a old forum thread, which stated that we should try to increase the amount of memory used by WordPress. I tried doing that as well, but it didn’t make difference 🙁

Reducing post count in feed

Then I tried to reduce the number of recent items that were shown in my feed to 10 from the default value of 25. The feed was getting generated in some decent time and was able to let feedburner pick up my feed. But it still didn’t solve my original issue.

Unoptimized Plugin

After some more debugging, I found the root cause of the issue. An unoptimized Plugin was the real culprit.

I was using github’s gist to store the code samples that I use in my blog posts and used a Plugin to embed the code directly from github. The advantage of this approach is that, there is one centralized repository for my code samples with versioning and also github provides nice syntax highlighting.

The Plugin was making curl request to github to retrieve the code sample and it so happened that most of my last 25 blog posts had code samples and some blog posts even had around three code embeds.

The problem with the Plugin was that, it was not using WordPress’s built-in HTTP request object and also it was not caching any of the response that it got from the curl request. I quickly rewrote the Plugin and WordPress was immediately able to serve the feed in less than a second. (Will be releasing the Plugin pretty soon) Update: You can find the Plugin in its homepage

Solution

So if you are also facing timeout issues with your WordPress feed, then try the following

  • Try increasing the memory used by WordPress
  • Try reducing the number of blog posts that are disabled in your feed.
  • If nothing works, then it’s mostly because of some unoptimized Plugin.

Posted in WordPress | Tagged , , , , | 4 Comments

Changed the permalink structure of my blog

Well, after wanting to do it for many years, I have finally bitten the bullet and have changed the permalink structure of the posts in my blog.

When I moved from blogspot to WordPress, (some 6 years ago) I retained the structure of the blog posts to the usual year/month/date/postname format. But later, I realized that this results in long urls and also these days the date is not adding any additional information to the blog posts.

I have been thinking of changing the permalink structure to the shorter /postname format for quite some time now, but was always worried about setting up the proper 301 redirects.

But at last I did it today, with just one line in my .htaccess file, which looks something like this.

So if you are planning to change your permalink structure then follow these steps.

  • Disable caching. (If you using Plugins like wp-super-cache etc.)
  • Add the above line to your .htaccess file
  • Change the permalink structure
  • Re enable cache

And you are done. 🙂

If you want you can also create a new sitemap.xml file which could speed up the index update by Google.

Posted in WordPress | Tagged | 1 Comment

RoloPress 1.5 released

We just released an update to RoloPress, a WordPress-based contact manager which is one of my pet projects.

Enhancements

There were lot of enhancements that went into this release. The following are some of the notable ones.

  • Tags are now supported on the front-end, including inline editing
  • Moved over to WordPress settings API.
  • Consolidated settings area for better admin navigation.

You can read the complete list in the announcement blog post.

Fixes

This release also includes couple of bug fixes which were reported in the forums. Notable among them are

  • “Recent Notes” works better.
  • Phone number / IM field deletion on edit has been fixed.

Plugins

This release also has a couple of Plugins added to the core, which can be activated separately.

  1. RoloPress Import: probably our most requested feature.  You can now import any Outlook CSV file into RoloPress.  We choose Outlook CSV because most contact managers allow you to export in this format.
  2. Google Maps for RoloPress: View a google map of any address in RoloPress. You can see an example on demo.rolopress.com.

Third developer

Another important milestone of this release is that, this release includes code from a third developer apart from me and Steve. The third developer is Mike Whitfield, who contributed the front-end tag editing code. Welcome Mike 🙂

Download

You can download the latest version from the homepage and if you are interested, you can check out the source code at github.

Try it out and if you have any feedback, please post it here or in the forums.

Posted in WordPress | Tagged , | 2 Comments

RoloPress 1.4 with drag-n-drop menu support

Just released an update to RoloPress, a WordPress-based contact manager which is one of my pet projects.

The main enhancement that went into this release is that, we have changed the default menu with the super cool drag-n-drop menu which was introduced in WordPress 3.0. Try it out and you will surely like it.

In addition to this, there are also other enhancements and bug fixes which went into this release. You can read the full list in the official announcement page.

You can download the latest version from the homepage and if you are interested, you can check out the source code at github.

Try it out and if you have any feedback, please post it here or in the forums.

PS: While you are at it also checkout the excellent review of RoloPress by John Hawkins.

Posted in WordPress | Tagged , | 3 Comments

RoloPress 1.3

Just released an update to RoloPress, a WordPress-based contact manager which is one of my pet projects.

The new release has compatibility fixes for WordPress 3.0, in addition to some bug fixes. If you are using WordPress 3.0, then it is a mandatory update.

You can download the latest version from the homepage and if you are interested, you can check out the source code at github.

Try it out and if you have any feedback, please post it here or in the forums.

Posted in WordPress | Tagged , | 2 Comments

Bright Light, a free WordPress theme

After promising a couple of times, I have finally found time to clean up the files and release the theme which I am using for my blog.

Right now I have uploaded the theme to my github page and you can find more information about using it from the theme’s homepage.

I have to clean up the files a bit more before I could upload them to the WordPress official theme directory. Till then you may have to download it from the theme’s homepage.

Features

The following are the some of the features of the theme

  • Two columns
  • Fluid width
  • Custom top navigation
  • Built-in support for social icons
  • Widgetized sidebar
  • Widgetized footer
  • Easy integration with couple of Plugins

Licence

The theme is released under GPL. Feel free to use or modify it as long as you can keep the link back to this page in the footer. If you cannot place the link (for instance on internal projects) and would still like to use the theme, then contact me and we can see what can be done.

Feedback

If you have any comments or if you want to report any bugs, please leave a comment below or contact me.

Posted in WordPress | Tagged , , , | 4 Comments