Support » Plugin: Global Javascript » Need to Add add_magic_quotes() when saving

  • In v1 in global-javascript.php, you need to use add_magic_quotes prior to saving to the database. The reason is WordPress automatically removes backslashes, but they need to be saved in JavaScript regular expressions.

    On line 188, change to:
    $post_id = wp_insert_post(add_magic_quotes($post));

    On line 197, change to: wp_update_post(add_magic_quotes($safejs_post));

    I’m using WordPress v4.0.1.

    The is the code you can use to test with. Once you save it in the plugin, it will remove the backslashes in the GUI once the page reloads from the save.
    function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, “,”);

Viewing 2 replies - 1 through 2 (of 2 total)
  • pcchynoweth


    I had to use this workaround in order to use \n in javascript alert.

    Any chance this will be fixed in a new version of the plugin?

    thanks for posting the fix. i think one of us should try to become a plugin author for this and make this update. No action in years. It’s a kick-ass plugin, and there’s really nothing as simple as this for this purpose.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need to Add add_magic_quotes() when saving’ is closed to new replies.