Skip to content

Fixes for Popularity Contest

Popularity Contest - is a comfortable and long-used plugin for WordPress, which allows to create the rating of blog entries on the basis of various parameters (such as number of views, comments, pings, hits from search engines, etc.).

Unfortunately its latest version 2.0 beta 2 has been released more than a year ago and still has several bugs preventing the full functionality of the plugin. Here are fixes for two such bugs.

The first, widely known, - the following error message is issued when you trying to reset the number of comments, pings and trackbacks:

Catchable fatal error: Object of class stdClass could not be converted to string in /path/to/popularity-contest.php on line 539

To fix it, you need to replace


$this->populate_post_data($post_id);

by


$this->populate_post_data($post_id->ID);

at 772th line (this is in recount_feedback() function, in a case you're using other version of the plugin).

The second bug is that the hits from search engines aren't counted when Ajax API is used for statistic updates (it's enabled by default). To fix it, you need to replace


else if (($api && in_array($type, array('single', 'page'))) || is_single() || is_singular() || is_page()) {

by


else if (($api && in_array($type, array('single', 'page', 'searcher'))) || is_single() || is_singular() || is_page()) {

at 660th line (in the record_view() function).

There is also an inconvenience with search engine hits counting linked with 50 char limit for the length of the parameter settings of this plugin written to the database, i.e. your list of search engines written in a row can't exceed the 50 characters (any excess will be cut silently). Therefore, I would recommend such a list: [www.google.com www.google.ru yandex.ru go.mail.ru] (for using in the Runet, Russian part of the Internet).

Leave a Reply

Your email address will not be published.