false, 'has__email' => false, ); $this->walk_blocks_for_email( $blocks, $result ); if ( $result['has_email'] ) { if ( $result['has__email'] ) { return self::FIELD; } return '_email'; } return 'email'; } private function walk_blocks_for_email( array $blocks, array &$result ) { foreach ( $blocks as $block ) { if ( ! is_array( $block ) ) { continue; } if ( isset( $block['attrs']['name'] ) ) { if ( 'email' === $block['attrs']['name'] ) { $result['has_email'] = true; } if ( '_email' === $block['attrs']['name'] ) { $result['has__email'] = true; } } if ( ! empty( $block['innerBlocks'] ) && is_array( $block['innerBlocks'] ) ) { $this->walk_blocks_for_email( $block['innerBlocks'], $result ); } } } public function on_render_field( string $content, string $field_name, array $attrs ): string { $type = $attrs['action_type'] ?? ''; if ( 'submit-field' !== $field_name || 'submit' !== $type ) { return $content; } $args = jet_form_builder()->post_type->get_args(); if ( empty( $args['use_honeypot'] ) ) { return $content; } $name = $this->find_email_field_name( Live_Form::instance()->blocks ); $field = Live_Form::force_render_field( 'text-field', array( 'field_type' => 'email', 'name' => $name, 'autocomplete' => 'off', ) ); $content .= sprintf( '