You are underestimating the complexity of robots file handling in WordPress. The presence of physical file is one of two cases.
If physical file is not present during template load is_robots()
checks is performed and in positive case do_robots()
runs, generating and serving the “file” on the fly.
Just going ahead and creating robots.txt
in arbitrary site might very well wreck havoc with related code that is making use of virtual file and hooks in it.
Answering direct question — I am not sure which goals you are pursuing by this functionality so it is a little hard to tell what would work best for timing. The simples might be to run it on visiting theme’s options page (in same way as visiting native permalink settings performs permalink flush).
Related Posts:
- get_option() vs get_theme_mod(): Why is one slower?
- Using update_option() and get_option() is echoing escaped strings
- Theme Options page with tabs
- Outputting results from select box option in options panel
- Display user HTML on website
- Need help understanding/coding with Settings API
- get option framework options returns Call to undefined function of_get_option()
- How to set a default theme option after installing theme?
- WordPress theme options framework, I can’t read them in my templates
- Multiple options in the options_value field of the wp_options table
- Theme options are they necessary
- How do I display a WP Option from an array?
- Blogname and Blogdescription in Pagelines DMS Options Panel
- What should I use to store options for a single blog on a network site?
- Delete Transient when clicking ‘Save Changes’ on options page
- Changing the layout of a custom options page
- Slightly modified options framework Colour picker
- wordpress theme option in other templates
- wp_editor() fields on Theme Options Page not saving
- Adding a checkbox to the theme customizer
- Adding a description to theme customizer controls
- How To Add New Option Types To Option Tree?
- Best practices for a Style/CSS based theme options page?
- Theme Options Panels, What are some good examples from Frameworks or Premium Themes? [closed]
- Submenu pages delete settings from options array when saved
- Site Title and Tagline in Theme Options Page
- Where are a theme’s options stored and can I export them to be imported into freshly installed themes?
- Can I install Analytics before deciding on a theme?
- Options Framework options not being output
- Editor role cannot save custom theme options
- Two Ways Of Creating WordPress Options Pages
- WordPress Nonce and check admin referer help needed
- Upload multiple images via theme options [closed]
- Save Theme Options (options.php) From The Frontend
- Separate backend “Widgets” page for each language
- Theme options WP Editor
- How to mark an option as selected
- Is there a reliable way to keep track of how long a WordPress theme has been active?
- Can’t save options
- How to add an alternative style sheet as a theme option?
- Disable image resizing on specific upload fields
- Put standard wordpress options into a theme options panel?
- How can I get my options in json response?
- Use of check_admin_referer with theme options and options.php
- WordPress custom options storing?
- How can I make my options in an array and store theme in WP options one DB row?
- Getting the ID of header image, even when set to random
- Theme Options page not saving data correctly
- Getting error to display radio button value in General Settings page
- Error: options page not found
- Create an Options page with two image upload fields
- Only allow site url in text field using wp_kses/wp_filter_nohtml_kses?
- Additional custom header image
- Efficiency of wp_options vs a new table
- Options Theme – WordPress [closed]
- How to reset (clear) theme settings
- Settings API settings section not appearing
- Is there a function to add additional options to the Twentyeleven option page?
- How to save custom settings api fields with custom section fuction
- How to get of_get_option() inside the inc folder file
- Issue on Checkbox with Custom Option Page
- Display and hide content using checkbox in Options Framework Theme
- How do I remove the page listing menu in the header in the Twenty Ten Theme?
- How to use WP Theme Option: Custom_Backgrounds on specific element?
- WP Page Options Array
- How can I create a rearrangeable list of items like OptionTree offers with the Theme Customization API?
- WordPress Theme Settings Page
- Bring page from sub menu to admin menu in option tree
- Update Specific Key Value in Complex `wp_options` object
- How to load dynamic option with ajax
- How to get functions.php to talk to options.php
- Options Framework not saving options correctly
- How to use checked() function with multiple check box group? How to properly sanitize that checkbox group?
- Admin menus and submenus
- WordPress Options Framework, add to main menu not appearance menu
- Tabbed theme options query about add_settings_section callback function
- WordPress karma theme shortcodes not working
- WordPress built-in Custom Background
- Weird undefined index: id,std notices. How to fix it?
- Splitting an eCommerce store from the WordPress Theme
- display category name based on its equivalent id
- How do I have my widgets in a Sidebar for my http://localhost/wordpress/
- Show multiple option in URL with Redux framework in front end
- Do not want to display random category. Want to exclude a few or make post show only the category I want [closed]
- Theme options on CPT
- Can’t save multiple sections on one page with register_setting
- Echo content based on current tabbed page in theme options
- Build Form on Dashboard
- How to make a hyperlink conditional according to whether you are logged in or not
- Set option to show the slider in post – WP
- Trouble saving wp_dropdown_pages()
- Theme Option’s Save Button is not working
- Notice: Undefined index: in options-framework.php
- Is it good idea to combine Options FrameWork with Hybrid Core Framework
- How to support special characters in text field?
- Multiple Custom Headers
- Can I call Options Framework in footer.php?
- Where to add the code for an outer container in a theme?
- Options.php loop won’t show!
- Theme Options wp_editor breaks with 6.0.2 update