PluginProbe
JSON API Auth / 1.7
JSON API Auth v1.7
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 +71 -90 trunk1.7 View file →
@@ -1,90 +1,71 @@
1 -<?php
2 -
3 -/*
4 -
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 authentication
8 - Version: 3.1.2
9 - Requires at least: 3.0.1
10 - Requires PHP: 7.4
11 - Tested up to: 7.1
12 - Author: Ali Qureshi
13 - Author URI: http://www.parorrey.com
14 - License: GPLv3
15 -
16 - */
17 -
18 -include_once(ABSPATH . 'wp-admin/includes/plugin.php');
19 -
20 -define('JSON_API_AUTH_HOME', dirname(__FILE__));
21 -
22 -function auth_action_links($links)
23 -{
24 -
25 - $links[] = '<a href="' . esc_url(get_admin_url(null, '/options-general.php?page=json-api')) . '">JSON API</a>';
26 -
27 - $links[] = '<a href="https://www.parorrey.com/solutions/json-api-user-plus/" target="_blank">' . __('Upgrade to User Plus', 'json-api-auth') . '</a>';
28 -
29 - return $links;
30 -}
31 -add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'auth_action_links', 10, 1);
32 -
33 -
34 -if (!(is_plugin_active('json-api/json-api.php') || is_plugin_active('json-api-master/json-api.php'))) {
35 -
36 - add_action('admin_notices', 'pim_auth_draw_notice_json_api');
37 -
38 - return;
39 -
40 -}
41 -
42 -add_filter('json_api_controllers', 'pimAuthJsonApiController');
43 -
44 -add_filter('json_api_auth_controller_path', 'setAuthControllerPath');
45 -
46 -add_action('init', 'json_api_auth_checkAuthCookie', 100);
47 -
48 -load_plugin_textdomain('json-api-auth', false, basename(dirname(__FILE__)) . '/languages');
49 -
50 -function pim_auth_draw_notice_json_api()
51 -{
52 -
53 - echo '<div id="message" class="error fade"><p style="line-height: 150%">';
54 -
55 - _e('<strong>JSON API Auth</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> for JSON API Auth.', 'json-api-auth');
56 -
57 - echo '</p></div>';
58 -
59 -}
60 -
61 -
62 -function pimAuthJsonApiController($aControllers)
63 -{
64 -
65 - $aControllers[] = 'Auth';
66 - return $aControllers;
67 -
68 -}
69 -
70 -
71 -function setAuthControllerPath($sDefaultPath)
72 -{
73 -
74 - return dirname(__FILE__) . '/controllers/Auth.php';
75 -
76 -}
77 -
78 -function json_api_auth_checkAuthCookie($sDefaultPath)
79 -{
80 - global $json_api;
81 -
82 - if ( isset( $json_api->query->cookie ) && $json_api->query->cookie ) {
83 - $user_id = wp_validate_auth_cookie($json_api->query->cookie, 'logged_in');
84 - if ($user_id) {
85 - $user = get_userdata($user_id);
86 -
87 - wp_set_current_user($user->ID, $user->user_login);
88 - }
89 - }
90 -}
1 +<?php
2 +
3 +/*
4 +
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.7
9 + Author: Ali Qureshi
10 + Author URI: http://www.parorrey.com
11 + License: GPLv3
12 +
13 + */
14 +
15 +include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
16 +
17 +define('JSON_API_AUTH_HOME', dirname(__FILE__));
18 +
19 +if (!is_plugin_active('json-api/json-api.php')) {
20 +
21 + add_action('admin_notices', 'pim_auth_draw_notice_json_api');
22 +
23 + return;
24 +
25 +}
26 +
27 +add_filter('json_api_controllers', 'pimAuthJsonApiController');
28 +
29 +add_filter('json_api_auth_controller_path', 'setAuthControllerPath');
30 +
31 +add_action('init', 'json_api_auth_checkAuthCookie', 100);
32 +
33 +load_plugin_textdomain('json-api-auth', false, basename(dirname(__FILE__)) . '/languages');
34 +
35 +function pim_auth_draw_notice_json_api() {
36 +
37 + echo '<div id="message" class="error fade"><p style="line-height: 150%">';
38 +
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');
40 +
41 + echo '</p></div>';
42 +
43 +}
44 +
45 +
46 +function pimAuthJsonApiController($aControllers) {
47 +
48 + $aControllers[] = 'Auth';
49 + return $aControllers;
50 +
51 +}
52 +
53 +
54 +function setAuthControllerPath($sDefaultPath) {
55 +
56 + return dirname(__FILE__) . '/controllers/Auth.php';
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 + }
71 +}