Use $wp_scripts->add_data() instead of wp_localize_script()

wp_localize_script() unfortunately will convert all items to strings. See #25280. So I've generally been directly calling $wp_scripts->add_data() which gives you complete control over the encoding, and you can export non-arrays as well.