Skip to content

Default Form Position: Fix errant HTML tags#1034

Open
n7studios wants to merge 1 commit intomainfrom
fix-form-injection
Open

Default Form Position: Fix errant HTML tags#1034
n7studios wants to merge 1 commit intomainfrom
fix-form-injection

Conversation

@n7studios
Copy link
Contributor

Summary

This PR fixes an issue introduced in #723, which allowed creators to choose where to display forms in Pages, Posts, and Custom Post Types (e.g., after the 3rd paragraph).

Previously, the implementation injected the entire $form_node->documentElement into the content using PHP's DOMDocument, which inadvertently included <html> and <head> tags.

This update instead extracts only the form’s actual node(s) (typically just a <script> or form fragment) and inserts them at the specified location in the Page/Post/CPT, avoiding any unintended root-level HTML tags.

Testing

Updated tests to confirm no additional <html>, <head> or <body> tags are included in the DOM.

Checklist

@n7studios n7studios self-assigned this Feb 26, 2026
@n7studios n7studios added the bug label Feb 26, 2026
@github-actions
Copy link

WordPress Playground

🚀 Your PR has been built and is ready for testing in WordPress Playground!

Click here to test your changes in WordPress Playground

@n7studios n7studios requested review from a team, ciccio-kit and noelherrick and removed request for a team February 26, 2026 09:55
@n7studios n7studios marked this pull request as ready for review February 26, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant