Make WordPress Core

Ticket #37332: 37332-01.patch

File 37332-01.patch, 1.8 KB (added by Jonnyauk, 9 years ago)

Adds error message if post password is incorrect. Adds new function get_the_password_form_wrong_password() and new filter 'the_password_form_wrong_password'

  • post-template.php

    old new  
    15311531function get_the_password_form( $post = 0 ) {
    15321532        $post = get_post( $post );
    15331533        $label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
    1534         $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
     1534
     1535        // Display error message if post password is incorrect
     1536        if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
     1537                echo '<p><strong>' . get_the_password_form_wrong_password() . '</strong></p>';
     1538
     1539        $output .= '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
    15351540        <p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
    15361541        <p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
    15371542        ';
     
    15481553         * @param string $output The password form HTML output.
    15491554         */
    15501555        return apply_filters( 'the_password_form', $output );
     1556}
     1557
     1558/**
     1559 * Displays message if incorrect password supplied on protected post.
     1560 *
     1561 * @since 4.5.2
     1562 *
     1563 * @return string HTML content for the error message if post password inputted incorrectly.
     1564 */
     1565function get_the_password_form_wrong_password() {
     1566
     1567        $output = esc_html_x('Wrong password. Please try again.', 'incorrect post password');
     1568
     1569        /**
     1570         * Filter the HTML output for the error message if post password inputted incorrectly.
     1571         *
     1572         * @since 4.5.2
     1573         *
     1574         * @param string $output The error message output.
     1575         */
     1576        return apply_filters( 'the_password_form_wrong_password', $output );
    15511577}