Wordpress get plugin directory

前端 未结 14 867
广开言路
广开言路 2021-01-31 02:09

Is there any function that would return the full path of my plugin in WordPress?

Example is

path/wp-contents/plugins/myplugin

I have tr

14条回答
  •  悲&欢浪女
    2021-01-31 02:51

    plugin_dir_path( __FILE__ ) will give you plugin path of current file.

    this is mean if you call this function like that inside "your_plugin_dir/sub_dir/file.php" will return "your_plugin_dir/sub_dir/"

    if you want to get the ROOT of your plugin directory, just change __FILE__ to __DIR__

    plugin_dir_path( __DIR__ )
    

提交回复
热议问题