Skip to content
This repository was archived by the owner on Feb 1, 2019. It is now read-only.

Commit ccf108a

Browse files
author
Kurt Wall
committed
Merge pull request #5 from kurtw/serialize
Unserialize custom fields
2 parents 40ba9df + 9d15135 commit ccf108a

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

json-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: WordPress JSON API
44
Plugin URI: https://github.com/cfpb/wp-json-api
55
Description: A RESTful API for WordPress
6-
Version: 1.1.4
6+
Version: 1.1.5
77
Author: Dan Phiffer, Greg Boone
88
*/
99

models/post.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,17 @@ function set_custom_fields_value() {
272272
$keys = explode(',', $json_api->query->custom_fields);
273273
}
274274
foreach ($wp_custom_fields as $key => $value) {
275+
if ( sizeof( $wp_custom_fields[$key] ) > 1 ) {
276+
$field = $wp_custom_fields[$key];
277+
} else {
278+
$field = $wp_custom_fields[$key][0];
279+
}
275280
if ($json_api->query->custom_fields) {
276281
if (in_array($key, $keys)) {
277-
$this->custom_fields->$key = $wp_custom_fields[$key];
282+
$this->custom_fields->$key = maybe_unserialize( $field );
278283
}
279284
} else if (substr($key, 0, 1) != '_') {
280-
$this->custom_fields->$key = $wp_custom_fields[$key];
285+
$this->custom_fields->$key = maybe_unserialize( $field );
281286
}
282287
}
283288
} else {

singletons/query.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
use \DateTime;
23

34
class JSON_API_Query {
45

56
// Default values
67
protected $defaults = array(
7-
'date_format' => 'Y-m-d H:i:s',
8+
'date_format' => Datetime::ISO8601,
89
'read_more' => 'Read more'
910
);
1011

0 commit comments

Comments
 (0)