Ejemplo n.º 1
0
/**
 * Output the like button
 * @since    0.5
 */
function get_simple_likes_button($post_id, $is_comment = NULL)
{
    $is_comment = NULL == $is_comment ? 0 : 1;
    $output = '';
    $nonce = wp_create_nonce('simple-likes-nonce');
    // Security
    if ($is_comment == 1) {
        $post_id_class = esc_attr(' sl-comment-button-' . $post_id);
        $comment_class = esc_attr(' sl-comment');
        $like_count = get_comment_meta($post_id, "_comment_like_count", true);
        $like_count = isset($like_count) && is_numeric($like_count) ? $like_count : 0;
    } else {
        $post_id_class = esc_attr(' sl-button-' . $post_id);
        $comment_class = esc_attr('');
        $like_count = get_post_meta($post_id, "_post_like_count", true);
        $like_count = isset($like_count) && is_numeric($like_count) ? $like_count : 0;
    }
    $count = get_like_count($like_count);
    $icon_empty = get_unliked_icon();
    $icon_full = get_liked_icon();
    // Loader
    $loader = '<span id="sl-loader"></span>';
    // Liked/Unliked Variables
    if (already_liked($post_id, $is_comment)) {
        $class = esc_attr(' tm-liked');
        $title = __('Unlike', 'tbr');
        $icon = $icon_full;
    } else {
        $class = '';
        $title = __('Like', 'tbr');
        $icon = $icon_empty;
    }
    $output = '<span class="sl-wrapper"><a href="' . admin_url('admin-ajax.php?action=process_simple_like' . '&nonce=' . $nonce . '&post_id=' . $post_id . '&disabled=true&is_comment=' . $is_comment) . '?no_cache=1" class="uk-button ' . $post_id_class . $class . $comment_class . '" data-nonce="' . $nonce . '" data-post-id="' . $post_id . '" data-iscomment="' . $is_comment . '" title="' . $title . '">' . $icon . $count . '</a>' . $loader . '</span>';
    return $output;
}
Ejemplo n.º 2
0
</article>
    <aside>

        <div class='post-content-like-button'>
          <a href='#' class='likeLink' data-id=<?php 
echo the_id();
?>
 data-number=<?php 
echo get_like_count($post->ID);
?>
>
            <i class="fa fa-heart"></i>
          </a>
        </div>
        <div class='post-content-like-prompt'>赞<span id='like-number'>(<?php 
echo get_like_count($post->ID);
?>
)</span></div>
      <?php 
comments_template('', true);
?>
    </aside>
  </article>
</div>
<script>
  (function() {
    $('.comment-reply-button').on('click', function(event) {
      var commentParentId = $(this).attr('data-comment-parent-id');
      $('#comment_parent').val(commentParentId);
      $('#comment').focus();
    });
Ejemplo n.º 3
0
/**
 * Output the like button
 * @since    0.5
 */
function get_simple_likes_button($post_id)
{
    $output = '';
    $nonce = wp_create_nonce('simple-likes-nonce');
    // Security
    $post_id_class = esc_attr(' like-button-' . $post_id);
    $like_count = get_post_meta($post_id, "_post_like_count", true);
    $like_count = isset($like_count) && is_numeric($like_count) ? $like_count : 0;
    $count = get_like_count($like_count);
    // Liked/Unliked Variables
    if (already_liked($post_id)) {
        $class = esc_attr(' liked');
        $title = __('Liked', 'kindel');
    } else {
        $class = '';
        $title = __('Like', 'kindel');
    }
    $ajax_url = admin_url('admin-ajax.php?action=process_post_like&nonce=' . $nonce . '&post_id=' . $post_id . '&disabled=true"');
    $output = '<a href="' . $ajax_url . '" class="like-button' . $post_id_class . $class . '" data-nonce="' . $nonce . '" data-post-id="' . $post_id . '" title="' . $title . '">';
    $output .= '<span class="like-icon">';
    $output .= '<div class="heart-animation-1"></div>';
    $output .= '<div class="heart-animation-2"></div>';
    $output .= '</span><span class="text">' . $title . '</span></a>';
    return $output;
}
Ejemplo n.º 4
0
</div>
          <div class='archives-list-item-footer-item author'><?php 
    echo get_the_author_meta('display_name');
    ?>
</div>
          </div>
          <div class='archives-list-item-footer-item-right'>
            <div class='archives-list-item-footer-item comment'>
              <i class="fa fa-commenting archives-list-item-footer-item-comment-icon"></i><span><?php 
    echo get_comments_number($post);
    ?>
</span>
            </div>
            <div class='archives-list-item-footer-item like'>
              <i class="fa fa-heart archives-list-item-footer-item-like-icon"></i><span><?php 
    echo get_like_count($query->post->ID);
    ?>
</span>
            </div>
          </div>
        </section>
      </div>
    <?php 
}
?>
  </div>
  <!-- <?php 
echo pagination($page, $pages);
?>
 -->
</div>
Ejemplo n.º 5
0
    echo get_avatar($item->post_author, 64);
    ?>
</div>
            <div class='archives-list-item-footer-item author'><?php 
    echo the_author_meta('display_name', $item->post_author);
    ?>
</div>
            </div>
            <div class='archives-list-item-footer-item-right'>
              <div class='archives-list-item-footer-item comment'>
                <i class="fa fa-commenting archives-list-item-footer-item-comment-icon"></i><span><?php 
    echo custom_get_comment_count($item->ID);
    ?>
</span>
              </div>
              <div class='archives-list-item-footer-item like'>
                <i class="fa fa-heart archives-list-item-footer-item-like-icon"></i><span><?php 
    echo get_like_count($item->ID);
    ?>
</span>
              </div>
            </div>
          </section>
        </div>
    <?php 
}
?>
    <?php 
echo pagination($page, $pages);
?>
</div>
Ejemplo n.º 6
0
<body>
  <div class="container" style="margin-top: 20px">
  <?php 
// Perform a query that pulls like info and img src
// from photos the user is tagged in.
$fql_query = "SELECT like_info, src_big FROM photo where object_id in \n        (SELECT object_id FROM photo_tag where subject={$user})";
$photos = $facebook->api(array('method' => 'fql.query', 'query' => $fql_query));
/* Get the average number of likes */
// $likes is an array of like count. We take out all the 0 likes from $likes
$likes = array_map("get_like_count", $photos);
$likes = array_filter($likes, create_function('$likes', 'return $likes > 0;'));
// Compute the average number of likes
$average_like = array_sum($likes) / count($likes);
// Print out the average number of likes
echo "<div class='page-header'>\n        <h1>\n          On average, " . round($average_like, 2) . " people like \n          photos you are tagged in\n          <small>Congratulations</small>\n        </h1>\n      </div>";
/* Get most liked photos */
// Sort photos based on like count
usort($photos, create_function('$photo1, $photo2', 'return get_like_count($photo2) - get_like_count($photo1);'));
// Grab the 3 most liked photos
$popular_photos = array_slice($photos, 0, 3);
// Display the 3 most liked photos
echo "<h3>Photos you're in that have the most likes:</h3><br/>\n          <ul class='thumbnails'>";
foreach ($popular_photos as $popular_photo) {
    echo "<li class='span4'>\n              <div class='thumbnail'>\n                <img src=" . $popular_photo['src_big'] . "/>\n                <div class='caption'>\n                " . get_like_count($popular_photo) . " people liked this<br/>\n              </div>\n            </li>";
}
echo "</ul>";
?>
  </div>
</body>
</html>