Is this plugin being loaded before file.php, subsequently not allowing me to use certain functions?

I’m trying to use get_home_path() in my plugin, however, I get a call to undefined function fatal error (running WordPress 3.8).

I believe this would imply that my plugin is being loaded before wp-admin/includes/file.php where get_home_path() is located, right?

Is it just me, or is that a little odd? How can I make file.php load first so I can access this function?

The line of code that causes this issue (within my plugin) is:

register_theme_directory(get_home_path().'/material/views');

1 Answer
1

to make sure everything required is loaded before plugins loads, use plugins_loaded hook and initialize your plugins its callback funtion. for example:

add_action('plugins_loaded',function(){
  // initialize your plugins here.
});

Leave a Comment