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?

2 s
2

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 define() from 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.

EDIT

As per @ChristopherDavis’ comment below, EMPTY_TRASH_DAYS gets defined at wp-settings.php, via 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?

Leave a Reply

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