Add body class depending on current URL I have an URL textarea and I want to add a body class if the current URL is one of those that the user has input in the textarea.

This is my current code:

function MYTHEME_form_system_theme_settings_alter(&amp;$form, &amp;$form_state, $form_id = NULL) {
  $form['head_footer_hiding_urls'] = [
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('Hide header and footer on specific url\'s'),
    '#description' =&gt; t('Specific url\'s to hide header and footer'),
    '#collabsible' =&gt; TRUE,
    '#collabsed' =&gt; TRUE,
  ];
  $form['head_footer_hiding_urls']['url'] = [
    '#type' =&gt; 'textarea',
    '#title' =&gt; t('Set url\'s'),
    '#description' =&gt; t('Set url\'s to hide header and footer,
 you can only write one url at a line.'),
    '#default_value' =&gt; (theme_get_setting('url') != NULL) ? theme_get_setting('url') : '',
  ];

  return $form;
}


How can I do that?
I found a solution, I wrote this in a preprocess function:

function THEME_preprocess_html(&amp;$vars) {
  // Add body class if current url is configured to have header/footer hidden.
  $urls_to_test = array(
    $_GET['q'],
    drupal_get_path_alias($_GET['q']),
  );
  foreach (explode("\n", theme_get_setting('head_footer_hiding_urls')) as $url) {
    if (in_array($url, $urls_to_test)) {
      $vars['classes_array'][] = 'theme-hide-header-footer';
    }
  }
}