is there a way to hook / filter or add action that would be printed in the wp-config file? lets say i want to add some simple command like “empty the trash” aka
define('EMPTY_TRASH_DAYS', 1 );
This should be changes in the wp-config but i want it to go with theme..
Any way to do that?
There is, as far as I know, no way to hook into
wp-config.php from a Theme. For one,
wp-config.php shouldn’t be writeable; for another,
wp-config.php is executed well-before a Theme’s
functions.php file is parsed. For a great overview of how WordPress boots, have a look at this two-part post by Theme.FM (part 1, part 2) or this Explanation with a flowchart by @Rarst.
You might want to look into removing the
wp-config.php, and moving it into the Theme? I’ll have to look to see where it gets used, but there’s a good chance that WordPress won’t have looked for it before
functions.php gets parsed.
As per @ChristopherDavis’ comment below,
EMPTY_TRASH_DAYS gets defined at
default-constants.php. So, you have to define it in
wp-config.php, if you want to override the default.
p.s. why would you want to define the number of trash days in a Theme, anyway?
You can just redefine it in your
functions.php file (call define with the key/value you want). Since it loads later, it’s going to be replaced with your value. I just tried this with a plugin, it generated some unexpected output errors, but it worked.
That said, if this is a theme for public consumption, it is definitely not your job to change site wide configuration options without consulting your users. If it’s for a client, you should be able to edit their
You’re better off to use xref (or something like
ack-grep) to search for where the constant is used and how. Are there hooks in those functions/whatever that you could used to accomplish the same thing as redefining the variable?