Callback function is being called twice
The issue is not with your code. It is due to how WordPress works internally. This has been reported as bug in 2012 (almost 10 years ago at this point). You can see the bug report here: https://core.trac.wordpress.org/ticket/21989 The thing is that update_option is called, which when the option does not exist, will call add_option … Read more