From c3094617c3dd5409921ea2474ee5d3a82c004a69 Mon Sep 17 00:00:00 2001 From: kurtw Date: Thu, 4 Jun 2015 15:13:42 -0400 Subject: [PATCH] Fix select field type output bug. --- json-api.php | 2 +- models/post.php | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/json-api.php b/json-api.php index 4df3bc4..04919bf 100644 --- a/json-api.php +++ b/json-api.php @@ -3,7 +3,7 @@ Plugin Name: WordPress JSON API Plugin URI: https://github.com/cfpb/wp-json-api Description: A RESTful API for WordPress -Version: 1.1.5 +Version: 1.1.6 Author: Dan Phiffer, Greg Boone */ diff --git a/models/post.php b/models/post.php index 0e0ac10..e50edb1 100644 --- a/models/post.php +++ b/models/post.php @@ -272,17 +272,12 @@ function set_custom_fields_value() { $keys = explode(',', $json_api->query->custom_fields); } foreach ($wp_custom_fields as $key => $value) { - if ( sizeof( $wp_custom_fields[$key] ) > 1 ) { - $field = $wp_custom_fields[$key]; - } else { - $field = $wp_custom_fields[$key][0]; - } if ($json_api->query->custom_fields) { if (in_array($key, $keys)) { - $this->custom_fields->$key = maybe_unserialize( $field ); + $this->custom_fields->$key = get_post_meta($this->id, $key, $single = true); } } else if (substr($key, 0, 1) != '_') { - $this->custom_fields->$key = maybe_unserialize( $field ); + $this->custom_fields->$key = get_post_meta($this->id, $key, $single = true); } } } else {