Quickie Visitors Country WP Plugin

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

/*
Plugin Name: Top Visitors Flag
Plugin URI: http://www.marvinmarcelo.com/
Description: This plugin displays visitors on sidebar as widget dependent on WP/GEO-Track plugin.
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 = "
  • Top Visiting Countries

    \n"; /* id string */ foreach ($flagstats as $cf) { $cf->rows = number_format($cf->rows, 0, "", ","); $html .= "flagname . ".png\" alt=\"Flag of $cf->country with $cf->rows visits\" title=\"$cf->country with $cf->rows visits\" />\n"; } $html .= "
  • "; echo $html; } function init_tvf_init(){ register_sidebar_widget("Top Visitors Flags", "tvf_get_topvisits"); } if (defined('GT_NOT_INSTALLED')) { echo ""; } 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!

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>