hmmm, move to Missouri where there is no code...
To make it come up to code, I think that all you'd have to do is make the hole in the walnut big enough for that connector box and attach it to your wood and the studs. I'd feel a lot better knowing that the switch was in it's box and not up snug against flammable wood...Beautiful piece of wood, by the way and a good idea to fix the problem. I sure wish that the folks that build my house would have thought the light-switch placement problem out a little better. I have got some reaching to do for a couple of the rooms...

rentman, June makes a very good point about the switch terminals being so close to the wood and not protected by a box. There is a valid reason for most electrical codes. It seems to me that since you've done so much work on the bathroom remodel, (I notice there's "in-progress" drywall work) why not just move the box a little to the right. You can use the current box as a junction box to splice in the new piece of romex and add a box where ever you want it to be.

Ok, ok I can't move the existing box but I will enlarge the wood frame to accept a metal box.
I know that's the correct way, but was just a little short sighted, or was it lazy , ^^_^^
I do love wood and I hate to paint most of it, I think I'll just polyurethane this, shame it in the closet, no one will see.
This job was a major one, had to move the hot water heater, cutting a new trough in the concrete floor, laying more ceramic floor tile, then extending the heat vent in the ceiling. But it's complete, except for little more dry wall mud and painting.. Before we had Two doors into this bath , now there is one , like it should be.
Now back to the garden, just sold my little Boules cultivator, my son in law gave me a 6hp tiller and it is getting a work out.
Sure it hot here in Kentucky, Dwight