Did you test this line of code? Don't you have to check if it returns an object.. and maybe unserialize before comparing to forceVisualEditor? Also - I recommend using identity ("===") instead of just equality ("==") checks.