Make WordPress Core

Changeset 49288


Ignore:
Timestamp:
10/23/2020 07:07:09 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: Set better default title for custom post types without title support.

The default title is now set to "(no title supported)" instead of "Auto Draft".

Props garrett-eclipse, rajanit2000, bridgetwillard, donmhico, nrqsnchz.
Fixes #45516.

File:
1 edited

Legend:

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

    r49172 r49288  
    681681
    682682        if ( $create_in_db ) {
     683                if ( post_type_supports( $post_type, 'title' ) ) {
     684                        $default_title = __( 'Auto Draft' );
     685                } else {
     686                        $default_title = __( '(no title supported)' );
     687                }
     688
    683689                $post_id = wp_insert_post(
    684690                        array(
    685                                 'post_title'  => __( 'Auto Draft' ),
     691                                'post_title'  => $default_title,
    686692                                'post_type'   => $post_type,
    687693                                'post_status' => 'auto-draft',
     
    691697                );
    692698                $post    = get_post( $post_id );
    693                 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) {
     699
     700                if ( current_theme_supports( 'post-formats' )
     701                        && post_type_supports( $post->post_type, 'post-formats' )
     702                        && get_option( 'default_post_format' )
     703                ) {
    694704                        set_post_format( $post, get_option( 'default_post_format' ) );
    695705                }
     706
    696707                wp_after_insert_post( $post, false );
    697708
Note: See TracChangeset for help on using the changeset viewer.