Php 插件返回的url不正确\u url
我试图获取我的插件的url,但plugins\uURL函数返回了一个不正确的url 在主插件文件中有这样一行:Php 插件返回的url不正确\u url,php,wordpress,Php,Wordpress,我试图获取我的插件的url,但plugins\uURL函数返回了一个不正确的url 在主插件文件中有这样一行: $this->plugin_url = plugins_url( '/', __FILE__ ); 注意,我已经通过wp config.php更改了我的插件文件夹: ... define( 'WP_PLUGIN_DIR', '/home/victor/hg/' ); define( 'WP_PLUGIN_URL', 'http://hg.victorpc.org' );
$this->plugin_url = plugins_url( '/', __FILE__ );
注意,我已经通过wp config.php
更改了我的插件文件夹:
...
define( 'WP_PLUGIN_DIR', '/home/victor/hg/' );
define( 'WP_PLUGIN_URL', 'http://hg.victorpc.org' );
...
hg.victorpc.org
是一个vhost,文档根目录设置为/home/victor/hg
函数返回此URLhttp://hg.victorpc.org/home/victor/hg/
正确的是http://hg.victorpc.org/hg/
使用插件目录url()
法典:
用法:
$this->plugin_url = plugin_dir_url( __FILE__ );
这将返回:
http://hg.victorpc.org/hg//
(注意后面的斜杠)。我已经解决了这个问题,使用了:
plugins_url( basename( __DIR__ ) );
返回我所期望的。使用plugin\u dir\u url
返回urlhttp://hg.victorpc.org/home/victor/hg//