diff --git a/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php b/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php index de42663aa4..53879ed303 100644 --- a/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php +++ b/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php @@ -148,7 +148,7 @@ class WP_REST_Post_Search_Handler extends WP_REST_Search_Handler { $links = array(); - $item_route = $this->detect_rest_item_route( $post ); + $item_route = rest_get_route_for_post( $post ); if ( ! empty( $item_route ) ) { $links['self'] = array( 'href' => rest_url( $item_route ), @@ -182,25 +182,16 @@ class WP_REST_Post_Search_Handler extends WP_REST_Search_Handler { * Attempts to detect the route to access a single item. * * @since 5.0.0 + * @deprecated 5.5.0 Use rest_get_route_for_post() + * @see rest_get_route_for_post() * * @param WP_Post $post Post object. * @return string REST route relative to the REST base URI, or empty string if unknown. */ protected function detect_rest_item_route( $post ) { - $post_type = get_post_type_object( $post->post_type ); - if ( ! $post_type ) { - return ''; - } + _deprecated_function( __METHOD__, '5.5.0', 'rest_get_route_for_post()' ); - // It's currently impossible to detect the REST URL from a custom controller. - if ( ! empty( $post_type->rest_controller_class ) && 'WP_REST_Posts_Controller' !== $post_type->rest_controller_class ) { - return ''; - } - - $namespace = 'wp/v2'; - $rest_base = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name; - - return sprintf( '%s/%s/%d', $namespace, $rest_base, $post->ID ); + return rest_get_route_for_post( $post ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 374cbafbd9..a973b72ff3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48380'; +$wp_version = '5.5-alpha-48381'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.