Example #1
0
<?php

session_start();
include "../config.php";
include "../functions.php";
include "../private_functions.php";
if (isset($_SESSION['auth']) && $_SESSION['auth'] == 1 && isset($_GET['pID'])) {
    $dbh = db_connect($MY_HOST, $MY_DB_PORT, $MY_DB, $DB_USER, $DB_PW);
    $res = already_liked($dbh, $_SESSION['user'], $_GET['pID']);
    close_db_connection($dbh);
    if ($res) {
        echo json_encode(array("status" => 1));
    } else {
        echo json_encode(array("status" => 0));
    }
} else {
    echo json_encode(array("status" => -1));
}
Example #2
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;
}
Example #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;
}