Skip to content

Commit e4024b8

Browse files
committed
Posts, Post Types: Style password form button in block themes.
When a block theme is active, wrap the post password form's submit button in a `wp-block-button` span and add the `wp-block-button__link` class along with the theme's button element class name, so it is styled consistently with other buttons output by the theme. The `wp-block-button` stylesheet is explicitly enqueued when registered, as it may not otherwise be present on pages without a Button block. Props apermo, mukesh27, sukhendu2002, poena, wildworks. Fixes #64569. git-svn-id: https://develop.svn.wordpress.org/trunk@62754 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 16af489 commit e4024b8

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/wp-includes/post-template.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,9 +1809,23 @@ 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+
if ( wp_style_is( 'wp-block-button', 'registered' ) ) {
1822+
wp_enqueue_style( 'wp-block-button' );
1823+
}
1824+
}
1825+
18121826
$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 . '
18131827
<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>
1828+
<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>
18151829
';
18161830

18171831
/**

0 commit comments

Comments
 (0)