diff options
Diffstat (limited to 'plugins/jetpack/json-endpoints/class.wpcom-json-api-get-post-v1-1-endpoint.php')
-rw-r--r-- | plugins/jetpack/json-endpoints/class.wpcom-json-api-get-post-v1-1-endpoint.php | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-post-v1-1-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-post-v1-1-endpoint.php index 517630a6..6f79222a 100644 --- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-post-v1-1-endpoint.php +++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-post-v1-1-endpoint.php @@ -10,13 +10,19 @@ class WPCOM_JSON_API_Get_Post_v1_1_Endpoint extends WPCOM_JSON_API_Post_v1_1_End $args = $this->query_args(); - if ( false === strpos( $path, '/posts/slug:' ) ) { - $get_by = 'ID'; - } else { - $get_by = 'name'; + if ( false !== strpos( $path, '/posts/slug:' ) ) { + $post_id = $this->get_platform()->get_site( $blog_id )->get_post_id_by_name( $post_id ); + if ( is_wp_error( $post_id ) ) { + return $post_id; + } } - $return = $this->get_post_by( $get_by, $post_id, $args['context'] ); + if ( defined( 'IS_WPCOM' ) && IS_WPCOM && + ! in_array( get_post_type( $post_id ), array( false, 'post', 'page', 'revision' ) ) ) { + $this->load_theme_functions(); + } + + $return = $this->get_post_by( 'ID', $post_id, $args['context'] ); if ( !$return || is_wp_error( $return ) ) { return $return; |