Tag Info

New answers tagged

0

Your code should be in an action callback function: function wpse186202_enqueue_scripts(){ wp_enqueue_script( 'stats', get_stylesheet_directory_uri() .'/js/t5-demo.js' , array( 'jquery' ), '1.0.0', true ); $categories = implode( ', ', wp_list_pluck( get_the_category( get_the_ID() ), 'name' ) ); $datatoBePassed = array( 'author' => ...


0

Unfortunately wp_localize_script() casts all scalars (simple types) in the passed-in array to strings (and then runs html_entity_decode() on them?!), so the casts mentioned by the answer you quote & @TheDeadMedic won't have any effect. A way around it is to put your arguments in an array within the passed-in array, then they don't get mangled, eg: ...


0

Just cast it to a boolean: 'ng_slicknav_parent_links' => ( bool ) $options['ng_slicknav_parent_links'], When the array is JSON-encoded, you'll get: "ng_slicknav_parent_links": true, // or false In other words, the JSON object will also have real boolean values, not a "true" or "false" string.



Top 50 recent answers are included