Fixing a Popularity Contest v1.1 Plugin Bug

The Popular Articles section in the right column of this page is automatically inserted by the Popularity Contest plugin for WordPress.  Unfortunately, the current version of this plugin (1.1) is not completely compatible with my version of WordPress (2.0.2).  As a result, page views are not counted properly.

The bug is related to the plugin’s use of the is_admin_page() function.  It was intended to distinguish post editing from normal viewing, and prevent incrementing the of view count during editing.  Actually, it prevents any counting whatsoever.

Here is my hack to fix the problem:

  1. Sign-in to the WordPress Administration Panel.
  2. Open the Plugin Editor in the Plugins tab.
  3. Select Popularity Contest from the list of Plugin files.
  4. Find this code within the record_view() function:

    if (!isset($posts) || !is_array($posts) || count($posts) == 0 || is_admin_page()) { return; }

  5. Replace that code with:

    if (!isset($posts) || !is_array($posts) || count($posts) == 0 || is_user_logged_in()) { return; }

  6. Save the updated plugin code.

This may not be the cleanest solution to the underlying problem, but it works; page views are now counted properly.

As a blog reader, this change probably means nothing to you.  If you are a blog owner yourself, you might want to check whether your stats plugins are working as intended.

[tags]wordpress, blogging[/tags]

4 thoughts on “Fixing a Popularity Contest v1.1 Plugin Bug”

  1. Alternatively, you could download the latest version of the plugin from the code repository, upload, disable/enable the plugin. That’s what I did and it worked for me.

Leave a Reply

Your email address will not be published.