Skip to content

Instantly share code, notes, and snippets.

@whalesalad
Created December 27, 2009 06:55
Show Gist options
  • Select an option

  • Save whalesalad/264187 to your computer and use it in GitHub Desktop.

Select an option

Save whalesalad/264187 to your computer and use it in GitHub Desktop.
<?php
/*
This creates a global variable called SG_STATIC with the full absolute URL to the static directory.
Note: this will only work if you're creating the statement inside of the base directory of your plugin
*/
define('SG_STATIC', WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/static');
// For example:
echo SG_STATIC;
// Will print out http://wordpress_server.com/wp-content/plugins/plugin_folder_name/static
// So in your situation, you could easily do something like
define('MYPLUGINNAME_DIRECTORY', WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)));
// And then in your use you can do the following
echo '<img src="'.MYPLUGINNAME_DIRECTORY.'/runners-log-chart.png" alt="image" />';
/*
Which will print out:
<img src="http://wordpress_server.com/wp-content/plugins/runner_plugin_folder/runners-log-chart.png" alt="image" />
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment