Skip to content

Instantly share code, notes, and snippets.

@chrisblackwell
Created November 18, 2015 18:04
Show Gist options
  • Save chrisblackwell/41156a35b772949cdef7 to your computer and use it in GitHub Desktop.
Save chrisblackwell/41156a35b772949cdef7 to your computer and use it in GitHub Desktop.
Define Absolute Paths in WordPress
if (!defined('MYPLUGIN_THEME_DIR'))
define('MYPLUGIN_THEME_DIR', ABSPATH . 'wp-content/themes/' . get_template());
if (!defined('MYPLUGIN_PLUGIN_NAME'))
define('MYPLUGIN_PLUGIN_NAME', trim(dirname(plugin_basename(__FILE__)), '/'));
if (!defined('MYPLUGIN_PLUGIN_DIR'))
define('MYPLUGIN_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . MYPLUGIN_PLUGIN_NAME);
if (!defined('MYPLUGIN_PLUGIN_URL'))
define('MYPLUGIN_PLUGIN_URL', WP_PLUGIN_URL . '/' . MYPLUGIN_PLUGIN_NAME);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment