WordPress Constants

Something I wanted to keep for reference.
See the source here: https://wppb.me/wordpress-constants

WordPress offers multiple ways to configure and customize your site, from the admin panel to hooks (filters and actions). However, one of the most powerful and often overlooked methods is through PHP constants. These constants provide developers with fine-grained control over various aspects of WordPress functionality.

You’ve likely encountered constants in the wp-config.php file. For instance:

// Enable debugging
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

// Customize the content directory
define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/custom-content' );
define( 'WP_CONTENT_URL', 'https://example.com/custom-content' );

// Enforce SSL for admin and logins
define( 'FORCE_SSL_ADMIN', true );

// Disable automatic updates
define( 'AUTOMATIC_UPDATER_DISABLED', true );

// Increase memory limit
define( 'WP_MEMORY_LIMIT', '256M' );

These constants demonstrate the breadth of control available, from enabling debugging features to customizing core WordPress directories and enforcing security measures.

Constants in WordPress Development

Beyond configuration, constants play a vital role in WordPress development. They provide consistent, reliable ways to reference important paths, URLs, and settings within your themes and plugins. For instance:

  • ABSPATH: The absolute path to the WordPress directory
  • WPINC: The relative path to the includes directory

Using these constants ensures your code remains portable and resistant to changes in WordPress’ file structure or a user’s custom setup.

ConstantDescriptionDefault ValuePossible Values
Admin
IS_PROFILE_PAGEDetermined if you are on profile edit page in admin panelNot settrue
WP_ADMINWill be defined if you are in the WordPress admin panelNot settrue
WP_BLOG_ADMINWill be defined if you are running a query in /wp-admin/Not settrue
WP_USER_ADMINDefined on pages: /wp-admin/user/Not settrue
Content Management
AUTOSAVE_INTERVALInterval of autosave posts on editing60Time in seconds
DOING_AUTOSAVEDetermined when auto-saving a recordNot settrue
EMPTY_TRASH_DAYSNumber of days before an entry is deleted from the Recycle Bin30Numberfalse
WP_POST_REVISIONSRevisions recordstruetruefalseNumber
Cookies
ADMIN_COOKIE_PATHPath to directory /wp-admin/SITECOOKIEPATH wp-admin Or for Multisite subdirectory SITECOOKIEPATHPath
AUTH_COOKIEName of authorization cookiewordpress_ COOKIEHASHCookie name
COOKIEHASHHash for generating cookie namesNot setHash
COOKIEPATHThe path to the WordPress root directoryHome URL without http(s)://Path
COOKIE_DOMAINThe domain that will be used in setcookie() and for which cookies will be setfalseDomain
LOGGED_IN_COOKIEName Cookie for authenticationwordpress_logged_in_ COOKIEHASHCookie name
PASS_COOKIECookie name for the passwordwordpresspass_ COOKIEHASHCookie name
PLUGINS_COOKIE_PATHPath to plugins directoryWP_PLUGIN_URL without http(s)://Path
SECURE_AUTH_COOKIECookie name for SSL authorizationwordpress_sec_ COOKIEHASHCookie name
SITECOOKIEPATHThe path to the siteSite URL without http(s)://Path
TEST_COOKIECookie name for the test cookiewordpress_test_cookieCookie name
USER_COOKIEThe cookie name for userswordpressuser_ COOKIEHASHCookie name
Core
SHORTINITStops the loading of the main part of WordPressNot settrue
Cron
ALTERNATE_WP_CRONUses an alternative Cron systemfalsetruefalse
DISABLE_WP_CRONDeactivates the cron (job scheduler) in WordPressNot settrue
DOING_CRONDetermined if cron task (scheduled task) is executedNot settrue
WP_CRON_LOCK_TIMEOUTSets the minimum time interval, between the execution of cron requests60Seconds
Database
CUSTOM_USER_META_TABLELets you define your own “user meta” tableNot setTable name
CUSTOM_USER_TABLEAllows you to define your own “user” tableNot setTable name
DB_CHARSETDefines the encoding (charset) of the databaseutf8Charset
DB_COLLATEDefines the collation type for the databaseutf8_general_ciCollation
DB_HOSTDefines database hostlocalhostHostname
DB_NAMESpecifies database nameNot setDatabase name
DB_PASSWORDDefines database passwordNot setPassword
DB_USERIdentifies database userNot setUsername
WP_ALLOW_REPAIRAllows automatic rebuilding and optimization of database tablesNot settrue
Debugging
DIEONDBERRORIf defined, database errors will be displayedNot settrue
ERRORLOGFILEIf defined, the database errors will be written to the log fileNot setPath
SAVEQUERIESEnables or disables writing database queries to an arrayNot settruefalse
SCRIPT_DEBUGEnables or disables loading of packed CSS and JavaScript filesNot settruefalse
WP_DEBUGEnables or disables WordPress debug modefalsetruefalse
WP_DEBUG_DISPLAYEnables or disables error output to the screentruetruefalsenull
WP_DEBUG_LOGEnables or disables error logging to file /wp-content/debug.logfalsetruefalse
WP_SANDBOX_SCRAPINGDisables fatal error handlingNot settrue
Development
WP_LOCAL_DEVNot a WordPress constant – often used to enable additional functionality when definedNot settrue
Email
WP_MAIL_INTERVALSpecifies the time interval during which only one mail request can be executed300Seconds
Environment
WP_ENVIRONMENT_TYPEDefines the current development environmentproductionlocaldevelopmentstagingproduction
File System
FS_CHMOD_DIRDefines access rights for directories0755Octal
FS_CHMOD_FILEDefines access rights for files0644Octal
FS_CONNECT_TIMEOUTSpecifies the timeout to create a connection30Seconds
FS_METHODSpecifies how to connect to the file systemNot setdirectsshftpextftpsockets
FS_TIMEOUTDefines timeout after a connection loss30Seconds
FTP_BASEPath to WordPress root directoryABSPATHPath
FTP_CONTENT_DIRDirectory path /wp-content/WP_CONTENT_DIRPath
FTP_HOSTSpecifies a host for FTPNot setHostname
FTP_LANG_DIRPath to directory of language filesWP_LANG_DIRPath
FTP_PASSSpecifies the password for FTPNot setPassword
FTP_PLUGIN_DIRPath to plugins directoryWP_PLUGIN_DIRPath
FTP_PRIKEYSpecifies private key for SSHNot setPath
FTP_PUBKEYSpecifies public key for SSHNot setPath
FTP_SSHTurns SSH on or offNot settruefalse
FTP_SSLTurns SSL on or offNot settruefalse
FTP_USERSpecifies a username for FTPNot setUsername
UPLOADSThe path to the site-specific upload directory depends on ABSPATHUPLOADBLOGSDIR /{blogid}/files/Path
Import
WP_IMPORTINGDefined when you are importing WordPress dataNot settrue
WP_LOAD_IMPORTERSDefined in import review in control panel (Tools -> Importer)Not settrue
Installation
WP_INSTALLINGWill be defined, during a new installation or upgradeNot settrue
WP_SETUP_CONFIGDefined during WP installation or configurationNot settrue
Localization
WP_LANG_DIRThe absolute path to the directory with the language filesWP_CONTENT_DIR . ‘/languages’ Or ABSPATH . WPINC . ‘/languages’Path
WPLANGDeprecated since WP 4.0. Defines the WordPress localization codeLanguage code
Maintenance
WP_REPAIRINGDefined on page: /wp-admin/maint/repair.phpNot settrue
Media
IMAGE_EDIT_OVERWRITEControls image edit behaviorNot settruefalse
MEDIA_TRASH“Recycle Bin” functionality for media filesfalsetruefalse
Multisite
ALLOW_SUBDIRECTORY_INSTALLAllows you to install Multisite in a subdirectory (subdomain)Not settrue
BLOGUPLOADDIRThe absolute path to the “upload” directory of a particular blogWP_CONTENT_DIR /blogs.dir/{ID блога}/files/Path
BLOG_ID_CURRENT_SITEThe blog ID of the main site1Number
DOMAIN_CURRENT_SITEThe domain of the main sitedomainDomain
MULTISITEWill be defined if Multi-site mode is usedNot settrue
NOBLOGREDIRECTSpecifies the site URL to which WordPress will redirect requests if the registration is closed or the site does not existNot setURL
PATH_CURRENT_SITEThe path to the main siteNot setPath
SITE_ID_CURRENT_SITENetwork ID of the main site1Number
SUBDOMAIN_INSTALLDetermines whether the installation goes to a subdomain or notNot settruefalse
SUNRISEIf defined, WordPress will upload the file /wp-content/sunrise.phpNot settrue
UPLOADBLOGSDIRThe path to the underlying upload directory, depending on ABSPATHwp-content/blogs.dirPath
WP_ALLOW_MULTISITEIf defined, the Multi-Site feature is availableNot settrue
WP_INSTALLING_NETWORKTo be determined when installing the network or when querying the network adminNot settrue
WP_NETWORK_ADMINDefined in page: /wp-admin/network/Not settrue
WPMU_ACCEL_REDIRECTEnables or disables support for X-Sendfile Headerfalsetruefalse
WPMU_SENDFILEEnables or disables support for X-Accel-Redirect Headerfalsetruefalse
Paths
ABSPATHThe path to the WordPress root directory with a slash at the endpath to the directory with the file wp-load.phpPath
WP_CONTENT_DIRAbsolute path to wp-content directoryABSPATH/wp-contentPath
WP_CONTENT_URLURL to the wp-content directory{URL сайта}/wp-contentURL
WP_PLUGIN_DIRAbsolute path to plugins directoryWP_CONTENT_DIR . ‘/plugins’Path
WP_PLUGIN_URLURL of the plugins directoryWP_CONTENT_URL . ‘/plugins’URL
WP_TEMP_DIRThe absolute path to the directory for temporary filesNot setPath
WPINCName of the directory wp-includeswp-includesNot set
WPMU_PLUGIN_DIRThe absolute path to the directory of plugins like “Must Use Plugins”WP_CONTENT_DIR/mu-pluginsPath
WPMU_PLUGIN_URLURL of the plugins directory of type “Must Use Plugins”WP_CONTENT_URL /mu-pluginsURL
Performance
COMPRESS_CSSEnables/disables stylesheet compression (stylesheets)Not settruefalse
COMPRESS_SCRIPTSEnables / disables compression of JavaScript filesNot settruefalse
CONCATENATE_SCRIPTSEnables/disables compression of JavaScript or CSS files before compressionNot settruefalse
ENFORCE_GZIPEnables/disables gzip compressionNot settruefalse
WP_CACHEIf defined, WordPress will try to load the /wp-content/advanced-cache.php filefalsetruefalse
WP_MAX_MEMORY_LIMITMaximum memory limit for some WordPress features256MMemory size
WP_MEMORY_LIMITMemory limit for running WordPress scripts32M, For Multisite 64MMemory size
WP_START_TIMESTAMPWP code start time stampNot setTimestamp
Plugins
WP_UNINSTALL_PLUGINDefined during plugin removalNot settrue
Proxy
WP_PROXY_BYPASS_HOSTSAllows you to define which addresses should not connect through the proxyNot setComma-separated list
WP_PROXY_HOSTDefines proxy addressNot setIP address or domain
WP_PROXY_PASSWORDDefines password for the proxyNot setPassword
WP_PROXY_PORTDefines port for the proxyNot setPort number
WP_PROXY_USERNAMEDefines proxy usernameNot setUsername
Request Types
APP_REQUESTDetermined when an Atom Publishing Protocol request is madeNot settrue
DOING_AJAXDetermined when an AJAX request is executedNot settrue
IFRAME_REQUESTDetermined if IFRAME request is executedNot settrue
REST_REQUESTDefined when performing a REST requestNot settrue
XMLRPC_REQUESTDefined at any XML-RPC requestNot settrue
Security
SECURE_AUTH_KEYSecret keyNot setText key
SECURE_AUTH_SALTSecret keyNot setText key
WP_ACCESSIBLE_HOSTSIf WP_HTTP_BLOCK_EXTERNAL is defined, you can add hosts that will not be blocked (white list)Not setComma-separated list
WP_HTTP_BLOCK_EXTERNALAllows blocking external requestsNot settruefalse
Site Configuration
WP_HOMEThe URL of your WordPress blogNot setURL
WP_SITEURLThe URL of the WordPress root directory where the WordPress files are locatedNot setURL
Template
COMMENTS_TEMPLATEDetermined when a comment template is loadedNot settrue
Testing
WP_TESTS_CONFIG_FILE_PATHLocation of the wp-tests-config.php file which is used for PHPUnit testsNot setPath
Theme
BACKGROUND_IMAGEDefines the default background imageNot setImage URL
HEADER_IMAGEDefines the default header imageNot setImage URL
HEADER_IMAGE_HEIGHTSpecifies the height of the header imageNot setNumber
HEADER_IMAGE_WIDTHDefines the width of the header imageNot setNumber
HEADER_TEXTCOLORDetermines the color of the header textNot setColor code
NO_HEADER_TEXTEnables or disables support for header textNot settruefalse
STYLESHEETPATHContains the absolute path to the theme folderNot setPath
TEMPLATEPATHContains an absolute path from the root of the site to the current themeNot setPath
WP_DEFAULT_THEMESets the default theme for new sitestwentyelevenTheme name
WP_USE_THEMESEnables or disables theme loadingNot settruefalse
Updates
AUTOMATIC_UPDATER_DISABLEDAuto-update engine, introduced in version 3.7falsetruefalse
CORE_UPGRADE_SKIP_NEW_BUNDLEDAffect new file groups (plugins or themes) when updatingNot settruefalse
WP_AUTO_UPDATE_COREManages core auto-updatesminortruefalseminor