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 framework for WordPress that can be embedded into either a plugin, a theme or a child theme. In order to return proper URLs, the script needs to determine from where it is being executed.

I believe I could do something like matching __FILE__ against:

  • get_template_directory_uri() (theme),
  • get_stylesheet_directory_uri() (theme or child theme), or
  • plugin_dir_url( __FILE__ ) (plugin)

Is there a better, more reliable approach than using strpos() to compare the above? How would I go about it?

share|improve this question
    
@PieterGoosen I have edited my question. I'm looking for a reliable, non-arbitrary method to determine where the current file is located in the WordPress hierarchy. Optimally, we could make a function called where_am_i() that would return either "theme", "child-theme" or "plugin". –  asked Feb 12 '12 May 13 at 19:06
    
@PieterGoosen I have edited my question. I'm looking for a reliable, non-arbitrary method to determine where the current file is located in the WordPress hierarchy. –  asked Feb 12 '12 May 13 at 19:07

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.