<?php 
global $redux_demo;
if(is_user_logged_in() ) {
    $userid = wp_get_current_user();
    $bookmarks = get_user_meta($userid->ID, 'bookmarks', true);
    $bookmarks = unserialize($bookmarks);
}
if(isset($bookmarks) && $bookmarks && in_array($post->ID, $bookmarks) ) {
    $bookmarked = 1;
}
else {
    $bookmarked = 0;
}
?>
<div class="buttons-bar">
    <div class="buttons">
        <?php
        //repost, only if it's enabled
        if($redux_demo['enable_repost'] != '2') { ?>
            <a data-id="<?php echo $post->ID;?>" class='repost has-tooltip' data-title="REPOST"><?php _e('Repost', 'Aruna');?></a>
        <?php } 
        //bookmarks, only if it's enabled
        if($redux_demo['enable_bookmarks'] != '2') { ?>
            <a <?php if(!isset($userid) ) echo 'href="#registerModal" data-toggle="modal"'; else echo 'href="javascript:void(0)"';?> class='<?php if(isset($userid) ) echo 'loggedin ';?> bookmark<?php if($bookmarked == 1) { echo 'ed'; } ?> has-tooltip' data-id="<?php echo $post->ID;?>" data-title="<?php if($bookmarked == 1 ) _e('BOOKMARKED', 'Aruna'); else _e('BOOKMARK', 'Aruna');?>"><?php if($bookmarked == 1) _e('bookmarked', 'Aruna'); else _e('bookmark', 'Aruna');?></a>
        <?php } ?>
        <div class="count"><?php echo teo_views_number($post->ID);?></div>
    </div>
    <div class="social-icons">
        <?php
        //social share buttons, only if they're enabled
        if($redux_demo['enable_fbshare'] != '2') { ?>
            <a href="javascript:void(0)" data-href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink();?>" class='facebook has-tooltip' data-title="<?php _e('Share on Facebook', 'Aruna');?>"><i class="fa fa-facebook"></i></a>
        <?php }
        if($redux_demo['enable_twshare'] != '2') { ?>
            <a href="javascript:void(0)" data-href="https://twitter.com/intent/tweet?source=tweetbutton&amp;text=<?php the_title();?>&url=<?php the_permalink();?>" class='twitter has-tooltip' data-title="<?php _e('Share on Twitter', 'Aruna');?>"><i class="fa fa-twitter"></i></a>
        <?php }
        if($redux_demo['enable_gplusshare'] != '2') { ?>
            <a href="javascript:void(0)" data-href="https://plus.google.com/share?url=<?php the_permalink();?>" class='googleplus has-tooltip' data-title="<?php _e('Share on Google +', 'Aruna');?>"><i class="fa fa-google-plus"></i></a>
        <?php }
        if($redux_demo['enable_linkedinshare'] != '2') { ?>
            <a href="javascript:void(0)" data-href="https://www.linkedin.com/shareArticle?mini=true&amp;url=<?php the_permalink();?>&amp;title=<?php the_title();?>&amp;summary=&amp;source=" class='linkedin has-tooltip' data-title="<?php _e('Share on LinkedIn', 'Aruna');?>"><i class="fa fa-linkedin"></i></a>
        <?php }
        if($redux_demo['enable_pinterestshare'] != '2' && get_post_format() == 'image' || get_post_format() == 'gallery' || get_post_format() == 'quote') {
            //getting the correct image for different post formats
            $format = get_post_format();
            if($format == 'image' || $format == 'standard') {
                $image = get_post_meta($post->ID, '_standard_image', true);
            }
            elseif($format == 'gallery') {
                for($i=1; $i<=10; $i++) {
                    $image = get_post_meta($post->ID, '_slider_image' . $i, true);
                    if($image != '') {
                        //image found, we exit the for statement
                        break;
                    }
                }
            }
            elseif($format == 'quote') {
                $image = get_post_meta($post->ID, '_quote_image', true);
            }
            if($image == '') {
               $image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
            }
            if($image != '') { //we show the pinterest button only if there's an actual image to be pined
        ?>
            <a href="javascript:void(0)" data-href="https://pinterest.com/pin/create/button/?url=<?php the_permalink();?>&amp;media=<?php echo $image;?>&amp;description=" class='googleplus has-tooltip' data-title="<?php _e('Share on Pinterest', 'Aruna');?>"><i class="fa fa-pinterest"></i></a>
        <?php }
        }
        if($redux_demo['enable_emailshare'] != '2') { 
            $subject = 'Check out "' . get_the_title() . '"';
            $body = 'This is extremely awesome, you should really take a look! :-) ' . get_permalink();
            ?>
            <a href="mailto:?subject=<?php echo esc_html($subject);?>&amp;body=<?php echo esc_html($body);?>" class='mail has-tooltip' data-title="<?php _e('Share via Email', 'Aruna');?>"><i class="fa fa-envelope"></i></a>
        <?php } ?>
    </div>
</div>