Version Description
Minor bugfixes
Download this release
Release Info
Developer | dphiffer |
Plugin | JSON API |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.9 to 1.1.0
- json-api.php +1 -1
- readme.txt +10 -3
- singletons/introspector.php +2 -2
- singletons/response.php +9 -4
- tests/core.info-01.phpt +0 -2
json-api.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: JSON API
|
4 |
Plugin URI: http://wordpress.org/plugins/json-api/
|
5 |
Description: A RESTful API for WordPress
|
6 |
-
Version: 1.0
|
7 |
Author: Dan Phiffer
|
8 |
Author URI: http://phiffer.org/
|
9 |
*/
|
3 |
Plugin Name: JSON API
|
4 |
Plugin URI: http://wordpress.org/plugins/json-api/
|
5 |
Description: A RESTful API for WordPress
|
6 |
+
Version: 1.1.0
|
7 |
Author: Dan Phiffer
|
8 |
Author URI: http://phiffer.org/
|
9 |
*/
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: dphiffer
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DH4MEG99JR2WE
|
4 |
Tags: json, api, ajax, cms, admin, integration, moma
|
5 |
Requires at least: 2.8
|
6 |
-
Tested up to: 3.5.
|
7 |
-
Stable tag: 1.0
|
8 |
|
9 |
A RESTful API for WordPress
|
10 |
|
@@ -689,7 +689,7 @@ The following arguments modify how you get results back from the API. The redire
|
|
689 |
* Setting `redirect` to a URL will cause the user's browser to redirect to the specified URL with a `status` value appended to the query vars (see the *Response objects* section below for an explanation of status values).
|
690 |
* Setting `redirect_[status]` allows you to control the resulting browser redirection depending on the `status` value.
|
691 |
* Setting `dev` to a non-empty value adds whitespace for readability and responds with `text/plain`
|
692 |
-
* Setting `json_encode_options` will let you specify an integer bitmask to modify the behavior of [PHP's `json_encode`](http://php.net/manual/en/function.json-encode.php)
|
693 |
* Setting `json_unescaped_unicode` will replace unicode-escaped characters with their unescaped equivalents (e.g., `\u00e1` becomes á)
|
694 |
* Omitting all of the above arguments will result in a standard JSON response.
|
695 |
|
@@ -1034,6 +1034,10 @@ You should see the test results print out culminating in a summary:
|
|
1034 |
|
1035 |
== Changelog ==
|
1036 |
|
|
|
|
|
|
|
|
|
1037 |
= 1.0.9 (2013-06-21): =
|
1038 |
* Added `update_post` and `delete_post` methods to Post controller
|
1039 |
* Added two JSON encoding arguments: `json_encode_options` and `json_unescaped_unicode`
|
@@ -1158,6 +1162,9 @@ You should see the test results print out culminating in a summary:
|
|
1158 |
|
1159 |
== Upgrade Notice ==
|
1160 |
|
|
|
|
|
|
|
1161 |
= 1.0.9 =
|
1162 |
Update/delete post methods and some other bugfixes and improvements
|
1163 |
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DH4MEG99JR2WE
|
4 |
Tags: json, api, ajax, cms, admin, integration, moma
|
5 |
Requires at least: 2.8
|
6 |
+
Tested up to: 3.5.2
|
7 |
+
Stable tag: 1.1.0
|
8 |
|
9 |
A RESTful API for WordPress
|
10 |
|
689 |
* Setting `redirect` to a URL will cause the user's browser to redirect to the specified URL with a `status` value appended to the query vars (see the *Response objects* section below for an explanation of status values).
|
690 |
* Setting `redirect_[status]` allows you to control the resulting browser redirection depending on the `status` value.
|
691 |
* Setting `dev` to a non-empty value adds whitespace for readability and responds with `text/plain`
|
692 |
+
* Setting `json_encode_options` will let you specify an integer bitmask to modify the behavior of [PHP's `json_encode`](http://php.net/manual/en/function.json-encode.php) (Note: this option is only recognized in PHP version 5.3+)
|
693 |
* Setting `json_unescaped_unicode` will replace unicode-escaped characters with their unescaped equivalents (e.g., `\u00e1` becomes á)
|
694 |
* Omitting all of the above arguments will result in a standard JSON response.
|
695 |
|
1034 |
|
1035 |
== Changelog ==
|
1036 |
|
1037 |
+
= 1.1.0 (2013-06-22): =
|
1038 |
+
* Bugfix for `json_encode` compatibility with PHP < 5.3
|
1039 |
+
* Bugfix for `get_author_index` warnings in WordPress > 3.5
|
1040 |
+
|
1041 |
= 1.0.9 (2013-06-21): =
|
1042 |
* Added `update_post` and `delete_post` methods to Post controller
|
1043 |
* Added two JSON encoding arguments: `json_encode_options` and `json_unescaped_unicode`
|
1162 |
|
1163 |
== Upgrade Notice ==
|
1164 |
|
1165 |
+
= 1.1.0 =
|
1166 |
+
Minor bugfixes
|
1167 |
+
|
1168 |
= 1.0.9 =
|
1169 |
Update/delete post methods and some other bugfixes and improvements
|
1170 |
|
singletons/introspector.php
CHANGED
@@ -171,14 +171,14 @@ class JSON_API_Introspector {
|
|
171 |
|
172 |
public function get_authors() {
|
173 |
global $wpdb;
|
174 |
-
$author_ids = $wpdb->get_col(
|
175 |
SELECT u.ID, m.meta_value AS last_name
|
176 |
FROM $wpdb->users AS u,
|
177 |
$wpdb->usermeta AS m
|
178 |
WHERE m.user_id = u.ID
|
179 |
AND m.meta_key = 'last_name'
|
180 |
ORDER BY last_name
|
181 |
-
")
|
182 |
$all_authors = array_map(array(&$this, 'get_author_by_id'), $author_ids);
|
183 |
$active_authors = array_filter($all_authors, array(&$this, 'is_active_author'));
|
184 |
return $active_authors;
|
171 |
|
172 |
public function get_authors() {
|
173 |
global $wpdb;
|
174 |
+
$author_ids = $wpdb->get_col("
|
175 |
SELECT u.ID, m.meta_value AS last_name
|
176 |
FROM $wpdb->users AS u,
|
177 |
$wpdb->usermeta AS m
|
178 |
WHERE m.user_id = u.ID
|
179 |
AND m.meta_key = 'last_name'
|
180 |
ORDER BY last_name
|
181 |
+
");
|
182 |
$all_authors = array_map(array(&$this, 'get_author_by_id'), $author_ids);
|
183 |
$active_authors = array_filter($all_authors, array(&$this, 'is_active_author'));
|
184 |
return $active_authors;
|
singletons/response.php
CHANGED
@@ -33,11 +33,15 @@ class JSON_API_Response {
|
|
33 |
|
34 |
if (function_exists('json_encode')) {
|
35 |
// Use the built-in json_encode function if it's available
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
-
$json = json_encode($data, $json_encode_options);
|
41 |
} else {
|
42 |
// Use PEAR's Services_JSON encoder otherwise
|
43 |
if (!class_exists('Services_JSON')) {
|
@@ -48,6 +52,7 @@ class JSON_API_Response {
|
|
48 |
$json = $json_service->encode($data);
|
49 |
}
|
50 |
|
|
|
51 |
if ($json_api->query->json_unescaped_unicode) {
|
52 |
$callback = array($this, 'replace_unicode_escape_sequence');
|
53 |
$json = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', $callback, $json);
|
33 |
|
34 |
if (function_exists('json_encode')) {
|
35 |
// Use the built-in json_encode function if it's available
|
36 |
+
if (version_compare(PHP_VERSION, '5.3') < 0) {
|
37 |
+
$json = json_encode($data);
|
38 |
+
} else {
|
39 |
+
$json_encode_options = 0;
|
40 |
+
if ($json_api->query->json_encode_options) {
|
41 |
+
$json_encode_options = $json_api->query->json_encode_options;
|
42 |
+
}
|
43 |
+
$json = json_encode($data, $json_encode_options);
|
44 |
}
|
|
|
45 |
} else {
|
46 |
// Use PEAR's Services_JSON encoder otherwise
|
47 |
if (!class_exists('Services_JSON')) {
|
52 |
$json = $json_service->encode($data);
|
53 |
}
|
54 |
|
55 |
+
// Thanks to Stack Overflow user Gumbo stackoverflow.com/questions/2934563
|
56 |
if ($json_api->query->json_unescaped_unicode) {
|
57 |
$callback = array($this, 'replace_unicode_escape_sequence');
|
58 |
$json = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', $callback, $json);
|
tests/core.info-01.phpt
CHANGED
@@ -10,14 +10,12 @@ $response = $http->currentResponse();
|
|
10 |
$response = json_decode($response['body']);
|
11 |
|
12 |
echo "Response status: $response->status\n";
|
13 |
-
echo "Version: $response->json_api_version\n";
|
14 |
echo "Controllers:\n";
|
15 |
var_dump($response->controllers);
|
16 |
|
17 |
?>
|
18 |
--EXPECT--
|
19 |
Response status: ok
|
20 |
-
Version: 1.0.8
|
21 |
Controllers:
|
22 |
array(4) {
|
23 |
[0]=>
|
10 |
$response = json_decode($response['body']);
|
11 |
|
12 |
echo "Response status: $response->status\n";
|
|
|
13 |
echo "Controllers:\n";
|
14 |
var_dump($response->controllers);
|
15 |
|
16 |
?>
|
17 |
--EXPECT--
|
18 |
Response status: ok
|
|
|
19 |
Controllers:
|
20 |
array(4) {
|
21 |
[0]=>
|