- Michael Barton |
- Web Development, Wordpress |
- October 28th, 2010
I recently added live chat to my site in hopes of helping my readers and picking up more business. Adding live chat is easy when you use a service. I’m using Olark. They offer different plans, depending on your budget; I’m using their free version.
When implementing the code, I had a few different, easy to implement, options:
- Copy and paste the code, as is, without change (most slackers do it this way).
- Put the code in a theme function with a descriptive function name using the wp_footer hook.
- Put the code in a plugin, existing or new, using the wp_footer hook.
I’m sure the quickest and easiest way would have been to use option #1. It’s easy to implement and it takes 2 seconds. Right? Well, here’s my problem with that approach. You have ugly, loose code in your theme. That right there should scare you away from that approach; however, your average developer will do it this way. It’s sad, really. What you need to understand is that being a good developer does not necessarily imply that you’re the fastest. Remember the story about the tortoise and the hare? This approach is horrible. Having un-organized code just laying around is bad. What happens when you need to make changes? What happens when you forget what the hell that code is? Forgive my cursing, sometimes I forget where I am.
The second approach is better; however, what happens down the line when you need to change the theme and you want to keep live chat on your site? You’d have to move the code over to the new theme.





