[wp-trac] [WordPress Trac] #26809: Errors from wp_update_post obscured in edit_post
WordPress Trac
noreply at wordpress.org
Wed Feb 19 17:31:08 UTC 2014
#26809: Errors from wp_update_post obscured in edit_post
-------------------------------+-----------------------------
Reporter: dllh | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Posts, Post Types | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------------+-----------------------------
Comment (by bobbingwide):
For me the expected result is that there should '''not''' be an error due
to the new theme not supporting the _wp_page_template post meta data.
I would simply wrap the code after get_page_templates() to only continue
if there are any defined for the current theme.
{{{
$page_templates = wp_get_theme()->get_page_templates();
if ( count( $page_templates ) ) {
if ( 'default' != $page_template && ! isset(
$page_templates[ $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',
$page_template);
}
}}}
If the user switches back to the original theme then they can continue
where they left off.
If they switch to another theme that supports page templates and the
chosen template does not exist in this theme then they might see errors.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26809#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list