\WP_REST_Server::CREATABLE, 'permission_callback' => static function ( \WP_REST_Request $request ): bool { return current_user_can( 'edit_post', (int) $request['post_id'] ); }, 'callback' => array( $this, 'handle_analyze' ), 'args' => array( 'post_id' => array( 'type' => 'integer', 'required' => true, ), ), ) ); } public function handle_analyze( \WP_REST_Request $request ): \WP_REST_Response { $checks = LiteAnalyzer::analyze( array( 'keyphrase' => (string) $request->get_param( 'keyphrase' ), 'seo_title' => (string) $request->get_param( 'seo_title' ), 'description' => (string) $request->get_param( 'description' ), 'post_title' => (string) $request->get_param( 'post_title' ), 'content' => (string) $request->get_param( 'content' ), 'slug' => (string) $request->get_param( 'slug' ), ) ); return new \WP_REST_Response( array( 'checks' => $checks ), 200 ); } }