Last active
November 24, 2018 18:14
-
-
Save johnalarcon/9249735fc90f648d8f7639a8ec908e03 to your computer and use it in GitHub Desktop.
Path/URL constants for use in WordPress/ClassicPress plugins to speed IDE autocompletion.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Declare the namespace. | |
namespace MYPLUGINNAME; | |
// Prevent direct access. | |
if (!defined('ABSPATH')) { | |
die(); | |
} | |
// Gain access to the get_home_path() function. | |
require_once(ABSPATH.'wp-admin/includes/file.php'); | |
// Ex: /home/user/mysite | |
define(__NAMESPACE__.'\PATH_HOME', untrailingslashit(get_home_path())); | |
// Ex: https://mysite.com | |
define(__NAMESPACE__.'\URL_HOME', untrailingslashit(home_url())); | |
// Ex: /home/user/mysite/wp-admin | |
const PATH_ADMIN = PATH_HOME.'/wp-admin'; | |
// Ex: /home/user/mysite/wp-content/plugins | |
const PATH_PLUGINS = WP_PLUGIN_DIR; | |
// Ex: /home/user/mysite/wp-content/plugins/my-plugin-name | |
const PATH_SELF = PATH_PLUGINS.'/'.PLUGIN_SLUG; | |
// Ex: /home/user/mysite/wp-content/plugins/my-plugin-name/extensions | |
const PATH_EXTENSIONS = PATH_SELF.'/extensions'; | |
// Ex: /home/user/mysite/wp-content/plugins/my-plugin-name/scripts | |
const PATH_SCRIPTS = PATH_SELF.'/scripts'; | |
// Ex: /home/user/mysite/wp-content/plugins/my-plugin-name/styles | |
const PATH_STYLES = PATH_SELF.'/styles'; | |
// Ex: /home/user/mysite/wp-content/plugins/my-plugin-name/images | |
const PATH_IMAGES = PATH_SELF.'/images'; | |
// Ex: /home/user/mysite/wp-content/plugins/my-plugin-name/languages | |
const PATH_LANGUAGES = PATH_SELF.'/languages'; | |
// Ex: /home/user/mysite/wp-content/plugins/my-plugin-name/includes | |
const PATH_INCLUDES = PATH_SELF.'/includes'; | |
// Ex: /home/user/mysite/wp-content/plugins/my-plugin-name/classes | |
const PATH_CLASSES = PATH_SELF.'/classes'; | |
// Ex: https://mysite.com/wp-admin | |
const URL_ADMIN = URL_HOME.'/wp-admin'; | |
// Ex: https://mysite.com/wp-content/plugins | |
const URL_PLUGINS = WP_PLUGIN_URL; | |
// Ex: https://mysite.com/wp-content/plugins/my-plugin-name | |
const URL_SELF = URL_PLUGINS.'/'.PLUGIN_SLUG; | |
// Ex: https://mysite.com/wp-content/plugins/my-plugin-name/extensions | |
const URL_EXTENSIONS = URL_SELF.'/extensions'; | |
// Ex: https://mysite.com/wp-content/plugins/my-plugin-name/scripts | |
const URL_SCRIPTS = URL_SELF.'/scripts'; | |
// Ex: https://mysite.com/wp-content/plugins/my-plugin-name/styles | |
const URL_STYLES = URL_SELF.'/styles'; | |
// Ex: https://mysite.com/wp-content/plugins/my-plugin-name/images | |
const URL_IMAGES = URL_SELF.'/images'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment