Archived
Initial commit
This commit is contained in:
commit
86c1e5f82b
40 files changed
+4362
No files matched your search
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
Controller name: Posts
|
||||
Controller description: Data manipulation methods for posts
|
||||
*/
|
||||
|
||||
class JSON_API_Posts_Controller {
|
||||
|
||||
public function create_post() {
|
||||
global $json_api;
|
||||
if (!current_user_can('edit_posts')) {
|
||||
$json_api->error("You need to login with a user capable of creating posts.");
|
||||
}
|
||||
if (!$json_api->query->nonce) {
|
||||
$json_api->error("You must include a 'nonce' value to create posts. Use the `get_nonce` Core API method.");
|
||||
}
|
||||
$nonce_id = $json_api->get_nonce_id('posts', 'create_post');
|
||||
if (!wp_verify_nonce($json_api->query->nonce, $nonce_id)) {
|
||||
$json_api->error("Your 'nonce' value was incorrect. Use the 'get_nonce' API method.");
|
||||
}
|
||||
nocache_headers();
|
||||
$post = new JSON_API_Post();
|
||||
$id = $post->create($_REQUEST);
|
||||
if (empty($id)) {
|
||||
$json_api->error("Could not create post.");
|
||||
}
|
||||
return array(
|
||||
'post' => $post
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user