Skip to content

Commit 6552a35

Browse files
committed
Themes: Add block button classes to password form submit for block themes
1 parent a95dd0e commit 6552a35

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/wp-includes/post-template.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,9 +1809,19 @@ function get_the_password_form( $post = 0 ) {
18091809
);
18101810
}
18111811

1812+
$button_class = '';
1813+
$button_wrapper_open = '';
1814+
$button_wrapper_close = '';
1815+
1816+
if ( wp_is_block_theme() ) {
1817+
$button_class = ' class="wp-block-button__link ' . wp_theme_get_element_class_name( 'button' ) . '"';
1818+
$button_wrapper_open = '<span class="wp-block-button">';
1819+
$button_wrapper_close = '</span>';
1820+
}
1821+
18121822
$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form' . $class . '" method="post">' . $redirect_field . $invalid_password_html . '
18131823
<p>' . __( 'This content is password-protected. To view it, please enter the password below.' ) . '</p>
1814-
<p><label for="' . $field_id . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $field_id . '" type="password" spellcheck="false" required size="20"' . $aria . ' /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
1824+
<p><label for="' . $field_id . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $field_id . '" type="password" spellcheck="false" required size="20"' . $aria . ' /></label> ' . $button_wrapper_open . '<input type="submit" name="Submit"' . $button_class . ' value="' . esc_attr_x( 'Enter', 'post password form' ) . '" />' . $button_wrapper_close . '</p></form>
18151825
';
18161826

18171827
/**
@@ -1825,6 +1835,7 @@ function get_the_password_form( $post = 0 ) {
18251835
* @since 2.7.0
18261836
* @since 5.8.0 Added the `$post` parameter.
18271837
* @since 6.8.0 Added the `$invalid_password` parameter.
1838+
* @since 7.1.0 Block button classes are added to the submit button for block themes.
18281839
*
18291840
* @param string $output The password form HTML output.
18301841
* @param WP_Post $post Post object.

0 commit comments

Comments
 (0)