Exemplo n.º 1
0
 function miss_likes($echo = true)
 {
     global $post;
     $uid = miss_get_basic_user_identification();
     $miss_likes_array = get_post_meta(get_the_ID(), 'miss_post_likes', true);
     $miss_likes_count = get_post_meta(get_the_ID(), 'miss_post_likes_total', true);
     $out = '';
     //$out .= $miss_likes_array[$uid];
     $out .= '<a href="' . get_permalink() . '" data-id="' . get_the_ID() . '" title="" class="miss_hearts pull-left active">';
     if (isset($miss_likes_array) && isset($uid) && isset($miss_likes_array[$uid])) {
         $out .= '<i class="fa-icon-heart icon"></i>';
     } else {
         $out .= '<i class="fa-icon-heart-empty icon"></i>';
     }
     $out .= '<span class="text">';
     $out .= '<span class="number">';
     $out .= !empty($miss_likes_count) ? $miss_likes_count : '0';
     $out .= '</span>';
     $out .= ' ' . __('LIKES', MISS_TEXTDOMAIN);
     $out .= '</span>';
     $out .= '</a>';
     if ($echo == false) {
         return $out;
     } else {
         echo $out;
     }
 }
Exemplo n.º 2
0
            }
            $count = count($instance);
            update_post_meta($post_id, 'miss_post_likes', $new_instance);
            update_post_meta($post_id, 'miss_post_likes_total', $count);
        }
        //  else {
        // 	$new_instance = '0';
        // 	$count = count( $instance );
        // 	add_post_meta($post_id, 'miss_post_likes', $new_instance, false);
        // 	add_post_meta($post_id, 'miss_post_likes_total', ( $count ), false );
        // }
        return array('count' => $count, 'state' => $miss_like_state);
    }
}
/**
 * Parse Requests
 */
if (isset($_POST['miss-like'])) {
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    header("Content-type: application/json");
    if (miss_get_basic_user_identification()) {
        $response = miss_like_this_post($_POST['post_id'], miss_get_basic_user_identification());
        echo '{"success": true, "response": {"count": "' . $response['count'] . '", "state": "' . $response['state'] . '"}}';
    } else {
        echo '{"success": false, "error": "' . __('Your browser doesn\'t support cookies. Please enable cookies first!', MISS_TEXTDOMAIN) . '"}';
    }
    get_post_meta($_POST['post_id'], 'miss_post_likes_total', true);
    exit;
}