Created
November 24, 2015 23:39
-
-
Save ericakfranz/181717a88c4370662c41 to your computer and use it in GitHub Desktop.
Easily include the Facebook SDK script, useful when adding Facebook Social Plugins to your site: https://developers.facebook.com/docs/plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Genesis - Facebook SDK | |
* Plugin URI: https://fatpony.me/ | |
* Description: Adds the Facebook SDK script just after the opening <body> tag on Genesis Framework sites. | |
* Version: 1.0.0 | |
* Author: Erica Franz | |
* Author URI: https://fatpony.me/ | |
* License: GPL2 | |
*/ | |
defined( 'ABSPATH' ) or die( 'No jellyfish!' ); | |
add_action( 'genesis_before', 'fb_sdk_output' ); | |
/* | |
* Facebook recommends adding the SDK script just after the opening <body> tag. | |
* Let's hook into 'genesis_before' to do this. | |
*/ | |
function fb_sdk_output() { | |
echo '<div id="fb-root"></div> | |
<script>(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/en_US/sdk.js#xfbml=1&version=v2.5&appId=1441666172782934"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, "script", "facebook-jssdk"));</script>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment