if ( !
$theme->
exists() ) { wp_die( __( 'The requested theme does not exist.'
) );
}if ( $theme->
errors() && 'theme_no_stylesheet' ===
$theme->
errors()->
get_error_code() ) { wp_die( __( 'The requested theme does not exist.'
) . ' ' .
$theme->
errors()->
get_error_message() );
}$allowed_files = array
();
$style_files = array
();
$file_types =
wp_get_theme_file_editable_extensions( $theme );
foreach ( $file_types as $type ) { switch ( $type ) { case 'php':
$allowed_files +=
$theme->
get_files( 'php', -1
);
break;
case 'css':
$style_files =
$theme->
get_files( 'css', -1
);
$allowed_files['style.css'
] =
$style_files['style.css'
];
$allowed_files +=
$style_files;
break;