Skip to content

Commit

Permalink
Fix CF7 live form with tag generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Jul 9, 2024
1 parent 0811966 commit d031597
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion .tests/php/integration/CF7/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ public function test_toplevel_page_wpcf7() {
<br class="clear" />
</div><!-- #poststuff -->
</div><!-- .wrap -->
HTML;

Expand Down
8 changes: 7 additions & 1 deletion src/php/CF7/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ private function insert_live_form( string $output ): string {

$form_start = $m[1];

if ( ! preg_match( '~(</div><!-- #poststuff -->).*?</form>~s', $output, $m ) ) {
return $output;
}

[ $form_end, $stuff_end ] = $m;

if ( ! preg_match( '/<input type="text" id="wpcf7-shortcode" .+ value="(.+)"/', $output, $m ) ) {
return $output;
}
Expand All @@ -114,7 +120,7 @@ private function insert_live_form( string $output ): string {
"\n";

// Remove form tag.
$output = str_replace( [ $form_start, '</form>' ], '', $output );
$output = str_replace( [ $form_start, $form_end ], [ '', $stuff_end ], $output );

// Insert form start at the beginning of the id="post-body".
$search = '<div id="post-body-content">';
Expand Down

0 comments on commit d031597

Please sign in to comment.