[Hack] How to use Stats Helper beside Jetpack. (4 posts)

  1. InvinciP
    Posted 5 years ago #

    Here is a small hack to use WordPress Stats Helper beside Jetpack. Everyone knows that: once Jetpack is installed, WordPress Stats will automatically be disabled. The WordPress Stats Helper check the existence of some functions of the WordPress Stats plugin to determine whether it is turning on or off. So if the Stats is disabled, the Stats Helper can not function too. But there's a small hack to bypass the checking procedure. I will show you how now:

    • Open the file wpcomstats-helper.php under wp-content/plugins/wordpresscom-stats-helper/
    • Go to the code block: function wpcomstats_api_key()
    • Comment out some lines and manually add your api-key like this:
      // Check if worpress.com stats plugin is installed
      //	if (!function_exists('stats_get_api_key') || //!function_exists('stats_get_option')) {
      //		echo 'WordPress.com stats not installed!';
      //		return null;
      //	}
      	// Check if the API key is defined
      //	$api_key = stats_get_api_key();
      $api_key = "your_own_api_key";
      	if (empty($api_key)) {
      		echo 'API Key not defined!';
      		return null;
      	return $api_key;

    (double-check again to make sure you have done correctly, because if there's something wrong, it will break some parts of your site)
    Assumed that you've known how to get api key. Now the api key for wordpress and akismet are the same thanks to automattic. ;))
    Because the fetching data function of Stats Helper is independent from Stats, so you don't have to worried where the data will come from.
    Aah, and don't forget to enable your Stats Helper plugin after doing everything I've shown you. Good luck!

  2. krunk
    Posted 5 years ago #

    Thanks for the suggested fix, but although it doesn't show that error anymore, I'm not sure it's actually getting the right stats or able to retrieve any. I used the same API key I have for Akismet which I got from https://apikey.wordpress.com/.

    I use the Most Visited Posts widget that comes with Stats Helper, and all it displays is my 5 most recent posts.

  3. krunk
    Posted 5 years ago #

    Nevermind, it looks like it just took awhile for my stats to be retrieved. Thanks for the fix!

  4. krunk
    Posted 5 years ago #

    I created a separate plugin that'll fix this issue, so you don't have to hack the existing plugin:


Topic Closed

This topic has been closed to new replies.

About this Topic