define('MYTHEME_OPTIONS_FILE', get_template_directory() . '/inc/theme-options.json'); function mytheme_get_options() { if (file_exists(MYTHEME_OPTIONS_FILE)) { $json = file_get_contents(MYTHEME_OPTIONS_FILE); return json_decode($json, true) ?: []; } return []; } function mytheme_save_options($data) { if (!is_writable(dirname(MYTHEME_OPTIONS_FILE))) { wp_die('لا يمكن الكتابة إلى ملف الإعدادات.'); } $options = mytheme_get_options(); $title_template = $options['match_page_title'] ?? 'مباراة {team1} ضد {team2} بتاريخ {date}'; $default_content_template = 'اذهب الي اعدادات القالب ثم صفحة المباراة وثم بأعدادها'; $content_template = $options['match_page_template'] ?? $default_content_template; if (!empty($data['matches-today'])) { $matches_html = $data['matches-today']; $updated_html = preg_replace_callback( '#(<div class="STING-web-Match"[^>]*>.*?<a\s+href=")([^"]*)(".*?<\/a>.*?<\/div>)#s', function ($matches) use ($title_template, $content_template) { $full_div = $matches[0]; $div_start = $matches[1]; $div_rest = $matches[3]; preg_match_all('#<div class="STING-web-Team-NAME">([^<]+)</div>#', $full_div, $teams_matches); $team1 = $teams_matches[1][0] ?? 'الفريق الأول'; $team2 = $teams_matches[1][1] ?? 'الفريق الثاني'; preg_match_all('#<div class="STING-web-Team-Logo">\s*<img[^>]+data-img="([^"]+)"#', $full_div, $logos_matches); $logo_team1 = $logos_matches[1][0] ?? ''; $logo_team2 = $logos_matches[1][1] ?? ''; preg_match('#data-start="([^"]+)"#', $full_div, $date_start_match); $date_start = $date_start_match[1] ?? ''; $date_obj = $date_start ? new DateTime($date_start) : false; $date_formatted = $date_obj ? $date_obj->format('d-m-Y') : ''; $time_formatted_12 = $date_obj ? $date_obj->format('g:i A') : ''; preg_match('#<div class="STING-web-Match-Info">([^<]+)</div>#', $full_div, $championship_match); $championship = trim($championship_match[1] ?? 'غير معروف'); preg_match('#<div id="STING-web-Result">([^<]*)</div>#', $full_div, $result_match); $match_result_raw = trim($result_match[1] ?? ''); $match_result_display = 'لم تُحدد بعد'; if ($match_result_raw && preg_match('#^(\d+)\s*-\s*(\d+)$#', $match_result_raw, $score_parts)) { $score_team1 = $score_parts[2]; $score_team2 = $score_parts[1]; $match_result_display = "$team1 $score_team1 - $score_team2 $team2"; } preg_match('#<div class="STING-web-Match"[^>]*id="(\d+)"#', $full_div, $id_match); $match_id = $id_match[1] ?? ''; $search = ['{team1}', '{team2}', '{date}', '{time}', '{championship}', '{result}', '{logo_team1}', '{logo_team2}', '{match_id}']; $replace = [$team1, $team2, $date_formatted, $time_formatted_12, $championship, $match_result_display, $logo_team1, $logo_team2, $match_id]; $new_title = str_replace($search, $replace, $title_template); $content = str_replace($search, $replace, $content_template); $slug = sanitize_title($new_title); $existing = get_page_by_path($slug, OBJECT, 'match'); if (!$existing) { $new_page_id = wp_insert_post([ 'post_title' => wp_strip_all_tags($new_title), 'post_name' => $slug, 'post_status' => 'publish', 'post_type' => 'match', 'post_content' => $content, ]); $existing = get_post($new_page_id); } else { wp_update_post([ 'ID' => $existing->ID, 'post_title' => wp_strip_all_tags($new_title), 'post_content' => $content, ]); } $permalink = get_permalink($existing->ID); return $div_start . esc_url($permalink) . $div_rest; }, $matches_html ); $data['matches-today'] = $updated_html; } file_put_contents(MYTHEME_OPTIONS_FILE, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); } add_action('admin_menu', function () { add_menu_page( 'تحكم القالب', 'تحكم القالب', 'manage_options', 'mytheme-options', 'mytheme_options_page', 'dashicons-admin-generic', 50 ); }); function mytheme_options_page() { $options = mytheme_get_options(); $menu_links = $options['menu_links'] ?? []; $social_links = $options['social_links'] ?? [];<style>.yalla-admin-wrap{display:flex;min-height:100vh;font-family:Change,Segoe UI,sans-serif}.yalla-admin-sidebar{width:220px;background:#fff;color:#000;text-align:center;border-left: 1px solid #ddd;}.admin-logo{padding:0 20px 20px;border-bottom:1px solid #ddd;margin-bottom:20px}.admin-logo h2{color:#000;font-size:20px}.admin-logo p{color:#000;margin:0;font-size:12px}.sidebar-menu .tab-link{display:flex;align-items:center;width:100%;padding:8px 15px;margin-bottom:5px;background:0 0;border:none;color:#000;text-align:right;transition:.3s;cursor:pointer}.admin-header h1,.help-link{align-items:center;display:flex}.sidebar-menu .tab-link:hover{background:#1d2327;color:#fff}.sidebar-menu .tab-link.active{background:#2271b1;color:#fff;font-weight:600}.sidebar-menu .tab-link .dashicons{margin-left:10px;font-size:18px}.sidebar-footer{padding:20px;margin-top:auto;border-top:1px solid #ddd}.help-link{color:#2271b1;text-decoration:none;font-size:13px;font-weight:600}.help-link:hover{color:#3699ff}.help-link .dashicons{margin-left:5px}.yalla-admin-content{flex:1;background:#fff}.admin-header{margin-bottom:25px}.admin-header h1{color:#1e1e2d;margin:0 0 20px;font-size:24px}.admin-header h1 .dashicons{margin-left:10px;color:#3699ff}.yalla-settings-form .card{background:#fff;border-radius:6px;padding:25px;margin-bottom:20px;box-shadow:0 0 15px transparent}.section-title{padding:15px;border-bottom:1px solid #eee;display:flex;align-items:center;border-radius:5px;margin-top:0;font-size:17px}.popup-notice,input#submit{font-size:20px}.section-title .dashicons{margin-left:10px;font-size:35px;width:35px;height:35px}.form-group{margin-bottom:20px;display:flex;justify-content:space-between;width:100%;gap:12px;align-items:center}.form-group label{display:flex;font-weight:600;color:#1e1e2d;align-items:center;gap:6px;padding:12px;border-radius:7px;font-size:14px;width:100%;max-width:200px}.form-group input[type=text],.form-group textarea{width:100%;padding:8px 12px;border:1px solid #ddd;border-radius:4px;min-width:200px}#tab-pages .form-group{padding-bottom:10px;border-bottom:1px solid #0000004d}.matches-tab-content{display:none}.form-group .large-text{min-height:150px}#wpbody-content{padding-bottom:0}.header-styles{display:flex;gap:20px;flex-wrap:wrap}.header-style-option{position:relative}.form-footer,.popup-notice{position:fixed;bottom:20px;z-index:9999}.header-style-option input{position:absolute;opacity:0}.header-style-option label{display:block;border:2px solid #ddd;border-radius:6px;padding:10px;cursor:pointer;transition:.3s}.header-style-option input:checked+label{border-color:#3699ff}.header-style-option img{max-width:200px;height:auto;display:block;margin-bottom:5px}.header-style-option span{display:block;text-align:center;font-weight:400;padding-top:6px;border-top:1px dashed #2933564d;font-size:13px}.checkbox-label{display:flex;align-items:center;font-weight:400;cursor:pointer}.checkbox-label input{margin-left:8px}.notice-success{background:#d4edda;border-left:4px solid #28a745;padding:12px;margin-bottom:20px}.notice-success p{margin:0;color:#155724}.link-item{display:flex;gap:10px;margin-bottom:10px;align-items:center}.link-item input{flex:1}.form-footer{left:20px}.link-item .button,.popup-notice p{margin:0}.card{width:100%;display:grid;border:1px solid #c3c4c700;max-width:none}#wpcontent{padding-right:0}.popup-notice{right:20px;background-color:#46b450;color:#fff;padding:15px 25px;border-radius:6px;box-shadow:0 4px 10px rgba(0,0,0,.2);transition:.5s;display:flex;align-items:center}.matches-tabs{margin-bottom:20px;display:flex;gap:10px;flex-wrap:wrap;justify-content:center;align-items: center;}.matches-tabs .tab-btn{padding:8px 16px;border:1px solid #ccd0d4;background:#f8f9fa;color:#333;cursor:pointer;border-radius:6px;transition:.3s;font-weight:500;box-shadow:0 1px 3px rgba(0,0,0,.05)}.matches-tabs .tab-btn:hover{background:#e2e6ea}.matches-tabs .tab-btn.active{background:#0073aa;color:#fff;border-color:#0073aa;box-shadow:0 2px 6px rgba(0,0,0,.1)}.matches-tab-content.active{display:block;animation:.4s fadeIn}.matches-preview .match-item{border:1px solid #e0e0e0;background:#fff;padding:5px 20px;margin-bottom:5px;border-radius:10px;display:flex;justify-content:center;align-items:center;gap:20px;box-shadow:0 4px 12px rgba(0,0,0,.06);position:relative;transition:transform .2s,box-shadow .3s}.match-teams{display:grid;align-items:center;gap:20px;grid-template-columns:.5fr 1fr .5fr 1fr .5fr 1fr .5fr;justify-content:space-around;justify-items:center;width:100%}.match-teams img{width:30px;height:30px;object-fit:contain;background:#fff;border:2px solid #ddd;border-radius:50%;padding:5px;transition:transform .2s}.match-teams img:hover{transform:scale(1.1)}.match-teams strong{font-size:15px;color:#222;min-width:80px;text-align:center}.match-result{padding:6px 12px;background:#28a745;color:#fff;border-radius:6px;font-weight:700;min-width:60px;text-align:center;font-size:15px;box-shadow:0 1px 3px rgba(0,0,0,.2);letter-spacing:3px}.match-tournament{font-size:12px;color:#333;max-width:200px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;box-shadow:0 1px 4px rgba(0,0,0,.05)}textarea.large-text{width:100%;min-height:140px;padding:12px;border-radius:8px;border:1px solid #ccd0d4;background:#fff;margin-bottom:20px;resize:vertical;font-family:monospace;box-shadow:inset 0 1px 3px rgba(0,0,0,.1);transition:border .3s;direction:ltr}textarea.large-text:focus{border-color:#0073aa;outline:0;box-shadow:0 0 5px rgba(0,115,170,.3)}@keyframes fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@media (max-width:991px){.yalla-admin-sidebar{width:180px}.form-group{flex-direction:column;align-items:stretch}.header-style-option img{max-width:150px}.auto-fold #wpcontent{padding-right:0}}@media (max-width:600px){.link-item{flex-direction:column;align-items:stretch;gap:8px}.link-item input{width:100%}.link-item .button{width:100%;text-align:center}}@media (max-width:767px){.yalla-admin-wrap{flex-direction:column}.yalla-admin-sidebar{width:100%;border-right:none;border-bottom:5px solid #2271b1}.match-tournament{position:relative;margin-top:10px}.matches-preview .match-item{flex-direction:column;gap:10px}.match-teams{grid-template-columns:1fr;gap:10px}}@media (max-width:480px){.admin-header h1{font-size:18px}.match-teams strong{font-size:14px}.match-result{font-size:12px}}button#add-menu-link,button#add-page-link,button#add-social-link,button.button.add-footer-link{display:flex;justify-self:center;place-items:center;border:0;background:green;color:#fff;font-size:14px;margin-top:12px;width:150px;text-align:center;justify-content:center;border-radius:50px;height:45px}button.remove-item.button{background:red;border:0;color:#fff;margin-bottom:12px;height:max-content;align-self:center}#tab-backup input[type=file]{display:block;margin:10px auto}#tab-backup button{min-width:180px;margin:10px 5px;padding:8px 16px;font-size:14px;border-radius:6px;cursor:pointer;transition:background .3s,transform .2s}#tab-backup button.button-primary{background-color:#0073aa;color:#fff;border:none}#tab-backup button.button-primary:hover{background-color:#005b8c;transform:scale(1.03)}iframe#mytheme_match_page_template_ifr{min-height:800px!important}.yalla-admin-wrap *{font-family:system-ui!important}.mce-toolbar .mce-ico,i.dashicons{font-family:dashicons!important}.popup-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.7);display:flex;justify-content:center;align-items:center;z-index:9999}.popup-content{background:#fff;width:1000%;max-width:800px;max-height:80vh;overflow-y:auto;border-radius:6px;position:relative;display:grid}.popup-close-btn{position:sticky;top:0;background:#ff4d4d;color:#fff;border:none;border-radius:6px;font-size:20px;cursor:pointer;transition:background .3s;margin-bottom:6px;width:35px;height:40px;z-index:9999;right:5px}.popup-close-btn:hover{background:#e60000}#tab-matches textarea { height: 20px !important; min-height: 100px !important; }</style>
<div class="yalla-admin-wrap">
<div class="yalla-admin-sidebar">
<div class="admin-header">
if (isset($_GET['status']) && $_GET['status'] === 'success') :
<div class="popup-notice">
<p>تم حفظ الإعدادات بنجاح.</p>
</div>
endif;
</div>
<div class="admin-logo">
<img src="https://www.sting-web.com/base64/favicon.ico" alt="تصميم وتطوير ستينج ويب" style=" width: 100px; height: 100px; border-radius: 12px; "><h2>لوحة تحكم القالب</h2><p>Yalla Shoot Pro</p>
</div>
<div class="sidebar-menu">
<button class="tab-link active" data-tab="matches"> <i class="dashicons dashicons-calendar-alt"></i> المباريات </button>
<button class="tab-link" data-tab="general"> <i class="dashicons dashicons-admin-settings"></i> الإعدادات العامة </button>
<button class="tab-link" data-tab="matchpage"> <i class="dashicons dashicons-admin-page"></i> صفحة المباراة </button>
<button class="tab-link" data-tab="menu"> <i class="dashicons dashicons-list-view"></i> القائمة الرئيسية </button>
<button class="tab-link" data-tab="social"> <i class="dashicons dashicons-share-alt2"></i> التواصل الاجتماعي </button>
<button class="tab-link" data-tab="texter"> <i class="dashicons dashicons-controls-forward"></i> منطقة نص الموقع </button>
<button class="tab-link" data-tab="ads"> <i class="dashicons dashicons-megaphone"></i> الإعلانات </button>
<button class="tab-link" data-tab="pages"> <i class="dashicons dashicons-admin-page"></i> الصفحات اسفل الموقع </button>
<button class="tab-link" data-tab="footer"> <i class="dashicons dashicons-editor-ol"></i> الصفحات في الفوتر </button>
<button class="tab-link" data-tab="copyright"> <i class="dashicons dashicons-lock"></i> حقوق الموقع والتصميم </button>
<button class="tab-link" data-tab="extras"> <i class="dashicons dashicons-plus-alt"></i> الربط </button>
<button class="tab-link" data-tab="backup"> <i class="dashicons dashicons-download"></i> النسخ الاحتياطي </button>
</div>
<div class="sidebar-footer">
<a href="https://m.me/stingweb.eg" class="help-link" target="_blank"> <i class="dashicons dashicons-sos"></i> المساعدة والدعم </a>
</div></div>
<div class="yalla-admin-content">
<form method="post" action="echo admin_url('admin-post.php');" class="yalla-settings-form">
<input type="hidden" name="action" value="save_mytheme_options">
wp_nonce_field('mytheme_options_save', 'mytheme_nonce');
<div class="form-footer">
submit_button('حفظ الإعدادات', 'primary large', 'submit', false);
</div>
<div class="tab-content" id="tab-matches"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-calendar-alt"></i> إدارة المباريات</h2><div class="matches-tabs"> <button type="button" class="tab-btn" data-tab="yesterday">مباريات الأمس</button> <button type="button" class="tab-btn active" data-tab="today">مباريات اليوم</button> <button type="button" class="tab-btn" data-tab="tomorrow">مباريات الغد</button> <div style="margin: 15px 0;display: flex;align-items: center;justify-content: center;flex-wrap: wrap;"> <input type="date" id="fetch-date" value="echo date('Y-m-d');" style="padding: 2px 10px; border-radius: 4px; border: 1px solid #ccc;"> <button type="button" id="fetch-matches-btn" class="button button-primary" style="margin-right: 10px;"> سحب المباريات </button> <button type="button" id="transfer-matches-btn" class="button" style="margin:10px 5px;"> نقل المباريات </button> </div> </div> <div id="matches-popup" class="popup-overlay" style="display:none;"> <div class="popup-content"> <input type="text" id="matches-search" placeholder="ابحث باسم الفريق..." style="width: 90%; padding: 6px; margin: 12px auto; border: 1px solid #ddd; border-radius: 4px;"> <div id="popup-matches-list">جاري التحميل...</div> </div> </div><div class="matches-tab-content" id="tab-yesterday"> <textarea id="matches-yesterday-textarea" name="mytheme_options[matches-yesterday]" rows="9" class="large-text">echo esc_textarea($options['matches-yesterday'] ?? '');</textarea> <div class="matches-preview" id="matches-yesterday-preview"></div> </div><div class="matches-tab-content active" id="tab-today"> <textarea id="matches-today-textarea" name="mytheme_options[matches-today]" rows="9" class="large-text">echo esc_textarea($options['matches-today'] ?? '');</textarea> <div class="matches-preview" id="matches-today-preview"></div> </div> <div class="matches-tab-content" id="tab-tomorrow"> <textarea id="matches-tomorrow-textarea" name="mytheme_options[matches-tomorrow]" rows="9" class="large-text">echo esc_textarea($options['matches-tomorrow'] ?? '');</textarea> <div class="matches-preview" id="matches-tomorrow-preview"></div> </div> </div> </div>
<div class="tab-content" id="tab-general"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-admin-settings"></i> الإعدادات العامة</h2> <div class="form-group"> <label>اختر تصميم موقعك</label> <div class="header-styles"> <div class="header-style-option"> <input type="radio" id="style1" name="mytheme_options[header_style]" value="style-1" checked($options['header_style'] ?? 'style-1', 'style-1');> <label for="style1"> <img src="echo get_template_directory_uri();/assets/imgs/Style-1.png" alt="عصري"> <span>عصري</span> </label> </div> <div class="header-style-option"> <input type="radio" id="style2" name="mytheme_options[header_style]" value="style-2" checked($options['header_style'] ?? 'style-1', 'style-2');> <label for="style2"> <img src="echo get_template_directory_uri();/assets/imgs/Style-2.png" alt="كلاسيكي"> <span>كلاسيكي</span> </label> </div> </div> </div> <div class="form-group"> <label>لون الموقع الأساسي</label> <input type="color" name="mytheme_options[site_color]" value="echo esc_attr($options['site_color'] ?? '#931800');"> </div> <div class="form-group"> <label class="checkbox-label"> <input type="checkbox" name="mytheme_options[show_Font_Site]" value="1" checked(1, $options['show_Font_Site'] ?? 0);> تفعيل الخط المخصص </label> </div> <div class="form-group"> <label>عنوان الموقع</label> <input type="text" name="mytheme_options[site_title]" value="echo esc_attr($options['site_title'] ?? '');" class="regular-text"> </div><div class="form-group"> <label>العنوان الفرعي</label> <input type="text" name="mytheme_options[site_subtitle]" value="echo esc_attr($options['site_subtitle'] ?? '');" class="regular-text"> </div><div class="form-group"> <label>رابط صورة للموقع</label> <input type="text" name="mytheme_options[og_image]" value="echo esc_attr($options['og_image'] ?? '');" class="regular-text" placeholder="https://example.com/image.jpg" id="og-image-input"> if (!empty($options['og_image'])) : <div style="margin-top:10px;"> <img id="og-image-preview" src="echo esc_url($options['og_image']);" alt="معاينة الصورة" style="max-width:200px; height:auto; border:1px solid #ddd;"> </div> else : <div style="margin-top:10px;"> <img id="og-image-preview" src="" alt="معاينة الصورة" style="display:none; max-width:200px; height:auto; border:1px solid #ddd;"> </div> endif; </div> <div class="form-group"> <label>العنوان فوق جدول المباريات</label> <input type="text" name="mytheme_options[matches_subtitle_top]" value="echo esc_attr($options['matches_subtitle_top'] ?? '');" class="regular-text"> </div> <div class="form-group"> <label>العنوان اعلي المقالات</label> <input type="text" name="mytheme_options[Site-Seo-Titled]" value="echo esc_textarea($options['Site-Seo-Titled'] ?? '');" class="regular-text"> </div> </div> </div>
<div class="tab-content" id="tab-matchpage"> <div class="settings-section card"> <h2>عنوان صفحة المباراة</h2> <p>يمكنك تخصيص عنوان صفحة المباراة باستخدام المتغيرات التالية:</p> <p> <code>{team1}</code>, <code>{team2}</code>, <code>{date}</code>, <code>{time}</code>, <code>{championship}</code>, </p> $default_title = 'مباراة {team1} ضد {team2} بتاريخ {date}'; $default_content = ' <div class="STING-web-MatchCover"> <div class="STING-web-Background-MatchCover"> <div class="STING-web-MatchCover-Right"> <img class="STING-web-MatchCover-Logo" loading="lazy" src="{logo_team1}" alt="{team1}"> <span>{team1}</span> </div> <div class="STING-web-MatchCover-Center">VS</div> <div class="STING-web-MatchCover-Left"> <img class="STING-web-MatchCover-Logo" loading="lazy" src="{logo_team2}" alt="{team2}"> <span>{team2}</span> </div> </div> </div> <p>ترقبوا المواجهة المرتقبة بين <strong>{team1}</strong> و<strong>{team2}</strong> ضمن منافسات بطولة <strong>{championship}</strong>، وذلك يوم <strong>{date}</strong> في تمام الساعة <strong>{time}</strong> بتوقيت المحلي.</p> <h2>تفاصيل مباراة {team1} و {team2}</h2> <p>مباراة قوية تجمع بين <strong>{team1}</strong> و<strong>{team2}</strong>، حيث يسعى الفريقان لتحقيق الفوز وإسعاد جماهيرهم.</p> <h2>بطاقة مباراة {team2} و {team1} اليوم</h2> <table class="STING-web-MatchInfo-Table"> <tbody> <tr> <th>البطولة</th> <td>{championship}</td> </tr> <tr> <th>تاريخ المباراة</th> <td>{date}</td> </tr> <tr> <th>توقيت المباراة</th> <td>{time}</td> </tr> <tr> <th>النتيجة</th> <td>{result}</td> </tr> </tbody> </table> <h2>تحليل مباراة {team1} اليوم</h2> <p>يُتوقع أن نشهد مباراة حماسية بين الفريقين، حيث يدخل <strong>{team1}</strong> اللقاء بمعنويات مرتفعة، بينما يسعى <strong>{team2}</strong> لإثبات نفسه وتحقيق الفوز.</p> <h2>التشكيلة المتوقعة وأبرز اللاعبين</h2> <p>يعتمد <strong>{team1}</strong> على مجموعة من النجوم المميزين القادرين على صناعة الفارق، في حين يطمح <strong>{team2}</strong> للظهور بشكل قوي بفضل مواهبه الشابة.</p> '; $match_page_title = $options['match_page_title'] ?? $default_title; $match_page_template = $options['match_page_template'] ?? $default_content; <input type="text" name="mytheme_options[match_page_title]" value="echo esc_attr($match_page_title);" style="width: 100%; padding: 8px; font-size: 16px; margin-bottom: 30px;" placeholder="اكتب عنوان صفحة المباراة هنا..." > <h2>محتوى صفحة المباراة</h2> <p>يمكنك تخصيص محتوى صفحة المباراة عبر هذا المحرر، ويمكنك إدراج معلومات ديناميكية باستخدام الأزرار التالية:</p> <p> <button type="button" class="button insert-placeholder" data-placeholder="{team1}">اسم الفريق الأول</button> <button type="button" class="button insert-placeholder" data-placeholder="{team2}">اسم الفريق الثاني</button> <button type="button" class="button insert-placeholder" data-placeholder="{date}">تاريخ المباراة</button> <button type="button" class="button insert-placeholder" data-placeholder="{time}">التوقيت</button> <button type="button" class="button insert-placeholder" data-placeholder="{championship}">البطولة</button> <button type="button" class="button insert-placeholder" data-placeholder="{result}">النتيجة</button> </p> wp_editor($match_page_template, 'mytheme_match_page_template', [ 'textarea_name' => 'mytheme_options[match_page_template]', 'textarea_rows' => 90, 'teeny' => false, 'media_buttons' => false, 'tinymce' => [ 'valid_elements' => '*[*]', 'extended_valid_elements' => '*[*]', 'valid_children' => '+body[style],+div[div|p|a|img|table|tbody|tr|td|th|h1|h2|h3|p|span|strong|em|ul|ol|li|br|hr|iframe|script]', 'verify_html' => false, 'cleanup' => false, 'entity_encoding' => 'raw', ], 'quicktags' => true, ]); <button type="button" id="reset-default-content" class="button" style="margin-top: 15px;">إعادة تعيين المحتوى الافتراضي</button> <script> document.querySelectorAll('.insert-placeholder').forEach(button => { button.addEventListener('click', function() { const placeholder = this.dataset.placeholder; if (typeof tinyMCE !== "undefined" && tinyMCE.activeEditor) { tinyMCE.activeEditor.execCommand('mceInsertContent', false, placeholder); } else { const textarea = document.getElementById('mytheme_match_page_template'); if (textarea) { const start = textarea.selectionStart; const end = textarea.selectionEnd; const text = textarea.value; textarea.value = text.substring(0, start) + placeholder + text.substring(end); textarea.focus(); } } }); }); document.getElementById('reset-default-content').addEventListener('click', function() { const defaultContent = echo json_encode($default_content);; if (typeof tinyMCE !== "undefined" && tinyMCE.activeEditor) { tinyMCE.activeEditor.setContent(defaultContent); } else { const textarea = document.getElementById('mytheme_match_page_template'); if (textarea) { textarea.value = defaultContent; textarea.focus(); } } }); </script> </div> </div>
<div class="tab-content" id="tab-menu"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-list-view"></i> القائمة الرئيسية</h2> <div id="menu-links-wrapper"> foreach ($menu_links as $index => $link) : <div class="link-item"> <input type="text" name="mytheme_options[menu_links][echo $index;][title]" placeholder="اسم الرابط" value="echo esc_attr($link['title'] ?? '');" class="regular-text"> <input type="text" name="mytheme_options[menu_links][echo $index;][url]" placeholder="رابط" value="echo esc_attr($link['url'] ?? '');" class="regular-text"> <button type="button" class="remove-item button">حذف</button> </div> endforeach; <button type="button" id="add-menu-link" class="button">إضافة رابط</button> </div> </div> </div>
<div class="tab-content" id="tab-social"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-share-alt2"></i> التواصل الاجتماعي</h2> <div id="social-links-wrapper"> foreach ($social_links as $index => $link) : <div class="link-item"> <input type="text" name="mytheme_options[social_links][echo $index;][name]" placeholder="اسم المنصة" value="echo esc_attr($link['name'] ?? '');" class="regular-text"> <input type="text" name="mytheme_options[social_links][echo $index;][url]" placeholder="رابط" value="echo esc_attr($link['url'] ?? '');" class="regular-text"> <button type="button" class="remove-item button">حذف</button> </div> endforeach; <button type="button" id="add-social-link" class="button">إضافة رابط تواصل</button> </div> </div> </div>
<div class="tab-content" id="tab-texter"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-controls-forward"></i> منطقة نص الموقع</h2> <div class="form-group"> <label class="checkbox-label"> <input type="checkbox" name="mytheme_options[show_site_description]" value="1" checked(1, $options['show_site_description'] ?? 0);> إظهار وصف الموقع </label> <input type="text" name="mytheme_options[Site-Seo-Title]" value="echo esc_textarea($options['Site-Seo-Title'] ?? '');" class="regular-text"> <textarea name="mytheme_options[Site-Seo]" rows="5" class="large-text">echo esc_textarea($options['Site-Seo'] ?? '');</textarea> </div> </div> </div>
<div class="tab-content" id="tab-ads"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-megaphone"></i> الإعلانات</h2> <div class="form-group"> <label class="checkbox-label"> <input type="checkbox" name="mytheme_options[show_ads_down_header]" value="1" checked(1, $options['show_ads_down_header'] ?? 0);> تفعيل إعلان أسفل الهيدر </label> <textarea name="mytheme_options[ads_down_header]" rows="3" class="large-text">echo esc_textarea($options['ads_down_header'] ?? '');</textarea> </div> <div class="form-group"> <label class="checkbox-label"> <input type="checkbox" name="mytheme_options[show_ads_top_site_links]" value="1" checked(1, $options['show_ads_top_site_links'] ?? 0);> تفعيل إعلان أعلي الفوتر </label> <textarea name="mytheme_options[ads_top_site_links]" rows="3" class="large-text">echo esc_textarea($options['ads_top_site_links'] ?? '');</textarea> </div> </div> </div>
<div class="tab-content" id="tab-pages"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-admin-page"></i> الصفحات اسفل الموقع</h2> <div class="form-group"> <label class="checkbox-label"> <input type="checkbox" name="mytheme_options[show_site_links]" value="1" checked(1, $options['show_site_links'] ?? 0);> إظهار روابط الفوتر </label> </div> for ($i = 1; $i <= 4; $i++) : $title_key = "footer-links-$i"; $links_key = "footer_links_$i"; $links = $options[$links_key] ?? []; <div class="form-group"><input type="text" name="mytheme_options[echo $title_key;]" value="echo esc_attr($options[$title_key] ?? '');" class="regular-text"> <div id="links-wrapper-echo $i;"> foreach ($links as $index => $link) : <div class="link-item"> <input type="text" name="mytheme_options[echo $links_key;][echo $index;][name]" placeholder="اسم" value="echo esc_attr($link['name'] ?? '');" class="regular-text"> <input type="text" name="mytheme_options[echo $links_key;][echo $index;][url]" placeholder="رابط" value="echo esc_attr($link['url'] ?? '');" class="regular-text"> <button type="button" class="remove-item button">حذف</button> </div> endforeach; </div> <button type="button" class="button add-footer-link" data-section="echo $i;">إضافة رابط</button> </div> endfor; </div> </div>
<div class="tab-content" id="tab-footer"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-editor-ol"></i> الصفحات في الفوتر</h2> <div id="page-links-wrapper"> $pages_links = $options['pages_links'] ?? []; foreach ($pages_links as $index => $link) : <div class="link-item"> <input type="text" name="mytheme_options[pages_links][echo $index;][title]" placeholder="اسم الرابط" value="echo esc_attr($link['title'] ?? '');" class="regular-text"> <input type="text" name="mytheme_options[pages_links][echo $index;][url]" placeholder="رابط" value="echo esc_attr($link['url'] ?? '');" class="regular-text"> <button type="button" class="remove-item button">حذف</button> </div> endforeach; </div> <button type="button" id="add-page-link" class="button">إضافة رابط صفحة</button> </div> </div>
<div class="tab-content" id="tab-copyright"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-lock"></i> حقوق الموقع والتصميم</h2> <div class="form-group"> <label>حقوق الموقع</label> <input type="text" name="mytheme_options[Site_Copyright]" value="echo esc_attr($options['Site_Copyright'] ?? '');" class="regular-text"> </div> <div class="form-group"> <label>حقوق القالب</label> <input type="text" name="mytheme_options[Temp_Copyright]" value="echo esc_attr($options['Temp_Copyright'] ?? '');" class="regular-text"> </div> </div> </div>
<div class="tab-content" id="tab-extras"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-plus-alt"></i> الربط</h2> <div class="form-group"> <label class="checkbox-label"> <input type="checkbox" name="mytheme_options[show_Google_Search_Console]" value="1" checked(1, $options['show_Google_Search_Console'] ?? 0);> ربط Search Console </label> <input type="text" name="mytheme_options[Google_Search_Console]" value="echo esc_textarea($options['Google_Search_Console'] ?? '');" class="regular-text"> </div> <div class="form-group"> <label class="checkbox-label"> <input type="checkbox" name="mytheme_options[show_Google_Adsense]" value="1" checked(1, $options['show_Google_Adsense'] ?? 0);> ربط Google Adsense </label> <input type="text" name="mytheme_options[Google_Adsense]" value="echo esc_textarea($options['Google_Adsense'] ?? '');" class="regular-text"> </div> <div class="form-group"> <label class="checkbox-label"> <input type="checkbox" name="mytheme_options[show_Google_Analytics]" value="1" checked(1, $options['show_Google_Analytics'] ?? 0);> ربط Google Analytics </label> <input type="text" name="mytheme_options[Google_Analytics]" value="echo esc_textarea($options['Google_Analytics'] ?? '');" class="regular-text"> </div> </div> </div>
<div class="tab-content" id="tab-backup"> <div class="settings-section card"> <h2 class="section-title"><i class="dashicons dashicons-download"></i> النسخ الاحتياطي </h2> <p>قم بإنشاء نسخة احتياطية من إعدادات موقعك :</p> <button id="export-settings" type="button" class="button button-primary">تحميل نسخة احتياطية</button> <hr> <p>استيراد إعدادات موقعك من ملف نسخ احتياطي سابق :</p> <input type="file" id="import-file" accept=".json"> <br><br> <button id="import-settings" type="button" class="button button-primary">استيراد</button> </div> </div>
</form>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const tabManager = {
init() {
this.tabs = document.querySelectorAll('.tab-link');
this.contents = document.querySelectorAll('.tab-content');
this.hideAllContents();
this.activateInitialTab();
this.setupEventListeners();
},
hideAllContents() {
this.contents.forEach(content => {
content.style.display = 'none';
});
},
activateInitialTab() {
const activeTab = document.querySelector('.tab-link.active');
if (activeTab) {
this.showContent(activeTab.dataset.tab);
} else if (this.tabs.length > 0) {
this.tabs[0].classList.add('active');
this.showContent(this.tabs[0].dataset.tab);
}
},
setupEventListeners() {
this.tabs.forEach(tab => {
tab.addEventListener('click', (e) => {
e.preventDefault();
this.activateTab(tab.dataset.tab);
});
});
},
activateTab(tabId) {
this.tabs.forEach(tab => {
tab.classList.remove('active');
});
this.hideAllContents();
const targetTab = Array.from(this.tabs).find(tab => tab.dataset.tab === tabId);
if (targetTab) {
targetTab.classList.add('active');
this.showContent(tabId);
}
},
showContent(tabId) {
const targetContent = document.getElementById(`tab-${tabId}`);
if (targetContent) {
targetContent.style.display = 'block';
targetContent.style.opacity = '0';
setTimeout(() => {
targetContent.style.transition = 'opacity 0.3s ease';
targetContent.style.opacity = '1';
}, 10);
}
}
};
tabManager.init();
});
document.addEventListener('DOMContentLoaded', () => {
let menuIndex = echo isset($menu_links) ? count($menu_links) : 0;;
let socialIndex = echo isset($social_links) ? count($social_links) : 0;;
let pageLinkIndex = echo isset($options['pages_links']) ? count($options['pages_links']) : 0;;
const footerIndexes = {
1: echo isset($options['footer_links_1']) ? count($options['footer_links_1']) : 0;,
2: echo isset($options['footer_links_2']) ? count($options['footer_links_2']) : 0;,
3: echo isset($options['footer_links_3']) ? count($options['footer_links_3']) : 0;,
4: echo isset($options['footer_links_4']) ? count($options['footer_links_4']) : 0;
};
function createInputGroup(type, index = null) {
const container = document.createElement('div');
container.classList.add(type + '-item');
if (type === 'menu-link') {
container.innerHTML = `
<input type="text" name="mytheme_options[menu_links][${menuIndex}][title]" placeholder="اسم الرابط">
<input type="text" name="mytheme_options[menu_links][${menuIndex}][url]" placeholder="رابط">
<button type="button" class="remove-item button">حذف</button>
`;
menuIndex++;
} else if (type === 'social-link') {
container.innerHTML = `
<input type="text" name="mytheme_options[social_links][${socialIndex}][name]" placeholder="اسم المنصة">
<input type="text" name="mytheme_options[social_links][${socialIndex}][url]" placeholder="رابط">
<button type="button" class="remove-item button">حذف</button>
`;
socialIndex++;
} else if (type.startsWith('footer-link-')) {
const section = type.split('-')[2];
container.classList.add('top-footer-link-item');
container.innerHTML = `
<input type="text" name="mytheme_options[footer_links_${section}][${footerIndexes[section]}][name]" placeholder="اسم المنصة">
<input type="text" name="mytheme_options[footer_links_${section}][${footerIndexes[section]}][url]" placeholder="رابط">
<button type="button" class="remove-item button">حذف</button>
`;
footerIndexes[section]++;
}
container.querySelector('.remove-item').addEventListener('click', () => container.remove());
return container;
}
const addMenuBtn = document.getElementById('add-menu-link');
if (addMenuBtn) {
addMenuBtn.addEventListener('click', () => {
document.getElementById('menu-links-wrapper').appendChild(createInputGroup('menu-link'));
});
}
const addPageLinkBtn = document.getElementById('add-page-link');
if (addPageLinkBtn) {
addPageLinkBtn.addEventListener('click', () => {
const container = document.createElement('div');
container.classList.add('page-link-item');
container.innerHTML = `
<input type="text" name="mytheme_options[pages_links][${pageLinkIndex}][title]" placeholder="اسم الرابط">
<input type="text" name="mytheme_options[pages_links][${pageLinkIndex}][url]" placeholder="رابط">
<button type="button" class="remove-item button">حذف</button>
`;
pageLinkIndex++;
container.querySelector('.remove-item').addEventListener('click', () => container.remove());
document.getElementById('page-links-wrapper').appendChild(container);
});
}
const addSocialBtn = document.getElementById('add-social-link');
if (addSocialBtn) {
addSocialBtn.addEventListener('click', () => {
document.getElementById('social-links-wrapper').appendChild(createInputGroup('social-link'));
});
}
document.querySelectorAll('.add-footer-link').forEach(button => {
button.addEventListener('click', () => {
const section = button.getAttribute('data-section');
const wrapper = document.getElementById(`links-wrapper-${section}`);
wrapper.appendChild(createInputGroup(`footer-link-${section}`));
});
});
document.querySelectorAll('.remove-item').forEach(btn => {
btn.addEventListener('click', () => btn.parentElement.remove());
});
});
setTimeout(function() {
const popup = document.querySelector('.popup-notice');
if (popup) {
popup.style.opacity = '0';
popup.style.transform = 'translateX(100%)';
setTimeout(() => {
popup.remove();
const url = new URL(window.location.href);
url.searchParams.delete('status');
window.history.replaceState({}, document.title, url.pathname + url.search);
}, 300);
}
}, 1000);
document.addEventListener('DOMContentLoaded', function () {
setupMatches('yesterday');
setupMatches('today');
setupMatches('tomorrow');
document.querySelectorAll('.tab-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.matches-tab-content').forEach(c => c.classList.remove('active'));
btn.classList.add('active');
document.getElementById('tab-' + btn.dataset.tab).classList.add('active');
});
});
function setupMatches(day) {
const textarea = document.getElementById(`matches-${day}-textarea`);
textarea.addEventListener('input', () => renderMatchesBlock(`matches-${day}-textarea`));
renderMatchesBlock(`matches-${day}-textarea`);
}
function renderMatchesBlock(textareaId) {
const textarea = document.getElementById(textareaId);
const preview = document.getElementById(textareaId.replace('-textarea', '-preview'));
const form = textarea.closest('form');
preview.innerHTML = '';
const tempDiv = document.createElement('div');
tempDiv.innerHTML = textarea.value;
tempDiv.querySelectorAll('.STING-web-Match').forEach(match => {
const team1 = match.querySelector('.STING-web-Right-Team .STING-web-Team-NAME')?.innerText || '';
const logo1 = match.querySelector('.STING-web-Right-Team img')?.getAttribute('data-img') || '';
const team2 = match.querySelector('.STING-web-Left-Team .STING-web-Team-NAME')?.innerText || '';
const logo2 = match.querySelector('.STING-web-Left-Team img')?.getAttribute('data-img') || '';
const result = match.querySelector('#STING-web-Result')?.innerText || '';
const tournament = match.querySelector('.STING-web-Match-Info')?.innerText || '';
const wrapper = document.createElement('div');
wrapper.classList.add('match-item');
wrapper.style.position = 'relative';
wrapper.innerHTML =
`<div class="match-teams">
<img src="${logo1}" alt="${team1}">
<strong>${team1}</strong>
<div class="match-result">${result}</div>
<strong>${team2}</strong>
<img src="${logo2}" alt="${team2}">
<div class="match-tournament">
<input type="text" class="tournament-input" value="${tournament}">
</div>
<button type="button" class="delete-match" style="background:#ff4d4d; color:#fff; border:none; padding:8px 12px; border-radius:4px; cursor:pointer;">حذف</button>
</div>`;
preview.appendChild(wrapper);
const input = wrapper.querySelector('.tournament-input');
input.addEventListener('input', () => {
match.querySelector('.STING-web-Match-Info').innerText = input.value;
textarea.value = tempDiv.innerHTML;
});
const deleteBtn = wrapper.querySelector('.delete-match');
deleteBtn.addEventListener('click', () => {
match.remove();
wrapper.remove();
textarea.value = tempDiv.innerHTML;
});
});
}
document.getElementById('fetch-matches-btn').addEventListener('click', () => {
const popup = document.getElementById('matches-popup');
const list = document.getElementById('popup-matches-list');
const date = document.getElementById('fetch-date').value || new Date().toISOString().split('T')[0];
list.innerHTML = 'جاري التحميل...';
popup.style.display = 'flex';
fetch(`https://apis.sting-web.com/tools/Yalla-Shoot-Pro/npm/?date=${date}&lang=27`)
.then(res => res.json())
.then(data => {
if (!data.Matches || !data.Matches.length) {
list.innerHTML = 'لا توجد مباريات متاحة.';
return;
}
list.innerHTML = '';
data.Matches.forEach(match => {
const item = document.createElement('div');
item.className = 'matches-preview';
item.setAttribute('data-search', `${match['Team-Right'].Name} ${match['Team-Left'].Name}`.toLowerCase());
const result = `${match['Team-Right'].Goal} - ${match['Team-Left'].Goal}`;
const timeStart = new Date(match['Time-Start']).toLocaleTimeString();
item.innerHTML = `
<div class="match-item">
<div class="match-teams">
<img src="${match['Team-Right'].Logo}" alt="${match['Team-Right'].Name}">
<strong>${match['Team-Right'].Name}</strong>
<div class="vs-text">VS</div>
<strong>${match['Team-Left'].Name}</strong>
<img src="${match['Team-Left'].Logo}" alt="${match['Team-Left'].Name}">
<strong>${timeStart}</strong>
</div>
</div>
<div class="match-info" style="display: flex; justify-content: space-around; align-items: center; margin-bottom: 10px;">
<strong>البطولة:</strong> ${match['Cup-Name']}
<div class="add-buttons">
<button type="button" class="button add-to" data-target="yesterday" data-info='${JSON.stringify(match)}'>سحب للأمس</button>
<button type="button" class="button add-to" data-target="today" data-info='${JSON.stringify(match)}'>سحب لليوم</button>
<button type="button" class="button add-to" data-target="tomorrow" data-info='${JSON.stringify(match)}'>سحب للغد</button>
</div>
</div>`;
list.appendChild(item);
});
})
.catch(() => {
list.innerHTML = `<div class="error-message subscription-error"> <h3>إنتهت صلاحيه الـ إشتراك الخاص بك</h3> <p>يرجى إعادة تجديد الاشتراك لمتابعة استخدام الخدمة.</p> </div><style>.matches-preview { margin-bottom: 20px; } .match-card { background: #fff; border-radius: 12px; box-shadow: 0 0 15px rgba(0,0,0,0.1); padding: 15px; text-align: center; transition: transform 0.3s; } .match-card:hover { transform: translateY(-5px); } .teams { display: flex; justify-content: space-around; align-items: center; margin-bottom: 10px; } .team img { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; } .team span { display: block; margin-top: 5px; font-weight: bold; } .vs-text { font-size: 18px; font-weight: bold; color: #d33; } .match-details { margin: 10px 0; font-size: 14px; } .add-buttons { display: flex; justify-content: center; gap: 10px; } .add-buttons .button { background: #28a745; color: #fff; border: none; padding: 8px 15px; border-radius: 6px; cursor: pointer; transition: background 0.3s; } .add-buttons .button:hover { background: #218838; } .error-message, .empty-message { background: #ffe5e5; color: #b30000; padding: 15px; border-radius: 10px; text-align: center; margin: 20px; box-shadow: 0 0 10px rgba(255,0,0,0.1); } .subscription-error { background: #fff3cd; color: #856404; } .loader { border: 4px solid #f3f3f3; border-top: 4px solid #d33; border-radius: 50%; width: 40px; height: 40px; margin: 0 auto 10px; animation: spin 1s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }</style>`;
});
});
document.getElementById('popup-matches-list').addEventListener('click', function(e) {
if (e.target.classList.contains('add-to')) {
e.preventDefault();
const target = e.target.getAttribute('data-target');
const match = JSON.parse(e.target.getAttribute('data-info'));
const dateStart = match['Time-Start'].split('T')[0];
const matchHTML = `
<div class="STING-web-Match" id="${match['Match-id']}"><a href="#" title="${match['Team-Right'].Name} vs ${match['Team-Left'].Name}"><div class="STING-web-Right-Team"><div class="STING-web-Team-Logo"><img alt="${match['Team-Right'].Name}" data-img="/wp-content/themes/Yalla-Shoot-Pro/assets/imgs/team-logo/?id=${match['Team-Right'].Logo.split('=')[1]}" loading="lazy" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" title="${match['Team-Right'].Name}" width="70" height="70"></div><div class="STING-web-Team-NAME">${match['Team-Right'].Name}</div></div><div class="STING-web-Match-Center"><div class="STING-web-Match-Timing"><div id="STING-web-Match-Time">${match['Match-Status']}</div><div id="STING-web-Result">${match['Team-Left'].Goal}-${match['Team-Right'].Goal}</div><div class="STING-web-Data" data-start="${match['Time-Start']}:00+03:00" data-gameends="${match['Time-End']}:00+03:00"></div><div class="STING-web-Match-Info">${match['Cup-Name']}</div></div></div><div class="STING-web-Left-Team"><div class="STING-web-Team-Logo"><img alt="${match['Team-Left'].Name}" data-img="/wp-content/themes/Yalla-Shoot-Pro/assets/imgs/team-logo/?id=${match['Team-Left'].Logo.split('=')[1]}" loading="lazy" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" title="${match['Team-Left'].Name}" width="70" height="70"></div><div class="STING-web-Team-NAME">${match['Team-Left'].Name}</div></div><div class="STING-web-Overlay"><div class="STING-web-SVG-Play"></div></div></a></div>`;
const textarea = document.getElementById(`matches-${target}-textarea`);
textarea.value += `\n${matchHTML}`;
renderMatchesBlock(`matches-${target}-textarea`);
}
});
const popup = document.getElementById('matches-popup');
const popupContent = document.querySelector('#matches-popup .popup-content');
popup.addEventListener('click', (e) => {
if (!popupContent.contains(e.target)) {
popup.style.display = 'none';
}
});
document.getElementById('matches-search').addEventListener('keyup', function () {
const keyword = this.value.toLowerCase().trim();
document.querySelectorAll('#popup-matches-list .matches-preview').forEach(item => {
const text = item.getAttribute('data-search');
item.style.display = text.includes(keyword) ? 'block' : 'none';
});
});
document.getElementById('transfer-matches-btn').addEventListener('click', () => {
if (!confirm('هل أنت متأكد أنك تريد نقل المباريات؟ سيتم حذف القديم أولاً.')) return;
const textareaYesterday = document.getElementById('matches-yesterday-textarea');
const textareaToday = document.getElementById('matches-today-textarea');
const textareaTomorrow = document.getElementById('matches-tomorrow-textarea');
textareaYesterday.value = textareaToday.value;
textareaToday.value = textareaTomorrow.value;
textareaTomorrow.value = '';
renderMatchesBlock('matches-yesterday-textarea');
renderMatchesBlock('matches-today-textarea');
renderMatchesBlock('matches-tomorrow-textarea');
});
});
document.getElementById('export-settings').addEventListener('click', function () {
window.location.href = 'echo admin_url('admin-ajax.php?action=export_theme_options');';
});
document.getElementById('import-settings').addEventListener('click', function () {
const fileInput = document.getElementById('import-file');
if (!fileInput.files.length) {
alert('يرجى اختيار ملف نسخة احتياطية سابق أولاً');
return;
}
const formData = new FormData();
formData.append('action', 'import_theme_options');
formData.append('import_file', fileInput.files[0]);
fetch('echo admin_url('admin-ajax.php');', {
method: 'POST',
body: formData
})
.then(res => res.text())
.then(response => {
alert(response);
location.reload();
})
.catch(() => alert('حدث خطأ أثناء الاستيراد'));
});
</script>
} add_action('admin_post_save_mytheme_options', function () { if ( !current_user_can('manage_options') || !isset($_POST['mytheme_nonce']) || !wp_verify_nonce($_POST['mytheme_nonce'], 'mytheme_options_save') ) { wp_die('غير مصرح به'); } $options = $_POST['mytheme_options'] ?? []; $allowed_html_fields = ['ads_down_header', 'matches-yesterday', 'matches-today', 'matches-tomorrow', 'ads_top_site_links','match_page_template', 'Google_Search_Console', 'Google_Analytics','Google_Adsense']; foreach ($options as $key => &$value) { if (in_array($key, $allowed_html_fields, true)) { $value = wp_kses_post($value); continue; } if (is_array($value)) { array_walk_recursive($value, function (&$v) { $v = sanitize_text_field($v); }); } else { $value = sanitize_text_field($value); } } mytheme_save_options($options); wp_redirect(admin_url('admin.php?page=mytheme-options&status=success')); exit; });
© 2023 Quttera Ltd. All rights reserved.