WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 3 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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.