Skip to content

Commit

Permalink
implemented a post exists method. Currently only works for post meta …
Browse files Browse the repository at this point in the history
…queries
  • Loading branch information
Achilles Charmpilas committed Feb 13, 2013
1 parent 2343e03 commit 3f17953
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion controllers/posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,26 @@
*/

class JSON_API_Posts_Controller {

public function post_exists() {
global $json_api;
$this->authenticate();
nocache_headers();

# custom field request
if ($json_api->query->meta) {
$args = array('meta_query' => array());
foreach ($json_api->query->meta as $key => $value) {
array_push($args['meta_query'], array('key' => $key, 'value' => $value));
}
$query = new WP_Query( $args );
if ($query->have_posts()) {
return array( 'result' => true);
} else {
return array( 'result' => false);
}
}
}

public function create_post() {
global $json_api;
$this->authenticate();
Expand Down

0 comments on commit 3f17953

Please sign in to comment.