Know The Constants Of An WordPress Installation

Today I will show you how to display the constants you use in your WordPress installation. Here is a small code snippet to list the defined constants.

Please note: The output shows all defined constants, including the database and FTP password. Therefore please don't put it up online for everybody, let only admins access this page. For the output of constants PHP has a function, which we will use and add a little bit code to create a readable list. You put the code in your Theme to have an output of all constants. Alternatively you can also create a Plugin to view a list of the constants.

print('<pre>');
print_r( @get_defined_constants() );
print('</pre>');

To be sure, that only logged in user can see the list, I will add an additional query to check if the user is logged in.

if ( is_user_logged_in() ) {
	print('<pre>');
	print_r( @get_defined_constants() );
	print('</pre>');
}

The output can also be checked by user rights with if ( current_user_can('manage_options') ) {. You can read more about it in a previous article or an article with examples for use the rights.

As an alternativ, the Plugins WP System Health and Debug Objects can be very helpful, which lists all constants.
Have fun!