get( EmailPreview::class ); $type_param = EmailPreview::DEFAULT_EMAIL_TYPE; if ( isset( $attributes['postId'] ) ) { $email_type_class_name = WCTransactionalEmailPostsManager::get_instance()->get_email_type_class_name_from_post_id( $attributes['postId'] ); $type_param = ! empty( $email_type_class_name ) ? $email_type_class_name : $type_param; } elseif ( isset( $attributes['emailType'] ) ) { $type_param = sanitize_text_field( wp_unslash( $attributes['emailType'] ) ); } try { return $email_preview->generate_placeholder_content( $type_param ); } catch ( \Exception $e ) { // Catch other potential errors during content generation. return esc_html__( 'There was an error rendering the email preview.', 'woocommerce' ); } } /** * Renders Woo content placeholder to be replaced by content during sending. * * @param array $attributes Block attributes. * @param string $content Block content. * @param \WP_Block $block Block instance. * @return string Rendered block output. */ protected function render( $attributes, $content, $block ) { // phpcs:disable WordPress.Security.NonceVerification.Recommended if ( defined( 'REST_REQUEST' ) && REST_REQUEST && isset( $_GET['context'] ) && 'edit' === sanitize_text_field( wp_unslash( $_GET['context'] ) ) ) { // Block is being rendered for ServerSideRender editor preview. return $this->render_preview( $attributes ); } return BlockEmailRenderer::WOO_EMAIL_CONTENT_PLACEHOLDER; } }