Hello,
I just ran a test and it seems to be working. I did the following:
function override_opt_domains($value) {
return 'cool';
}
add_filter('pre_option_multiple-domain-domains', 'override_opt_domains');
var_dump(get_option('multiple-domain-domains'));
It outputs string(4) "cool"
. If I comment out the add_filter
call, it outputs the array with all domain settings, as expected.
I’m running WordPress 5.1 and the latest version of Multiple Domain. That piece of code was added to the functions.php
of **TwentyNineteen** theme.
Thread Starter
crmb
(@crmb)
But i am not sure it works during initAttributes();
I have to try again.
You’re right. The plugin loads before the filter in functions.php
. It’s unexpected, though. According to this, functions.php
is supposed to load before. I’ll keep investigating.
Looking at the official reference, plugins are loaded before themes: https://codex.wordpress.org/Action_Reference#Actions_Run_During_a_Typical_Request. Therefore, I don’t think you can achieve what you want simply using the pre_option_[...]
filter. We probably need some way to enable programmatically changes to the list of domains.
Thread Starter
crmb
(@crmb)
Thank you.
I think it may work with the hook in a mu-plugin because they are loaded before regular plugins. But all my code is in the theme right now for convenience, i will go with the programmatically update option value way then.
You can follow and contribute to this new feature here: https://github.com/straube/multiple-domain/issues/56
Please check the updates on GitHub. I’m closing this topic for now.