WordPress.org

Make WordPress Core

Ticket #11863: 11863-2.patch

File 11863-2.patch, 1.8 KB (added by williamsba1, 6 years ago)
  • wp-admin/includes/post.php

     
    11751175        if ( ! $post )
    11761176                return '';
    11771177
     1178        $orig_permalink = sanitize_title( $post->post_title );
     1179
    11781180        list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
    11791181
    11801182        if ( current_user_can( 'read_post', $post->ID ) ) {
     
    12241226                }
    12251227        }
    12261228
     1229        // Permalink conflict error messages.
     1230        if ( $new_slug && $new_slug != $post_name_abridged ) {
     1231                //error message when editing a permalink
     1232                global $wpdb;
     1233                $conflicting_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_name = %s;", $new_slug ) );
     1234                if ( $conflicting_post->post_status == 'trash' ) {
     1235                        echo '<div id="message" class="error"><p>';
     1236                        echo sprintf( __( 'There was a permalink conflict with the post "%s" in the trash. %s' ), esc_html( $post->post_title ), '<a href="edit.php?post_status=trash&post_type=' . $post->post_type . '&s=' . $post->post_title . '">View Trash</a>');
     1237                        echo '</p></div>';
     1238                }
     1239        }elseif ( $orig_permalink != $post_name_abridged && $_GET['message'] == '6' ) {
     1240                //error message on a newly created post
     1241                echo '<div id="message" class="error"><p>';
     1242                echo sprintf( __( 'There was a permalink conflict with the post "%s" in the trash. %s' ), esc_html( $post->post_title ), '<a href="edit.php?post_status=trash&post_type=' . $post->post_type . '&s=' . $post->post_title . '">View Trash</a>' );
     1243                echo '</p></div>';
     1244        }
     1245
    12271246        $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
    12281247        $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
    12291248