blob: 903a16ac8fbd5993042bf7a746de286ef2113185 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?php
class Jetpack_JSON_API_Get_Post_Backup_Endpoint extends Jetpack_JSON_API_Endpoint {
// /sites/%s/posts/%d/backup -> $blog_id, $post_id
protected $needed_capabilities = array(); // This endpoint is only accessible using a site token
protected $post_id;
function validate_input( $post_id ) {
if ( empty( $post_id ) || ! is_numeric( $post_id ) ) {
return new WP_Error( 'post_id_not_specified', __( 'You must specify a Post ID', 'jetpack' ), 400 );
}
$this->post_id = intval( $post_id );
return true;
}
protected function result() {
$post = get_post( $this->post_id );
if ( empty( $post ) ) {
return new WP_Error( 'post_not_found', __( 'Post not found', 'jetpack' ), 404 );
}
return array(
'post' => (array)$post,
'meta' => get_post_meta( $post->ID ),
);
}
}
|