If you know a function or class of the plugin’s main file, you can use the Reflection API.
Example with my plugin T5 Taxonomy Location
add_action( 'plugins_loaded', function()
{
$class="T5_Taxonomy_Location";
if ( ! class_exists( $class ) )
return;
add_action( 'admin_footer', function() use ( $class )
{
$reflection = new ReflectionClass( $class );
$file = $reflection->getFileName();
$data = get_plugin_data( $file );
print '<pre>$data=" . esc_html( var_export( $data, TRUE ) ) . "</pre>';
});
});
Result
$data = array (
'Name' => 'T5 Taxonomy Location',
'PluginURI' => 'https://github.com/toscho/t5-taxonomy-location',
'Version' => '2012.09.11',
'Description' => 'Creates a new taxonomy for locations. <cite>By <a href="http://toscho.de" title="Visit author homepage">Thomas Scholz </a>.</cite>',
'Author' => '<a href="http://toscho.de" title="Visit author homepage">Thomas Scholz </a>',
'AuthorURI' => 'http://toscho.de',
'TextDomain' => 'plugin_t5_tax_location',
'DomainPath' => '/languages',
'Network' => false,
'Title' => '<a href="https://github.com/toscho/t5-taxonomy-location" title="Visit plugin homepage">T5 Taxonomy Location</a>',
'AuthorName' => 'Thomas Scholz ',
)
For a function, use ReflectionFunction
. It inherits the method getFileName()
too.