WordPress.org

Ready to get started?Download WordPress

Forums

Find my plugin directory (3 posts)

  1. Aaron D. Campbell
    Member
    Posted 7 years ago #

    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.

  2. Aaron D. Campbell
    Member
    Posted 7 years ago #

    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;
    }

  3. marjorie
    Member
    Posted 7 years ago #

    So did that resolve your situation?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags