testManager = new ABTestManager(); } public function getTestsData($request) { if (!$request->get_param('id')) { return new \WP_Error('rest_invalid_request', 'Missing test id parameter.', ['status' => 400]); } $ids = $request->get_param('id'); return rest_ensure_response($this->testManager->getTestsByIds($ids)); } public function getTestPreviewContentByPost($request) { if (!$request->get_param('id')) { return new \WP_Error('rest_invalid_request', 'Missing test id parameter.', ['status' => 400]); } $id = $request->get_param('id'); $content_post = get_post($id); $content = $content_post->post_content; return rest_ensure_response([ 'html' => $this->getPreviewHTML(apply_filters('the_content', $content)), 'editLink' => get_edit_post_link($id) ]); } private function getPreviewHTML($body) { ob_start(); echo '
'; do_action( 'wp_head' ); echo "