You are here

function at_tools_flush_caches in AT Tools 7

File

./at_tools.module, line 6

Code

function at_tools_flush_caches() {
  if (variable_get('preprocess_css', '') == 1) {

    // Nicked strait from commons_install() with mods to get
    // all enabled AT subthemes since we don't know which ones to clear.
    $themes_array = array(
      'adaptivetheme',
    );
    $themes = list_themes(TRUE);
    foreach ($themes as $key => $theme_name) {
      if ($key == 'adaptivetheme') {
        foreach ($theme_name->sub_themes as $sub_theme_key => $sub_theme_name) {
          $array[] = $sub_theme_key;
        }
      }
      foreach ($array as $name) {
        if ($name == $key) {
          if ($theme_name->status == 1) {
            $themes_array[] = $key;
          }
        }
      }
    }
    module_load_include('inc', 'system', 'system.admin');
    foreach ($themes_array as $theme_name) {
      $form_state = form_state_defaults();
      $form_state['build_info']['args'][0] = $theme_name;
      $form_state['values'] = array();
      drupal_form_submit('system_theme_settings', $form_state);
    }
  }
}