-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax-admin-handler.php
109 lines (108 loc) · 3.46 KB
/
ajax-admin-handler.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
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
<?php
add_action('wp_ajax_save_phrase', 'callback_save_phrase');
add_action('wp_ajax_save_color_1', 'callback_save_color_1');
add_action('wp_ajax_save_color_2', 'callback_save_color_2');
add_action('wp_ajax_save_text_color', 'callback_save_text_color');
add_action('wp_ajax_save_deadline', 'callback_save_deadline');
add_action('wp_ajax_save_deadline', 'callback_save_changes');
// add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
include('database-procedures.php');
function callback_save_phrase()
{
$phrase = $_POST['phrase'];
$res = insert_countdown_options('phrase',$phrase,get_current_user_id());
if($res ===true){
$result = array(
'success' => true,
'message' => 'The result is: ' . $res,
);
wp_send_json_success($result);
}else{
wp_send_json_error(array('error' => $res));
}
}
function callback_save_color_1()
{
$phrase = $_POST['color1'];
$res = insert_countdown_options('color1',$phrase,get_current_user_id());
if($res ===true){
$result = array(
'success' => true,
'message' => 'The result is: ' . $res,
);
wp_send_json_success($result);
}else{
wp_send_json_error(array('error' => $res));
}
}
function callback_save_color_2()
{
$phrase = $_POST['color2'];
$res = insert_countdown_options('color2',$phrase,get_current_user_id());
if($res ===true){
$result = array(
'success' => true,
'message' => 'The result is: ' . $res,
);
wp_send_json_success($result);
}else{
wp_send_json_error(array('error' => $res));
}
}
function callback_save_text_color()
{
$phrase = $_POST['textColor'];
$res = insert_countdown_options('color2',$phrase,get_current_user_id());
if($res ===true){
$result = array(
'success' => true,
'message' => 'The result is: ' . $res,
);
wp_send_json_success($result);
}else{
wp_send_json_error(array('error' => $res));
}
}
function callback_save_deadline()
{
$phrase = $_POST['deadline'];
$res = insert_countdown_options('deadline',$phrase,get_current_user_id());
if($res ===true){
$result = array(
'success' => true,
'message' => 'The result is: ' . $res,
);
wp_send_json_success($result);
}else{
wp_send_json_error(array('error' => $res));
}
}
// function callback_save_changes()
// {
// $deadline = $_POST['deadline'];
// $textColor = $_POST['textColor'];
// $color1 = $_POST['color1'];
// $color2 = $_POST['color2'];
// $phrase = $_POST['phrase'];
// $res1 = insert_countdown_options('deadline',$deadline,get_current_user_id());
// $res2 = insert_countdown_options('textColor',$textColor,get_current_user_id());
// $res3 = insert_countdown_options('color1',$color1,get_current_user_id());
// $res4 = insert_countdown_options('color2',$color2,get_current_user_id());
// $res5 = insert_countdown_options('phrase',$phrase,get_current_user_id());
// if(
// ($res1 ===true) &&
// ($res2 ===true) &&
// ($res3 ===true) &&
// ($res4 ===true) &&
// ($res5 ===true)
// ){
// $result = array(
// 'success' => true,
// 'message' => 'The result is: ' . $res,
// );
// wp_send_json_success($result);
// }else{
// wp_send_json_error(array('error' => $res));
// }
// }
?>