The logic on the IF THEN ELSE does seem a bit wonky. If I’m reading it correctly…
The call to get_option( $option_name ) will return FALSE if the option does not exist or if it has no value.
So the IF would be executed:
- when the option doesn’t exist and $new_value != FALSE
- the option has no value and $new_value != FALSE
- the option exists and has a value that is != $new value
The update_option() call would then update the value or create the option with $new_value.
The ELSE would be called if:
- the option exists and has the same value as $new_value
- the option does not exist and the $new_value == FALSE