If you set `'_wp_page_template'` for a post, and then switch to a theme that doesn't support the template, subsequent calls to `wp_insert_post()` will bail early without running a plethora of hooks. This shouldn't happen. We should set the template to `'default'` and continue through the rest of the function. The function will still bail if `$wp_error` is `true` via `wp_insert_post( $arr, true )`.
Props nofearinc. Fixes #25334. git-svn-id: https://develop.svn.wordpress.org/trunk@31020 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
64784baa95
commit
f014d0cf35
|
@ -3423,11 +3423,11 @@ function wp_insert_post( $postarr, $wp_error = false ) {
|
|||
if ( 'default' != $postarr['page_template'] && ! isset( $page_templates[ $postarr['page_template'] ] ) ) {
|
||||
if ( $wp_error ) {
|
||||
return new WP_Error('invalid_page_template', __('The page template is invalid.'));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
update_post_meta( $post_ID, '_wp_page_template', 'default' );
|
||||
} else {
|
||||
update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
|
||||
}
|
||||
update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
|
||||
}
|
||||
|
||||
if ( 'attachment' !== $postarr['post_type'] ) {
|
||||
|
|
Loading…
Reference in New Issue