public function delete_index($index_name = null)
{
$index = null === $index_name ? ep_get_index_name() : sanitize_text_field($index_name);
$request_args = array('method' => 'DELETE');
$request = ep_remote_request($index, apply_filters('ep_delete_index_request_args', $request_args));
// 200 means the delete was successful
// 404 means the index was non-existent, but we should still pass this through as we will occasionally want to delete an already deleted index
if (!is_wp_error($request) && (200 === wp_remote_retrieve_response_code($request) || 404 === wp_remote_retrieve_response_code($request))) {
$response_body = wp_remote_retrieve_body($request);
return json_decode($response_body);
}
return false;
}