I have a WordPress plugin that I would like to work on localhost as well as in deployment without modification, but I can't seem to set the location for a directory using one statement.
I would like to do this:
$feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/wp-content/cache');
While that works on the web host. On localhost it produces this error:
C:/xampp/htdocs/wp-content/cache/a547b8792c3144c98549be23ef1465e7.spc is not writeable
On localhost, I need to set it to this to get it work:
$feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/mysite/wp-content/cache');
Surely there must be something that works both on localhost and on a web host!
Thanks.
Check this out Determining Plugin and Content Directories WP already has this.