WordPress.org

Forums

Social PopUP - Facebook, Twitter & Google+
[resolved] spu.js error breaks other plugins/theme when twttr is not defined (2 posts)

  1. zytzagoo
    Member
    Posted 1 year ago #

    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/

  2. Damian
    Member
    Plugin Contributor

    Posted 1 year ago #

    Thanks! I will add it on next release. Also created a github repository for the plugin as I don't have much time to maintain it.

    https://github.com/timersys/social-popup/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.