I've created a working plugin and now I've created a second one.
I would like to acces a file that's in the plugin 2 directory, from within the plugin 1 directory.
I've tried it by using the below code:
require_once '/wp-content/plugins/my-core/updare/plugin-update-checker.php';
However I'm getting the following error:
Warning: require_once(): open_basedir restriction in effect. File(//wp-content/plugins/my-core/updare/plugin-update-checker.php) is not within the allowed path(s):
It could be fixed by changing the .htaccess file by disabling my open_basedir settings, but due to security I'm not willing to disable it completely. How can I acces a from from plugin 1 towards plugin 2 without changing up the open_basedir globaly? Also, it should be in a .htaccess file because I'm planning on using the plugin on several websites.
CodePudding user response:
generally you should not be able to access other plugin files' content or even try to. If the second plugin is written in Object-oriented programming PHP language then you can easily hook into it using its class, if not, you can use its functions to do whatever you need. This is the goal of OOP, to access other sources without accessing entire file and violating security.
CodePudding user response:
You can use the WP_PLUGIN_DIR
constant like this
require_once WP_PLUGIN_DIR . '/my-core/updare/plugin-update-checker.php';