“Whenever you find yourself on the side of the majority, it's time to pause and reflect.”
– Mark Twain

Posts Tagged ‘snippet’


27
Oct

This plugin is dependent on WP/GeoTrack by Johannes Lietz, this is NOT a stand-alone plugin, it won’t work if WP/GeoTrack is not installed anyway, so it’s safe.

And don’t look for it in WP Plugins repo, you won’t find it there :D

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Plugin Name: Top Visitors Flag
Plugin URI: http://www.marvinmarcelo.com/
Description: This plugin displays visitors on sidebar as widget dependent on <a href="http://dadabase.de/weblog/archives/2006/05/23/wordpress-geotrack-plugin">WP/GEO-Track plugin</a>.
Author: Marvin Marcelo
Author URI: http://www.marvinmarcelo.com/
Version: 1.0.0
*/
function tvf_get_topvisits()
{
  global $wpdb, $table_prefix;
  $sql = "select count(*) as `rows` , `country` , `flagname` from `".$table_prefix."geotrack` group by `country` order by `rows` desc limit 0 , 12";
  $flagstats = $wpdb->get_results($sql);
 
  $html = "<li id='top-country-flags'><h2>Top Visiting Countries</h2><div>\n"; /*  id string */
  foreach ($flagstats as $cf)
  {
    $cf->rows = number_format($cf->rows, 0, "", ",");
    $html .= "<img src=\"". GEOTRACK_URL . "flags/" . $cf-/>flagname . ".png\" alt=\"Flag of $cf->country with $cf->rows visits\" title=\"$cf->country with $cf->rows visits\" />\n";
  }
  $html .= "</div></li>";
  echo $html;
}
 
function init_tvf_init(){
	register_sidebar_widget("Top Visitors Flags", "tvf_get_topvisits");
}
 
if (defined('GT_NOT_INSTALLED'))
{
  echo "<!-- You need \"http://dadabase.de/weblog/archives/2006/05/23/wordpress-geotrack-plugin\" installed first-->";
}
else
{
  add_action("plugins_loaded", "init_tvf_init");
}

Also, you have to forgive the function, constants, and variables names, we all struggle for a better and sensible one :) Happy coding!