Created
September 29, 2015 21:27
-
-
Save designbuildtest/2267c8e13e7f13dda56a to your computer and use it in GitHub Desktop.
Facebook and Disqus Comments
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
/** | |
* Facebook and Disqus Comments - drop-in replacement for comments.php | |
*/ | |
function dbt_facebook_or_disqus_comments() { | |
if ( comments_open() && get_option( 'dbt_facebook_comments_app_id' ) ) { | |
// If Facebook Comments enabled. | |
if ( get_option( 'WPLANG' ) ) { $language = get_option( 'WPLANG' ); } | |
else { $language = 'en_US'; } ?> | |
<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/<?php esc_attr_e( $language ); ?>/sdk.js#xfbml=1&version=v2.4&appId=<?php esc_attr_e( get_option( 'dbt_facebook_comments_app_id' ) ); ?>"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk'));</script> | |
<div class="fb-comments" data-href="<?php echo get_permalink(); ?>" data-numposts="50" data-order-by="reverse_time" data-width="100%"></div><?php | |
} | |
elseif ( comments_open() && get_option( 'dbt_disqus_shortname' ) ) { ?> | |
<?php // If Disqus Comments enabled ?> | |
<div id="disqus_thread"></div> | |
<script type="text/javascript"> | |
var disqus_shortname = '<?php esc_attr_e( get_option( 'dbt_disqus_shortname' ) ); ?>'; | |
(function() { | |
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; | |
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); | |
})(); | |
</script><?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment