function g4h_send_to_telegram($title, $content, $post_link, $image_url = '', $post_id = 0) { $telegram_token = get_option('g4h_telegram_token'); $channel_username = get_option('g4h_telegram_channel'); if (!$telegram_token || !$channel_username) { return; } // تأكيد صلاحية الرابط $photo_url = (!empty($image_url) && filter_var($image_url, FILTER_VALIDATE_URL)) ? $image_url : 'https://via.placeholder.com/800x600.png?text=G4H+Post'; // تجهيز الرسالة $caption = "📝 " . esc_html($title) . "\n"; $caption .= esc_html(wp_trim_words(strip_tags($content), 30)) . "\n\n"; $caption .= 'اقرأ المزيد'; // طلب الإرسال $response = wp_remote_post("https://api.telegram.org/bot{$telegram_token}/sendPhoto", [ 'body' => [ 'chat_id' => $channel_username, 'photo' => $photo_url, 'caption' => $caption, 'parse_mode' => 'HTML' ] ]); // التحليل واللوج $body = wp_remote_retrieve_body($response); $code = wp_remote_retrieve_response_code($response); $status = ($code === 200) ? 'success' : 'failed'; // لوج فقط لو فيه دالة if (function_exists('g4h_log_distribution')) { g4h_log_distribution( $post_id, $title, $content, 'telegram', $status, $body, '' // ممكن تضيف platform_id من response إذا احتجت ); } } https://ninawaa.com/wp-sitemap-posts-post-1.xmlhttps://ninawaa.com/wp-sitemap-posts-page-1.xmlhttps://ninawaa.com/wp-sitemap-taxonomies-category-1.xmlhttps://ninawaa.com/wp-sitemap-taxonomies-post_tag-1.xmlhttps://ninawaa.com/wp-sitemap-users-1.xml