Plugin Path (3 posts)

  1. davosian
    Posted 9 years ago #

    I would like to embed an image in my plugin (widget). The image resides in the plugin folder (wp-content/plugins/myplugin/image.gif). How can I reference the image from within my plugin without hardcoding the path?

    Is there something like get_plugin_directory()?

    Thank you,

  2. Kafkaesqui

    Posted 9 years ago #

    Typical ways to accomplish this:

    ABSPATH . 'wp-content/plugins/myplugin/image.gif'

    ABSPATH is a WP constant that provides the full directory path to the (WordPress) installation directory.

    For providing the url, you could use:

    get_settings('siteurl') . '/wp-content/plugins/myplugin/image.gif'

  3. iamfletch
    Posted 8 years ago #

    i did this :)
    define('PLUGINPATH', ABSPATH.'wp-content/plugins/myplugin');

    and this,

    define('PLUGINLINK', get_settings('siteurl') . 'wp-content/plugins/wpajax/');

Topic Closed

This topic has been closed to new replies.

About this Topic