PluginProbe
JSON API Auth / 1.9.4
JSON API Auth v1.9.4
3.1.2 3.1.1 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.7.1 2.8.0 2.9.0 2.9.1 3.0.0 3.1.0 trunk 0.1 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 All 33 releases
← All changes | json-api-auth.php +22 -26 1.11.9.4 View file →
@@ -1,34 +1,22 @@
1 1 <?php
2 2
3 -
4 -
5 3 /*
6 4
7 - Plugin Name: JSON API Auth
8 -
9 - Plugin URI: http://downloads.wordpress.org/plugin/json-api-auth.zip
10 -
11 - Description: Extends the JSON API for user authentiocation utilizing the Wordpress cookie validation and generation.
12 -
13 - Version: 1.1
14 -
15 - Author: mattberg, Ali Qureshi
16 -
5 + Plugin Name: JSON API Auth
6 + Plugin URI: http://www.parorrey.com/solutions/json-api-auth/
7 + Description: Extends the JSON API Plugin for RESTful user authentiocation
8 + Version: 1.9.4
9 + Author: Ali Qureshi
17 10 Author URI: http://www.parorrey.com
18 -
19 11 License: GPLv3
20 -
12 +
21 13 */
22 14
23 -
24 -
25 15 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
26 16
27 17 define('JSON_API_AUTH_HOME', dirname(__FILE__));
28 18
29 -
30 -
31 19 if (!is_plugin_active('json-api/json-api.php')) {
32 20
33 21 add_action('admin_notices', 'pim_auth_draw_notice_json_api');
34 22
@@ -35,23 +23,21 @@
35 23 return;
36 24
37 25 }
38 26
39 -
40 -
41 27 add_filter('json_api_controllers', 'pimAuthJsonApiController');
42 28
43 29 add_filter('json_api_auth_controller_path', 'setAuthControllerPath');
44 30
31 +add_action('init', 'json_api_auth_checkAuthCookie', 100);
32 +
45 33 load_plugin_textdomain('json-api-auth', false, basename(dirname(__FILE__)) . '/languages');
46 34
47 -
48 -
49 35 function pim_auth_draw_notice_json_api() {
50 36
51 37 echo '<div id="message" class="error fade"><p style="line-height: 150%">';
52 38
53 - _e('<strong>JSON API Auth</strong></a> requires the JSON API plugin to be activated. Please <a href="wordpress.org/plugins/json-api/‎">install / activate JSON API</a> first.', 'json-api-user');
39 + _e('<strong>JSON API Auth</strong></a> requires the JSON API plugin to be activated. Please <a href="https://wordpress.org/plugins/json-api/">install / activate JSON API</a> first.', 'json-api-user');
54 40
55 41 echo '</p></div>';
56 42
57 43 }
@@ -56,20 +42,30 @@
56 42
57 43 }
58 44
59 45
60 -
61 46 function pimAuthJsonApiController($aControllers) {
62 47
63 48 $aControllers[] = 'Auth';
64 -
65 49 return $aControllers;
66 50
67 51 }
68 52
69 53
70 -
71 54 function setAuthControllerPath($sDefaultPath) {
72 55
73 56 return dirname(__FILE__) . '/controllers/Auth.php';
74 57
58 +}
59 +
60 +function json_api_auth_checkAuthCookie($sDefaultPath) {
61 + global $json_api;
62 +
63 + if ($json_api->query->cookie) {
64 + $user_id = wp_validate_auth_cookie($json_api->query->cookie, 'logged_in');
65 + if ($user_id) {
66 + $user = get_userdata($user_id);
67 +
68 + wp_set_current_user($user->ID, $user->user_login);
69 + }
70 + }
75 71 }