Support » Plugin: Yoast SEO » Uncaught SyntaxError: Unexpected token & on admin area

  • WordPress version: 3.5
    WordPress SEO version:

    I did this: Activated the plugin

    I expected the plugin to do this: Run smoothly

    Instead it did this: Produced this error in the browser’s console:
    Uncaught SyntaxError: Unexpected token &.

    I have disabled all other plugins and switched back to both twenty-eleven and twenty-twelve themes to test it. The error persists, but only when viewing the administration area. Here’s the problematic code section:

    <script type="text/javascript">
    		(function ($) {
    			var wpseo_pointer_options = {"content":"<h3>Help improve WordPress SEO<\/h3><p>You've just installed WordPress SEO by Yoast. Please helps us improve it by allowing us to gather anonymous usage stats so we know which configurations, plugins and themes to test with.<\/p>","position":{"edge":"top","align":"center"}}, setup;
    			wpseo_pointer_options = $.extend(wpseo_pointer_options, {
    				buttons:function (event, t) {
    					button = jQuery('<a id="pointer-close" style="margin-left:5px" class="button-secondary">' + 'Do not allow tracking' + '</a>');
    					button.bind('click.pointer', function () {
    					return button;
    				close:function () {
    			setup = function () {
    									jQuery('#pointer-close').after('<a id="pointer-primary" class="button-primary">' + 'Allow tracking' + '</a>');
    					jQuery('#pointer-primary').click(function () {
    						document.location=&quot;;;					});
    Uncaught SyntaxError: Unexpected token &
    					jQuery('#pointer-close').click(function () {
    													document.location=&quot;;;												});
    			if (wpseo_pointer_options.position && wpseo_pointer_options.position.defer_loading)
    				$(window).bind('load.wp-pointers', setup);

    The double quotes around the url get escaped for some reason, and they should not be esacaped.

Viewing 1 replies (of 1 total)
  • Was just about to post this too – troublemaker is WPSEO_Pointers::print_scripts, lines 233 & 239, which applies esc_js() to the button function parameters.

    Escaping should be performed (where necessary) as the caller builds the JS code, and then printed as-is by print_scripts().

Viewing 1 replies (of 1 total)
  • The topic ‘Uncaught SyntaxError: Unexpected token & on admin area’ is closed to new replies.