JSON API - Version 0.9.5

Version Description

Feature addition: post thumbnails now included in response objects.

Download this release

Release Info

Developer dphiffer
Plugin Icon wp plugin JSON API
Version 0.9.5
Comparing to
See all releases

Code changes from version 0.9.4 to 0.9.5

Files changed (3) hide show
  1. json-api.php +1 -1
  2. models/post.php +17 -0
  3. readme.txt +8 -1
json-api.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: JSON API
4
  Plugin URI: http://wordpress.org/extend/plugins/json-api/
5
  Description: A RESTful API for WordPress
6
- Version: 0.9.4
7
  Author: Dan Phiffer
8
  Author URI: http://phiffer.org/
9
  */
3
  Plugin Name: JSON API
4
  Plugin URI: http://wordpress.org/extend/plugins/json-api/
5
  Description: A RESTful API for WordPress
6
+ Version: 0.9.5
7
  Author: Dan Phiffer
8
  Author URI: http://phiffer.org/
9
  */
models/post.php CHANGED
@@ -22,6 +22,7 @@ class JSON_API_Post {
22
  var $attachments; // Array of objects
23
  var $comment_count; // Integer
24
  var $comment_status; // String ("open" or "closed")
 
25
  var $custom_fields; // Object (included by using custom_fields query var)
26
 
27
  function JSON_API_Post($wp_post = null) {
@@ -139,6 +140,7 @@ class JSON_API_Post {
139
  $this->set_attachments_value();
140
  $this->set_value('comment_count', (int) $wp_post->comment_count);
141
  $this->set_value('comment_status', $wp_post->comment_status);
 
142
  $this->set_custom_fields_value();
143
  }
144
 
@@ -211,6 +213,21 @@ class JSON_API_Post {
211
  }
212
  }
213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  function set_custom_fields_value() {
215
  global $json_api;
216
  if ($json_api->include_value('custom_fields') &&
22
  var $attachments; // Array of objects
23
  var $comment_count; // Integer
24
  var $comment_status; // String ("open" or "closed")
25
+ var $thumbnail; // String
26
  var $custom_fields; // Object (included by using custom_fields query var)
27
 
28
  function JSON_API_Post($wp_post = null) {
140
  $this->set_attachments_value();
141
  $this->set_value('comment_count', (int) $wp_post->comment_count);
142
  $this->set_value('comment_status', $wp_post->comment_status);
143
+ $this->set_thumbnail_value();
144
  $this->set_custom_fields_value();
145
  }
146
 
213
  }
214
  }
215
 
216
+ function set_thumbnail_value() {
217
+ $values = get_post_custom_values('_thumbnail_id', $this->id);
218
+ if (empty($values)) {
219
+ unset($this->thumbnail);
220
+ return;
221
+ }
222
+ foreach ($this->attachments as $attachment) {
223
+ if ($attachment->id == $values[0]) {
224
+ $image = $attachment->images['thumbnail'];
225
+ $this->thumbnail = $image->url;
226
+ break;
227
+ }
228
+ }
229
+ }
230
+
231
  function set_custom_fields_value() {
232
  global $json_api;
233
  if ($json_api->include_value('custom_fields') &&
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: dphiffer
3
  Tags: json, api, ajax, cms, admin, integration, moma
4
  Requires at least: 2.8
5
  Tested up to: 2.9
6
- Stable tag: 0.9.4
7
 
8
  A RESTful API for WordPress
9
 
@@ -165,6 +165,7 @@ Developers familiar with WordPress may notice that many names for properties and
165
  * `attachments` - Array of attachment objects
166
  * `comment_count` - Integer
167
  * `comment_status` - String (`"open"` or `"closed"`)
 
168
  * `custom_fields` - Object (included by setting the `custom_fields` argument to a comma-separated list of custom field names)
169
 
170
  = Category response object =
@@ -587,6 +588,9 @@ Submits a comment to a WordPress post.
587
 
588
  == Changelog ==
589
 
 
 
 
590
  = 0.9.4 (2010-04-28): =
591
  * Fixed a bug where any non-authenticated user could create a draft blog post through `create_post`. Thanks to user futtta for posting about this.
592
 
@@ -634,6 +638,9 @@ Submits a comment to a WordPress post.
634
 
635
  == Upgrade Notice ==
636
 
 
 
 
637
  = 0.9.4 =
638
  Security fix: all users are strongly encouraged to upgrade. (See Changelog.)
639
 
3
  Tags: json, api, ajax, cms, admin, integration, moma
4
  Requires at least: 2.8
5
  Tested up to: 2.9
6
+ Stable tag: 0.9.5
7
 
8
  A RESTful API for WordPress
9
 
165
  * `attachments` - Array of attachment objects
166
  * `comment_count` - Integer
167
  * `comment_status` - String (`"open"` or `"closed"`)
168
+ * `thumbnail` - String (only included if a post thumbnail has been specified)
169
  * `custom_fields` - Object (included by setting the `custom_fields` argument to a comma-separated list of custom field names)
170
 
171
  = Category response object =
588
 
589
  == Changelog ==
590
 
591
+ = 0.9.5 (2010-05-27): =
592
+ * Added a `thumbnail` property to Post response objects
593
+
594
  = 0.9.4 (2010-04-28): =
595
  * Fixed a bug where any non-authenticated user could create a draft blog post through `create_post`. Thanks to user futtta for posting about this.
596
 
638
 
639
  == Upgrade Notice ==
640
 
641
+ = 0.9.5 =
642
+ Feature addition: post thumbnails now included in response objects.
643
+
644
  = 0.9.4 =
645
  Security fix: all users are strongly encouraged to upgrade. (See Changelog.)
646