wordpress插件在哪个文件夹
plugins_url()
获取当前插件的目录的 URI,例如一个插件位于/wp-content/plugins/myplugin下,该目录下放有插件的主文件名为myplugin.php,在myplugin.php中执行下面的代码,结果如下:echo plugins_url();//输出:https://www.53431.com/wp-content/pluginsecho plugins_url('',__FILE__);//输出:https://www.53431.com/wp-content/plugins/mypluginecho plugins_url('js/myscript.js',__FILE__);//输出:https://www.53431.com/wp-content/plugins/myplugin/js/myscript.jsplugin_dir_url()
返回当前插件的目录 URI,例如echo plugin_dir_url(__FILE__ );//输出:https://www.53431.com/wp-content/plugins/myplugin/注意结尾有反斜杠。
相关推荐:《WordPress教程》
plugin_dir_path()
返回当前插件目录的服务器绝对路径,例如echo plugin_dir_path(__FILE__ );//输出:/home/user/public_html/wp-content/plugins/myplugin/可以用来引用文件,例如<?phpdefine('MYPLUGINNAME_PATH', plugin_dir_path(__FILE__) );require MYPLUGINNAME_PATH . 'includes/class-metabox.php';require MYPLUGINNAME_PATH . 'includes/class-widget.php';?>plugin_basename()
返回调用该函数的插件文件名称(包含插件路径)
例如在插件myplugin下的myplugin.php文件中调用该函数,结果如下echo plugin_basename(__FILE__);//输出:myplugin/myplugin.php如果在myplugin/include/test.php文件中调用(test.php通过include引用到myplugin.php中),结果如下echo plugin_basename(__FILE__);//输出:myplugin/include/test.php以上就是wordpress插件在哪个文件夹的详细内容,更多请关注小潘博客其它相关文章!