// =========================================================================
// HOT & COLD PLAYERS WIDGET (Skaters Only & Last 10 Played Team Games)
// =========================================================================
add_shortcode('otg_hot_cold_widget', 'otg_render_hot_cold_widget');
function otg_get_hot_cold_rangers() {
global $wpdb;
// 1. Get the Rangers' last 10 played game IDs where game_state != 'FUT'
$recent_games = $wpdb->get_results("
SELECT game_id, game_date
FROM otg_rangers_games
WHERE game_state != 'FUT'
ORDER BY game_date DESC, game_id DESC
LIMIT 10
");
if (empty($recent_games)) {
return ['hot' => [], 'not' => []];
}
// Reverse to chronological order (oldest to newest)
$recent_games = array_reverse($recent_games);
$total_team_games = count($recent_games);
// Extract ordered game_ids array for SQL IN clause
$game_ids = array_map(function($g) { return intval($g->game_id); }, $recent_games);
$game_ids_placeholder = implode(',', $game_ids);
// 2. Fetch active Rangers skaters (Strictly excluding Goalies/G)
$active_skaters = $wpdb->get_results("
SELECT ID, Name, nhl_id, Position
FROM otg_players
WHERE Status = 'Rangers'
AND nhl_id > 0
AND LOWER(TRIM(Position)) NOT IN ('g', 'goalie', 'goaltender')
");
$player_scores = array();
foreach ($active_skaters as $player) {
// 3. Fetch player stats across these exact 10 team games
$boxscores = $wpdb->get_results($wpdb->prepare("
SELECT game_id, goals, assists, shots
FROM otg_rangers_player_boxscores
WHERE player_id = %d
AND team_abbr = 'NYR'
AND game_id IN ($game_ids_placeholder)
", $player->nhl_id), OBJECT_K); // Index array by game_id for O(1) lookup
$score = 0;
// 4. Calculate score with recency weight across all 10 Rangers games
foreach ($recent_games as $index => $g) {
$gid = $g->game_id;
// Recency multiplier: 0.1 for oldest of the 10 games, 1.0 for the most recent game
$recency_weight = ($index + 1) / $total_team_games;
// If player played in this game, use stats; otherwise 0
if (isset($boxscores[$gid])) {
$goals = intval($boxscores[$gid]->goals);
$assists = intval($boxscores[$gid]->assists);
$shots = intval($boxscores[$gid]->shots);
} else {
$goals = 0;
$assists = 0;
$shots = 0;
}
// Weighting: Goals (5.0) > Assists (3.0) > SOG (0.4)
$game_points = ($goals * 5.0) + ($assists * 3.0) + ($shots * 0.4);
$score += ($game_points * $recency_weight);
}
$player_scores[] = [
'id' => $player->ID,
'name' => $player->Name,
'score' => round($score, 2)
];
}
// 5. Sort players by score descending
usort($player_scores, function($a, $b) {
return $b['score'] <=> $a['score'];
});
// Top 5 Hottest & Bottom 5 Coldest
$hot = array_slice($player_scores, 0, 5);
$not = array_slice(array_reverse($player_scores), 0, 5);
return [
'hot' => $hot,
'not' => $not
];
}
function otg_render_hot_cold_widget() {
$data = otg_get_hot_cold_rangers();
$hot = $data['hot'];
$not = $data['not'];
$html = '
';
// Who is Hot Box (Orange theme)
$html .= '
';
$html .= '
🔥 Who Is Hot ';
$html .= '
';
if (!empty($hot)) {
foreach ($hot as $p) {
$html .= '';
$html .= ''.esc_html($p['name']).' ';
$html .= ''.$p['score'].' ';
$html .= ' ';
}
} else {
$html .= 'No data available ';
}
$html .= ' ';
// Who is Not Box (Blue theme)
$html .= '
';
$html .= '
❄️ Who Is Not ';
$html .= '
';
if (!empty($not)) {
foreach ($not as $p) {
$html .= '';
$html .= ''.esc_html($p['name']).' ';
$html .= ''.$p['score'].' ';
$html .= ' ';
}
} else {
$html .= 'No data available ';
}
$html .= ' ';
$html .= '
';
return $html;
}
July 14, 2026 - OutsideTheGarden
Skip to content
With a new year, comes new jersey numbers for you to remember. Captain J.T. Miller is able to revert back from #8 to his preferred #10 now that Artemi Panarin is no longer with the organization. Defenseman Sean Durzi picks up a very defenseman looking number in #5, while his projected partner Marcus Pettersson on the second pair will wear #26.
Up front the three main forwards expected to slot into the line-up will wear #16 – Pavel Dorofeyev, #28 – Oliver Bjorkstrand and #90 – Joe Veleno. Finally in goal Joonas Korpisalo, acquired from Boston and hoping to win the backup role, will take #70. It’s a relatively high number of additions this year with the moves that Chris Drury make, combined with Miller’s switch, which will inevitably mean some early challenges identifying players and their new numbers.