I have a subfolder WP installation. It serves multiple domains, which are linked to the same folder. The requested domain is received in wp-config.php (from the $_SERVER variable) and used to define WP_SITEURL, WP_HOME and DOMAIN_CURRENT_SITE. So we can open the same both from domain.com and domain.co.uk. I need to add the link to XML sitemap to robots.txt and, obviously, it should be different depending on the domain requested.
There is the do_robots() native WP function which generates robots.txt for multisite and allows changing it dynamically using its robots_txt action from theme's functions.php file or from a plugin. However, it does not seem the case for a single-site installation.
I can call do_robots from theme functions to generate the content and write to the robots.txt file but am not sure where I should hook it.
The question is: how do I have the robots.txt dynamically generated or have the possibility to change its content with hooks from theme functions.php?