Fix JavaScript error when wp is not defined

On Wordpress 3.3.2, the variable `wp` doesn't seem to exist - perhaps it's a variable that came with Wordpress 3.5 and its new media uploader.

This patch just checks if the variable is defined before setting a property of it.