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 am trying to use SMOF Options Framework in a plugin and i have this problem. SMOOF use this constants to get theme directory url:

if( !defined('ADMIN_PATH') )
    define( 'ADMIN_PATH', get_template_directory() . '/admin/' );
if( !defined('ADMIN_DIR') )
    define( 'ADMIN_DIR', get_template_directory_uri() . '/admin/' );

But i want to use SMOF in a plugin, not in theme, how can i get the plugin directory url? What to put in order to get_template_directory() and get_template_directory_uri() to use it in a plugin?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Use plugin_dir_url( __FILE__ ); for the URL and plugin_dir_path( __FILE__ ); for the path.

Pass the plugin’s main file to both functions to get similar results.

Besides that, ADMIN_PATH and ADMIN_DIR are really poor names for custom code. They might result in collisions with other code in the future. Try to use better names, something with a unique prefix.

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.