get_rest_url(), 'cmplz_preview' => CMPLZ_URL . 'assets/images/gutenberg-preview.png', 'user_can_unfiltered_html' => current_user_can( 'unfiltered_html' ), ) ); wp_set_script_translations( 'cmplz-block', 'complianz-gdpr', CMPLZ_PATH . '/languages' ); } add_action( 'enqueue_block_editor_assets', 'cmplz_editor_assets' ); /** * Enqueue block styles for both editor iframe and frontend. */ function cmplz_block_assets() { if ( ! is_admin() ) { return; } $load_css = cmplz_get_option( 'use_document_css', true ); if ( $load_css ) { $v = filemtime( CMPLZ_PATH . 'assets/css/document.min.css' ); wp_enqueue_style( 'cmplz-block', CMPLZ_URL . 'assets/css/document.min.css', array( 'wp-edit-blocks' ), $v ); } else { $v = filemtime( CMPLZ_PATH . 'assets/css/document-grid.min.css' ); wp_enqueue_style( 'cmplz-block', CMPLZ_URL . 'assets/css/document-grid.min.css', array( 'wp-edit-blocks' ), $v ); } } add_action( 'enqueue_block_assets', 'cmplz_block_assets' ); register_block_type( 'complianz/document', array( 'render_callback' => 'cmplz_render_document_block', ) ); register_block_type( 'complianz/consent-area', array( 'render_callback' => 'cmplz_render_consent_area_block', ) ); /** * Handles the front end rendering of the complianz consent area block * * @param array $attributes * @param string $content * @return string */ function cmplz_render_consent_area_block( $attributes, $content ) { $category = isset( $attributes['category'] ) ? cmplz_sanitize_category( $attributes['category'] ) : 'marketing'; $service = isset( $attributes['service'] ) ? COMPLIANZ::$cookie_blocker->sanitize_service_name( $attributes['service'] ) : 'general'; $post_id = (int) $attributes['postId']; $block_id = sanitize_title( $attributes['blockId'] ); $placeholder_content = $attributes['placeholderContent'] ?? ''; ob_start(); ?> get_document_html( $type, $region ); } } return $html; }