Handle json_encode errors
PHP Notice fixes

Check for DEPLOYMENT_TARGET before using, check for path index in
REQUEST
Wrap wp_register_script and wp_localize_script in init to quiet the "doing it wrong" message