/** * Edit a post * * @see WP_JSON_Posts::edit_post() */ function edit_post($id, $data, $_headers = array()) { $id = (int) $id; if (empty($id)) { json_error(BigAppErr::$post['code'], BigAppErr::$post['msg'], ""); } $post = get_post($id, ARRAY_A); if (empty($post['ID'])) { json_error(BigAppErr::$post['code'], BigAppErr::$post['msg'], ""); } if ($post['post_type'] !== $this->type) { json_error(BigAppErr::$post['code'], BigAppErr::$post['msg'], ""); } return parent::edit_post($id, $data, $_headers); }
/** * Edit a attachment * * @see WP_JSON_Posts::edit_post() */ public function edit_post($id, $data, $_headers = array()) { $id = (int) $id; if (empty($id)) { return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404)); } $post = get_post($id, ARRAY_A); if (empty($post['ID'])) { return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404)); } if ($post['post_type'] !== 'attachment') { return new WP_Error('json_post_invalid_type', __('Invalid post type'), array('status' => 400)); } return parent::edit_post($id, $data, $_headers); }