我试图在wordpress中创建一个插件 这是我的代码
include plugins_url("/imp-file/admin/partials/imp-file-admin-display.php");
那是警告
> Warning: include(): http:// wrapper is disabled in the server
> configuration by allow_url_include=0 in
> /home/darelizza/public_html/wp-content/plugins/imp-file/admin/class-imp-file-admin.php
> on line 120
>
> Warning:
> include(http://darelizza.com/wp-content/plugins/imp-file/admin/partials/imp-file-admin-display.php):
> failed to open stream: no suitable wrapper could be found in
> /home/darelizza/public_html/wp-content/plugins/imp-file/admin/class-imp-file-admin.php
> on line 120
>
> Warning: include(): Failed opening
> 'http://darelizza.com/wp-content/plugins/imp-file/admin/partials/imp-file-admin-display.php'
> for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in
> /home/darelizza/public_html/wp-content/plugins/imp-file/admin/class-imp-file-admin.php
> on line 120
答案 0 :(得分:0)
不要使用plugins_url。试试这个:
include plugins_dir_path("/imp-file/admin/partials/imp-file-admin-
display.php");
答案 1 :(得分:0)
创建一个在基类中定义插件路径变量的结构:
define( 'XPlugin_PLUGIN_PATH', plugin_dir_path(__FILE__) );
然后将其用作include
函数中的参数,如下所示:
include( XPlugin_PLUGIN_PATH. '/admin/partials/XPlugin-admin-display.php');