Skip to content

Commit

Permalink
♿️ Move required fields notice on top of the form.
Browse files Browse the repository at this point in the history
See #53
  • Loading branch information
MatzeKitt committed Sep 1, 2024
1 parent 9fe9294 commit 526cecc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions inc/blocks/class-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function add_method( string $block_content, array $block ): string {
*/
public function add_required_notice( string $block_content, array $block ): string {
/* translators: an asterisk sign */
$notice = '<p class="form-block__required-notice">' . sprintf( esc_html__( 'Required fields are marked with %s', 'form-block' ), '<span class="is-required" aria-hidden="true">*</span>' ) . '</p>';
$notice = '<p class="form-block__required-notice" aria-hidden="true">' . sprintf( esc_html__( 'Required fields are marked with %s', 'form-block' ), '<span class="is-required" aria-hidden="true">*</span>' ) . '</p>';

/**
* Filter the form required notice.
Expand All @@ -185,7 +185,7 @@ public function add_required_notice( string $block_content, array $block ): stri
*/
$notice = apply_filters( 'form_block_form_required_notice', $notice, $block_content, $block );

return str_replace( '</form>', '</form>' . $notice, $block_content );
return str_replace( '<form', $notice . '<form', $block_content );
}

/**
Expand Down

0 comments on commit 526cecc

Please sign in to comment.