Take the tour ×

I have a class inside a file that i include_once() from the functions.php of my theme. The class can be used as stand alone plugin, or integrated in a theme.

Inside the class i want to fill a class variable (inside the __construct() function) with the native wordpress function get_plugin_data(). Fun as it is, i get the following error:

Call to undefined function get_plugin_data()

Am I asking for the plugin data too late, or what else might be my problem?


share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

get_plugin_data() is only defined in the administration section. What info did you need to get from the plugin's header that you would need to display in the theme? If the answer is none, I would suggest that you place a conditional call in your constructor. Something like:

if ( is_admin() ) {
    $var = get_plugin_data();
share|improve this answer
add comment

Your Answer


