[wp-trac] [WordPress Trac] #21931: White screen of death if theme can't be found
WordPress Trac
noreply at wordpress.org
Mon Jan 18 08:04:15 UTC 2016
#21931: White screen of death if theme can't be found
--------------------------------------+-----------------------
Reporter: ericlewis | Owner:
Type: enhancement | Status: reopened
Priority: normal | Milestone: 4.5
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: dev-feedback 2nd-opinion | Focuses:
--------------------------------------+-----------------------
Changes (by sebastian.pisula):
* keywords: dev-feedback => dev-feedback 2nd-opinion
Comment:
I use this filter:
{{{#!php
<?php
add_filter('template_include', function(){
return locate_template('test.php');
});
}}}
And I have white page. I think that should be this if:
{{{#!php
<?php
if ( $template = apply_filters( 'template_include', $template ) ) {
include( $template );
} elseif ( current_user_can( 'install_themes' ) ) {
$theme = wp_get_theme();
if ( $theme->errors() ) {
wp_die( $theme->errors() );
} else {
wp_die( __( 'Template is missing.' ) );
}
}
}}}
But theme->erros return error if not exists index.php file so better patch
is:
{{{#!php
<?php
if ( $template = apply_filters( 'template_include', $template ) )
{
include( $template );
} elseif ( current_user_can( 'install_themes' ) ) {
wp_die( __( 'Template is missing.' ) );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21931#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list