Skip to content

WP CONFIG CONSTANTS

  • by

In a WordPress site, the wp-config.php is responsible for storing information related to the main configuration of the WordPress core. Below is a list of constants for reference that are stored in wp-config.php for various reasons.

Helpful WP Config Constants:

// PHP Directives

define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.

or generally in the themes functions.php file:

@ini_set( 'upload_max_size' , '20M' );
@ini_set( 'post_max_size', '13M');
@ini_set( 'memory_limit', '15M' );

Max Execution time:

set_time_limit(300);

// Database

define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)

// Explicitely setting url

define( 'WP_HOME', 'http://domain.com' );
define( 'WP_SITEURL', 'http://domain.com' );

// Set url to… whatever.

define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );

// Temporary for causing a site to relocate. Remove after login.

define( 'RELOCATE', true );

// Allow WordPress to update files

define( 'FS_METHOD', 'direct' );
define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) ); // change permissions of directories
define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) ); // change permissions of files

// Set the directory files should be downloaded to before they’re moved.

// This is usually set in the PHP conf

define( 'WP_TEMP_DIR', '/Applications/MAMP/tmp/php/' ); // this one is for default MAMP setup

// Set post revisions to something feasible

define( 'WP_POST_REVISIONS', 5 );

// Autosave interval of post revisions in seconds.

define( 'AUTOSAVE_INTERVAL', 160 ); // Seconds

// Set cookie domain for login cookies

// Very helpful if you’re getting cookie errors during login

define( 'COOKIE_DOMAIN', '.domain.com' ); // Domain and all subdomains
define( 'COOKIE_DOMAIN', 'domain.com' ); // only root domain
define( 'COOKIE_DOMAIN', 'www.domain.com' ); // only subdomain

// More cookie constants

define( 'COOKIEPATH', $_SERVER['HTTP_HOST'] . '/' ); // You should set this explicitely. 
define( 'SITECOOKIEPATH', $_SERVER['HTTP_HOST'] . '/' ); // You should set this explicitely. 
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
define( 'PLUGINS_COOKIE_PATH', preg_replace( '|https?://[^/]+|i', '', WP_PLUGIN_URL ) );

// Cookie names.

define( 'USER_COOKIE', 'wordpressuser_' . COOKIEHASH );
define( 'PASS_COOKIE', 'wordpresspass_' . COOKIEHASH );
define( 'AUTH_COOKIE', 'wordpress_' . COOKIEHASH );
define( 'SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH );
define( 'LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH );
define( 'RECOVERY_MODE_COOKIE', 'wordpress_rec_' . COOKIEHASH );

// WordPress debug on and off

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
define( 'WP_LOCAL_DEV', true ); // Magic switch for local dev

// Script and style debug

define( 'CONCATENATE_SCRIPTS', false ); // Causes WordPress scripts to be included separately
define( 'SCRIPT_DEBUG', true ); // Uses unminified scripts
define( 'SAVEQUERIES', true ); // Requires analyzing the global $wpdb object.
define('COMPRESS_SCRIPTS', true); 
define('COMPRESS_CSS', true);
define('ENFORCE_GZIP', true);

// Disable WP cron in favor of server cron

define( 'DISABLE_WP_CRON', true );
define( 'ALTERNATE_WP_CRON', true ); // alternate method of firing cron in the background when initiated by end users.
define( 'WP_CRON_LOCK_TIMEOUT', 60 ); // limit cron runs to a certain interval.

// SSL

define( 'FORCE_SSL_LOGIN', true ); // Only secures the registration/login process
define( 'FORCE_SSL_ADMIN', true ); // Force SSL for the whole WordPress admin

// The “timthumb” fix

define( 'WP_HTTP_BLOCK_EXTERNAL', true );
define( 'WP_ACCESSIBLE_HOSTS', 'api.wordpress.org,*.github.com' ); // Only allow particular hosts in

// Modifying files

define( 'DISALLOW_FILE_EDIT', true ); // Kill the WordPress file editor
define( 'DISALLOW_FILE_MODS', true ); // Don't allow users to update core, plugins, or themes
define( 'IMAGE_EDIT_OVERWRITE', true ); // Allow editing images to replace the originals

// Changing WordPress updates.

define( 'AUTOMATIC_UPDATER_DISABLED', true ); // Disable all WordPress auto-updates
define( 'WP_AUTO_UPDATE_CORE', false ); // Only disable core updates
define( 'WP_AUTO_UPDATE_CORE', 'minor' ); // Only enable minor core updates

// Change languages

define( 'WPLANG', 'de_DE' );
define( 'WP_LANG_DIR', dirname(__FILE__) . 'wordpress/languages' );

// Trash

define( 'EMPTY_TRASH_DAYS', 30 ); // 30 days

// Dev tools

define( 'SHORTINIT', false ); // Disable most of WordPress. Useful for fast responses for custom integrations.
define( 'WP_FEATURE_BETTER_PASSWORDS', true ); // Remove better password feature.

// Recovery mode and fatal error handling.

define( 'WP_SANDBOX_SCRAPING', true ); // Turn off WSOD Protection (and don't send email notification)

// Allow Multisite

define( 'WP_ALLOW_MULTISITE', true );

// Multisite Config After it’s setup in Tools > Network

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'sitename.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

// Multisite Redirecting to Register/Signup Page Fix

define( 'NOBLOGREDIRECT', 'http://www.yourdomain.com' );

// Boost Site Speed

define('COMPRESS_SCRIPTS', true);
define('COMPRESS_CSS', true);
define('ENFORCE_GZIP', true);

// Sorry, This File Type Is Not Permitted for Security Reasons FIX

define('ALLOW_UNFILTERED_UPLOADS', true)

//Adding SFTP FTP Details

define('FS_METHOD', 'ftpext'); 
define('FTP_BASE', '/path/to/wordpress/'); 
define('FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/'); 
define('FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/'); 
define('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub'); 
define('FTP_PRIKEY', '/home/username/.ssh/id_rsa'); 
define('FTP_USER', 'username'); 
define('FTP_PASS', 'password'); 
define('FTP_HOST', 'ftp.example.org'); 
define('FTP_SSL', false);

Leave a Reply

Your email address will not be published. Required fields are marked *