se, 'message' => $this->get_last_error() !== '' ? $this->get_last_error() : 'تعذر جلب سعر الدولار', ); } $target_currencies = $this->get_story_cards_currencies(); $cards_data = $this->fetch_story_cards_data($target_currencies, (float) $price_data_usd['ounce_price']); if (empty($cards_data)) { return array( 'success' => false, 'message' => $this->get_last_error() !== '' ? $this->get_last_error() : 'تعذر جلب أسعار العملات العربية', ); } $caption = $this->build_story_cards_whatsapp_caption($price_data_usd, $cards_data); $image_url = add_query_arg( array('currency' => $base_currency), trailingslashit(home_url('/gptb-image/story-cards/')) ); $title = apply_filters( 'gptb_story_cards_share_title', 'سعر الذهب اليوم — الدولار والعملات العربية' ); return array( 'success' => true, 'title' => (string) $title, 'image' => $image_url, 'currency' => $base_currency, 'caption' => $caption, ); } /** * جلب أسعار الصرف مقابل الدولار (لاستخدامها كخطة بديلة) */ private function fetch_usd_exchange_rates() { $url = 'https://open.er-api.com/v6/latest/USD'; $json = @file_get_contents($url); if ($json === false) { return null; } $data = json_decode($json, true); if (!is_array($data) || !isset($data['rates']) || !is_array($data['rates'])) { return null; } return $data['rates']; } /** * رسم علم العملة داخل البطاقة */ private function draw_currency_flag($image, $currency, $x, $y, $width, $height) { if (!isset($this->currencies[$currency])) { return; } $flag_code = $this->currencies[$currency]['flag']; $flag_path = $this->flags_path . $flag_code . '.png'; if (!file_exists($flag_path)) { return; } $flag_image = @imagecreatefrompng($flag_path); if (!$flag_image) { return; } $flag_resized = imagecreatetruecolor($width, $height); imagealphablending($flag_resized, false); imagesavealpha($flag_resized, true); $transparent = imagecolorallocatealpha($flag_resized, 0, 0, 0, 127); imagefilledrectangle($flag_resized, 0, 0, $width, $height, $transparent); imagealphablending($flag_resized, true); imagecopyresampled( $flag_resized, $flag_image, 0, 0, 0, 0, $width, $height, imagesx($flag_image), imagesy($flag_image) ); imagecopy($image, $flag_resized, $x, $y, 0, 0, $width, $height); imagedestroy($flag_image); imagedestroy($flag_resized); } /** * رسم إطار بزوايا مدورة بشكل موحد لكل البطاقات */ private function draw_rounded_border($image, $x, $y, $width, $height, $radius, $color, $thickness = 1) { $thickness = max(1, (int) $thickness); for ($i = 0; $i < $thickness; $i++) { $this->draw_rounded_rectangle_outline($image, $x + $i, $y + $i, $width - ($i * 2), $height - ($i * 2), max(1, $radius - $i), $color); } } /** * رسم Outline لمستطيل بزوايا مدورة */ private function draw_rounded_rectangle_outline($image, $x, $y, $width, $height, $radius, $color) { if ($width <= 2 || $height <= 2) { return; } $radius = min($radius, floor($width / 2), floor($height / 2)); $diameter = $radius * 2; imageline($image, $x + $radius, $y, $x + $width - $radius, $y, $color); imageline($image, $x + $radius, $y + $height, $x + $width - $radius, $y + $height, $color); imageline($image, $x, $y + $radius, $x, $y + $height - $radius, $color); imageline($image, $x + $width, $y + $radius, $x + $width, $y + $height - $radius, $color); imagearc($image, $x + $radius, $y + $radius, $diameter, $diameter, 180, 270, $color); imagearc($image, $x + $width - $radius, $y + $radius, $diameter, $diameter, 270, 360, $color); imagearc($image, $x + $radius, $y + $height - $radius, $diameter, $diameter, 90, 180, $color); imagearc($image, $x + $width - $radius, $y + $height - $radius, $diameter, $diameter, 0, 90, $color); } /** * معالجة قالب الرسالة مع استبدال الشورتكودات */ public function process_caption_template($template, $currency = 'EGP') { if (!isset($this->currencies[$currency])) { $currency = 'EGP'; } $currency_info = $this->currencies[$currency]; // جلب بيانات الأسعار $price_data = $this->fetch_price_data($currency); if (!$price_data) { return ''; } // جلب البيانات الزمنية $timezone_data = $this->get_timezone_data($currency); // جلب أسماء العملات $currency_names = $this->get_currency_names(); $currency_name = isset($currency_names[$currency]) ? $currency_names[$currency]['name'] : $currency; $currency_symbol = isset($currency_names[$currency]) ? $currency_names[$currency]['symbol'] : ''; // استبدال الشورتكودات $replacements = array( '{day_name}' => $timezone_data['day_name'], '{date}' => $timezone_data['day'] . ' ' . $timezone_data['month'] . ' ' . $timezone_data['year'], '{day}' => $timezone_data['day'], '{month}' => $timezone_data['month'], '{year}' => $timezone_data['year'], '{time}' => $timezone_data['time'], '{capital}' => $timezone_data['capital'], '{country_name}' => isset($currency_info['name']) ? $currency_info['name'] : '', '{currency_name}' => $currency_name, '{currency_symbol}' => $currency_symbol, '{currency_code}' => $currency, '{ounce_price}' => number_format($price_data['ounce_price'], 2, '.', ','), '{ounce_usd}' => number_format($price_data['ounce_usd'], 2, '.', ','), '{price_24k}' => number_format(round($price_data['price_24k']), 0, '', ','), '{price_21k}' => number_format(round($price_data['price_21k']), 0, '', ','), '{price_18k}' => number_format(round($price_data['price_18k']), 0, '', ','), '{gold_pound}' => number_format(round($price_data['gold_pound']), 0, '', ','), '{price_change}' => ($price_data['price_change'] >= 0 ? '+' : '') . number_format($price_data['price_change'], 2, '.', ','), '{price_change_percent}' => ($price_data['price_change_percent'] >= 0 ? '+' : '') . number_format($price_data['price_change_percent'], 2) . '%', '{newline}' => "\n", ); $caption = str_replace(array_keys($replacements), array_values($replacements), $template); return $caption; } /** * الحصول على البيانات الزمنية */ private function get_timezone_data($currency) { $timezones = array( // الدول العربية 'EGP' => 'Africa/Cairo', 'SAR' => 'Asia/Riyadh', 'AED' => 'Asia/Dubai', 'KWD' => 'Asia/Kuwait', 'BHD' => 'Asia/Bahrain', 'QAR' => 'Asia/Qatar', 'OMR' => 'Asia/Muscat', 'IQD' => 'Asia/Baghdad', 'JOD' => 'Asia/Amman', 'LBP' => 'Asia/Beirut', 'TND' => 'Africa/Tunis', 'DZD' => 'Africa/Algiers', 'MAD' => 'Africa/Casablanca', 'SDG' => 'Africa/Khartoum', 'SYP' => 'Asia/Damascus', 'ILS' => 'Asia/Jerusalem', 'TRY' => 'Europe/Istanbul', // أوروبا 'GBP' => 'Europe/London', 'EUR' => 'Europe/Brussels', 'CHF' => 'Europe/Zurich', 'NOK' => 'Europe/Oslo', 'SEK' => 'Europe/Stockholm', 'DKK' => 'Europe/Copenhagen', 'PLN' => 'Europe/Warsaw', 'CZK' => 'Europe/Prague', 'HUF' => 'Europe/Budapest', 'RON' => 'Europe/Bucharest', 'BGN' => 'Europe/Sofia', 'HRK' => 'Europe/Zagreb', 'RUB' => 'Europe/Moscow', 'UAH' => 'Europe/Kiev', 'ISK' => 'Atlantic/Reykjavik', // آسيا 'CNY' => 'Asia/Shanghai', 'JPY' => 'Asia/Tokyo', 'KRW' => 'Asia/Seoul', 'INR' => 'Asia/Kolkata', 'PKR' => 'Asia/Karachi', 'BDT' => 'Asia/Dhaka', 'IDR' => 'Asia/Jakarta', 'MYR' => 'Asia/Kuala_Lumpur', 'SGD' => 'Asia/Singapore', 'THB' => 'Asia/Bangkok', 'VND' => 'Asia/Ho_Chi_Minh', 'PHP' => 'Asia/Manila', 'HKD' => 'Asia/Hong_Kong', 'TWD' => 'Asia/Taipei', 'IRR' => 'Asia/Tehran', 'AFN' => 'Asia/Kabul', 'KZT' => 'Asia/Almaty', 'UZS' => 'Asia/Tashkent', // أمريكا الشمالية 'USD' => 'America/New_York', 'CAD' => 'America/Toronto', 'MXN' => 'America/Mexico_City', // أمريكا الجنوبية 'BRL' => 'America/Sao_Paulo', 'ARS' => 'America/Buenos_Aires', 'CLP' => 'America/Santiago', 'COP' => 'America/Bogota', 'PEN' => 'America/Lima', 'VES' => 'America/Caracas', ); $capitals = array( // الدول العربية 'EGP' => 'القاهرة', 'SAR' => 'الرياض', 'AED' => 'دبي', 'KWD' => 'الكويت', 'BHD' => 'المنامة', 'QAR' => 'الدوحة', 'OMR' => 'مسقط', 'IQD' => 'بغداد', 'JOD' => 'عمّان', 'LBP' => 'بيروت', 'TND' => 'تونس', 'DZD' => 'الجزائر', 'MAD' => 'الرباط', 'SDG' => 'الخرطوم', 'SYP' => 'دمشق', 'ILS' => 'القدس', 'TRY' => 'إسطنبول', // أوروبا 'GBP' => 'لندن', 'EUR' => 'بروكسل', 'CHF' => 'زيورخ', 'NOK' => 'أوسلو', 'SEK' => 'ستوكهولم', 'DKK' => 'كوبنهاغن', 'PLN' => 'وارسو', 'CZK' => 'براغ', 'HUF' => 'بودابست', 'RON' => 'بوخارست', 'BGN' => 'صوفيا', 'HRK' => 'زغرب', 'RUB' => 'موسكو', 'UAH' => 'كييف', 'ISK' => 'ريكيافيك', // آسيا 'CNY' => 'بكين', 'JPY' => 'طوكيو', 'KRW' => 'سيول', 'INR' => 'نيودلهي', 'PKR' => 'إسلام آباد', 'BDT' => 'داكا', 'IDR' => 'جاكرتا', 'MYR' => 'كوالالمبور', 'SGD' => 'سنغافورة', 'THB' => 'بانكوك', 'VND' => 'هانوي', 'PHP' => 'مانيلا', 'HKD' => 'هونغ كونغ', 'TWD' => 'تايبي', 'IRR' => 'طهران', 'AFN' => 'كابل', 'KZT' => 'ألماتي', 'UZS' => 'طشقند', // أمريكا الشمالية 'USD' => 'واشنطن', 'CAD' => 'أوتاوا', 'MXN' => 'مكسيكو سيتي', // أمريكا الجنوبية 'BRL' => 'برازيليا', 'ARS' => 'بوينس آيرس', 'CLP' => 'سانتياغو', 'COP' => 'بوغوتا', 'PEN' => 'ليما', 'VES' => 'كاراكاس', ); $timezone = isset($timezones[$currency]) ? $timezones[$currency] : 'UTC'; $capital_name = isset($capitals[$currency]) ? $capitals[$currency] : 'محلي'; $original_timezone = date_default_timezone_get(); date_default_timezone_set($timezone); $days_ar = array('الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'); $day_name = $days_ar[date('w')]; $months_ar = array('', 'يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'); $month_name = $months_ar[(int)date('n')]; $local_time = date('H:i'); $local_date = date('d'); $local_year = date('Y'); date_default_timezone_set($original_timezone); return array( 'day_name' => $day_name, 'day' => $local_date, 'month' => $month_name, 'year' => $local_year, 'time' => $local_time, 'capital' => $capital_name ); } /** * الحصول على أسماء العملات */ private function get_currency_names() { return array( // الدول العربية 'EGP' => array('name' => 'الجنيه المصري', 'symbol' => 'ج.م'), 'SAR' => array('name' => 'الريال السعودي', 'symbol' => 'ر.س'), 'AED' => array('name' => 'الدرهم الإماراتي', 'symbol' => 'د.إ'), 'KWD' => array('name' => 'الدينار الكويتي', 'symbol' => 'د.ك'), 'BHD' => array('name' => 'الدينار البحريني', 'symbol' => 'د.ب'), 'QAR' => array('name' => 'الريال القطري', 'symbol' => 'ر.ق'), 'OMR' => array('name' => 'الريال العماني', 'symbol' => 'ر.ع'), 'IQD' => array('name' => 'الدينار العراقي', 'symbol' => 'د.ع'), 'JOD' => array('name' => 'الدينار الأردني', 'symbol' => 'د.أ'), 'LBP' => array('name' => 'الليرة اللبنانية', 'symbol' => 'ل.ل'), 'TND' => array('name' => 'الدينار التونسي', 'symbol' => 'د.ت'), 'DZD' => array('name' => 'الدينار الجزائري', 'symbol' => 'د.ج'), 'MAD' => array('name' => 'الدرهم المغربي', 'symbol' => 'د.م'), 'SDG' => array('name' => 'الجنيه السوداني', 'symbol' => 'ج.س'), 'SYP' => array('name' => 'الليرة السورية', 'symbol' => 'ل.س'), 'ILS' => array('name' => 'الشيكل الإسرائيلي', 'symbol' => '₪'), 'TRY' => array('name' => 'الليرة التركية', 'symbol' => '₺'), // أوروبا 'GBP' => array('name' => 'الجنيه الإسترليني', 'symbol' => '£'), 'EUR' => array('name' => 'اليورو', 'symbol' => '€'), 'CHF' => array('name' => 'الفرنك السويسري', 'symbol' => 'CHF'), 'NOK' => array('name' => 'الكرونة النرويجية', 'symbol' => 'kr'), 'SEK' => array('name' => 'الكرونة السويدية', 'symbol' => 'kr'), 'DKK' => array('name' => 'الكرونة الدنماركية', 'symbol' => 'kr'), 'PLN' => array('name' => 'الزلوتي البولندي', 'symbol' => 'zł'), 'CZK' => array('name' => 'الكرونة التشيكية', 'symbol' => 'Kč'), 'HUF' => array('name' => 'الفورنت المجري', 'symbol' => 'Ft'), 'RON' => array('name' => 'الليو الروماني', 'symbol' => 'lei'), 'BGN' => array('name' => 'الليف البلغاري', 'symbol' => 'лв'), 'HRK' => array('name' => 'الكونا الكرواتية', 'symbol' => 'kn'), 'RUB' => array('name' => 'الروبل الروسي', 'symbol' => '₽'), 'UAH' => array('name' => 'الهريفنيا الأوكرانية', 'symbol' => '₴'), 'ISK' => array('name' => 'الكرونة الآيسلندية', 'symbol' => 'kr'), // آسيا 'CNY' => array('name' => 'اليوان الصيني', 'symbol' => '¥'), 'JPY' => array('name' => 'الين الياباني', 'symbol' => '¥'), 'KRW' => array('name' => 'الوون الكوري', 'symbol' => '₩'), 'INR' => array('name' => 'الروبية الهندية', 'symbol' => '₹'), 'PKR' => array('name' => 'الروبية الباكستانية', 'symbol' => 'Rs'), 'BDT' => array('name' => 'التاكا البنغلاديشي', 'symbol' => '৳'), 'IDR' => array('name' => 'الروبية الإندونيسية', 'symbol' => 'Rp'), 'MYR' => array('name' => 'الرينغيت الماليزي', 'symbol' => 'RM'), 'SGD' => array('name' => 'الدولار السنغافوري', 'symbol' => 'S$'), 'THB' => array('name' => 'الباهت التايلاندي', 'symbol' => '฿'), 'VND' => array('name' => 'الدونغ الفيتنامي', 'symbol' => '₫'), 'PHP' => array('name' => 'البيزو الفلبيني', 'symbol' => '₱'), 'HKD' => array('name' => 'الدولار الهونغ كونغي', 'symbol' => 'HK$'), 'TWD' => array('name' => 'الدولار التايواني', 'symbol' => 'NT$'), 'IRR' => array('name' => 'الريال الإيراني', 'symbol' => '﷼'), 'AFN' => array('name' => 'الأفغاني', 'symbol' => '؋'), 'KZT' => array('name' => 'التنغي الكازاخستاني', 'symbol' => '₸'), 'UZS' => array('name' => 'السوم الأوزبكي', 'symbol' => 'so\'m'), // أمريكا الشمالية 'USD' => array('name' => 'الدولار الأمريكي', 'symbol' => '$'), 'CAD' => array('name' => 'الدولار الكندي', 'symbol' => 'C$'), 'MXN' => array('name' => 'البيزو المكسيكي', 'symbol' => '$'), // أمريكا الجنوبية 'BRL' => array('name' => 'الريال البرازيلي', 'symbol' => 'R$'), 'ARS' => array('name' => 'البيزو الأرجنتيني', 'symbol' => '$'), 'CLP' => array('name' => 'البيزو التشيلي', 'symbol' => '$'), 'COP' => array('name' => 'البيزو الكولومبي', 'symbol' => '$'), 'PEN' => array('name' => 'السول البيروفي', 'symbol' => 'S/'), 'VES' => array('name' => 'البوليفار الفنزويلي', 'symbol' => 'Bs'), ); } /** * الحصول على النص التوضيحي */ public function get_caption($currency = 'EGP') { // الحصول على القالب من الإعدادات $template = GPTB_Database::get_setting('caption_template', ''); // إذا كان هناك قالب مخصص، استخدمه if (!empty($template)) { return $this->process_caption_template($template, $currency); } // وإلا استخدم القالب الافتراضي if (!isset($this->currencies[$currency])) { $currency = 'EGP'; } $currency_info = $this->currencies[$currency]; // المناطق الزمنية $timezone_data = $this->get_timezone_data($currency); $price_data = $this->fetch_price_data($currency); if (!$price_data) { return ''; } $currency_names = $this->get_currency_names(); $currency_name = isset($currency_names[$currency]) ? $currency_names[$currency]['name'] : $currency; $currency_symbol = isset($currency_names[$currency]) ? $currency_names[$currency]['symbol'] : ''; $caption = "💰 سعر أونصة الذهب يوم {$timezone_data['day_name']} {$timezone_data['day']} {$timezone_data['month']} {$timezone_data['year']}\n"; $caption .= "🕐 الساعة {$timezone_data['time']} (بتوقيت {$timezone_data['capital']})\n\n"; $caption .= "ب{$currency_name}:\n"; $caption .= "💵 " . number_format($price_data['ounce_price'], 2, '.', ',') . " {$currency_symbol}\n\n"; if ($price_data['ounce_usd'] > 0) { $caption .= "بالدولار:\n"; $caption .= "💵 $" . number_format($price_data['ounce_usd'], 2, '.', ',') . "\n\n"; } $caption .= "سعر الجرام:\n"; $caption .= "• عيار 24: " . number_format(round($price_data['price_24k']), 0, '', ',') . " {$currency_symbol}\n"; $caption .= "• عيار 21: " . number_format(round($price_data['price_21k']), 0, '', ',') . " {$currency_symbol}\n"; $caption .= "• عيار 18: " . number_format(round($price_data['price_18k']), 0, '', ',') . " {$currency_symbol}\n"; $caption .= "• جنيه الذهب: " . number_format(round($price_data['gold_pound']), 0, '', ',') . " {$currency_symbol}\n\n"; $caption .= "⚠️ ملاحظة: هذه أسعار عالمية، قد تختلف قليلا عن السوق المحلي.\n\n"; $caption .= "@instantgoldprice"; return $caption; if (!isset($this->currencies[$currency])) { $currency = 'EGP'; } $currency_info = $this->currencies[$currency]; // المناطق الزمنية $timezones = array( 'EGP' => 'Africa/Cairo', 'SAR' => 'Asia/Riyadh', 'AED' => 'Asia/Dubai', 'KWD' => 'Asia/Kuwait', 'BHD' => 'Asia/Bahrain', 'QAR' => 'Asia/Qatar', 'OMR' => 'Asia/Muscat', 'IQD' => 'Asia/Baghdad', 'JOD' => 'Asia/Amman', 'LBP' => 'Asia/Beirut', 'TND' => 'Africa/Tunis', 'DZD' => 'Africa/Algiers', 'MAD' => 'Africa/Casablanca', 'SDG' => 'Africa/Khartoum', 'TRY' => 'Europe/Istanbul', 'ILS' => 'Asia/Jerusalem', ); $capitals = array( 'EGP' => 'القاهرة', 'SAR' => 'الرياض', 'AED' => 'دبي', 'KWD' => 'الكويت', 'BHD' => 'المنامة', 'QAR' => 'الدوحة', 'OMR' => 'مسقط', 'IQD' => 'بغداد', 'JOD' => 'عمّان', 'LBP' => 'بيروت', 'TND' => 'تونس', 'DZD' => 'الجزائر', 'MAD' => 'الرباط', 'SDG' => 'الخرطوم', 'TRY' => 'إسطنبول', 'ILS' => 'القدس', ); $timezone = isset($timezones[$currency]) ? $timezones[$currency] : 'UTC'; $capital_name = isset($capitals[$currency]) ? $capitals[$currency] : 'محلي'; $original_timezone = date_default_timezone_get(); date_default_timezone_set($timezone); $days_ar = array('الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'); $day_name = $days_ar[date('w')]; $months_ar = array('', 'يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'); $month_name = $months_ar[(int)date('n')]; $local_time = date('H:i'); $local_date = date('d'); $local_year = date('Y'); date_default_timezone_set($original_timezone); $price_data = $this->fetch_price_data($currency); if (!$price_data) { return ''; } $currency_names = array( 'EGP' => array('name' => 'الجنيه المصري', 'symbol' => 'ج.م'), 'SAR' => array('name' => 'الريال السعودي', 'symbol' => 'ر.س'), 'AED' => array('name' => 'الدرهم الإماراتي', 'symbol' => 'د.إ'), 'KWD' => array('name' => 'الدينار الكويتي', 'symbol' => 'د.ك'), 'BHD' => array('name' => 'الدينار البحريني', 'symbol' => 'د.ب'), 'QAR' => array('name' => 'الريال القطري', 'symbol' => 'ر.ق'), 'OMR' => array('name' => 'الريال العماني', 'symbol' => 'ر.ع'), 'IQD' => array('name' => 'الدينار العراقي', 'symbol' => 'د.ع'), 'JOD' => array('name' => 'الدينار الأردني', 'symbol' => 'د.أ'), 'LBP' => array('name' => 'الليرة اللبنانية', 'symbol' => 'ل.ل'), 'TND' => array('name' => 'الدينار التونسي', 'symbol' => 'د.ت'), 'DZD' => array('name' => 'الدينار الجزائري', 'symbol' => 'د.ج'), 'MAD' => array('name' => 'الدرهم المغربي', 'symbol' => 'د.م'), 'SDG' => array('name' => 'الجنيه السوداني', 'symbol' => 'ج.س'), 'TRY' => array('name' => 'الليرة التركية', 'symbol' => '₺'), 'ILS' => array('name' => 'الشيكل الإسرائيلي', 'symbol' => '₪'), ); $currency_name = isset($currency_names[$currency]) ? $currency_names[$currency]['name'] : $currency; $currency_symbol = isset($currency_names[$currency]) ? $currency_names[$currency]['symbol'] : ''; $caption = "💰 سعر أونصة الذهب يوم {$day_name} {$local_date} {$month_name} {$local_year}\n"; $caption .= "🕐 الساعة {$local_time} (بتوقيت {$capital_name})\n\n"; $caption .= "ب{$currency_name}:\n"; $caption .= "💵 " . number_format($price_data['ounce_price'], 2, '.', ',') . " {$currency_symbol}\n\n"; if ($price_data['ounce_usd'] > 0) { $caption .= "بالدولار:\n"; $caption .= "💵 $" . number_format($price_data['ounce_usd'], 2, '.', ',') . "\n\n"; } $caption .= "سعر الجرام:\n"; $caption .= "• عيار 24: " . number_format(round($price_data['price_24k']), 0, '', ',') . " {$currency_symbol}\n"; $caption .= "• عيار 21: " . number_format(round($price_data['price_21k']), 0, '', ',') . " {$currency_symbol}\n"; $caption .= "• عيار 18: " . number_format(round($price_data['price_18k']), 0, '', ',') . " {$currency_symbol}\n"; $caption .= "• جنيه الذهب: " . number_format(round($price_data['gold_pound']), 0, '', ',') . " {$currency_symbol}\n\n"; $caption .= "⚠️ ملاحظة: هذه أسعار عالمية، قد تختلف قليلا عن السوق المحلي.\n\n"; $caption .= "@instantgoldprice"; return $caption; } /** * التحقق من أن الخط قابل للرسم عبر GD */ private function is_font_renderable($font_path) { if (!is_string($font_path) || $font_path === '' || !file_exists($font_path)) { return false; } if (!function_exists('imagettfbbox')) { return false; } $bbox = @imagettfbbox(18, 0, $font_path, '123ABC'); return is_array($bbox) && count($bbox) >= 8; } /** * هاش بسيط للألوان المطبقة لضمان صلاحية الكاش */ private function get_colors_cache_hash() { if (is_array($this->custom_colors)) { return md5(wp_json_encode($this->custom_colors)); } $settings = array( GPTB_Database::get_setting('color_bg', '#FEFDF8'), GPTB_Database::get_setting('color_primary', '#FF9F00'), GPTB_Database::get_setting('color_text_dark', '#333333'), GPTB_Database::get_setting('color_text_light', '#787878'), ); return md5(implode('|', $settings)); } /** * جلب صورة ثنائية من transient cache */ private function get_cached_image_binary($cache_key) { if (!function_exists('get_transient')) { return false; } $transient_key = 'gptb_img_' . md5($cache_key); $payload = get_transient($transient_key); if (!is_array($payload) || empty($payload['data'])) { return false; } $raw = base64_decode($payload['data'], true); return ($raw !== false && $raw !== '') ? $raw : false; } /** * حفظ الصورة الثنائية في transient cache */ private function set_cached_image_binary($cache_key, $image_data, $ttl_seconds = 45) { if (!function_exists('set_transient') || !is_string($image_data) || $image_data === '') { return; } $transient_key = 'gptb_img_' . md5($cache_key); set_transient($transient_key, array('data' => base64_encode($image_data)), max(10, (int) $ttl_seconds)); } /** * رسم مستطيل بزوايا مدورة */ private function draw_rounded_rectangle($image, $x, $y, $width, $height, $radius, $color) { // التأكد من أن نصف القطر لا يتجاوز نصف العرض أو الارتفاع $radius = min($radius, floor($width / 2), floor($height / 2)); // المستطيل الرئيسي (الوسط) imagefilledrectangle($image, $x + $radius, $y, $x + $width - $radius, $y + $height, $color); imagefilledrectangle($image, $x, $y + $radius, $x + $width, $y + $height - $radius, $color); // الزوايا المدورة (دوائر) imagefilledellipse($image, $x + $radius, $y + $radius, $radius * 2, $radius * 2, $color); imagefilledellipse($image, $x + $width - $radius, $y + $radius, $radius * 2, $radius * 2, $color); imagefilledellipse($image, $x + $radius, $y + $height - $radius, $radius * 2, $radius * 2, $color); imagefilledellipse($image, $x + $width - $radius, $y + $height - $radius, $radius * 2, $radius * 2, $color); } } Page Not Found - سعر الذهب اليوم في السعودية

404

Page Not Found

Sorry, the page you are looking for could not be found.

Go to Homepage