Make WordPress Core


Ignore:
Timestamp:
05/20/2024 09:47:41 AM (9 months ago)
Author:
youknowriad
Message:

Posts: Ensure get_sample_permalink returns the right permalink for auto-draft posts.

The post editor uses the permalink_template property from the posts REST API to render the post slug input or not. For auto-drafts or newly created posts, this property was not set properly. This PR solves by fixing the get_sample_permalink function used to compute this property.

Props youknowriad, mcsf, antonvlasenko, azaozz, peterwilsoncc, andrewserong, hellofromTonya, spacedmonkey.
Fixes #59283.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r58129 r58174  
    14641464
    14651465    // Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published.
    1466     if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ), true ) ) {
     1466    if ( in_array( $post->post_status, array( 'auto-draft', 'draft', 'pending', 'future' ), true ) ) {
    14671467        $post->post_status = 'publish';
    14681468        $post->post_name   = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID );
Note: See TracChangeset for help on using the changeset viewer.