function tarek_end_content() {

    if (!is_single()) return '';

    $settings = get_option('tarek_options');

    if (!is_array($settings)) return '';

    // التحقق من التفعيل
    if (empty($settings['link_end'])) return '';

    // جلب التصنيفات الحالية
    $categories = wp_get_post_categories(get_the_ID());

    $posts = get_posts([
        'posts_per_page' => 4,
        'post__not_in'   => [get_the_ID()], // استثناء المقال الحالي
        'category__in'   => $categories,
    ]);

    if (empty($posts)) return '';

    $html = '<div class="tarek-end-links">';
    $html .= '<h3>مقالات ذات صلة</h3>';

    foreach ($posts as $post) {

        $title = esc_html($post->post_title);
        $link  = esc_url(get_permalink($post->ID));

        $html .= '<a href="'.$link.'">'.$title.'</a>';
    }

    $html .= '</div>';

    return $html;
}function tarek_auto_linking($content) {

    // جلب الإعدادات الموحدة
    $settings = get_option('tarek_options');

    if (!is_array($settings)) return $content;

    // التحقق من تفعيل الميزة
    if (empty($settings['link_auto'])) return $content;

    // جلب الكلمات
    $keywords = $settings['auto_keywords'] ?? [];

    if (empty($keywords) || !is_array($keywords)) return $content;

    foreach ($keywords as $item) {

        if (empty($item['keyword']) || empty($item['url'])) continue;

        $word  = trim($item['keyword']);
        $url   = esc_url($item['url']);
        $limit = isset($item['limit']) ? (int)$item['limit'] : 1;

        $count = 0;

        // منع التعديل داخل روابط موجودة
        $content = preg_replace_callback(
            '/(?!<a[^>]*?>)(\b'.preg_quote($word, '/').'\b)(?![^<]*?<\/a>)/u',
            function($matches) use ($url, &$count, $limit){

                if ($count >= $limit) return $matches[0];

                $count++;

                return '<a href="'.$url.'">'.$matches[0].'</a>';
            },
            $content
        );
    }

    return $content;
}<?xml version="1.0" encoding="UTF-8"?>
<!--generator='jetpack-15.7'-->
<!--Jetpack_Sitemap_Buffer_News_XMLWriter-->
<?xml-stylesheet type="text/xsl" href="//www.shipping-sa.com/news-sitemap.xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
 <url>
  <loc>https://www.shipping-sa.com/</loc>
 </url>
</urlset>
