Commit dfe03af4 authored by leymannx's avatar leymannx Committed by RenatoG

Issue #3020155 by leymannx, RenatoG: Add config to disable RobotsTxt support

parent e1da3d9a
......@@ -314,6 +314,12 @@ function xmlsitemap_settings_form($form, &$form_state) {
'#description' => t('When enabled, this will fetch all URL aliases at once instead of one at a time during sitemap generation. For medium or large sites, it is recommended to disable this feature as it uses a lot of memory.'),
'#default_value' => variable_get('xmlsitemap_prefetch_aliases', 1),
);
$form['xmlsitemap_robotstxt'] = array(
'#type' => 'checkbox',
'#title' => t('Enable RobotsTxt support'),
'#description' => t('When enabled, this will add all sitemaps to the robots.txt generated by <a href="@drupal-robotstxt">the RobotsTxt</a>.', array('@drupal-robotstxt' => 'https://www.drupal.org/project/robotstxt')),
'#default_value' => variable_get('xmlsitemap_robotstxt', 1),
);
$form['advanced'] = array(
'#type' => 'fieldset',
......
......@@ -284,9 +284,11 @@ function xmlsitemap_modules_disabled(array $modules) {
* Implements hook_robotstxt().
*/
function xmlsitemap_robotstxt() {
if ($sitemap = xmlsitemap_sitemap_load_by_context()) {
$robotstxt[] = 'Sitemap: ' . url($sitemap->uri['path'], $sitemap->uri['options']);
return $robotstxt;
if (variable_get('xmlsitemap_robotstxt', 1)) {
if ($sitemap = xmlsitemap_sitemap_load_by_context()) {
$robotstxt[] = 'Sitemap: ' . url($sitemap->uri['path'], $sitemap->uri['options']);
return $robotstxt;
}
}
}
......@@ -302,6 +304,7 @@ function xmlsitemap_variables() {
'xmlsitemap_generated_last' => 0,
'xmlsitemap_xsl' => 1,
'xmlsitemap_prefetch_aliases' => 1,
'xmlsitemap_robotstxt' => 1,
'xmlsitemap_chunk_size' => 'auto',
'xmlsitemap_batch_limit' => 100,
'xmlsitemap_path' => 'xmlsitemap',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment