register_rest_route_with_post_id( '/rest-route', array( 'GET' ), array( $this, 'get_rest_route' ) ); } /** * API Endpoint: GET /utils/post/{post_id}/rest-route * * Returns the REST route of a post. * * @since 3.20.5 * * @param WP_REST_Request $request The request object. * @return WP_REST_Response The response object. */ public function get_rest_route( WP_REST_Request $request ) { $post_id = $request->get_param( 'post_id' ); $post_rest_route = rest_get_route_for_post( $post_id ); return new WP_REST_Response( array( 'data' => $post_rest_route ), 200 ); } }