// ادارة القنوات add_action('wp_ajax_ee_save_scraperapi_api_key', function () { if (!current_user_can('manage_options')) { wp_send_json_error(['message' => 'ليس لديك صلاحية']); wp_die(); } $api_key = sanitize_text_field($_POST['scraperapi_api_key'] ?? ''); if (empty($api_key)) { wp_send_json_error(['message' => 'المفتاح فارغ']); wp_die(); } update_option('ee_scraperapi_key', $api_key); wp_send_json_success(['message' => 'تم حفظ المفتاح بنجاح']); wp_die(); }); add_action('wp_ajax_ee_fetch_matches_for_channels', function () { if (!current_user_can('manage_options')) { wp_send_json_error(['message' => 'ليس لديك صلاحية']); wp_die(); } set_time_limit(300); date_default_timezone_set('Asia/Dubai'); $api_key = get_option('ee_scraperapi_key', ''); if (empty($api_key)) { wp_send_json_error(['message' => 'لم يتم حفظ مفتاح ScraperAPI. يرجى إدخال المفتاح في إعدادات الدوري أولاً.']); wp_die(); } $selected_leagues = get_option('ee_leagues_list', []); if (empty($selected_leagues)) { wp_send_json_error(['message' => 'يرجى تحديد دوري في إعدادات الدوري أولاً.']); wp_die(); } $today = new DateTime('now', new DateTimeZone('Asia/Dubai')); $today_str = $today->format('Y-m-d'); $url = 'https://jdwel.com/today/'; $scraper_url = 'https://api.scraperapi.com/?api_key=' . $api_key . '&url=' . urlencode($url) . '&keep_headers=true'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $scraper_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)', 'Accept: text/html' ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curl_error = curl_error($ch); curl_close($ch); if ($httpCode !== 200 || empty($response)) { $error_message = "فشل الاتصال بـ ScraperAPI: كود الاستجابة $httpCode"; if (!empty($curl_error)) { $error_message .= " - خطأ cURL: $curl_error"; } wp_send_json_error(['message' => $error_message]); wp_die(); } libxml_use_internal_errors(true); $dom = new DOMDocument(); @$dom->loadHTML($response); $xpath = new DOMXPath($dom); $matches = $xpath->query('//li[contains(@class, "single_match")]'); if ($matches->length === 0) { wp_send_json_error(['message' => 'لم يتم العثور على مباريات.']); wp_die(); } $matches_data = []; $match_ids = []; foreach ($matches as $match) { $league_node = $xpath->query('preceding::div[contains(@class, "comp_separator")][1]//h4[@class="title"]', $match); $league = $league_node->item(0)?->textContent ?? 'غير محدد'; if (!in_array($league, $selected_leagues)) { continue; } $match_id = $match->getAttribute('id') ? str_replace('match_', '', $match->getAttribute('id')) : 'غير محدد'; $home_team = $xpath->query('.//div[contains(@class, "hometeam")]//span[@class="the_team"]', $match)->item(0)?->textContent ?? 'غير محدد'; $away_team = $xpath->query('.//div[contains(@class, "awayteam")]//span[@class="the_team"]', $match)->item(0)?->textContent ?? 'غير محدد'; $date_time = $xpath->query('.//span[@class="the_otime"]', $match)->item(0)?->textContent ?? ''; $date = $today_str; // افتراضيًا، استخدم تاريخ اليوم $time = 'غير محدد'; $next_day_str = (clone $today)->modify('+1 day')->format('Y-m-d'); // التحقق من ملاحظة "(اليوم التالي)" $next_day_note = $xpath->query('.//div[contains(text(), "(اليوم التالي)")]', $match)->item(0)?->textContent ?? ''; if ($date_time !== '') { try { $datetime = new DateTime($date_time, new DateTimeZone('Asia/Dubai')); $datetime->modify('+1 hour'); $date_parts = explode(' ', $date_time); $original_date = $date_parts[0]; $time = $datetime->format('g:i A'); $time = str_replace('AM', 'ص', $time); $time = str_replace('PM', 'م', $time); $date = $original_date; // إذا وُجدت ملاحظة "(اليوم التالي)"، استخدم تاريخ اليوم التالي if (strpos($next_day_note, '(اليوم التالي)') !== false) { $date = $next_day_str; } // التحقق من التاريخ if ($date !== $today_str && $date !== $next_day_str) { continue; // تجاهل المباريات التي لا تتطابق مع تاريخ اليوم أو اليوم التالي } // إذا كانت المباراة في اليوم التالي، تحقق من أن توقيتها قبل 6:00 صباحًا if ($date === $next_day_str && $time !== 'غير محدد') { $match_time = DateTime::createFromFormat('g:i A', str_replace(['ص', 'م'], ['AM', 'PM'], $time), new DateTimeZone('Asia/Dubai')); if ($match_time === false) { continue; // تجاهل إذا فشل تحويل التوقيت } $cutoff_time = new DateTime($next_day_str . ' 06:00:00', new DateTimeZone('Asia/Dubai')); if ($match_time->format('H:i:s') > $cutoff_time->format('H:i:s')) { continue; // تجاهل المباريات بعد 6:00 صباحًا في اليوم التالي } } } catch (Exception $e) { continue; // تجاهل إذا حدث خطأ في معالجة التوقيت } } else { $time_raw = $xpath->query('.//span[@class="the_time"]', $match)->item(0)?->textContent ?? 'غير محدد'; if ($time_raw !== 'غير محدد') { try { $time_raw = trim($time_raw); $datetime = DateTime::createFromFormat('g:i A', str_replace(['ص', 'م'], ['AM', 'PM'], $time_raw), new DateTimeZone('Asia/Dubai')); if ($datetime === false) { continue; // تجاهل إذا فشل تحويل التوقيت } $time = $datetime->format('g:i A'); $time = str_replace('AM', 'ص', $time); $time = str_replace('PM', 'م', $time); } catch (Exception $e) { continue; // تجاهل إذا حدث خطأ في معالجة التوقيت } } $date_input = $xpath->query('//div[contains(@class, "matchday_header")]//input[@type="date"]/@value')->item(0)?->value ?? ''; if ($date_input) { $date = $date_input; // إذا وُجدت ملاحظة "(اليوم التالي)"، استخدم تاريخ اليوم التالي if (strpos($next_day_note, '(اليوم التالي)') !== false) { $date = $next_day_str; } if ($date !== $today_str && $date !== $next_day_str) { continue; // تجاهل المباريات التي لا تتطابق مع تاريخ اليوم أو اليوم التالي } if ($date === $next_day_str && $time !== 'غير محدد') { $match_time = DateTime::createFromFormat('g:i A', str_replace(['ص', 'م'], ['AM', 'PM'], $time), new DateTimeZone('Asia/Dubai')); if ($match_time === false) { continue; // تجاهل إذا فشل تحويل التوقيت } $cutoff_time = new DateTime($next_day_str . ' 06:00:00', new DateTimeZone('Asia/Dubai')); if ($match_time->format('H:i:s') > $cutoff_time->format('H:i:s')) { continue; // تجاهل المباريات بعد 6:00 صباحًا في اليوم التالي } } } if ($time === 'غير محدد') { continue; // تجاهل إذا لم يتم العثور على توقيت صحيح } } if ($match_id !== 'غير محدد') { $match_ids[] = $match_id; } $matches_data[] = [ 'league' => $league, 'match' => "$home_team vs $away_team", 'date' => $date, 'time' => $time, 'channels' => [], 'commentators' => [], 'match_link' => 'غير متوفر' // سيتم تحديثه لاحقًا ]; } if (empty($matches_data)) { wp_send_json_error(['message' => 'لم يتم العثور على مباريات تنتمي إلى الدوريات المحددة لتاريخ اليوم.']); wp_die(); } // ربط الروابط foreach ($matches_data as &$match) { $match_str = !empty($match['match']) ? trim($match['match']) : 'غير محدد vs غير محدد'; $teams = explode(' vs ', $match_str); $team1 = !empty($teams[0]) ? trim($teams[0]) : 'غير محدد'; $team2 = !empty($teams[1]) ? trim($teams[1]) : 'غير محدد'; $date = !empty($match['date']) ? trim($match['date']) : $today_str; $search_title = "$team1 vs $team2"; $query = new WP_Query([ 'post_type' => 'joomsport_match', 'post_status' => 'publish', 's' => $search_title, 'posts_per_page' => 1, 'meta_query' => [ [ 'key' => '_joomsport_match_date', 'value' => $date, 'compare' => '=' ] ] ]); if ($query->have_posts()) { $query->the_post(); $match['match_link'] = rawurldecode(get_permalink()); wp_reset_postdata(); } else { $match['match_link'] = 'غير متوفر'; } } unset($match); $existing_channels_data = get_option('ee_matches_channels_data', []); foreach ($match_ids as $index => $match_id) { $api_url = "https://jdwel.com/wp-json/jmanager/web/v1/match/$match_id"; $scraper_api_url = "https://api.scraperapi.com/?api_key=$api_key&url=" . urlencode($api_url) . "&keep_headers=true"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $scraper_api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)', 'Accept: application/json' ]); $api_response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curl_error = curl_error($ch); curl_close($ch); if ($httpCode === 200 && !empty($api_response)) { $json = json_decode($api_response, true); if ($json !== null) { $tv_stations = $json['data']['tv_stations'] ?? []; if (is_array($tv_stations) && !empty($tv_stations)) { $channel_names = []; $commentator_names = []; foreach ($tv_stations as $station) { $channel_name = isset($station['name']) && !empty($station['name']) ? esc_html($station['name']) : 'غير محدد'; $commentator = isset($station['commentators']) && !empty($station['commentators']) && $station['commentators'] !== 'غير محدد' ? esc_html($station['commentators']) : 'غير محدد'; $channel_names[] = $channel_name; $commentator_names[] = $commentator; } $matches_data[$index]['channels'] = $channel_names; $matches_data[$index]['commentators'] = $commentator_names; $match_key = $matches_data[$index]['match'] . '|' . $matches_data[$index]['date']; $existing_channels_data[$match_key] = [ 'channels' => $channel_names, 'commentators' => $commentator_names, ]; } else { $matches_data[$index]['channels'] = ['غير متاح']; $matches_data[$index]['commentators'] = ['غير متاح']; } } else { $matches_data[$index]['channels'] = ['غير متاح']; $matches_data[$index]['commentators'] = ['غير متاح']; } } else { $matches_data[$index]['channels'] = ['غير متاح']; $matches_data[$index]['commentators'] = ['غير متاح']; } usleep(500000); } update_option('ee_matches_data', $matches_data); update_option('ee_matches_channels_data', $existing_channels_data); wp_send_json_success(['matches' => $matches_data]); wp_die(); }); add_action('wp_ajax_ee_add_league', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ee_league_settings_nonce')) { wp_send_json_error(['message' => 'فشل التحقق من رمز الأمان']); wp_die(); } $league = isset($_POST['league']) ? sanitize_text_field($_POST['league']) : ''; if (empty($league)) { wp_send_json_error(['message' => 'يرجى إدخال اسم الدوري']); wp_die(); } $leagues = get_option('ee_leagues_list', []); $leagues[] = $league; update_option('ee_leagues_list', $leagues); wp_send_json_success(['leagues' => $leagues, 'html' => ee_render_leagues_list()]); wp_die(); }); add_action('wp_ajax_ee_delete_league', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ee_league_settings_nonce')) { wp_send_json_error(['message' => 'فشل التحقق من رمز الأمان']); wp_die(); } $league_id = isset($_POST['league_id']) ? intval($_POST['league_id']) : -1; $leagues = get_option('ee_leagues_list', []); if ($league_id >= 0 && isset($leagues[$league_id])) { array_splice($leagues, $league_id, 1); update_option('ee_leagues_list', $leagues); wp_send_json_success(['leagues' => $leagues, 'html' => ee_render_leagues_list()]); } else { wp_send_json_error(['message' => 'فشل في حذف الدوري']); } wp_die(); }); add_action('wp_ajax_ee_get_current_match_data', function () { $match_id = isset($_POST['match_id']) ? intval($_POST['match_id']) : get_the_ID(); $home_team_id = get_post_meta($match_id, '_joomsport_home_team', true); $away_team_id = get_post_meta($match_id, '_joomsport_away_team', true); $home_team_name = $home_team_id ? get_the_title($home_team_id) : ''; $away_team_name = $away_team_id ? get_the_title($away_team_id) : ''; $match_teams = $home_team_name && $away_team_name ? "$home_team_name vs $away_team_name" : ''; $match_date = get_post_meta($match_id, '_joomsport_match_date', true); $all_meta = get_post_meta($match_id); wp_send_json_success([ 'match_teams' => $match_teams, 'match_date' => $match_date, 'all_meta' => $all_meta ]); wp_die(); }); add_action('wp_ajax_ee_add_channel', function () { if (!current_user_can('manage_options')) { wp_send_json_error(['message' => 'ليس لديك صلاحية لإضافة قناة']); wp_die(); } if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ee_channel_settings_nonce')) { wp_send_json_error(['message' => 'فشل التحقق من رمز الأمان']); wp_die(); } $channel_name = isset($_POST['channel_name']) ? sanitize_text_field($_POST['channel_name']) : ''; $display_name = isset($_POST['display_name']) ? sanitize_text_field($_POST['display_name']) : $channel_name; $channel_link = isset($_POST['channel_link']) ? sanitize_text_field($_POST['channel_link']) : ''; $background_color = isset($_POST['background_color']) ? sanitize_hex_color($_POST['background_color']) : '#ffffff'; $text_color = isset($_POST['text_color']) ? sanitize_hex_color($_POST['text_color']) : '#000000'; $commentator_background_color = isset($_POST['commentator_background_color']) ? sanitize_hex_color($_POST['commentator_background_color']) : '#ffffff'; $commentator_text_color = isset($_POST['commentator_text_color']) ? sanitize_hex_color($_POST['commentator_text_color']) : '#000000'; if (empty($channel_name)) { wp_send_json_error(['message' => 'يرجى ملء اسم القناة']); wp_die(); } $channels = get_option('ee_channels_list', []); $channels[] = [ 'name' => $channel_name, 'display_name' => $display_name, 'link' => $channel_link, 'background_color' => $background_color, 'text_color' => $text_color, 'commentator_background_color' => $commentator_background_color, 'commentator_text_color' => $commentator_text_color, ]; update_option('ee_channels_list', $channels); wp_send_json_success(['channels' => $channels]); wp_die(); }); add_action('wp_ajax_ee_delete_channel', function () { error_log('wp_ajax_ee_delete_channel called with nonce: ' . ($_POST['nonce'] ?? 'none') . ', user: ' . wp_get_current_user()->user_login); if (!current_user_can('manage_options')) { error_log('Permission denied for user: ' . wp_get_current_user()->user_login); wp_send_json_error(['message' => 'ليس لديك صلاحية']); wp_die(); } if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ee_channel_settings_nonce')) { error_log('Nonce verification failed for ee_delete_channel, nonce: ' . ($_POST['nonce'] ?? 'none')); wp_send_json_error(['message' => 'فشل التحقق من رمز الأمان']); wp_die(); } $index = isset($_POST['index']) ? intval($_POST['index']) : -1; $channels = get_option('ee_channels_list', []); if ($index >= 0 && isset($channels[$index])) { array_splice($channels, $index, 1); update_option('ee_channels_list', $channels); wp_send_json_success(['channels' => $channels]); } else { wp_send_json_error(['message' => 'فشل في حذف القناة']); } wp_die(); }); add_action('wp_ajax_ee_update_channel_colors', function () { check_ajax_referer('ee_channel_settings_nonce', 'nonce'); $index = isset($_POST['index']) ? intval($_POST['index']) : -1; $background_color = isset($_POST['background_color']) ? sanitize_hex_color($_POST['background_color']) : '#ffffff'; $text_color = isset($_POST['text_color']) ? sanitize_hex_color($_POST['text_color']) : '#000000'; $commentator_background_color = isset($_POST['commentator_background_color']) ? sanitize_hex_color($_POST['commentator_background_color']) : '#ffffff'; $commentator_text_color = isset($_POST['commentator_text_color']) ? sanitize_hex_color($_POST['commentator_text_color']) : '#000000'; $channels = get_option('ee_channels_list', []); if ($index >= 0 && isset($channels[$index])) { $channels[$index]['background_color'] = $background_color; $channels[$index]['text_color'] = $text_color; $channels[$index]['commentator_background_color'] = $commentator_background_color; $channels[$index]['commentator_text_color'] = $commentator_text_color; update_option('ee_channels_list', $channels); wp_send_json_success(['channels' => $channels]); } else { wp_send_json_error(['message' => 'فشل في تحديث الألوان']); } }); add_action('wp_ajax_ee_save_global_colors', function () { check_ajax_referer('ee_global_colors_nonce', 'nonce'); $channel_icon_color = isset($_POST['channel_icon_color']) ? sanitize_hex_color($_POST['channel_icon_color']) : '#333333'; $commentator_icon_color = isset($_POST['commentator_icon_color']) ? sanitize_hex_color($_POST['commentator_icon_color']) : '#333333'; $play_icon_show_before = isset($_POST['play_icon_show_before']) ? intval($_POST['play_icon_show_before']) : 15; $play_icon_hide_after = isset($_POST['play_icon_hide_after']) ? intval($_POST['play_icon_hide_after']) : 5; update_option('ee_channel_icon_color', $channel_icon_color); update_option('ee_commentator_icon_color', $commentator_icon_color); update_option('ee_play_icon_show_before', $play_icon_show_before); update_option('ee_play_icon_hide_after', $play_icon_hide_after); wp_send_json_success(); }); add_action('wp_ajax_ee_update_channel', function () { if (!current_user_can('manage_options')) { wp_send_json_error(['message' => 'ليس لديك صلاحية لتحديث القناة']); wp_die(); } if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ee_channel_settings_nonce')) { wp_send_json_error(['message' => 'فشل التحقق من رمز الأمان']); wp_die(); } $index = isset($_POST['index']) ? intval($_POST['index']) : -1; $channel_name = isset($_POST['channel_name']) ? sanitize_text_field($_POST['channel_name']) : ''; $display_name = isset($_POST['display_name']) ? sanitize_text_field($_POST['display_name']) : $channel_name; $channel_link = isset($_POST['channel_link']) ? sanitize_text_field($_POST['channel_link']) : ''; $background_color = isset($_POST['background_color']) ? sanitize_hex_color($_POST['background_color']) : '#ffffff'; $text_color = isset($_POST['text_color']) ? sanitize_hex_color($_POST['text_color']) : '#000000'; $commentator_background_color = isset($_POST['commentator_background_color']) ? sanitize_hex_color($_POST['commentator_background_color']) : '#ffffff'; $commentator_text_color = isset($_POST['commentator_text_color']) ? sanitize_hex_color($_POST['commentator_text_color']) : '#000000'; $channels = get_option('ee_channels_list', []); if ($index >= 0 && isset($channels[$index])) { $channels[$index]['name'] = $channel_name; $channels[$index]['display_name'] = $display_name; $channels[$index]['link'] = $channel_link; $channels[$index]['background_color'] = $background_color; $channels[$index]['text_color'] = $text_color; $channels[$index]['commentator_background_color'] = $commentator_background_color; $channels[$index]['commentator_text_color'] = $commentator_text_color; update_option('ee_channels_list', $channels); wp_send_json_success(['channels' => $channels]); } else { wp_send_json_error(['message' => 'فشل في تحديث القناة']); } wp_die(); }); add_action('wp_ajax_ee_get_matches', function () { $matches = get_option('ee_matches_data', []); wp_send_json_success(['matches' => $matches]); wp_die(); }); add_action('wp_ajax_ee_get_channels', function () { $channels = get_option('ee_channels_list', []); wp_send_json_success(['channels' => $channels]); }); add_action('wp_ajax_ee_get_match_channels', 'ee_get_match_channels_callback'); add_action('wp_ajax_nopriv_ee_get_match_channels', 'ee_get_match_channels_callback'); function ee_get_match_channels_callback() { $match_teams = isset($_POST['match_teams']) ? sanitize_text_field($_POST['match_teams']) : ''; $match_date = isset($_POST['match_date']) ? sanitize_text_field($_POST['match_date']) : ''; if (empty($match_teams) || empty($match_date)) { wp_send_json_error(['message' => 'بيانات المباراة غير مكتملة']); wp_die(); } $match_teams_cleaned = trim(str_replace("\u00a0", " ", $match_teams)); $match_date_cleaned = trim($match_date); $channels_data = get_option('ee_matches_channels_data', []); $match_key = $match_teams_cleaned . '|' . $match_date_cleaned; $defined_channels = get_option('ee_channels_list', []); if (isset($channels_data[$match_key])) { $channels = !empty($channels_data[$match_key]['channels']) ? $channels_data[$match_key]['channels'] : ['لا توجد قنوات']; $commentators = !empty($channels_data[$match_key]['commentators']) ? $channels_data[$match_key]['commentators'] : ['غير محدد']; $formatted_channels = []; foreach ($channels as $index => $channel_name) { $channel_settings = null; foreach ($defined_channels as $defined_channel) { if ($defined_channel['name'] === $channel_name) { $channel_settings = $defined_channel; break; } } $formatted_channels[] = [ 'name' => $channel_settings && !empty($channel_settings['display_name']) ? $channel_settings['display_name'] : $channel_name, 'background_color' => $channel_settings ? $channel_settings['background_color'] : '#ffffff', 'text_color' => $channel_settings ? $channel_settings['text_color'] : '#000000', 'commentator_background_color' => $channel_settings ? $channel_settings['commentator_background_color'] : '#ffffff', 'commentator_text_color' => $channel_settings ? $channel_settings['commentator_text_color'] : '#000000', 'link' => $channel_settings ? $channel_settings['link'] : '' ]; } } else { $formatted_channels = []; $commentators = ['غير محدد']; foreach ($channels_data as $key => $data) { list($stored_teams, $stored_date) = explode('|', $key); if ($stored_date === $match_date_cleaned) { $similarity = 0; similar_text($match_teams_cleaned, $stored_teams, $similarity); if ($similarity >= 80) { $channels = !empty($data['channels']) ? $data['channels'] : ['لا توجد قنوات']; $commentators = !empty($data['commentators']) ? $data['commentators'] : ['غير محدد']; foreach ($channels as $index => $channel_name) { $channel_settings = null; foreach ($defined_channels as $defined_channel) { if ($defined_channel['name'] === $channel_name) { $channel_settings = $defined_channel; break; } } $formatted_channels[] = [ 'name' => $channel_settings && !empty($channel_settings['display_name']) ? $channel_settings['display_name'] : $channel_name, 'background_color' => $channel_settings ? $channel_settings['background_color'] : '#ffffff', 'text_color' => $channel_settings ? $channel_settings['text_color'] : '#000000', 'commentator_background_color' => $channel_settings ? $channel_settings['commentator_background_color'] : '#ffffff', 'commentator_text_color' => $channel_settings ? $channel_settings['commentator_text_color'] : '#000000', 'link' => $channel_settings ? $channel_settings['link'] : '' ]; } break; } } } if (empty($formatted_channels)) { $formatted_channels = [['name' => 'لا توجد قنوات', 'background_color' => '#ffffff', 'text_color' => '#000000', 'commentator_background_color' => '#ffffff', 'commentator_text_color' => '#000000', 'link' => '']]; } } wp_send_json_success([ 'channels' => $formatted_channels, 'commentators' => $commentators ]); wp_die(); } add_action('wp_ajax_ee_get_scraperapi_api_key', function () { if (!current_user_can('manage_options')) { wp_send_json_error(['message' => 'ليس لديك صلاحية']); wp_die(); } if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ee_channel_settings_nonce')) { wp_send_json_error(['message' => 'فشل التحقق من رمز الأمان']); wp_die(); } $api_key = get_option('ee_scraperapi_key', ''); wp_send_json_success(['api_key' => $api_key]); wp_die(); }); function ee_render_leagues_list() { $leagues = get_option('ee_leagues_list', []); if (empty($leagues)) { return '
لا توجد دوريات مضافة حاليًا.
'; } $output = '