Martial Development

Martial arts for personal development

Fixing a Popularity Contest v1.1 Plugin Bug

Tags:
4 Comments

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]

Categories: Blogging

4 responses so far ↓

  • 1 wujimon // Oct 16, 2006

    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.

  • 2 Chris // Oct 16, 2006

    Thanks for the tip. I saw no mention of a bug fix on Alex King’s website.

  • 3 wujimon // Oct 17, 2006

    Hi Chris. It’s hidden in his referenced support thread. Took me a while to find.

  • 4 m0n // Nov 23, 2006

    Thank you for sharing this — worked like a charm!

Leave a Comment

Highlighted fields are required; others are optional. Gravatars are enabled.

Supported HTML Tags: <blockquote> <b> <i>