Permalink
Browse files

add get_posts passthrough api method

  • Loading branch information...
aMoniker committed May 2, 2013
1 parent 1035fb4 commit 06b9bc542c92d156f467a98419dad2aab06a88b2
Showing with 20 additions and 0 deletions.
  1. +20 −0 controllers/core.php
View
@@ -41,6 +41,26 @@ public function get_recent_posts() {
$posts = $json_api->introspector->get_posts();
return $this->posts_result($posts);
}
+
+ public function get_posts() {
+ global $json_api;
+ $allowed_vars = array(
+ 'posts_per_page', 'numberposts', 'offset', 'category', 'orderby'
+ ,'order', 'include', 'exclude', 'meta_key', 'meta_value'
+ ,'post_type', 'post_mime_type', 'post_parent', 'post_status', 'suppress_filters'
+ );
+ extract($json_api->query->get($allowed_vars));
+
+ $args = array();
+ foreach ($allowed_vars as $allowed_var) {
+ if ($$allowed_var) {
+ $args[$allowed_var] = $$allowed_var;
+ }
+ }
+
+ $posts = $json_api->introspector->get_posts($args);
+ return $this->posts_result($posts);
+ }
public function get_post() {
global $json_api, $post;

0 comments on commit 06b9bc5

Please sign in to comment.