Warning: fread() expects parameter 1 to be resource

Warning- fread() expects parameter 1 to be resource

Error

When I was migrating my page from localhost to production server, I got this warning message:

Warning: fread() expects parameter 1 to be resource, boolean given in .../www/wp-includes/functions.php on line 4837

The only article mentioning this issue is this one in the wordpress support thread. But the author of the plugin doesn’t address the issue. @kernel52 says you should

a) change the theme of the website
b) disable and re-enable the plugin
c) then switch back to the theme you were using

but that doesn’t worked for me.

Solution

After more investigation I have found the code in functions.php that was causing the issue. I think it’s because of the freemium feature. What worked for me is:

1. change $__DIR variable on line 26

// $__DIR = dirname( __FILE__ );
$__DIR = plugin_dir_path( __FILE__ );

2. comment out the freemium feature on line 71:

require_once $__DIR . '/analytics/initialize.php';
// require_once $__DIR . '/analytics/initialize.php';

3. navigate from the plugins page somewhere else. (don’t test it while you are in plugins page).

And that’s it. Hope it helped.

Buy me a coffeeOut of coffee 😱, please help!