[wp-trac] [WordPress Trac] #45250: Backward compatibility: Impossible to prefill a new post in WP 5.0

WordPress Trac noreply at wordpress.org
Thu Nov 1 11:11:35 UTC 2018


#45250: Backward compatibility: Impossible to prefill a new post in WP 5.0
-------------------------------+---------------------
 Reporter:  Chouby             |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  5.0
Component:  Editor             |     Version:  5.0
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+---------------------
Changes (by danielbachhuber):

 * keywords:  needs-patch => reporter-feedback


Comment:

 @Chouby In looking at this a bit further, I don't think the code snippet
 you've provided is the "correct" way to overload the default post.

 WordPress formally supports the `default_content`, `default_excerpt`, and
 `default_title` filters. I've verified these work as expected with the
 block editor on the 5.0 branch.

 The code snippet you've included worked through happenstance pre-5.0. For
 the other values, I think you'll need to filter `rest_prepare_post`,
 `rest_prepare_page`, etc. to include the default values.

 {{{
 add_filter( 'rest_prepare_page', function( $response, $post ){
         if ( 'auto-draft' === $post->post_status ) {
                 $response->data['menu_order'] = 2;
         }
         return $response;
 }, 10, 2 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45250#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list