Tag Archives: wordpress

Twitter id comment field

I saw this post on problogger about how Darren implemented a new field in the comment form for his new blog about twitter tips powered by wordpress. Basically he used a plugin for adding and extra field to the comment form and then modified the comment template to show the link to the twitter profile page.

There are two problems with this approach. #1 Unlike the author name, email and web site, the twitter id field is not saved in a cookie so your comentators will have to fill it in every time they post a comment, this migh be annoying for some of them. the second problem is that if you're logged in and want to reply to a comment there's no way you can set the twitter id.

The first problem was almost solved by a new plugin named wp-twitip-id by Andy Baily specially created for setting up the twitter id field. I said almost solved because this plugin uses javascript to add the new field and in some cases ( depending on the template you are using ) javascript would not be the best way to do this.

Luckily you can use this plugin without javascript and add the new field manually by modifying the comments.php template file but then the cookie would not work anymore so it needs some modification to set the cookie from the php script instead of javascript .

Simply calling setcookie before the comment is saved will do the work, then when you display the form field just use $_COOKIE['atf_cookie'] to set the value of the twitter field.

If you like to modify some plugin code get the wp-twitip-id plugin, open wp-twitip-id.php look for addtwitterfieldmeta function and add

  1. span style="color: #ff0000;">'atf_cookie'

right after the line with this code: 'if($twitter){'

Then go into wp-content/themes/<yout_theme>/ edit comments.php  look for the URL field and add a new field after it like this:

<input name="atf_twitter_id" type="text" value="<?php echo $_COOKIE['atf_cookie']?>" />

You might have to add some other html code and css to make the field look like the others but that depends on the theme you are using.

For convenience I have attached the modified plugin but you still have to modify the comments.php file in your theme.
wp-twitip-id-091

Let me know how this works for you. Do you think the twitter id comment field is worth the effort ? Does it bring value to you it as a commentator?

wordpress 2.5.1

I have just upgraded to wordpress 2.5.1. My upgrade routine worked well without any problem.

The new release seems to bring a few bug fixes to  some annoying issues and a security fix as well as some performance enhancements.

Unfortunately the automatic plugin updater still fails at times and doesn't save the ftp password and the media uploader still renames .tar.gz files in a stupid way.

Upgraded wordpress to 2.5

I have finally upgraded wordpress to 2.5.

The old version was 2.3.1 ( yeah that old ) and the upgrade was pretty smooth.  I didn't use plugins like instant upgrade for this upgrade but I'm thinking of using for the next upgrades.

How did I do it?

I have my own method for this. It's very similar to what they descibe in the official upgrade docs but a bit modified.

Here are the 7 steps I followed:

  1. backup the database using the backup plugin
  2. remember ( write a list of) active plugins then deactivate all ( so if any plugin will not work in the new version you can still access the blog and the admin interface )
  3. make a backup of all files ( assuming current install is in public_html ):
    1.  
  4. download and extract the new version ( it will create a wordpress folder so make sure you don't already have one cause it will overwrite the files in it ) :
    1.  
  5. use rsync to copy the new files over the old files ( note the exclusion of wp-content to preserve the modifications you might have done to themes and plugins ) :
    1.  
  6. call the upgrade.php script, go to : http://your_own_blog.tld/upgrade.php
  7. reactivate the plugins you had active before the upgrade

The whole thing took about 10 minutes and there were no problems encountered except for a few plugins that could not be reactivated because they were incompatible with the new version.

What I like about it?

I like the new interface,it seems friendlier, faster, more slick and  I was getting  bored of the old one.

I don't care much about the dashboard, but I love the way the WYSIWYG editor works.

I think the feature that I love the most is the automatic plugin upgrade but this is also the one that I think it needs more work ( of course there may be others that I did not notice yet )

what id didn't like?

Here are three problems I found with the automatic plugin upgrade:

  1. the first time I tired it id didn't seem to care that I selected "No" for the "Use SSL" option and it just told me it could not connect.
    This was because my ftp server did not have ssl enabled but it was impossible to know this was the cause because it was clear to me from the web interface that it was not using SSL until I went in the code and just run a print_r on the $credentials variable .
    I'm not sure why this happened, I guess a bug. I had to go into the database and manually edit the ftp_credentials option and set ssl to 0 and then the plugin upgrade worked.
  2. It doesn't remember the value of the "Use SSL" option. After I go in to upgrade another plugin the option is set to "yes" even thou in the database it is 0.
  3. it removes the old plugin first and then tries to install the other. If the new version install doesn't work for some reason you are left with no plugin and you will have to go in and install manually the old way. I think a bettwe approach would be to first deactivate the old plugin, make a backup copy, try to install the new one and if it doesn't work restore the old plugin.

Conclusions

Overall wp 2.5 brings good improvements and great new features but as with any new major version increase there are a few minor details not taken good care of. Waiting to see what the 2.5.1 version wil bring on he bug fixing side.

Have you upgraded yet?  what are your thoughts on the 2.5 version ?

Hidden Affiliate Links WordPress Plugin

There is a new version of this plugin. Please download it from the plugin page

This post is about a wordpress plugin that will help you to manage your hidden affiliate links a lot easier then what others have suggested.

If you don't know why you should hide the affiliate links then continue reading, but if you already know this then skip to the plugin part of the post.

One of the best monetization methods for blogs is using affiliate programs.Money making blogs don't get their income from a single source like adsense, they also use affiliate links for a lot of services like Text Link Ads and other products.

Why hide your affiliate links?

Many bloggers think it's good to hide the affiliate links, not because they don't want their visitors to know they are affiliated but because of other reasons like:

  • Changing your affiliate links is a lot less work because you have to change in just one place then on hundreds of pages where you use those links
  • It hides the ugly part of affiliate codes. People tend to not trust long links with a lot of characters and unknown codes. A nicely formated and clean link is more likely to be clicked then one that contains an affiliate code in it.
  • It kind of forces them to click the link instead of just typing the link (without your affiliate code ) in the browser.
  • better SEO, the links don't look like affiliate links, the redirect is done from a html page that has noindex on it so search engines shouldn't look at it.

Methods to hide Affiliate links

There are a lot of methods to do this like:

  • writing a .htaccess rule
  • doing a http redirect from a script. Setting the HTTP location header to the destination url.
  • doing a redirect from the meta of a html page
  • doing a redirect from javascript by setting the window.location to the destination URL

Those methods are not hard to use but they do involve write a small piece of code and require this for each affiliate link. I will not show you in details any of those methods because there's a better, easier way to do this.

My Method to hide affiliate links

I wrote a plugin for wordpress that will let you define such redirects from a nice (AJAXy ) web interface inside your wordpress admin.

The plugin installs just like any other wordpress plugin and once installed you can start defining your affiliate link without having to write any code.

The plugin uses a meta and javascript redirect inspired by a post on John Chow dot Com about hiding affiliate links for better seo

License

The plugin is released under GPL and the usual "No Warranty" disclaimer applies

Download

Hidden affiliate links v0.1.zip
Hidden affiliate links v0.1.tar.gz

Installation

The script was tested on wordpress 2.2.3, so it you use any other version and it doesn't work let me know about and problems and I'll try to write a fix. If you use a previous version you should really upgrade to the latest version of wordpress.
Copy hidden-affiliate-links.zip and unzip or copy hidden-affiliate-links folder in wp-content/plugins then go to wp-admin -> Plugins and activate the Hidden Affiliate Links plugin

Using the plugin

After you activate the plugin you can go to wp-admin -> Manage -> Hidden Affiliate Links and add/edit/delete hidden affiliate links. For each link you have to define a slug, a destination link/code and a description.Manage Hidden Affiliate Links

The "slug" is what the link looks like on your blog, the link/code is the part where the visitor will be redirected and the description is something to remind you what's this link about, but it's also used in the title of the page that's doing the redirect ( in case the redirect does not succeed ).

For example if the slug is go/tla and the link/code is my affiliate link for Text Link Ads http://tinyurl.com/2kasce then if you write a post on your blog and you use a link like http://patchlog.com/go/tla in your post, anyone that clicks that link will be redirected to http://tinyurl.com/2kasce

Why link/code and not just Link? In case you want to hide an affiliate link where you cannot just do a redirect, like adsense referral links that are generated by javascript, then you will have to put the javascript instead of the link.
Because you cannot redirect to a link that is generated by javascript ( because there's no link until the javascript executes ) you'll have to redirect to a page where the javascript is inserted and will execute to generate the link. In this case the user will have to actually click the generated link. So if you put anything else then a link ( starting with http or https ) in the link/code box then the script will think this is a code and will not try to redirect to the code but to a page containing the code. You can customize the look of that page by modifying : redirect_code.php

In case the redirect does no succeed for some reason then you will see a page with the affiliate link in it and the title of the page will be the one specified in the description for the link. You can also customize that page by modifying: redirect_link.php

Advanced Feature

The script is very easy to use but if you want some power and you have some knowledge of writing regular expressions then here's how you can use it. The slug part can be any regex, and anything that will match that regular expression will be redirected to the real affiliate link.

For example I could make the slug like this: (.+)/tla and everything that ends in /tla like http://patchlog.com/go-to/tla or http://patchlog.com/recommended/tla, would be redirected to my text-link ads affiliate link. Or something like go/(tla|text-link-ads) would match both links like http://patchlog.com/go/tla and http://patchlog.com/go/text-link-ads

I hope you like the plugin and let me know of any questions or problems you might have. Feedback is highly appreciated in the comments section of this post.

If you like the plugin you might want to subscribe to my full RSS feed, other great plugins might be on the way.

Update:

there's a new version that can also automatically replace keywords you define with hidden affiliate links Click here to get it.

About me update

The first thing I did when I started this blog was to look for plugins to give wordpress more functionality and then I started writing posts.

I'm still looking for cool plugins and sometimes write my owns and from time to time I still write on the blog ( not as much as I would like to  because I don't have the time ).

Since  January when I started the blog I have written 73 posts ( this one included ), an average of about 2 posts per week.  Many of this blog's visitors (more then 50% ) come from search engines, looking for a solution to some problem they have, others come from blogs that have linked to me or where I have commented .  The blog gets about 100 visits/day. That's not much comparing to other blogs that get thousands but I thought some of those visitors might want to know who I am so I thought I should write something about that on my "About page"

I didn't  put anything on that page when I started the blog , I just left the default text that came with wordpress.  Many high profile bloggers say it is important for people to know you ( this is a blog after all, and the blog should have something to do with it's author ) and an "about page" is a good way to start.

I didn't think that it was that important because at the beginning I didn't think the blog will have many visitors and I'm not even sure it's purpose was to get visitors or that they would want to know who writes the blog.

Anyway, now it's there so you can take a look if you are interested, there's not much about me, but I will be updating it with more details when I (or you the reader ) think it is necessary.

What do you think about it ? Do you have an "about me" page ?

Sidebar decluttering

A few days ago I came across a post at Problogger.net where Darren Rowse suggested bloggers should de clutter the sidebar of their blogs.

I looked at my sidebar and I saw what he meant by clutter. Darren could have used my sidebar as an example of a cluttered sidebar.

The sidebar was full of widgets that were not really useful to me or to my visitors. Here is what I had and removed:

  • Most popular Posts: I removed this because I didn't think it was really useful for my visitors. A lot of them come from a search engine and look for something specific. I don't think they are interested in what's popular on my blog, but I might be wrong about it and I might add it back in the future, maybe on the footer.
  • Tag cloud: this one was getting too big. I occupied too much space and the most popular tags were already the words in categories to it was kind of redundant. I might add this on a page of it's own
  • Top commentators: I removed this because it looks bad to see a list of top commentators where #1 has only 3 comments.
  • Technorati fave this blog: removed because I already have a technorati button at the bottom of each post
  • Google Referrals banners: The banners increased the load times and were not making money. I may add them back as links like this :
    because I see some potential in this but I'll have to get more traffic before I start using it again
  • Text link adds affiliate banner: In two months of using this I got about 80 clicks on it and no conversions. But the text link ads is reported to be one of the best affiliate program. They give you $25 for signing up an active publisher or advertiser
  • Reviewme banner: removed because I received no offer for a review since I started using it a few months ago. I guess no one wants me to review a patch 🙂
  • WordPress meta: does anyone care about this ?
  • DoFollow: This doesn't really have anything to do with the sidebar but I removed this plugin because it was pretty much useless. I don't think anyone that commented on my posts did it because of the dofollow plugin. The only ones that commented because of dofollow were those that commented on the post about dofollow. The idea to reward your commentators is good but if there isn't anyone ( or very few ) to reward the plugin is useless. Also I think the Top commentators plugin might be better for this.

Some thoughts about what I should do, but I'm not sure about this yet:

  • move archives and maybe categories in the footer
  • add most popular posts in the footer
  • remove google ads, I this I can afford losing about $2/month 🙂
  • remove kontera
  • create a top navigation bar and move the links to pages on that bar

What do you think I should do about the blog ? Any suggestions are welcome in the comments.

More optimization for comment relish plugin

In my previous post about optimizing the comment relish plugin I managed to lower the load generated by the comment relish plugin on the database server by adding an index on a column in the cr_emailed table and by optimizing a query ( basically removing a "useless?" join ). This improved the load time a lot but some users still reported slow load times on blogs with a lot of comments.

Looking more over the source code I realized that the function that tried to find new commentators was executed on each page. This function was executing a mysql query that joined two tables wp_comments and wp_cr_emailed. I think you can imagine the result of this on blogs with a large number of comments.

The solution was to execute this function only when a new comment was posted. And this comes with two benefits:

  1. because this is called only when a new comment is posted ( or approved ) the rest of the blog will remain as fast as before the plugin was installed.
  2. because of the way we call the function ( as an action/hook associated with the code that processes the comments ) we have more information about the comment so we don't have to do the query where we join two tables. We still do one query to get the whole comment data and one to see if this is a new commentator ( not emailed yet ) but these use indexes and are really fast.

Get the new optimized plugin here and let me know how it works for you.

Update:

the plugin link above contains a plugin that tries to send email even when the blog receives a pingback or trackback as reported by Rhys. I have uploaded another version that corrects this problem here: [download id="9" format="1"]

Comment relish optimization

Comment Relish is a wordpress plugin that sends an email the first time someone comments on your blog. The plugin allows you to define the message in wp-admin and you can embed tags like author's name, email, website and others in the message.

This can be used to send a welcome message to the first time commentators and maybe invite them to subscribe to your rss feed.

The Problem

John Chow, tried to use it on his blog but the plugin and his huge number of comments ( 43000 ? ) put the site down for about 2 hours. He said the plugin misbehaved and he would not recommend it if you have a lot of comments.

I did a little simulation on a wordpres blog with about 25000 comments and I can see how the plugin misbehaves :). It took more then tho minutes to select the email addresses that should be emailed before I decided to stop it, because that's just unacceptable, but I think it would have taken a lot more.

I managed to optimize it easily by just modifying a field in the table used by this plugin. If you don't care how I did it and just want the optimized plugin skip to the end of the post. If not then read on...

How it works

The plugin uses a table ( cr_emailed ) to remember which addresses received an email, so that it does not send a message more then once. Basically the plugin just inserts a new record in this table every time someone new comments on the blog. It tries to see if someone is new by doing a LEFT JOIN select on two tables: comments and cr_emailed, and then filters the results that have cr_emailed.email = NULL. The problem with this is that the email column has no index so if you have 43000 comments the query will have a huge result set and mysql will have to process each result to find out if cr_emailed.email is null ( the email has not received a message yet ) .

The solution

This was really simple, just convert the email field to a varchar ( needed in order to be able to set a fixed length key on this field ) and then add an index on it.

After doing this the query that took more then two minutes, now takes a little less then 1 second.

Some one on John Chow's blog suggested to add an index to wp_comments.comment_author_email. I tried that but I noticed no improvements, and using explain on the sql query shows the index on comment_author_email is not used, so that's useless.

Looking more over the code I noticed another weird thing. The query executed to find the email addresses looks like this:

  1. span style="color: #ff0000;">'1'

I wonder why the author used the posts table in this query? The results from the posts table are not used anywhere in the code. I really couldn't see a good reason for keeping the posts table in this query so I removed the posts table from this query, making it even faster.

Get the source code

Here is a diff file between my version and the original version and here is a my new version . If you have this plugin already installed you have to uninstall it and remove the wp_cr_emailed table and then copy the new version and activate it in wp-admin.

I'm using the new version on this blog and is working but I have few comments here. I have only tested the modifications on this blog and on a fictional blog with 25000 automatically generated comments so the usual disclaimer applies... you know all that "WARNING NO WARRANTIES" stuff...

If you have a blog with many comments and you want to try this, let me know how it works in a real environment.

Stop playing with page titles

This is more like a reminder to me then an advice for others to follow. It reminds me that I should stop playing with page titles and get them right from the beginning.

WordPress default post titles

When I first started this blog using wordpress the default template had something like "Patchlog ›› Blog Archive ›› Post name" for the post titles.

That's really not good for search engines. Having that "Patchlog ›› Blog Archive" in front of every post title is looking like all posts have the same title to a search engine because they only consider a small number of characters from the title when they index your pages, and because the part that makes them different is in the end it may not be considered or may not show up in results.

The first change and the imediat result
By the time I finally decided to change this, google had already indexed all my pages with the wrong titles. After I changed it google started to re-index everything because it thought that everything changed ( see how important the page title is ? 🙂 )

That was all fine but because it started to re-index my posts were not showing anymore in google results for relevant keywords until it finished the re-index.So during that time the traffic decreased till my posts were back in it's database with the new titles.

The second change

The only problem is that I did not get the page titles right so I had to change them again after the site was already re-indexed and I'm back in the dark on google.

Take for example my post about making squid 2.6 transparent proxy to work if you are used to squid 2.5 config. That post got more then 400 visits from people searching for squid 2.6 transparent or phrases containing squid 2.6 or transparent or proxy last month. This month got around 100 and I think that was in the beginning of the month before I did the second round of changes to my page titles because I did not notice any increase on those numbers in the last week.

So if you want to change something as important as your page / post titles and you know it will affect all the pages on your site, think twice before applying the changes to make sure you get it right the first time.

Full Feeds

I just enabled full text feeds on this blog so now you can subscribe to my feeds and read full articles from  the comfort of your feed reader 🙂 .

I'm using the <!--more--> tag on some articles and because wordpress 2.1 also splits the feeds when it finds the more tag I had to install the Full Text Feeds plugin created by Ronald Heft.

There are some other methods to do this presented by Kevin Muldon on his How to use the more tag and display the full content in your RSS Feed  post.