Created
June 23, 2015 14:04
-
-
Save mikejolley/31390769327c16fba662 to your computer and use it in GitHub Desktop.
ShareThis integration code for WooCommerce
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
if ( ! defined( 'SHARETHIS_PUBLISHER_ID' ) ) { | |
define( 'SHARETHIS_PUBLISHER_ID', 'enter your id here' ); | |
} | |
function sharethis_for_woocommerce() { | |
global $post; | |
$thumbnail_id = get_post_thumbnail_id( $post->ID ); | |
$thumbnail = $thumbnail_id ? current( wp_get_attachment_image_src( $thumbnail_id, 'large' ) ) : ''; | |
?> | |
<div class="social"> | |
<iframe src="https://www.facebook.com/plugins/like.php?href=<?php echo esc_attr( urlencode( get_permalink( $post->ID ) ) ); ?>&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light&height=21" style="border:none; overflow:hidden; width:100px; height:21px;"></iframe> | |
<span class="st_twitter"></span><span class="st_email"></span><span class="st_sharethis" st_image="<?php echo esc_attr( urlencode( $thumbnail ) ); ?>"></span><span class="st_plusone_button"></span> | |
</div> | |
<script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="https://ws.sharethis.com/button/buttons.js"></script> | |
<script type="text/javascript">stLight.options({publisher:"<?php echo esc_attr( SHARETHIS_PUBLISHER_ID ); ?>"});</script> | |
<?php | |
} | |
add_action( 'woocommerce_share', 'sharethis_for_woocommerce' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment