tiktok_get_dial_code($country_code); // 3. Apply the '0' prefix and dial code logic if (strpos($phone, '0') === 0) { $phone = $dial . substr($phone, 1); } if (strpos($phone, $dial) !== 0) { $phone = $dial . $phone; } return '+' . $phone; } /** * Formats phone numbers to strict E.164 standard. * Logic migrated from the original PXSYNC_Tracker. */ public static function format_and_hash_phone( $phone, $country_code = '' ) { if ( empty( $phone ) ) return ''; // 1. Remove all non-digits $phone = preg_replace('/\D/', '', $phone); // 2. Get dial code (using the helper method from Tracker) $dial = PXSYNC_Tracker::get_instance()->tiktok_get_dial_code($country_code); // 3. Apply the '0' prefix and dial code logic if (strpos($phone, '0') === 0) { $phone = $dial . substr($phone, 1); } if (strpos($phone, $dial) !== 0) { $phone = $dial . $phone; } return self::hash( '+' . $phone ); } }