'GET', 'callback' => 'cmplz_tc_rest_api_documents', // The document content is public; no authentication is required. 'permission_callback' => '__return_true', ) ); } /** * Return the Terms & Conditions document data for the Gutenberg block. * * Fetches the rendered HTML for the `terms-conditions` document type via * {@see COMPLIANZ_TC::$document} and returns a flat associative array * consumed by the `@complianz/terms-conditions` Gutenberg block. The content * is already sanitised and escaped by the document renderer, so it is safe * to output directly in a block context. * * @since 1.0.0 * @access public * * @see cmplz_tc_documents_rest_route() Registers the route that maps to this callback. * @see COMPLIANZ_TC::$document * * @return array { * Associative array representing the document. * * @type string $id Fixed identifier for the document type. Always `'terms'`. * @type string $title Translated document title. * @type string $content Rendered HTML content of the Terms & Conditions document. * } */ function cmplz_tc_rest_api_documents() { $html = COMPLIANZ_TC::$document->get_document_html( 'terms-conditions' ); return array( 'id' => 'terms', 'title' => __( 'Terms and Conditions', 'complianz-terms-conditions' ), 'content' => $html, ); }