Support » Plugins » Find my plugin directory

  • I’m trying to make a plugin, and I’d like to be able to locate the directory it’s in. I have some images that I’m packaging with it, and I’d like to be able to link to them no matter WHAT the blog owner names the directory with my plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I ended up doing this:
    function get_plugin_dir() {
    $plugin_loc = get_option('wam_location');
    if ($plugin_loc == false) {
    $plugin_loc = 'wp-content/plugins/';

    if (function_exists('get_plugins')) {
    foreach (get_plugins() as $plugin_file=>$plugin) {
    if ($plugin['Name'] == 'Attachment Manager' && strip_tags($plugin['Author']) == 'Aaron D. Campbell') {
    $plugin_loc .= dirname($plugin_file);
    break;
    }
    }
    }
    update_option('wam_location', $plugin_loc);
    }
    return $plugin_loc;
    }

    So did that resolve your situation?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Find my plugin directory’ is closed to new replies.