diff --git a/wp-blocked.php b/wp-blocked.php index 6045646..2d53382 100644 --- a/wp-blocked.php +++ b/wp-blocked.php @@ -73,26 +73,25 @@ function format_results($URL, $fetch_stats=false) { // create table $output .= '
'."\n"; $output .= '
'."\n"; - - foreach ($status['results'] as $country) { - if($country['error']) { - $output .= '
'.$country['country'].': '.$country['error'].'
'; - } else if($country['success'] == 1 && $country['results']) { - if(count($country['results']) > 0) { - $status['url'] = $country['results']['url']; - $output .= '

'.__("Results for", 'wp-blocked').' '. $status['url'].'

'."\n"; - // we might have a global request + $output .= '

'.__("Results for", 'wp-blocked').' '. $URL.'

'."\n"; + + if($status['results'][0]['success'] || $status['results'][0]['error']) { + // global request + foreach ($status['results'] as $country) { + if($country['error']) { + $output .= '
'.$country['country'].': '.$country['error'].'
'; + } else if($country['success'] == 1 && count($country['results']) > 0) { $output .= format_results_table($country['results'], $country['country']); } else { $output .= '
'.$country['country'].': '.__('No results', 'wp-blocked').'
'; } - } else { - if(count($country['results']) > 0) { - $output .= '

'.__("Results for", 'wp-blocked').' '. $status['url'].'

'."\n"; - $output .= format_results_table($country); - } else { - $output .= '
'.$country['country'].': '.__('No results', 'wp-blocked').'
'; - } + } + } else { + // simple request + if(count($status['results']) > 0) { + $output .= format_results_table($status['results']); + } else { + $output .= '
'.$status['results'].': '.__('No results', 'wp-blocked').'
'; } }