wp_localize_script with boolean and init

Question

I have problem with wp_localize_script, That I cannot get boolean and int as variable

wp_enqueue_script( 'helloworld' , 'helloworld.js', false, '1.0.0', true);

$site_config = array();

$site_config['boo'] = (bool)true;
$site_config['number'] = (int)1;

wp_localize_script( 'helloworld' , 'site_config' , $site_config );

Why I getting :

var site_config = {"boo":"1","number":"1"};

Why not :

var site_config = {"boo":true,"number":1};
  • WordPress 4.6 (latest)
  • PHP 5.6.10

Does not it fixed ? https://core.trac.wordpress.org/ticket/25280 , I do anything wrong or missing something ?

0
, , , l2aelba 1 year 2020-07-15T08:10:32-05:00 0 Answers 73 views 0

Leave an answer

Browse
Browse