{\rtf1\ansi\ansicpg1252\cocoartf2822
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\fs24 \cf0 <?php\
/**\
 * Plugin Name: World Nations Score Ticker\
 * Description: Live scrolling ticker of UN nations with editable scores.\
 * Version: 1.0\
 */\
\
if (!defined('ABSPATH')) exit;\
\
define('WNST_PATH', plugin_dir_path(__FILE__));\
define('WNST_URL', plugin_dir_url(__FILE__));\
\
require_once WNST_PATH . 'includes/install.php';\
require_once WNST_PATH . 'includes/functions.php';\
require_once WNST_PATH . 'includes/admin-page.php';\
\
register_activation_hook(__FILE__, 'wnst_install');\
\
add_action('wp_enqueue_scripts', function () \{\
    wp_enqueue_style('wnst-css', WNST_URL . 'assets/ticker.css');\
    wp_enqueue_script('wnst-js', WNST_URL . 'assets/ticker.js', [], null, true);\
\});\
\
add_action('wp_body_open', 'wnst_render_ticker');\
\
function wnst_render_ticker() \{\
    global $wpdb;\
    $table = $wpdb->prefix . "wnst_scores";\
\
    $rows = $wpdb->get_results("SELECT * FROM $table ORDER BY country_name ASC");\
\
    echo '<div class="wnst-ticker"><div class="wnst-track">';\
\
    foreach ($rows as $row) \{\
\
        $score = floatval($row->score);\
        $prev = floatval($row->previous_score);\
\
        $diff = $score - $prev;\
        $percent = $prev != 0 ? ($diff / $prev) * 100 : 0;\
\
        $arrow = "\uc0\u9658 ";\
        $class = "flat";\
\
        if ($diff > 0) \{\
            $arrow = "\uc0\u9650 ";\
            $class = "up";\
        \} elseif ($diff < 0) \{\
            $arrow = "\uc0\u9660 ";\
            $class = "down";\
        \}\
\
        $flag = wnst_flag($row->country_code);\
\
        echo "<span class='wnst-item $class'>\
                $flag \{$row->country_name\}\
                <strong>" . number_format($score, 2) . "</strong>\
                $arrow (" . number_format($percent, 2) . "%)\
              </span>";\
    \}\
\
    echo '</div></div>';\
\}}<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://thehumanvalueindex.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://thehumanvalueindex.com/wp-sitemap-posts-page-1.xml</loc></sitemap></sitemapindex>
