File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -294,18 +294,20 @@ protected function update_post_from_markdown_source( $post_id ) {
294294}
295295
296296$ title = null ;
297+ if ( preg_match ( '/^\n*#\s(.+)/ ' , $ markdown , $ matches ) ) {
298+ $ title = $ matches [1 ];
299+ $ markdown = preg_replace ( '/^\n*#\swp\s(.+)/ ' , '' , $ markdown );
300+ }
301+ // Allow YAML override.
297302if ( isset ( $ yaml ['title ' ] ) ) {
298303$ title = $ yaml ['title ' ];
299- } elseif ( preg_match ( '/^\n*#\s(.+)/ ' , $ markdown , $ matches ) ) {
300- $ title = $ matches [1 ];
301- $ markdown = preg_replace ( '/^\n*#\swp\s(.+)/ ' , '' , $ markdown );
302304}
303305$ markdown = trim ( $ markdown );
304306
305307// Steal the first sentence as the excerpt
306308$ excerpt = '' ;
307309if ( preg_match ( '/^(.+)/ ' , $ markdown , $ matches ) ) {
308- $ excerpt = $ matches [1 ];
310+ $ excerpt = $ matches [1 ];
309311$ markdown = preg_replace ( '/^(.+)/ ' , '' , $ markdown );
310312}
311313
@@ -322,6 +324,9 @@ protected function update_post_from_markdown_source( $post_id ) {
322324if ( ! is_null ( $ title ) ) {
323325$ post_data ['post_title ' ] = sanitize_text_field ( wp_slash ( $ title ) );
324326}
327+ if ( isset ( $ yaml ['description ' ] ) ) {
328+ $ post_data ['post_excerpt ' ] = sanitize_text_field ( wp_slash ( $ yaml ['description ' ] ) );
329+ }
325330if ( isset ( $ yaml ['published ' ] ) ) {
326331$ post_data ['post_status ' ] = (bool ) $ yaml ['published ' ] ? 'publish ' : 'draft ' ;
327332}
You can’t perform that action at this time.
0 commit comments