/** * Retrieve a attachment * * @see WP_JSON_Posts::get_post() */ public function get_post($id, $context = 'view') { $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 ($post['post_type'] !== 'attachment') { return new WP_Error('json_post_invalid_type', __('Invalid post type'), array('status' => 400)); } return parent::get_post($id, $context); }
/** * Retrieve a attachment * * @see WP_JSON_Posts::get_post() */ public function get_post($id, $context = 'view') { $id = (int) $id; if (empty($id)) { json_error(BigAppErr::$post['code'], BigAppErr::$comment['msg'], __lan("Invalid post id")); } $post = get_post($id, ARRAY_A); if ($post['post_type'] !== 'attachment') { json_error(BigAppErr::$post['code'], BigAppErr::$comment['msg'], __lan("Invalid post type")); } return parent::get_post($id, $context, true); //特征图给了一个特殊表示,用于返回数组 }
/** * Retrieve a post * * @see WP_JSON_Posts::get_post() */ public function get_post($id, $context = 'view') { $id = (int) $id; if (empty($id)) { json_error(BigAppErr::$post['code'], BigAppErr::$post['msg'], ""); } $post = get_post($id, ARRAY_A); if ($post['post_type'] !== $this->type) { json_error(BigAppErr::$post['code'], BigAppErr::$post['msg'], ""); } return parent::get_post($id, $context); }