add_shortcode('online_models_v2', 'render_root_models_v2');

function render_root_models_v2() {
    // АБСОЛЮТНЫЙ ПУТЬ: указываем на корень всего сайта WordPress
    $file_path = ABSPATH . 'rus_data_V2.json';

    if (!file_exists($file_path)) {
        return '<p style="color:red;">Ошибка: Файл rus_data_V2.json не найден в корне сайта (' . esc_html($file_path) . ').</p>';
    }

    // Читаем файл
    $json_content = file_get_contents($file_path);
    $data = json_decode($json_content, true);

    // Проверяем структуру: данные должны быть в массиве 'models'
    if (empty($data) || !isset($data['models']) || !is_array($data['models'])) {
        return '<p>Модели сейчас недоступны или JSON пуст.</p>';
    }

    // Верстка сетки карточек
    $output = '<div class="models-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 15px;">';

    foreach ($data['models'] as $model) {
        // Собираем данные по ключам из скриншота
        $name = !empty($model['display_name']) ? esc_html($model['display_name']) : (!empty($model['username']) ? esc_html($model['username']) : 'Model');
        $age = !empty($model['display_age']) ? (int)$model['display_age'] : '';
        
        // Локация
        $hometown = !empty($model['hometown']) ? esc_html($model['hometown']) : '';
        $country = !empty($model['homecountry']) ? esc_html($model['homecountry']) : '';
        $location = array_filter([$hometown, $country]);
        $location_str = !empty($location) ? implode(', ', $location) : '';

        // Картинка (берём большую из profile_images -> thumbnail_image_big)
        $image = 'https://placeholder.com'; 
        if (!empty($model['profile_images']['thumbnail_image_big'])) {
            $image = esc_url($model['profile_images']['thumbnail_image_big']);
        }

        // Партнёрская ссылка
        $partner_link = !empty($model['profile_page_url']) ? esc_url($model['profile_page_url']) : '#';

        // Собираем карточку
        $output .= '<div class="model-card" style="border: 1px solid #e0e0e0; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,0.08); text-align: center; background: #fff; display: flex; flex-direction: column; justify-content: space-between; transition: transform 0.2s;">';
        
        // Фото
        $output .= '<div style="position: relative; height: 340px; overflow: hidden;">';
        $output .= '<img src="' . $image . '" alt="' . $name . '" style="width: 100%; height: 100%; object-fit: cover; display: block;">';
        $output .= '</div>';
        
        // Инфо-блок
        $output .= '<div style="padding: 15px; flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; background: #fafafa;">';
        $output .= '<div>';
        $output .= '<h3 style="margin: 0 0 5px 0; font-size: 20px; color: #222; font-weight: bold;">' . $name . ($age ? ', ' . $age : '') . '</h3>';
        if ($location_str) {
            $output .= '<p style="margin: 0 0 15px 0; font-size: 13px; color: #777;">📍 ' . $location_str . '</p>';
        }
        $output .= '</div>';
        
        // Кнопка партнёрки
        $output .= '<a href="' . $partner_link . '" target="_blank" rel="nofollow" style="display: block; background: #ff4757; color: #fff; padding: 12px 20px; border-radius: 8px; text-decoration: none; font-weight: bold; font-size: 15px; box-shadow: 0 3px 6px rgba(255,71,87,0.3); text-transform: uppercase; letter-spacing: 0.5px;">Открыть профиль</a>';
        $output .= '</div>'; // /padding
        
        $output .= '</div>'; // /model-card
    }

    $output .= '</div>'; // /models-grid

    return $output;
}
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//runetki.sxvchat.com/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://runetki.sxvchat.com/post-sitemap.xml</loc>
		<lastmod>2026-09-09T17:03:23+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://runetki.sxvchat.com/page-sitemap.xml</loc>
		<lastmod>2026-09-09T21:13:57+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://runetki.sxvchat.com/category-sitemap.xml</loc>
		<lastmod>2026-09-09T17:03:23+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Rank Math SEO Plugin (c) Rank Math - rankmath.com -->
<!-- This sitemap was originally generated in 0,006 second(s). (Memory usage: 393,41 КБ) - 16 queries -->