From 43373a00754a315463f38979f469971f2b199d62 Mon Sep 17 00:00:00 2001 From: Cameron Jones Date: Tue, 19 Apr 2016 10:06:41 +1000 Subject: [PATCH 1/2] Enqueuing SDK --- facebook-page-feed-graph-api.php | 1 + js/sdk.js | 1 + 2 files changed, 2 insertions(+) create mode 100644 js/sdk.js diff --git a/facebook-page-feed-graph-api.php b/facebook-page-feed-graph-api.php index c654291..f7b72d5 100644 --- a/facebook-page-feed-graph-api.php +++ b/facebook-page-feed-graph-api.php @@ -99,6 +99,7 @@ function facebook_page_plugin_generate_wrapper_id() { //Client side stuff //Parse shortcode function facebook_page_plugin( $filter ) { + wp_enqueue_script( 'facebook-page-plugin-sdk', CJW_FBPP_PLUGIN_URL . 'js/sdk.js', array(), NULL, true ); wp_enqueue_script( 'facebook-page-plugin-responsive-script', CJW_FBPP_PLUGIN_URL . 'js/responsive.min.js', 'jquery', NULL, true ); $return = NULL; $a = shortcode_atts( array( diff --git a/js/sdk.js b/js/sdk.js new file mode 100644 index 0000000..4abcdc6 --- /dev/null +++ b/js/sdk.js @@ -0,0 +1 @@ +(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/" + facebook_page_plugin_language.language + "/sdk.js#xfbml=1&version=v2.4";fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); \ No newline at end of file From cd9d9d02d636a5fd52f032ee70d29ea9aad26c50 Mon Sep 17 00:00:00 2001 From: Cameron Jones Date: Tue, 19 Apr 2016 10:08:30 +1000 Subject: [PATCH 2/2] Localising SDK --- facebook-page-feed-graph-api.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/facebook-page-feed-graph-api.php b/facebook-page-feed-graph-api.php index f7b72d5..f0ff543 100644 --- a/facebook-page-feed-graph-api.php +++ b/facebook-page-feed-graph-api.php @@ -120,6 +120,10 @@ function facebook_page_plugin( $filter ) { ), $filter ); if(isset($a['href']) && !empty($a['href'])){ $a['language'] = str_replace("-", "_", $a['language']); + + //Send the language as a parameter to the SDK + wp_localize_script( 'facebook-page-plugin-sdk', 'facebook_page_plugin_language', array( 'language' => $a['language'] ) ); + $return .= '
'; $return .= '
'; $return .= '