function counterize_get_flag_tag($code, $alt) { $alt = htmlspecialchars($alt); $code = htmlspecialchars($code); $src = counterize_get_flag_url($code); $res = ''; if ($src != '') { $res .= "\n\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\tsrc='{$src}'\n\t\t\t\t\t\t\t\t\talt='" . sprintf(__('National flag of %s', COUNTERIZE_TD), $alt) . "'\n\t\t\t\t\t\t\t\t\ttitle='" . counterize_get_countryname($code) . " ({$code})'\n\t\t\t\t\t\t\t\t\theight='" . COUNTERIZE_ICON_SIZE . "'\n\t\t\t\t\t\t\t\t\tclass='countryflag'\n\t\t\t\t\t\t\t\t />\n\t\t\t\t\t\t\t\t\t"; } return $res; }
public function counterize_feed_most_visiting_countries24hrs($number = 10, $header_override = '') { global $wpdb; $number = $wpdb->prepare("%d", $number); $onedayago = date('Y-m-d H:i:s', time() - 86400); $sql = "SELECT COUNT( m.id ) AS `count`, c.code, c.code AS label " . " FROM `" . counterize_logTable() . "` m, `" . counterize_countryTable() . "` c " . " WHERE m.countryID = c.countryID" . " AND m.timestamp >= '{$onedayago}'" . " GROUP BY c.code " . " ORDER BY `count` DESC " . " LIMIT {$number}"; $rows = $wpdb->get_results($sql); $title = __('Most visiting countries for the last 24 hours', COUNTERIZE_PLUGIN_COUNTRIES_TD); if (!empty($header_override)) { $title = $header_override; } $feed = new CounterizeFeed($title, __('Countries', COUNTERIZE_PLUGIN_COUNTRIES_TD)); foreach ($rows as $row) { $src = counterize_get_flag_url($row->code); $name = counterize_get_countryname($row->code); if (empty($row->code) || $row->code == ' ' || $row->code == '00') { $label = __('unknown', COUNTERIZE_PLUGIN_COUNTRIES_TD); } else { $label = $name; } if (!empty($src)) { $img = new CounterizeFeedImg($src, sprintf(__('National flag of %s', COUNTERIZE_PLUGIN_COUNTRIES_TD), $name), counterize_get_countryname($row->code) . " ({$row->code})", 'countryflag'); $feed->add_item_4($row->count, $label, '', $img); } else { $feed->add_item_2($row->count, $label); } unset($src, $name, $label); } unset($rows, $sql); $feed->refresh_percentages(); return $feed; }