2016-11-28 21:52:15 -08:00
< script type = " text/javascript " >
2018-01-26 15:50:15 +01:00
jQuery ( document ) . ready ( function () {
postboxes . add_postbox_toggles ( pagenow );
});
2016-11-28 21:52:15 -08:00
</ script >
< ? php
2018-01-26 15:50:15 +01:00
$daysToDisplay = 20 ;
if ( array_key_exists ( 'hitdays' , $_GET ) ) {
$daysToDisplay = intval ( $_GET [ 'hitdays' ] );
}
2016-11-28 21:52:15 -08:00
2018-01-26 15:50:15 +01:00
if ( array_key_exists ( 'rangestart' , $_GET ) ) {
$rangestart = $_GET [ 'rangestart' ];
} else {
$rangestart = '' ;
}
if ( array_key_exists ( 'rangeend' , $_GET ) ) {
$rangeend = $_GET [ 'rangeend' ];
} else {
$rangeend = '' ;
}
2016-11-28 21:52:15 -08:00
2018-01-26 15:50:15 +01:00
list ( $daysToDisplay , $rangestart_utime , $rangeend_utime ) = wp_statistics_date_range_calculator (
$daysToDisplay ,
$rangestart ,
$rangeend
);
2016-11-28 21:52:15 -08:00
?>
< div class = " wrap " >
2018-01-26 15:50:15 +01:00
< h2 >< ? php _e ( 'Top Countries' , 'wp-statistics' ); ?> </h2>
< ? php wp_statistics_date_range_selector ( WP_Statistics :: $page [ 'countries' ], $daysToDisplay ); ?>
< div class = " postbox-container " id = " last-log " >
< div class = " metabox-holder " >
< div class = " meta-box-sortables " >
< div class = " postbox " >
< ? php $paneltitle = __ ( 'Top Countries' , 'wp-statistics' ); ?>
< button class = " handlediv " type = " button " aria - expanded = " true " >
< span class = " screen-reader-text " >< ? php printf (
__ ( 'Toggle panel: %s' , 'wp-statistics' ),
$paneltitle
); ?> </span>
< span class = " toggle-indicator " aria - hidden = " true " ></ span >
</ button >
< h2 class = " hndle " >< span >< ? php echo $paneltitle ; ?> </h2>
2016-11-28 21:52:15 -08:00
2018-01-26 15:50:15 +01:00
< div class = " inside " >
< table class = " widefat table-stats " id = " last-referrer " style = " width: 100%; " >
< tr >
< td >< ? php _e ( 'Rank' , 'wp-statistics' ); ?> </td>
< td >< ? php _e ( 'Flag' , 'wp-statistics' ); ?> </td>
< td >< ? php _e ( 'Country' , 'wp-statistics' ); ?> </td>
< td >< ? php _e ( 'Visitor Count' , 'wp-statistics' ); ?> </td>
</ tr >
2016-11-28 21:52:15 -08:00
< ? php
2018-01-26 15:50:15 +01:00
$ISOCountryCode = $WP_Statistics -> get_country_codes ();
$rangestartdate = $WP_Statistics -> real_current_date ( 'Y-m-d' , '-0' , $rangestart_utime );
$rangeenddate = $WP_Statistics -> real_current_date ( 'Y-m-d' , '-0' , $rangeend_utime );
2016-11-28 21:52:15 -08:00
2018-01-26 15:50:15 +01:00
$result = $wpdb -> get_results (
sprintf ( " SELECT `location`, COUNT(`location`) AS `count` FROM ` { $wpdb -> prefix } statistics_visitor` WHERE `last_counter` BETWEEN '%s' AND '%s' GROUP BY `location` ORDER BY `count` DESC " ,
$rangestartdate ,
$rangeenddate
)
);
$i = 0 ;
foreach ( $result as $item ) {
$i ++ ;
$item -> location = strtoupper ( $item -> location );
echo " <tr> " ;
echo " <td> $i </td> " ;
echo " <td><img src=' " .
plugins_url ( 'wp-statistics/assets/images/flags/' . $item -> location . '.png' ) .
" ' title=' { $ISOCountryCode [ $item -> location ] } '/></td> " ;
echo " <td style='direction: ltr;'> { $ISOCountryCode [ $item -> location ] } </td> " ;
echo " <td> " . number_format_i18n ( $item -> count ) . " </td> " ;
echo " </tr> " ;
}
2016-11-28 21:52:15 -08:00
?>
2018-01-26 15:50:15 +01:00
</ table >
</ div >
</ div >
</ div >
</ div >
</ div >
</ div >