Use json_encode instead of add_slashes in PHP->JS code
-
Hi Greg,
Sorry to bother you again, this is just a tip actually, I saw that you replaced htmlentities with addslashes in your code, you could use json_encode to ensure all characters are compatible with JS.
For example:
text: '<b><?php echo addslashes(__($chart_title, 'wp_statistics')); ?></b>',
would become
text: <?php echo json_encode('<b>' . __($chart_title, 'wp_statistics') . '</b>') ?>,
it will include starting and closing quotes too and escape other things like /b.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Use json_encode instead of add_slashes in PHP->JS code’ is closed to new replies.