Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

Thanks!

share|improve this question
add comment

1 Answer 1

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

 
discard

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.