<?php
// =================================================
// Assign Share Buttons Scripts After Body Tag
// =================================================
function serpentsoft_share_buttons_assign_to_body(){
    $fb_appID = '';
    if( serpentsoft_get_data('serpentsoft_switch_social_facebook_sdk') ){
        $fb_appID = '&appId=' . serpentsoft_get_data('serpentsoft_switch_social_facebook_sdk_appid');
    } ?>

    <!-- Facebook Script -->
    <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/all.js#xfbml=1<?php echo $fb_appID; ?>";
          fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    <?php if( serpentsoft_get_data('serpentsoft_switch_social_share_twitter') ): ?>
        <!-- Twitter Script -->
        <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
    <?php endif; if( serpentsoft_get_data('serpentsoft_switch_social_share_googleplus') ): ?>    
        <!-- Google Plus Script -->
        <script type="text/javascript">
            (function() {
              var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
              po.src = 'https://apis.google.com/js/plusone.js';
              var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
            })();
        </script>
          
    <?php endif; if( serpentsoft_get_data('serpentsoft_switch_social_share_linkedin') ): ?>
        <!-- LinkedIn Script -->
        <script src="//platform.linkedin.com/in.js" type="text/javascript">lang: en_US</script>
    <?php endif; if( serpentsoft_get_data('serpentsoft_switch_social_share_stumbleupon') ): ?>
    <!-- Stumble Upon Script -->
    <script type="text/javascript">
      (function() {
        var li = document.createElement('script'); li.type = 'text/javascript'; li.async = true;
        li.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + '//platform.stumbleupon.com/1/widgets.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(li, s);
      })();
    </script>
    <?php endif;
}

// =================================================
// Put Share Buttons In Post
// =================================================
function serpentsoft_share_buttons_post(){ ?>
    <ul>
    <?php if( serpentsoft_get_data('serpentsoft_switch_social_share_facebook') ): ?>
        <li><fb:share-button href="<?php esc_url(the_permalink()); ?>" type="button_count"></fb:share-button></li>
    
    <?php endif; if( serpentsoft_get_data('serpentsoft_switch_social_like_facebook') ): ?>
        <li><div class="fb-like" data-href="<?php the_permalink(); ?>" data-width="90" data-layout="button_count" data-show-faces="false" data-send="false"></div></li>
    
    <?php endif; if( serpentsoft_get_data('serpentsoft_switch_social_share_twitter') ): ?>
        <li><a href="<?php echo 'https://twitter.com/share'; ?>" class="twitter-share-button" data-url="<?php the_permalink(); ?>" data-text="<?php the_title(); ?>" data-via="<?php echo serpentsoft_get_data('serpentsoft_switch_social_share_twitter_user_name'); ?>">Tweet</a></li>
    
    <?php endif; if( serpentsoft_get_data('serpentsoft_switch_social_share_googleplus') ): ?>
        <li><div class="g-plus" data-action="share" data-annotation="bubble" data-href="<?php the_permalink(); ?>"></div></li>

    <?php endif; if( serpentsoft_get_data('serpentsoft_switch_social_share_linkedin') ): ?>
        <li><script type="IN/Share" data-url="<?php the_permalink(); ?>" data-counter="right"></script></li>
            
    <?php endif; if( serpentsoft_get_data('serpentsoft_switch_social_share_stumbleupon') ): ?>
        <li><su:badge layout="1"></su:badge></li>
    <?php endif; ?>
    </ul>
    
<?php }

// =================================================
// Put Share Buttons In Post
// =================================================
function serpentsoft_fb_comment_box($num_of_posts = 10){ ?>
    <div class="fb-comments" data-href="<?php the_permalink(); ?>" data-width="604" num_posts="<?php echo $num_of_posts; ?>" order_by="social"></div>
<?php } ?>