是否有方法从同一服务器上多个已安装站点的默认位置调用函数?
For example:
\\public_html\\functions\\global_functions.php
具有所有站点的共享功能。\\public_html\\site1\\wp-content\\themes\\theme1_child\\functions.php
require_once( dirname(__FILE__) . \'../../../../global_functions.php\');
\\public_html\\site2\\wp-content\\themes\\theme1_child\\functions.php
require_once( dirname(__FILE__) . \'../../../../global_functions.php\');
我知道这是不对的,但我不确定这样做是否可行。由于它位于同一台服务器上,我不知道是否有办法查看当前安装点上方的其他目录。<小时>
After continuing to play with this, I ended up doing it this way:
define ( \'global_functions_dir\', dirname(__FILE__) . \'../../../../../_functions\' );
require_once( global_functions_dir . \'/global-functions.php\');
可以在每个站点上添加,以包含必要的功能。如果有人知道这样做是否有任何安全风险,请告诉我。由于这是一个服务器端调用,我认为这很好??我已经开始阅读多站点配置,这可能是实现这一点的一个很好的方法。在我对这样做可能产生的问题有了更好的理解之后,我将考虑朝着这个方向前进。谢谢你的帮助。