WordPress.org

Make WordPress Core

Ticket #37332: 37332-02.3.diff

File 37332-02.3.diff, 1.8 KB (added by Jonnyauk, 4 years ago)

Updated patch file in correct format (trunk dev version) - 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'

  • wp-includes/post-template.php

    diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
    index be15252..002d274 100644
    a b function prepend_attachment($content) { 
    15411541function get_the_password_form( $post = 0 ) {
    15421542        $post = get_post( $post );
    15431543        $label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
     1544
     1545        // Display error message if post password is incorrect
     1546        if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
     1547                echo '<p><strong>' . get_the_password_form_wrong_password() . '</strong></p>';
     1548
    15441549        $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
    15451550        <p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
    15461551        <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>
    function get_the_password_form( $post = 0 ) { 
    15611566}
    15621567
    15631568/**
     1569 * Displays message if incorrect password supplied on protected post.
     1570 *
     1571 * @since 4.5.2
     1572 *
     1573 * @return string HTML content for the error message if post password inputted incorrectly.
     1574 */
     1575function get_the_password_form_wrong_password() {
     1576
     1577        $output = esc_html_x('Wrong password. Please try again.', 'incorrect post password');
     1578
     1579        /**
     1580         * Filter the HTML output for the error message if post password inputted incorrectly.
     1581         *
     1582         * @since 4.5.2
     1583         *
     1584         * @param string $output The error message output.
     1585         */
     1586        return apply_filters( 'the_password_form_wrong_password', $output );
     1587}
     1588
     1589/**
    15641590 * Whether currently in a page template.
    15651591 *
    15661592 * This template tag allows you to determine if you are in a page template.