Make WordPress Core

Ticket #50002: 50002.patch

File 50002.patch, 1.6 KB (added by aubreypwd, 6 years ago)

First pass at fixing this that does not modify post_status but does not affect the desired result (please test!).

  • wp-admin/includes/post.php

    diff --git wp-admin/includes/post.php wp-admin/includes/post.php
    index 774bd1ea34..f237965bd9 100644
    function get_sample_permalink( $id, $title = null, $name = null ) { 
    13411341        $original_date   = $post->post_date;
    13421342        $original_name   = $post->post_name;
    13431343
    1344         // Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published.
    1345         if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) {
    1346                 $post->post_status = 'publish';
    1347                 $post->post_name   = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID );
    1348         }
    1349 
    13501344        // If the user wants to set a new name -- override the current one.
    13511345        // Note: if empty name is supplied -- use the title instead, see #6072.
    13521346        if ( ! is_null( $name ) ) {
  • wp-includes/link-template.php

    diff --git wp-includes/link-template.php wp-includes/link-template.php
    index 4d47a8fae4..5d07f3f277 100644
    function get_permalink( $post = 0, $leavename = false ) { 
    165165         */
    166166        $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
    167167
    168         if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) {
     168        if ( ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) || $sample ) {
     169                if ( $sample ) {
     170                        $post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID );
     171                }
    169172
    170173                $category = '';
    171174                if ( strpos( $permalink, '%category%' ) !== false ) {