我有一个processForm。主题目录中的php实现了它所说的功能。我正在努力include a file (我需要它来运行processform.php中的特定函数)从插件目录中执行,但无法执行此操作。如中所述first solution in this thread 我试过:
include( plugin_dir_path( __FILE__ ) . \'test-plugin/needed_file.php\');
我很确定这会起作用,但不幸的是,它会发出这样的警告:Warning: include(/home2/xxx/public_html/wp-content/themes/xxx/test-plugin/needed_file.php) [function.include]: failed to open stream: No such file or directory
如前所述,流程表单。php位于主题目录中,我在其他任何地方都没有问题,只调用模板目录中的文件。如果这有帮助的话,可以为这个特定插件的路径定义一个常量,如下所示:define(\'WPFP_PATH\', plugins_url() . \'/test-plugin\');
所以根据建议的解决方案here, 我尝试使用以下代码:include(WPFP_PATH . \'/needed_file.php\');
不幸的是,它会引发三种类型的警告:第一个警告:
http:// wrapper is disabled in the server configuration by allow_url_include=0
第二个警告:failed to open stream: no suitable wrapper could be found in....
第三个警告:Failed opening \'http://awesomeness.com/wp-content/plugins/test-plugin/needed_file.php\' for inclusion (include_path=\'.:/usr/lib/php:/usr/local/lib/php\') in.....
因此,底线是如何将此文件包含到processForm中。php(位于主题目录的根目录中)。