WP-Matomo
WP-Matomo copied to clipboard
Proxy-Script not working when installed in symlink'ed path
The proxy script from wp-matomo/proxy/piwik.php throws an exception, when the plugin is located in a directory outside Wordpress and made available through a symlink to the WP installation. Apparently, the plugin is looking for wp-load.php from the Wordpress install outside of the expected path (which is also not in include path). I don't want go to into lengths discussing if that's a good way to install a plugin good or not - but it's not working :-)
How to reproduce:
- Move plugin outside of wordpress plugin dir
mv /var/www/mywordpress/wp-contents/plugins/wp-matomo /var/www/shared/ ln -s /var/www/shared/wp-matomo /var/www/mywordpress/wp-contents/plugins/wp-matomo
- Open wordpress site: proxy script not working
Workaround (currently working for my set-up): wp-matomo/proxy/config.php, ln 2:
$wpRootDir = isset($wpRootDir)
? $wpRootDir
//: '../../../../';
: realpath(dirname(dirname(dirname(dirname(dirname($_SERVER["SCRIPT_FILENAME"])))))) . '/';
require ($wpRootDir.'wp-load.php');
Justification: Using symlinks to provide anything to a Wordpress instance was proposed by some means in 2014 for Wordpress 3.9. Example: https://make.wordpress.org/core/?p=10196