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. Built from https://develop.svn.wordpress.org/trunk@58174 git-svn-id: http://core.svn.wordpress.org/trunk@57637 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3cdaeae7ab
commit
e1034e15f0
|
@ -1463,7 +1463,7 @@ function get_sample_permalink( $post, $title = null, $name = null ) {
|
||||||
$original_filter = $post->filter;
|
$original_filter = $post->filter;
|
||||||
|
|
||||||
// Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published.
|
// Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published.
|
||||||
if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ), true ) ) {
|
if ( in_array( $post->post_status, array( 'auto-draft', 'draft', 'pending', 'future' ), true ) ) {
|
||||||
$post->post_status = 'publish';
|
$post->post_status = 'publish';
|
||||||
$post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID );
|
$post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1219,7 +1219,11 @@ function get_post_mime_type( $post = null ) {
|
||||||
* @return string|false Post status on success, false on failure.
|
* @return string|false Post status on success, false on failure.
|
||||||
*/
|
*/
|
||||||
function get_post_status( $post = null ) {
|
function get_post_status( $post = null ) {
|
||||||
|
if ( $post instanceof WP_Post && isset( $post->filter ) && 'sample' === $post->filter ) {
|
||||||
|
// Skip normalization
|
||||||
|
} else {
|
||||||
$post = get_post( $post );
|
$post = get_post( $post );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! is_object( $post ) ) {
|
if ( ! is_object( $post ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.6-alpha-58173';
|
$wp_version = '6.6-alpha-58174';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue