diff --git a/sc/social/like/plugins/facebook/browser.py b/sc/social/like/plugins/facebook/browser.py index b40ec3c7..2603848e 100644 --- a/sc/social/like/plugins/facebook/browser.py +++ b/sc/social/like/plugins/facebook/browser.py @@ -17,10 +17,6 @@ from zope.component import getMultiAdapter -BASE_URL = 'https://www.facebook.com/plugins/like.php?' -PARAMS = 'locale={0}&href={1}&send=false&layout={2}&show_faces=true&action={3}' - - class PluginView(BrowserView): fb_enabled = False @@ -62,13 +58,13 @@ def is_plone_5(self): def fbjs(self): js_source = """ - (function() {{ - var po = document.createElement('script'); - po.async = true; - po.src = document.location.protocol + '//connect.facebook.net/{0}/all.js#xfbml=1'; - var head = document.getElementsByTagName('head')[0]; - head.appendChild(po); - }}()); + (function(d, s, id) {{ + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) return; + js = d.createElement(s); js.id = id; + js.src = "//connect.facebook.net/{0}/sdk.js#xfbml=1&version=v2.10"; + fjs.parentNode.insertBefore(js, fjs); + }}(document, 'script', 'facebook-jssdk')); """.format(self.language) return js_source diff --git a/sc/social/like/plugins/facebook/templates/metadata.pt b/sc/social/like/plugins/facebook/templates/metadata.pt index 70621b70..d26828e6 100644 --- a/sc/social/like/plugins/facebook/templates/metadata.pt +++ b/sc/social/like/plugins/facebook/templates/metadata.pt @@ -16,5 +16,5 @@ - + diff --git a/sc/social/like/tests/test_plugin_facebook.py b/sc/social/like/tests/test_plugin_facebook.py index 7d62faa0..040ac07a 100644 --- a/sc/social/like/tests/test_plugin_facebook.py +++ b/sc/social/like/tests/test_plugin_facebook.py @@ -251,12 +251,12 @@ def test_plugin_language(self): self.document.setLanguage('pt-br') view = document.restrictedTraverse(plugin_view) html = view.metadata() - self.assertIn('connect.facebook.net/pt_BR/all.js', html) + self.assertIn('connect.facebook.net/pt_BR/sdk.js', html) self.document.setLanguage('en') view = document.restrictedTraverse(plugin_view) html = view.metadata() - self.assertIn('connect.facebook.net/en_GB/all.js', html) + self.assertIn('connect.facebook.net/en_GB/sdk.js', html) def test_plugin_view_typebutton(self): portal = self.portal