-
Notifications
You must be signed in to change notification settings - Fork 4
/
pinim-ajax.php
65 lines (45 loc) · 1.73 KB
/
pinim-ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
function pinim_login_ajax(){
$result = array(
'success' => false
);
$result['message'] ="yololo";
/*
if (!isset($_POST['post_id'])) return false;
$post_id = $_POST['post_id'];
if ( $action=='pinim_post_vote_up' ){
$nonce = 'vote-up-post_'.$post_id;
}else if ( $action=='pinim_post_vote_down' ){
$nonce = 'vote-down-post_'.$post_id;
}
if( ! wp_verify_nonce( $_POST['_wpnonce'], $nonce ) ) return false;
if ( $action=='pinim_post_vote_up' ){
$vote = pinim()->do_post_vote($post_id,true);
}else if ( $action=='pinim_post_vote_down' ){
$vote = pinim()->do_post_vote($post_id,false);
}
if ( !is_wp_error( $vote ) ) {
$result['success'] = true;
$score = pinim_get_votes_score_for_post($post_id);
$score_display = pinim_number_format($score);
$votes_count = pinim_get_votes_count_for_post($post_id);
$vote_count_display = pinim_number_format($votes_count);
$result['score_text'] = sprintf(__('Score: %1$s','pinim'),$score_display);
$result['score_title'] = sprintf(__('Votes count: %1$s','pinim'),$vote_count_display);
}else{
$result['message'] = $vote->get_error_message();
}
*/
header('Content-type: application/json');
echo json_encode($result);
die();
}
function pinim_get_votes_log_ajax(){
if (!isset($_POST['post_id'])) return false;
echo pinim_get_post_votes_log( $_POST['post_id'] );
die();
}
add_action('wp_ajax_pinim_login', 'pinim_login_ajax');
//add_action('wp_ajax_pinim_post_vote_down', 'pinim_post_vote_ajax');
//add_action('wp_ajax_pinim_get_votes_log', 'pinim_get_votes_log_ajax');
?>