Make WordPress Core

Changeset 62754


Ignore:
Timestamp:
07/15/2026 09:03:35 AM (3 months ago)
Author:
wildworks
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r61649 r62754  
    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
Note: See TracChangeset for help on using the changeset viewer.