secret
Last active

Diff on json-api/models/post.php to allow for multiple authors

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
diff --git a/wp-content/plugins/json-api/models/post.php b/wp-content/plugins/json-api/models/post.php
index 4a8c492..c5b28cb 100644
--- a/wp-content/plugins/json-api/models/post.php
+++ b/wp-content/plugins/json-api/models/post.php
@@ -18,7 +18,6 @@ class JSON_API_Post {
var $modified; // String (modified by date_format query var)
var $categories; // Array of objects
var $tags; // Array of objects
- var $author; // Object
var $comments; // Array of objects
var $attachments; // Array of objects
var $comment_count; // Integer
@@ -206,10 +205,21 @@ class JSON_API_Post {
function set_author_value($author_id) {
global $json_api;
- if ($json_api->include_value('author')) {
- $this->author = new JSON_API_Author($author_id);
+ if ($json_api->include_value('author') || $json_api->include_value('authors')) {
+ // Check for the Coauthors Plus plugin's function
+ if ( function_exists('get_coauthors') ) {
+ $this->authors = array();
+ if ( $wp_authors = get_coauthors() ) {
+ foreach ($wp_authors as $wp_author) {
+ $this->authors[] = new JSON_API_Author( $wp_author->ID );
+ }
+ }
+ }
+ else {
+ $this->author = new JSON_API_Author($author_id);
+ }
} else {
- unset($this->author);
+ unset($this->author, $this->authors);
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.