Skip to content

Commit db9bbf5

Browse files
committed
Add sanitation to remove form tags from imported templates
1 parent 285ac85 commit db9bbf5

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ and import them into the form admin for specific forms.
222222
The simplest way is to create a HTML5 file and read its contents. Other
223223
options include using Twig to render HTML templates.
224224

225+
Remember: WPLF will insert `form` tags on its own, meaning you only have
226+
to create the markup which sits directly inside the `form` tags.
227+
225228
### Importing a template into WPLF
226229

227230
Once you're done creating a form template, you need to inform

classes/class-cpt-wplf-form.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,10 @@ function maybe_load_imported_template( $post_type, $post ) {
497497
return;
498498
}
499499

500+
// Clear unwanted form tags. WPLF will insert those by itself when rendering a form.
501+
$template_content = preg_replace( '%<form ?[^>]*?>%', '', $template_content );
502+
$template_content = preg_replace( '%</form>%', '', $template_content );
503+
500504
$this->override_form_template( $template_content, $form_id );
501505
}
502506

0 commit comments

Comments
 (0)