Support » Plugin: Social PopUP - Facebook, Twitter & Google+ » spu.js error breaks other plugins/theme when twttr is not defined

  • Resolved zytzagoo

    (@zytzagoo)


    This happens for users that use Ghostery, disconnect.me or similar privacy enhancers (or if Twitter CDN is down), and it breaks other js-based functionalities on the site (think jQuery Colorbox or similar)

    It’s due to using the global twttr variable without checking if it’s available (and when it’s not, any other potential JS stops executing)

    Quick fix:

    Replace (lines 70-74) in spu.js:

    twttr.ready(function(twttr) {
    	clearInterval(counter);
    	twttr.events.bind('tweet', twitterCB);
    	twttr.events.bind('follow', twitterCB);
    });

    With:

    if (typeof twttr !== 'undefined') {
    		twttr.ready(function(twttr) {
    			clearInterval(counter);
    			twttr.events.bind('tweet', twitterCB);
    			twttr.events.bind('follow', twitterCB);
    		});
    	}

    P.S.
    Is there a github repo available for the plugin? (in case you’d like an easily mergeable pull request)

    (edited to try to add the missing tab character at the beginning of the replacement code block, but it’s eaten on submit/display and doesn’t go through…)

    http://wordpress.org/plugins/social-popup/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘spu.js error breaks other plugins/theme when twttr is not defined’ is closed to new replies.