ericakfranz
11/24/2015 - 11:39 PM

Easily include the Facebook SDK script, useful when adding Facebook Social Plugins to your site: https://developers.facebook.com/docs/plugin

Easily include the Facebook SDK script, useful when adding Facebook Social Plugins to your site: https://developers.facebook.com/docs/plugins

<?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>';
   }