call( 'getUpdates', array( 'offset' => (int) get_option( self::OFFSET_OPTION, 0 ), 'timeout' => 0, 'limit' => 50, 'allowed_updates' => array( 'message' ), ) ); if ( ! $result['ok'] || ! is_array( $result['result'] ) ) { return 0; } $handled = 0; foreach ( $result['result'] as $update ) { if ( ! is_array( $update ) || ! isset( $update['update_id'] ) ) { continue; } update_option( self::OFFSET_OPTION, (int) $update['update_id'] + 1, false ); try { Updates_Handler::handle( $update ); } catch ( \Throwable $e ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- surfaced to the site's own error log only. error_log( 'Orderchirp: could not handle a Telegram update: ' . $e->getMessage() ); } ++$handled; } return $handled; } }