-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathjson-api-user.php
97 lines (49 loc) · 2.53 KB
/
json-api-user.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
<?php
/*
Plugin Name: JSON API User
Plugin URI: http://www.parorrey.com/solutions/json-api-user/
Description: Extends the JSON API for RESTful user registration, authentication, password reset, Facebook Login, user meta and BuddyPress Profile related functions. A Pro version is also available.
Version: 3.6.0
Author: Ali Qureshi
Author URI: http://www.parorrey.com/
License: GPLv3
*/
define('JAU_VERSION', '3.6.0');
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
define('JSON_API_USER_HOME', dirname(__FILE__));
if (!(is_plugin_active('json-api/json-api.php') || is_plugin_active('json-api-master/json-api.php'))) {
add_action('admin_notices', 'pim_draw_notice_json_api');
return;
}
function jaup_action_links( $links ) {
$links[] = '<a href="'. esc_url( get_admin_url(null, '/options-general.php?page=json-api') ) .'">JSON API</a>';
$links[] = '<a href="https://www.parorrey.com/solutions/json-api-user-plus/" target="_blank">' . __( 'Upgrade to User Plus', 'json-api-user' ) . '</a>';
return $links;
}
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'jaup_action_links', 10, 1 );
add_filter('json_api_controllers', 'pimJsonApiController');
add_filter('json_api_user_controller_path', 'setUserControllerPath');
add_action('init', 'json_api_user_checkAuthCookie', 100);
load_plugin_textdomain('json-api-user', false, basename(dirname(__FILE__)) . '/languages');
function pim_draw_notice_json_api() {
echo '<div id="message" class="error fade"><p style="line-height: 150%">';
_e('<strong>JSON API User</strong></a> requires the JSON API plugin to be activated. Please <a href="https://github.com/PI-Media/json-api">install / activate JSON API</a> first from <a href="https://github.com/PI-Media/json-api" target="_blank">GitHub repository here</a>. <br>You can also upgrade to a pro verison <a href="http://www.parorrey.com/solutions/json-api-user-plus/" target="_blank">JSON API User Plus</a>', 'json-api-user');
echo '</p></div>';
}
function pimJsonApiController($aControllers) {
$aControllers[] = 'User';
return $aControllers;
}
function setUserControllerPath($sDefaultPath) {
return dirname(__FILE__) . '/controllers/User.php';
}
function json_api_user_checkAuthCookie($sDefaultPath) {
global $json_api;
if ($json_api->query->cookie) {
$user_id = wp_validate_auth_cookie($json_api->query->cookie, 'logged_in');
if ($user_id) {
$user = get_userdata($user_id);
wp_set_current_user($user->ID, $user->user_login);
}
}
}