<?php if (helper_getsession('reaction_vote_count_' . $blog['blog_id'], 'int') < 1): ?>
  
  <span class="vote_counter"><?php echo $reactions; ?></span>
  <a onclick="add_reaction('<?php echo $reaction; ?>', '<?php echo $blog['blog_id'] ?>')" href="javascript:void(0)"><i class="<?php echo $icon; ?>" aria-hidden="true"></i></a> 
<?php else:
    if (is_reaction_voted($blog['blog_id'], $reaction) == 1): ?>

      <span class="vote_counter"><?php echo $reactions; ?></span>
      <a onclick="add_reaction('<?php echo $reaction; ?>', '<?php echo $blog['blog_id'] ?>')" href="javascript:void(0)"><i class="<?php echo $icon; ?>" aria-hidden="true"></i></a> 
    <?php else: ?>
      
      <span class="vote_counter"><?php echo $reactions; ?></span>
      <a class="disabled" onclick="add_reaction('<?php echo $reaction; ?>', '<?php echo $blog['blog_id'] ?>')" href="javascript:void(0)"><i class="<?php echo $icon; ?>" aria-hidden="true"></i></a> 
    <?php endif; ?>

<?php endif; ?>
<script type="text/javascript">
function add_reaction(reaction, id) 
{
  $.ajax({
      method: "POST",
      url:"<?php echo base_url()?>/home/save_reaction",
      data: {post_id:id, reaction:reaction},
      success: function(d) 
      {
        document.getElementById("reactions_result").innerHTML = d;
        $("#reactions_r").load(window.location.href + " #reactions_r" );
      },
      error: function(xhr, textStatus) {
        // console.log(xhr.responseText)
      }
  })
}
</script>