$status['errorMessage'
] =
__( 'The requested theme does not exist.'
);
wp_send_json_error( $status );
} // Check filesystem credentials. `delete_theme()` will bail otherwise.
$url =
wp_nonce_url( 'themes.php?action=delete&stylesheet=' .
urlencode( $stylesheet ), 'delete-theme_' .
$stylesheet );
ob_start();
$credentials =
request_filesystem_credentials( $url );
ob_end_clean();
if ( false ===
$credentials || !
WP_Filesystem( $credentials ) ) { global $wp_filesystem;
$status['errorCode'
] = 'unable_to_connect_to_filesystem';
$status['errorMessage'
] =
__( 'Unable to connect to the filesystem. Please confirm your credentials.'
);
// Pass through the error from WP_Filesystem if one was raised.
if ( $wp_filesystem instanceof WP_Filesystem_Base &&
is_wp_error( $wp_filesystem->errors
) &&
$wp_filesystem->errors->
has_errors() ) { $status['errorMessage'
] =
esc_html( $wp_filesystem->errors->
get_error_message() );
} wp_send_json_error( $status );
}