PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | json-endpoints/class.wpcom-json-api-get-post-v1-1-endpoint.php +17 -3 13.2.4 → 16.3-a.5 View file →
@@ -1,6 +1,10 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit( 0 );
5 +}
6 +
3 7 new WPCOM_JSON_API_Get_Post_v1_1_Endpoint(
4 8 array(
5 9 'description' => 'Get a single post (by ID).',
6 10 'min_version' => '1.1',
@@ -13,8 +17,12 @@
13 17 '$site' => '(int|string) Site ID or domain',
14 18 '$post_ID' => '(int) The post ID',
15 19 ),
16 20
21 + // The %d token is substituted with the real post ID by the transport (build_concrete_rest_route).
22 + 'rest_route' => '/posts/%d',
23 + 'rest_min_jp_version' => '16.1-a.3',
24 +
17 25 'allow_fallback_to_jetpack_blog_token' => true,
18 26
19 27 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/7',
20 28 )
@@ -33,8 +41,12 @@
33 41 '$site' => '(int|string) Site ID or domain',
34 42 '$post_slug' => '(string) The post slug (a.k.a. sanitized name)',
35 43 ),
36 44
45 + // The slug:%s token is substituted with the real slug by the transport (build_concrete_rest_route).
46 + 'rest_route' => '/posts/slug:%s',
47 + 'rest_min_jp_version' => '16.1-a.3',
48 +
37 49 'allow_fallback_to_jetpack_blog_token' => true,
38 50
39 51 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/slug:blogging-and-stuff',
40 52 )
@@ -41,8 +53,10 @@
41 53 );
42 54
43 55 /**
44 56 * Get Post v1_1 endpoint.
57 + *
58 + * @phan-constructor-used-for-side-effects
45 59 */
46 60 class WPCOM_JSON_API_Get_Post_v1_1_Endpoint extends WPCOM_JSON_API_Post_v1_1_Endpoint { // phpcs:ignore
47 61 /**
48 62 *
@@ -50,11 +64,11 @@
50 64 *
51 65 * /sites/%s/posts/%d -> $blog_id, $post_id
52 66 * /sites/%s/posts/slug:%s -> $blog_id, $post_id
53 67 *
54 - * @param string $path - the path.
55 - * @param int $blog_id - the blog ID.
56 - * @param int $post_id - the post ID.
68 + * @param string $path - the path.
69 + * @param int $blog_id - the blog ID.
70 + * @param int|string $post_id - the post ID, or the post slug for the `/posts/slug:` route.
57 71 */
58 72 public function callback( $path = '', $blog_id = 0, $post_id = 0 ) {
59 73 $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
60 74 if ( is_wp_error( $blog_id ) ) {