I need to get the current plugin directory like
[wordpress_install_dir]/wp-content/plugins/plugin_name
(if getcwd()
called from the plugin, it returns [wordpress_install_dir]
, the root of installation)
thanks for help
Why not use the WordPress core function that's designed specifically for that purpose?
<?php plugin_dir_path( __FILE__ ); ?>
See Codex documentation here.
You also have
<?php plugin_dir_url( __FILE__ ); ?>
if what you're looking for is a URI as opposed to a server path.
See Codex documentation here.
IMO it's always best to use the highest-level method that's available in core, and this is it. It makes your code more future proof.