-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocialer_ajax.php
More file actions
50 lines (40 loc) · 973 Bytes
/
socialer_ajax.php
File metadata and controls
50 lines (40 loc) · 973 Bytes
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
<?php
/**
* @author Meshin Dmitry <0x7ffec at gmail.com>
*/
session_start();
define('DOING_AJAX', true);
//Typical headers
header('Content-Type: text/json');
require_once('../../../wp-load.php');
send_nosniff_header();
//Disable caching
header('Cache-Control: no-cache');
header('Pragma: no-cache');
if ( !isset( $_REQUEST[ 'action' ] ) ) {
die(json_encode(array(
'error' => 'No action',
'error_code' => -1
)));
}
$action = esc_attr( $_REQUEST['action'] );
//A bit of security
$allowed_actions = array(
'is_user_registered',
'get_register_button',
'get_tweet_box',
'push_tweet',
'get_scheduled_tweet',
'schedule_tweet',
'get_draft_tweet',
);
if( in_array($action, $allowed_actions) ) {
if ( is_user_logged_in() ) {
do_action( 'socialer_ajax_' . $action );
return;
}
}
die(json_encode(array(
'error' => 'Action is not allowed or user did not logged in',
'error_code' => -1
)));