Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Info2grow, how did you fix it?

    Thread Starter info2grow

    (@info2grow)

    Never heard back so we uninstalled it.

    Thanks for the reply info2grow.

    I did following, knowing that this is not clever because of updates coming.

    file: wordpress-seo/frontend/class-frontend.php

    //echo “<script type=’application/ld+json’>”, json_encode( $this->data ), ‘</script>’, “\n”;

    //$this->output( ‘website’ );

    I faced the same issue, and have been able to resolve it.

    Looks like the browser isn’t able to recognize ld+json format outside the body tags of the page. The plugin adds the data before the body tag, and hence the error. If the structured data is written inside the body tags, it works totally fine.
    Initially I tried using a try catch block as below:

    var t = {
        //json data
    };
    try {
        jQuery.globalEval(t)
    } catch (e) {
        console.log(e)
    }

    but Google wasn’t able to understand this, so I had to revert the changes.
    Then after more hits and trials, I was able to fix it:
    file: wordpress-seo/frontend/class-frontend.php (Version: upto 2.1.1)
    Line: 1914

    echo "<script type='application/ld+json'>", json_encode( array($this->data) ), '</script>', "\n";

    which has been verified to work, although, I would really appreciate if someone could provide a better fix than this.
    It is strange, how such a major issue went unnoticed from the plugin development team. Let’s hope they fix it soon.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Uncaught SyntaxError: Unexpected Token’ is closed to new replies.