How to check if we are in the init hook?
You can use did_action to test for this, e.g.: if ( did_action( ‘init’ ) < 1 ) { // init has not ran yet! Throw the exception } https://developer.wordpress.org/reference/functions/did_action/ did_action returns the number of times that action has been run. This can also be used to ensure it only happens once for filters that happen … Read more