-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax.php
More file actions
142 lines (124 loc) · 3.32 KB
/
Copy pathajax.php
File metadata and controls
142 lines (124 loc) · 3.32 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
add_action('wp_ajax_block_user', 'block_user');
add_action('wp_ajax_nopriv_block_user', 'block_user');
function block_user() {
global $wpdb;
global $current_user;
get_currentuserinfo();
$blk_id = $_POST['blk_id'];
$blocked_users=unserialize($current_user->blocked_users);
if($blocked_users==false)
$blocked_users=array();
if(!in_array($blk_id,$blocked_users))
{
array_push($blocked_users,$blk_id);
update_user_meta($current_user->ID, 'blocked_users', serialize($blocked_users));
}
get_currentuserinfo();
$blocked_users=unserialize($current_user->blocked_users);
?>
<select id="unblck_id" size="5">
<?php
if($blocked_users!=false)
{
foreach($blocked_users as $b)
{?>
<option id="<?php echo $b;?>" value="<?php echo $b;?>"><?php $user_info = get_userdata($b); echo $user_info->display_name;?></option><?php
}
}
?>
</select>
<?
die;
}
add_action('wp_ajax_unblock_user', 'unblock_user');
add_action('wp_ajax_nopriv_unblock_user', 'unblock_user');
function unblock_user() {
global $wpdb;
global $current_user;
get_currentuserinfo();
$id = $_POST['id'];
//echo "id - ".$id;
$blocked_users=unserialize($current_user->blocked_users);
//var_dump($blocked_users);
//echo "<br>".in_array($id,$blocked_users);
if($blocked_users==false)
$blocked_users=array();
if(in_array($id,$blocked_users))
{
$key=array_search($id, $blocked_users);
//echo "id - ".$id."key - ".$key;
unset($blocked_users[$key]);
$arr=array();
foreach($blocked_users as $b)
{
array_push($arr,$b);
}
//var_dump($arr);
update_user_meta($current_user->ID, 'blocked_users', serialize($arr));
}
get_currentuserinfo();
$blocked_users=unserialize($current_user->blocked_users);
?>
<select id="unblck_id" size="5">
<?php
if($blocked_users!=false)
{
foreach($blocked_users as $b)
{?>
<option id="<?php echo $b;?>" value="<?php echo $b;?>"><?php $user_info = get_userdata($b); echo $user_info->display_name;?></option><?php
}
}
?>
</select>
<?
die;
}
add_action('wp_ajax_sip_it', 'sip_it');
add_action('wp_ajax_nopriv_sip_it', 'sip_it');
function sip_it()
{
require_once('custom_functions/sipping.php');
global $current_user;
get_currentuserinfo();
$post_id = $_POST['id'];
$sipper_id=$current_user->id;
$rtrn=sipit($sipper_id,$post_id);
echo $rtrn;
die;
}
/*function sip_it() {
global $wpdb;
global $current_user;
get_currentuserinfo();
$post_id = $_POST['id'];
$sip_it = intval(get_post_meta($post_id,'sip_it',true));
$sip_it++;
update_post_meta($post_id,'sip_it',$sip_it);
echo $sip_it;
die;
}*/
add_action('wp_ajax_spit_it', 'spit_it');
add_action('wp_ajax_nopriv_spit_it', 'spit_it');
function spit_it()
{
require_once('custom_functions/sipping.php');
global $current_user;
get_currentuserinfo();
$post_id = $_POST['id'];
$sipper_id=$current_user->id;
$rtrn=spitit($sipper_id,$post_id);
echo $rtrn;
die;
}
/*function spit_it() {
global $wpdb;
global $current_user;
get_currentuserinfo();
$post_id = $_POST['id'];
$spit_it = intval(get_post_meta($post_id,'spit_it',true));
$spit_it++;
update_post_meta($post_id,'spit_it',$spit_it);
echo $spit_it;
die;
}*/