Update the value of a constant

You can’t alter a constant once it is defined. That is how PHP works. Don’t fight it. The good news is that you should not be using a constant at all. Use options. // get your value // the second parameter is the default $enable_paypal = get_option(‘enable_paypal’,true); // set your value based on, I assume, … Read more

is there a benefit in using a constant over get_stylesheet_directory_uri?

You can read up the source code of theme.php where get_stylesheet_directory_uri() is defined, inside you’ll see a str_replace() wich is consuming additional resources on each request. The best way to avoid this is to define a variable or constant that contains the path. In that case it is only called once. https://core.trac.wordpress.org/browser/tags/4.3.1/src/wp-includes/theme.php#L0

Checking for existence of constants before defining them

These are not PHP global variables, they are constants that cannot be modified(hence the name). Trying to redefine them, using a define() will trigger a notice since they are already defined(and consequently keep the initial value assigned). To stay away from notices, you should check if they have been defined() before. Example: define(‘VARIABLE’, ‘hello’); define(‘VARIABLE’, … Read more