WordPress.org

Make WordPress Core

Ticket #11863: 11863.2.diff

File 11863.2.diff, 1.9 KB (added by ericlewis, 5 years ago)
  • src/wp-admin/includes/post.php

     
    12731273        if ( ! $post )
    12741274                return '';
    12751275
     1276        $orig_permalink = sanitize_title( $post->post_title );
     1277
    12761278        list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
    12771279
    12781280        if ( current_user_can( 'read_post', $post->ID ) ) {
     
    13061308                        }
    13071309                }
    13081310
     1311                // Permalink conflict error messages.
     1312                if ( $new_slug && $new_slug != $post_name_abridged ) {
     1313                        //error message when editing a permalink
     1314                        global $wpdb;
     1315                        $conflicting_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_name = %s;", $new_slug ) );
     1316                        if ( $conflicting_post->post_status == 'trash' ) {
     1317                                echo '<div id="message" class="error"><p>';
     1318                                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>');
     1319                                echo '</p></div>';
     1320                        }
     1321                }elseif ( $orig_permalink != $post_name_abridged && $_GET['message'] == '6' ) {
     1322                        //error message on a newly created post
     1323                        echo '<div id="message" class="error"><p>';
     1324                        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>' );
     1325                        echo '</p></div>';
     1326                }
     1327
    13091328                $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
    13101329                $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) );
    13111330                $pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post_name, urldecode( $permalink ) );